diff --git a/.github/actions/setup_python/action.yml b/.github/actions/setup_python/action.yml index 0bbbf45522e0cd..c076c5156da039 100644 --- a/.github/actions/setup_python/action.yml +++ b/.github/actions/setup_python/action.yml @@ -26,16 +26,16 @@ 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 + run: apt-get update && apt-get install -y ca-certificates software-properties-common - if: ${{ runner.os == 'Linux' && runner.arch == 'ARM64' }} - name: Setup sudo + name: Setup sudo and python3 shell: bash - run: apt-get update && apt-get install -y sudo # Needed for the deadsnakes action + run: apt-get update && apt-get install -y sudo python3 # Needed for the deadsnakes action - if: ${{ runner.os == 'Linux' && runner.arch == 'ARM64' }} name: Setup Python ${{ inputs.version }} - uses: deadsnakes/action@v3.0.1 + uses: akashchi/deadsnakes-action@f01521a69eee61eaca3a34440bea3ce838317846 with: python-version: ${{ inputs.version }} diff --git a/.github/workflows/cleanup_pip_cache.yml b/.github/workflows/cleanup_pip_cache.yml index eaf8d0ec743f5a..cd66e1150c3ef1 100644 --- a/.github/workflows/cleanup_pip_cache.yml +++ b/.github/workflows/cleanup_pip_cache.yml @@ -1,12 +1,13 @@ name: Cleanup PIP caches on: + workflow_dispatch: schedule: # at 00:00 on the 1st day of every month - cron: '0 0 1 * *' jobs: Cleanup_PIP_Caches: - runs-on: aks-linux-2-cores + runs-on: aks-linux-2-cores-8gb container: image: openvinogithubactions.azurecr.io/dockerhub/ubuntu:20.04 volumes: diff --git a/.github/workflows/job_cpu_functional_tests.yml b/.github/workflows/job_cpu_functional_tests.yml new file mode 100644 index 00000000000000..b1f2e6bbf08b59 --- /dev/null +++ b/.github/workflows/job_cpu_functional_tests.yml @@ -0,0 +1,124 @@ +name: CPU functional tests + +on: + workflow_call: + inputs: + runner: + description: 'Machine on which the tests would run' + type: string + required: true + image: + description: 'Docker image in which the tests would run' + type: string + required: false + default: null + +jobs: + CPU_Functional_Tests: + name: CPU functional tests + timeout-minutes: 25 + runs-on: ${{ inputs.runner }} + container: + image: ${{ inputs.image }} + defaults: + run: + shell: bash + env: + DEBIAN_FRONTEND: noninteractive # to prevent apt-get from waiting user input + INSTALL_DIR: ${{ github.workspace }}/install + 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 + steps: + - name: Download OpenVINO package + uses: actions/download-artifact@v3 + with: + name: openvino_package + path: ${{ env.INSTALL_DIR }} + + - name: Download OpenVINO tests package + uses: actions/download-artifact@v3 + with: + name: openvino_tests + path: ${{ env.INSTALL_TEST_DIR }} + + # Needed as ${{ github.workspace }} is not working correctly when using Docker + - name: Setup Variables + run: | + echo "INSTALL_DIR=$GITHUB_WORKSPACE/install" >> "$GITHUB_ENV" + echo "INSTALL_TEST_DIR=$GITHUB_WORKSPACE/install/tests" >> "$GITHUB_ENV" + echo "PARALLEL_TEST_SCRIPT=$GITHUB_WORKSPACE/install/tests/functional_test_utils/layer_tests_summary/run_parallel.py" >> "$GITHUB_ENV" + echo "PARALLEL_TEST_CACHE=$GITHUB_WORKSPACE/install/tests/test_cache.lst" >> "$GITHUB_ENV" + + - name: Extract OpenVINO packages + run: | + pushd $INSTALL_DIR + tar -xzf openvino_package.tar.gz -C $INSTALL_DIR + popd + + pushd $INSTALL_TEST_DIR + tar -xzf openvino_tests.tar.gz -C $INSTALL_DIR + popd + + - name: Install OpenVINO dependencies (Linux) + if: runner.os == 'Linux' + run: $INSTALL_DIR/install_dependencies/install_openvino_dependencies.sh -c=core -c=dev -c=gpu -y + + - name: Fetch setup_python action + uses: actions/checkout@v4 + with: + sparse-checkout: | + .github/actions/setup_python/action.yml + sparse-checkout-cone-mode: false + path: 'openvino' + + - name: Setup Python 3.11 + uses: ./openvino/.github/actions/setup_python + with: + version: '3.11' + should-setup-pip-paths: 'false' + self-hosted-runner: ${{ runner.os == 'Linux' }} + + - name: Install python dependencies for run_parallel.py + run: python3 -m pip install -r ${INSTALL_TEST_DIR}/functional_test_utils/layer_tests_summary/requirements.txt + + - name: Restore tests execution time + uses: actions/cache/restore@v3 + with: + path: ${{ env.PARALLEL_TEST_CACHE }} + key: ${{ runner.os }}-${{ runner.arch }}-tests-functional-cpu-stamp-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-${{ runner.arch }}-tests-functional-cpu-stamp + + - name: Intel CPU plugin func tests (parallel) + run: | + # Needed as the Linux CC does not require setupvars to work + if [[ -f "${INSTALL_DIR}/setupvars.sh" ]]; then + source ${INSTALL_DIR}/setupvars.sh + fi + + python3 ${PARALLEL_TEST_SCRIPT} -e ${INSTALL_TEST_DIR}/ov_cpu_func_tests -c ${PARALLEL_TEST_CACHE} -w ${INSTALL_TEST_DIR} -s suite -rf 0 -- --gtest_print_time=1 --gtest_filter=*smoke* + timeout-minutes: 20 + + - name: Save tests execution time + uses: actions/cache/save@v3 + if: github.ref_name == 'master' + with: + path: ${{ env.PARALLEL_TEST_CACHE }} + key: ${{ runner.os }}-${{ runner.arch }}-tests-functional-cpu-stamp-${{ github.sha }} + + - name: Upload Test Results + uses: actions/upload-artifact@v3 + if: ${{ !cancelled() }} + with: + name: test-results-functional-cpu + path: | + ${{ env.INSTALL_TEST_DIR }}/temp/*.log + ${{ env.INSTALL_TEST_DIR }}/logs/*.log + ${{ env.INSTALL_TEST_DIR }}/logs/failed/*.log + ${{ env.INSTALL_TEST_DIR }}/logs/crashed/*.log + ${{ env.INSTALL_TEST_DIR }}/logs/hanged/*.log + ${{ env.INSTALL_TEST_DIR }}/logs/interapted/*.log + ${{ env.INSTALL_TEST_DIR }}/logs/hash_table.csv + ${{ env.PARALLEL_TEST_CACHE }} + if-no-files-found: 'error' diff --git a/.github/workflows/job_cxx_unit_tests.yml b/.github/workflows/job_cxx_unit_tests.yml new file mode 100644 index 00000000000000..bc6157d3478a8c --- /dev/null +++ b/.github/workflows/job_cxx_unit_tests.yml @@ -0,0 +1,279 @@ +name: Samples + +on: + workflow_call: + inputs: + runner: + description: 'Machine on which the tests would run' + type: string + required: true + image: + description: 'Docker image in which the tests would run' + type: string + required: false + default: null + affected-components: + description: 'Components that are affected by changes in the commit defined by the Smart CI Action' + type: string + required: true + +jobs: + CXX_Unit_Tests: + name: C++ unit tests + timeout-minutes: 30 + runs-on: ${{ inputs.runner }} + container: + image: ${{ inputs.image }} + defaults: + run: + shell: bash + env: + DEBIAN_FRONTEND: noninteractive # to prevent apt-get from waiting user input + INSTALL_DIR: ${{ github.workspace }}/install + INSTALL_TEST_DIR: ${{ github.workspace }}/install/tests + steps: + - name: Download OpenVINO package + uses: actions/download-artifact@v3 + with: + name: openvino_package + path: ${{ env.INSTALL_DIR }} + + - name: Download OpenVINO tests package + uses: actions/download-artifact@v3 + with: + name: openvino_tests + path: ${{ env.INSTALL_TEST_DIR }} + + # Needed as ${{ github.workspace }} is not working correctly when using Docker + - name: Setup Variables + run: | + echo "INSTALL_DIR=$GITHUB_WORKSPACE/install" >> "$GITHUB_ENV" + echo "INSTALL_TEST_DIR=$GITHUB_WORKSPACE/install/tests" >> "$GITHUB_ENV" + + - name: Extract OpenVINO packages + run: | + pushd $INSTALL_DIR + tar -xzf openvino_package.tar.gz -C $INSTALL_DIR + popd + pushd $INSTALL_TEST_DIR + tar -xzf openvino_tests.tar.gz -C $INSTALL_DIR + popd + + - name: Install OpenVINO dependencies (Linux) + if: runner.os == 'Linux' + run: $INSTALL_DIR/install_dependencies/install_openvino_dependencies.sh -c=core -c=dev -c=gpu -y + + # + # Tests + # + + - name: OpenVINO Core Unit Tests + if: fromJSON(inputs.affected-components).Core.test + run: | + source ${INSTALL_DIR}/setupvars.sh + ${INSTALL_TEST_DIR}/ov_core_unit_tests --gtest_print_time=1 --gtest_filter=-*IE_GPU* \ + --gtest_output=xml:${INSTALL_TEST_DIR}/TEST-OVCoreUT.xml + + - name: OpenVINO Inference Functional Tests + if: fromJSON(inputs.affected-components).inference.test + run: | + source ${INSTALL_DIR}/setupvars.sh + ${INSTALL_TEST_DIR}/ov_inference_functional_tests --gtest_print_time=1 \ + --gtest_output=xml:${INSTALL_TEST_DIR}/TEST-InferenceFunc.xml + + - name: OpenVINO Inference Unit Tests + if: fromJSON(inputs.affected-components).inference.test + run: | + source ${INSTALL_DIR}/setupvars.sh + ${INSTALL_TEST_DIR}/ov_inference_unit_tests --gtest_print_time=1 \ + --gtest_output=xml:${INSTALL_TEST_DIR}/TEST-InferenceUnit.xml + + - name: Low Precision Transformations Tests + if: fromJSON(inputs.affected-components).LP_transformations.test + run: | + source ${INSTALL_DIR}/setupvars.sh + + ${INSTALL_TEST_DIR}/ov_lp_transformations_tests --gtest_print_time=1 \ + --gtest_output=xml:${INSTALL_TEST_DIR}/TEST-LpTransformations.xml + + - name: OpenVINO Conditional compilation tests + if: fromJSON(inputs.affected-components).Core.test + run: | + source ${INSTALL_DIR}/setupvars.sh + ${INSTALL_TEST_DIR}/ov_conditional_compilation_tests --gtest_print_time=1 \ + --gtest_output=xml:${INSTALL_TEST_DIR}/TEST-ConditionalCompilation.xml + + - name: IR frontend tests + if: fromJSON(inputs.affected-components).IR_FE.test + run: | + source ${INSTALL_DIR}/setupvars.sh + ${INSTALL_TEST_DIR}/ov_ir_frontend_tests --gtest_print_time=1 \ + --gtest_output=xml:${INSTALL_TEST_DIR}/TEST-IRFrontend.xml + + - name: PaddlePaddle frontend tests + run: | + source ${INSTALL_DIR}/setupvars.sh + ${INSTALL_TEST_DIR}/paddle_tests --gtest_print_time=1 \ + --gtest_output=xml:${INSTALL_TEST_DIR}/TEST-PaddleTests.xml + + - name: ONNX frontend tests + if: ${{ fromJSON(inputs.affected-components).ONNX_FE.test && runner.arch != 'ARM64' }} # Ticket for macOS ARM64: 122663, for Linux ARM64: 126280 + run: | + source ${INSTALL_DIR}/setupvars.sh + ${INSTALL_TEST_DIR}/ov_onnx_frontend_tests --gtest_print_time=1 \ + --gtest_filter=-*IE_GPU* \ + --gtest_output=xml:${INSTALL_TEST_DIR}/TEST-ONNXFrontend.xml + + - name: TensorFlow Common frontend tests + if: fromJSON(inputs.affected-components).TF_FE.test || + fromJSON(inputs.affected-components).TFL_FE.test && + (runner.os != 'macOS' && runner.arch != 'ARM64') + run: | + source ${INSTALL_DIR}/setupvars.sh + ${INSTALL_TEST_DIR}/ov_tensorflow_common_tests --gtest_print_time=1 \ + --gtest_output=xml:${INSTALL_TEST_DIR}/TEST-TensorFlowCommonFrontend.xml + + - name: TensorFlow frontend tests + if: fromJSON(inputs.affected-components).TF_FE.test + run: | + source ${INSTALL_DIR}/setupvars.sh + + ${INSTALL_TEST_DIR}/ov_tensorflow_frontend_tests --gtest_print_time=1 \ + --gtest_output=xml:${INSTALL_TEST_DIR}/TEST-TensorFlowFrontend.xml + + - name: TensorFlow Lite frontend tests + if: fromJSON(inputs.affected-components).TFL_FE.test + run: | + source ${INSTALL_DIR}/setupvars.sh + ${INSTALL_TEST_DIR}/ov_tensorflow_lite_frontend_tests --gtest_print_time=1 \ + --gtest_output=xml:${INSTALL_TEST_DIR}/TEST-TensorFlowLiteFrontend.xml + + - name: Transformations func tests + if: ${{ fromJSON(inputs.affected-components).transformations.test && runner.arch != 'ARM64' }} # Ticket: 126281 + run: | + source ${INSTALL_DIR}/setupvars.sh + + ${INSTALL_TEST_DIR}/ov_transformations_tests --gtest_print_time=1 \ + --gtest_output=xml:${INSTALL_TEST_DIR}/TEST-Transformations.xml + + - name: Legacy Transformations func tests + if: fromJSON(inputs.affected-components).GNA.test && + (runner.os != 'macOS' && runner.arch != 'ARM64') + run: | + source ${INSTALL_DIR}/setupvars.sh + ${INSTALL_TEST_DIR}/ov_legacy_transformations_tests --gtest_print_time=1 \ + --gtest_output=xml:${INSTALL_TEST_DIR}/TEST-LegacyTransformations.xml + + - name: Inference Engine 1.0 unit tests + if: fromJSON(inputs.affected-components).GNA.test && + (runner.os != 'macOS' && runner.arch != 'ARM64') + run: | + source ${INSTALL_DIR}/setupvars.sh + ${INSTALL_TEST_DIR}/InferenceEngineUnitTests --gtest_print_time=1 \ + --gtest_output=xml:${INSTALL_TEST_DIR}/TEST-InferenceEngineUnitTests.xml + + - name: Common test utils tests + run: | + source ${INSTALL_DIR}/setupvars.sh + ${INSTALL_TEST_DIR}/ov_util_tests --gtest_print_time=1 \ + --gtest_output=xml:${INSTALL_TEST_DIR}/TEST-CommonUtilTests.xml + + - name: Snippets func tests + if: fromJSON(inputs.affected-components).CPU.test + run: | + source ${INSTALL_DIR}/setupvars.sh + ${INSTALL_TEST_DIR}/ov_snippets_func_tests --gtest_print_time=1 \ + --gtest_output=xml:${INSTALL_TEST_DIR}/TEST-SnippetsFuncTests.xml + + - name: CPU plugin unit tests + if: fromJSON(inputs.affected-components).CPU.test + run: | + source ${INSTALL_DIR}/setupvars.sh + ${INSTALL_TEST_DIR}/ov_cpu_unit_tests --gtest_print_time=1 \ + --gtest_output=xml:${INSTALL_TEST_DIR}/TEST-CPUUnitTests.xml + + - name: ov_subgraphs_dumper_tests tests + run: | + source ${INSTALL_DIR}/setupvars.sh + ${INSTALL_TEST_DIR}/ov_subgraphs_dumper_tests --gtest_print_time=1 \ + --gtest_output=xml:${INSTALL_TEST_DIR}/TEST-ov_subgraphs_dumper_tests.xml + + - name: Template OpImpl tests + run: | + source ${INSTALL_DIR}/setupvars.sh + ${INSTALL_TEST_DIR}/ov_op_conformance_tests --gtest_print_time=1 --device=TEMPLATE --gtest_filter=*OpImpl*\ + --gtest_output=xml:${INSTALL_TEST_DIR}/TEST-OpImplTests.xml + + - name: AUTO unit tests + if: fromJSON(inputs.affected-components).AUTO.test + run: | + source ${INSTALL_DIR}/setupvars.sh + ${INSTALL_TEST_DIR}/ov_auto_unit_tests --gtest_print_time=1 \ + --gtest_output=xml:${INSTALL_TEST_DIR}/TEST-ov_auto_unit_tests.xml + + - name: AUTO func Tests + if: fromJSON(inputs.affected-components).AUTO.test + run: | + source ${{ env.INSTALL_DIR }}/setupvars.sh + ${{ env.INSTALL_TEST_DIR }}/ov_auto_func_tests --gtest_print_time=1 \ + --gtest_output=xml:${{ env.INSTALL_TEST_DIR }}/TEST-ov_auto_func_tests.xml + + - name: Template plugin func tests + if: fromJSON(inputs.affected-components).TEMPLATE.test + run: | + source ${INSTALL_DIR}/setupvars.sh + ${INSTALL_TEST_DIR}/ov_template_func_tests --gtest_print_time=1 \ + --gtest_filter=*smoke* \ + --gtest_output=xml:${INSTALL_TEST_DIR}/TEST-TemplateFuncTests.xml + + - name: Inference Engine C API tests + if: fromJSON(inputs.affected-components).C_API.test + run: | + source ${INSTALL_DIR}/setupvars.sh + ${INSTALL_TEST_DIR}/InferenceEngineCAPITests --gtest_print_time=1 \ + --gtest_output=xml:${INSTALL_TEST_DIR}/TEST-InferenceEngineCAPITests.xml + + - name: OpenVINO C API tests + if: fromJSON(inputs.affected-components).C_API.test + run: | + source ${INSTALL_DIR}/setupvars.sh + ${INSTALL_TEST_DIR}/ov_capi_test --gtest_print_time=1 \ + --gtest_output=xml:${INSTALL_TEST_DIR}/TEST-OpenVINOCAPITests.xml + + - name: AutoBatch unit tests + if: fromJSON(inputs.affected-components).AUTO_BATCH.test + run: | + source ${INSTALL_DIR}/setupvars.sh + ${INSTALL_TEST_DIR}/ov_auto_batch_unit_tests --gtest_output=xml:${INSTALL_TEST_DIR}/TEST-ov_auto_batch_unit_tests.xml + + - name: AutoBatch func tests + if: fromJSON(inputs.affected-components).AUTO_BATCH.test + run: | + source ${INSTALL_DIR}/setupvars.sh + ${INSTALL_TEST_DIR}/ov_auto_batch_func_tests --gtest_output=xml:${INSTALL_TEST_DIR}/TEST-ov_auto_batch_func_tests.xml + + - name: Proxy Plugin func tests + if: fromJSON(inputs.affected-components).PROXY.test + run: | + source ${INSTALL_DIR}/setupvars.sh + ${INSTALL_TEST_DIR}/ov_proxy_plugin_tests --gtest_print_time=1 --gtest_output=xml:${INSTALL_TEST_DIR}/TEST-OVProxyTests.xml + + - name: Hetero unit tests + if: fromJSON(inputs.affected-components).HETERO.test + run: | + source ${{ env.INSTALL_DIR }}/setupvars.sh + ${{ env.INSTALL_TEST_DIR }}/ov_hetero_unit_tests --gtest_print_time=1 --gtest_output=xml:${{ env.INSTALL_TEST_DIR }}/TEST-OVHeteroUnitTests.xml + + - name: Hetero func tests + if: fromJSON(inputs.affected-components).HETERO.test + run: | + source ${INSTALL_DIR}/setupvars.sh + ${INSTALL_TEST_DIR}/ov_hetero_func_tests --gtest_print_time=1 --gtest_output=xml:${INSTALL_TEST_DIR}/TEST-OVHeteroFuncTests.xml + + - name: Upload Test Results + uses: actions/upload-artifact@v3 + if: ${{ !cancelled() }} + with: + name: test-results-cpp + path: ${{ env.INSTALL_TEST_DIR }}/TEST*.xml + if-no-files-found: 'warn' diff --git a/.github/workflows/job_debian_packages.yml b/.github/workflows/job_debian_packages.yml new file mode 100644 index 00000000000000..f063a7734b8aec --- /dev/null +++ b/.github/workflows/job_debian_packages.yml @@ -0,0 +1,83 @@ +name: Debian Packages + +on: + workflow_call: + inputs: + runner: + description: 'Machine on which the tests would run' + type: string + required: true + image: + description: 'Docker image in which the tests would run' + type: string + required: false + default: null + +jobs: + Debian_Packages: + name: Debian Packages + runs-on: ${{ inputs.runner }} + container: + image: ${{ inputs.image }} + defaults: + run: + shell: bash + env: + DEBIAN_FRONTEND: noninteractive # to prevent apt-get from waiting user input + DEBIAN_PACKAGES_DIR: ${{ github.workspace }}/packages + steps: + + - name: Download OpenVINO debian packages + uses: actions/download-artifact@v3 + with: + name: openvino_debian_packages + path: ${{ env.DEBIAN_PACKAGES_DIR }} + + # Needed as ${{ github.workspace }} is not working correctly when using Docker + - name: Setup Variables + run: echo "DEBIAN_PACKAGES_DIR=$GITHUB_WORKSPACE/packages" >> "$GITHUB_ENV" + + - name: Install debian packages & check conflicts + run: | + apt-get update -y + + if [[ "${{ runner.arch }}" == "X64" ]]; then + # Install debian packages from previous release + apt-get install --no-install-recommends -y gnupg wget ca-certificates + wget https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB + apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB + echo "deb https://apt.repos.intel.com/openvino/2023 ubuntu20 main" | tee /etc/apt/sources.list.d/intel-openvino-2023.list + apt-get update -y + apt-get install -y openvino + fi + + # install our local one and make sure the conflicts are resolved + apt-get install --no-install-recommends -y dpkg-dev + dpkg-scanpackages . /dev/null | gzip -9c > Packages.gz + echo "deb [trusted=yes] file:${DEBIAN_PACKAGES_DIR} ./" | tee /etc/apt/sources.list.d/openvino-local.list + apt-get update -y + apt-get install openvino -y + working-directory: ${{ env.DEBIAN_PACKAGES_DIR }} + + - name: Test debian packages + run: | + /usr/share/openvino/samples/cpp/build_samples.sh + /usr/share/openvino/samples/c/build_samples.sh + + [[ "${{ runner.arch }}" == "X64" ]] && path_by_arch="intel64" || path_by_arch="aarch64" + ~/openvino_cpp_samples_build/$path_by_arch/Release/hello_query_device + + 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")' + + if [[ "${{ runner.arch }}" == "X64" ]]; then + 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.frontend import FrontEndManager; assert len(FrontEndManager().get_available_front_ends()) == 6' + benchmark_app --help + ovc --help diff --git a/.github/workflows/job_onnx_runtime.yml b/.github/workflows/job_onnx_runtime.yml new file mode 100644 index 00000000000000..5a6f5cb27eceae --- /dev/null +++ b/.github/workflows/job_onnx_runtime.yml @@ -0,0 +1,157 @@ +name: ONNX Runtime Integration + +on: + workflow_call: + inputs: + runner: + description: 'Machine on which the tests would run' + type: string + required: true + container: + description: 'JSON to be converted to the value of the "container" configuration for the job' + type: string + required: false + default: '{"image": null}' + sccache-azure-key-prefix: + description: 'Key prefix for the cache folder on the Azure' + type: string + required: true + +jobs: + ONNX_Runtime: + name: ONNX Runtime Integration + timeout-minutes: 60 + runs-on: ${{ inputs.runner }} + container: ${{ fromJSON(inputs.container) }} + defaults: + run: + shell: bash + env: + DEBIAN_FRONTEND: noninteractive # to prevent apt-get from waiting user input + OPENVINO_REPO: ${{ github.workspace }}/openvino + INSTALL_DIR: ${{ github.workspace }}/install + CMAKE_GENERATOR: 'Ninja Multi-Config' + CMAKE_CXX_COMPILER_LAUNCHER: sccache + CMAKE_C_COMPILER_LAUNCHER: sccache + SCCACHE_AZURE_KEY_PREFIX: ${{ inputs.sccache-azure-key-prefix }} + ONNX_RUNTIME_REPO: ${{ github.workspace }}/onnxruntime + ONNX_RUNTIME_UTILS: ${{ github.workspace }}/install/onnxruntime + ONNX_RUNTIME_BUILD_DIR: ${{ github.workspace }}/onnxruntime/build + steps: + - name: Download OpenVINO package + uses: actions/download-artifact@v3 + with: + name: openvino_package + path: ${{ env.INSTALL_DIR }} + + # Needed as ${{ github.workspace }} is not working correctly when using Docker + - name: Setup Variables + run: | + echo "OPENVINO_REPO=$GITHUB_WORKSPACE/openvino" >> "$GITHUB_ENV" + echo "INSTALL_DIR=$GITHUB_WORKSPACE/install" >> "$GITHUB_ENV" + echo "ONNX_RUNTIME_REPO=$GITHUB_WORKSPACE/onnxruntime" >> "$GITHUB_ENV" + echo "ONNX_RUNTIME_UTILS=$GITHUB_WORKSPACE/install/onnxruntime" >> "$GITHUB_ENV" + echo "ONNX_RUNTIME_BUILD_DIR=$GITHUB_WORKSPACE/onnxruntime/build" >> "$GITHUB_ENV" + + - name: Fetch install_build_dependencies.sh and setup_python action + uses: actions/checkout@v4 + with: + sparse-checkout: | + install_build_dependencies.sh + .github/actions/setup_python/action.yml + sparse-checkout-cone-mode: false + path: 'openvino' + + - name: Install git + run: | + apt-get update + apt-get install --assume-yes --no-install-recommends git ca-certificates + + - name: Setup Python ${{ env.PYTHON_VERSION }} + uses: ./openvino/.github/actions/setup_python + with: + version: '3.11' + should-setup-pip-paths: 'false' + + - name: Extract OpenVINO package + run: | + pushd ${INSTALL_DIR} + tar -xzf openvino_package.tar.gz -C ${INSTALL_DIR} + popd + + - name: Install OpenVINO dependencies + run: ${INSTALL_DIR}/install_dependencies/install_openvino_dependencies.sh -c=core -c=dev -y + + - name: Clone ONNX Runtime + run: | + branch=`tr -s '\n ' < ${ONNX_RUNTIME_UTILS}/version` + git clone --branch $branch --single-branch --recursive https://github.com/microsoft/onnxruntime.git ${ONNX_RUNTIME_REPO} + + # + # Tests + # + + - name: Install Build Dependencies + run: bash ${OPENVINO_REPO}/install_build_dependencies.sh + + - name: Install sccache + uses: mozilla-actions/sccache-action@v0.0.3 + with: + version: "v0.5.4" + + - name: Build Lin ONNX Runtime + run: | + source ${INSTALL_DIR}/setupvars.sh + + ${ONNX_RUNTIME_REPO}/build.sh \ + --config RelWithDebInfo \ + --use_openvino CPU_FP32 \ + --build_shared_lib \ + --parallel \ + --skip_tests \ + --compile_no_warning_as_error \ + --build_dir ${ONNX_RUNTIME_BUILD_DIR} + env: + CXXFLAGS: "-Wno-error=deprecated-declarations" + + - name: Show sccache stats + run: ${SCCACHE_PATH} --show-stats + + - name: Run onnxruntime_test_all + if: ${{ runner.arch != 'ARM64' }} # Ticket: 126277 + run: | + source ${INSTALL_DIR}/setupvars.sh + skip_tests=$(tr -s '\n ' ':' < ${ONNX_RUNTIME_UTILS}/skip_tests) + + ./onnxruntime_test_all --gtest_filter=-$skip_tests + working-directory: ${{ env.ONNX_RUNTIME_BUILD_DIR }}/RelWithDebInfo/RelWithDebInfo + + - name: Run onnxruntime_shared_lib_test + run: | + source ${INSTALL_DIR}/setupvars.sh + ./onnxruntime_shared_lib_test --gtest_filter=-CApiTest.test_custom_op_openvino_wrapper_library + working-directory: ${{ env.ONNX_RUNTIME_BUILD_DIR }}/RelWithDebInfo/RelWithDebInfo + + - name: Run onnxruntime_global_thread_pools_test + run: | + source ${INSTALL_DIR}/setupvars.sh + ./onnxruntime_global_thread_pools_test + working-directory: ${{ env.ONNX_RUNTIME_BUILD_DIR }}/RelWithDebInfo/RelWithDebInfo + + - name: Run onnxruntime_api_tests_without_env + run: | + source ${INSTALL_DIR}/setupvars.sh + ./onnxruntime_api_tests_without_env + working-directory: ${{ env.ONNX_RUNTIME_BUILD_DIR }}/RelWithDebInfo/RelWithDebInfo + + - name: Run pytorch-converted tests + run: | + source ${INSTALL_DIR}/setupvars.sh + ./onnx_test_runner "${ONNX_RUNTIME_REPO}/cmake/external/onnx/onnx/backend/test/data/pytorch-converted" + working-directory: ${{ env.ONNX_RUNTIME_BUILD_DIR }}/RelWithDebInfo/RelWithDebInfo + + - name: Run pytorch-operator tests + run: | + source ${INSTALL_DIR}/setupvars.sh + ./onnx_test_runner "${ONNX_RUNTIME_REPO}/cmake/external/onnx/onnx/backend/test/data/pytorch-operator" + working-directory: ${{ env.ONNX_RUNTIME_BUILD_DIR }}/RelWithDebInfo/RelWithDebInfo diff --git a/.github/workflows/job_python_unit_tests.yml b/.github/workflows/job_python_unit_tests.yml new file mode 100644 index 00000000000000..38b35d17623f38 --- /dev/null +++ b/.github/workflows/job_python_unit_tests.yml @@ -0,0 +1,323 @@ +name: Python unit tests + +on: + workflow_call: + inputs: + runner: + description: 'Machine on which the tests would run' + type: string + required: true + container: + description: 'JSON to be converted to the value of the "container" configuration for the job' + type: string + required: false + default: '{"image": null}' + affected-components: + description: 'Components that are affected by changes in the commit defined by the Smart CI Action' + type: string + required: true + +env: + PIP_CACHE_PATH: /mount/caches/pip/linux + PYTHON_VERSION: '3.11' + +jobs: + Python_Unit_Tests: + name: Python unit tests + timeout-minutes: 60 + runs-on: ${{ inputs.runner }} + container: ${{ fromJSON(inputs.container) }} + defaults: + run: + shell: bash + env: + DEBIAN_FRONTEND: noninteractive # to prevent apt-get from waiting user input + OPENVINO_REPO: ${{ github.workspace }}/openvino + INSTALL_DIR: ${{ github.workspace }}/install + INSTALL_TEST_DIR: ${{ github.workspace }}/install/tests + LAYER_TESTS_INSTALL_DIR: ${{ github.workspace }}/install/tests/layer_tests + steps: + - name: Download OpenVINO package + uses: actions/download-artifact@v3 + with: + name: openvino_package + path: ${{ env.INSTALL_DIR }} + + - name: Download OpenVINO tests package + uses: actions/download-artifact@v3 + with: + name: openvino_tests + path: ${{ env.INSTALL_TEST_DIR }} + + # Needed as ${{ github.workspace }} is not working correctly when using Docker + - name: Setup Variables + run: | + echo "OPENVINO_REPO=$GITHUB_WORKSPACE/openvino" >> "$GITHUB_ENV" + echo "INSTALL_DIR=$GITHUB_WORKSPACE/install" >> "$GITHUB_ENV" + echo "INSTALL_TEST_DIR=$GITHUB_WORKSPACE/install/tests" >> "$GITHUB_ENV" + echo "LAYER_TESTS_INSTALL_DIR=$GITHUB_WORKSPACE/install/tests/layer_tests" >> "$GITHUB_ENV" + + - name: Extract OpenVINO packages + run: | + pushd $INSTALL_DIR + tar -xzf openvino_package.tar.gz -C $INSTALL_DIR + popd + pushd $INSTALL_TEST_DIR + tar -xzf openvino_tests.tar.gz -C $INSTALL_DIR + popd + + - name: Install OpenVINO dependencies (Linux) + if: runner.os == 'Linux' + run: $INSTALL_DIR/install_dependencies/install_openvino_dependencies.sh -c=core -c=dev -y + + - name: Fetch setup_python action + uses: actions/checkout@v4 + with: + sparse-checkout: | + .github/actions/setup_python/action.yml + sparse-checkout-cone-mode: false + path: 'openvino' + + - name: Setup Python ${{ env.PYTHON_VERSION }} + uses: ./openvino/.github/actions/setup_python + with: + version: ${{ env.PYTHON_VERSION }} + pip-cache-path: ${{ runner.os == 'Linux' && env.PIP_CACHE_PATH || '' }} + should-setup-pip-paths: ${{ runner.os == 'Linux' }} + self-hosted-runner: ${{ runner.os == 'Linux' }} + + # + # Tests + # + + - name: Install OpenVINO Python wheels + run: | + # Install the core OV wheel + python3 -m pip install ${INSTALL_DIR}/tools/openvino-*.whl + + extras_to_install="caffe,kaldi,onnx,tensorflow2,pytorch" + + if [[ "${{ runner.arch }}" != "ARM64" ]]; then + extras_to_install="mxnet,$extras_to_install" + fi + + # Find and install OV dev wheel + pushd ${INSTALL_DIR}/tools + ov_dev_wheel_name=$(find . -name 'openvino_dev*.whl') + python3 -m pip install $ov_dev_wheel_name[$extras_to_install] + popd + + - name: Install Python API tests dependencies + run: | + # To enable pytest parallel features + python3 -m pip install pytest-xdist[psutil] + # For torchvision to OpenVINO preprocessing converter + python3 -m pip install -r ${INSTALL_TEST_DIR}/python/preprocess/torchvision/requirements.txt + + # TODO: replace with Python API tests requirements + python3 -m pip install -r ${INSTALL_TEST_DIR}/mo/requirements_dev.txt + + # + # Tests + # + + - name: Python API 1.0 Tests + # if: fromJSON(inputs.affected-components).Python_API.test # Ticket: 127101 + run: | + python3 -m pytest -s ${INSTALL_TEST_DIR}/pyngraph \ + --junitxml=${INSTALL_TEST_DIR}/TEST-Pyngraph.xml \ + --ignore=${INSTALL_TEST_DIR}/pyngraph/tests_compatibility/test_onnx/test_zoo_models.py \ + --ignore=${INSTALL_TEST_DIR}/pyngraph/tests_compatibility/test_onnx/test_backend.py + + - name: Python API 2.0 Tests + # if: ${{ fromJSON(inputs.affected-components).Python_API.test && runner.arch != 'ARM64' }} # Ticket: 126380, 127101 + run: | + # for 'template' extension + export LD_LIBRARY_PATH=${INSTALL_TEST_DIR}:$LD_LIBRARY_PATH + python3 -m pytest -sv ${INSTALL_TEST_DIR}/pyopenvino \ + --junitxml=${INSTALL_TEST_DIR}/TEST-Pyngraph.xml \ + --ignore=${INSTALL_TEST_DIR}/pyopenvino/tests/test_utils/test_utils.py + + - name: Model Optimizer unit tests + if: fromJSON(inputs.affected-components).MO.test + run: | + skip_filter='' + if [[ "${{ runner.os }}" != "Linux" ]] && [[ "${{ runner.arch }} != "ARM64" ]] || [[ "${{ runner.os }} != "macOS" ]]; then + # required for MxNet + apt-get install -y libgomp1 libquadmath0 + else + # Skips under Ticket: 122666 + skip_filter='--ignore-glob=**/mo/unit_tests/mo/front/mxnet/**' + fi + + python3 -m pytest -s ${INSTALL_TEST_DIR}/mo/unit_tests \ + --junitxml=${INSTALL_TEST_DIR}/TEST-ModelOptimizer.xml \ + "$skip_filter" + + - name: Python ONNX operators tests + if: fromJSON(inputs.affected-components).Python_API.test || + fromJSON(inputs.affected-components).ONNX_FE.test && runner.os != 'macOS' # Ticket: 123325 + run: | + # Skip test_onnx/test_zoo_models and test_onnx/test_backend due to long execution time - ONNX Model Zoo tests are run separately + python3 -m pytest -sv ${INSTALL_TEST_DIR}/onnx -k 'not cuda' \ + --junitxml=${INSTALL_TEST_DIR}/TEST-onnx_frontend.xml \ + --ignore=${INSTALL_TEST_DIR}/onnx/test_python/test_zoo_models.py + + - name: OVC unit tests + if: fromJSON(inputs.affected-components).MO.test + run: python3 -m pytest -s ${INSTALL_TEST_DIR}/ovc/unit_tests --junitxml=${INSTALL_TEST_DIR}/TEST-OpenVinoConversion.xml + + - name: Install Python Layer tests dependencies + run: | + # layer test requirements + python3 -m pip install -r ${LAYER_TESTS_INSTALL_DIR}/requirements.txt + + - name: MO Python API Tests + if: fromJSON(inputs.affected-components).MO.test + run: | + # Import 'test_utils' installed in '/tests/python/openvino' + export LD_LIBRARY_PATH=${PIP_INSTALL_PATH}/openvino/libs:$LD_LIBRARY_PATH + export PYTHONPATH=${INSTALL_TEST_DIR}/python + + if [[ "${{ runner.os }}" == "Linux" ]] && [[ "${{ runner.arch }}" == "ARM64" ]]; then + # Find gomp lib + GOMP_LIB=$(find "${PIP_INSTALL_PATH}/torch/lib/../../torch.libs/" -name '*libgomp-*so*') + export LD_PRELOAD=${GOMP_LIB} + fi + + python3 -m pytest ${LAYER_TESTS_INSTALL_DIR}/mo_python_api_tests --junitxml=${INSTALL_TEST_DIR}/TEST-test_mo_convert.xml + env: + TEST_DEVICE: CPU + TEST_PRECISION: FP16 + + - name: OVC Python API Tests + if: fromJSON(inputs.affected-components).MO.test + run: | + # Import 'test_utils' installed in '/tests/python/openvino' + export PYTHONPATH=${INSTALL_TEST_DIR}/python + export LD_LIBRARY_PATH=${PIP_INSTALL_PATH}/openvino/libs:$LD_LIBRARY_PATH + + if [[ "${{ runner.os }}" == "Linux" ]] && [[ "${{ runner.arch }}" == "ARM64" ]]; then + # Find gomp lib + GOMP_LIB=$(find "${PIP_INSTALL_PATH}/torch/lib/../../torch.libs/" -name '*libgomp-*so*') + export LD_PRELOAD=${GOMP_LIB} + fi + + python3 -m pytest ${LAYER_TESTS_INSTALL_DIR}/ovc_python_api_tests --junitxml=${INSTALL_TEST_DIR}/TEST-test_ovc_convert.xml + env: + TEST_DEVICE: CPU + TEST_PRECISION: FP16 + + - name: Python Frontend tests + if: fromJSON(inputs.affected-components).PyTorch_FE.test || + fromJSON(inputs.affected-components).PDPD_FE.test + run: | + # to allow 'libtest_builtin_extensions.so' to find 'libopenvino_onnx_frontend.so' + export LD_LIBRARY_PATH=${PIP_INSTALL_PATH}/openvino/libs:$LD_LIBRARY_PATH + python3 -m pytest ${LAYER_TESTS_INSTALL_DIR}/py_frontend_tests --junitxml=${INSTALL_TEST_DIR}/TEST-test_py_fontend.xml + + - name: PyTorch 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 -n logical -m precommit --junitxml=${INSTALL_TEST_DIR}/TEST-pytorch.xml + env: + TEST_DEVICE: CPU + TEST_PRECISION: FP32 + + - name: PyTorch torch.compile TORCHFX Layer Tests + if: ${{ fromJSON(inputs.affected-components).PyTorch_FE.test && runner.os != 'macOS' }} + run: | + python3 -m pytest ${LAYER_TESTS_INSTALL_DIR}/pytorch_tests -m precommit_fx_backend --junitxml=${INSTALL_TEST_DIR}/TEST-pytorch.xml + env: + TEST_DEVICE: CPU + TEST_PRECISION: FP32 + PYTORCH_TRACING_MODE: TORCHFX + + - name: PyTorch torch.compile TORCHSCRIPT Layer Tests + if: ${{ fromJSON(inputs.affected-components).PyTorch_FE.test && runner.os != 'macOS' }} + run: | + python3 -m pytest ${LAYER_TESTS_INSTALL_DIR}/pytorch_tests -m precommit_ts_backend --junitxml=${INSTALL_TEST_DIR}/TEST-pytorch.xml + env: + TEST_DEVICE: CPU + TEST_PRECISION: FP32 + PYTORCH_TRACING_MODE: TORCHSCRIPT + + - name: ONNX Layer Tests + if: fromJSON(inputs.affected-components).ONNX_FE.test + run: | + # requires 'unit_tests' from 'tools/mo' + export PYTHONPATH=${INSTALL_TEST_DIR}/mo:$PYTHONPATH + python3 -m pytest ${LAYER_TESTS_INSTALL_DIR}/onnx_tests -m "not launch_only_if_manually_specified and precommit" --junitxml=${INSTALL_TEST_DIR}/TEST-onnx.xml + env: + TEST_DEVICE: CPU + TEST_PRECISION: FP16 + + - name: TensorFlow 1 Layer Tests - TF FE + if: fromJSON(inputs.affected-components).TF_FE.test + run: | + # requires 'unit_tests' from 'mo' + export PYTHONPATH=${INSTALL_TEST_DIR}/mo + python3 -m pytest ${LAYER_TESTS_INSTALL_DIR}/tensorflow_tests/ --use_new_frontend -m precommit_tf_fe --junitxml=${INSTALL_TEST_DIR}/TEST-tf_fe.xml + env: + TEST_DEVICE: CPU + TEST_PRECISION: FP16 + + - name: TensorFlow 2 Layer Tests - TF FE + if: fromJSON(inputs.affected-components).TF_FE.test && runner.os != 'macOS' # Ticket: 123322 + run: | + # requires 'unit_tests' from 'mo' + export PYTHONPATH=${INSTALL_TEST_DIR}/mo + python3 -m pytest ${LAYER_TESTS_INSTALL_DIR}/tensorflow2_keras_tests/ --use_new_frontend -m precommit_tf_fe --junitxml=${INSTALL_TEST_DIR}/TEST-tf2_fe.xml + env: + TEST_DEVICE: CPU + TEST_PRECISION: FP16 + + - name: JAX Layer Tests - TF FE + if: ${{ fromJSON(inputs.affected-components).TF_FE.test && runner.arch != 'ARM64' }} + run: python3 -m pytest ${LAYER_TESTS_INSTALL_DIR}/jax_tests/ -m precommit --junitxml=${INSTALL_TEST_DIR}/TEST-jax.xml + env: + TEST_DEVICE: CPU + + - name: TensorFlow 1 Layer Tests - Legacy FE + if: fromJSON(inputs.affected-components).TF_FE.test + run: python3 -m pytest ${LAYER_TESTS_INSTALL_DIR}/tensorflow_tests/test_tf_Roll.py --ir_version=10 --junitxml=${INSTALL_TEST_DIR}/TEST-tf_Roll.xml + + - name: TensorFlow 2 Layer Tests - Legacy FE + if: fromJSON(inputs.affected-components).TF_FE.test + run: python3 -m pytest ${LAYER_TESTS_INSTALL_DIR}/tensorflow2_keras_tests/test_tf2_keras_activation.py --ir_version=11 -k "sigmoid" --junitxml=${INSTALL_TEST_DIR}/TEST-tf2_Activation.xml + env: + TEST_DEVICE: CPU + TEST_PRECISION: FP16 + + - name: TensorFlow Lite Layer Tests - TFL FE + if: fromJSON(inputs.affected-components).TFL_FE.test + run: python3 -m pytest ${LAYER_TESTS_INSTALL_DIR}/tensorflow_lite_tests/ --junitxml=${INSTALL_TEST_DIR}/TEST-tfl_fe.xml + env: + TEST_DEVICE: CPU + TEST_PRECISION: FP16 + + - name: Clone API snippets + if: runner.os != 'macOS' + uses: actions/checkout@v4 + with: + sparse-checkout: openvino/docs/snippets + path: ${{ env.OPENVINO_REPO }} + submodules: 'false' + + - name: Docs Python snippets + if: runner.os != 'macOS' + run: | + # to find 'snippets' module in docs + export PYTHONPATH=${OPENVINO_REPO}/docs + # for 'template' extension + export LD_LIBRARY_PATH=${INSTALL_TEST_DIR}:$LD_LIBRARY_PATH + python3 ${OPENVINO_REPO}/docs/snippets/main.py + + - name: Upload Test Results + uses: actions/upload-artifact@v3 + if: ${{ !cancelled() }} + with: + name: test-results-python + path: | + ${{ env.INSTALL_TEST_DIR }}/TEST*.html + ${{ env.INSTALL_TEST_DIR }}/TEST*.xml + if-no-files-found: 'warn' diff --git a/.github/workflows/job_pytorch_models_tests.yml b/.github/workflows/job_pytorch_models_tests.yml new file mode 100644 index 00000000000000..1640bea02c413b --- /dev/null +++ b/.github/workflows/job_pytorch_models_tests.yml @@ -0,0 +1,126 @@ +name: PyTorch Models tests + +on: + workflow_call: + inputs: + runner: + description: 'Machine on which the tests would run' + type: string + required: true + container: + description: 'JSON to be converted to the value of the "container" configuration for the job' + type: string + required: false + default: '{"image": null}' + event: + description: 'Event that triggered the workflow. E.g., "schedule" for nightly runs' + type: string + required: true + +jobs: + PyTorch_Models_Tests: + name: PyTorch Models tests + timeout-minutes: ${{ inputs.event == 'schedule' && 400 || 30 }} + runs-on: ${{ inputs.runner }} + container: ${{ fromJSON(inputs.container) }} + defaults: + run: + shell: bash + env: + DEBIAN_FRONTEND: noninteractive # to prevent apt-get from waiting user input + OPENVINO_REPO: ${{ github.workspace }}/openvino + INSTALL_DIR: ${{ github.workspace }}/install + 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: Download OpenVINO package + uses: actions/download-artifact@v3 + with: + name: openvino_package + path: ${{ env.INSTALL_DIR }} + + - name: Download OpenVINO tests package + uses: actions/download-artifact@v3 + with: + name: openvino_tests + path: ${{ env.INSTALL_TEST_DIR }} + + # Needed as ${{ github.workspace }} is not working correctly when using Docker + - name: Setup Variables + run: | + echo "OPENVINO_REPO=$GITHUB_WORKSPACE/openvino" >> "$GITHUB_ENV" + echo "INSTALL_DIR=$GITHUB_WORKSPACE/install" >> "$GITHUB_ENV" + echo "INSTALL_TEST_DIR=$GITHUB_WORKSPACE/install/tests" >> "$GITHUB_ENV" + echo "MODEL_HUB_TESTS_INSTALL_DIR=$GITHUB_WORKSPACE/install/tests/model_hub_tests" >> "$GITHUB_ENV" + + - name: Extract OpenVINO packages + run: | + pushd ${INSTALL_DIR} + tar -xzf openvino_package.tar.gz -C ${INSTALL_DIR} + popd + + pushd ${INSTALL_TEST_DIR} + tar -xzf openvino_tests.tar.gz -C ${INSTALL_DIR} + popd + + - name: Fetch setup_python action + uses: actions/checkout@v4 + with: + sparse-checkout: | + .github/actions/setup_python/action.yml + sparse-checkout-cone-mode: false + path: 'openvino' + + - name: Install dependencies + if: ${{ runner.os == 'Linux' }} + run: | + # install git (required to build pip deps from the sources) + # install 'g++' to build 'detectron2' and 'natten' wheels + sudo apt-get install --assume-yes --no-install-recommends g++ git ca-certificates + + - name: Setup Python 3.11 + uses: ./openvino/.github/actions/setup_python + with: + version: '3.11' + should-setup-pip-paths: 'false' + self-hosted-runner: ${{ contains(inputs.runner, 'aks') }} + + - name: Install OpenVINO Python wheels + run: python3 -m pip install ${INSTALL_DIR}/tools/openvino-* + + - name: Install PyTorch tests requirements + run: | + python3 -m pip install -r ${MODEL_HUB_TESTS_INSTALL_DIR}/torch_tests/requirements.txt + python3 -m pip install -r ${MODEL_HUB_TESTS_INSTALL_DIR}/torch_tests/requirements_secondary.txt + echo "Available storage:" + df -h + env: + CPLUS_INCLUDE_PATH: ${{ env.Python_ROOT_DIR }}/include/python${{ env.PYTHON_VERSION }} + + - name: PyTorch Models Tests + run: | + export PYTHONPATH=${MODEL_HUB_TESTS_INSTALL_DIR}:$PYTHONPATH + python3 -m pytest ${MODEL_HUB_TESTS_INSTALL_DIR}/torch_tests -m ${TYPE} --html=${INSTALL_TEST_DIR}/TEST-torch_model_tests.html --self-contained-html -v + env: + TYPE: ${{ inputs.event == 'schedule' && 'nightly' || 'precommit'}} + TEST_DEVICE: CPU + USE_SYSTEM_CACHE: False + + - name: Available storage after tests + run: | + echo "Available storage:" + df -h + + - name: Upload Test Results + uses: actions/upload-artifact@v3 + if: ${{ !cancelled() }} + with: + name: test-results-torch-models + path: | + ${{ env.INSTALL_TEST_DIR }}/TEST*.html + if-no-files-found: 'error' diff --git a/.github/workflows/job_samples_tests.yml b/.github/workflows/job_samples_tests.yml new file mode 100644 index 00000000000000..8c1401a819d845 --- /dev/null +++ b/.github/workflows/job_samples_tests.yml @@ -0,0 +1,132 @@ +name: Samples + +on: + workflow_call: + inputs: + runner: + description: 'Machine on which the tests would run' + type: string + required: true + image: + description: 'Docker image in which the tests would run' + type: string + required: false + default: null + affected-components: + description: 'Components that are affected by changes in the commit defined by the Smart CI Action' + type: string + required: true + +jobs: + Samples: + runs-on: ${{ inputs.runner }} + container: + image: ${{ inputs.image }} + defaults: + run: + shell: bash + env: + DEBIAN_FRONTEND: noninteractive # to prevent apt-get from waiting user input + INSTALL_DIR: ${{ github.workspace }}/install + INSTALL_TEST_DIR: ${{ github.workspace }}/install/tests + BUILD_DIR: ${{ github.workspace }}/build + steps: + - name: Download OpenVINO package + uses: actions/download-artifact@v3 + with: + name: openvino_package + path: ${{ env.INSTALL_DIR }} + + - name: Download OpenVINO tests package + uses: actions/download-artifact@v3 + with: + name: openvino_tests + path: ${{ env.INSTALL_TEST_DIR }} + + # Needed as ${{ github.workspace }} is not working correctly when using Docker + - name: Setup Variables + run: | + echo "INSTALL_DIR=$GITHUB_WORKSPACE/install" >> "$GITHUB_ENV" + echo "INSTALL_TEST_DIR=$GITHUB_WORKSPACE/install/tests" >> "$GITHUB_ENV" + echo "BUILD_DIR=$GITHUB_WORKSPACE/build" >> "$GITHUB_ENV" + + - name: Extract OpenVINO packages + run: | + pushd $INSTALL_DIR + tar -xzf openvino_package.tar.gz -C $INSTALL_DIR + popd + pushd $INSTALL_TEST_DIR + tar -xzf openvino_tests.tar.gz -C $INSTALL_DIR + popd + + - name: Install OpenVINO dependencies (Linux) + if: runner.os == 'Linux' + run: $INSTALL_DIR/install_dependencies/install_openvino_dependencies.sh -c=core -c=dev -y + + - name: Install OpenVINO dependencies (mac) + if: runner.os == 'macOS' + run: brew install coreutils + + - name: Fetch setup_python action + uses: actions/checkout@v4 + with: + sparse-checkout: | + .github/actions/setup_python/action.yml + sparse-checkout-cone-mode: false + path: 'openvino' + + - name: Setup Python 3.11 + uses: ./openvino/.github/actions/setup_python + with: + version: '3.11' + should-setup-pip-paths: 'false' + self-hosted-runner: ${{ runner.os == 'Linux' }} + + - name: Build cpp samples - GCC + run: $INSTALL_DIR/samples/cpp/build_samples.sh -i $INSTALL_DIR -b $BUILD_DIR/cpp_samples + env: + CMAKE_COMPILE_WARNING_AS_ERROR: 'ON' + + - name: Build cpp samples - Clang + if: runner.os == 'Linux' + run: | + apt-get install -y clang + $INSTALL_DIR/samples/cpp/build_samples.sh -i $INSTALL_DIR -b $BUILD_DIR/cpp_samples_clang + env: + CMAKE_COMPILE_WARNING_AS_ERROR: 'ON' + CC: clang + CXX: clang++ + + - name: Build c samples + run: $INSTALL_DIR/samples/c/build_samples.sh -i $INSTALL_DIR -b $BUILD_DIR/c_samples + env: + CMAKE_COMPILE_WARNING_AS_ERROR: 'ON' + + # + # Tests + # + + - name: Samples tests + if: fromJSON(inputs.affected-components).samples.test + run: | + export WORKSPACE=$INSTALL_DIR + export IE_APP_PATH=$INSTALL_DIR/samples_bin + export IE_APP_PYTHON_PATH=$INSTALL_DIR/samples/python + export SHARE=$INSTALL_TEST_DIR/smoke_tests/samples_smoke_tests_data + + python3 -m pip install --ignore-installed PyYAML -r $INSTALL_TEST_DIR/smoke_tests/requirements.txt + export LD_LIBRARY_PATH=${IE_APP_PATH}:$LD_LIBRARY_PATH + + source ${INSTALL_DIR}/setupvars.sh + + python3 -m pytest -sv $INSTALL_TEST_DIR/smoke_tests \ + --env_conf $INSTALL_TEST_DIR/smoke_tests/env_config.yml \ + --junitxml=$INSTALL_TEST_DIR/TEST-SamplesSmokeTests.xml + + - name: Upload Test Results + uses: actions/upload-artifact@v3 + if: ${{ !cancelled() }} + with: + name: test-results-samples + path: ${{ env.INSTALL_TEST_DIR }}/TEST*.xml + if-no-files-found: 'warn' diff --git a/.github/workflows/job_tensorflow_hub_models_tests.yml b/.github/workflows/job_tensorflow_hub_models_tests.yml new file mode 100644 index 00000000000000..6dcecaa267e8c4 --- /dev/null +++ b/.github/workflows/job_tensorflow_hub_models_tests.yml @@ -0,0 +1,113 @@ +name: TensorFlow Hub Models tests + +on: + workflow_call: + inputs: + runner: + description: 'Machine on which the tests would run' + type: string + required: true + container: + description: 'JSON to be converted to the value of the "container" configuration for the job' + type: string + required: false + default: '{"image": null}' + event: + description: 'Event that triggered the workflow. E.g., "schedule" for nightly runs' + type: string + required: true + +jobs: + TensorFlow_Hub_Models_Tests: + name: TensorFlow Hub Models tests + timeout-minutes: ${{ inputs.event == 'schedule' && 400 || 25 }} + runs-on: ${{ inputs.runner }} + container: ${{ fromJSON(inputs.container) }} + defaults: + run: + shell: bash + env: + DEBIAN_FRONTEND: noninteractive # to prevent apt-get from waiting user input + OPENVINO_REPO: ${{ github.workspace }}/openvino + INSTALL_DIR: ${{ github.workspace }}/install + 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: Download OpenVINO package + uses: actions/download-artifact@v3 + with: + name: openvino_package + path: ${{ env.INSTALL_DIR }} + + - name: Download OpenVINO tests package + uses: actions/download-artifact@v3 + with: + name: openvino_tests + path: ${{ env.INSTALL_TEST_DIR }} + + # Needed as ${{ github.workspace }} is not working correctly when using Docker + - name: Setup Variables + run: | + echo "OPENVINO_REPO=$GITHUB_WORKSPACE/openvino" >> "$GITHUB_ENV" + echo "INSTALL_DIR=$GITHUB_WORKSPACE/install" >> "$GITHUB_ENV" + echo "INSTALL_TEST_DIR=$GITHUB_WORKSPACE/install/tests" >> "$GITHUB_ENV" + echo "MODEL_HUB_TESTS_INSTALL_DIR=$GITHUB_WORKSPACE/install/tests/model_hub_tests" >> "$GITHUB_ENV" + + - name: Extract OpenVINO packages + run: | + pushd ${INSTALL_DIR} + tar -xzf openvino_package.tar.gz -C ${INSTALL_DIR} + popd + + pushd ${INSTALL_TEST_DIR} + tar -xzf openvino_tests.tar.gz -C ${INSTALL_DIR} + popd + + - name: Fetch setup_python action + uses: actions/checkout@v4 + with: + sparse-checkout: | + .github/actions/setup_python/action.yml + sparse-checkout-cone-mode: false + path: 'openvino' + + - name: Install dependencies + if: ${{ runner.os == 'Linux' }} + run: | + # install git (required to build pip deps from the sources) + sudo apt-get install --assume-yes --no-install-recommends g++ git ca-certificates + + - name: Setup Python 3.11 + uses: ./openvino/.github/actions/setup_python + with: + version: '3.11' + should-setup-pip-paths: 'false' + self-hosted-runner: ${{ contains(inputs.runner, 'aks') }} + + - name: Install OpenVINO Python wheels + run: python3 -m pip install ${INSTALL_DIR}/tools/openvino-* + + - name: Install TF Hub tests requirements + run: python3 -m pip install -r ${MODEL_HUB_TESTS_INSTALL_DIR}/tf_hub_tests/requirements.txt + + - name: TensorFlow Hub Tests - TF FE + run: | + export PYTHONPATH=${MODEL_HUB_TESTS_INSTALL_DIR}:$PYTHONPATH + python3 -m pytest ${MODEL_HUB_TESTS_INSTALL_DIR}/tf_hub_tests/ -m ${TYPE} --html=${INSTALL_TEST_DIR}/TEST-tf_hub_tf_fe.html --self-contained-html -v + env: + TYPE: ${{ inputs.event == 'schedule' && 'nightly' || 'precommit'}} + TEST_DEVICE: CPU + + - name: Upload Test Results + uses: actions/upload-artifact@v3 + if: ${{ !cancelled() }} + with: + name: test-results-tensorflow-hub-models + path: | + ${{ env.INSTALL_TEST_DIR }}/TEST*.html + if-no-files-found: 'error' diff --git a/.github/workflows/job_tensorflow_hub_performance_models_tests.yml b/.github/workflows/job_tensorflow_hub_performance_models_tests.yml new file mode 100644 index 00000000000000..6e00f25e0c0ebb --- /dev/null +++ b/.github/workflows/job_tensorflow_hub_performance_models_tests.yml @@ -0,0 +1,116 @@ +name: TensorFlow Hub Performance Models tests + +on: + workflow_call: + inputs: + runner: + description: 'Machine on which the tests would run' + type: string + required: true + container: + description: 'JSON to be converted to the value of the "container" configuration for the job' + type: string + required: false + default: '{"image": null}' + event: + description: 'Event that triggered the workflow. E.g., "schedule" for nightly runs' + type: string + required: true + +jobs: + TensorFlow_Hub_Performance_Models_Tests: + name: TensorFlow Hub Performance Models tests + timeout-minutes: ${{ inputs.event == 'schedule' && 400 || 25 }} + runs-on: ${{ inputs.runner }} + container: ${{ fromJSON(inputs.container) }} + defaults: + run: + shell: bash + env: + DEBIAN_FRONTEND: noninteractive # to prevent apt-get from waiting user input + OPENVINO_REPO: ${{ github.workspace }}/openvino + INSTALL_DIR: ${{ github.workspace }}/install + 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: Download OpenVINO package + uses: actions/download-artifact@v3 + with: + name: openvino_package + path: ${{ env.INSTALL_DIR }} + + - name: Download OpenVINO tests package + uses: actions/download-artifact@v3 + with: + name: openvino_tests + path: ${{ env.INSTALL_TEST_DIR }} + + # Needed as ${{ github.workspace }} is not working correctly when using Docker + - name: Setup Variables + run: | + echo "OPENVINO_REPO=$GITHUB_WORKSPACE/openvino" >> "$GITHUB_ENV" + echo "INSTALL_DIR=$GITHUB_WORKSPACE/install" >> "$GITHUB_ENV" + echo "INSTALL_TEST_DIR=$GITHUB_WORKSPACE/install/tests" >> "$GITHUB_ENV" + echo "MODEL_HUB_TESTS_INSTALL_DIR=$GITHUB_WORKSPACE/install/tests/model_hub_tests" >> "$GITHUB_ENV" + + - name: Extract OpenVINO packages + run: | + pushd ${INSTALL_DIR} + tar -xzf openvino_package.tar.gz -C ${INSTALL_DIR} + popd + + pushd ${INSTALL_TEST_DIR} + tar -xzf openvino_tests.tar.gz -C ${INSTALL_DIR} + popd + + - name: Fetch setup_python action + uses: actions/checkout@v4 + with: + sparse-checkout: | + .github/actions/setup_python/action.yml + sparse-checkout-cone-mode: false + path: 'openvino' + + - name: Install dependencies + if: ${{ runner.os == 'Linux' }} + run: | + # install git (required to build pip deps from the sources) + sudo apt-get install --assume-yes --no-install-recommends g++ git ca-certificates + + - name: Setup Python 3.11 + uses: ./openvino/.github/actions/setup_python + with: + version: '3.11' + should-setup-pip-paths: 'false' + self-hosted-runner: ${{ contains(inputs.runner, 'aks') }} + + - name: Install OpenVINO Python wheels + run: python3 -m pip install ${INSTALL_DIR}/tools/openvino-* + + - name: Install TF Hub tests requirements + run: python3 -m pip install -r ${MODEL_HUB_TESTS_INSTALL_DIR}/tf_hub_tests/requirements.txt + + - name: Install Hub Performance tests requirements + run: python3 -m pip install -r ${MODEL_HUB_TESTS_INSTALL_DIR}/performance_tests/requirements.txt + + - name: Performance Hub Tests + run: | + export PYTHONPATH=${MODEL_HUB_TESTS_INSTALL_DIR}:$PYTHONPATH + python3 -m pytest ${MODEL_HUB_TESTS_INSTALL_DIR}/performance_tests/ -m ${TYPE} --html=${INSTALL_TEST_DIR}/TEST-tf_hub_performance.html --self-contained-html -v + env: + TYPE: ${{ inputs.event == 'schedule' && 'nightly' || 'precommit'}} + TEST_DEVICE: CPU + + - name: Upload Test Results + uses: actions/upload-artifact@v3 + if: ${{ !cancelled() }} + with: + name: test-results-tensorflow-hub-performance-models + path: | + ${{ env.INSTALL_TEST_DIR }}/TEST*.html + if-no-files-found: 'error' diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 4e90619162d155..5cdc7804c7b06e 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -261,164 +261,22 @@ jobs: Debian_Packages: name: Debian Packages needs: Build - timeout-minutes: 5 - defaults: - run: - shell: bash - runs-on: ubuntu-20.04 - container: - image: ubuntu:20.04 - env: - DEBIAN_FRONTEND: noninteractive # to prevent apt-get from waiting user input - DEBIAN_PACKAGES_DIR: /__w/openvino/packages/ - - steps: - - name: Download OpenVINO debian packages - uses: actions/download-artifact@v3 - with: - name: openvino_debian_packages - path: ${{ env.DEBIAN_PACKAGES_DIR }} - - - name: Install debian packages & check conflicts - run: | - apt-get update -y - # Install debian packages from previous release - apt-get install --no-install-recommends -y gnupg wget ca-certificates - wget https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB - apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB - echo "deb https://apt.repos.intel.com/openvino/2023 ubuntu20 main" | tee /etc/apt/sources.list.d/intel-openvino-2023.list - apt-get update -y - apt-get install -y openvino - # install our local one and make sure the conflicts are resolved - apt-get install --no-install-recommends -y dpkg-dev - dpkg-scanpackages . /dev/null | gzip -9c > Packages.gz - echo "deb [trusted=yes] file:${DEBIAN_PACKAGES_DIR} ./" | tee /etc/apt/sources.list.d/openvino-local.list - apt-get update -y - apt-get install openvino -y - working-directory: ${{ env.DEBIAN_PACKAGES_DIR }} - - - name: Test debian packages - run: | - /usr/share/openvino/samples/cpp/build_samples.sh - /usr/share/openvino/samples/c/build_samples.sh - ~/openvino_cpp_samples_build/intel64/Release/hello_query_device - 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.frontend import FrontEndManager; assert len(FrontEndManager().get_available_front_ends()) == 6' - benchmark_app --help - ovc --help + uses: ./.github/workflows/job_debian_packages.yml + with: + runner: 'aks-linux-4-cores-16gb' + image: 'openvinogithubactions.azurecr.io/dockerhub/ubuntu:20.04' Samples: - needs: [Build, Smart_CI] - timeout-minutes: 20 - defaults: - run: - shell: bash - runs-on: ubuntu-20.04 - container: - image: ubuntu:20.04 - env: - DEBIAN_FRONTEND: noninteractive # to prevent apt-get from waiting user input - INSTALL_DIR: /__w/openvino/openvino/install - INSTALL_TEST_DIR: /__w/openvino/openvino/install/tests - BUILD_DIR: /__w/openvino/openvino/build + needs: [ Build, Smart_CI ] if: fromJSON(needs.smart_ci.outputs.affected_components).samples - - steps: - - name: Download OpenVINO package - uses: actions/download-artifact@v3 - with: - name: openvino_package - path: ${{ env.INSTALL_DIR }} - - - name: Download OpenVINO tests package - uses: actions/download-artifact@v3 - with: - name: openvino_tests - path: ${{ env.INSTALL_TEST_DIR }} - - - name: Extract OpenVINO packages - run: | - pushd ${INSTALL_DIR} - tar -xzf openvino_package.tar.gz -C ${INSTALL_DIR} - popd - pushd ${INSTALL_TEST_DIR} - tar -xzf openvino_tests.tar.gz -C ${INSTALL_DIR} - popd - - - name: Install OpenVINO dependencies - run: ${INSTALL_DIR}/install_dependencies/install_openvino_dependencies.sh -c=core -c=dev -y - - - name: Fetch setup_python action - uses: actions/checkout@v4 - with: - sparse-checkout: | - .github/actions/setup_python/action.yml - sparse-checkout-cone-mode: false - path: 'openvino' - - - name: Setup Python ${{ env.PYTHON_VERSION }} - uses: ./openvino/.github/actions/setup_python - with: - version: ${{ env.PYTHON_VERSION }} - should-setup-pip-paths: 'false' - self-hosted-runner: 'false' - - - name: Build cpp samples - GCC - run: ${INSTALL_DIR}/samples/cpp/build_samples.sh -i ${INSTALL_DIR} -b ${BUILD_DIR}/cpp_samples - env: - CMAKE_COMPILE_WARNING_AS_ERROR: 'ON' - - - name: Build cpp samples - Clang - run: | - apt-get install -y clang - ${INSTALL_DIR}/samples/cpp/build_samples.sh -i ${INSTALL_DIR} -b ${BUILD_DIR}/cpp_samples_clang - env: - CMAKE_COMPILE_WARNING_AS_ERROR: 'ON' - CC: clang - CXX: clang++ - - - name: Build c samples - run: ${INSTALL_DIR}/samples/c/build_samples.sh -i ${INSTALL_DIR} -b ${BUILD_DIR}/c_samples - env: - CMAKE_COMPILE_WARNING_AS_ERROR: 'ON' - - # - # Tests - # - - - name: Samples tests - if: fromJSON(needs.smart_ci.outputs.affected_components).samples.test - run: | - export WORKSPACE=${INSTALL_DIR} - export IE_APP_PATH=${INSTALL_DIR}/samples_bin - export IE_APP_PYTHON_PATH=${INSTALL_DIR}/samples/python - export SHARE=${INSTALL_TEST_DIR}/smoke_tests/samples_smoke_tests_data - - python3 -m pip install --ignore-installed PyYAML -r ${INSTALL_TEST_DIR}/smoke_tests/requirements.txt - export LD_LIBRARY_PATH=${IE_APP_PATH}:$LD_LIBRARY_PATH - - source ${INSTALL_DIR}/setupvars.sh - - python3 -m pytest -sv ${INSTALL_TEST_DIR}/smoke_tests \ - --env_conf ${INSTALL_TEST_DIR}/smoke_tests/env_config.yml \ - --junitxml=${INSTALL_TEST_DIR}/TEST-SamplesSmokeTests.xml - - - name: Upload Test Results - uses: actions/upload-artifact@v3 - if: ${{ !cancelled() }} - with: - name: test-results-samples - path: ${{ env.INSTALL_TEST_DIR }}/TEST*.xml - if-no-files-found: 'warn' + uses: ./.github/workflows/job_samples_tests.yml + with: + runner: 'aks-linux-4-cores-16gb' + image: 'openvinogithubactions.azurecr.io/dockerhub/ubuntu:20.04' + affected-components: ${{ needs.smart_ci.outputs.affected_components }} Conformance: - needs: [Build, Smart_CI] + needs: [ Build, Smart_CI ] timeout-minutes: ${{ matrix.TEST_TYPE == 'API' && 5 || 15 }} defaults: run: @@ -522,1028 +380,88 @@ jobs: ONNX_Runtime: name: ONNX Runtime Integration - needs: [Build, Smart_CI] - timeout-minutes: 10 - defaults: - run: - shell: bash - runs-on: aks-linux-16-cores-32gb - container: - image: openvinogithubactions.azurecr.io/dockerhub/ubuntu:20.04 - volumes: - - /mount/caches:/mount/caches - options: -e SCCACHE_AZURE_BLOB_CONTAINER -e SCCACHE_AZURE_CONNECTION_STRING - env: - DEBIAN_FRONTEND: noninteractive # to prevent apt-get from waiting user input - CMAKE_GENERATOR: 'Ninja Multi-Config' - CMAKE_CXX_COMPILER_LAUNCHER: sccache - CMAKE_C_COMPILER_LAUNCHER: sccache - OPENVINO_REPO: /__w/openvino/openvino/openvino - INSTALL_DIR: /__w/openvino/openvino/install - SCCACHE_AZURE_KEY_PREFIX: ubuntu20_x86_64_onnxruntime - ONNX_RUNTIME_REPO: /__w/openvino/openvino/onnxruntime - ONNX_RUNTIME_UTILS: /__w/openvino/openvino/install/onnxruntime - ONNX_RUNTIME_BUILD_DIR: /__w/openvino/openvino/onnxruntime/build if: fromJSON(needs.smart_ci.outputs.affected_components).ONNX_RT - - steps: - - name: Fetch install_build_dependencies.sh and setup_python action - uses: actions/checkout@v4 - with: - sparse-checkout: | - install_build_dependencies.sh - .github/actions/setup_python/action.yml - sparse-checkout-cone-mode: false - path: ${{ env.OPENVINO_REPO }} - - - name: Install git - run: | - apt-get update - apt-get install --assume-yes --no-install-recommends git ca-certificates - - - name: Setup Python ${{ env.PYTHON_VERSION }} - uses: ./openvino/.github/actions/setup_python - with: - version: ${{ env.PYTHON_VERSION }} - should-setup-pip-paths: 'false' - - # - # Initialize OpenVINO - # - - - name: Download OpenVINO package - uses: actions/download-artifact@v3 - with: - name: openvino_package - path: ${{ env.INSTALL_DIR }} - - - name: Extract OpenVINO package - run: | - pushd ${INSTALL_DIR} - tar -xzf openvino_package.tar.gz -C ${INSTALL_DIR} - popd - - - name: Install OpenVINO dependencies - run: ${INSTALL_DIR}/install_dependencies/install_openvino_dependencies.sh -c=core -c=dev -y - - - name: Clone ONNX Runtime - run: | - branch=`tr -s '\n ' < ${ONNX_RUNTIME_UTILS}/version` - git clone --branch $branch --single-branch --recursive https://github.com/microsoft/onnxruntime.git ${ONNX_RUNTIME_REPO} - - # - # Tests - # - - - name: Install Build Dependencies - run: bash ${OPENVINO_REPO}/install_build_dependencies.sh - - - name: Install sccache - uses: mozilla-actions/sccache-action@v0.0.3 - with: - version: "v0.5.4" - - - name: Build Lin ONNX Runtime - run: | - source ${INSTALL_DIR}/setupvars.sh - - ${ONNX_RUNTIME_REPO}/build.sh \ - --config RelWithDebInfo \ - --use_openvino CPU_FP32 \ - --build_shared_lib \ - --parallel \ - --skip_tests \ - --compile_no_warning_as_error \ - --build_dir ${ONNX_RUNTIME_BUILD_DIR} - env: - CXXFLAGS: "-Wno-error=deprecated-declarations" - - - name: Show sccache stats - run: ${SCCACHE_PATH} --show-stats - - - name: Run onnxruntime_test_all - run: | - source ${INSTALL_DIR}/setupvars.sh - skip_tests=$(tr -s '\n ' ':' < ${ONNX_RUNTIME_UTILS}/skip_tests) - - ./onnxruntime_test_all --gtest_filter=-$skip_tests - working-directory: ${{ env.ONNX_RUNTIME_BUILD_DIR }}/RelWithDebInfo/RelWithDebInfo - - - name: Run onnxruntime_shared_lib_test - run: | - source ${INSTALL_DIR}/setupvars.sh - ./onnxruntime_shared_lib_test --gtest_filter=-CApiTest.test_custom_op_openvino_wrapper_library - working-directory: ${{ env.ONNX_RUNTIME_BUILD_DIR }}/RelWithDebInfo/RelWithDebInfo - - - name: Run onnxruntime_global_thread_pools_test - run: | - source ${INSTALL_DIR}/setupvars.sh - ./onnxruntime_global_thread_pools_test - working-directory: ${{ env.ONNX_RUNTIME_BUILD_DIR }}/RelWithDebInfo/RelWithDebInfo - - - name: Run onnxruntime_api_tests_without_env - run: | - source ${INSTALL_DIR}/setupvars.sh - ./onnxruntime_api_tests_without_env - working-directory: ${{ env.ONNX_RUNTIME_BUILD_DIR }}/RelWithDebInfo/RelWithDebInfo - - - name: Run pytorch-converted tests - run: | - source ${INSTALL_DIR}/setupvars.sh - ./onnx_test_runner "${ONNX_RUNTIME_REPO}/cmake/external/onnx/onnx/backend/test/data/pytorch-converted" - working-directory: ${{ env.ONNX_RUNTIME_BUILD_DIR }}/RelWithDebInfo/RelWithDebInfo - - - name: Run pytorch-operator tests - run: | - source ${INSTALL_DIR}/setupvars.sh - ./onnx_test_runner "${ONNX_RUNTIME_REPO}/cmake/external/onnx/onnx/backend/test/data/pytorch-operator" - working-directory: ${{ env.ONNX_RUNTIME_BUILD_DIR }}/RelWithDebInfo/RelWithDebInfo + needs: [ Build, Smart_CI ] + uses: ./.github/workflows/job_onnx_runtime.yml + with: + runner: 'aks-linux-16-cores-32gb' + container: '{"image": "openvinogithubactions.azurecr.io/dockerhub/ubuntu:20.04", "volumes": ["/mount/caches:/mount/caches"], "options": "-e SCCACHE_AZURE_BLOB_CONTAINER -e SCCACHE_AZURE_CONNECTION_STRING"}' + sccache-azure-key-prefix: 'ubuntu20_x86_64_onnxruntime' CXX_Unit_Tests: name: C++ unit tests - needs: [Build, Smart_CI] - timeout-minutes: 20 - defaults: - run: - shell: bash - runs-on: aks-linux-4-cores-16gb - container: - image: openvinogithubactions.azurecr.io/dockerhub/ubuntu:20.04 - env: - INSTALL_DIR: /__w/openvino/openvino/install - INSTALL_TEST_DIR: /__w/openvino/openvino/install/tests - - steps: - - name: Download OpenVINO package - uses: actions/download-artifact@v3 - with: - name: openvino_package - path: ${{ env.INSTALL_DIR }} - - - name: Download OpenVINO tests package - uses: actions/download-artifact@v3 - with: - name: openvino_tests - path: ${{ env.INSTALL_TEST_DIR }} - - - name: Extract OpenVINO packages - run: | - pushd ${INSTALL_DIR} - tar -xzf openvino_package.tar.gz -C ${INSTALL_DIR} - popd - pushd ${INSTALL_TEST_DIR} - tar -xzf openvino_tests.tar.gz -C ${INSTALL_DIR} - popd - - - name: Install OpenVINO dependencies - run: ${INSTALL_DIR}/install_dependencies/install_openvino_dependencies.sh -c=core -c=gpu -y - - # - # Tests - # - - - name: OpenVINO Core Unit Tests - if: fromJSON(needs.smart_ci.outputs.affected_components).Core.test - run: | - source ${INSTALL_DIR}/setupvars.sh - ${INSTALL_TEST_DIR}/ov_core_unit_tests --gtest_print_time=1 --gtest_filter=-*IE_GPU* \ - --gtest_output=xml:${INSTALL_TEST_DIR}/TEST-OVCoreUT.xml - - - name: OpenVINO Inference Functional Tests - if: fromJSON(needs.smart_ci.outputs.affected_components).inference.test - run: | - source ${INSTALL_DIR}/setupvars.sh - ${INSTALL_TEST_DIR}/ov_inference_functional_tests --gtest_print_time=1 \ - --gtest_output=xml:${INSTALL_TEST_DIR}/TEST-InferenceFunc.xml - - - name: OpenVINO Inference Unit Tests - if: fromJSON(needs.smart_ci.outputs.affected_components).inference.test - run: | - source ${INSTALL_DIR}/setupvars.sh - ${INSTALL_TEST_DIR}/ov_inference_unit_tests --gtest_print_time=1 \ - --gtest_output=xml:${INSTALL_TEST_DIR}/TEST-InferenceUnit.xml - - - name: Low Precision Transformations Tests - if: fromJSON(needs.smart_ci.outputs.affected_components).LP_transformations.test - run: | - source ${INSTALL_DIR}/setupvars.sh - ${INSTALL_TEST_DIR}/ov_lp_transformations_tests --gtest_print_time=1 \ - --gtest_output=xml:${INSTALL_TEST_DIR}/TEST-LpTransformations.xml - - - name: OpenVINO Conditional compilation tests - if: fromJSON(needs.smart_ci.outputs.affected_components).Core.test - run: | - source ${INSTALL_DIR}/setupvars.sh - ${INSTALL_TEST_DIR}/ov_conditional_compilation_tests --gtest_print_time=1 \ - --gtest_output=xml:${INSTALL_TEST_DIR}/TEST-ConditionalCompilation.xml - - - name: IR frontend tests - if: fromJSON(needs.smart_ci.outputs.affected_components).IR_FE.test - run: | - source ${INSTALL_DIR}/setupvars.sh - ${INSTALL_TEST_DIR}/ov_ir_frontend_tests --gtest_print_time=1 \ - --gtest_output=xml:${INSTALL_TEST_DIR}/TEST-IRFrontend.xml - - - name: PaddlePaddle frontend tests - if: ${{ 'false' }} - run: | - source ${INSTALL_DIR}/setupvars.sh - ${INSTALL_TEST_DIR}/paddle_tests --gtest_print_time=1 \ - --gtest_output=xml:${INSTALL_TEST_DIR}/TEST-PaddleTests.xml - - - name: ONNX frontend tests - if: fromJSON(needs.smart_ci.outputs.affected_components).ONNX_FE.test - run: | - source ${INSTALL_DIR}/setupvars.sh - ${INSTALL_TEST_DIR}/ov_onnx_frontend_tests --gtest_print_time=1 \ - --gtest_filter=-*IE_GPU* \ - --gtest_output=xml:${INSTALL_TEST_DIR}/TEST-ONNXFrontend.xml - - - name: TensorFlow Common frontend tests - if: fromJSON(needs.smart_ci.outputs.affected_components).TF_FE.test || - fromJSON(needs.smart_ci.outputs.affected_components).TFL_FE.test - run: | - source ${INSTALL_DIR}/setupvars.sh - ${INSTALL_TEST_DIR}/ov_tensorflow_common_tests --gtest_print_time=1 \ - --gtest_output=xml:${INSTALL_TEST_DIR}/TEST-TensorFlowCommonFrontend.xml - - - name: TensorFlow frontend tests - if: fromJSON(needs.smart_ci.outputs.affected_components).TF_FE.test - run: | - source ${INSTALL_DIR}/setupvars.sh - ${INSTALL_TEST_DIR}/ov_tensorflow_frontend_tests --gtest_print_time=1 \ - --gtest_output=xml:${INSTALL_TEST_DIR}/TEST-TensorFlowFrontend.xml - - - name: TensorFlow Lite frontend tests - if: fromJSON(needs.smart_ci.outputs.affected_components).TFL_FE.test - run: | - source ${INSTALL_DIR}/setupvars.sh - ${INSTALL_TEST_DIR}/ov_tensorflow_lite_frontend_tests --gtest_print_time=1 \ - --gtest_output=xml:${INSTALL_TEST_DIR}/TEST-TensorFlowLiteFrontend.xml - - - name: Transformations func tests - if: fromJSON(needs.smart_ci.outputs.affected_components).transformations.test - run: | - source ${INSTALL_DIR}/setupvars.sh - ${INSTALL_TEST_DIR}/ov_transformations_tests --gtest_print_time=1 \ - --gtest_output=xml:${INSTALL_TEST_DIR}/TEST-Transformations.xml - - - name: Legacy Transformations func tests - if: fromJSON(needs.smart_ci.outputs.affected_components).GNA.test - run: | - source ${INSTALL_DIR}/setupvars.sh - ${INSTALL_TEST_DIR}/ov_legacy_transformations_tests --gtest_print_time=1 \ - --gtest_output=xml:${INSTALL_TEST_DIR}/TEST-LegacyTransformations.xml - - - name: Inference Engine 1.0 unit tests - if: fromJSON(needs.smart_ci.outputs.affected_components).GNA.test - run: | - source ${INSTALL_DIR}/setupvars.sh - ${INSTALL_TEST_DIR}/InferenceEngineUnitTests --gtest_print_time=1 \ - --gtest_output=xml:${INSTALL_TEST_DIR}/TEST-InferenceEngineUnitTests.xml + needs: [ Build, Smart_CI ] + uses: ./.github/workflows/job_cxx_unit_tests.yml + with: + runner: 'aks-linux-4-cores-16gb' + image: 'openvinogithubactions.azurecr.io/dockerhub/ubuntu:20.04' + affected-components: ${{ needs.smart_ci.outputs.affected_components }} - - name: Common test utils tests - run: | - source ${INSTALL_DIR}/setupvars.sh - ${INSTALL_TEST_DIR}/ov_util_tests --gtest_print_time=1 \ - --gtest_output=xml:${INSTALL_TEST_DIR}/TEST-CommonUtilTests.xml - - - name: Snippets func tests - if: fromJSON(needs.smart_ci.outputs.affected_components).CPU.test - run: | - source ${INSTALL_DIR}/setupvars.sh - ${INSTALL_TEST_DIR}/ov_snippets_func_tests --gtest_print_time=1 \ - --gtest_output=xml:${INSTALL_TEST_DIR}/TEST-SnippetsFuncTests.xml - - - name: CPU plugin unit tests - if: fromJSON(needs.smart_ci.outputs.affected_components).CPU.test - run: | - source ${INSTALL_DIR}/setupvars.sh - ${INSTALL_TEST_DIR}/ov_cpu_unit_tests --gtest_print_time=1 \ - --gtest_output=xml:${INSTALL_TEST_DIR}/TEST-CPUUnitTests.xml - - - name: ov_subgraphs_dumper_tests tests - run: | - source ${INSTALL_DIR}/setupvars.sh - ${INSTALL_TEST_DIR}/ov_subgraphs_dumper_tests --gtest_print_time=1 \ - --gtest_output=xml:${INSTALL_TEST_DIR}/TEST-ov_subgraphs_dumper_tests.xml - - - name: Template OpImpl tests - run: | - source ${INSTALL_DIR}/setupvars.sh - ${INSTALL_TEST_DIR}/ov_op_conformance_tests --gtest_print_time=1 --device=TEMPLATE --gtest_filter=*OpImpl*\ - --gtest_output=xml:${INSTALL_TEST_DIR}/TEST-OpImplTests.xml - - - name: AUTO unit tests - if: fromJSON(needs.smart_ci.outputs.affected_components).AUTO.test - run: | - source ${INSTALL_DIR}/setupvars.sh - ${INSTALL_TEST_DIR}/ov_auto_unit_tests --gtest_print_time=1 \ - --gtest_output=xml:${INSTALL_TEST_DIR}/TEST-ov_auto_unit_tests.xml - - - name: AUTO func Tests - if: fromJSON(needs.smart_ci.outputs.affected_components).AUTO.test - run: | - source ${{ env.INSTALL_DIR }}/setupvars.sh - ${{ env.INSTALL_TEST_DIR }}/ov_auto_func_tests --gtest_print_time=1 \ - --gtest_output=xml:${{ env.INSTALL_TEST_DIR }}/TEST-ov_auto_func_tests.xml - - - name: Template plugin func tests - if: fromJSON(needs.smart_ci.outputs.affected_components).TEMPLATE.test - run: | - source ${INSTALL_DIR}/setupvars.sh - ${INSTALL_TEST_DIR}/ov_template_func_tests --gtest_print_time=1 \ - --gtest_filter=*smoke* \ - --gtest_output=xml:${INSTALL_TEST_DIR}/TEST-TemplateFuncTests.xml - - - name: Inference Engine C API tests - if: fromJSON(needs.smart_ci.outputs.affected_components).C_API.test - run: | - source ${INSTALL_DIR}/setupvars.sh - ${INSTALL_TEST_DIR}/InferenceEngineCAPITests --gtest_print_time=1 \ - --gtest_output=xml:${INSTALL_TEST_DIR}/TEST-InferenceEngineCAPITests.xml - - - name: OpenVINO C API tests - if: fromJSON(needs.smart_ci.outputs.affected_components).C_API.test - run: | - source ${INSTALL_DIR}/setupvars.sh - ${INSTALL_TEST_DIR}/ov_capi_test --gtest_print_time=1 \ - --gtest_output=xml:${INSTALL_TEST_DIR}/TEST-OpenVINOCAPITests.xml - - - name: AutoBatch unit tests - if: fromJSON(needs.smart_ci.outputs.affected_components).AUTO_BATCH.test - run: | - source ${INSTALL_DIR}/setupvars.sh - ${INSTALL_TEST_DIR}/ov_auto_batch_unit_tests --gtest_output=xml:${INSTALL_TEST_DIR}/TEST-ov_auto_batch_unit_tests.xml - - - name: AutoBatch func tests - if: fromJSON(needs.smart_ci.outputs.affected_components).AUTO_BATCH.test - run: | - source ${INSTALL_DIR}/setupvars.sh - ${INSTALL_TEST_DIR}/ov_auto_batch_func_tests --gtest_output=xml:${INSTALL_TEST_DIR}/TEST-ov_auto_batch_func_tests.xml - - - name: Proxy Plugin func tests - if: fromJSON(needs.smart_ci.outputs.affected_components).PROXY.test - run: | - source ${INSTALL_DIR}/setupvars.sh - ${INSTALL_TEST_DIR}/ov_proxy_plugin_tests --gtest_print_time=1 --gtest_output=xml:${INSTALL_TEST_DIR}/TEST-OVProxyTests.xml - - - name: Hetero unit tests - if: fromJSON(needs.smart_ci.outputs.affected_components).HETERO.test - run: | - source ${{ env.INSTALL_DIR }}/setupvars.sh - ${{ env.INSTALL_TEST_DIR }}/ov_hetero_unit_tests --gtest_print_time=1 --gtest_output=xml:${{ env.INSTALL_TEST_DIR }}/TEST-OVHeteroUnitTests.xml - - - name: Hetero func tests - if: fromJSON(needs.smart_ci.outputs.affected_components).HETERO.test - run: | - source ${INSTALL_DIR}/setupvars.sh - ${INSTALL_TEST_DIR}/ov_hetero_func_tests --gtest_print_time=1 --gtest_output=xml:${INSTALL_TEST_DIR}/TEST-OVHeteroFuncTests.xml - - - name: Upload Test Results - uses: actions/upload-artifact@v3 - if: ${{ !cancelled() }} - with: - name: test-results-cpp - path: ${{ env.INSTALL_TEST_DIR }}/TEST*.xml - if-no-files-found: 'warn' - - Python_Unit_Tests: - name: Python unit tests - needs: [Build, Smart_CI] - timeout-minutes: 40 - defaults: - run: - shell: bash - runs-on: aks-linux-4-cores-16gb - container: - image: openvinogithubactions.azurecr.io/dockerhub/ubuntu:20.04 - volumes: - - /mount/caches:/mount/caches - env: - OPENVINO_REPO: /__w/openvino/openvino/openvino - INSTALL_DIR: /__w/openvino/openvino/install - INSTALL_TEST_DIR: /__w/openvino/openvino/install/tests - LAYER_TESTS_INSTALL_DIR: /__w/openvino/openvino/install/tests/layer_tests - - steps: - # - # Initialize OpenVINO - # - - name: Download OpenVINO package - uses: actions/download-artifact@v3 - with: - name: openvino_package - path: ${{ env.INSTALL_DIR }} - - - name: Download OpenVINO tests package - uses: actions/download-artifact@v3 - with: - name: openvino_tests - path: ${{ env.INSTALL_TEST_DIR }} - - - name: Extract OpenVINO packages - run: | - pushd ${INSTALL_DIR} - tar -xzf openvino_package.tar.gz -C ${INSTALL_DIR} - popd - - pushd ${INSTALL_TEST_DIR} - tar -xzf openvino_tests.tar.gz -C ${INSTALL_DIR} - popd - - - name: Fetch setup_python action - uses: actions/checkout@v4 - with: - sparse-checkout: | - .github/actions/setup_python/action.yml - sparse-checkout-cone-mode: false - path: ${{ env.OPENVINO_REPO }} - - - name: Setup Python ${{ env.PYTHON_VERSION }} - uses: ./openvino/.github/actions/setup_python - with: - version: ${{ env.PYTHON_VERSION }} - pip-cache-path: ${{ env.PIP_CACHE_PATH }} - should-setup-pip-paths: 'true' - - - name: Install OpenVINO dependencies - run: ${INSTALL_DIR}/install_dependencies/install_openvino_dependencies.sh -c=core -y - - - name: Install OpenVINO Python wheels - run: | - # Install the core OV wheel - python3 -m pip install ${INSTALL_DIR}/tools/openvino-*.whl - - # Find and install OV dev wheel - pushd ${INSTALL_DIR}/tools - ov_dev_wheel_name=$(find . -name 'openvino_dev*.whl') - python3 -m pip install $ov_dev_wheel_name[mxnet,caffe,kaldi,onnx,tensorflow2,pytorch] - popd - - - name: Install Python API tests dependencies - run: | - # To enable pytest parallel features - python3 -m pip install pytest-xdist[psutil] - # For torchvision to OpenVINO preprocessing converter - python3 -m pip install -r ${INSTALL_TEST_DIR}/python/preprocess/torchvision/requirements.txt - - # TODO: replace with Python API tests requirements - python3 -m pip install -r ${INSTALL_TEST_DIR}/mo/requirements_dev.txt - - # - # Tests - # - - - name: Python API 1.0 Tests - #if: fromJSON(needs.smart_ci.outputs.affected_components).Python_API.test - run: | - python3 -m pytest -s ${INSTALL_TEST_DIR}/pyngraph \ - --junitxml=${INSTALL_TEST_DIR}/TEST-Pyngraph.xml \ - --ignore=${INSTALL_TEST_DIR}/pyngraph/tests_compatibility/test_onnx/test_zoo_models.py \ - --ignore=${INSTALL_TEST_DIR}/pyngraph/tests_compatibility/test_onnx/test_backend.py - - - name: Python API 2.0 Tests - #if: fromJSON(needs.smart_ci.outputs.affected_components).Python_API.test - run: | - # for 'template' extension - export LD_LIBRARY_PATH=${INSTALL_TEST_DIR}:$LD_LIBRARY_PATH - python3 -m pytest -sv ${INSTALL_TEST_DIR}/pyopenvino \ - --junitxml=${INSTALL_TEST_DIR}/TEST-Pyngraph.xml \ - --ignore=${INSTALL_TEST_DIR}/pyopenvino/tests/test_utils/test_utils.py - - - name: Model Optimizer unit tests - if: fromJSON(needs.smart_ci.outputs.affected_components).MO.test - run: | - # required for MxNet - apt-get install -y libgomp1 libquadmath0 - - python3 -m pytest -s ${INSTALL_TEST_DIR}/mo/unit_tests \ - --junitxml=${INSTALL_TEST_DIR}/TEST-ModelOptimizer.xml - - - name: Python ONNX operators tests - if: fromJSON(needs.smart_ci.outputs.affected_components).Python_API.test || - fromJSON(needs.smart_ci.outputs.affected_components).ONNX_FE.test - run: | - # Skip test_onnx/test_zoo_models and test_onnx/test_backend due to long execution time - ONNX Model Zoo tests are run separately - python3 -m pytest -sv ${INSTALL_TEST_DIR}/onnx -k 'not cuda' \ - --junitxml=${INSTALL_TEST_DIR}/TEST-onnx_frontend.xml \ - --ignore=${INSTALL_TEST_DIR}/onnx/test_python/test_zoo_models.py - - - name: OVC unit tests - if: fromJSON(needs.smart_ci.outputs.affected_components).MO.test - run: python3 -m pytest -s ${INSTALL_TEST_DIR}/ovc/unit_tests --junitxml=${INSTALL_TEST_DIR}/TEST-OpenVinoConversion.xml - - - name: Install Python Layer tests dependencies - run: | - # layer test requirements - python3 -m pip install -r ${LAYER_TESTS_INSTALL_DIR}/requirements.txt - - - name: MO Python API Tests - if: fromJSON(needs.smart_ci.outputs.affected_components).MO.test - run: | - # Import 'test_utils' installed in '/tests/python/openvino' - export LD_LIBRARY_PATH=${PIP_INSTALL_PATH}/openvino/libs:$LD_LIBRARY_PATH - export PYTHONPATH=${INSTALL_TEST_DIR}/python - python3 -m pytest ${LAYER_TESTS_INSTALL_DIR}/mo_python_api_tests --junitxml=${INSTALL_TEST_DIR}/TEST-test_mo_convert.xml - env: - TEST_DEVICE: CPU - TEST_PRECISION: FP16 - - - name: OVC Python API Tests - if: fromJSON(needs.smart_ci.outputs.affected_components).MO.test - run: | - # Import 'test_utils' installed in '/tests/python/openvino' - export PYTHONPATH=${INSTALL_TEST_DIR}/python - export LD_LIBRARY_PATH=${PIP_INSTALL_PATH}/openvino/libs:$LD_LIBRARY_PATH - python3 -m pytest ${LAYER_TESTS_INSTALL_DIR}/ovc_python_api_tests --junitxml=${INSTALL_TEST_DIR}/TEST-test_ovc_convert.xml - env: - TEST_DEVICE: CPU - TEST_PRECISION: FP16 - - - name: Python Frontend tests - if: fromJSON(needs.smart_ci.outputs.affected_components).PyTorch_FE.test || - fromJSON(needs.smart_ci.outputs.affected_components).PDPD_FE.test - run: | - # to allow 'libtest_builtin_extensions.so' to find 'libopenvino_onnx_frontend.so' - export LD_LIBRARY_PATH=${PIP_INSTALL_PATH}/openvino/libs:$LD_LIBRARY_PATH - python3 -m pytest ${LAYER_TESTS_INSTALL_DIR}/py_frontend_tests --junitxml=${INSTALL_TEST_DIR}/TEST-test_py_fontend.xml - - - name: PyTorch Layer Tests - if: fromJSON(needs.smart_ci.outputs.affected_components).PyTorch_FE.test - run: python3 -m pytest ${LAYER_TESTS_INSTALL_DIR}/pytorch_tests -n logical -m precommit --junitxml=${INSTALL_TEST_DIR}/TEST-pytorch.xml - env: - TEST_DEVICE: CPU - TEST_PRECISION: FP32 - - - name: PyTorch torch.compile TORCHFX Layer Tests - if: fromJSON(needs.smart_ci.outputs.affected_components).PyTorch_FE.test - run: | - python3 -m pytest ${LAYER_TESTS_INSTALL_DIR}/pytorch_tests -m precommit_fx_backend --junitxml=${INSTALL_TEST_DIR}/TEST-pytorch.xml - env: - TEST_DEVICE: CPU - TEST_PRECISION: FP32 - PYTORCH_TRACING_MODE: TORCHFX - - - name: PyTorch torch.compile TORCHSCRIPT Layer Tests - if: fromJSON(needs.smart_ci.outputs.affected_components).PyTorch_FE.test - run: | - python3 -m pytest ${LAYER_TESTS_INSTALL_DIR}/pytorch_tests -m precommit_ts_backend --junitxml=${INSTALL_TEST_DIR}/TEST-pytorch.xml - env: - TEST_DEVICE: CPU - TEST_PRECISION: FP32 - PYTORCH_TRACING_MODE: TORCHSCRIPT - - - name: ONNX Layer Tests - if: fromJSON(needs.smart_ci.outputs.affected_components).ONNX_FE.test - run: | - # requires 'unit_tests' from 'tools/mo' - export PYTHONPATH=${INSTALL_TEST_DIR}/mo:$PYTHONPATH - python3 -m pytest ${LAYER_TESTS_INSTALL_DIR}/onnx_tests -m "not launch_only_if_manually_specified and precommit" --junitxml=${INSTALL_TEST_DIR}/TEST-onnx.xml - env: - TEST_DEVICE: CPU - TEST_PRECISION: FP16 - - - name: TensorFlow 1 Layer Tests - TF FE - if: fromJSON(needs.smart_ci.outputs.affected_components).TF_FE.test - run: | - # requires 'unit_tests' from 'mo' - export PYTHONPATH=${INSTALL_TEST_DIR}/mo - python3 -m pytest ${LAYER_TESTS_INSTALL_DIR}/tensorflow_tests/ --use_new_frontend -m precommit_tf_fe --junitxml=${INSTALL_TEST_DIR}/TEST-tf_fe.xml - env: - TEST_DEVICE: CPU - TEST_PRECISION: FP16 - - - name: TensorFlow 2 Layer Tests - TF FE - if: fromJSON(needs.smart_ci.outputs.affected_components).TF_FE.test - run: | - # requires 'unit_tests' from 'mo' - export PYTHONPATH=${INSTALL_TEST_DIR}/mo - python3 -m pytest ${LAYER_TESTS_INSTALL_DIR}/tensorflow2_keras_tests/ --use_new_frontend -m precommit_tf_fe --junitxml=${INSTALL_TEST_DIR}/TEST-tf2_fe.xml - env: - TEST_DEVICE: CPU - TEST_PRECISION: FP16 - - - name: JAX Layer Tests - TF FE - if: fromJSON(needs.smart_ci.outputs.affected_components).TF_FE.test - run: python3 -m pytest ${LAYER_TESTS_INSTALL_DIR}/jax_tests/ -m precommit --junitxml=${INSTALL_TEST_DIR}/TEST-jax.xml - env: - TEST_DEVICE: CPU - - - name: TensorFlow 1 Layer Tests - Legacy FE - if: fromJSON(needs.smart_ci.outputs.affected_components).TF_FE.test - run: python3 -m pytest ${LAYER_TESTS_INSTALL_DIR}/tensorflow_tests/test_tf_Roll.py --ir_version=10 --junitxml=${INSTALL_TEST_DIR}/TEST-tf_Roll.xml - - - name: TensorFlow 2 Layer Tests - Legacy FE - if: fromJSON(needs.smart_ci.outputs.affected_components).TF_FE.test - run: python3 -m pytest ${LAYER_TESTS_INSTALL_DIR}/tensorflow2_keras_tests/test_tf2_keras_activation.py --ir_version=11 -k "sigmoid" --junitxml=${INSTALL_TEST_DIR}/TEST-tf2_Activation.xml - env: - TEST_DEVICE: CPU - TEST_PRECISION: FP16 - - - name: TensorFlow Lite Layer Tests - TFL FE - if: fromJSON(needs.smart_ci.outputs.affected_components).TFL_FE.test - run: python3 -m pytest ${LAYER_TESTS_INSTALL_DIR}/tensorflow_lite_tests/ --junitxml=${INSTALL_TEST_DIR}/TEST-tfl_fe.xml - env: - TEST_DEVICE: CPU - TEST_PRECISION: FP16 - - - name: Clone API snippets - uses: actions/checkout@v4 - with: - sparse-checkout: openvino/docs/snippets - path: ${{ env.OPENVINO_REPO }} - submodules: 'false' - - - name: Docs Python snippets - run: | - # to find 'snippets' module in docs - export PYTHONPATH=${OPENVINO_REPO}/docs - # for 'template' extension - export LD_LIBRARY_PATH=${INSTALL_TEST_DIR}:$LD_LIBRARY_PATH - python3 ${OPENVINO_REPO}/docs/snippets/main.py - - - name: Upload Test Results - uses: actions/upload-artifact@v3 - if: ${{ !cancelled() }} - with: - name: test-results-python - path: | - ${{ env.INSTALL_TEST_DIR }}/TEST*.html - ${{ env.INSTALL_TEST_DIR }}/TEST*.xml - if-no-files-found: 'warn' + 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/caches:/mount/caches"]}' + affected-components: ${{ needs.smart_ci.outputs.affected_components }} CPU_Functional_Tests: name: CPU functional tests - needs: [Build, Smart_CI] - timeout-minutes: 25 - defaults: - run: - shell: bash - runs-on: aks-linux-8-cores - container: - image: openvinogithubactions.azurecr.io/dockerhub/ubuntu:20.04 - env: - OPENVINO_REPO: /__w/openvino/openvino/openvino - INSTALL_DIR: /__w/openvino/openvino/install - INSTALL_TEST_DIR: /__w/openvino/openvino/install/tests - PARALLEL_TEST_SCRIPT: /__w/openvino/openvino/install/tests/functional_test_utils/layer_tests_summary/run_parallel.py - PARALLEL_TEST_CACHE: /__w/openvino/openvino/install/tests/test_cache.lst if: fromJSON(needs.smart_ci.outputs.affected_components).CPU.test - steps: - - name: Download OpenVINO package - uses: actions/download-artifact@v3 - with: - name: openvino_package - path: ${{ env.INSTALL_DIR }} - - - name: Download OpenVINO tests package - uses: actions/download-artifact@v3 - with: - name: openvino_tests - path: ${{ env.INSTALL_TEST_DIR }} - - - name: Extract OpenVINO packages - run: | - pushd ${INSTALL_DIR} - tar -xzf openvino_package.tar.gz -C ${INSTALL_DIR} - popd - pushd ${INSTALL_TEST_DIR} - tar -xzf openvino_tests.tar.gz -C ${INSTALL_DIR} - popd - - - name: Install OpenVINO dependencies - run: bash ${INSTALL_DIR}/install_dependencies/install_openvino_dependencies.sh -c=core -y - - - name: Fetch setup_python action - uses: actions/checkout@v4 - with: - sparse-checkout: | - .github/actions/setup_python/action.yml - sparse-checkout-cone-mode: false - path: ${{ env.OPENVINO_REPO }} - - - name: Setup Python ${{ env.PYTHON_VERSION }} - uses: ./openvino/.github/actions/setup_python - with: - version: ${{ env.PYTHON_VERSION }} - should-setup-pip-paths: 'false' - - - name: Install python dependencies for run_parallel.py - run: python3 -m pip install -r ${INSTALL_TEST_DIR}/functional_test_utils/layer_tests_summary/requirements.txt - - - name: Restore tests execution time - uses: actions/cache/restore@v3 - with: - path: ${{ env.PARALLEL_TEST_CACHE }} - key: ${{ runner.os }}-tests-functional-cpu-stamp-${{ github.sha }} - restore-keys: | - ${{ runner.os }}-tests-functional-cpu-stamp - - - name: Intel CPU plugin func tests (parallel) - run: | - source ${INSTALL_DIR}/setupvars.sh - python3 ${PARALLEL_TEST_SCRIPT} -e ${INSTALL_TEST_DIR}/ov_cpu_func_tests -c ${PARALLEL_TEST_CACHE} -w ${INSTALL_TEST_DIR} -s suite -rf 0 -- --gtest_print_time=1 --gtest_filter=*smoke* - timeout-minutes: 20 - - - name: Save tests execution time - uses: actions/cache/save@v3 - if: github.ref_name == 'master' - with: - path: ${{ env.PARALLEL_TEST_CACHE }} - key: ${{ runner.os }}-tests-functional-cpu-stamp-${{ github.sha }} - - - name: Upload Test Results - uses: actions/upload-artifact@v3 - if: ${{ !cancelled() }} - with: - name: test-results-functional-cpu - path: | - ${{ env.INSTALL_TEST_DIR }}/temp/*.log - ${{ env.INSTALL_TEST_DIR }}/logs/*.log - ${{ env.INSTALL_TEST_DIR }}/logs/failed/*.log - ${{ env.INSTALL_TEST_DIR }}/logs/crashed/*.log - ${{ env.INSTALL_TEST_DIR }}/logs/hanged/*.log - ${{ env.INSTALL_TEST_DIR }}/logs/interapted/*.log - ${{ env.INSTALL_TEST_DIR }}/logs/hash_table.csv - ${{ env.PARALLEL_TEST_CACHE }} - if-no-files-found: 'error' - + needs: [ Build, Smart_CI ] + uses: ./.github/workflows/job_cpu_functional_tests.yml + with: + runner: 'aks-linux-8-cores-32gb' + image: 'openvinogithubactions.azurecr.io/dockerhub/ubuntu:20.04' + + # TODO: Switch back to self-hosted runners + # container: + # image: openvinogithubactions.azurecr.io/dockerhub/ubuntu:20.04 + # volumes: + # - /mount/caches:/mount/caches TensorFlow_Hub_Models_Tests: name: TensorFlow Hub Models tests - needs: [Build, Smart_CI] - defaults: - run: - shell: bash - runs-on: ${{ github.event_name == 'schedule' && 'ubuntu-20.04-16-cores' || 'ubuntu-20.04-8-cores'}} - timeout-minutes: ${{ github.event_name == 'schedule' && 400 || 25 }} - # TODO: Switch back to self-hosted runners - # container: - # image: openvinogithubactions.azurecr.io/dockerhub/ubuntu:20.04 - # volumes: - # - /mount/caches:/mount/caches - env: - OPENVINO_REPO: ${{ github.workspace }}/openvino - INSTALL_DIR: ${{ github.workspace }}/install - INSTALL_TEST_DIR: ${{ github.workspace }}/install/tests - MODEL_HUB_TESTS_INSTALL_DIR: ${{ github.workspace }}/install/tests/model_hub_tests - if: fromJSON(needs.smart_ci.outputs.affected_components).TF_FE.test || + if: fromJSON(needs.smart_ci.outputs.affected_components).TF_FE.test || fromJSON(needs.smart_ci.outputs.affected_components).TFL_FE.test - - steps: - - name: Check sudo - run: if [ "$(id -u)" -eq 0 ]; then apt update && apt --assume-yes install sudo; fi - - - name: Download OpenVINO package - uses: actions/download-artifact@v3 - with: - name: openvino_package - path: ${{ env.INSTALL_DIR }} - - - name: Download OpenVINO tests package - uses: actions/download-artifact@v3 - with: - name: openvino_tests - path: ${{ env.INSTALL_TEST_DIR }} - - - name: Extract OpenVINO packages - run: | - pushd ${INSTALL_DIR} - tar -xzf openvino_package.tar.gz -C ${INSTALL_DIR} - popd - - pushd ${INSTALL_TEST_DIR} - tar -xzf openvino_tests.tar.gz -C ${INSTALL_DIR} - popd - - - name: Fetch setup_python action - uses: actions/checkout@v4 - with: - sparse-checkout: | - .github/actions/setup_python/action.yml - sparse-checkout-cone-mode: false - path: 'openvino' - - - name: Setup Python ${{ env.PYTHON_VERSION }} - uses: ./openvino/.github/actions/setup_python - with: - version: ${{ env.PYTHON_VERSION }} - should-setup-pip-paths: 'false' - self-hosted-runner: 'false' - - - name: Install OpenVINO Python wheels - run: python3 -m pip install ${INSTALL_DIR}/tools/openvino-* - - - name: Install TF Hub tests requirements - run: | - python3 -m pip install -r ${MODEL_HUB_TESTS_INSTALL_DIR}/tf_hub_tests/requirements.txt - - - name: TensorFlow Hub Tests - TF FE - run: | - export PYTHONPATH=${MODEL_HUB_TESTS_INSTALL_DIR}:$PYTHONPATH - python3 -m pytest ${MODEL_HUB_TESTS_INSTALL_DIR}/tf_hub_tests/ -m ${TYPE} --html=${INSTALL_TEST_DIR}/TEST-tf_hub_tf_fe.html --self-contained-html -v - env: - TYPE: ${{ github.event_name == 'schedule' && 'nightly' || 'precommit'}} - TEST_DEVICE: CPU - - - name: Upload Test Results - uses: actions/upload-artifact@v3 - if: ${{ !cancelled() }} - with: - name: test-results-tensorflow-hub-models - path: | - ${{ env.INSTALL_TEST_DIR }}/TEST*.html - if-no-files-found: 'error' - + needs: [ Build, Smart_CI ] + 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' }} + event: ${{ github.event_name }} + + # TODO: Switch back to self-hosted runners + # container: + # image: openvinogithubactions.azurecr.io/dockerhub/ubuntu:20.04 + # volumes: + # - /mount/caches:/mount/caches TensorFlow_Hub_Performance_Models_Tests: name: TensorFlow Hub Performance Models tests - needs: [Build, Smart_CI] - defaults: - run: - shell: bash - runs-on: ${{ github.event_name == 'schedule' && 'ubuntu-20.04-16-cores' || 'ubuntu-20.04-8-cores'}} - timeout-minutes: ${{ github.event_name == 'schedule' && 400 || 25 }} - env: - OPENVINO_REPO: ${{ github.workspace }}/openvino - INSTALL_DIR: ${{ github.workspace }}/install - INSTALL_TEST_DIR: ${{ github.workspace }}/install/tests - MODEL_HUB_TESTS_INSTALL_DIR: ${{ github.workspace }}/install/tests/model_hub_tests - if: fromJSON(needs.smart_ci.outputs.affected_components).TF_FE.test || + if: fromJSON(needs.smart_ci.outputs.affected_components).TF_FE.test || fromJSON(needs.smart_ci.outputs.affected_components).TFL_FE.test - - steps: - - name: Check sudo - run: if [ "$(id -u)" -eq 0 ]; then apt update && apt --assume-yes install sudo; fi - - - name: Download OpenVINO package - uses: actions/download-artifact@v3 - with: - name: openvino_package - path: ${{ env.INSTALL_DIR }} - - - name: Download OpenVINO tests package - uses: actions/download-artifact@v3 - with: - name: openvino_tests - path: ${{ env.INSTALL_TEST_DIR }} - - - name: Extract OpenVINO packages - run: | - pushd ${INSTALL_DIR} - tar -xzf openvino_package.tar.gz -C ${INSTALL_DIR} - popd - - pushd ${INSTALL_TEST_DIR} - tar -xzf openvino_tests.tar.gz -C ${INSTALL_DIR} - popd - - - name: Fetch setup_python action - uses: actions/checkout@v4 - with: - sparse-checkout: | - .github/actions/setup_python/action.yml - sparse-checkout-cone-mode: false - path: 'openvino' - - - name: Setup Python ${{ env.PYTHON_VERSION }} - uses: ./openvino/.github/actions/setup_python - with: - version: ${{ env.PYTHON_VERSION }} - should-setup-pip-paths: 'false' - self-hosted-runner: 'false' - - - name: Install OpenVINO Python wheels - run: python3 -m pip install ${INSTALL_DIR}/tools/openvino-* - - - name: Install TF Hub tests requirements - run: | - python3 -m pip install -r ${MODEL_HUB_TESTS_INSTALL_DIR}/tf_hub_tests/requirements.txt - - - name: Install Hub Performance tests requirements - run: | - python3 -m pip install -r ${MODEL_HUB_TESTS_INSTALL_DIR}/performance_tests/requirements.txt - - - name: Performance Hub Tests - run: | - export PYTHONPATH=${MODEL_HUB_TESTS_INSTALL_DIR}:$PYTHONPATH - python3 -m pytest ${MODEL_HUB_TESTS_INSTALL_DIR}/performance_tests/ -m ${TYPE} --html=${INSTALL_TEST_DIR}/TEST-tf_hub_performance.html --self-contained-html -v - env: - TYPE: ${{ github.event_name == 'schedule' && 'nightly' || 'precommit'}} - TEST_DEVICE: CPU - - - name: Upload Test Results - uses: actions/upload-artifact@v3 - if: ${{ !cancelled() }} - with: - name: test-results-tensorflow-hub-performance-models - path: | - ${{ env.INSTALL_TEST_DIR }}/TEST*.html - if-no-files-found: 'error' - + needs: [ Build, Smart_CI ] + uses: ./.github/workflows/job_tensorflow_hub_performance_models_tests.yml + with: + runner: ${{ github.event_name == 'schedule' && 'ubuntu-20.04-16-cores' || 'ubuntu-20.04-8-cores' }} + event: ${{ github.event_name }} + + # TODO: Switch back to self-hosted runners + # container: + # image: openvinogithubactions.azurecr.io/dockerhub/ubuntu:20.04 + # volumes: + # - /mount/caches:/mount/caches PyTorch_Models_Tests: name: PyTorch Models tests - needs: [Build, Smart_CI] - timeout-minutes: ${{ github.event_name == 'schedule' && 400 || 30 }} - defaults: - run: - shell: bash - runs-on: ${{ github.event_name == 'schedule' && 'ubuntu-20.04-16-cores' || 'ubuntu-20.04-8-cores'}} - # TODO: Switch back to self-hosted runners - # container: - # image: openvinogithubactions.azurecr.io/dockerhub/ubuntu:20.04 - # volumes: - # - /mount/caches:/mount/caches - env: - OPENVINO_REPO: ${{ github.workspace }}/openvino - INSTALL_DIR: ${{ github.workspace }}/install - INSTALL_TEST_DIR: ${{ github.workspace }}/install/tests - MODEL_HUB_TESTS_INSTALL_DIR: ${{ github.workspace }}/install/tests/model_hub_tests if: fromJSON(needs.smart_ci.outputs.affected_components).PyTorch_FE.test - - steps: - - name: Check sudo - run: if [ "$(id -u)" -eq 0 ]; then apt update && apt --assume-yes install sudo; fi - - - name: Install dependencies - run: | - # install git (required to build pip deps from the sources) - # install 'g++' to build 'detectron2' and 'natten' wheels - sudo apt-get install --assume-yes --no-install-recommends g++ git ca-certificates - - - name: Download OpenVINO package - uses: actions/download-artifact@v3 - with: - name: openvino_package - path: ${{ env.INSTALL_DIR }} - - - name: Download OpenVINO tests package - uses: actions/download-artifact@v3 - with: - name: openvino_tests - path: ${{ env.INSTALL_TEST_DIR }} - - - name: Extract OpenVINO packages - run: | - pushd ${INSTALL_DIR} - tar -xzf openvino_package.tar.gz -C ${INSTALL_DIR} - popd - pushd ${INSTALL_TEST_DIR} - tar -xzf openvino_tests.tar.gz -C ${INSTALL_DIR} - popd - - - name: Fetch setup_python action - uses: actions/checkout@v4 - with: - sparse-checkout: | - .github/actions/setup_python/action.yml - sparse-checkout-cone-mode: false - path: 'openvino' - - - name: Setup Python ${{ env.PYTHON_VERSION }} - uses: ./openvino/.github/actions/setup_python - with: - version: ${{ env.PYTHON_VERSION }} - should-setup-pip-paths: 'false' - self-hosted-runner: 'false' - - - name: Install OpenVINO Python wheels - run: python3 -m pip install ${INSTALL_DIR}/tools/openvino-* - - - name: Install PyTorch tests requirements - run: | - python3 -m pip install -r ${MODEL_HUB_TESTS_INSTALL_DIR}/torch_tests/requirements.txt - python3 -m pip install -r ${MODEL_HUB_TESTS_INSTALL_DIR}/torch_tests/requirements_secondary.txt - echo "Available storage:" - df -h - env: - CPLUS_INCLUDE_PATH: ${{ env.Python_ROOT_DIR }}/include/python${{ env.PYTHON_VERSION }} - - - name: PyTorch Models Tests - run: | - export PYTHONPATH=${MODEL_HUB_TESTS_INSTALL_DIR}:$PYTHONPATH - python3 -m pytest ${MODEL_HUB_TESTS_INSTALL_DIR}/torch_tests -m ${TYPE} --html=${INSTALL_TEST_DIR}/TEST-torch_model_tests.html --self-contained-html -v - env: - TYPE: ${{ github.event_name == 'schedule' && 'nightly' || 'precommit'}} - TEST_DEVICE: CPU - USE_SYSTEM_CACHE: False - - - name: Available storage after tests - run: | - echo "Available storage:" - df -h - - - name: Upload Test Results - uses: actions/upload-artifact@v3 - if: ${{ !cancelled() }} - with: - name: test-results-torch-models - path: | - ${{ env.INSTALL_TEST_DIR }}/TEST*.html - if-no-files-found: 'error' + needs: [ Build, Smart_CI ] + uses: ./.github/workflows/job_pytorch_models_tests.yml + with: + runner: ${{ github.event_name == 'schedule' && 'ubuntu-20.04-16-cores' || 'ubuntu-20.04-8-cores' }} + event: ${{ github.event_name }} NVIDIA_Plugin: name: NVIDIA plugin - needs: [Build, Smart_CI] + needs: [ Build, Smart_CI ] timeout-minutes: 15 defaults: run: @@ -1660,13 +578,13 @@ jobs: run: ${SCCACHE_PATH} --show-stats GPU_Stub: - needs: [Build, Smart_CI] + needs: [ Build, Smart_CI ] runs-on: ubuntu-latest if: fromJSON(needs.smart_ci.outputs.affected_components).GPU steps: - name: GPU stub run: | - echo "This is only a stub to collect statistics of GPU runs filtered by Smart CI. + echo "This is only a stub to collect statistics of GPU runs filtered by Smart CI. It will help us to estimate hardware requirements" shell: bash @@ -1680,7 +598,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/linux_arm64.yml b/.github/workflows/linux_arm64.yml new file mode 100644 index 00000000000000..f2687f663c3ace --- /dev/null +++ b/.github/workflows/linux_arm64.yml @@ -0,0 +1,361 @@ +name: Linux ARM64 (Ubuntu 20.04, Python 3.11) +on: + workflow_dispatch: + pull_request: + push: + branches: + - master + - 'releases/**' + +concurrency: + # github.ref is not unique in post-commit + group: ${{ github.event_name == 'push' && github.run_id || github.ref }}-linux-arm + cancel-in-progress: true + +env: + PIP_CACHE_PATH: /mount/caches/pip/linux + PYTHON_VERSION: '3.11' + +jobs: + Smart_CI: + runs-on: ubuntu-latest + outputs: + affected_components: "${{ steps.smart_ci.outputs.affected_components }}" + steps: + - name: checkout action + uses: actions/checkout@v4 + with: + sparse-checkout: .github/actions/smart-ci + + - name: Get affected components + id: smart_ci + uses: ./.github/actions/smart-ci + with: + repository: ${{ github.repository }} + pr: ${{ github.event.number }} + commit_sha: ${{ github.sha }} + component_pattern: "category: (.*)" + repo_token: ${{ secrets.GITHUB_TOKEN }} + + - name: Show affected components + run: | + echo "${{ toJSON(steps.smart_ci.outputs.affected_components) }}" + shell: bash + + Build: + needs: Smart_CI + timeout-minutes: 150 + defaults: + run: + shell: bash + runs-on: 'aks-linux-16-cores-arm' + container: + image: openvinogithubactions.azurecr.io/dockerhub/ubuntu:20.04 + volumes: + - /mount/caches:/mount/caches + options: -e SCCACHE_AZURE_BLOB_CONTAINER -e SCCACHE_AZURE_CONNECTION_STRING + env: + DEBIAN_FRONTEND: noninteractive # to prevent apt-get from waiting user input + CMAKE_BUILD_TYPE: 'Release' + CMAKE_GENERATOR: 'Ninja Multi-Config' + CMAKE_CXX_COMPILER_LAUNCHER: sccache + CMAKE_C_COMPILER_LAUNCHER: sccache + GITHUB_WORKSPACE: '/__w/openvino/openvino' + OPENVINO_REPO: /__w/openvino/openvino/openvino + OPENVINO_CONTRIB_REPO: /__w/openvino/openvino/openvino_contrib + INSTALL_DIR: /__w/openvino/openvino/openvino_install + INSTALL_TEST_DIR: /__w/openvino/openvino/tests_install + DEVELOPER_PACKAGE_DIR: /__w/openvino/openvino/developer_package_install + BUILD_DIR: /__w/openvino/openvino/openvino_build + SCCACHE_AZURE_KEY_PREFIX: 'ubuntu20_aarch64_Release' + ONNX_RUNTIME_UTILS: /__w/openvino/openvino/openvino/.ci/azure/ci_utils/onnxruntime + if: "!fromJSON(needs.smart_ci.outputs.affected_components).docs_only" + + steps: + - name: Install git + run: apt-get update && apt-get install --assume-yes --no-install-recommends git ca-certificates + + - name: Clone OpenVINO + uses: actions/checkout@v4 + with: + path: ${{ env.OPENVINO_REPO }} + submodules: 'true' + + - name: Clone OpenVINO Contrib + uses: actions/checkout@v4 + with: + repository: 'openvinotoolkit/openvino_contrib' + path: ${{ env.OPENVINO_CONTRIB_REPO }} + submodules: 'true' + ref: 'master' + + # + # Print system info + # + + - name: System info + uses: ./openvino/.github/actions/system_info + + # + # Dependencies + # + + - name: Install build dependencies + run: | + bash ${OPENVINO_REPO}/install_build_dependencies.sh + # default-jdk - Java API + apt install --assume-yes --no-install-recommends default-jdk + + - name: Install sccache + uses: mozilla-actions/sccache-action@v0.0.3 + with: + version: "v0.5.4" + + - name: Setup Python ${{ env.PYTHON_VERSION }} + uses: ./openvino/.github/actions/setup_python + with: + version: ${{ env.PYTHON_VERSION }} + pip-cache-path: ${{ env.PIP_CACHE_PATH }} + should-setup-pip-paths: 'true' + show-cache-info: 'true' + + - name: Install python dependencies + run: | + # For Python API: build and wheel packaging + python3 -m pip install -r ${OPENVINO_REPO}/src/bindings/python/wheel/requirements-dev.txt + python3 -m pip install -r ${OPENVINO_REPO}/src/bindings/python/src/compatibility/openvino/requirements-dev.txt + + # For running ONNX frontend unit tests + python3 -m pip install --force-reinstall -r ${OPENVINO_REPO}/src/frontends/onnx/tests/requirements.txt + + # For running TensorFlow frontend unit tests + python3 -m pip install -r ${OPENVINO_REPO}/src/frontends/tensorflow/tests/requirements.txt + + # For running TensorFlow Lite frontend unit tests + python3 -m pip install -r ${OPENVINO_REPO}/src/frontends/tensorflow_lite/tests/requirements.txt + + # For running Paddle frontend unit tests + python3 -m pip install -r ${OPENVINO_REPO}/src/frontends/paddle/tests/requirements.txt + + # + # Build + # + + - name: CMake configure - OpenVINO + run: | + cmake \ + -G "${{ env.CMAKE_GENERATOR }}" \ + -DENABLE_CPPLINT=OFF \ + -DENABLE_NCC_STYLE=OFF \ + -DENABLE_TESTS=ON \ + -DENABLE_STRICT_DEPENDENCIES=OFF \ + -DENABLE_SYSTEM_TBB=OFF \ + -DENABLE_SYSTEM_OPENCL=ON \ + -DCMAKE_VERBOSE_MAKEFILE=ON \ + -DCPACK_GENERATOR=TGZ \ + -DCMAKE_COMPILE_WARNING_AS_ERROR=ON \ + -DCMAKE_CXX_COMPILER_LAUNCHER=${{ env.CMAKE_CXX_COMPILER_LAUNCHER }} \ + -DCMAKE_C_COMPILER_LAUNCHER=${{ env.CMAKE_C_COMPILER_LAUNCHER }} \ + -S ${OPENVINO_REPO} \ + -B ${BUILD_DIR} + + - name: Clean sccache stats + run: ${SCCACHE_PATH} --zero-stats + + - name: Cmake build - OpenVINO + run: cmake --build ${BUILD_DIR} --parallel --config ${{ env.CMAKE_BUILD_TYPE }} + + - name: Show sccache stats + run: ${SCCACHE_PATH} --show-stats + + - name: Cmake install - OpenVINO + run: | + cmake -DCMAKE_INSTALL_PREFIX=${INSTALL_DIR} -P ${BUILD_DIR}/cmake_install.cmake + cmake -DCMAKE_INSTALL_PREFIX=${INSTALL_TEST_DIR} -DCOMPONENT=tests -P ${BUILD_DIR}/cmake_install.cmake + cmake -DCMAKE_INSTALL_PREFIX=${DEVELOPER_PACKAGE_DIR} -DCOMPONENT=developer_package -P ${BUILD_DIR}/cmake_install.cmake + cmake -DCMAKE_INSTALL_PREFIX=${INSTALL_DIR} -DCOMPONENT=python_wheels -P ${BUILD_DIR}/cmake_install.cmake + + - name: Pack Artifacts + run: | + + # Add the ONNX Runtime version and skip tests list to the archive to use in the ONNX Runtime Job + # w/o the need to checkout repository + + cp -R ${ONNX_RUNTIME_UTILS} ${INSTALL_DIR} + + pushd ${INSTALL_DIR} + tar -czvf ${BUILD_DIR}/openvino_package.tar.gz * + popd + + pushd ${DEVELOPER_PACKAGE_DIR} + tar -czvf ${BUILD_DIR}/openvino_developer_package.tar.gz * + popd + + pushd ${INSTALL_TEST_DIR} + tar -czvf ${BUILD_DIR}/openvino_tests.tar.gz * + popd + + - name: Build Debian packages + if: ${{ 'false' }} + run: | + /usr/bin/python3.8 -m pip install -U pip + /usr/bin/python3.8 -m pip install -r ${OPENVINO_REPO}/src/bindings/python/wheel/requirements-dev.txt + /usr/bin/python3.8 -m pip install -r ${OPENVINO_REPO}/src/bindings/python/src/compatibility/openvino/requirements-dev.txt + cmake -UPYTHON* \ + -DENABLE_PYTHON_PACKAGING=ON \ + -DENABLE_TESTS=OFF \ + -DPython3_EXECUTABLE=/usr/bin/python3.8 \ + -DCPACK_GENERATOR=DEB \ + ${BUILD_DIR} + cmake --build ${BUILD_DIR} --parallel --config ${{ env.CMAKE_BUILD_TYPE }} --target package + + - name: Cmake & Build - OpenVINO Contrib + run: | + cmake \ + -DBUILD_nvidia_plugin=OFF \ + -DCUSTOM_OPERATIONS="calculate_grid;complex_mul;fft;grid_sample;sparse_conv;sparse_conv_transpose" \ + -DOPENVINO_EXTRA_MODULES=${OPENVINO_CONTRIB_REPO}/modules \ + -S ${OPENVINO_REPO} \ + -B ${BUILD_DIR} + cmake --build ${BUILD_DIR} --parallel --config ${{ env.CMAKE_BUILD_TYPE }} + + # + # Upload build artifacts + # + + - name: Upload openvino package + if: ${{ always() }} + uses: actions/upload-artifact@v3 + with: + name: openvino_package + path: ${{ env.BUILD_DIR }}/openvino_package.tar.gz + if-no-files-found: 'error' + + - name: Upload openvino developer package + if: ${{ always() }} + uses: actions/upload-artifact@v3 + with: + name: openvino_developer_package + path: ${{ env.BUILD_DIR }}/openvino_developer_package.tar.gz + if-no-files-found: 'error' + + - name: Upload openvino debian packages + if: ${{ 'false' }} + uses: actions/upload-artifact@v3 + with: + name: openvino_debian_packages + path: ${{ env.BUILD_DIR }}/*.deb + if-no-files-found: 'error' + + - name: Upload openvino tests package + if: ${{ always() }} + uses: actions/upload-artifact@v3 + with: + name: openvino_tests + path: ${{ env.BUILD_DIR }}/openvino_tests.tar.gz + if-no-files-found: 'error' + + Debian_Packages: + name: Debian Packages + needs: Build + if: ${{ 'false' }} + uses: ./.github/workflows/job_debian_packages.yml + with: + runner: 'aks-linux-16-cores-arm' + image: 'openvinogithubactions.azurecr.io/dockerhub/ubuntu:20.04' + + Samples: + needs: [ Build, Smart_CI ] + if: fromJSON(needs.smart_ci.outputs.affected_components).samples + uses: ./.github/workflows/job_samples_tests.yml + with: + runner: 'aks-linux-16-cores-arm' + image: 'openvinogithubactions.azurecr.io/dockerhub/ubuntu:20.04' + affected-components: ${{ needs.smart_ci.outputs.affected_components }} + + ONNX_Runtime: + name: ONNX Runtime Integration + if: fromJSON(needs.smart_ci.outputs.affected_components).ONNX_RT + needs: [ Build, Smart_CI ] + uses: ./.github/workflows/job_onnx_runtime.yml + with: + runner: 'aks-linux-16-cores-arm' + container: '{"image": "openvinogithubactions.azurecr.io/dockerhub/ubuntu:20.04", "volumes": ["/mount/caches:/mount/caches"], "options": "-e SCCACHE_AZURE_BLOB_CONTAINER -e SCCACHE_AZURE_CONNECTION_STRING"}' + sccache-azure-key-prefix: 'ubuntu20_aarch64_onnxruntime' + + CXX_Unit_Tests: + name: C++ unit tests + needs: [ Build, Smart_CI ] + uses: ./.github/workflows/job_cxx_unit_tests.yml + with: + runner: 'aks-linux-16-cores-arm' + image: 'openvinogithubactions.azurecr.io/dockerhub/ubuntu:20.04' + affected-components: ${{ needs.smart_ci.outputs.affected_components }} + + Python_Unit_Tests: + name: Python unit tests + needs: [ Build, Smart_CI ] + uses: ./.github/workflows/job_python_unit_tests.yml + with: + runner: 'aks-linux-16-cores-arm' + container: '{"image": "openvinogithubactions.azurecr.io/dockerhub/ubuntu:20.04", "volumes": ["/mount/caches:/mount/caches"]}' + affected-components: ${{ needs.smart_ci.outputs.affected_components }} + + CPU_Functional_Tests: + name: CPU functional tests + if: fromJSON(needs.smart_ci.outputs.affected_components).CPU.test + needs: [ Build, Smart_CI ] + uses: ./.github/workflows/job_cpu_functional_tests.yml + with: + runner: 'aks-linux-16-cores-arm' + image: 'openvinogithubactions.azurecr.io/dockerhub/ubuntu:20.04' + + TensorFlow_Hub_Models_Tests: + name: TensorFlow Hub Models tests + if: ${{ 'false' }} # TODO: Enable once the dependencies are ready for arm (no tensorflow-text available for arm from PyPI) + # 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 ] + uses: ./.github/workflows/job_tensorflow_hub_models_tests.yml + with: + runner: 'aks-linux-16-cores-arm' + container: '{"image": "openvinogithubactions.azurecr.io/dockerhub/ubuntu:20.04"}' + event: ${{ github.event_name }} + + TensorFlow_Hub_Performance_Models_Tests: + name: TensorFlow Hub Performance Models tests + if: ${{ 'false' }} # TODO: Enable once the dependencies are ready for arm (no tensorflow-text available for arm from PyPI) + # 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 ] + uses: ./.github/workflows/job_tensorflow_hub_performance_models_tests.yml + with: + runner: 'aks-linux-16-cores-arm' + container: '{"image": "openvinogithubactions.azurecr.io/dockerhub/ubuntu:20.04"}' + event: ${{ github.event_name }} + + PyTorch_Models_Tests: + name: PyTorch Models tests + if: ${{ 'false' }} # TODO: Enable once the dependencies are ready for arm (no tensorflow-text available for arm from PyPI) + # if: fromJSON(needs.smart_ci.outputs.affected_components).PyTorch_FE.test + needs: [ Build, Smart_CI ] + uses: ./.github/workflows/job_pytorch_models_tests.yml + with: + runner: 'aks-linux-16-cores-arm' + container: '{"image": "openvinogithubactions.azurecr.io/dockerhub/ubuntu:20.04"}' + event: ${{ github.event_name }} + + Overall_Status: + name: ci/gha_overall_status + needs: [Smart_CI, Build, Debian_Packages, Samples, ONNX_Runtime, CXX_Unit_Tests, Python_Unit_Tests, CPU_Functional_Tests, + TensorFlow_Hub_Models_Tests, TensorFlow_Hub_Performance_Models_Tests, PyTorch_Models_Tests] + if: ${{ always() }} + runs-on: ubuntu-latest + steps: + - name: Check status of all jobs + if: >- + ${{ + contains(needs.*.result, 'failure') || + contains(needs.*.result, 'cancelled') + }} + run: exit 1 diff --git a/.github/workflows/linux_conditional_compilation.yml b/.github/workflows/linux_conditional_compilation.yml index 3db29914117ba7..1b323041ff1675 100644 --- a/.github/workflows/linux_conditional_compilation.yml +++ b/.github/workflows/linux_conditional_compilation.yml @@ -60,6 +60,7 @@ jobs: GITHUB_WORKSPACE: '/__w/openvino/openvino' OPENVINO_REPO: /__w/openvino/openvino/openvino INSTALL_DIR: /__w/openvino/openvino/openvino_install + INSTALL_TEST_DIR: /__w/openvino/openvino/tests_install BUILD_DIR: /__w/openvino/openvino/openvino_build SELECTIVE_BUILD_STAT_DIR: /__w/openvino/openvino/selective_build_stat MODELS_PATH: /__w/openvino/openvino/testdata @@ -163,7 +164,9 @@ jobs: run: ${SCCACHE_PATH} --show-stats - name: Cmake install - OpenVINO - run: cmake -DCMAKE_INSTALL_PREFIX=${INSTALL_DIR} -P ${BUILD_DIR}/cmake_install.cmake + run: | + cmake -DCMAKE_INSTALL_PREFIX=${INSTALL_DIR} -P ${BUILD_DIR}/cmake_install.cmake + cmake -DCMAKE_INSTALL_PREFIX=${INSTALL_TEST_DIR} -DCOMPONENT=tests -P ${BUILD_DIR}/cmake_install.cmake - name: Build C++ samples - OpenVINO build tree run: | @@ -189,13 +192,26 @@ jobs: tar -czvf ${BUILD_DIR}/openvino_selective_build_stat.tar.gz * popd - pushd ${OPENVINO_REPO} + pushd ${INSTALL_DIR} + tar -czvf ${BUILD_DIR}/openvino_package.tar.gz \ + install_dependencies/install_openvino_dependencies.sh + popd + + pushd ${INSTALL_TEST_DIR} tar -czvf ${BUILD_DIR}/openvino_tests.tar.gz \ - bin/intel64/Release/ov_cpu_func_tests \ - src/tests/test_utils/functional_test_utils/layer_tests_summary/* \ - scripts/install_dependencies/* + tests/ov_cpu_func_tests \ + tests/libtemplate_extension.so \ + tests/functional_test_utils/layer_tests_summary/* popd + - name: Upload openvino package + if: ${{ always() }} + uses: actions/upload-artifact@v3 + with: + name: openvino_package + path: ${{ env.BUILD_DIR }}/openvino_package.tar.gz + if-no-files-found: 'error' + - name: Upload selective build statistics package if: ${{ always() }} uses: actions/upload-artifact@v3 @@ -310,74 +326,9 @@ jobs: CPU_Functional_Tests: name: CPU functional tests - needs: [Build, Smart_CI] - timeout-minutes: 25 - defaults: - run: - shell: bash - runs-on: aks-linux-8-cores-16gb - container: - image: openvinogithubactions.azurecr.io/dockerhub/ubuntu:22.04 - env: - OPENVINO_REPO: /__w/openvino/openvino/openvino - DEBIAN_FRONTEND: noninteractive # to prevent apt-get from waiting user input - INSTALL_TEST_DIR: /__w/openvino/openvino/install/tests - PARALLEL_TEST_SCRIPT: /__w/openvino/openvino/install/tests/src/tests/test_utils/functional_test_utils/layer_tests_summary/run_parallel.py - PARALLEL_TEST_CACHE: /__w/openvino/openvino/install/tests/test_cache.lst if: fromJSON(needs.smart_ci.outputs.affected_components).CPU.test - - steps: - - name: Download OpenVINO tests package - uses: actions/download-artifact@v3 - with: - name: openvino_tests - path: ${{ env.INSTALL_TEST_DIR }} - - - name: Extract OpenVINO tests package - run: tar -xvzf ${INSTALL_TEST_DIR}/openvino_tests.tar.gz -C ${INSTALL_TEST_DIR} - - - name: Install OpenVINO dependencies - run: bash ${INSTALL_TEST_DIR}/scripts/install_dependencies/install_openvino_dependencies.sh -c=core -c=gpu -y - - - name: Fetch setup_python action - uses: actions/checkout@v4 - with: - sparse-checkout: | - .github/actions/setup_python/action.yml - sparse-checkout-cone-mode: false - path: ${{ env.OPENVINO_REPO }} - - - name: Setup Python ${{ env.PYTHON_VERSION }} - uses: ./openvino/.github/actions/setup_python - with: - version: ${{ env.PYTHON_VERSION }} - should-setup-pip-paths: 'false' - - - name: Install python dependencies for run_parallel.py - run: python3 -m pip install -r ${INSTALL_TEST_DIR}/src/tests/test_utils/functional_test_utils/layer_tests_summary/requirements.txt - - - name: Restore tests execution time - uses: actions/cache/restore@v3 - with: - path: ${{ env.PARALLEL_TEST_CACHE }} - key: ${{ runner.os }}-tests-functional-cpu-stamp-${{ github.sha }} - restore-keys: | - ${{ runner.os }}-tests-functional-cpu-stamp - - - name: Intel CPU plugin func tests (parallel) - run: python3 ${PARALLEL_TEST_SCRIPT} -e ${INSTALL_TEST_DIR}/bin/intel64/Release/ov_cpu_func_tests -c ${PARALLEL_TEST_CACHE} -w ${INSTALL_TEST_DIR} -s suite -rf 0 -- --gtest_print_time=1 --gtest_filter=*smoke* - timeout-minutes: 20 - - - name: Upload Test Results - uses: actions/upload-artifact@v3 - if: ${{ !cancelled() }} - with: - name: test-results-functional-cpu - path: | - ${{ env.INSTALL_TEST_DIR }}/TEST*.xml - ${{ env.INSTALL_TEST_DIR }}/logs/failed/*.log - ${{ env.INSTALL_TEST_DIR }}/logs/crashed/*.log - ${{ env.INSTALL_TEST_DIR }}/logs/hanged/*.log - ${{ env.INSTALL_TEST_DIR }}/logs/interapted/*.log - ${{ env.INSTALL_TEST_DIR }}/logs/disabled_tests.log - if-no-files-found: 'error' + needs: [ Build, Smart_CI ] + uses: ./.github/workflows/job_cpu_functional_tests.yml + with: + runner: 'aks-linux-8-cores-32gb' + image: 'openvinogithubactions.azurecr.io/dockerhub/ubuntu:22.04' diff --git a/.github/workflows/mac.yml b/.github/workflows/mac.yml index d8ac800e18b7d5..2a59d9de4d50b2 100644 --- a/.github/workflows/mac.yml +++ b/.github/workflows/mac.yml @@ -33,27 +33,41 @@ env: PYTHON_VERSION: '3.11' jobs: + + Smart_CI: + runs-on: ubuntu-latest + outputs: + affected_components: "${{ steps.smart_ci.outputs.affected_components }}" + skip_workflow: "${{ steps.smart_ci.outputs.skip_workflow }}" + steps: + - name: checkout action + uses: actions/checkout@v4 + with: + sparse-checkout: .github/actions/smart-ci + + - name: Get affected components + id: smart_ci + uses: ./.github/actions/smart-ci + with: + repository: ${{ github.repository }} + pr: ${{ github.event.number }} + commit_sha: ${{ github.sha }} + component_pattern: "category: (.*)" + repo_token: ${{ secrets.GITHUB_TOKEN }} + skip_when_only_listed_labels_set: 'docs' + skip_when_only_listed_files_changed: '*.md,*.rst,*.png,*.jpg,*.svg' + Build: + needs: Smart_CI timeout-minutes: 150 defaults: run: shell: bash - strategy: - max-parallel: 2 - fail-fast: false - matrix: - include: - - arhitecture: 'x86_64' - machine: 'macos-13-large' - macos_deployment_target: '10.12' - - arhitecture: 'arm64' - machine: 'macos-13-xlarge' - macos_deployment_target: '11.0' - runs-on: ${{ matrix.machine }} + runs-on: 'macos-13-large' env: CMAKE_BUILD_TYPE: 'Release' CMAKE_GENERATOR: 'Ninja Multi-Config' - MACOSX_DEPLOYMENT_TARGET: ${{ matrix.macos_deployment_target }} + MACOSX_DEPLOYMENT_TARGET: '10.12' CMAKE_CXX_COMPILER_LAUNCHER: ccache CMAKE_C_COMPILER_LAUNCHER: ccache OPENVINO_REPO: ${{ github.workspace }}/openvino @@ -125,9 +139,9 @@ jobs: # github.ref_name is 'ref/PR_#' in case of the PR, and 'branch_name' when executed on push save: ${{ github.ref_name == 'master' && 'true' || 'false' }} verbose: 2 - key: ${{ runner.os }}-${{ matrix.arhitecture }}-main + key: ${{ runner.os }}-${{ runner.arch }}-main restore-keys: | - ${{ runner.os }}-${{ matrix.arhitecture }}-main + ${{ runner.os }}-${{ runner.arch }}-main - name: CMake configure run: | @@ -184,7 +198,7 @@ jobs: if: ${{ always() }} uses: actions/upload-artifact@v3 with: - name: openvino_package_${{ matrix.arhitecture }} + name: openvino_package path: ${{ env.BUILD_DIR }}/openvino_package.tar.gz if-no-files-found: 'error' @@ -192,650 +206,39 @@ jobs: if: ${{ always() }} uses: actions/upload-artifact@v3 with: - name: openvino_tests_${{ matrix.arhitecture }} + name: openvino_tests path: ${{ env.BUILD_DIR }}/openvino_tests.tar.gz if-no-files-found: 'error' Samples: - needs: Build - timeout-minutes: 5 - defaults: - run: - shell: bash - strategy: - max-parallel: 2 - fail-fast: false - matrix: - include: - - arhitecture: 'x86_64' - machine: 'macos-13' - - arhitecture: 'arm64' - machine: 'macos-13-xlarge' - runs-on: ${{ matrix.machine }} - env: - OPENVINO_REPO: ${{ github.workspace }}/openvino - INSTALL_DIR: ${{ github.workspace }}/install - INSTALL_TEST_DIR: ${{ github.workspace }}/install/tests - BUILD_DIR: ${{ github.workspace }}/build - - steps: - - # - # Initialize OpenVINO - # - - - name: Download OpenVINO package - uses: actions/download-artifact@v3 - with: - name: openvino_package_${{ matrix.arhitecture }} - path: ${{ env.INSTALL_DIR }} - - - name: Download OpenVINO tests package - uses: actions/download-artifact@v3 - with: - name: openvino_tests_${{ matrix.arhitecture }} - path: ${{ env.INSTALL_TEST_DIR }} - - - name: Extract OpenVINO packages - run: | - pushd ${INSTALL_DIR} - tar -xzf openvino_package.tar.gz -C ${INSTALL_DIR} - popd - - pushd ${INSTALL_TEST_DIR} - tar -xzf openvino_tests.tar.gz -C ${INSTALL_DIR} - popd - - - name: Install dependencies - run: brew install coreutils - - - name: Fetch setup_python action - uses: actions/checkout@v4 - with: - sparse-checkout: | - .github/actions/setup_python/action.yml - sparse-checkout-cone-mode: false - path: 'openvino' - - - name: Setup Python ${{ env.PYTHON_VERSION }} - uses: ./openvino/.github/actions/setup_python - with: - version: ${{ env.PYTHON_VERSION }} - should-setup-pip-paths: 'false' - self-hosted-runner: 'false' - - - name: Build cpp samples - run: ${INSTALL_DIR}/samples/cpp/build_samples.sh -i ${INSTALL_DIR} -b ${BUILD_DIR}/cpp_samples - env: - CMAKE_COMPILE_WARNING_AS_ERROR: 'ON' - - - name: Build c samples - run: ${INSTALL_DIR}/samples/c/build_samples.sh -i ${INSTALL_DIR} -b ${BUILD_DIR}/c_samples - env: - CMAKE_COMPILE_WARNING_AS_ERROR: 'ON' - - # - # Tests - # - - - name: Samples tests - run: | - export WORKSPACE=${INSTALL_DIR} - export IE_APP_PATH=${INSTALL_DIR}/samples_bin - export IE_APP_PYTHON_PATH=${INSTALL_DIR}/samples/python - export SHARE=${INSTALL_TEST_DIR}/smoke_tests/samples_smoke_tests_data - - python3 -m pip install --ignore-installed PyYAML -r ${INSTALL_TEST_DIR}/smoke_tests/requirements.txt - - source ${INSTALL_DIR}/setupvars.sh - - python3 -m pytest -sv ${INSTALL_TEST_DIR}/smoke_tests \ - --env_conf ${INSTALL_TEST_DIR}/smoke_tests/env_config.yml \ - --junitxml=${INSTALL_TEST_DIR}/TEST-SamplesSmokeTests.xml - - - name: Upload Test Results - uses: actions/upload-artifact@v3 - if: ${{ !cancelled() }} - with: - name: test-results-samples-${{ matrix.arhitecture }} - path: ${{ env.INSTALL_TEST_DIR }}/TEST*.xml - if-no-files-found: 'error' + needs: [ Build, Smart_CI ] + if: fromJSON(needs.smart_ci.outputs.affected_components).samples + uses: ./.github/workflows/job_samples_tests.yml + with: + runner: 'macos-13' + affected-components: ${{ needs.smart_ci.outputs.affected_components }} CXX_Unit_Tests: - name: C++ Unit tests - needs: Build - timeout-minutes: 20 - defaults: - run: - shell: bash - strategy: - max-parallel: 2 - fail-fast: false - matrix: - include: - - arhitecture: 'x86_64' - machine: 'macos-13' - - arhitecture: 'arm64' - machine: 'macos-13-xlarge' - runs-on: ${{ matrix.machine }} - env: - INSTALL_DIR: ${{ github.workspace }}/install - INSTALL_TEST_DIR: ${{ github.workspace }}/install/tests - - steps: - # - # Dependencies - # - - - name: Download OpenVINO package - uses: actions/download-artifact@v3 - with: - name: openvino_package_${{ matrix.arhitecture }} - path: ${{ env.INSTALL_DIR }} - - - name: Download OpenVINO tests package - uses: actions/download-artifact@v3 - with: - name: openvino_tests_${{ matrix.arhitecture }} - path: ${{ env.INSTALL_TEST_DIR }} - - - name: Extract OpenVINO packages - run: | - pushd ${{ env.INSTALL_DIR }} - tar -xzf openvino_package.tar.gz -C ${{ env.INSTALL_DIR }} && rm openvino_package.tar.gz || exit 1 - popd - pushd ${{ env.INSTALL_TEST_DIR }} - tar -xzf openvino_tests.tar.gz -C ${{ env.INSTALL_DIR }} && rm openvino_tests.tar.gz || exit 1 - popd - - # - # Tests - # - - - name: OpenVINO Core Unit Tests - run: | - source ${{ env.INSTALL_DIR }}/setupvars.sh - ${{ env.INSTALL_TEST_DIR }}/ov_core_unit_tests --gtest_print_time=1 --gtest_filter=-*IE_GPU* \ - --gtest_output=xml:${{ env.INSTALL_TEST_DIR }}/TEST-NGraphUT.xml - - - name: OpenVINO Inference Functional Tests - run: | - source ${{ env.INSTALL_DIR }}/setupvars.sh - ${{ env.INSTALL_TEST_DIR }}/ov_inference_functional_tests --gtest_print_time=1 \ - --gtest_output=xml:${{ env.INSTALL_TEST_DIR }}/TEST-InferenceFunc.xml - - - name: OpenVINO Inference Unit Tests - run: | - source ${{ env.INSTALL_DIR }}/setupvars.sh - ${{ env.INSTALL_TEST_DIR }}/ov_inference_unit_tests --gtest_print_time=1 \ - --gtest_output=xml:${{ env.INSTALL_TEST_DIR }}/TEST-InferenceUnit.xml - - - name: Low Precision Transformations Tests - run: | - source ${{ env.INSTALL_DIR }}/setupvars.sh - - # Skips under Ticket: 122660 - skip_filter=${{ matrix.arhitecture == 'arm64' && '--gtest_filter=-*smoke_LPT/FoldFakeQuantizeInTransformations.CompareFunctions*' || '' }} - - ${{ env.INSTALL_TEST_DIR }}/ov_lp_transformations_tests --gtest_print_time=1 "$skip_filter" \ - --gtest_output=xml:${{ env.INSTALL_TEST_DIR }}/TEST-LpTransformations.xml - - - name: OpenVINO Conditional compilation tests - run: | - source ${{ env.INSTALL_DIR }}/setupvars.sh - ${{ env.INSTALL_TEST_DIR }}/ov_conditional_compilation_tests --gtest_print_time=1 \ - --gtest_output=xml:${{ env.INSTALL_TEST_DIR }}/TEST-ConditionalCompilation.xml - - - name: IR frontend tests - run: | - source ${{ env.INSTALL_DIR }}/setupvars.sh - ${{ env.INSTALL_TEST_DIR }}/ov_ir_frontend_tests --gtest_print_time=1 \ - --gtest_output=xml:${{ env.INSTALL_TEST_DIR }}/TEST-IRFrontend.xml - - - name: PaddlePaddle frontend tests - if: ${{ 'false' }} - run: | - source ${{ env.INSTALL_DIR }}/setupvars.sh - ${{ env.INSTALL_TEST_DIR }}/paddle_tests --gtest_print_time=1 --gtest_filter=*smoke* \ - --gtest_output=xml:${{ env.INSTALL_TEST_DIR }}/TEST-PaddleTests.xml - - - name: ONNX frontend tests - if: ${{ matrix.arhitecture == 'x86_64' }} # Ticket for ARM64: 122663 - run: | - source ${{ env.INSTALL_DIR }}/setupvars.sh - - ${{ env.INSTALL_TEST_DIR }}/ov_onnx_frontend_tests --gtest_print_time=1 --gtest_filter=-*IE_GPU* \ - --gtest_output=xml:${{ env.INSTALL_TEST_DIR }}/TEST-ONNXFrontend.xml - - - name: TensorFlow Common tests - run: | - source ${{ env.INSTALL_DIR }}/setupvars.sh - ${{ env.INSTALL_TEST_DIR }}/ov_tensorflow_common_tests --gtest_print_time=1 \ - --gtest_output=xml:${{ env.INSTALL_TEST_DIR }}/TEST-TensorFlowCommonFrontend.xml - - - name: TensorFlow frontend tests - run: | - source ${{ env.INSTALL_DIR }}/setupvars.sh - - # Skips under Ticket: 122666 - skip_filter=${{ matrix.arhitecture == 'arm64' && '--gtest_filter=-*CompileModelsTests.ModelWithSplitConvConcat*:*NgramCompilation*' || '' }} - - ${{ env.INSTALL_TEST_DIR }}/ov_tensorflow_frontend_tests --gtest_print_time=1 "$skip_filter" \ - --gtest_output=xml:${{ env.INSTALL_TEST_DIR }}/TEST-TensorFlowFrontend.xml - - - name: TensorFlow Lite frontend tests - run: | - source ${{ env.INSTALL_DIR }}/setupvars.sh - ${{ env.INSTALL_TEST_DIR }}/ov_tensorflow_lite_frontend_tests --gtest_print_time=1 \ - --gtest_output=xml:${{ env.INSTALL_TEST_DIR }}/TEST-TensorFlowLiteFrontend.xml - - - name: Transformations func tests - run: | - source ${{ env.INSTALL_DIR }}/setupvars.sh - - # Skips under Ticket: 122668 - skip_filter=${{ matrix.arhitecture == 'arm64' && '--gtest_filter=-*TransformationTestsF.CompressQuantizeWeights*:*TransformationTests/CompressQuantizeWeightsTests.FusionTest*' || '' }} - - ${{ env.INSTALL_TEST_DIR }}/ov_transformations_tests --gtest_print_time=1 "$skip_filter" \ - --gtest_output=xml:${{ env.INSTALL_TEST_DIR }}/TEST-Transformations.xml - - - name: Common test utils tests - run: | - source ${{ env.INSTALL_DIR }}/setupvars.sh - ${{ env.INSTALL_TEST_DIR }}/ov_util_tests --gtest_print_time=1 \ - --gtest_output=xml:${{ env.INSTALL_TEST_DIR }}/TEST-commonUtilsTests.xml - - - name: Snippets func tests - run: | - source ${{ env.INSTALL_DIR }}/setupvars.sh - ${{ env.INSTALL_TEST_DIR }}/ov_snippets_func_tests --gtest_print_time=1 \ - --gtest_output=xml:${{ env.INSTALL_TEST_DIR }}/TEST-SnippetsFuncTests.xml - - - name: CPU plugin unit tests - run: | - source ${{ env.INSTALL_DIR }}/setupvars.sh - ${{ env.INSTALL_TEST_DIR }}/ov_cpu_unit_tests --gtest_print_time=1 \ - --gtest_output=xml:${{ env.INSTALL_TEST_DIR }}/TEST-CPUUnitTests.xml - - - name: ov_subgraphs_dumper_tests tests - run: | - source ${{ env.INSTALL_DIR }}/setupvars.sh - ${{ env.INSTALL_TEST_DIR }}/ov_subgraphs_dumper_tests --gtest_print_time=1 \ - --gtest_output=xml:${INSTALL_TEST_DIR}/TEST-ov_subgraphs_dumper_tests.xml - - - name: Template OpImpl tests - run: | - source ${{ env.INSTALL_DIR }}/setupvars.sh - ${{ env.INSTALL_TEST_DIR }}/ov_op_conformance_tests --gtest_print_time=1 --device=TEMPLATE --gtest_filter="*OpImpl*" \ - --gtest_output=xml:${INSTALL_TEST_DIR}/TEST-TemplateOpImplTests.xml - - - name: AUTO unit tests - run: | - source ${{ env.INSTALL_DIR }}/setupvars.sh - ${{ env.INSTALL_TEST_DIR }}/ov_auto_unit_tests --gtest_print_time=1 \ - --gtest_output=xml:${{ env.INSTALL_TEST_DIR }}/TEST-ov_auto_unit_tests.xml - - - name: AUTO func Tests - run: | - source ${{ env.INSTALL_DIR }}/setupvars.sh - ${{ env.INSTALL_TEST_DIR }}/ov_auto_func_tests --gtest_print_time=1 \ - --gtest_output=xml:${{ env.INSTALL_TEST_DIR }}/TEST-ov_auto_func_tests.xml - - - name: Template plugin func tests - run: | - source ${{ env.INSTALL_DIR }}/setupvars.sh - ${{ env.INSTALL_TEST_DIR }}/ov_template_func_tests --gtest_print_time=1 \ - --gtest_filter=*smoke* \ - --gtest_output=xml:${{ env.INSTALL_TEST_DIR }}/TEST-TemplateFuncTests.xml - - - name: Inference Engine C API tests - run: | - source ${{ env.INSTALL_DIR }}/setupvars.sh - ${{ env.INSTALL_TEST_DIR }}/InferenceEngineCAPITests --gtest_print_time=1 \ - --gtest_output=xml:${{ env.INSTALL_TEST_DIR }}/TEST-InferenceEngineCAPITests.xml - - - name: OpenVINO C API tests - run: | - source ${{ env.INSTALL_DIR }}/setupvars.sh - ${{ env.INSTALL_TEST_DIR }}/ov_capi_test --gtest_print_time=1 \ - --gtest_output=xml:${{ env.INSTALL_TEST_DIR }}/TEST-OpenVINOCAPITests.xml - - - name: AutoBatch unit tests - run: | - source ${{ env.INSTALL_DIR }}/setupvars.sh - ${{ env.INSTALL_TEST_DIR }}/ov_auto_batch_unit_tests --gtest_output=xml:${{ env.INSTALL_TEST_DIR }}/TEST-ov_auto_batch_unit_tests.xml - - - name: AutoBatch func tests - run: | - source ${{ env.INSTALL_DIR }}/setupvars.sh - ${{ env.INSTALL_TEST_DIR }}/ov_auto_batch_func_tests --gtest_output=xml:${{ env.INSTALL_TEST_DIR }}/TEST-ov_auto_batch_func_tests.xml - - - name: Proxy Plugin func tests - run: | - source ${{ env.INSTALL_DIR }}/setupvars.sh - ${{ env.INSTALL_TEST_DIR }}/ov_proxy_plugin_tests --gtest_print_time=1 --gtest_output=xml:${{ env.INSTALL_TEST_DIR }}/TEST-OVProxyTests.xml - - - name: Hetero unit tests - run: | - source ${{ env.INSTALL_DIR }}/setupvars.sh - ${{ env.INSTALL_TEST_DIR }}/ov_hetero_unit_tests --gtest_print_time=1 --gtest_output=xml:${{ env.INSTALL_TEST_DIR }}/TEST-OVHeteroUnitTests.xml - - - name: Hetero func tests - run: | - source ${{ env.INSTALL_DIR }}/setupvars.sh - ${{ env.INSTALL_TEST_DIR }}/ov_hetero_func_tests --gtest_print_time=1 --gtest_output=xml:${{ env.INSTALL_TEST_DIR }}/TEST-OVHeteroFuncTests.xml - - - name: Upload Test Results - uses: actions/upload-artifact@v3 - if: ${{ always() }} - with: - name: test-results-cpp-${{ matrix.arhitecture }} - path: ${{ env.INSTALL_TEST_DIR }}/TEST*.xml - if-no-files-found: 'error' + name: C++ unit tests + needs: [ Build, Smart_CI ] + uses: ./.github/workflows/job_cxx_unit_tests.yml + with: + runner: 'macos-13' + affected-components: ${{ needs.smart_ci.outputs.affected_components }} Python_Unit_Tests: name: Python unit tests - needs: Build - timeout-minutes: 55 - defaults: - run: - shell: bash - strategy: - max-parallel: 2 - fail-fast: false - matrix: - include: - - arhitecture: 'x86_64' - machine: 'macos-13' - - arhitecture: 'arm64' - machine: 'macos-13-xlarge' - runs-on: ${{ matrix.machine }} - env: - OPENVINO_REPO: ${{ github.workspace }}/openvino - OPENVINO_CONTRIB_REPO: ${{ github.workspace }}/openvino_contrib - INSTALL_DIR: ${{ github.workspace }}/install - INSTALL_TEST_DIR: ${{ github.workspace }}/install/tests - LAYER_TESTS_INSTALL_DIR: ${{ github.workspace }}/install/tests/layer_tests - steps: - - name: Fetch setup_python action - uses: actions/checkout@v4 - with: - sparse-checkout: | - .github/actions/setup_python/action.yml - sparse-checkout-cone-mode: false - path: 'openvino' - - - name: Setup Python ${{ env.PYTHON_VERSION }} - uses: ./openvino/.github/actions/setup_python - with: - version: ${{ env.PYTHON_VERSION }} - should-setup-pip-paths: 'false' - self-hosted-runner: 'false' - - # - # Dependencies - # - - - name: Download OpenVINO package - uses: actions/download-artifact@v3 - with: - name: openvino_package_${{ matrix.arhitecture }} - path: ${{ env.INSTALL_DIR }} - - - name: Download OpenVINO tests package - uses: actions/download-artifact@v3 - with: - name: openvino_tests_${{ matrix.arhitecture }} - path: ${{ env.INSTALL_TEST_DIR }} - - - name: Extract OpenVINO packages - run: | - pushd ${{ env.INSTALL_DIR }} - tar -xzf openvino_package.tar.gz -C ${{ env.INSTALL_DIR }} - popd - - pushd ${{ env.INSTALL_TEST_DIR }} - tar -xzf openvino_tests.tar.gz -C ${{ env.INSTALL_DIR }} - popd - - - name: Install OpenVINO Python wheels - run: | - # Install the core OV wheel - python3 -m pip install ${{ env.INSTALL_DIR }}/tools/openvino-*.whl - - # mxnet is only available on x86_64 - extras_to_install="caffe,kaldi,onnx,tensorflow2,pytorch" - if [[ "${{ matrix.arhitecture }}" == "x86_64" ]]; then - extras_to_install="mxnet,$extras_to_install" - fi - - # Find and install OV dev wheel - pushd ${{ env.INSTALL_DIR }}/tools - ov_dev_wheel_name=$(find . -name 'openvino_dev*.whl') - python3 -m pip install $ov_dev_wheel_name[$extras_to_install] - popd - - - name: Install Python API tests dependencies - run: | - # For torchvision to OpenVINO preprocessing converter - python3 -m pip install -r ${{ env.INSTALL_TEST_DIR }}/python/preprocess/torchvision/requirements.txt - - # TODO: replace with Python API tests requirements - python3 -m pip install -r ${{ env.INSTALL_TEST_DIR }}/mo/requirements_dev.txt - - - name: Python API 1.0 Tests - run: | - python3 -m pytest -s ${{ env.INSTALL_TEST_DIR }}/pyngraph \ - --junitxml=${{ env.INSTALL_TEST_DIR }}/TEST-Pyngraph.xml \ - --ignore=${{ env.INSTALL_TEST_DIR }}/pyngraph/tests_compatibility/test_onnx/test_zoo_models.py \ - --ignore=${{ env.INSTALL_TEST_DIR }}/pyngraph/tests_compatibility/test_onnx/test_backend.py - - - name: Python API 2.0 Tests - run: | - # For python imports to import pybind_mock_frontend - export PYTHONPATH=${{ env.INSTALL_TEST_DIR }}:$PYTHONPATH - # for 'template' extension - export DYLD_LIBRARY_PATH=${{ env.INSTALL_TEST_DIR }}:$DYLD_LIBRARY_PATH - - python3 -m pytest -sv ${{ env.INSTALL_TEST_DIR }}/pyopenvino \ - --junitxml=${{ env.INSTALL_TEST_DIR }}/TEST-Pyngraph.xml \ - --ignore=${{ env.INSTALL_TEST_DIR }}/pyopenvino/tests/test_utils/test_utils.py - - - name: MO Python API Tests - run: | - python3 -m pip install -r ${{ env.LAYER_TESTS_INSTALL_DIR }}/requirements.txt - - # Used for 'test_utils' installed in '/python/openvino/test_utils' - export PYTHONPATH=${{ env.INSTALL_TEST_DIR }}/python/openvino/test_utils:${{ env.INSTALL_TEST_DIR }}/python:$PYTHONPATH - - python3 -m pytest ${{ env.LAYER_TESTS_INSTALL_DIR }}/mo_python_api_tests/ --junitxml=${{ env.INSTALL_TEST_DIR }}/TEST-test_mo_convert.xml - env: - TEST_DEVICE: CPU - TEST_PRECISION: FP16 - - - name: OVC Python API Tests - run: | - python3 -m pip install -r ${{ env.LAYER_TESTS_INSTALL_DIR }}/requirements.txt - - # Used for 'test_utils' installed in '/python/openvino/test_utils' - export PYTHONPATH=${{ env.INSTALL_TEST_DIR }}/python/openvino/test_utils:${{ env.INSTALL_TEST_DIR }}/python:$PYTHONPATH - - python3 -m pytest ${{ env.LAYER_TESTS_INSTALL_DIR }}/ovc_python_api_tests --junitxml=${{ env.INSTALL_TEST_DIR }}/TEST-test_ovc_convert.xml - env: - TEST_DEVICE: CPU - TEST_PRECISION: FP16 - - - name: Model Optimizer unit tests - run: | - export PYTHONPATH=${{ env.INSTALL_TEST_DIR }}:$PYTHONPATH - python3 -m pytest -s ${{ env.INSTALL_TEST_DIR }}/mo/unit_tests \ - --ignore=${{ env.INSTALL_TEST_DIR }}/mo/unit_tests/mo/front/mxnet \ - --junitxml=${{ env.INSTALL_TEST_DIR }}/TEST-ModelOptimizer.xml - - - name: PyTorch Layer Tests - run: | - python3 -m pip install -r ${{ env.LAYER_TESTS_INSTALL_DIR }}/requirements.txt - export PYTHONPATH=${{ env.LAYER_TESTS_INSTALL_DIR }}:$PYTHONPATH - - python3 -m pytest ${{ env.LAYER_TESTS_INSTALL_DIR }}/pytorch_tests -m precommit --junitxml=${{ env.INSTALL_TEST_DIR }}/TEST-pytorch.xml - env: - TEST_DEVICE: CPU - TEST_PRECISION: FP16 - - - name: ONNX Layer Tests - run: | - python3 -m pip install -r ${{ env.LAYER_TESTS_INSTALL_DIR }}/requirements.txt - - export PYTHONPATH=${{ env.INSTALL_TEST_DIR }}/mo:$PYTHONPATH - - python3 -m pytest ${{ env.LAYER_TESTS_INSTALL_DIR }}/onnx_tests -m "not launch_only_if_manually_specified and precommit" --junitxml=${{ env.INSTALL_TEST_DIR }}/TEST-onnx.xml - env: - TEST_DEVICE: CPU - TEST_PRECISION: FP16 - - - name: TensorFlow 1 Layer Tests - TF FE - run: | - python3 -m pip install -r ${{ env.LAYER_TESTS_INSTALL_DIR }}/requirements.txt - - export PYTHONPATH=${{ env.INSTALL_TEST_DIR }}/mo:$PYTHONPATH - - python3 -m pytest ${{ env.LAYER_TESTS_INSTALL_DIR }}/tensorflow_tests/ --use_new_frontend -m precommit_tf_fe --junitxml=${{ env.INSTALL_TEST_DIR }}/TEST-tf_fe.xml - env: - TEST_DEVICE: CPU - - - name: TensorFlow 2 Layer Tests - TF FE - if: ${{ 'false' }} # Ticket: 123322 - run: | - python3 -m pip install -r ${{ env.LAYER_TESTS_INSTALL_DIR }}/requirements.txt - - export PYTHONPATH=${{ env.INSTALL_TEST_DIR }}/mo:$PYTHONPATH - - python3 -m pytest ${{ env.LAYER_TESTS_INSTALL_DIR }}/tensorflow2_keras_tests/ --use_new_frontend -m precommit_tf_fe --junitxml=${{ env.INSTALL_TEST_DIR }}/TEST-tf2_fe.xml - env: - TEST_DEVICE: CPU - - - name: TensorFlow 1 Layer Tests - Legacy FE - run: | - python3 -m pip install -r ${{ env.LAYER_TESTS_INSTALL_DIR }}/requirements.txt - - export PYTHONPATH=${{ env.INSTALL_TEST_DIR }}/mo:$PYTHONPATH - - python3 -m pytest ${{ env.LAYER_TESTS_INSTALL_DIR }}/tensorflow_tests/test_tf_Roll.py --ir_version=10 --junitxml=${{ env.INSTALL_TEST_DIR }}/TEST-tf_Roll.xml - - - name: TensorFlow 2 Layer Tests - Legacy FE - run: | - python3 -m pip install -r ${{ env.LAYER_TESTS_INSTALL_DIR }}/requirements.txt - - export PYTHONPATH=${{ env.INSTALL_TEST_DIR }}/mo:$PYTHONPATH - - python3 -m pytest ${{ env.LAYER_TESTS_INSTALL_DIR }}/tensorflow2_keras_tests/test_tf2_keras_activation.py \ - --ir_version=11 --junitxml=${{ env.INSTALL_TEST_DIR }}/TEST-tf2_Activation.xml -k "sigmoid" - env: - TEST_DEVICE: CPU - TEST_PRECISION: FP16 - - - name: TensorFlow Lite Layer Tests - TFL FE - run: | - python3 -m pip install -r ${{ env.LAYER_TESTS_INSTALL_DIR }}/requirements.txt - - export PYTHONPATH=${{ env.INSTALL_TEST_DIR }}/mo:$PYTHONPATH - - python3 -m pytest ${{ env.LAYER_TESTS_INSTALL_DIR }}/tensorflow_lite_tests/ --junitxml=${{ env.INSTALL_TEST_DIR }}/TEST-tfl_fe.xml - env: - TEST_DEVICE: CPU - TEST_PRECISION: FP16 - - - name: Python ONNX operators tests - if: ${{ 'false' }} # Ticket: 123325 - run: | - # Skip test_onnx/test_zoo_models and test_onnx/test_backend due to long execution time - ONNX Model Zoo tests are run separately - python3 -m pytest -sv ${{ env.INSTALL_TEST_DIR }}/onnx -k 'not cuda' \ - --junitxml=${{ env.INSTALL_TEST_DIR }}/TEST-onnx_frontend.xml \ - --ignore=${{ env.INSTALL_TEST_DIR }}/onnx/test_python/test_zoo_models.py - - - name: Python Frontend tests - run: | - python3 -m pip install -r ${{ env.LAYER_TESTS_INSTALL_DIR }}/requirements.txt - - export PYTHONPATH=${{ env.INSTALL_TEST_DIR }}/mo:$PYTHONPATH - - # to allow 'libtest_builtin_extensions.so' to find 'libopenvino_onnx_frontend.so' - source ${{ env.INSTALL_DIR }}/setupvars.sh - - python3 -m pytest ${{ env.LAYER_TESTS_INSTALL_DIR }}/py_frontend_tests --junitxml=${{ env.INSTALL_TEST_DIR }}/TEST-test_py_fontend.xml - - # TODO: install to 'tests' component via cpack - - name: OVC unit tests - run: python3 -m pytest -s ${{ env.INSTALL_TEST_DIR }}/ovc/unit_tests --junitxml=${{ env.INSTALL_TEST_DIR }}/TEST-OpenVinoConversion.xml - - - name: Upload Test Results - uses: actions/upload-artifact@v3 - if: ${{ always() }} - with: - name: test-results-python-${{ matrix.arhitecture }} - path: ${{ env.INSTALL_TEST_DIR }}/TEST*.xml - if-no-files-found: 'error' + needs: [ Build, Smart_CI ] + uses: ./.github/workflows/job_python_unit_tests.yml + with: + runner: 'macos-13' + affected-components: ${{ needs.smart_ci.outputs.affected_components }} CPU_Functional_Tests: name: CPU functional tests - needs: Build - timeout-minutes: 25 - defaults: - run: - shell: bash - strategy: - max-parallel: 2 - fail-fast: false - matrix: - include: - # ticket: 122001 - # - arhitecture: 'x86_64' - # machine: 'macos-13' - - arhitecture: 'arm64' - machine: 'macos-13-xlarge' - runs-on: ${{ matrix.machine }} - env: - INSTALL_DIR: ${{ github.workspace }}/install - INSTALL_TEST_DIR: ${{ github.workspace }}/install/tests - - steps: - - name: Create Directories - run: mkdir -p ${{ env.INSTALL_DIR }} ${{ env.INSTALL_TEST_DIR }} - - - name: Download OpenVINO package - uses: actions/download-artifact@v3 - with: - name: openvino_package_${{ matrix.arhitecture }} - path: ${{ env.INSTALL_DIR }} - - - name: Download OpenVINO tests package - uses: actions/download-artifact@v3 - with: - name: openvino_tests_${{ matrix.arhitecture }} - path: ${{ env.INSTALL_TEST_DIR }} - - - name: Extract OpenVINO packages - run: | - pushd ${{ env.INSTALL_DIR }} - tar -xzf openvino_package.tar.gz -C ${{ env.INSTALL_DIR }} && rm openvino_package.tar.gz - popd - pushd ${{ env.INSTALL_TEST_DIR }} - tar -xzf openvino_tests.tar.gz -C ${{ env.INSTALL_DIR }} && rm openvino_tests.tar.gz - popd - - - name: CPU plugin func tests - run: | - source ${{ env.INSTALL_DIR }}/setupvars.sh - - # Skips under Ticket: 122769 - skip_filter=${{ matrix.arhitecture == 'arm64' && '--gtest_filter=-*smoke_nonzero/NonZeroLayerTest.Inference/IS*:*smoke_NormalizeL2_*:*Extension.XmlModelWithExtensionFromDSO*:*Extension.OnnxModelWithExtensionFromDSO*:*ONNXQuantizedModels/QuantizedModelsTests.MaxPool*:*ONNXQuantizedModels/QuantizedModelsTests.Convolution*:**' || '' }} - - ${{ env.INSTALL_TEST_DIR }}/ov_cpu_func_tests --gtest_print_time=1 --gtest_filter=*smoke* "$skip_filter" --gtest_output=xml:"${{ env.INSTALL_TEST_DIR }}/TEST-CPUFuncTests.xml" - - - name: Upload Test Results - uses: actions/upload-artifact@v3 - if: ${{ always() }} - with: - name: test-results-functional-cpu-${{ matrix.arhitecture }} - path: ${{ env.INSTALL_TEST_DIR }}/TEST*.xml - if-no-files-found: 'error' + # if: fromJSON(needs.smart_ci.outputs.affected_components).CPU.test + if: ${{ 'false' }} # Ticket: 122001 + needs: [ Build, Smart_CI ] + uses: ./.github/workflows/job_cpu_functional_tests.yml + with: + runner: 'macos-13' diff --git a/.github/workflows/mac_arm64.yml b/.github/workflows/mac_arm64.yml new file mode 100644 index 00000000000000..ea96b26c465a7e --- /dev/null +++ b/.github/workflows/mac_arm64.yml @@ -0,0 +1,241 @@ +name: macOS ARM64 (Python 3.11) +on: + workflow_dispatch: + schedule: + # at 00:00 on workdays + - cron: '0 0 * * 1,2,3,4,5' +# pull_request: +# paths-ignore: +# - '**/docs/**' +# - 'docs/**' +# - '**/**.md' +# - '**.md' +# - '**/layer_tests_summary/**' +# - '**/conformance/**' +# push: +# paths-ignore: +# - '**/docs/**' +# - 'docs/**' +# - '**/**.md' +# - '**.md' +# - '**/layer_tests_summary/**' +# - '**/conformance/**' +# branches: +# - master +# - 'releases/**' + +concurrency: + # github.ref is not unique in post-commit + group: ${{ github.event_name == 'push' && github.run_id || github.ref }}-mac-arm64 + cancel-in-progress: true + +env: + PYTHON_VERSION: '3.11' + +jobs: + Smart_CI: + runs-on: ubuntu-latest + outputs: + affected_components: "${{ steps.smart_ci.outputs.affected_components }}" + skip_workflow: "${{ steps.smart_ci.outputs.skip_workflow }}" + steps: + - name: checkout action + uses: actions/checkout@v4 + with: + sparse-checkout: .github/actions/smart-ci + + - name: Get affected components + id: smart_ci + uses: ./.github/actions/smart-ci + with: + repository: ${{ github.repository }} + pr: ${{ github.event.number }} + commit_sha: ${{ github.sha }} + component_pattern: "category: (.*)" + repo_token: ${{ secrets.GITHUB_TOKEN }} + skip_when_only_listed_labels_set: 'docs' + skip_when_only_listed_files_changed: '*.md,*.rst,*.png,*.jpg,*.svg' + + Build: + needs: Smart_CI + timeout-minutes: 150 + defaults: + run: + shell: bash + runs-on: 'macos-13-xlarge' + env: + CMAKE_BUILD_TYPE: 'Release' + CMAKE_GENERATOR: 'Ninja Multi-Config' + MACOSX_DEPLOYMENT_TARGET: '11.0' + CMAKE_CXX_COMPILER_LAUNCHER: ccache + CMAKE_C_COMPILER_LAUNCHER: ccache + OPENVINO_REPO: ${{ github.workspace }}/openvino + OPENVINO_CONTRIB_REPO: ${{ github.workspace }}/openvino_contrib + INSTALL_DIR: ${{ github.workspace }}/openvino_install + INSTALL_TEST_DIR: ${{ github.workspace }}/tests_install + BUILD_DIR: ${{ github.workspace }}/build + steps: + - name: Clone OpenVINO + uses: actions/checkout@v4 + with: + path: 'openvino' + submodules: 'true' + + - name: Clone OpenVINO Contrib + uses: actions/checkout@v4 + with: + repository: 'openvinotoolkit/openvino_contrib' + path: 'openvino_contrib' + + # + # Print system info + # + + - name: System info + uses: ./openvino/.github/actions/system_info + + # + # Dependencies + # + + - name: Install build dependencies + run: brew install coreutils ninja scons + + - name: Setup Python ${{ env.PYTHON_VERSION }} + uses: ./openvino/.github/actions/setup_python + with: + version: ${{ env.PYTHON_VERSION }} + should-setup-pip-paths: 'false' + self-hosted-runner: 'false' + + - name: Install python dependencies + run: | + # For Python API + python3 -m pip install -r ${{ env.OPENVINO_REPO }}/src/bindings/python/wheel/requirements-dev.txt + python3 -m pip install -r ${{ env.OPENVINO_REPO }}/src/bindings/python/requirements.txt + + # For running Python API tests + python3 -m pip install -r ${{ env.OPENVINO_REPO }}/src/bindings/python/src/compatibility/openvino/requirements-dev.txt + + # For running ONNX frontend unit tests + python3 -m pip install --force-reinstall -r ${{ env.OPENVINO_REPO }}/src/frontends/onnx/tests/requirements.txt + + # For running TensorFlow frontend unit tests + python3 -m pip install -r ${{ env.OPENVINO_REPO }}/src/frontends/tensorflow/tests/requirements.txt + + # For running Paddle frontend unit tests + python3 -m pip install -r ${{ env.OPENVINO_REPO }}/src/frontends/paddle/tests/requirements.txt + + # + # Build + # + + - name: Setup ccache + uses: hendrikmuhs/ccache-action@v1.2 + with: + max-size: "2000M" + # Should save cache only if run in the master branch of the base repo + # github.ref_name is 'ref/PR_#' in case of the PR, and 'branch_name' when executed on push + save: ${{ github.ref_name == 'master' && 'true' || 'false' }} + verbose: 2 + key: ${{ runner.os }}-${{ runner.arch }}-main + restore-keys: | + ${{ runner.os }}-${{ runner.arch }}-main + + - name: CMake configure + run: | + cmake \ + -G "${{ env.CMAKE_GENERATOR }}" \ + -DENABLE_CPPLINT=OFF \ + -DENABLE_NCC_STYLE=OFF \ + -DENABLE_TESTS=ON \ + -DCMAKE_COMPILE_WARNING_AS_ERROR=OFF \ + -DENABLE_STRICT_DEPENDENCIES=OFF \ + -DCMAKE_CXX_COMPILER_LAUNCHER=${{ env.CMAKE_CXX_COMPILER_LAUNCHER }} \ + -DCMAKE_C_COMPILER_LAUNCHER=${{ env.CMAKE_C_COMPILER_LAUNCHER }} \ + -S ${{ env.OPENVINO_REPO }} \ + -B ${{ env.BUILD_DIR }} + + - name: Cmake build - OpenVINO + run: cmake --build ${{ env.BUILD_DIR }} --parallel --config ${{ env.CMAKE_BUILD_TYPE }} + + - name: Show ccache stats + run: ccache --show-stats + + - name: Cmake install - OpenVINO + run: | + cmake -DCMAKE_INSTALL_PREFIX=${{ env.INSTALL_DIR }} -P ${{ env.BUILD_DIR }}/cmake_install.cmake + cmake -DCMAKE_INSTALL_PREFIX=${{ env.INSTALL_TEST_DIR }} -DCOMPONENT=tests -P ${{ env.BUILD_DIR }}/cmake_install.cmake + cmake -DCMAKE_INSTALL_PREFIX=${{ env.INSTALL_DIR }} -DCOMPONENT=python_wheels -P ${{ env.BUILD_DIR }}/cmake_install.cmake + + - name: Pack Artifacts + run: | + pushd ${{ env.INSTALL_DIR }} + tar -czvf ${{ env.BUILD_DIR }}/openvino_package.tar.gz * + popd + + pushd ${{ env.INSTALL_TEST_DIR }} + tar -czvf ${{ env.BUILD_DIR }}/openvino_tests.tar.gz * + popd + + - name: Cmake & Build - OpenVINO Contrib + run: | + cmake \ + -DBUILD_nvidia_plugin=OFF \ + -DBUILD_java_api=OFF \ + -DCUSTOM_OPERATIONS="calculate_grid;complex_mul;fft;grid_sample;sparse_conv;sparse_conv_transpose" \ + -DOPENVINO_EXTRA_MODULES=${{ env.OPENVINO_CONTRIB_REPO }}/modules \ + -S ${{ env.OPENVINO_REPO }} \ + -B ${{ env.BUILD_DIR }} + cmake --build ${{ env.BUILD_DIR }} --parallel --config ${{ env.CMAKE_BUILD_TYPE }} + + # + # Upload build artifacts + # + + - name: Upload openvino package + if: ${{ always() }} + uses: actions/upload-artifact@v3 + with: + name: openvino_package + path: ${{ env.BUILD_DIR }}/openvino_package.tar.gz + if-no-files-found: 'error' + + - name: Upload openvino tests package + if: ${{ always() }} + uses: actions/upload-artifact@v3 + with: + name: openvino_tests + path: ${{ env.BUILD_DIR }}/openvino_tests.tar.gz + if-no-files-found: 'error' + + Samples: + needs: Build + uses: ./.github/workflows/job_samples_tests.yml + with: + runner: 'macos-13-xlarge' + affected-components: ${{ needs.smart_ci.outputs.affected_components }} + + CXX_Unit_Tests: + name: C++ unit tests + needs: [ Build, Smart_CI ] + uses: ./.github/workflows/job_cxx_unit_tests.yml + with: + runner: 'macos-13-xlarge' + affected-components: ${{ needs.smart_ci.outputs.affected_components }} + + Python_Unit_Tests: + name: Python unit tests + needs: [ Build, Smart_CI ] + uses: ./.github/workflows/job_python_unit_tests.yml + with: + runner: 'macos-13-xlarge' + affected-components: ${{ needs.smart_ci.outputs.affected_components }} + + CPU_Functional_Tests: + name: CPU functional tests + if: fromJSON(needs.smart_ci.outputs.affected_components).CPU.test + needs: [ Build, Smart_CI ] + uses: ./.github/workflows/job_cpu_functional_tests.yml + with: + runner: 'macos-13-xlarge' diff --git a/.github/workflows/stale_prs_and_issues.yml b/.github/workflows/stale_prs_and_issues.yml index 0ea15bb6d4e6cb..deaf62781842e4 100644 --- a/.github/workflows/stale_prs_and_issues.yml +++ b/.github/workflows/stale_prs_and_issues.yml @@ -12,7 +12,7 @@ jobs: stale: runs-on: ubuntu-latest steps: - - uses: actions/stale@v8 + - uses: actions/stale@v9 with: stale-issue-message: 'This issue will be closed in a week because of 9 months of no activity.' stale-pr-message: 'This PR will be closed in a week because of 2 weeks of no activity.' diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 353a38666d7862..f4d59f63019782 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -1,22 +1,8 @@ name: Windows (VS 2019, Python 3.11) on: workflow_dispatch: -# pull_request: -# paths-ignore: -# - '**/docs/**' -# - 'docs/**' -# - '**/**.md' -# - '**.md' -# - '**/layer_tests_summary/**' -# - '**/conformance/**' + pull_request: push: - paths-ignore: - - '**/docs/**' - - 'docs/**' - - '**/**.md' - - '**.md' - - '**/layer_tests_summary/**' - - '**/conformance/**' branches: - master concurrency: @@ -28,7 +14,31 @@ env: PYTHON_VERSION: '3.11' jobs: + Smart_CI: + runs-on: ubuntu-latest + outputs: + affected_components: "${{ steps.smart_ci.outputs.affected_components }}" + skip_workflow: "${{ steps.smart_ci.outputs.skip_workflow }}" + steps: + - name: checkout action + uses: actions/checkout@v4 + with: + sparse-checkout: .github/actions/smart-ci + + - name: Get affected components + id: smart_ci + uses: ./.github/actions/smart-ci + with: + repository: ${{ github.repository }} + pr: ${{ github.event.number }} + commit_sha: ${{ github.sha }} + component_pattern: "category: (.*)" + repo_token: ${{ secrets.GITHUB_TOKEN }} + skip_when_only_listed_labels_set: 'docs' + skip_when_only_listed_files_changed: '*.md,*.rst,*.png,*.jpg,*.svg,*/layer_tests_summary/*,*/conformance/*' + Build: + needs: Smart_CI timeout-minutes: 180 defaults: run: @@ -46,6 +56,8 @@ jobs: BUILD_DIR: "${{ github.workspace }}\\openvino_build" # TODO: specify version of compiler here SCCACHE_AZURE_KEY_PREFIX: windows2022_x86_64_Release + if: "!needs.smart_ci.outputs.skip_workflow" + steps: - name: Clone OpenVINO uses: actions/checkout@v4 @@ -93,6 +105,7 @@ jobs: # For running TensorFlow Lite frontend unit tests python3 -m pip install -r ${{ env.OPENVINO_REPO }}/src/frontends/tensorflow_lite/tests/requirements.txt + # Disabled because of CVS-95904 # For running Paddle frontend unit tests # python3 -m pip install -r ${{ env.OPENVINO_REPO }}/src/frontends/paddle/tests/requirements.txt @@ -186,7 +199,8 @@ jobs: if-no-files-found: 'error' Samples: - needs: Build + needs: [Build, Smart_CI] + if: fromJSON(needs.smart_ci.outputs.affected_components).samples timeout-minutes: 20 defaults: run: @@ -267,7 +281,7 @@ jobs: Python_Unit_Tests: name: Python unit tests - needs: Build + needs: [Build, Smart_CI] timeout-minutes: 75 defaults: run: @@ -337,17 +351,20 @@ jobs: python3 -m pip install -r ${{ env.INSTALL_TEST_DIR }}/mo/requirements_dev.txt - name: Python API 1.0 Tests + #if: fromJSON(needs.smart_ci.outputs.affected_components).Python_API.test # Ticket: 127101 shell: cmd run: | python3 -m pytest -s ${{ env.INSTALL_TEST_DIR }}/pyngraph ${{ env.PYTHON_STATIC_ARGS }} --junitxml=${{ env.INSTALL_TEST_DIR }}/TEST-Pyngraph.xml --ignore=${{ env.INSTALL_TEST_DIR }}/pyngraph/tests_compatibility/test_onnx/test_zoo_models.py - name: Python API 2.0 Tests + #if: fromJSON(needs.smart_ci.outputs.affected_components).Python_API.test # Ticket: 127101 shell: cmd run: | set PYTHONPATH=${{ env.LAYER_TESTS_INSTALL_DIR }};%PYTHONPATH% python3 -m pytest -sv ${{ env.INSTALL_TEST_DIR }}/pyopenvino ${{ env.PYTHON_STATIC_ARGS }} --junitxml=${{ env.INSTALL_TEST_DIR }}/TEST-Pyngraph.xml --ignore=${{ env.INSTALL_TEST_DIR }}/pyopenvino/tests/test_utils/test_utils.py - name: Model Optimizer UT + if: fromJSON(needs.smart_ci.outputs.affected_components).MO.test shell: cmd run: | python3 -m pytest -s ${{ env.INSTALL_TEST_DIR }}/mo/unit_tests --ignore=${{ env.INSTALL_TEST_DIR }}/mo/unit_tests/mo/front/mxnet --junitxml=${{ env.INSTALL_TEST_DIR }}/TEST-ModelOptimizer.xml @@ -363,6 +380,7 @@ jobs: TEST_DEVICE: CPU - name: ONNX Layer Tests + if: fromJSON(needs.smart_ci.outputs.affected_components).ONNX_FE.test shell: cmd run: | python3 -m pip install -r ${{ env.LAYER_TESTS_INSTALL_DIR }}/requirements.txt @@ -375,6 +393,7 @@ jobs: TEST_PRECISION: FP16 - name: TensorFlow 1 Layer Tests - TF FE + if: fromJSON(needs.smart_ci.outputs.affected_components).TF_FE.test shell: cmd run: | python3 -m pip install -r ${{ env.LAYER_TESTS_INSTALL_DIR }}/requirements.txt @@ -387,6 +406,7 @@ jobs: TEST_PRECISION: FP16 - name: TensorFlow 2 Layer Tests - TF FE + if: fromJSON(needs.smart_ci.outputs.affected_components).TF_FE.test shell: cmd run: | python3 -m pip install -r ${{ env.LAYER_TESTS_INSTALL_DIR }}/requirements.txt @@ -399,12 +419,14 @@ jobs: TEST_DEVICE: CPU - name: TensorFlow 1 Layer Tests - Legacy FE + if: fromJSON(needs.smart_ci.outputs.affected_components).TF_FE.test shell: cmd run: | python3 -m pip install -r ${{ env.LAYER_TESTS_INSTALL_DIR }}/requirements.txt python3 -m pytest ${{ env.LAYER_TESTS_INSTALL_DIR }}/tensorflow_tests/test_tf_Roll.py --ir_version=10 --junitxml=${{ env.INSTALL_TEST_DIR }}/TEST-tf_Roll.xml - name: TensorFlow 2 Layer Tests - Legacy FE + if: fromJSON(needs.smart_ci.outputs.affected_components).TF_FE.test shell: cmd run: | python3 -m pip install -r ${{ env.LAYER_TESTS_INSTALL_DIR }}/requirements.txt @@ -414,6 +436,7 @@ jobs: TEST_PRECISION: FP16 - name: TensorFlow Lite Layer Tests - TFL FE + if: fromJSON(needs.smart_ci.outputs.affected_components).TFL_FE.test shell: cmd run: | python3 -m pip install -r ${{ env.LAYER_TESTS_INSTALL_DIR }}/requirements.txt @@ -423,6 +446,8 @@ jobs: TEST_PRECISION: FP16 - name: Python ONNX operators tests + if: fromJSON(needs.smart_ci.outputs.affected_components).Python_API.test || + fromJSON(needs.smart_ci.outputs.affected_components).ONNX_FE.test shell: cmd run: | :: Skip test_onnx/test_zoo_models and test_onnx/test_backend due to long execution time - ONNX Model Zoo tests are run separately @@ -431,26 +456,28 @@ jobs: --ignore=${{ env.INSTALL_TEST_DIR }}/onnx/test_python/test_zoo_models.py - name: MO Python API Tests + if: fromJSON(needs.smart_ci.outputs.affected_components).MO.test shell: cmd run: | python3 -m pip install -r ${{ env.LAYER_TESTS_INSTALL_DIR }}/requirements.txt :: Used for 'test_utils' installed in '\python\openvino\test_utils' set PYTHONPATH=${{ env.INSTALL_TEST_DIR }}\python\openvino\test_utils;${{ env.INSTALL_TEST_DIR }}\python;%PYTHONPATH% - + python3 -m pytest ${{ env.LAYER_TESTS_INSTALL_DIR }}/mo_python_api_tests --junitxml=${{ env.INSTALL_TEST_DIR }}/TEST-test_mo_convert.xml env: TEST_DEVICE: CPU TEST_PRECISION: FP16 - name: OVC Python API Tests + if: fromJSON(needs.smart_ci.outputs.affected_components).MO.test shell: cmd run: | python3 -m pip install -r ${{ env.LAYER_TESTS_INSTALL_DIR }}/requirements.txt :: Used for 'test_utils' installed in '\python\openvino\test_utils' set PYTHONPATH=${{ env.INSTALL_TEST_DIR }}\python\openvino\test_utils;${{ env.INSTALL_TEST_DIR }}\python;%PYTHONPATH% - + :: Skip test ticket: 126319 python3 -m pytest ${{ env.LAYER_TESTS_INSTALL_DIR }}/ovc_python_api_tests -k "not test_ovc_tool_non_existng_output_dir" --junitxml=${{ env.INSTALL_TEST_DIR }}/TEST-test_ovc_convert.xml env: @@ -458,6 +485,8 @@ jobs: TEST_PRECISION: FP16 - name: Python Frontend tests + if: fromJSON(needs.smart_ci.outputs.affected_components).PyTorch_FE.test || + fromJSON(needs.smart_ci.outputs.affected_components).PDPD_FE.test shell: cmd run: | python3 -m pip install -r ${{ env.LAYER_TESTS_INSTALL_DIR }}/requirements.txt @@ -465,6 +494,7 @@ jobs: call "${{ env.INSTALL_DIR }}\\setupvars.bat" && python3 -m pytest ${{ env.LAYER_TESTS_INSTALL_DIR }}/py_frontend_tests --junitxml=${{ env.INSTALL_TEST_DIR }}/TEST-test_py_fontend.xml - name: OVC unit tests + if: fromJSON(needs.smart_ci.outputs.affected_components).MO.test shell: cmd run: python3 -m pytest -s ${{ env.INSTALL_TEST_DIR }}/ovc/unit_tests --junitxml=${{ env.INSTALL_TEST_DIR }}/TEST-OpenVinoConversion.xml @@ -478,7 +508,7 @@ jobs: CXX_Unit_Tests: name: C++ unit tests - needs: Build + needs: [Build, Smart_CI] timeout-minutes: 25 defaults: run: @@ -511,73 +541,87 @@ jobs: popd - name: OpenVINO Core unit tests + if: fromJSON(needs.smart_ci.outputs.affected_components).Core.test shell: cmd run: | call "${{ env.INSTALL_DIR }}\\setupvars.bat" && ${{ env.INSTALL_TEST_DIR }}/ov_core_unit_tests --gtest_print_time=1 --gtest_filter=-*IE_GPU* --gtest_output=xml:${{ env.INSTALL_TEST_DIR }}/TEST-NGraphUT.xml - name: OpenVINO Inference functional tests + if: fromJSON(needs.smart_ci.outputs.affected_components).inference.test shell: cmd run: | call "${{ env.INSTALL_DIR }}\\setupvars.bat" && ${{ env.INSTALL_TEST_DIR }}/ov_inference_functional_tests --gtest_print_time=1 --gtest_output=xml:${{ env.INSTALL_TEST_DIR }}/TEST-InferenceFunc.xml - name: OpenVINO Inference unit tests + if: fromJSON(needs.smart_ci.outputs.affected_components).inference.test shell: cmd run: | call "${{ env.INSTALL_DIR }}\\setupvars.bat" && ${{ env.INSTALL_TEST_DIR }}/ov_inference_unit_tests --gtest_print_time=1 --gtest_output=xml:${{ env.INSTALL_TEST_DIR }}/TEST-InferenceUnit.xml - name: Low Precision Transformations Tests + if: fromJSON(needs.smart_ci.outputs.affected_components).LP_transformations.test shell: cmd run: | call "${{ env.INSTALL_DIR }}\\setupvars.bat" && ${{ env.INSTALL_TEST_DIR }}/ov_lp_transformations_tests --gtest_print_time=1 --gtest_output=xml:${{ env.INSTALL_TEST_DIR }}/TEST-LpTransformations.xml - name: OpenVINO Conditional compilation tests + if: fromJSON(needs.smart_ci.outputs.affected_components).Core.test shell: cmd run: | call "${{ env.INSTALL_DIR }}\\setupvars.bat" && ${{ env.INSTALL_TEST_DIR }}/ov_conditional_compilation_tests --gtest_print_time=1 --gtest_output=xml:${{ env.INSTALL_TEST_DIR }}/TEST-ConditionalCompilation.xml - name: IR frontend tests + if: fromJSON(needs.smart_ci.outputs.affected_components).IR_FE.test shell: cmd run: | call "${{ env.INSTALL_DIR }}\\setupvars.bat" && ${{ env.INSTALL_TEST_DIR }}/ov_ir_frontend_tests --gtest_print_time=1 --gtest_output=xml:${{ env.INSTALL_TEST_DIR }}/TEST-IRFrontend.xml - - name: PaddlePaddle frontend tests # Disabled in Azure: https://github.com/openvinotoolkit/openvino/blob/master/.ci/azure/linux.yml#L403 + - name: PaddlePaddle frontend tests # Disabled because of CVS-95904 if: ${{ 'false' }} shell: cmd run: | call "${{ env.INSTALL_DIR }}\\setupvars.bat" && ${{ env.INSTALL_TEST_DIR }}/paddle_tests --gtest_print_time=1 --gtest_filter=*smoke* --gtest_output=xml:${{ env.INSTALL_TEST_DIR }}/TEST-PaddleTests.xml - name: ONNX frontend tests + if: fromJSON(needs.smart_ci.outputs.affected_components).ONNX_FE.test shell: cmd run: | call "${{ env.INSTALL_DIR }}\\setupvars.bat" && ${{ env.INSTALL_TEST_DIR }}/ov_onnx_frontend_tests --gtest_print_time=1 --gtest_filter=-*IE_GPU* --gtest_output=xml:${{ env.INSTALL_TEST_DIR }}/TEST-ONNXFrontend.xml - name: TensorFlow Common frontend tests + if: fromJSON(needs.smart_ci.outputs.affected_components).TF_FE.test || + fromJSON(needs.smart_ci.outputs.affected_components).TFL_FE.test shell: cmd run: | call "${{ env.INSTALL_DIR }}\\setupvars.bat" && ${{ env.INSTALL_TEST_DIR }}/ov_tensorflow_common_tests --gtest_print_time=1 --gtest_output=xml:${{ env.INSTALL_TEST_DIR }}/TEST-TensorFlowCommonFrontend.xml - name: TensorFlow frontend tests + if: fromJSON(needs.smart_ci.outputs.affected_components).TF_FE.test shell: cmd run: | call "${{ env.INSTALL_DIR }}\\setupvars.bat" && ${{ env.INSTALL_TEST_DIR }}/ov_tensorflow_frontend_tests --gtest_print_time=1 --gtest_output=xml:${{ env.INSTALL_TEST_DIR }}/TEST-TensorFlowFrontend.xml - name: TensorFlow Lite frontend tests + if: fromJSON(needs.smart_ci.outputs.affected_components).TFL_FE.test shell: cmd run: | :: Skip ticket: 126320 call "${{ env.INSTALL_DIR }}\\setupvars.bat" && ${{ env.INSTALL_TEST_DIR }}/ov_tensorflow_lite_frontend_tests --gtest_print_time=1 --gtest_filter=-*test_decode_convert_equal_convert*:*test_convert_partially_equal_convert* --gtest_output=xml:${{ env.INSTALL_TEST_DIR }}/TEST-TensorFlowLiteFrontend.xml - name: Transformations func tests + if: fromJSON(needs.smart_ci.outputs.affected_components).transformations.test shell: cmd run: | call "${{ env.INSTALL_DIR }}\\setupvars.bat" && ${{ env.INSTALL_TEST_DIR }}/ov_transformations_tests --gtest_print_time=1 --gtest_output=xml:${{ env.INSTALL_TEST_DIR }}/TEST-Transformations.xml - name: Legacy Transformations func tests + if: fromJSON(needs.smart_ci.outputs.affected_components).GNA.test shell: cmd run: | call "${{ env.INSTALL_DIR }}\\setupvars.bat" && ${{ env.INSTALL_TEST_DIR }}/ov_legacy_transformations_tests --gtest_print_time=1 --gtest_output=xml:${{ env.INSTALL_TEST_DIR }}/TEST-LegacyTransformations.xml - name: Inference Engine 1.0 unit tests + if: fromJSON(needs.smart_ci.outputs.affected_components).GNA.test shell: cmd run: | call "${{ env.INSTALL_DIR }}\\setupvars.bat" && ${{ env.INSTALL_TEST_DIR }}/InferenceEngineUnitTests --gtest_print_time=1 --gtest_output=xml:${{ env.INSTALL_TEST_DIR }}/TEST-InferenceEngineUnitTests.xml @@ -588,11 +632,13 @@ jobs: call "${{ env.INSTALL_DIR }}\\setupvars.bat" && ${{ env.INSTALL_TEST_DIR }}/ov_util_tests --gtest_print_time=1 --gtest_output=xml:${{ env.INSTALL_TEST_DIR }}/TEST-commonUtilsTests.xml - name: Snippets func tests + if: fromJSON(needs.smart_ci.outputs.affected_components).CPU.test shell: cmd run: | call "${{ env.INSTALL_DIR }}\\setupvars.bat" && ${{ env.INSTALL_TEST_DIR }}/ov_snippets_func_tests --gtest_print_time=1 --gtest_output=xml:${{ env.INSTALL_TEST_DIR }}/TEST-SnippetsFuncTests.xml - name: CPU plugin unit tests + if: fromJSON(needs.smart_ci.outputs.affected_components).CPU.test shell: cmd run: | call "${{ env.INSTALL_DIR }}\\setupvars.bat" && ${{ env.INSTALL_TEST_DIR }}/ov_cpu_unit_tests --gtest_print_time=1 --gtest_output=xml:${{ env.INSTALL_TEST_DIR }}/TEST-CPUUnitTests.xml @@ -608,26 +654,31 @@ jobs: call "${{ env.INSTALL_DIR }}\\setupvars.bat" && ${{ env.INSTALL_TEST_DIR }}/ov_op_conformance_tests --gtest_print_time=1 --gtest_filter="*OpImpl*" --gtest_output=xml:${{ env.INSTALL_TEST_DIR }}/TEST-TemplateOpImplTests.xml - name: GNA plugin unit tests + if: fromJSON(needs.smart_ci.outputs.affected_components).GNA.test shell: cmd run: | call "${{ env.INSTALL_DIR }}\\setupvars.bat" && ${{ env.INSTALL_TEST_DIR }}/ov_gna_unit_tests --gtest_print_time=1 --gtest_output=xml:${{ env.INSTALL_TEST_DIR }}/TEST-GNAUnitTests.xml - name: AUTO unit tests + if: fromJSON(needs.smart_ci.outputs.affected_components).AUTO.test shell: cmd run: | call "${{ env.INSTALL_DIR }}\\setupvars.bat" && ${{ env.INSTALL_TEST_DIR }}/ov_auto_unit_tests --gtest_print_time=1 --gtest_output=xml:${{ env.INSTALL_TEST_DIR }}/TEST-ov_auto_unit_tests.xml - name: AUTO func Tests + if: fromJSON(needs.smart_ci.outputs.affected_components).AUTO.test shell: cmd run: | call "${{ env.INSTALL_DIR }}\\setupvars.bat" && ${{ env.INSTALL_TEST_DIR }}/ov_auto_func_tests --gtest_print_time=1 --gtest_output=xml:${{ env.INSTALL_TEST_DIR }}/TEST-ov_auto_func_tests.xml - name: Template plugin func tests + if: fromJSON(needs.smart_ci.outputs.affected_components).TEMPLATE.test shell: cmd run: | call "${{ env.INSTALL_DIR }}\\setupvars.bat" && ${{ env.INSTALL_TEST_DIR }}/ov_template_func_tests --gtest_print_time=1 --gtest_filter=*smoke* --gtest_output=xml:${{ env.INSTALL_TEST_DIR }}/TEST-TemplateFuncTests.xml - name: Inference Engine C API tests + if: fromJSON(needs.smart_ci.outputs.affected_components).C_API.test shell: cmd run: | call "${{ env.INSTALL_DIR }}\\setupvars.bat" && ${{ env.INSTALL_TEST_DIR }}/InferenceEngineCAPITests --gtest_print_time=1 --gtest_output=xml:${{ env.INSTALL_TEST_DIR }}/TEST-InferenceEngineCAPITests.xml @@ -639,26 +690,31 @@ jobs: call "${{ env.INSTALL_DIR }}\\setupvars.bat" && ${{ env.INSTALL_TEST_DIR }}/ov_capi_test --gtest_print_time=1 --gtest_output=xml:${{ env.INSTALL_TEST_DIR }}/TEST-OpenVINOCAPITests.xml - name: AutoBatch unit tests + if: fromJSON(needs.smart_ci.outputs.affected_components).AUTO_BATCH.test shell: cmd run: | call "${{ env.INSTALL_DIR }}\\setupvars.bat" && ${{ env.INSTALL_TEST_DIR }}/ov_auto_batch_unit_tests --gtest_output=xml:${{ env.INSTALL_TEST_DIR }}/TEST-ov_auto_batch_unit_tests.xml - name: AutoBatch func tests + if: fromJSON(needs.smart_ci.outputs.affected_components).AUTO_BATCH.test shell: cmd run: | call "${{ env.INSTALL_DIR }}\\setupvars.bat" && ${{ env.INSTALL_TEST_DIR }}/ov_auto_batch_func_tests --gtest_output=xml:${{ env.INSTALL_TEST_DIR }}/TEST-ov_auto_batch_func_tests.xml - name: Proxy Plugin func tests + if: fromJSON(needs.smart_ci.outputs.affected_components).PROXY.test shell: cmd run: | call "${{ env.INSTALL_DIR }}\\setupvars.bat" && ${{ env.INSTALL_TEST_DIR }}/ov_proxy_plugin_tests --gtest_print_time=1 --gtest_output=xml:${{ env.INSTALL_TEST_DIR }}/TEST-OVProxyTests.xml - name: Hetero Unit Tests + if: fromJSON(needs.smart_ci.outputs.affected_components).HETERO.test shell: cmd run: | call "${{ env.INSTALL_DIR }}\\setupvars.bat" && ${{ env.INSTALL_TEST_DIR }}/ov_hetero_unit_tests --gtest_print_time=1 --gtest_output=xml:${{ env.INSTALL_TEST_DIR }}/TEST-OVHeteroUnitTests.xml - name: Hetero Func Tests + if: fromJSON(needs.smart_ci.outputs.affected_components).HETERO.test shell: cmd run: | call "${{ env.INSTALL_DIR }}\\setupvars.bat" && ${{ env.INSTALL_TEST_DIR }}/ov_hetero_func_tests --gtest_print_time=1 --gtest_output=xml:${{ env.INSTALL_TEST_DIR }}/TEST-OVHeteroFuncTests.xml @@ -673,7 +729,7 @@ jobs: CPU_Functional_Tests: name: CPU functional tests - needs: Build + needs: [Build, Smart_CI] timeout-minutes: 70 defaults: run: @@ -685,7 +741,7 @@ 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: fromJSON(needs.smart_ci.outputs.affected_components).CPU.test steps: - name: Download OpenVINO package uses: actions/download-artifact@v3 @@ -763,3 +819,17 @@ jobs: ${{ env.INSTALL_TEST_DIR }}/logs/hash_table.csv ${{ env.PARALLEL_TEST_CACHE }} if-no-files-found: 'error' + + Overall_Status: + name: ci/gha_overall_status_windows + needs: [Smart_CI, Build, Samples, CXX_Unit_Tests, Python_Unit_Tests, CPU_Functional_Tests] + if: ${{ always() }} + runs-on: ubuntu-latest + steps: + - name: Check status of all jobs + if: >- + ${{ + contains(needs.*.result, 'failure') || + contains(needs.*.result, 'cancelled') + }} + run: exit 1 diff --git a/.github/workflows/windows_conditional_compilation.yml b/.github/workflows/windows_conditional_compilation.yml index e2155ab06997f3..fcb74ab0438532 100644 --- a/.github/workflows/windows_conditional_compilation.yml +++ b/.github/workflows/windows_conditional_compilation.yml @@ -4,24 +4,24 @@ on: schedule: # run daily at 00:00 - cron: '0 0 * * *' -# pull_request: -# paths-ignore: -# - '**/docs/**' -# - 'docs/**' -# - '**/**.md' -# - '**.md' -# - '**/layer_tests_summary/**' -# - '**/conformance/**' -# push: -# paths-ignore: -# - '**/docs/**' -# - 'docs/**' -# - '**/**.md' -# - '**.md' -# - '**/layer_tests_summary/**' -# - '**/conformance/**' -# branches: -# - master + # pull_request: + # paths-ignore: + # - '**/docs/**' + # - 'docs/**' + # - '**/**.md' + # - '**.md' + # - '**/layer_tests_summary/**' + # - '**/conformance/**' + push: + paths-ignore: + - '**/docs/**' + - 'docs/**' + - '**/**.md' + - '**.md' + - '**/layer_tests_summary/**' + - '**/conformance/**' + branches: + - master concurrency: # github.ref is not unique in post-commit @@ -37,7 +37,7 @@ jobs: defaults: run: shell: pwsh - runs-on: windows-latest-8-cores + runs-on: aks-win-16-cores-32gb env: CMAKE_BUILD_TYPE: 'Release' CMAKE_GENERATOR: 'Ninja Multi-Config' @@ -49,6 +49,8 @@ jobs: BUILD_DIR: "${{ github.workspace }}\\openvino_build" MODELS_PATH: "${{ github.workspace }}\\testdata" SELECTIVE_BUILD_STAT_DIR: "${{ github.workspace }}\\selective_build_stat" + # TODO: specify version of compiler here + SCCACHE_AZURE_KEY_PREFIX: windows2022_x86_64_itt_Release steps: - name: Clone OpenVINO uses: actions/checkout@v4 @@ -82,6 +84,11 @@ jobs: should-setup-pip-paths: 'false' self-hosted-runner: 'false' + - name: Install sccache + uses: mozilla-actions/sccache-action@v0.0.3 + with: + version: "v0.5.4" + - name: Install build dependencies run: choco install --no-progress ninja @@ -89,15 +96,16 @@ jobs: run: | # For running ONNX frontend unit tests python3 -m pip install --force-reinstall -r ${{ env.OPENVINO_REPO }}/src/frontends/onnx/tests/requirements.txt - + # For running TensorFlow frontend unit tests python3 -m pip install -r ${{ env.OPENVINO_REPO }}/src/frontends/tensorflow/tests/requirements.txt - + # For running TensorFlow Lite frontend unit tests python3 -m pip install -r ${{ env.OPENVINO_REPO }}/src/frontends/tensorflow_lite/tests/requirements.txt - + + # Disabled because of CVS-95904 # For running Paddle frontend unit tests - python3 -m pip install -r ${{ env.OPENVINO_REPO }}/src/frontends/paddle/tests/requirements.txt + # python3 -m pip install -r ${{ env.OPENVINO_REPO }}/src/frontends/paddle/tests/requirements.txt # # Build @@ -106,18 +114,6 @@ jobs: - name: Configure Developer Command Prompt for Microsoft Visual C++ uses: ilammy/msvc-dev-cmd@v1 - - name: Setup sccache - uses: hendrikmuhs/ccache-action@v1.2 - with: - variant: sccache - max-size: "2000M" - # Should save cache only if run in the master branch of the base repo - # github.ref_name is 'ref/PR_#' in case of the PR, and 'branch_name' when executed on push - save: ${{ github.ref_name == 'master' && 'true' || 'false' }} - key: ${{ github.job }}-${{ runner.os }}-itt - restore-keys: | - ${{ github.job }}-${{ runner.os }}-itt - - name: CMake configure - CC COLLECT run: | cmake -G "${{ env.CMAKE_GENERATOR }}" ` @@ -133,10 +129,29 @@ jobs: -S ${{ env.OPENVINO_REPO }} ` -B ${{ env.BUILD_DIR }} + - 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 - CC COLLECT run: | - cmake --build ${{ env.BUILD_DIR }} --parallel --config ${{ env.CMAKE_BUILD_TYPE }} - cmake --build ${{ env.BUILD_DIR }} --parallel --config ${{ env.CMAKE_BUILD_TYPE }} --target sea_itt_lib + cmake --build ${{ env.BUILD_DIR }} --parallel 8 --config ${{ env.CMAKE_BUILD_TYPE }} && ` + cmake --build ${{ env.BUILD_DIR }} --parallel 8 --config ${{ env.CMAKE_BUILD_TYPE }} --target sea_itt_lib + + - name: Show sccache stats + run: '& "$Env:SCCACHE_PATH" --show-stats' - name: Cmake install - OpenVINO run: cmake -DCMAKE_INSTALL_PREFIX=${{ env.INSTALL_DIR }} -P ${{ env.BUILD_DIR }}/cmake_install.cmake @@ -160,7 +175,7 @@ jobs: shell: cmd run: | set path=%path%;${{ env.OPENVINO_REPO }}\temp\tbb\bin - + python3 ${{ env.OPENVINO_REPO }}\thirdparty\itt_collector\runtool\sea_runtool.py ^ --bindir ${{ env.OPENVINO_REPO }}\bin\intel64\${{ env.CMAKE_BUILD_TYPE }} ^ -o ${{ env.SELECTIVE_BUILD_STAT_DIR }}\itt_stat ! ${{ env.OPENVINO_REPO }}\bin\intel64\${{ env.CMAKE_BUILD_TYPE }}\benchmark_app.exe ^ @@ -216,7 +231,7 @@ jobs: defaults: run: shell: pwsh - runs-on: windows-latest-8-cores + runs-on: aks-win-16-cores-32gb env: CMAKE_BUILD_TYPE: 'Release' CMAKE_CXX_COMPILER_LAUNCHER: sccache @@ -225,6 +240,7 @@ jobs: BUILD_DIR: "${{ github.workspace }}\\openvino_build" MODELS_PATH: "${{ github.workspace }}\\testdata" SELECTIVE_BUILD_STAT_DIR: "${{ github.workspace }}\\selective_build_stat" + SCCACHE_AZURE_KEY_PREFIX: windows2022_x86_64_cc_Release steps: - name: Clone OpenVINO uses: actions/checkout@v4 @@ -249,6 +265,18 @@ jobs: - name: Extract selective build statistics package run: Expand-Archive ${{ env.SELECTIVE_BUILD_STAT_DIR }}/openvino_selective_build_stat.zip -DestinationPath "${{ env.SELECTIVE_BUILD_STAT_DIR }}" + - name: Setup Python ${{ env.PYTHON_VERSION }} + uses: ./openvino/.github/actions/setup_python + with: + version: ${{ env.PYTHON_VERSION }} + should-setup-pip-paths: 'false' + self-hosted-runner: 'false' + + - name: Install sccache + uses: mozilla-actions/sccache-action@v0.0.3 + with: + version: "v0.5.4" + - name: CMake configure - CC ON run: | cmake ` @@ -267,9 +295,15 @@ jobs: -S ${{ env.OPENVINO_REPO }} ` -B ${{ env.BUILD_DIR }} + - name: Clean sccache stats + run: '& "$Env:SCCACHE_PATH" --zero-stats' + - name: Cmake build - CC ON run: cmake --build ${{ env.BUILD_DIR }} --parallel --config ${{ env.CMAKE_BUILD_TYPE }} --target benchmark_app + - name: Show sccache stats + run: '& "$Env:SCCACHE_PATH" --show-stats' + - name: List bin files shell: cmd run: dir ${{ env.OPENVINO_REPO }}\bin\ /s @@ -283,10 +317,11 @@ jobs: CPU_Functional_Tests: name: CPU functional tests needs: Build + timeout-minutes: 70 defaults: run: shell: pwsh - runs-on: windows-latest-8-cores + runs-on: aks-win-8-cores-16gb env: OPENVINO_REPO: "${{ github.workspace }}\\openvino" INSTALL_TEST_DIR: "${{ github.workspace }}\\tests_install" diff --git a/cmake/developer_package/OpenVINODeveloperScriptsConfig.cmake b/cmake/developer_package/OpenVINODeveloperScriptsConfig.cmake index bc512b9b229b02..fc9abc64b9e4cc 100644 --- a/cmake/developer_package/OpenVINODeveloperScriptsConfig.cmake +++ b/cmake/developer_package/OpenVINODeveloperScriptsConfig.cmake @@ -87,11 +87,6 @@ function(ov_set_temp_directory temp_variable source_tree_dir) endif() endfunction() -macro(set_temp_directory) - message(WARNING "'set_temp_directory' is deprecated. Please, use 'ov_set_temp_directory'") - ov_set_temp_directory(${ARGV}) -endmacro() - # # For cross-compilation # @@ -294,11 +289,6 @@ function(ov_mark_target_as_cc TARGET_NAME) add_dependencies(${TARGET_NAME} conditional_compilation_gen) endfunction() -function(ie_mark_target_as_cc TARGET_NAME) - message(WARNING "This function is deprecated. Please use ov_mark_target_as_cc(TARGET_NAME) instead.") - ov_mark_target_as_cc(${TARGET_NAME}) -endfunction() - include(python_requirements) # Code style utils diff --git a/cmake/developer_package/add_target_helpers.cmake b/cmake/developer_package/add_target_helpers.cmake index 92f4afbc23bbbe..238a9cde5b37eb 100644 --- a/cmake/developer_package/add_target_helpers.cmake +++ b/cmake/developer_package/add_target_helpers.cmake @@ -181,15 +181,3 @@ function(ov_add_test_target) COMPONENT ${ARG_COMPONENT} EXCLUDE_FROM_ALL) endfunction() - -# deprecated - -function(addIeTarget) - message(WARNING "'addIeTarget' is deprecated, please, use 'ov_add_target' instead") - ov_add_target(${ARGV}) -endfunction() - -function(addIeTargetTest) - message(WARNING "'addIeTargetTest' is deprecated, please, use 'ov_add_test_target' instead") - ov_add_test_target(${ARGV}) -endfunction() diff --git a/cmake/developer_package/api_validator/api_validator.cmake b/cmake/developer_package/api_validator/api_validator.cmake index 6749366a64db05..4eeb9e1e5e0b7e 100644 --- a/cmake/developer_package/api_validator/api_validator.cmake +++ b/cmake/developer_package/api_validator/api_validator.cmake @@ -196,10 +196,3 @@ endfunction() function(ov_add_api_validator_post_build_step) _ov_add_api_validator_post_build_step(${ARGN}) endfunction() - -# deprecated - -function(ie_add_api_validator_post_build_step) - message(WARNING "'ie_add_api_validator_post_build_step' is deprecated, use 'ov_add_api_validator_post_build_step' instead") - _ov_add_api_validator_post_build_step(${ARGN}) -endfunction() diff --git a/cmake/developer_package/clang_format/clang_format.cmake b/cmake/developer_package/clang_format/clang_format.cmake index 57319e48006938..b031c1e640bce9 100644 --- a/cmake/developer_package/clang_format/clang_format.cmake +++ b/cmake/developer_package/clang_format/clang_format.cmake @@ -130,8 +130,3 @@ function(ov_add_clang_format_target TARGET_NAME) add_dependencies(clang_format_check_all ${TARGET_NAME}) add_dependencies(clang_format_fix_all ${TARGET_NAME}_fix) endfunction() - -function(add_clang_format_target) - message(WARNING "add_clang_format_target is deprecated, use ov_add_clang_format_target instead") - ov_add_clang_format_target(${ARGV}) -endfunction() diff --git a/cmake/developer_package/compile_flags/os_flags.cmake b/cmake/developer_package/compile_flags/os_flags.cmake index c0c878e0183eb0..2e2e52b015c58d 100644 --- a/cmake/developer_package/compile_flags/os_flags.cmake +++ b/cmake/developer_package/compile_flags/os_flags.cmake @@ -32,11 +32,6 @@ macro(ov_disable_deprecated_warnings) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${ov_c_cxx_deprecated}") endmacro() -macro(disable_deprecated_warnings) - message(WARNING "'disable_deprecated_warnings' is deprecated, use 'ov_disable_deprecated_warnings' instead") - ov_disable_deprecated_warnings() -endmacro() - # # ov_deprecated_no_errors() # @@ -125,7 +120,7 @@ macro(ov_avx2_optimization_flags flags) set(${flags} -xCORE-AVX2) endif() elseif(OV_COMPILER_IS_CLANG OR CMAKE_COMPILER_IS_GNUCXX) - set(${flags} -mavx2 -mfma) + set(${flags} -mavx2 -mfma -mf16c) else() message(WARNING "Unsupported CXX compiler ${CMAKE_CXX_COMPILER_ID}") endif() @@ -147,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) + set(${flags} -mavx512f -mfma -mf16c) else() message(WARNING "Unsupported CXX compiler ${CMAKE_CXX_COMPILER_ID}") endif() @@ -213,16 +208,6 @@ function(ov_disable_all_warnings) endforeach() endfunction() -# -# ie_enable_lto() -# -# Enables Link Time Optimization compilation -# -macro(ie_enable_lto) - message(WARNING "'ie_enable_lto' is deprecated, set 'INTERPROCEDURAL_OPTIMIZATION_RELEASE' target property instead") - set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE ON) -endmacro() - # # ov_add_compiler_flags(]) # @@ -235,11 +220,6 @@ macro(ov_add_compiler_flags) endforeach() endmacro() -macro(ie_add_compiler_flags) - message(WARNING "'ie_add_compiler_flags' is deprecated, use 'ov_add_compiler_flags' instead") - ov_add_compiler_flags(${ARGN}) -endmacro() - # # ov_force_include(
) # diff --git a/cmake/developer_package/faster_build.cmake b/cmake/developer_package/faster_build.cmake index f70274f465070c..b9ad18dfa98570 100644 --- a/cmake/developer_package/faster_build.cmake +++ b/cmake/developer_package/faster_build.cmake @@ -19,10 +19,3 @@ function(ov_build_target_faster TARGET_NAME) target_precompile_headers(${TARGET_NAME} ${FASTER_BUILD_PCH}) endif() endfunction() - -# deprecated - -function(ie_faster_build) - message(WARNING "ie_faster_build is deprecated, use ov_build_target_faster instead") - ov_build_target_faster(${ARGV}) -endfunction() diff --git a/cmake/developer_package/frontends/frontends.cmake b/cmake/developer_package/frontends/frontends.cmake index 1a037c5ab72309..0b14cabe54a05e 100644 --- a/cmake/developer_package/frontends/frontends.cmake +++ b/cmake/developer_package/frontends/frontends.cmake @@ -57,10 +57,10 @@ function(ov_generate_frontends_hpp) # for some reason dependency on source files does not work # so, we have to use explicit target and make it dependency for frontend_common add_custom_target(_ov_frontends_hpp DEPENDS ${ov_frontends_hpp}) - add_dependencies(frontend_common_obj _ov_frontends_hpp) + add_dependencies(openvino_frontend_common_obj _ov_frontends_hpp) # add dependency for object files - get_target_property(sources frontend_common_obj SOURCES) + get_target_property(sources openvino_frontend_common_obj SOURCES) foreach(source IN LISTS sources) if("${source}" MATCHES "\\$\\") # object library @@ -220,6 +220,7 @@ macro(ov_add_frontend) PUBLIC $ PRIVATE + $ ${frontend_root_dir}/src ${CMAKE_CURRENT_BINARY_DIR}) @@ -342,6 +343,7 @@ macro(ov_add_frontend) install(DIRECTORY ${${TARGET_NAME}_INCLUDE_DIR}/openvino DESTINATION ${FRONTEND_INSTALL_INCLUDE} COMPONENT ${dev_component} + ${OV_CPACK_COMP_CORE_DEV_EXCLUDE_ALL} FILES_MATCHING PATTERN "*.hpp") # public target name diff --git a/cmake/developer_package/ncc_naming_style/openvino.style b/cmake/developer_package/ncc_naming_style/openvino.style index 2eb616aae8cf85..12b255ac074c9f 100644 --- a/cmake/developer_package/ncc_naming_style/openvino.style +++ b/cmake/developer_package/ncc_naming_style/openvino.style @@ -18,7 +18,7 @@ VariableReference: '^\w+$' EnumName: '^[A-Z][\w]+$' # excepts element_type -EnumConstantName: '^([A-Z\d_]+|undefined|dynamic|boolean|bf16|f16|f32|f64|i4|i8|i16|i32|i64|u1|u4|u8|u16|u32|u64|nf4|asymmetric|align_corners|round_prefer_floor|round_prefer_ceil|floor|ceil|simple|nearest|linear|linear_onnx|cubic|area|scales|sizes|half_pixel|tf_half_pixel_for_nn|pytorch_half_pixel|asymetric)$' +EnumConstantName: '^([A-Z\d_]+|undefined|dynamic|boolean|bf16|f16|f32|f64|i4|i8|i16|i32|i64|u1|u4|u8|u16|u32|u64|nf4|string|asymmetric|align_corners|round_prefer_floor|round_prefer_ceil|floor|ceil|simple|nearest|linear|linear_onnx|cubic|area|scales|sizes|half_pixel|tf_half_pixel_for_nn|pytorch_half_pixel|asymetric)$' # TODO: align UsingDeclaration: '^.*$' TypedefName: '^.*$' diff --git a/cmake/developer_package/options.cmake b/cmake/developer_package/options.cmake index 4506d85a027f92..7a9baa0b41de24 100644 --- a/cmake/developer_package/options.cmake +++ b/cmake/developer_package/options.cmake @@ -55,20 +55,3 @@ function (ov_print_enabled_features) endforeach() message(STATUS "") endfunction() - -# deprecated - -macro (ie_option variable description value) - message(WARNING "'ie_option' is deprecated, please, use 'ov_option' instead") - ov_option(${variable} "${description}" ${value}) -endmacro() - -macro(ie_dependent_option variable description def_value condition fallback_value) - message(WARNING "'ie_dependent_option' is deprecated, please, use 'ov_dependent_option' instead") - ov_dependent_option(${variable} "${description}" ${def_value} "${condition}" ${fallback_value}) -endmacro() - -function(print_enabled_features) - message(WARNING "'print_enabled_features' is deprecated, please, use 'ov_print_enabled_features' instead") - ov_print_enabled_features() -endfunction() diff --git a/cmake/developer_package/packaging/packaging.cmake b/cmake/developer_package/packaging/packaging.cmake index 2279580040f736..ff970e0b040cc5 100644 --- a/cmake/developer_package/packaging/packaging.cmake +++ b/cmake/developer_package/packaging/packaging.cmake @@ -241,10 +241,3 @@ macro(ov_cpack) include(CPack) endmacro() - -# deprecated - -macro(ie_cpack) - message(WARNING "'ie_cpack' is deprecated. Please, use 'ov_cpack'") - ov_cpack(${ARGV}) -endmacro() diff --git a/cmake/developer_package/plugins/plugins.cmake b/cmake/developer_package/plugins/plugins.cmake index a8ba97ad9fa27d..16a9e935a896c8 100644 --- a/cmake/developer_package/plugins/plugins.cmake +++ b/cmake/developer_package/plugins/plugins.cmake @@ -135,9 +135,6 @@ function(ov_add_plugin) install(TARGETS ${OV_PLUGIN_NAME} LIBRARY DESTINATION ${OV_CPACK_PLUGINSDIR} COMPONENT ${install_component}) - install(TARGETS ${OV_PLUGIN_NAME} - LIBRARY DESTINATION ${OV_CPACK_PLUGINSDIR} - COMPONENT ${install_component}) else() ov_install_static_lib(${OV_PLUGIN_NAME} ${OV_CPACK_COMP_CORE}) endif() @@ -167,11 +164,6 @@ function(ov_add_plugin) endif() endfunction() -function(ie_add_plugin) - message(WARNING "'ie_add_plugin' is deprecated. Please, use 'ov_add_plugin'") - ov_add_plugin(${ARGN}) -endfunction() - # # ov_register_in_plugins_xml(MAIN_TARGET
) # @@ -263,14 +255,6 @@ macro(ov_register_plugins) endif() endmacro() -# -# ie_register_plugins() -# -macro(ie_register_plugins) - message(WARNING "'ie_register_plugins' is deprecated. Please, use 'ov_register_plugins'") - ov_register_plugins(${ARGN}) -endmacro() - # # ov_target_link_plugins() # diff --git a/cmake/developer_package/version.cmake b/cmake/developer_package/version.cmake index effb320014452a..4ecf558225fb65 100644 --- a/cmake/developer_package/version.cmake +++ b/cmake/developer_package/version.cmake @@ -166,28 +166,6 @@ macro(ov_parse_ci_build_number repo_root) endif() endmacro() -macro (addVersionDefines FILE) - message(WARNING "'addVersionDefines' is deprecated. Please, use 'ov_add_version_defines'") - - set(__version_file ${FILE}) - if(NOT IS_ABSOLUTE ${__version_file}) - set(__version_file "${CMAKE_CURRENT_SOURCE_DIR}/${__version_file}") - endif() - if(NOT EXISTS ${__version_file}) - message(FATAL_ERROR "${FILE} does not exists in current source directory") - endif() - foreach (VAR ${ARGN}) - if (DEFINED ${VAR} AND NOT "${${VAR}}" STREQUAL "") - set_property( - SOURCE ${__version_file} - APPEND - PROPERTY COMPILE_DEFINITIONS - ${VAR}="${${VAR}}") - endif() - endforeach() - unset(__version_file) -endmacro() - macro (ov_add_version_defines FILE TARGET) set(__version_file ${FILE}) if(NOT IS_ABSOLUTE ${__version_file}) diff --git a/cmake/developer_package/whole_archive.cmake b/cmake/developer_package/whole_archive.cmake index 0ad00055fbfb0e..c15a5c378a3181 100644 --- a/cmake/developer_package/whole_archive.cmake +++ b/cmake/developer_package/whole_archive.cmake @@ -51,10 +51,3 @@ function(ov_target_link_whole_archive targetName) target_link_libraries(${targetName} PRIVATE ${libs}) endif() endfunction() - -# deprecated - -function(ieTargetLinkWholeArchive) - message(WARNING "'ieTargetLinkWholeArchive' is deprecated, use 'ov_target_link_whole_archive' instead") - ov_target_link_whole_archive(${ARGN}) -endfunction() diff --git a/cmake/extra_modules.cmake b/cmake/extra_modules.cmake index 6c392fcc6eed12..dae1cb0b2e045e 100644 --- a/cmake/extra_modules.cmake +++ b/cmake/extra_modules.cmake @@ -2,38 +2,6 @@ # SPDX-License-Identifier: Apache-2.0 # -function(ie_generate_dev_package_config) - # dummy check that OpenCV is here - find_package(OpenCV QUIET) - if(OpenCV_VERSION VERSION_LESS 3.0) - set(OpenCV_FOUND OFF) - endif() - - # export all targets with prefix and use them during extra modules build - export(TARGETS ${_OPENVINO_DEVELOPER_PACKAGE_TARGETS} NAMESPACE IE:: - APPEND FILE "${CMAKE_BINARY_DIR}/inference_engine_developer_package_targets.cmake") - add_custom_target(ie_dev_targets DEPENDS ${_OPENVINO_DEVELOPER_PACKAGE_TARGETS}) - - set(PATH_VARS "OpenVINO_SOURCE_DIR") - if(ENABLE_SAMPLES OR ENABLE_TESTS) - list(APPEND PATH_VARS "gflags_BINARY_DIR") - # if we've found system gflags - if(gflags_DIR) - set(gflags_BINARY_DIR "${gflags_DIR}") - endif() - endif() - - configure_package_config_file("${OpenVINO_SOURCE_DIR}/cmake/templates/InferenceEngineDeveloperPackageConfig.cmake.in" - "${CMAKE_BINARY_DIR}/InferenceEngineDeveloperPackageConfig.cmake" - INSTALL_DESTINATION share # not used - PATH_VARS ${PATH_VARS} - NO_CHECK_REQUIRED_COMPONENTS_MACRO) - - configure_file("${OpenVINO_SOURCE_DIR}/cmake/templates/InferenceEngineConfig-version.cmake.in" - "${CMAKE_BINARY_DIR}/InferenceEngineDeveloperPackageConfig-version.cmake" - @ONLY) -endfunction() - function(ov_generate_dev_package_config) # dummy check that OpenCV is here find_package(OpenCV QUIET) @@ -207,7 +175,6 @@ endfunction() # this OpenVINODeveloperPackageConfig.cmake is not used during extra modules build # since it's generated after modules are configured -ie_generate_dev_package_config() ov_generate_dev_package_config() # extra modules must be registered after inference_engine library diff --git a/cmake/templates/InferenceEngineDeveloperPackageConfig.cmake.in b/cmake/templates/InferenceEngineDeveloperPackageConfig.cmake.in deleted file mode 100644 index a98b4207e285d2..00000000000000 --- a/cmake/templates/InferenceEngineDeveloperPackageConfig.cmake.in +++ /dev/null @@ -1,188 +0,0 @@ -# Copyright (C) 2018-2023 Intel Corporation -# SPDX-License-Identifier: Apache-2.0 -# - -@PACKAGE_INIT@ - -include(CMakeFindDependencyMacro) - -message(WARNING "find_package(InferenceEngineDeveloperPackage) is deprecated and will be removed in 2024.0 release. Please, use find_package(OpenVINODeveloperPackage)") - -# TODO: remove after changing [private plugins] -set_and_check(OpenVINO_SOURCE_DIR "@OpenVINO_SOURCE_DIR@") # NPU -set_and_check(OpenVINO_MAIN_SOURCE_DIR "@OpenVINO_SOURCE_DIR@") # NPU - -# Variables to export in plugin's projects - -set(ov_options "@OV_OPTIONS@") -list(APPEND ov_options CMAKE_CXX_COMPILER_LAUNCHER CMAKE_C_COMPILER_LAUNCHER - CMAKE_CXX_LINKER_LAUNCHER CMAKE_C_LINKER_LAUNCHER - CMAKE_INSTALL_PREFIX CPACK_GENERATOR) - -if(APPLE) - list(APPEND ov_options CMAKE_OSX_ARCHITECTURES CMAKE_OSX_DEPLOYMENT_TARGET) -endif() - -get_property(_OV_GENERATOR_MULTI_CONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) -if(_OV_GENERATOR_MULTI_CONFIG) - list(APPEND ov_options CMAKE_CONFIGURATION_TYPES) - if(CMAKE_GENERATOR MATCHES "^Ninja Multi-Config$") - list(APPEND ov_options CMAKE_DEFAULT_BUILD_TYPE) - endif() -else() - list(APPEND ov_options CMAKE_BUILD_TYPE) -endif() -unset(_OV_GENERATOR_MULTI_CONFIG) - -file(TO_CMAKE_PATH "${CMAKE_CURRENT_LIST_DIR}" cache_path) - -message(STATUS "The following CMake options are exported from Inference Engine Developer package") -message(" ") -foreach(option IN LISTS ov_options) - if(NOT DEFINED "${option}") - load_cache("${cache_path}" READ_WITH_PREFIX "" ${option}) - endif() - message(" ${option}: ${${option}}") -endforeach() -message(" ") - -# for samples in 3rd party projects -if(ENABLE_SAMPLES) - set_and_check(gflags_DIR "@gflags_BINARY_DIR@") -endif() - -# Disable warning as error for private components -set(CMAKE_COMPILE_WARNING_AS_ERROR OFF) - -# -# Content -# - -find_dependency(OpenVINODeveloperScripts - PATHS "${OpenVINO_SOURCE_DIR}/cmake/developer_package" - NO_CMAKE_FIND_ROOT_PATH - NO_DEFAULT_PATH) - -find_dependency(InferenceEngine - PATHS "${CMAKE_CURRENT_LIST_DIR}" - NO_CMAKE_FIND_ROOT_PATH - NO_DEFAULT_PATH) - -find_dependency(ngraph - PATHS "${CMAKE_CURRENT_LIST_DIR}" - NO_CMAKE_FIND_ROOT_PATH - NO_DEFAULT_PATH) - -if(TARGET openvino::runtime AND NOT TARGET IE::runtime) - add_library(IE::runtime INTERFACE IMPORTED) - set_target_properties(IE::runtime PROPERTIES - INTERFACE_LINK_LIBRARIES openvino::runtime) -endif() - -# WA for cmake: it exports ngraph as IE::ngraph in the IE export list -# while we already have ngraph export in its own export list as ngraph::ngraph -if(TARGET ngraph::ngraph AND NOT TARGET IE::ngraph) - add_library(IE::ngraph INTERFACE IMPORTED) - set_target_properties(IE::ngraph PROPERTIES INTERFACE_LINK_LIBRARIES ngraph::ngraph) -endif() - -_ov_find_tbb() - -include("${CMAKE_CURRENT_LIST_DIR}/inference_engine_developer_package_targets.cmake") - -if(TARGET IE::ov_core_dev AND NOT TARGET openvino::core::dev) - add_library(openvino::core::dev INTERFACE IMPORTED) - set_target_properties(openvino::core::dev PROPERTIES - INTERFACE_LINK_LIBRARIES IE::ov_core_dev) -endif() - -if(TARGET IE::runtime::dev AND NOT TARGET openvino::runtime::dev) - add_library(openvino::runtime::dev INTERFACE IMPORTED) - set_target_properties(openvino::runtime::dev PROPERTIES - INTERFACE_LINK_LIBRARIES IE::runtime::dev) -endif() - -if(TARGET IE::reference AND NOT TARGET IE::ngraph_reference) - add_library(IE::ngraph_reference INTERFACE IMPORTED) - set_target_properties(IE::ngraph_reference PROPERTIES - INTERFACE_LINK_LIBRARIES IE::reference) -endif() - -if(ENABLE_SYSTEM_PUGIXML) - set(_ov_pugixml_pkgconfig_interface "@pugixml_FOUND@") - set(_ov_pugixml_cmake_interface "@PugiXML_FOUND@") - if(_ov_pugixml_pkgconfig_interface) - find_dependency(PkgConfig) - elseif(_ov_pugixml_cmake_interface) - find_dependency(PugiXML) - endif() - if(PugiXML_FOUND) - set_property(TARGET pugixml PROPERTY IMPORTED_GLOBAL TRUE) - add_library(IE::pugixml ALIAS pugixml) - elseif(PkgConfig_FOUND) - if(${CMAKE_FIND_PACKAGE_NAME}_FIND_QUIETLY) - set(pkg_config_quiet_arg QUIET) - endif() - if(${CMAKE_FIND_PACKAGE_NAME}_FIND_REQUIRED) - set(pkg_config_required_arg REQUIRED) - endif() - - pkg_search_module(pugixml - ${pkg_config_quiet_arg} - ${pkg_config_required_arg} - IMPORTED_TARGET GLOBAL - pugixml) - - unset(pkg_config_quiet_arg) - unset(pkg_config_required_arg) - - if(pugixml_FOUND) - add_library(IE::pugixml ALIAS PkgConfig::pugixml) - - # PATCH: on Ubuntu 18.04 pugixml.pc contains incorrect include directories - get_target_property(interface_include_dir PkgConfig::pugixml INTERFACE_INCLUDE_DIRECTORIES) - if(interface_include_dir AND NOT EXISTS "${interface_include_dir}") - set_target_properties(PkgConfig::pugixml PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "") - endif() - endif() - endif() - - # debian 9 case: no cmake, no pkg-config files - if(NOT TARGET IE::pugixml) - find_library(PUGIXML_LIBRARY NAMES pugixml DOC "Path to pugixml library") - if(PUGIXML_LIBRARY) - add_library(IE::pugixml INTERFACE IMPORTED GLOBAL) - set_target_properties(IE::pugixml PROPERTIES INTERFACE_LINK_LIBRARIES "${PUGIXML_LIBRARY}") - else() - message(FATAL_ERROR "Failed to find system pugixml in OpenVINO Developer Package") - endif() - endif() -endif() - -set(_ov_nlohmann_json_FOUND "@nlohmann_json_FOUND@") -if(_ov_nlohmann_json_FOUND) - find_dependency(nlohmann_json) - set_target_properties(nlohmann_json::nlohmann_json PROPERTIES IMPORTED_GLOBAL ON) - add_library(IE::nlohmann_json ALIAS nlohmann_json::nlohmann_json) -endif() -unset(_ov_nlohmann_json_FOUND) - -# inherit OpenCV from main IE project if enabled -if("@OpenCV_FOUND@") - # Use OpenCV_DIR from cache only if user doesn't define OpenCV_DIR - if(NOT OpenCV_DIR) - load_cache("${cache_path}" READ_WITH_PREFIX "" OpenCV_DIR) - endif() - find_dependency(OpenCV) -endif() - -# -# Extra Compile Flags -# - -# don't fail on strict compilation options in 3rd party modules -ov_dev_package_no_errors() - -# Don't threat deprecated API warnings as errors in 3rd party apps -ov_deprecated_no_errors() diff --git a/docs/OV_Runtime_UG/auto_device_selection.rst b/docs/OV_Runtime_UG/auto_device_selection.rst index 832369d9611183..807944dd248506 100644 --- a/docs/OV_Runtime_UG/auto_device_selection.rst +++ b/docs/OV_Runtime_UG/auto_device_selection.rst @@ -167,6 +167,17 @@ Following the OpenVINO™ naming convention, the Automatic Device Selection mode | | | | | The default value is ``true``. | +----------------------------------------------+--------------------------------------------------------------------+ +| ``ov::intel_auto::schedule_policy`` | **Values**: | +| | | +| | ``ROUND_ROBIN`` | +| | | +| | ``DEVICE_PRIORITY`` | +| | | +| | Specify the schedule policy of infer request assigned to hardware | +| | plugin for AUTO cumulative mode (MULTI). | +| | | +| | The default value is ``DEVICE_PRIORITY``. | ++----------------------------------------------+--------------------------------------------------------------------+ Inference with AUTO is configured similarly to when device plugins are used: you compile the model on the plugin with configuration and execute inference. diff --git a/docs/articles_en/documentation/openvino_ir/operation_sets/operations_specifications/reduction/ReduceMax_1.rst b/docs/articles_en/documentation/openvino_ir/operation_sets/operations_specifications/reduction/ReduceMax_1.rst index 77ea0d5b177049..5037372de4cbce 100644 --- a/docs/articles_en/documentation/openvino_ir/operation_sets/operations_specifications/reduction/ReduceMax_1.rst +++ b/docs/articles_en/documentation/openvino_ir/operation_sets/operations_specifications/reduction/ReduceMax_1.rst @@ -30,6 +30,8 @@ Particular cases: 1. If ``axes`` is an empty list, *ReduceMax* corresponds to the identity operation. 2. If ``axes`` contains all dimensions of input ``data``, a single reduction value is calculated for the entire input tensor. +Reducing empty tensor results in an undefined behavior. + **Attributes** * *keep_dims* diff --git a/docs/articles_en/documentation/openvino_ir/operation_sets/operations_specifications/reduction/ReduceMin_1.rst b/docs/articles_en/documentation/openvino_ir/operation_sets/operations_specifications/reduction/ReduceMin_1.rst index a8c0f351fde32e..4986ddc474606f 100644 --- a/docs/articles_en/documentation/openvino_ir/operation_sets/operations_specifications/reduction/ReduceMin_1.rst +++ b/docs/articles_en/documentation/openvino_ir/operation_sets/operations_specifications/reduction/ReduceMin_1.rst @@ -30,6 +30,8 @@ Particular cases: 1. If ``axes`` is an empty list, *ReduceMin* corresponds to the identity operation. 2. If ``axes`` contains all dimensions of input ``data``, a single reduction value is calculated for the entire input tensor. +Reducing empty tensor results in an undefined behavior. + **Attributes** * *keep_dims* diff --git a/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api.rst b/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api.rst index 953a330a215ca1..1107961ded34fa 100644 --- a/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api.rst +++ b/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api.rst @@ -8,13 +8,13 @@ Legacy Conversion API :maxdepth: 1 :hidden: - openvino_docs_MO_DG_prepare_model_convert_model_Converting_Model - openvino_docs_MO_DG_prepare_model_convert_model_Cutting_Model - openvino_docs_MO_DG_Additional_Optimization_Use_Cases - openvino_docs_MO_DG_FP16_Compression - openvino_docs_MO_DG_Python_API - openvino_docs_MO_DG_prepare_model_Model_Optimizer_FAQ - Supported_Model_Formats_MO_DG + Setting Input Shapes + Cutting Off Parts of a Model + Embedding Preprocessing Computation + Compressing a Model to FP16 + Convert Models Represented as Python Objects + Model Optimizer Frequently Asked Questions + Supported Model Formats .. meta:: :description: Model conversion (MO) furthers the transition between training and diff --git a/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/convert_python_model_objects.rst b/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/convert_python_model_objects.rst index e04814b8ea07ee..0eb9ca76060cd9 100644 --- a/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/convert_python_model_objects.rst +++ b/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/convert_python_model_objects.rst @@ -1,8 +1,13 @@ .. {#openvino_docs_MO_DG_Python_API} -Convert Models Represented as Python Objects -============================================ +[LEGACY] Convert Models Represented as Python Objects +============================================================= +.. danger:: + + The code described here has been **deprecated!** Do not use it to avoid working with a legacy solution. It will be kept for some time to ensure backwards compatibility, but **you should not use** it in contemporary applications. + + This guide describes a deprecated conversion method. The guide on the new and recommended method can be found in the :doc:`Model Preparation ` article. Model conversion API is represented by ``convert_model()`` method in openvino.tools.mo namespace. ``convert_model()`` is compatible with types from openvino.runtime, like PartialShape, Layout, Type, etc. diff --git a/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/cutting_model.rst b/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/cutting_model.rst index a0519aa75146cb..1a43044c4bcffa 100644 --- a/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/cutting_model.rst +++ b/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/cutting_model.rst @@ -1,8 +1,11 @@ .. {#openvino_docs_MO_DG_prepare_model_convert_model_Cutting_Model} -Cutting Off Parts of a Model -============================ +[LEGACY] Cutting Off Parts of a Model +================================================ +.. danger:: + + The code described here has been **deprecated!** Do not use it to avoid working with a legacy solution. It will be kept for some time to ensure backwards compatibility, but **you should not use** it in contemporary applications. Sometimes, it is necessary to remove parts of a model when converting it to OpenVINO IR. This chapter describes how to do it, using model conversion API parameters. Model cutting applies mostly to TensorFlow models, which is why TensorFlow will be used in this chapter's examples, but it may be also useful for other frameworks. diff --git a/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/embedding_preprocessing_computation.rst b/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/embedding_preprocessing_computation.rst index bb8585a489c5f6..dd6aac35bd0de0 100644 --- a/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/embedding_preprocessing_computation.rst +++ b/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/embedding_preprocessing_computation.rst @@ -1,8 +1,13 @@ .. {#openvino_docs_MO_DG_Additional_Optimization_Use_Cases} -Embedding Preprocessing Computation -=================================== +[LEGACY] Embedding Preprocessing Computation +===================================================== +.. danger:: + + The code described here has been **deprecated!** Do not use it to avoid working with a legacy solution. It will be kept for some time to ensure backwards compatibility, but **you should not use** it in contemporary applications. + + This guide describes a deprecated conversion method. The guide on the new and recommended method can be found in the :doc:`Conversion Parameters ` article. Input data for inference can be different from the training dataset and requires additional preprocessing before inference. To accelerate the whole pipeline including diff --git a/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/fp16_compression.rst b/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/fp16_compression.rst index e2820ecbaddab1..a692fe389451ae 100644 --- a/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/fp16_compression.rst +++ b/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/fp16_compression.rst @@ -1,9 +1,14 @@ .. {#openvino_docs_MO_DG_FP16_Compression} -Compressing a Model to FP16 -=========================== +[LEGACY] Compressing a Model to FP16 +============================================= +.. danger:: + The code described here has been **deprecated!** Do not use it to avoid working with a legacy solution. It will be kept for some time to ensure backwards compatibility, but **you should not use** it in contemporary applications. + + This guide describes a deprecated conversion method. The guide on the new and recommended method can be found in the :doc:`Conversion Parameters ` article. + By default, when IR is saved all relevant floating-point weights are compressed to ``FP16`` data type during model conversion. It results in creating a "compressed ``FP16`` model", which occupies about half of the original space in the file system. The compression may introduce a minor drop in accuracy, diff --git a/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/model_optimizer_faq.rst b/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/model_optimizer_faq.rst index 4ab9963388147b..0138307a04aec6 100644 --- a/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/model_optimizer_faq.rst +++ b/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/model_optimizer_faq.rst @@ -1,7 +1,7 @@ .. {#openvino_docs_MO_DG_prepare_model_Model_Optimizer_FAQ} -Model Optimizer Frequently Asked Questions -========================================== +[LEGACY] Model Optimizer Frequently Asked Questions +=========================================================== .. important:: diff --git a/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/setting_input_shapes.rst b/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/setting_input_shapes.rst index c9c4ad6aac121b..a4e5e1fb935149 100644 --- a/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/setting_input_shapes.rst +++ b/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/setting_input_shapes.rst @@ -1,7 +1,13 @@ .. {#openvino_docs_MO_DG_prepare_model_convert_model_Converting_Model} -Setting Input Shapes -==================== +[LEGACY] Setting Input Shapes +==================================== + +.. danger:: + + The code described here has been **deprecated!** Do not use it to avoid working with a legacy solution. It will be kept for some time to ensure backwards compatibility, but **you should not use** it in contemporary applications. + + This guide describes a deprecated conversion method. The guide on the new and recommended method can be found in the :doc:`Setting Input Shapes ` article. With model conversion API you can increase your model's efficiency by providing an additional shape definition, with these two parameters: `input_shape` and `static_shape`. diff --git a/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats.rst b/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats.rst index a9fc5aad4703f4..d66f8596f09fe6 100644 --- a/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats.rst +++ b/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats.rst @@ -1,19 +1,24 @@ .. {#Supported_Model_Formats_MO_DG} -Supported Model Formats -======================= +[LEGACY] Supported Model Formats +===================================== +.. danger:: + + The code described here has been **deprecated!** Do not use it to avoid working with a legacy solution. It will be kept for some time to ensure backwards compatibility, but **you should not use** it in contemporary applications. + + This guide describes a deprecated conversion method. The guide on the new and recommended method can be found in the :doc:`Supported Model Formats ` article. .. toctree:: :maxdepth: 1 :hidden: - openvino_docs_MO_DG_prepare_model_convert_model_Convert_Model_From_TensorFlow - openvino_docs_MO_DG_prepare_model_convert_model_Convert_Model_From_ONNX - openvino_docs_MO_DG_prepare_model_convert_model_Convert_Model_From_PyTorch - openvino_docs_MO_DG_prepare_model_convert_model_Convert_Model_From_TensorFlow_Lite - openvino_docs_MO_DG_prepare_model_convert_model_Convert_Model_From_Paddle - openvino_docs_MO_DG_prepare_model_convert_model_tutorials + Converting a TensorFlow Model + Converting an ONNX Model + Converting a PyTorch Model + Converting a TensorFlow Lite Model + Converting a PaddlePaddle Model + Model Conversion Tutorials .. meta:: :description: Learn about supported model formats and the methods used to convert, read, and compile them in OpenVINO™. diff --git a/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/Convert_Model_From_ONNX.rst b/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/Convert_Model_From_ONNX.rst index 6da4ac3ba36e5b..db3a16b4954643 100644 --- a/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/Convert_Model_From_ONNX.rst +++ b/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/Convert_Model_From_ONNX.rst @@ -1,13 +1,20 @@ .. {#openvino_docs_MO_DG_prepare_model_convert_model_Convert_Model_From_ONNX} -Converting an ONNX Model -======================== - +[LEGACY] Converting an ONNX Model +============================================= .. meta:: :description: Learn how to convert a model from the ONNX format to the OpenVINO Intermediate Representation. + +.. danger:: + + The code described here has been **deprecated!** Do not use it to avoid working with a legacy solution. It will be kept for some time to ensure backwards compatibility, but **you should not use** it in contemporary applications. + + This guide describes a deprecated conversion method. The guide on the new and recommended method can be found in the :doc:`Converting an ONNX Model ` article. + + .. note:: ONNX models are supported via FrontEnd API. You may skip conversion to IR and read models directly by OpenVINO runtime API. Refer to the :doc:`inference example ` for more details. Using ``convert_model`` is still necessary in more complex cases, such as new custom inputs/outputs in model pruning, adding pre-processing, or using Python conversion extensions. Converting an ONNX Model diff --git a/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/Convert_Model_From_Paddle.rst b/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/Convert_Model_From_Paddle.rst index 0819d97ed90934..09f6a8d99f3057 100644 --- a/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/Convert_Model_From_Paddle.rst +++ b/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/Convert_Model_From_Paddle.rst @@ -1,7 +1,7 @@ .. {#openvino_docs_MO_DG_prepare_model_convert_model_Convert_Model_From_Paddle} -Converting a PaddlePaddle Model -=============================== +[LEGACY] Converting a PaddlePaddle Model +====================================================== .. meta:: @@ -9,6 +9,13 @@ Converting a PaddlePaddle Model PaddlePaddle format to the OpenVINO Intermediate Representation. +.. danger:: + + The code described here has been **deprecated!** Do not use it to avoid working with a legacy solution. It will be kept for some time to ensure backwards compatibility, but **you should not use** it in contemporary applications. + + This guide describes a deprecated conversion method. The guide on the new and recommended method can be found in the :doc:`Converting a PaddlePaddle Model ` article. + + This page provides general instructions on how to convert a model from a PaddlePaddle format to the OpenVINO IR format using Model Optimizer. The instructions are different depending on PaddlePaddle model format. .. note:: PaddlePaddle models are supported via FrontEnd API. You may skip conversion to IR and read models directly by OpenVINO runtime API. Refer to the :doc:`inference example ` for more details. Using ``convert_model`` is still necessary in more complex cases, such as new custom inputs/outputs in model pruning, adding pre-processing, or using Python conversion extensions. diff --git a/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/Convert_Model_From_PyTorch.rst b/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/Convert_Model_From_PyTorch.rst index 87963bc9531bee..f4003b700446d6 100644 --- a/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/Convert_Model_From_PyTorch.rst +++ b/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/Convert_Model_From_PyTorch.rst @@ -1,7 +1,7 @@ .. {#openvino_docs_MO_DG_prepare_model_convert_model_Convert_Model_From_PyTorch} -Converting a PyTorch Model -========================== +[LEGACY] Converting a PyTorch Model +============================================ .. meta:: @@ -9,6 +9,12 @@ Converting a PyTorch Model PyTorch format to the OpenVINO Intermediate Representation. +.. danger:: + + The code described here has been **deprecated!** Do not use it to avoid working with a legacy solution. It will be kept for some time to ensure backwards compatibility, but **you should not use** it in contemporary applications. + + This guide describes a deprecated conversion method. The guide on the new and recommended method can be found in the :doc:`Converting a PyTorch Model ` article. + This page provides instructions on how to convert a model from the PyTorch format to the OpenVINO IR format. The conversion is a required step to run inference using OpenVINO API. diff --git a/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/Convert_Model_From_TensorFlow.rst b/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/Convert_Model_From_TensorFlow.rst index 637912310bba6c..54bb1016bf800c 100644 --- a/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/Convert_Model_From_TensorFlow.rst +++ b/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/Convert_Model_From_TensorFlow.rst @@ -1,13 +1,18 @@ .. {#openvino_docs_MO_DG_prepare_model_convert_model_Convert_Model_From_TensorFlow} -Converting a TensorFlow Model -============================= - +[LEGACY] Converting a TensorFlow Model +============================================ .. meta:: :description: Learn how to convert a model from a TensorFlow format to the OpenVINO Intermediate Representation. +.. danger:: + + The code described here has been **deprecated!** Do not use it to avoid working with a legacy solution. It will be kept for some time to ensure backwards compatibility, but **you should not use** it in contemporary applications. + + This guide describes a deprecated conversion method. The guide on the new and recommended method can be found in the :doc:`Converting a TensorFlow Model ` article. + .. note:: TensorFlow models are supported via :doc:`FrontEnd API `. You may skip conversion to IR and read models directly by OpenVINO runtime API. Refer to the :doc:`inference example ` for more details. Using ``convert_model`` is still necessary in more complex cases, such as new custom inputs/outputs in model pruning, adding pre-processing, or using Python conversion extensions. diff --git a/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/Convert_Model_From_TensorFlow_Lite.rst b/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/Convert_Model_From_TensorFlow_Lite.rst index f986048c566456..996785d8fc7655 100644 --- a/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/Convert_Model_From_TensorFlow_Lite.rst +++ b/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/Convert_Model_From_TensorFlow_Lite.rst @@ -1,13 +1,18 @@ .. {#openvino_docs_MO_DG_prepare_model_convert_model_Convert_Model_From_TensorFlow_Lite} -Converting a TensorFlow Lite Model -================================== +[LEGACY] Converting a TensorFlow Lite Model +===================================================== .. meta:: :description: Learn how to convert a model from a TensorFlow Lite format to the OpenVINO Intermediate Representation. +.. danger:: + + The code described here has been **deprecated!** Do not use it to avoid working with a legacy solution. It will be kept for some time to ensure backwards compatibility, but **you should not use** it in contemporary applications. + + This guide describes a deprecated conversion method. The guide on the new and recommended method can be found in the :doc:`Converting a TensorFlow Lite Model ` article. To convert a TensorFlow Lite model, use the ``mo`` script and specify the path to the input ``.tflite`` model file: diff --git a/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/convert_model_tutorials.rst b/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/convert_model_tutorials.rst index 53878b922ad321..ae8a20f937a9b0 100644 --- a/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/convert_model_tutorials.rst +++ b/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/convert_model_tutorials.rst @@ -1,7 +1,7 @@ .. {#openvino_docs_MO_DG_prepare_model_convert_model_tutorials} -Model Conversion Tutorials -========================== +[LEGACY] Model Conversion Tutorials +==================================================== .. toctree:: @@ -39,6 +39,12 @@ Model Conversion Tutorials :description: Get to know conversion methods for specific TensorFlow, ONNX, PyTorch, MXNet, and Kaldi models. +.. danger:: + + The code described in the tutorials has been **deprecated!** Do not use it to avoid working with a legacy solution. It will be kept for some time to ensure backwards compatibility, but **you should not use** it in contemporary applications. + + This guide describes a deprecated conversion method. The guide on the new and recommended method can be found in the :doc:`Python tutorials `. + This section provides a set of tutorials that demonstrate conversion methods for specific TensorFlow, ONNX, and PyTorch models. Note that these instructions do not cover all use cases and may not reflect your particular needs. diff --git a/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/convert_model_tutorials/Convert_AttentionOCR_From_Tensorflow.rst b/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/convert_model_tutorials/Convert_AttentionOCR_From_Tensorflow.rst index 46a362f40838d1..e24f50c82d6efd 100644 --- a/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/convert_model_tutorials/Convert_AttentionOCR_From_Tensorflow.rst +++ b/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/convert_model_tutorials/Convert_AttentionOCR_From_Tensorflow.rst @@ -10,6 +10,12 @@ Converting a TensorFlow Attention OCR Model OpenVINO Intermediate Representation. +.. danger:: + + The code described here has been **deprecated!** Do not use it to avoid working with a legacy solution. It will be kept for some time to ensure backwards compatibility, but **you should not use** it in contemporary applications. + + This guide describes a deprecated conversion method. The guide on the new and recommended method can be found in the :doc:`Python tutorials `. + This tutorial explains how to convert the Attention OCR (AOCR) model from the `TensorFlow Attention OCR repository `__ to the Intermediate Representation (IR). Extracting a Model from ``aocr`` Library diff --git a/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/convert_model_tutorials/Convert_BERT_From_Tensorflow.rst b/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/convert_model_tutorials/Convert_BERT_From_Tensorflow.rst index 37dda47124b92c..1fb3df0ccca34d 100644 --- a/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/convert_model_tutorials/Convert_BERT_From_Tensorflow.rst +++ b/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/convert_model_tutorials/Convert_BERT_From_Tensorflow.rst @@ -9,6 +9,12 @@ Converting a TensorFlow BERT Model from TensorFlow to the OpenVINO Intermediate Representation. +.. danger:: + + The code described here has been **deprecated!** Do not use it to avoid working with a legacy solution. It will be kept for some time to ensure backwards compatibility, but **you should not use** it in contemporary applications. + + This guide describes a deprecated conversion method. The guide on the new and recommended method can be found in the :doc:`Python tutorials `. + Pretrained models for BERT (Bidirectional Encoder Representations from Transformers) are `publicly available `__. diff --git a/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/convert_model_tutorials/Convert_Bert_ner.rst b/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/convert_model_tutorials/Convert_Bert_ner.rst index 4074a0446eb685..a2fa512c62a061 100644 --- a/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/convert_model_tutorials/Convert_Bert_ner.rst +++ b/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/convert_model_tutorials/Convert_Bert_ner.rst @@ -8,6 +8,11 @@ Converting a PyTorch BERT-NER Model :description: Learn how to convert a BERT-NER model from PyTorch to the OpenVINO Intermediate Representation. +.. danger:: + + The code described here has been **deprecated!** Do not use it to avoid working with a legacy solution. It will be kept for some time to ensure backwards compatibility, but **you should not use** it in contemporary applications. + + This guide describes a deprecated conversion method. The guide on the new and recommended method can be found in the :doc:`Python tutorials `. The goal of this article is to present a step-by-step guide on how to convert PyTorch BERT-NER model to OpenVINO IR. First, you need to download the model and convert it to ONNX. diff --git a/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/convert_model_tutorials/Convert_CRNN_From_Tensorflow.rst b/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/convert_model_tutorials/Convert_CRNN_From_Tensorflow.rst index bb84fd01296da2..a101ce8ac24d91 100644 --- a/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/convert_model_tutorials/Convert_CRNN_From_Tensorflow.rst +++ b/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/convert_model_tutorials/Convert_CRNN_From_Tensorflow.rst @@ -9,6 +9,12 @@ Converting a TensorFlow CRNN Model from TensorFlow to the OpenVINO Intermediate Representation. +.. danger:: + + The code described here has been **deprecated!** Do not use it to avoid working with a legacy solution. It will be kept for some time to ensure backwards compatibility, but **you should not use** it in contemporary applications. + + This guide describes a deprecated conversion method. The guide on the new and recommended method can be found in the :doc:`Python tutorials `. + This tutorial explains how to convert a CRNN model to OpenVINO™ Intermediate Representation (IR). There are several public versions of TensorFlow CRNN model implementation available on GitHub. This tutorial explains how to convert the model from diff --git a/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/convert_model_tutorials/Convert_Cascade_RCNN_res101.rst b/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/convert_model_tutorials/Convert_Cascade_RCNN_res101.rst index 7242607070d101..5de41b8473b4e4 100644 --- a/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/convert_model_tutorials/Convert_Cascade_RCNN_res101.rst +++ b/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/convert_model_tutorials/Convert_Cascade_RCNN_res101.rst @@ -9,6 +9,12 @@ Converting a PyTorch Cascade RCNN R-101 Model model from PyTorch to the OpenVINO Intermediate Representation. +.. danger:: + + The code described here has been **deprecated!** Do not use it to avoid working with a legacy solution. It will be kept for some time to ensure backwards compatibility, but **you should not use** it in contemporary applications. + + This guide describes a deprecated conversion method. The guide on the new and recommended method can be found in the :doc:`Python tutorials `. + The goal of this article is to present a step-by-step guide on how to convert a PyTorch Cascade RCNN R-101 model to OpenVINO IR. First, you need to download the model and convert it to ONNX. Downloading and Converting Model to ONNX diff --git a/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/convert_model_tutorials/Convert_DeepSpeech_From_Tensorflow.rst b/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/convert_model_tutorials/Convert_DeepSpeech_From_Tensorflow.rst index 51a190fb823a7c..48e473511e8068 100644 --- a/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/convert_model_tutorials/Convert_DeepSpeech_From_Tensorflow.rst +++ b/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/convert_model_tutorials/Convert_DeepSpeech_From_Tensorflow.rst @@ -8,7 +8,12 @@ Converting a TensorFlow DeepSpeech Model :description: Learn how to convert a DeepSpeech model from TensorFlow to the OpenVINO Intermediate Representation. +.. danger:: + The code described here has been **deprecated!** Do not use it to avoid working with a legacy solution. It will be kept for some time to ensure backwards compatibility, but **you should not use** it in contemporary applications. + + This guide describes a deprecated conversion method. The guide on the new and recommended method can be found in the :doc:`Python tutorials `. + `DeepSpeech project `__ provides an engine to train speech-to-text models. Downloading the Pretrained DeepSpeech Model diff --git a/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/convert_model_tutorials/Convert_EfficientDet_Models.rst b/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/convert_model_tutorials/Convert_EfficientDet_Models.rst index ca59af4c210d95..4adb0107e792f0 100644 --- a/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/convert_model_tutorials/Convert_EfficientDet_Models.rst +++ b/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/convert_model_tutorials/Convert_EfficientDet_Models.rst @@ -9,6 +9,12 @@ Converting TensorFlow EfficientDet Models from TensorFlow to the OpenVINO Intermediate Representation. +.. danger:: + + The code described here has been **deprecated!** Do not use it to avoid working with a legacy solution. It will be kept for some time to ensure backwards compatibility, but **you should not use** it in contemporary applications. + + This guide describes a deprecated conversion method. The guide on the new and recommended method can be found in the :doc:`Python tutorials `. + This tutorial explains how to convert EfficientDet public object detection models to the Intermediate Representation (IR). .. _efficientdet-to-ir: diff --git a/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/convert_model_tutorials/Convert_F3Net.rst b/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/convert_model_tutorials/Convert_F3Net.rst index 70d5eebddfcec1..a4489d6a6349d8 100644 --- a/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/convert_model_tutorials/Convert_F3Net.rst +++ b/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/convert_model_tutorials/Convert_F3Net.rst @@ -8,7 +8,12 @@ Converting a PyTorch F3Net Model :description: Learn how to convert a F3Net model from PyTorch to the OpenVINO Intermediate Representation. +.. danger:: + The code described here has been **deprecated!** Do not use it to avoid working with a legacy solution. It will be kept for some time to ensure backwards compatibility, but **you should not use** it in contemporary applications. + + This guide describes a deprecated conversion method. The guide on the new and recommended method can be found in the :doc:`Python tutorials `. + `F3Net `__ : Fusion, Feedback and Focus for Salient Object Detection Cloning the F3Net Repository diff --git a/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/convert_model_tutorials/Convert_FaceNet_From_Tensorflow.rst b/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/convert_model_tutorials/Convert_FaceNet_From_Tensorflow.rst index 949fe0b98f02e5..dd8bab2c05adcd 100644 --- a/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/convert_model_tutorials/Convert_FaceNet_From_Tensorflow.rst +++ b/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/convert_model_tutorials/Convert_FaceNet_From_Tensorflow.rst @@ -8,7 +8,12 @@ Converting TensorFlow FaceNet Models :description: Learn how to convert a FaceNet model from TensorFlow to the OpenVINO Intermediate Representation. +.. danger:: + The code described here has been **deprecated!** Do not use it to avoid working with a legacy solution. It will be kept for some time to ensure backwards compatibility, but **you should not use** it in contemporary applications. + + This guide describes a deprecated conversion method. The guide on the new and recommended method can be found in the :doc:`Supported Model Formats ` article. + `Public pre-trained FaceNet models `__ contain both training and inference part of graph. Switch between this two states is manageable with placeholder value. Intermediate Representation (IR) models are intended for inference, which means that train part is redundant. diff --git a/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/convert_model_tutorials/Convert_Faster_RCNN.rst b/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/convert_model_tutorials/Convert_Faster_RCNN.rst index 5813d026f8ac11..02aa087fff08e4 100644 --- a/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/convert_model_tutorials/Convert_Faster_RCNN.rst +++ b/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/convert_model_tutorials/Convert_Faster_RCNN.rst @@ -8,7 +8,12 @@ Converting an ONNX Faster R-CNN Model :description: Learn how to convert a Faster R-CNN model from ONNX to the OpenVINO Intermediate Representation. +.. danger:: + The code described here has been **deprecated!** Do not use it to avoid working with a legacy solution. It will be kept for some time to ensure backwards compatibility, but **you should not use** it in contemporary applications. + + This guide describes a deprecated conversion method. The guide on the new and recommended method can be found in the :doc:`Python tutorials `. + The instructions below are applicable **only** to the Faster R-CNN model converted to the ONNX file format from the `maskrcnn-benchmark model `__: 1. Download the pretrained model file from `onnx/models `__ (commit-SHA: 8883e49e68de7b43e263d56b9ed156dfa1e03117). diff --git a/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/convert_model_tutorials/Convert_GNMT_From_Tensorflow.rst b/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/convert_model_tutorials/Convert_GNMT_From_Tensorflow.rst index df4759b75f0e4d..7857d3fd4c9836 100644 --- a/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/convert_model_tutorials/Convert_GNMT_From_Tensorflow.rst +++ b/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/convert_model_tutorials/Convert_GNMT_From_Tensorflow.rst @@ -8,7 +8,12 @@ Converting a TensorFlow GNMT Model :description: Learn how to convert a GNMT model from TensorFlow to the OpenVINO Intermediate Representation. +.. danger:: + The code described here has been **deprecated!** Do not use it to avoid working with a legacy solution. It will be kept for some time to ensure backwards compatibility, but **you should not use** it in contemporary applications. + + This guide describes a deprecated conversion method. The guide on the new and recommended method can be found in the :doc:`Python tutorials `. + This tutorial explains how to convert Google Neural Machine Translation (GNMT) model to the Intermediate Representation (IR). There are several public versions of TensorFlow GNMT model implementation available on GitHub. This tutorial explains how to convert the GNMT model from the `TensorFlow Neural Machine Translation (NMT) repository `__ to the IR. diff --git a/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/convert_model_tutorials/Convert_GPT2.rst b/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/convert_model_tutorials/Convert_GPT2.rst index 26e5d0821d7cc4..2a6de424f3136d 100644 --- a/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/convert_model_tutorials/Convert_GPT2.rst +++ b/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/convert_model_tutorials/Convert_GPT2.rst @@ -8,6 +8,11 @@ Converting an ONNX GPT-2 Model :description: Learn how to convert a pre-trained GPT-2 model from ONNX to the OpenVINO Intermediate Representation. +.. danger:: + + The code described here has been **deprecated!** Do not use it to avoid working with a legacy solution. It will be kept for some time to ensure backwards compatibility, but **you should not use** it in contemporary applications. + + This guide describes a deprecated conversion method. The guide on the new and recommended method can be found in the :doc:`Python tutorials `. `Public pre-trained GPT-2 model `__ is a large transformer-based language model with a simple objective: predict the next word, given all of the previous words within some text. diff --git a/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/convert_model_tutorials/Convert_Mask_RCNN.rst b/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/convert_model_tutorials/Convert_Mask_RCNN.rst index 9f4d7906372e51..24aca44222ac54 100644 --- a/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/convert_model_tutorials/Convert_Mask_RCNN.rst +++ b/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/convert_model_tutorials/Convert_Mask_RCNN.rst @@ -8,6 +8,11 @@ Converting an ONNX Mask R-CNN Model :description: Learn how to convert a pre-trained Mask R-CNN model from ONNX to the OpenVINO Intermediate Representation. +.. danger:: + + The code described here has been **deprecated!** Do not use it to avoid working with a legacy solution. It will be kept for some time to ensure backwards compatibility, but **you should not use** it in contemporary applications. + + This guide describes a deprecated conversion method. The guide on the new and recommended method can be found in the :doc:`Python tutorials `. The instructions below are applicable **only** to the Mask R-CNN model converted to the ONNX file format from the `maskrcnn-benchmark model `__. diff --git a/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/convert_model_tutorials/Convert_NCF_From_Tensorflow.rst b/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/convert_model_tutorials/Convert_NCF_From_Tensorflow.rst index 5ae521e38e9228..407e2373eaf79a 100644 --- a/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/convert_model_tutorials/Convert_NCF_From_Tensorflow.rst +++ b/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/convert_model_tutorials/Convert_NCF_From_Tensorflow.rst @@ -9,6 +9,11 @@ Converting a TensorFlow Neural Collaborative Filtering Model Filtering Model from TensorFlow to the OpenVINO Intermediate Representation. +.. danger:: + + The code described here has been **deprecated!** Do not use it to avoid working with a legacy solution. It will be kept for some time to ensure backwards compatibility, but **you should not use** it in contemporary applications. + + This guide describes a deprecated conversion method. The guide on the new and recommended method can be found in the :doc:`Python tutorials `. This tutorial explains how to convert Neural Collaborative Filtering (NCF) model to the OpenVINO Intermediate Representation. diff --git a/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/convert_model_tutorials/Convert_Object_Detection_API_Models.rst b/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/convert_model_tutorials/Convert_Object_Detection_API_Models.rst index fe19d38a288e5d..f5688887b253f2 100644 --- a/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/convert_model_tutorials/Convert_Object_Detection_API_Models.rst +++ b/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/convert_model_tutorials/Convert_Object_Detection_API_Models.rst @@ -10,6 +10,12 @@ Converting TensorFlow Object Detection API Models Representation. +.. danger:: + + The code described here has been **deprecated!** Do not use it to avoid working with a legacy solution. It will be kept for some time to ensure backwards compatibility, but **you should not use** it in contemporary applications. + + This guide describes a deprecated conversion method. The guide on the new and recommended method can be found in the :doc:`Python tutorials `. + * Starting with the 2022.1 release, model conversion API can convert the TensorFlow Object Detection API Faster and Mask RCNNs topologies differently. By default, model conversion adds operation "Proposal" to the generated IR. This operation needs an additional input to the model with name "image_info" which should be fed with several values describing the preprocessing applied to the input image (refer to the :doc:`Proposal ` operation specification for more information). However, this input is redundant for the models trained and inferred with equal size images. Model conversion API can generate IR for such models and insert operation :doc:`DetectionOutput ` instead of ``Proposal``. The `DetectionOutput` operation does not require additional model input "image_info". Moreover, for some models the produced inference results are closer to the original TensorFlow model. In order to trigger new behavior, the attribute "operation_to_add" in the corresponding JSON transformation configuration file should be set to value "DetectionOutput" instead of default one "Proposal". * Starting with the 2021.1 release, model conversion API converts the TensorFlow Object Detection API SSDs, Faster and Mask RCNNs topologies keeping shape-calculating sub-graphs by default, so topologies can be re-shaped in the OpenVINO Runtime using dedicated reshape API. Refer to the :doc:`Using Shape Inference ` guide for more information on how to use this feature. It is possible to change the both spatial dimensions of the input image and batch size. * To generate IRs for TF 1 SSD topologies, model conversion API creates a number of ``PriorBoxClustered`` operations instead of a constant node with prior boxes calculated for the particular input image size. This change allows you to reshape the topology in the OpenVINO Runtime using dedicated API. The reshaping is supported for all SSD topologies except FPNs, which contain hardcoded shapes for some operations preventing from changing topology input shape. diff --git a/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/convert_model_tutorials/Convert_QuartzNet.rst b/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/convert_model_tutorials/Convert_QuartzNet.rst index 738c5b4fb8e68c..e0db665df7f25d 100644 --- a/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/convert_model_tutorials/Convert_QuartzNet.rst +++ b/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/convert_model_tutorials/Convert_QuartzNet.rst @@ -8,7 +8,12 @@ Converting a PyTorch QuartzNet Model :description: Learn how to convert a QuartzNet model from PyTorch to the OpenVINO Intermediate Representation. +.. danger:: + The code described here has been **deprecated!** Do not use it to avoid working with a legacy solution. It will be kept for some time to ensure backwards compatibility, but **you should not use** it in contemporary applications. + + This guide describes a deprecated conversion method. The guide on the new and recommended method can be found in the :doc:`Python tutorials `. + `NeMo project `__ provides the QuartzNet model. Downloading the Pre-trained QuartzNet Model diff --git a/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/convert_model_tutorials/Convert_RCAN.rst b/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/convert_model_tutorials/Convert_RCAN.rst index 3fb9d5cad3775f..1d2254c129ec3e 100644 --- a/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/convert_model_tutorials/Convert_RCAN.rst +++ b/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/convert_model_tutorials/Convert_RCAN.rst @@ -8,7 +8,12 @@ Converting a PyTorch RCAN Model :description: Learn how to convert a RCAN model from PyTorch to the OpenVINO Intermediate Representation. +.. danger:: + The code described here has been **deprecated!** Do not use it to avoid working with a legacy solution. It will be kept for some time to ensure backwards compatibility, but **you should not use** it in contemporary applications. + + This guide describes a deprecated conversion method. The guide on the new and recommended method can be found in the :doc:`Python tutorials `. + `RCAN `__ : Image Super-Resolution Using Very Deep Residual Channel Attention Networks Downloading and Converting the Model to ONNX diff --git a/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/convert_model_tutorials/Convert_RNNT.rst b/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/convert_model_tutorials/Convert_RNNT.rst index 2df33ff523a170..e1fae7f6f70474 100644 --- a/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/convert_model_tutorials/Convert_RNNT.rst +++ b/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/convert_model_tutorials/Convert_RNNT.rst @@ -8,7 +8,12 @@ Converting a PyTorch RNN-T Model :description: Learn how to convert a RNN-T model from PyTorch to the OpenVINO Intermediate Representation. +.. danger:: + The code described here has been **deprecated!** Do not use it to avoid working with a legacy solution. It will be kept for some time to ensure backwards compatibility, but **you should not use** it in contemporary applications. + + This guide describes a deprecated conversion method. The guide on the new and recommended method can be found in the :doc:`Python tutorials `. + This guide covers conversion of RNN-T model from `MLCommons `__ repository. Follow the instructions below to export a PyTorch model into ONNX, before converting it to IR: diff --git a/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/convert_model_tutorials/Convert_RetinaNet_From_Tensorflow.rst b/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/convert_model_tutorials/Convert_RetinaNet_From_Tensorflow.rst index 6c76154292883a..554b3fff9dd181 100644 --- a/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/convert_model_tutorials/Convert_RetinaNet_From_Tensorflow.rst +++ b/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/convert_model_tutorials/Convert_RetinaNet_From_Tensorflow.rst @@ -9,6 +9,12 @@ Converting a TensorFlow RetinaNet Model from TensorFlow to the OpenVINO Intermediate Representation. +.. danger:: + + The code described here has been **deprecated!** Do not use it to avoid working with a legacy solution. It will be kept for some time to ensure backwards compatibility, but **you should not use** it in contemporary applications. + + This guide describes a deprecated conversion method. The guide on the new and recommended method can be found in the :doc:`Python tutorials `. + This tutorial explains how to convert a RetinaNet model to the Intermediate Representation (IR). `Public RetinaNet model `__ does not contain pretrained TensorFlow weights. diff --git a/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/convert_model_tutorials/Convert_Slim_Library_Models.rst b/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/convert_model_tutorials/Convert_Slim_Library_Models.rst index ddeaca05ec6fe9..59a5a0389b6de4 100644 --- a/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/convert_model_tutorials/Convert_Slim_Library_Models.rst +++ b/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/convert_model_tutorials/Convert_Slim_Library_Models.rst @@ -9,6 +9,11 @@ Converting TensorFlow Slim Image Classification Model Library Models Classification model from TensorFlow to the OpenVINO Intermediate Representation. +.. danger:: + + The code described here has been **deprecated!** Do not use it to avoid working with a legacy solution. It will be kept for some time to ensure backwards compatibility, but **you should not use** it in contemporary applications. + + This guide describes a deprecated conversion method. The guide on the new and recommended method can be found in the :doc:`Python tutorials `. `TensorFlow-Slim Image Classification Model Library `__ is a library to define, train and evaluate classification models in TensorFlow. The library contains Python scripts defining the classification topologies together with checkpoint files for several pre-trained classification topologies. To convert a TensorFlow-Slim library model, complete the following steps: diff --git a/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/convert_model_tutorials/Convert_WideAndDeep_Family_Models.rst b/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/convert_model_tutorials/Convert_WideAndDeep_Family_Models.rst index 18d8b134df38ef..d5fd1bb320072d 100644 --- a/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/convert_model_tutorials/Convert_WideAndDeep_Family_Models.rst +++ b/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/convert_model_tutorials/Convert_WideAndDeep_Family_Models.rst @@ -9,6 +9,12 @@ Converting TensorFlow Wide and Deep Family Models models from TensorFlow to the OpenVINO Intermediate Representation. +.. danger:: + + The code described here has been **deprecated!** Do not use it to avoid working with a legacy solution. It will be kept for some time to ensure backwards compatibility, but **you should not use** it in contemporary applications. + + This guide describes a deprecated conversion method. The guide on the new and recommended method can be found in the :doc:`Python tutorials `. + The Wide and Deep models is a combination of wide and deep parts for memorization and generalization of object features respectively. These models can contain different types of object features such as numerical, categorical, sparse and sequential features. These feature types are specified through Tensorflow tf.feature_column API. Table below presents what feature types are supported by the OpenVINO toolkit. diff --git a/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/convert_model_tutorials/Convert_XLNet_From_Tensorflow.rst b/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/convert_model_tutorials/Convert_XLNet_From_Tensorflow.rst index cbabde8ff6cc40..2d23feca2ded5b 100644 --- a/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/convert_model_tutorials/Convert_XLNet_From_Tensorflow.rst +++ b/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/convert_model_tutorials/Convert_XLNet_From_Tensorflow.rst @@ -8,7 +8,12 @@ Converting a TensorFlow XLNet Model :description: Learn how to convert an XLNet model from TensorFlow to the OpenVINO Intermediate Representation. +.. danger:: + The code described here has been **deprecated!** Do not use it to avoid working with a legacy solution. It will be kept for some time to ensure backwards compatibility, but **you should not use** it in contemporary applications. + + This guide describes a deprecated conversion method. The guide on the new and recommended method can be found in the :doc:`Python tutorials `. + Pretrained models for XLNet (Bidirectional Encoder Representations from Transformers) are `publicly available `__. diff --git a/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/convert_model_tutorials/Convert_YOLACT.rst b/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/convert_model_tutorials/Convert_YOLACT.rst index 53f212c27e1f2f..23495f299f8e65 100644 --- a/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/convert_model_tutorials/Convert_YOLACT.rst +++ b/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/convert_model_tutorials/Convert_YOLACT.rst @@ -9,6 +9,12 @@ Converting a PyTorch YOLACT Model from PyTorch to the OpenVINO Intermediate Representation. +.. danger:: + + The code described here has been **deprecated!** Do not use it to avoid working with a legacy solution. It will be kept for some time to ensure backwards compatibility, but **you should not use** it in contemporary applications. + + This guide describes a deprecated conversion method. The guide on the new and recommended method can be found in the :doc:`Python tutorials `. + You Only Look At CoefficienTs (YOLACT) is a simple, fully convolutional model for real-time instance segmentation. The PyTorch implementation is publicly available in `this GitHub repository `__. The YOLACT++ model is not supported, because it uses deformable convolutional layers that cannot be represented in ONNX format. diff --git a/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/convert_model_tutorials/Convert_YOLO_From_Tensorflow.rst b/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/convert_model_tutorials/Convert_YOLO_From_Tensorflow.rst index d2e3b4d919c531..a2273e68505ff6 100644 --- a/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/convert_model_tutorials/Convert_YOLO_From_Tensorflow.rst +++ b/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/convert_model_tutorials/Convert_YOLO_From_Tensorflow.rst @@ -8,6 +8,11 @@ Converting TensorFlow YOLO Models :description: Learn how to convert YOLO models from TensorFlow to the OpenVINO Intermediate Representation. +.. danger:: + + The code described here has been **deprecated!** Do not use it to avoid working with a legacy solution. It will be kept for some time to ensure backwards compatibility, but **you should not use** it in contemporary applications. + + This guide describes a deprecated conversion method. The guide on the new and recommended method can be found in the :doc:`Python tutorials `. This document explains how to convert real-time object detection YOLOv1, YOLOv2, YOLOv3 and YOLOv4 public models to the Intermediate Representation (IR). All YOLO models are originally implemented in the DarkNet framework and consist of two files: diff --git a/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/convert_model_tutorials/Convert_lm_1b_From_Tensorflow.rst b/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/convert_model_tutorials/Convert_lm_1b_From_Tensorflow.rst index a7d348ea304d1d..b4dec76b524353 100644 --- a/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/convert_model_tutorials/Convert_lm_1b_From_Tensorflow.rst +++ b/docs/articles_en/documentation/openvino_legacy_features/mo_ovc_transition/legacy_conversion_api/supported_model_formats/convert_model_tutorials/Convert_lm_1b_From_Tensorflow.rst @@ -9,7 +9,12 @@ Converting a TensorFlow Language Model on One Billion Word Benchmark Model on One Billion Word Benchmark to the OpenVINO Intermediate Representation. +.. danger:: + The code described here has been **deprecated!** Do not use it to avoid working with a legacy solution. It will be kept for some time to ensure backwards compatibility, but **you should not use** it in contemporary applications. + + This guide describes a deprecated conversion method. The guide on the new and recommended method can be found in the :doc:`Python tutorials `. + Downloading a Pre-trained Language Model on One Billion Word Benchmark ###################################################################### diff --git a/docs/articles_en/documentation/openvino_legacy_features/post_training_optimization_tool.rst b/docs/articles_en/documentation/openvino_legacy_features/post_training_optimization_tool.rst index 234f6dca2493e6..840a53b5c237b6 100644 --- a/docs/articles_en/documentation/openvino_legacy_features/post_training_optimization_tool.rst +++ b/docs/articles_en/documentation/openvino_legacy_features/post_training_optimization_tool.rst @@ -1,6 +1,6 @@ .. {#pot_introduction} -(Deprecated) Post-training Quantization with POT +[Deprecated] Post-training Quantization with POT ================================================ @@ -14,15 +14,15 @@ API Reference Command-line Interface Examples - pot_docs_FrequentlyAskedQuestions + Post-training Optimization Tool FAQ (Experimental) Protecting Model -.. note:: Post-training Optimization Tool is deprecated since OpenVINO 2023.0. :doc:`Neural Network Compression Framework (NNCF) ` is recommended for the post-training quantization instead. +.. danger:: Post-training Optimization Tool is deprecated since OpenVINO 2023.0. :doc:`Neural Network Compression Framework (NNCF) ` is recommended for the post-training quantization instead. -For the needs of post-training optimization, OpenVINO™ provides a **Post-training Optimization Tool (POT)** +For the needs of post-training optimization, OpenVINO provides a **Post-training Optimization Tool (POT)** which supports the **uniform integer quantization** method. This method allows moving from floating-point precision to integer precision (for example, 8-bit) for weights and activations during inference time. It helps to reduce the model size, memory footprint and latency, as well as improve the computational efficiency, using integer arithmetic. diff --git a/docs/articles_en/documentation/openvino_legacy_features/post_training_optimization_tool/pot_api_reference.rst b/docs/articles_en/documentation/openvino_legacy_features/post_training_optimization_tool/pot_api_reference.rst index a837398e652f08..bbbf724b0431f3 100644 --- a/docs/articles_en/documentation/openvino_legacy_features/post_training_optimization_tool/pot_api_reference.rst +++ b/docs/articles_en/documentation/openvino_legacy_features/post_training_optimization_tool/pot_api_reference.rst @@ -1,7 +1,9 @@ .. {#pot_compression_api_README} -API Reference -============= +[Deprecated] API Reference +================================= + +.. danger:: Post-training Optimization Tool is deprecated since OpenVINO 2023.0. :doc:`Neural Network Compression Framework (NNCF) ` is recommended for the post-training quantization instead. Post-training Optimization Tool API provides a full set of interfaces and helpers that allow users to implement a custom optimization pipeline for various types of DL models including cascaded or compound models. Below is a full specification of this API: diff --git a/docs/articles_en/documentation/openvino_legacy_features/post_training_optimization_tool/pot_cli.rst b/docs/articles_en/documentation/openvino_legacy_features/post_training_optimization_tool/pot_cli.rst index a0b2887536bb90..d893a683b2d841 100644 --- a/docs/articles_en/documentation/openvino_legacy_features/post_training_optimization_tool/pot_cli.rst +++ b/docs/articles_en/documentation/openvino_legacy_features/post_training_optimization_tool/pot_cli.rst @@ -1,7 +1,7 @@ .. {#pot_compression_cli_README} -Use Post-Training Optimization Tool Command-Line Interface (Model Zoo flow) -=========================================================================== +[Deprecated] Use Post-Training Optimization Tool Command-Line Interface (Model Zoo flow) +==================================================================================================== .. toctree:: @@ -9,9 +9,10 @@ Use Post-Training Optimization Tool Command-Line Interface (Model Zoo flow) :hidden: Simplified Mode - pot_configs_README + Configuration File Description +.. danger:: Post-training Optimization Tool is deprecated since OpenVINO 2023.0. :doc:`Neural Network Compression Framework (NNCF) ` is recommended for the post-training quantization instead. Introduction #################### diff --git a/docs/articles_en/documentation/openvino_legacy_features/post_training_optimization_tool/pot_cli/configuration_file_description.rst b/docs/articles_en/documentation/openvino_legacy_features/post_training_optimization_tool/pot_cli/configuration_file_description.rst index 4f0729fb4d6759..d4f41bc14e1397 100644 --- a/docs/articles_en/documentation/openvino_legacy_features/post_training_optimization_tool/pot_cli/configuration_file_description.rst +++ b/docs/articles_en/documentation/openvino_legacy_features/post_training_optimization_tool/pot_cli/configuration_file_description.rst @@ -1,7 +1,9 @@ .. {#pot_configs_README} -Configuration File Description -============================== +[Deprecated] Configuration File Description +============================================== + +.. danger:: Post-training Optimization Tool is deprecated since OpenVINO 2023.0. :doc:`Neural Network Compression Framework (NNCF) ` is recommended for the post-training quantization instead. The tool is designed to work with the configuration file where all the parameters required for the optimization are specified. These parameters are organized as a dictionary and stored in diff --git a/docs/articles_en/documentation/openvino_legacy_features/post_training_optimization_tool/pot_cli/simplified_mode.rst b/docs/articles_en/documentation/openvino_legacy_features/post_training_optimization_tool/pot_cli/simplified_mode.rst index a7b9465aaab859..de5fccd0af7b54 100644 --- a/docs/articles_en/documentation/openvino_legacy_features/post_training_optimization_tool/pot_cli/simplified_mode.rst +++ b/docs/articles_en/documentation/openvino_legacy_features/post_training_optimization_tool/pot_cli/simplified_mode.rst @@ -1,7 +1,9 @@ .. {#pot_docs_simplified_mode} -Optimization with Simplified Mode -================================= +[Deprecated] Optimization with Simplified Mode +==================================================== + +.. danger:: Post-training Optimization Tool is deprecated since OpenVINO 2023.0. :doc:`Neural Network Compression Framework (NNCF) ` is recommended for the post-training quantization instead. Introduction diff --git a/docs/articles_en/documentation/openvino_legacy_features/post_training_optimization_tool/pot_examples.rst b/docs/articles_en/documentation/openvino_legacy_features/post_training_optimization_tool/pot_examples.rst index 0693a9bdf49383..8d0cb6f0444c46 100644 --- a/docs/articles_en/documentation/openvino_legacy_features/post_training_optimization_tool/pot_examples.rst +++ b/docs/articles_en/documentation/openvino_legacy_features/post_training_optimization_tool/pot_examples.rst @@ -1,7 +1,7 @@ .. {#pot_examples_description} -Examples -======== +[Deprecated] Examples +======================== .. toctree:: @@ -11,6 +11,7 @@ Examples API Examples Command-line Example +.. danger:: Post-training Optimization Tool is deprecated since OpenVINO 2023.0. :doc:`Neural Network Compression Framework (NNCF) ` is recommended for the post-training quantization instead. This section provides a set of examples that demonstrate how to apply the post-training optimization methods to optimize various models from different domains. It contains optimization recipes for concrete models, that unnecessarily cover your case, but which should be sufficient to reuse these recipes to optimize custom models: diff --git a/docs/articles_en/documentation/openvino_legacy_features/post_training_optimization_tool/pot_examples/pot_api_examples.rst b/docs/articles_en/documentation/openvino_legacy_features/post_training_optimization_tool/pot_examples/pot_api_examples.rst index 19cb0616e32767..f4eea83bed5b07 100644 --- a/docs/articles_en/documentation/openvino_legacy_features/post_training_optimization_tool/pot_examples/pot_api_examples.rst +++ b/docs/articles_en/documentation/openvino_legacy_features/post_training_optimization_tool/pot_examples/pot_api_examples.rst @@ -1,7 +1,7 @@ .. {#pot_example_README} -Post-training Optimization Tool API Examples -============================================ +[Deprecated] Post-training Optimization Tool API Examples +=============================================================== .. toctree:: @@ -15,6 +15,8 @@ Post-training Optimization Tool API Examples Quantizing 3D Segmentation Model Quantizing for GNA Device +.. danger:: Post-training Optimization Tool is deprecated since OpenVINO 2023.0. :doc:`Neural Network Compression Framework (NNCF) ` is recommended for the post-training quantization instead. + The Post-training Optimization Tool contains multiple examples that demonstrate how to use its :doc:`API ` to optimize DL models. All available examples can be found on `GitHub `__. diff --git a/docs/articles_en/documentation/openvino_legacy_features/post_training_optimization_tool/pot_examples/pot_api_examples/pot_example_3d_segmentation.rst b/docs/articles_en/documentation/openvino_legacy_features/post_training_optimization_tool/pot_examples/pot_api_examples/pot_example_3d_segmentation.rst index 7217d51314210e..a80701ad9c54aa 100644 --- a/docs/articles_en/documentation/openvino_legacy_features/post_training_optimization_tool/pot_examples/pot_api_examples/pot_example_3d_segmentation.rst +++ b/docs/articles_en/documentation/openvino_legacy_features/post_training_optimization_tool/pot_examples/pot_api_examples/pot_example_3d_segmentation.rst @@ -1,7 +1,9 @@ .. {#pot_example_3d_segmentation_README} -Quantizing 3D Segmentation Model -================================ +[Deprecated] Quantizing 3D Segmentation Model +================================================================ + +.. danger:: Post-training Optimization Tool is deprecated since OpenVINO 2023.0. :doc:`Neural Network Compression Framework (NNCF) ` is recommended for the post-training quantization instead. This example demonstrates the use of the :doc:`Post-training Optimization Tool API ` for the task of quantizing a 3D segmentation model. diff --git a/docs/articles_en/documentation/openvino_legacy_features/post_training_optimization_tool/pot_examples/pot_api_examples/pot_example_classification.rst b/docs/articles_en/documentation/openvino_legacy_features/post_training_optimization_tool/pot_examples/pot_api_examples/pot_example_classification.rst index fe7f79a8c3177b..6bf8d2ec310447 100644 --- a/docs/articles_en/documentation/openvino_legacy_features/post_training_optimization_tool/pot_examples/pot_api_examples/pot_example_classification.rst +++ b/docs/articles_en/documentation/openvino_legacy_features/post_training_optimization_tool/pot_examples/pot_api_examples/pot_example_classification.rst @@ -1,7 +1,9 @@ .. {#pot_example_classification_README} -Quantizing Image Classification Model -===================================== +[Deprecated] Quantizing Image Classification Model +======================================================== + +.. danger:: Post-training Optimization Tool is deprecated since OpenVINO 2023.0. :doc:`Neural Network Compression Framework (NNCF) ` is recommended for the post-training quantization instead. This example demonstrates the use of the :doc:`Post-training Optimization Tool API ` for the task of quantizing a classification model. diff --git a/docs/articles_en/documentation/openvino_legacy_features/post_training_optimization_tool/pot_examples/pot_api_examples/pot_example_face_detection.rst b/docs/articles_en/documentation/openvino_legacy_features/post_training_optimization_tool/pot_examples/pot_api_examples/pot_example_face_detection.rst index 587f7f6e2bc541..2f3964bbcd44e9 100644 --- a/docs/articles_en/documentation/openvino_legacy_features/post_training_optimization_tool/pot_examples/pot_api_examples/pot_example_face_detection.rst +++ b/docs/articles_en/documentation/openvino_legacy_features/post_training_optimization_tool/pot_examples/pot_api_examples/pot_example_face_detection.rst @@ -1,7 +1,9 @@ .. {#pot_example_face_detection_README} -Quantizing Cascaded Face detection Model -======================================== +[Deprecated] Quantizing Cascaded Face detection Model +============================================================ + +.. danger:: Post-training Optimization Tool is deprecated since OpenVINO 2023.0. :doc:`Neural Network Compression Framework (NNCF) ` is recommended for the post-training quantization instead. This example demonstrates the use of the :doc:`Post-training Optimization Tool API ` for the task of quantizing a face detection model. diff --git a/docs/articles_en/documentation/openvino_legacy_features/post_training_optimization_tool/pot_examples/pot_api_examples/pot_example_object_detection.rst b/docs/articles_en/documentation/openvino_legacy_features/post_training_optimization_tool/pot_examples/pot_api_examples/pot_example_object_detection.rst index ce158f201956cc..860d60058d1ba5 100644 --- a/docs/articles_en/documentation/openvino_legacy_features/post_training_optimization_tool/pot_examples/pot_api_examples/pot_example_object_detection.rst +++ b/docs/articles_en/documentation/openvino_legacy_features/post_training_optimization_tool/pot_examples/pot_api_examples/pot_example_object_detection.rst @@ -1,7 +1,9 @@ .. {#pot_example_object_detection_README} -Quantizing Object Detection Model with Accuracy Control -======================================================= +[Deprecated] Quantizing Object Detection Model with Accuracy Control +================================================================================ + +.. danger:: Post-training Optimization Tool is deprecated since OpenVINO 2023.0. :doc:`Neural Network Compression Framework (NNCF) ` is recommended for the post-training quantization instead. This example demonstrates the use of the :doc:`Post-training Optimization Toolkit API ` to quantize an object detection model in the :doc:`accuracy-aware mode `. The `MobileNetV1 FPN `__ model from TensorFlow for object detection task is used for this purpose. A custom ``DataLoader`` is created to load the `COCO `__ dataset for object detection task and the implementation of mAP COCO is used for the model evaluation. The code of the example is available on `GitHub `__. diff --git a/docs/articles_en/documentation/openvino_legacy_features/post_training_optimization_tool/pot_examples/pot_api_examples/pot_example_segmentation.rst b/docs/articles_en/documentation/openvino_legacy_features/post_training_optimization_tool/pot_examples/pot_api_examples/pot_example_segmentation.rst index 5b13e99ec098db..5c6cf59696203f 100644 --- a/docs/articles_en/documentation/openvino_legacy_features/post_training_optimization_tool/pot_examples/pot_api_examples/pot_example_segmentation.rst +++ b/docs/articles_en/documentation/openvino_legacy_features/post_training_optimization_tool/pot_examples/pot_api_examples/pot_example_segmentation.rst @@ -1,7 +1,9 @@ .. {#pot_example_segmentation_README} -Quantizing Semantic Segmentation Model -====================================== +[Deprecated] Quantizing Semantic Segmentation Model +============================================================= + +.. danger:: Post-training Optimization Tool is deprecated since OpenVINO 2023.0. :doc:`Neural Network Compression Framework (NNCF) ` is recommended for the post-training quantization instead. This example demonstrates the use of the :doc:`Post-training Optimization Tool API ` for the task of quantizing a segmentation model. diff --git a/docs/articles_en/documentation/openvino_legacy_features/post_training_optimization_tool/pot_examples/pot_api_examples/pot_example_speech.rst b/docs/articles_en/documentation/openvino_legacy_features/post_training_optimization_tool/pot_examples/pot_api_examples/pot_example_speech.rst index 6ac3962c283954..56f153b46652c2 100644 --- a/docs/articles_en/documentation/openvino_legacy_features/post_training_optimization_tool/pot_examples/pot_api_examples/pot_example_speech.rst +++ b/docs/articles_en/documentation/openvino_legacy_features/post_training_optimization_tool/pot_examples/pot_api_examples/pot_example_speech.rst @@ -1,7 +1,9 @@ .. {#pot_example_speech_README} -Quantizing for GNA Device -========================= +[Deprecated] Quantizing for GNA Device +========================================= + +.. danger:: Post-training Optimization Tool is deprecated since OpenVINO 2023.0. :doc:`Neural Network Compression Framework (NNCF) ` is recommended for the post-training quantization instead. This example demonstrates the use of the :doc:`Post-training Optimization Tool API ` for the task of quantizing a speech model for :doc:`GNA ` device. Quantization for GNA is different from CPU quantization due to device specifics: GNA supports quantized inputs in INT16 and INT32 (for activations) precision and quantized weights in INT8 and INT16 precision. diff --git a/docs/articles_en/documentation/openvino_legacy_features/post_training_optimization_tool/pot_examples/pot_cli_example.rst b/docs/articles_en/documentation/openvino_legacy_features/post_training_optimization_tool/pot_examples/pot_cli_example.rst index 7d0e016647f39a..c5fd319d988ef2 100644 --- a/docs/articles_en/documentation/openvino_legacy_features/post_training_optimization_tool/pot_examples/pot_cli_example.rst +++ b/docs/articles_en/documentation/openvino_legacy_features/post_training_optimization_tool/pot_examples/pot_cli_example.rst @@ -1,7 +1,9 @@ .. {#pot_configs_examples_README} -End-to-end Command-line Interface Example -========================================= +[Deprecated] End-to-end Command-line Interface Example +========================================================= + +.. danger:: Post-training Optimization Tool is deprecated since OpenVINO 2023.0. :doc:`Neural Network Compression Framework (NNCF) ` is recommended for the post-training quantization instead. This tutorial describes an example of running post-training quantization for the **MobileNet v2 model from PyTorch** framework, diff --git a/docs/articles_en/documentation/openvino_legacy_features/post_training_optimization_tool/pot_faq.rst b/docs/articles_en/documentation/openvino_legacy_features/post_training_optimization_tool/pot_faq.rst index bfc2f0276fb172..5a495d77c63334 100644 --- a/docs/articles_en/documentation/openvino_legacy_features/post_training_optimization_tool/pot_faq.rst +++ b/docs/articles_en/documentation/openvino_legacy_features/post_training_optimization_tool/pot_faq.rst @@ -1,10 +1,10 @@ .. {#pot_docs_FrequentlyAskedQuestions} -Post-training Optimization Tool FAQ -=================================== +[Deprecated] Post-training Optimization Tool FAQ +=========================================================== -.. note:: +.. danger:: Post-training Optimization Tool has been deprecated since OpenVINO 2023.0. :doc:`Neural Network Compression Framework (NNCF) ` is recommended for post-training quantization instead. diff --git a/docs/articles_en/documentation/openvino_legacy_features/post_training_optimization_tool/protecting_model.rst b/docs/articles_en/documentation/openvino_legacy_features/post_training_optimization_tool/protecting_model.rst index 9ce1b2bf0ceea7..1eeeddfe0a293e 100644 --- a/docs/articles_en/documentation/openvino_legacy_features/post_training_optimization_tool/protecting_model.rst +++ b/docs/articles_en/documentation/openvino_legacy_features/post_training_optimization_tool/protecting_model.rst @@ -1,8 +1,12 @@ .. {#pot_ranger_README} -Experimental: Protecting Deep Learning Model through Range Supervision ("RangeSupervision") -=========================================================================================== +[Deprecated] Experimental: Protecting Deep Learning Model through Range Supervision ("RangeSupervision") +================================================================================================================ +.. danger:: + + Post-training Optimization Tool has been deprecated since OpenVINO 2023.0. + :doc:`Neural Network Compression Framework (NNCF) ` is recommended for post-training quantization instead. Introduction #################### diff --git a/docs/articles_en/documentation/openvino_legacy_features/post_training_optimization_tool/quantization_best_practices.rst b/docs/articles_en/documentation/openvino_legacy_features/post_training_optimization_tool/quantization_best_practices.rst index a2b31b35fc85d9..f5f4e3d08ec255 100644 --- a/docs/articles_en/documentation/openvino_legacy_features/post_training_optimization_tool/quantization_best_practices.rst +++ b/docs/articles_en/documentation/openvino_legacy_features/post_training_optimization_tool/quantization_best_practices.rst @@ -1,7 +1,7 @@ .. {#pot_docs_BestPractices} -Post-Training Quantization Best Practices -========================================= +[Deprecated] Post-Training Quantization Best Practices +======================================================== .. toctree:: @@ -10,6 +10,7 @@ Post-Training Quantization Best Practices Saturation Issue +.. danger:: Post-training Optimization Tool is deprecated since OpenVINO 2023.0. :doc:`Neural Network Compression Framework (NNCF) ` is recommended for the post-training quantization instead. The :doc:`Default Quantization ` of the Post-training Optimization Tool (POT) is the fastest and easiest way to get a quantized model. It requires only some unannotated representative dataset to be provided in most cases. Therefore, it is recommended to use it as a starting point when it comes to model optimization. However, it can lead to significant accuracy deviation in some cases. The purpose of this article is to provide tips to address this issue. diff --git a/docs/articles_en/documentation/openvino_legacy_features/post_training_optimization_tool/quantization_best_practices/saturation_issue.rst b/docs/articles_en/documentation/openvino_legacy_features/post_training_optimization_tool/quantization_best_practices/saturation_issue.rst index d78a29ed03e817..369adc5b981869 100644 --- a/docs/articles_en/documentation/openvino_legacy_features/post_training_optimization_tool/quantization_best_practices/saturation_issue.rst +++ b/docs/articles_en/documentation/openvino_legacy_features/post_training_optimization_tool/quantization_best_practices/saturation_issue.rst @@ -1,7 +1,9 @@ .. {#pot_saturation_issue} -Saturation (overflow) Issue Workaround -====================================== +[Deprecated] Saturation (overflow) Issue Workaround +======================================================= + +.. danger:: Post-training Optimization Tool is deprecated since OpenVINO 2023.0. :doc:`Neural Network Compression Framework (NNCF) ` is recommended for the post-training quantization instead. Introduction diff --git a/docs/articles_en/documentation/openvino_legacy_features/post_training_optimization_tool/quantizing_models.rst b/docs/articles_en/documentation/openvino_legacy_features/post_training_optimization_tool/quantizing_models.rst index 9005f296d585ad..48bfb24fe9ce66 100644 --- a/docs/articles_en/documentation/openvino_legacy_features/post_training_optimization_tool/quantizing_models.rst +++ b/docs/articles_en/documentation/openvino_legacy_features/post_training_optimization_tool/quantizing_models.rst @@ -1,7 +1,7 @@ .. {#pot_default_quantization_usage} -Quantizing Models -================= +[Deprecated] Quantizing Models +====================================== @@ -12,6 +12,8 @@ Quantizing Models DefaultQuantization Method +.. danger:: Post-training Optimization Tool is deprecated since OpenVINO 2023.0. :doc:`Neural Network Compression Framework (NNCF) ` is recommended for the post-training quantization instead. + This guide describes how to apply model quantization with the Default Quantization method without accuracy control, using an unannotated dataset. To use this method, create a Python script using an API of Post-Training Optimization Tool (POT) and implement data preparation logic and quantization pipeline. If you are not familiar with Python, try :doc:`command-line interface ` of POT which is designed to quantize models from diff --git a/docs/articles_en/documentation/openvino_legacy_features/post_training_optimization_tool/quantizing_models/default_quantization_algorithm.rst b/docs/articles_en/documentation/openvino_legacy_features/post_training_optimization_tool/quantizing_models/default_quantization_algorithm.rst index 20793e7e8f8290..78c5f34df09f02 100644 --- a/docs/articles_en/documentation/openvino_legacy_features/post_training_optimization_tool/quantizing_models/default_quantization_algorithm.rst +++ b/docs/articles_en/documentation/openvino_legacy_features/post_training_optimization_tool/quantizing_models/default_quantization_algorithm.rst @@ -1,7 +1,9 @@ .. {#pot_compression_algorithms_quantization_default_README} -DefaultQuantization Parameters -============================== +[Deprecated] DefaultQuantization Parameters +======================================================== + +.. danger:: Post-training Optimization Tool is deprecated since OpenVINO 2023.0. :doc:`Neural Network Compression Framework (NNCF) ` is recommended for the post-training quantization instead. The DefaultQuantization Algorithm is designed to perform fast and accurate quantization. It does not offer direct control over the accuracy metric itself but provides many options that can be used to improve it. diff --git a/docs/articles_en/documentation/openvino_legacy_features/post_training_optimization_tool/quantizing_models_with_accuracy.rst b/docs/articles_en/documentation/openvino_legacy_features/post_training_optimization_tool/quantizing_models_with_accuracy.rst index 679394d6a53559..0cac04e0e61d77 100644 --- a/docs/articles_en/documentation/openvino_legacy_features/post_training_optimization_tool/quantizing_models_with_accuracy.rst +++ b/docs/articles_en/documentation/openvino_legacy_features/post_training_optimization_tool/quantizing_models_with_accuracy.rst @@ -1,7 +1,7 @@ .. {#pot_accuracyaware_usage} -Quantizing Models with Accuracy Control -======================================= +[Deprecated] Quantizing Models with Accuracy Control +================================================================ .. toctree:: @@ -10,6 +10,7 @@ Quantizing Models with Accuracy Control AccuracyAwareQuantization Method +.. danger:: Post-training Optimization Tool is deprecated since OpenVINO 2023.0. :doc:`Neural Network Compression Framework (NNCF) ` is recommended for the post-training quantization instead. The Accuracy-aware Quantization algorithm allows performing quantization while maintaining accuracy within a pre-defined range. Note that it should be used only if the :doc:`Default Quantization ` introduces a significant accuracy degradation. The reason for it not being the primary choice is its potential for performance degradation, due to some layers getting reverted to the original precision. diff --git a/docs/articles_en/documentation/openvino_legacy_features/post_training_optimization_tool/quantizing_models_with_accuracy/accuracy_aware_algorithm.rst b/docs/articles_en/documentation/openvino_legacy_features/post_training_optimization_tool/quantizing_models_with_accuracy/accuracy_aware_algorithm.rst index f47bf5f8743112..42ba337e79b896 100644 --- a/docs/articles_en/documentation/openvino_legacy_features/post_training_optimization_tool/quantizing_models_with_accuracy/accuracy_aware_algorithm.rst +++ b/docs/articles_en/documentation/openvino_legacy_features/post_training_optimization_tool/quantizing_models_with_accuracy/accuracy_aware_algorithm.rst @@ -1,7 +1,9 @@ .. {#accuracy_aware_README} -AccuracyAwareQuantization Parameters -==================================== +[Deprecated] AccuracyAwareQuantization Parameters +======================================================== + +.. danger:: Post-training Optimization Tool is deprecated since OpenVINO 2023.0. :doc:`Neural Network Compression Framework (NNCF) ` is recommended for the post-training quantization instead. Introduction diff --git a/docs/articles_en/learn_openvino.rst b/docs/articles_en/learn_openvino.rst index db433e93272aed..a8a2a8018b4f43 100644 --- a/docs/articles_en/learn_openvino.rst +++ b/docs/articles_en/learn_openvino.rst @@ -30,6 +30,5 @@ as well as an experienced user. | :doc:`OpenVINO Samples ` | The OpenVINO samples (Python and C++) are simple console applications that show how to use specific OpenVINO API features. They can assist you in executing tasks such as loading a model, running inference, querying particular device capabilities, etc. -| :doc:`OpenVINO™ API 2.0 Transition Guide ` -| With the release of 2022.1 OpenVINO introduced its improved API 2.0 and its new OpenVINO IR model format: IR v11. This tutorial will instruct you on how to adopt the new solution, as well as show you the benefits of the new logic of working with models. - +| :doc:`Optimize and Deploy Generative AI Models ` +| Detailed information on how OpenVINO accelerates Generative AI use cases and what models it supports. This tutorial provides instructions for running Generative AI models using Hugging Face Optimum Intel and Native OpenVINO APIs. diff --git a/docs/articles_en/openvino_workflow/model_optimization_guide.rst b/docs/articles_en/openvino_workflow/model_optimization_guide.rst index 60f861a8ec8a99..c1c2fa48bc0566 100644 --- a/docs/articles_en/openvino_workflow/model_optimization_guide.rst +++ b/docs/articles_en/openvino_workflow/model_optimization_guide.rst @@ -13,7 +13,7 @@ Model Optimization Guide weight_compression -Model optimization is an optional offline step of improving the final model performance and reducing the model size by applying special optimization methods, such as 8-bit quantization, pruning, etc. OpenVINO offers two optimization paths implemented in `Neural Network Compression Framework (NNCF) `__: +Model optimization is an optional offline step of improving the final model performance and reducing the model size by applying special optimization methods, such as 8-bit quantization, pruning, etc. OpenVINO offers three optimization paths implemented in `Neural Network Compression Framework (NNCF) `__: - :doc:`Post-training Quantization ` is designed to optimize the inference of deep learning models by applying the post-training 8-bit integer quantization that does not require model retraining or fine-tuning. diff --git a/docs/documentation_build_instructions.md b/docs/documentation_build_instructions.md index dc0c33a388da35..31759abb9b3b2a 100644 --- a/docs/documentation_build_instructions.md +++ b/docs/documentation_build_instructions.md @@ -1,37 +1,44 @@ -# Build Documentation Using CMake +# Building documentation with CMake -1. Clone submodules: +**NOTE**: Instructions were tested inside container based on Ubuntu 22.04 docker image. + +1. Clone the OpenVINO repository and setup its submodules ``` -cd openvino -git submodule update --init --recursive +$ git clone +$ cd +$ git submodule update --init --recursive ``` -2. Install build dependencies using the `install_build_dependencies.sh` script in the project root folder. +2. Install build dependencies using the `install_build_dependencies.sh` script located in OpenVINO root directory ``` -chmod +x install_build_dependencies.sh -./install_build_dependencies.sh +$ chmod +x install_build_dependencies.sh +$ ./install_build_dependencies.sh ``` - -3. Install [doxyrest](https://github.com/vovkos/doxyrest/releases/tag/doxyrest-2.1.2) and put the `bin` folder in your path - -4. Install python dependencies: - +3. Install additional packages needed to build documentation ``` -python -m pip install -r docs/requirements.txt +$ apt install -y doxygen graphviz texlive ``` - -5. Install the sphinx theme - -6. Create a build folder: - +4. Create python virtualenv and install needed libraries ``` -mkdir build && cd build +$ python3 -m venv env +$ source env/bin/activate +(env) $ pip install -r docs/requirements.txt ``` - -7. Build documentation using these commands: +5. Install the sphinx theme ``` -cmake .. -DENABLE_DOCS=ON -DENABLE_DOCKER=ON +(env) $ cd docs/openvino_sphinx_theme && python setup.py install && cd - +`````` +6. Create build folder: ``` - +(env) $ mkdir build && cd build +``` +7. Build documentation using these commands: ``` -cmake --build . --target sphinx_docs +(env) $ cmake .. -DENABLE_DOCS=ON +(env) $ cmake --build . --target sphinx_docs ``` +Depending on the needs, following variables can be added to first cmake call: +- building C/C++ API: `-DENABLE_CPP_API=ON` +- building Python API: `-DENABLE_PYTHON_API=ON` +- building Notebooks: `-DENABLE_NOTEBOOKS=ON` +- building OMZ: `-DENABLE_OMZ=ON` +- building OVMS: `-DENABLE_OVMS=ON -DOVMS_DOCS_DIR=` diff --git a/docs/snippets/ov_auto.py b/docs/snippets/ov_auto.py index 47d8d877ecda24..d912401e85f453 100644 --- a/docs/snippets/ov_auto.py +++ b/docs/snippets/ov_auto.py @@ -8,6 +8,7 @@ import openvino.properties.device as device import openvino.properties.hint as hints import openvino.properties.streams as streams +import openvino.properties.intel_auto as intel_auto #! [py_ov_property_import_header] import openvino.properties.log as log @@ -96,11 +97,13 @@ def part3(): }, ) # To use the “CUMULATIVE_THROUGHPUT” mode: + # To use the ROUND_ROBIN schedule policy: compiled_model = core.compile_model( model=model, device_name="AUTO", config={ - hints.performance_mode: hints.PerformanceMode.CUMULATIVE_THROUGHPUT + hints.performance_mode: hints.PerformanceMode.CUMULATIVE_THROUGHPUT, + intel_auto.schedule_policy: intel_auto.SchedulePolicy.ROUND_ROBIN }, ) #! [part3] diff --git a/docs/sphinx_setup/api/ie_python_api/api.rst b/docs/sphinx_setup/api/ie_python_api/api.rst index f0f835c51aa35e..50fa863ef6a623 100644 --- a/docs/sphinx_setup/api/ie_python_api/api.rst +++ b/docs/sphinx_setup/api/ie_python_api/api.rst @@ -17,6 +17,12 @@ OpenVINO Python API openvino.runtime.op +.. autosummary:: + :toctree: _autosummary + :template: custom-module-template.rst + + openvino.runtime.op.util + .. autosummary:: :toctree: _autosummary :template: custom-module-template.rst diff --git a/src/bindings/c/src/CMakeLists.txt b/src/bindings/c/src/CMakeLists.txt index edc29574fe1a3b..8d8facf42179a6 100644 --- a/src/bindings/c/src/CMakeLists.txt +++ b/src/bindings/c/src/CMakeLists.txt @@ -52,17 +52,19 @@ ov_cpack_add_component(${OV_CPACK_COMP_CORE_C} HIDDEN) ov_cpack_add_component(${OV_CPACK_COMP_CORE_C_DEV} HIDDEN) install(TARGETS ${TARGET_NAME} EXPORT OpenVINOTargets - RUNTIME DESTINATION ${OV_CPACK_RUNTIMEDIR} COMPONENT ${OV_CPACK_COMP_CORE_C} - ARCHIVE DESTINATION ${OV_CPACK_ARCHIVEDIR} COMPONENT ${OV_CPACK_COMP_CORE_C} - LIBRARY DESTINATION ${OV_CPACK_LIBRARYDIR} COMPONENT ${OV_CPACK_COMP_CORE_C} + RUNTIME DESTINATION ${OV_CPACK_RUNTIMEDIR} COMPONENT ${OV_CPACK_COMP_CORE_C} ${OV_CPACK_COMP_CORE_C_EXCLUDE_ALL} + ARCHIVE DESTINATION ${OV_CPACK_ARCHIVEDIR} COMPONENT ${OV_CPACK_COMP_CORE_C} ${OV_CPACK_COMP_CORE_C_EXCLUDE_ALL} + LIBRARY DESTINATION ${OV_CPACK_LIBRARYDIR} COMPONENT ${OV_CPACK_COMP_CORE_C} ${OV_CPACK_COMP_CORE_C_EXCLUDE_ALL} NAMELINK_COMPONENT ${OV_CPACK_COMP_CORE_C_DEV} INCLUDES DESTINATION ${OV_CPACK_INCLUDEDIR} ${OV_CPACK_INCLUDEDIR}/ie) install(DIRECTORY ${OpenVINO_C_API_SOURCE_DIR}/include/c_api DESTINATION ${OV_CPACK_INCLUDEDIR}/ie - COMPONENT ${OV_CPACK_COMP_CORE_C_DEV}) + COMPONENT ${OV_CPACK_COMP_CORE_C_DEV} + ${OV_CPACK_COMP_CORE_C_DEV_EXCLUDE_ALL}) install(DIRECTORY ${OpenVINO_C_API_SOURCE_DIR}/include/openvino/ DESTINATION ${OV_CPACK_INCLUDEDIR}/openvino - COMPONENT ${OV_CPACK_COMP_CORE_C_DEV}) + COMPONENT ${OV_CPACK_COMP_CORE_C_DEV} + ${OV_CPACK_COMP_CORE_C_DEV_EXCLUDE_ALL}) diff --git a/src/bindings/c/tests/ov_core_test.cpp b/src/bindings/c/tests/ov_core_test.cpp index 90ed036cec32b4..6579c9268418fe 100644 --- a/src/bindings/c/tests/ov_core_test.cpp +++ b/src/bindings/c/tests/ov_core_test.cpp @@ -154,7 +154,12 @@ TEST_P(ov_core_test, ov_core_compile_model) { ov_core_free(core); } +#ifdef OPENVINO_ARCH_ARM64 +// Ticket: 126283 +TEST_P(ov_core_test, DISABLED_ov_core_compile_model_with_property) { +#else TEST_P(ov_core_test, ov_core_compile_model_with_property) { +#endif auto device_name = GetParam(); ov_core_t* core = nullptr; OV_EXPECT_OK(ov_core_create(&core)); 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 5723d06d395592..404601643feadd 100644 --- a/src/bindings/python/src/openvino/frontend/pytorch/ts_decoder.py +++ b/src/bindings/python/src/openvino/frontend/pytorch/ts_decoder.py @@ -7,7 +7,7 @@ from openvino.frontend.pytorch.py_pytorch_frontend import _FrontEndPytorchDecoder as Decoder from openvino.frontend.pytorch.py_pytorch_frontend import _Type as DecoderType from openvino.runtime import op, PartialShape, Type as OVType, OVAny -from openvino.frontend.pytorch.utils import ivalue_to_constant, get_value_from_getattr, pt_to_ov_type_map, prepare_example_inputs_and_model, convert_quantized_tensor +from openvino.frontend.pytorch.utils import ivalue_to_constant, get_value_from_getattr, pt_to_ov_type_map, prepare_example_inputs_and_model, convert_quantized_tensor, graph_has_ops from openvino.runtime import opset11 as ops from openvino.frontend.pytorch import gptq @@ -25,7 +25,8 @@ def __init__(self, pt_module, graph_element=None, example_input=None, alias_db=N self._input_is_list = False if graph_element is None: try: - pt_module = self._get_scripted_model(pt_module, example_input, skip_freeze) + pt_module = self._get_scripted_model( + pt_module, example_input, skip_freeze) except Exception as e: if example_input is not None: msg = "tracing" @@ -56,10 +57,12 @@ def __init__(self, pt_module, graph_element=None, example_input=None, alias_db=N self._input_signature = self._input_signature[:-1] n = len(self._input_signature) for i in range(len(self.raw_inputs) - n): - self._input_signature.append(self.raw_inputs[i + n].debugName()) + self._input_signature.append( + self.raw_inputs[i + n].debugName()) if isinstance(self.graph_element, torch.Graph): - self._transform_tensor_list_constants_to_listconstruct(self.graph_element) + self._transform_tensor_list_constants_to_listconstruct( + self.graph_element) self._transform_optional_constants(self.graph_element) @staticmethod @@ -67,7 +70,7 @@ def _get_preserved_attributes(model) -> list: preserved_attributes = [] for name, module in model.named_modules(): if hasattr(module, "weight"): - if module.weight is not None and getattr(module.weight, "dtype", None) in [torch.int8, torch.uint8]: + if module.weight is not None and getattr(module.weight, "dtype", None) in [torch.int8, torch.uint8, torch.float16, torch.bfloat16]: preserved_attributes.append(name) return preserved_attributes @@ -75,15 +78,18 @@ def _get_scripted_model(self, pt_module, example_inputs=None, skip_freeze=False) import torch import inspect + freeze_by_default = False if isinstance(pt_module, torch.nn.Module): pt_module.eval() input_signature = None if isinstance(pt_module, torch.nn.Module) and not isinstance(pt_module, (torch.jit._trace.TopLevelTracedModule, torch.jit._script.RecursiveScriptModule)): # input params is dictionary contains input names and their signature values (type hints and default values if any) - input_params = inspect.signature(pt_module.forward if hasattr(pt_module, "forward") else pt_module.__call__).parameters + input_params = inspect.signature(pt_module.forward if hasattr( + pt_module, "forward") else pt_module.__call__).parameters input_signature = list(input_params) if example_inputs is None: scripted = torch.jit.script(pt_module) + freeze_by_default = True else: input_parameters, input_signature, pt_module, self._input_is_list = prepare_example_inputs_and_model( example_inputs, input_params, pt_module) @@ -94,8 +100,10 @@ def _get_scripted_model(self, pt_module, example_inputs=None, skip_freeze=False) gptq.patch_model(pt_module) gptq_patched = True except Exception as error: - print('[ WARNING ] Failed patching of AutoGPTQ model. Error message:\n', error) - print('[ WARNING ] Tracing of the model will likely be unsuccesfull or incorrect') + print( + '[ WARNING ] Failed patching of AutoGPTQ model. Error message:\n', error) + print( + '[ WARNING ] Tracing of the model will likely be unsuccessful or incorrect') gptq.unpatch_model(pt_module) gptq_patched = False @@ -106,25 +114,16 @@ def _get_scripted_model(self, pt_module, example_inputs=None, skip_freeze=False) if gptq_patched: gptq.unpatch_model(pt_module) - if not skip_freeze: - ops_kind_no_freeze = ["quantize", "aten::as_strided"] - for n in scripted.inlined_graph.nodes(): - # TODO: switch off freezing for all traced models - if any(kind in n.kind() for kind in ops_kind_no_freeze): - # do not freeze quantized models - skip_freeze = True - break - elif "aten::to" in n.kind(): - first_input = next(n.inputs()) - if first_input.node().kind() == "prim::Constant": - ivalue = first_input.toIValue() - if isinstance(ivalue, torch.Tensor) and ivalue.dtype in [torch.bfloat16, torch.float16]: - # do not freeze models with compressed constants - skip_freeze = True - break - if not skip_freeze: + if not freeze_by_default and graph_has_ops(scripted.inlined_graph, ["prim::Uninitialized", "prim::unchecked_cast", "aten::append"]): + # freeze models with unsupported ops + freeze_by_default = True + if freeze_by_default and graph_has_ops(scripted.inlined_graph, ["quantized", "aten::as_strided"]): + # do not freeze quantized models and can't freeze for aten::as_strided it will result in incorrect inference + freeze_by_default = False + if freeze_by_default and not skip_freeze: preserved_attrs = self._get_preserved_attributes(scripted) - f_model = torch.jit.freeze(scripted, preserved_attrs=preserved_attrs) + f_model = torch.jit.freeze( + scripted, preserved_attrs=preserved_attrs) else: f_model = scripted else: @@ -223,7 +222,8 @@ 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) self.m_decoders.append(decoder) node_visitor(decoder) @@ -233,7 +233,8 @@ def decoder_type_name(self) -> str: def get_subgraphs(self) -> list: if self.graph_element.kind() == "prim::PythonOp": if "Subgraph" in self.graph_element.attributeNames(): - assert isinstance(self.graph_element, torch.Node), "Graph element must be of type torch.Node." + assert isinstance( + self.graph_element, torch.Node), "Graph element must be of type torch.Node." return [getattr(self.graph_element, self.graph_element.kindOf("Subgraph"))("Subgraph")] else: # Attribute "Subgraph" is only available if Graph was created using tracing. @@ -242,12 +243,14 @@ 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 def get_op_type(self) -> str: - assert isinstance(self.graph_element, torch.Node), "Function can be called only when self.graph_element is of type torch.Node" + assert isinstance( + self.graph_element, torch.Node), "Function can be called only when self.graph_element is of type torch.Node" return self.graph_element.kind() def get_schema(self) -> str: @@ -273,7 +276,8 @@ def mark_node(self, node): if "FrameworkNode" not in node.get_type_name(): name += "/" + node.get_type_name() if self.graph_element.scopeName(): - node.set_friendly_name(self.graph_element.scopeName().split("/")[-1] + "/" + name) + node.set_friendly_name( + self.graph_element.scopeName().split("/")[-1] + "/" + name) else: node.set_friendly_name(name) return node @@ -289,17 +293,22 @@ def try_decode_get_attr(self): if isinstance(bias, torch.Tensor): res += ivalue_to_constant(bias) else: - res += ops.convert_like(ivalue_to_constant(torch.zeros(1))[0], res[0]).outputs() + res += ops.convert_like(ivalue_to_constant(torch.zeros(1)) + [0], res[0]).outputs() try: # these params exist only for conv params stride = pt_value.stride() padding = pt_value.padding() dilation = pt_value.dilation() groups = pt_value.groups() - res += ivalue_to_constant(stride, shared_memory=self._shared_memory) - res += ivalue_to_constant(padding, shared_memory=self._shared_memory) - res += ivalue_to_constant(dilation, shared_memory=self._shared_memory) - res += ivalue_to_constant(groups, shared_memory=self._shared_memory) + res += ivalue_to_constant(stride, + shared_memory=self._shared_memory) + res += ivalue_to_constant(padding, + shared_memory=self._shared_memory) + res += ivalue_to_constant(dilation, + shared_memory=self._shared_memory) + res += ivalue_to_constant(groups, + shared_memory=self._shared_memory) except: pass return res @@ -347,7 +356,8 @@ def _as_constant_list(pt_value: torch.Value): return ov_const.outputs() def _get_device_string(self) -> str: - assert self.graph_element.kind() == "prim::device", "This function can be called for prim::device node." + assert self.graph_element.kind( + ) == "prim::device", "This function can be called for prim::device node." value = self.raw_inputs[0] if value.type().isSubtypeOf(torch.TensorType.get()): tensor = typing.cast(torch.TensorType, value.type()) @@ -388,14 +398,16 @@ def inlined_inputs(self, index): def _transform_tensor_list_constants_to_listconstruct(graph: torch.Graph): # Function replaces prim::Constant containing List of Tensors with # prim::ListConstruct containing prim::Constant Tensors. - assert isinstance(graph, torch.Graph), "Function can be called only with parameters of type torch.Graph." + assert isinstance( + graph, torch.Graph), "Function can be called only with parameters of type torch.Graph." for node in graph.nodes(): if node.kind() != "prim::Constant": continue output_type = node.output().type() allowed_types = [ output_type.isSubtypeOf(torch.ListType.ofTensors()), - output_type.isSubtypeOf(torch.ListType(torch.OptionalType.ofTensor())), + output_type.isSubtypeOf(torch.ListType( + torch.OptionalType.ofTensor())), ] if not any(allowed_types): continue @@ -416,7 +428,8 @@ def _transform_tensor_list_constants_to_listconstruct(graph: torch.Graph): def _transform_optional_constants(graph: torch.Graph): # Function replaces prim::Constant containing torch.OptionalType with # prim::Constant containing torch.NoneType or type of IValue. - assert isinstance(graph, torch.Graph), "Function can be called only with parameters of type torch.Graph." + assert isinstance( + graph, torch.Graph), "Function can be called only with parameters of type torch.Graph." for node in graph.nodes(): if node.kind() != "prim::Constant": continue diff --git a/src/bindings/python/src/openvino/frontend/pytorch/utils.py b/src/bindings/python/src/openvino/frontend/pytorch/utils.py index 0901fea81c6c58..eb0f4c1e0b9a4a 100644 --- a/src/bindings/python/src/openvino/frontend/pytorch/utils.py +++ b/src/bindings/python/src/openvino/frontend/pytorch/utils.py @@ -107,6 +107,17 @@ def get_value_from_getattr(getattr_node, self_module): module = getattr(module, attr_name) return module +def graph_has_ops(graph, op_types:list) -> bool: + res = False + for n in graph.nodes(): + if any(kind in n.kind() for kind in op_types): + return True + for b in n.blocks(): + res = graph_has_ops(b, op_types) + if res: + return res + return res + pt_to_ov_type_map = { "float": OVType.f32, diff --git a/src/bindings/python/src/openvino/frontend/tensorflow/utils.py b/src/bindings/python/src/openvino/frontend/tensorflow/utils.py index 298914ffdbd27d..aa99adbffdd2d8 100644 --- a/src/bindings/python/src/openvino/frontend/tensorflow/utils.py +++ b/src/bindings/python/src/openvino/frontend/tensorflow/utils.py @@ -352,7 +352,11 @@ def extract_model_graph(argv): from tensorflow.python.training.tracking.base import Trackable # pylint: disable=no-name-in-module,import-error trackable_is_imported = True except: - log.warning("Could not import tensorflow.python.training.tracking.base.Trackable type.") + try: + from tensorflow.python.trackable.base import Trackable + trackable_is_imported = True + except: + log.warning("Could not import tensorflow.python.training.tracking.base.Trackable type.") env_setup = get_environment_setup("tf") if isinstance(model, tf.Graph): return True diff --git a/src/bindings/python/src/openvino/properties/intel_auto/__init__.py b/src/bindings/python/src/openvino/properties/intel_auto/__init__.py index 2d8a52ac10920f..23486becc306b4 100644 --- a/src/bindings/python/src/openvino/properties/intel_auto/__init__.py +++ b/src/bindings/python/src/openvino/properties/intel_auto/__init__.py @@ -2,7 +2,11 @@ # Copyright (C) 2018-2023 Intel Corporation # SPDX-License-Identifier: Apache-2.0 +# Enums +from openvino._pyopenvino.properties.intel_auto import SchedulePolicy + # Properties import openvino._pyopenvino.properties.intel_auto as __intel_auto from openvino.properties._properties import __make_properties + __make_properties(__intel_auto, __name__) diff --git a/src/bindings/python/src/openvino/runtime/op/__init__.py b/src/bindings/python/src/openvino/runtime/op/__init__.py index 069976998f415c..32ec2e8b909344 100644 --- a/src/bindings/python/src/openvino/runtime/op/__init__.py +++ b/src/bindings/python/src/openvino/runtime/op/__init__.py @@ -8,11 +8,10 @@ # flake8: noqa -import numpy as np - from openvino._pyopenvino.op import Constant from openvino._pyopenvino.op import assign from openvino._pyopenvino.op import Parameter from openvino._pyopenvino.op import if_op from openvino._pyopenvino.op import loop from openvino._pyopenvino.op import tensor_iterator +from openvino._pyopenvino.op import Result diff --git a/src/bindings/python/src/openvino/runtime/opset13/__init__.py b/src/bindings/python/src/openvino/runtime/opset13/__init__.py index 9c544b0d7e775f..1abac3e07a7f2f 100644 --- a/src/bindings/python/src/openvino/runtime/opset13/__init__.py +++ b/src/bindings/python/src/openvino/runtime/opset13/__init__.py @@ -144,7 +144,7 @@ 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.opset1.ops import result +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 diff --git a/src/bindings/python/src/openvino/runtime/opset13/ops.py b/src/bindings/python/src/openvino/runtime/opset13/ops.py index 3fc0828273be99..6d4864c7aa1991 100644 --- a/src/bindings/python/src/openvino/runtime/opset13/ops.py +++ b/src/bindings/python/src/openvino/runtime/opset13/ops.py @@ -11,8 +11,8 @@ log = logging.getLogger(__name__) -from openvino.runtime import Node, Shape, Type -from openvino.runtime.op import Constant +from openvino.runtime import Node, Shape, Type, Output +from openvino.runtime.op import Constant, Result from openvino.runtime.opset_utils import _get_node_factory from openvino.runtime.utils.decorators import binary_op, nameable_op, unary_op from openvino.runtime.utils.types import ( @@ -162,7 +162,7 @@ def multinomial( ) -> Node: """Return a node which generates a sequence of class indices sampled from the multinomial distribution. - :param probs: Tensor with probabilities of floating-point type, and shape [class_size] or [batch_size, class_size]. + :param probs: Tensor with probabilities of floating-point type, and shape [batch_size, class_size]. :param num_samples: Tensor (scalar or 1D) a single element of type i32 or i64, specifying the number of samples to draw from the multinomial distribution. :param convert_type: Specifies the output tensor type, possible values: 'i64', 'i32'. @@ -296,7 +296,9 @@ def constant( _value, _shared_memory = value, shared_memory else: _value, _shared_memory = np.array(value), False - log.warning(f"Converting scalar to corresponding type of {_value.dtype}. Memory sharing is disabled by default.") + if shared_memory: + log.warning(f"Converting scalar to corresponding type of {_value.dtype}. Memory sharing is disabled by default. " + "Set shared_memory=False to hide this warning.") # Handle type casting, when dtype is not None: if dtype: # Expect packed data, use different constructor to handle it correctly: @@ -332,3 +334,15 @@ def constant( _value, _shared_memory = _value.astype(_dtype), False # Create Constant itself: return Constant(_value, shared_memory=_shared_memory) + + +@unary_op +def result(data: Union[Node, Output, NumericData], name: Optional[str] = None) -> Node: + """Return a node which represents an output of a graph (Model). + + :param data: The tensor containing the input data + :return: Result node + """ + if isinstance(data, Node): + return Result(data.output(0)) + return Result(data) diff --git a/src/bindings/python/src/pyopenvino/core/properties/properties.cpp b/src/bindings/python/src/pyopenvino/core/properties/properties.cpp index 2e70b63b5851dd..23e10bedadc72a 100644 --- a/src/bindings/python/src/pyopenvino/core/properties/properties.cpp +++ b/src/bindings/python/src/pyopenvino/core/properties/properties.cpp @@ -282,8 +282,14 @@ void regmodule_properties(py::module m) { py::module m_intel_auto = m_properties.def_submodule("intel_auto", "openvino.runtime.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) + .value("DEVICE_PRIORITY", ov::intel_auto::SchedulePolicy::DEVICE_PRIORITY) + .value("DEFAULT", ov::intel_auto::SchedulePolicy::DEFAULT); wrap_property_RW(m_intel_auto, ov::intel_auto::device_bind_buffer, "device_bind_buffer"); wrap_property_RW(m_intel_auto, ov::intel_auto::enable_startup_fallback, "enable_startup_fallback"); wrap_property_RW(m_intel_auto, ov::intel_auto::enable_runtime_fallback, "enable_runtime_fallback"); + wrap_property_RW(m_intel_auto, ov::intel_auto::schedule_policy, "schedule_policy"); } diff --git a/src/bindings/python/src/pyopenvino/graph/model.cpp b/src/bindings/python/src/pyopenvino/graph/model.cpp index 08c30afd7d217d..374bbe8704eae6 100644 --- a/src/bindings/python/src/pyopenvino/graph/model.cpp +++ b/src/bindings/python/src/pyopenvino/graph/model.cpp @@ -521,48 +521,48 @@ void regclass_graph_Model(py::module m) { R"( Return the model parameters. - :return: ParameterVector containing model parameters. - :rtype: ParameterVector + :return: a list of model's parameters. + :rtype: List[op.Parameter] )"); model.def_property_readonly("parameters", &ov::Model::get_parameters, R"( Return the model parameters. - :return: ParameterVector containing model parameters. - :rtype: ParameterVector + :return: a list of model's parameters. + :rtype: List[op.Parameter] )"); model.def("get_results", &ov::Model::get_results, R"( Return a list of model outputs. - :return: ResultVector containing model parameters. - :rtype: ResultVector - )"); + :return: a list of model's result nodes. + :rtype: List[op.Result] + )"); model.def_property_readonly("results", &ov::Model::get_results, R"( - Return a list of model outputs. + Return a list of model outputs. - :return: ResultVector containing model parameters. - :rtype: ResultVector - )"); + :return: a list of model's result nodes. + :rtype: List[op.Result] + )"); model.def("get_result", &ov::Model::get_result, R"( Return single result. :return: Node object representing result. - :rtype: openvino.runtime.Node - )"); + :rtype: op.Result + )"); model.def_property_readonly("result", &ov::Model::get_result, R"( Return single result. :return: Node object representing result. - :rtype: openvino.runtime.Node + :rtype: op.Result )"); model.def("get_result_index", (int64_t(ov::Model::*)(const ov::Output&) const) & ov::Model::get_result_index, @@ -747,6 +747,7 @@ void regclass_graph_Model(py::module m) { Delete Result node from the list of results. Method will not delete node from graph. :param result: Result node to delete. + :type result: op.Result )"); model.def("remove_parameter", @@ -765,6 +766,7 @@ void regclass_graph_Model(py::module m) { * call graph validation to check all changes :param parameter: Parameter node to delete. + :type parameter: op.Parameter )"); model.def( @@ -785,8 +787,20 @@ void regclass_graph_Model(py::module m) { Delete sink node from the list of sinks. Method doesn't delete node from graph. :param sink: Sink to delete. + :type sink: openvino.runtime.Node )"); + model.def("remove_variable", + &ov::Model::remove_variable, + py::arg("variable"), + R"( + Delete variable from the list of variables. + Method doesn't delete nodes that used this variable from the graph. + + :param variable: Variable to delete. + :type variable: op.util.Variable + )"); + model.def("add_parameters", &ov::Model::add_parameters, py::arg("parameters"), @@ -814,7 +828,7 @@ void regclass_graph_Model(py::module m) { :param results: new Result nodes. :type results: List[op.Result] - )"); + )"); model.def( "add_sinks", @@ -830,13 +844,54 @@ void regclass_graph_Model(py::module m) { }, py::arg("sinks"), R"( - Add new sink nodes to the list. + Add new sink nodes to the list. + + Method doesn't validate graph, it should be done manually after all changes. + + :param sinks: new sink nodes. + :type sinks: List[openvino.runtime.Node] + )"); + + model.def("add_variables", + &ov::Model::add_variables, + py::arg("variables"), + R"( + Add new variables to the list. Method doesn't validate graph, it should be done manually after all changes. - :param sinks: new sink nodes. - :type sinks: List[openvino.runtime.Node] - )"); + :param variables: new variables to add. + :type variables: List[op.util.Variable] + )"); + + model.def("get_variables", + &ov::Model::get_variables, + R"( + Return a list of model's variables. + + :return: a list of model's variables. + :rtype: List[op.util.Variable] + )"); + + model.def_property_readonly("variables", + &ov::Model::get_variables, + R"( + Return a list of model's variables. + + :return: a list of model's variables. + :rtype: List[op.util.Variable] + )"); + + model.def("get_variable_by_id", + &ov::Model::get_variable_by_id, + R"( + Return a variable by specified variable_id. + + :param variable_id: a variable id to get variable node. + :type variable_id: str + :return: a variable node. + :rtype: op.util.Variable + )"); model.def( "get_sinks", @@ -858,10 +913,10 @@ void regclass_graph_Model(py::module m) { return cast_to_node_vector(sinks); }, R"( - Return a list of model outputs. + Return a list of model's sinks. - :return: ResultVector containing model parameters. - :rtype: ResultVector + :return: a list of model's sinks. + :rtype: List[openvino.runtime.Node] )"); model.def( diff --git a/src/bindings/python/src/pyopenvino/graph/ops/if.cpp b/src/bindings/python/src/pyopenvino/graph/ops/if.cpp index ad83891ebaa68a..10453341e38657 100644 --- a/src/bindings/python/src/pyopenvino/graph/ops/if.cpp +++ b/src/bindings/python/src/pyopenvino/graph/ops/if.cpp @@ -115,10 +115,10 @@ void regclass_graph_op_If(py::module m) { Sets new output from the operation associated with results of each sub-graphs. :param then_result: result from then_body. - :type then_result: openvino.runtime.Node + :type then_result: op.Result :param else_result: result from else_body. - :type else_result: openvino.runtime.Node + :type else_result: op.Result :return: output from operation. :rtype: openvino.runtime.Output diff --git a/src/bindings/python/src/pyopenvino/graph/ops/result.cpp b/src/bindings/python/src/pyopenvino/graph/ops/result.cpp index 022982a27999aa..c8576c8ecaf2ab 100644 --- a/src/bindings/python/src/pyopenvino/graph/ops/result.cpp +++ b/src/bindings/python/src/pyopenvino/graph/ops/result.cpp @@ -20,6 +20,8 @@ void regclass_graph_op_Result(py::module m) { result.doc() = "openvino.runtime.op.Result wraps ov::op::v0::Result"; + result.def(py::init&>()); + result.def("get_output_partial_shape", &ov::Node::get_output_partial_shape, py::arg("index")); result.def("get_output_element_type", &ov::Node::get_output_element_type, py::arg("index")); diff --git a/src/bindings/python/src/pyopenvino/utils/utils.cpp b/src/bindings/python/src/pyopenvino/utils/utils.cpp index 232a12e75281ae..2d94ea21f3092e 100644 --- a/src/bindings/python/src/pyopenvino/utils/utils.cpp +++ b/src/bindings/python/src/pyopenvino/utils/utils.cpp @@ -172,6 +172,8 @@ py::object from_ov_any(const ov::Any& any) { return py::cast(any.as()); } else if (any.is()) { return py::cast(any.as()); + } else if (any.is()) { + return py::cast(any.as()); } else if (any.is()) { return py::cast(any.as()); } else if (any.is()) { @@ -357,6 +359,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); } else if (py::isinstance(py_obj)) { return py::cast(py_obj); } else if (py::isinstance(py_obj)) { diff --git a/src/bindings/python/src/pyopenvino/utils/utils.hpp b/src/bindings/python/src/pyopenvino/utils/utils.hpp index e16797f2c6a225..0e7aa6055e0143 100644 --- a/src/bindings/python/src/pyopenvino/utils/utils.hpp +++ b/src/bindings/python/src/pyopenvino/utils/utils.hpp @@ -20,6 +20,7 @@ #include "openvino/core/type/element_type.hpp" #include "openvino/runtime/properties.hpp" +#include "openvino/runtime/auto/properties.hpp" #include "openvino/pass/serialize.hpp" namespace py = pybind11; diff --git a/src/bindings/python/tests/test_graph/__init__.py b/src/bindings/python/tests/test_graph/__init__.py index 3ed608316c2e1a..2949d70c3b3227 100644 --- a/src/bindings/python/tests/test_graph/__init__.py +++ b/src/bindings/python/tests/test_graph/__init__.py @@ -2,6 +2,6 @@ # Copyright (C) 2018-2023 Intel Corporation # SPDX-License-Identifier: Apache-2.0 -# openvino.dll directory path visibility is needed to use _pyngraph module +# openvino.dll directory path visibility is needed to use _pyopenvino module # import below causes adding this path to os.environ["PATH"] import openvino # noqa: F401 'imported but unused' diff --git a/src/bindings/python/tests/test_graph/test_basic.py b/src/bindings/python/tests/test_graph/test_basic.py index b64cb06ae46821..45723c6db7b20c 100644 --- a/src/bindings/python/tests/test_graph/test_basic.py +++ b/src/bindings/python/tests/test_graph/test_basic.py @@ -25,9 +25,10 @@ from openvino._pyopenvino import DescriptorTensor from openvino.runtime.utils.types import get_element_type +from tests.utils.helpers import generate_model_with_memory -def test_graph_function_api(): +def test_graph_api(): shape = [2, 2] parameter_a = ops.parameter(shape, dtype=np.float32, name="A") parameter_b = ops.parameter(shape, dtype=Type.f32, name="B") @@ -39,33 +40,33 @@ def test_graph_function_api(): assert parameter_a.partial_shape == PartialShape([2, 2]) parameter_a.layout = Layout("NC") assert parameter_a.layout == Layout("NC") - function = Model(model, [parameter_a, parameter_b, parameter_c], "TestModel") + model = Model(model, [parameter_a, parameter_b, parameter_c], "TestModel") - function.get_parameters()[1].set_partial_shape(PartialShape([3, 4, 5])) + model.get_parameters()[1].set_partial_shape(PartialShape([3, 4, 5])) - ordered_ops = function.get_ordered_ops() + ordered_ops = model.get_ordered_ops() op_types = [op.get_type_name() for op in ordered_ops] assert op_types == ["Parameter", "Parameter", "Parameter", "Add", "Multiply", "Result"] - assert len(function.get_ops()) == 6 - assert function.get_output_size() == 1 - assert ["A", "B", "C"] == [input.get_node().friendly_name for input in function.inputs] - assert ["Result"] == [output.get_node().get_type_name() for output in function.outputs] - assert function.input(0).get_node().friendly_name == "A" - assert function.output(0).get_node().get_type_name() == "Result" - assert function.input(tensor_name="A").get_node().friendly_name == "A" - assert function.output().get_node().get_type_name() == "Result" - assert function.get_output_op(0).get_type_name() == "Result" - assert function.get_output_element_type(0) == parameter_a.get_element_type() - assert list(function.get_output_shape(0)) == [2, 2] - assert (function.get_parameters()[1].get_partial_shape()) == PartialShape([3, 4, 5]) - assert len(function.get_parameters()) == 3 - results = function.get_results() + assert len(model.get_ops()) == 6 + assert model.get_output_size() == 1 + assert ["A", "B", "C"] == [input.get_node().friendly_name for input in model.inputs] + assert ["Result"] == [output.get_node().get_type_name() for output in model.outputs] + assert model.input(0).get_node().friendly_name == "A" + assert model.output(0).get_node().get_type_name() == "Result" + assert model.input(tensor_name="A").get_node().friendly_name == "A" + assert model.output().get_node().get_type_name() == "Result" + assert model.get_output_op(0).get_type_name() == "Result" + assert model.get_output_element_type(0) == parameter_a.get_element_type() + assert list(model.get_output_shape(0)) == [2, 2] + assert (model.get_parameters()[1].get_partial_shape()) == PartialShape([3, 4, 5]) + assert len(model.get_parameters()) == 3 + results = model.get_results() assert len(results) == 1 assert results[0].get_output_element_type(0) == Type.f32 assert results[0].get_output_partial_shape(0) == PartialShape([2, 2]) results[0].layout = Layout("NC") assert results[0].layout.to_string() == Layout("NC") - assert function.get_friendly_name() == "TestModel" + assert model.get_friendly_name() == "TestModel" @pytest.mark.parametrize( @@ -554,12 +555,7 @@ def test_multiple_outputs(): def test_sink_model_ctor(): - input_data = ops.parameter([2, 2], name="input_data", dtype=np.float32) - rv = ops.read_value(input_data, "var_id_667", np.float32, [2, 2]) - add = ops.add(rv, input_data, name="MemoryAdd") - node = ops.assign(add, "var_id_667") - res = ops.result(add, "res") - model = Model(results=[res], sinks=[node], parameters=[input_data], name="TestModel") + model = generate_model_with_memory(input_shape=[2, 2], data_type=np.float32) ordered_ops = model.get_ordered_ops() op_types = [op.get_type_name() for op in ordered_ops] @@ -570,7 +566,7 @@ def test_sink_model_ctor(): assert len(model.get_ops()) == 5 assert model.get_output_size() == 1 assert model.get_output_op(0).get_type_name() == "Result" - assert model.get_output_element_type(0) == input_data.get_element_type() + assert model.get_output_element_type(0) == model.get_parameters()[0].get_element_type() assert list(model.get_output_shape(0)) == [2, 2] assert (model.get_parameters()[0].get_partial_shape()) == PartialShape([2, 2]) assert len(model.get_parameters()) == 1 diff --git a/src/bindings/python/tests/test_graph/test_core.py b/src/bindings/python/tests/test_graph/test_core.py index 20c9c2bfe57a0a..985cd68284672e 100644 --- a/src/bindings/python/tests/test_graph/test_core.py +++ b/src/bindings/python/tests/test_graph/test_core.py @@ -340,18 +340,18 @@ def test_repr_dynamic_shape(): shape = PartialShape([-1, 2]) parameter_a = ov.parameter(shape, dtype=np.float32, name="A") parameter_b = ov.parameter(shape, dtype=np.float32, name="B") - model = parameter_a + parameter_b - function = Model(model, [parameter_a, parameter_b], "simple_dyn_shapes_graph") + param_sum = parameter_a + parameter_b + model = Model(param_sum, [parameter_a, parameter_b], "simple_dyn_shapes_graph") assert ( - repr(function) + repr(model) == "," + "\n\n]" + "\noutputs[\n\n]>" ) - ops = function.get_ordered_ops() + ops = model.get_ordered_ops() for op in ops: assert "[?,2]" in repr(op) diff --git a/src/bindings/python/tests/test_graph/test_manager.py b/src/bindings/python/tests/test_graph/test_manager.py index 98fe76a0cc0504..95be2a1df2c7ac 100644 --- a/src/bindings/python/tests/test_graph/test_manager.py +++ b/src/bindings/python/tests/test_graph/test_manager.py @@ -1,8 +1,7 @@ +# -*- coding: utf-8 -*- # Copyright (C) 2018-2023 Intel Corporation # SPDX-License-Identifier: Apache-2.0 -# flake8: noqa - import os import numpy as np @@ -15,20 +14,21 @@ from tests.test_graph.util import count_ops_of_type from tests.utils.helpers import create_filename_for_test, compare_models + def create_model(): shape = [100, 100, 2] parameter_a = ops.parameter(shape, dtype=np.float32, name="A") parameter_b = ops.parameter(shape, dtype=np.float32, name="B") parameter_c = ops.parameter(shape, dtype=np.float32, name="C") - model = ops.floor(ops.minimum(ops.abs(parameter_a), ops.multiply(parameter_b, parameter_c))) - func = Model(model, [parameter_a, parameter_b, parameter_c], "Model") - return func + floor_op = ops.floor(ops.minimum(ops.abs(parameter_a), ops.multiply(parameter_b, parameter_c))) + model = Model(floor_op, [parameter_a, parameter_b, parameter_c], "Model") + return model def test_constant_folding(): node_constant = ops.constant(np.array([[0.0, 0.1, -0.1], [-2.5, 2.5, 3.0]], dtype=np.float32)) node_ceil = ops.ceiling(node_constant) - model = Model(node_ceil, [], "TestFunction") + model = Model(node_ceil, [], "TestModel") assert count_ops_of_type(model, node_ceil) == 1 assert count_ops_of_type(model, node_constant) == 1 @@ -40,7 +40,8 @@ def test_constant_folding(): assert count_ops_of_type(model, node_ceil) == 0 assert count_ops_of_type(model, node_constant) == 1 - new_const = model.get_results()[0].input(0).get_source_output().get_node() + result = model.get_results()[0] + new_const = result.input(0).get_source_output().get_node() values_out = new_const.get_vector() values_expected = [0.0, 1.0, 0.0, -2.0, 3.0, 3.0] @@ -48,14 +49,14 @@ def test_constant_folding(): # request - https://docs.pytest.org/en/7.1.x/reference/reference.html#request -@pytest.fixture +@pytest.fixture() def prepare_ir_paths(request, tmp_path): xml_path, bin_path = create_filename_for_test(request.node.name, tmp_path) yield xml_path, bin_path - + # IR Files deletion should be done after `Model` is destructed. - # It may be achieved by splitting scopes (`Model` will be destructed + # It may be achieved by splitting scopes (`Model` will be destructed # just after test scope finished), or by calling `del Model` os.remove(xml_path) os.remove(bin_path) @@ -104,7 +105,7 @@ def test_serialize_separate_paths_args(prepare_ir_paths): def test_serialize_pass_mixed_args_kwargs(prepare_ir_paths): core = Core() - + shape = [3, 2] parameter_a = ops.parameter(shape, dtype=np.float32, name="A") parameter_b = ops.parameter(shape, dtype=np.float32, name="B") @@ -123,7 +124,7 @@ def test_serialize_pass_mixed_args_kwargs(prepare_ir_paths): def test_serialize_pass_mixed_args_kwargs_v2(prepare_ir_paths): core = Core() - + xml_path, bin_path = prepare_ir_paths model = create_model() pass_manager = Manager() @@ -175,7 +176,7 @@ def test_default_version(prepare_ir_paths): assert compare_models(model, res_model) -def test_default_version_IR_V11_separate_paths(prepare_ir_paths): +def test_default_version_ir_v11_separate_paths(prepare_ir_paths): core = Core() xml_path, bin_path = prepare_ir_paths diff --git a/src/bindings/python/tests/test_graph/test_multinomial.py b/src/bindings/python/tests/test_graph/test_multinomial.py index 8ed7fc877b136b..b0da48737c3cea 100644 --- a/src/bindings/python/tests/test_graph/test_multinomial.py +++ b/src/bindings/python/tests/test_graph/test_multinomial.py @@ -13,7 +13,7 @@ ("probs_shape", "num_samples_shape", "convert_type", "with_replacement", "log_probs", "global_seed", "op_seed", "expected_out_shape"), [ ([4, 16], [], "i32", False, True, 7461, 1546, PartialShape([4, -1])), - ([8], [1], "i64", True, False, 0, 0, PartialShape([-1])), + ([1, 8], [1], "i64", True, False, 0, 0, PartialShape([1, -1])), ], ) def test_multinomial_param_inputs(probs_shape, num_samples_shape, convert_type, with_replacement, log_probs, global_seed, op_seed, expected_out_shape): @@ -35,7 +35,7 @@ def test_multinomial_param_inputs(probs_shape, num_samples_shape, convert_type, @pytest.mark.parametrize( ("probs_array", "num_samples_val", "convert_type", "with_replacement", "log_probs", "global_seed", "op_seed", "expected_out_shape"), [ - (np.array([0.7, 0.3, 0.6, 0.5]), 3, "i32", False, True, 111, 222, PartialShape([3])), + (np.array([[0.7, 0.3, 0.6, 0.5]]), 3, "i32", False, True, 111, 222, PartialShape([1, 3])), (np.array([[0.7, 0.3], [0.6, 0.5]]), 2, "i64", True, False, 111, 222, PartialShape([2, 2])), ], ) @@ -59,7 +59,7 @@ def test_multinomial_const_inputs(probs_array, num_samples_val, convert_type, wi @pytest.mark.parametrize( ("probs_shape", "num_samples_shape", "convert_type", "with_replacement", "log_probs", "expected_out_shape"), [ - ([10], [1], "i32", True, True, PartialShape([-1])), + ([1, 10], [1], "i32", True, True, PartialShape([1, -1])), ([2, 16], [], "i64", False, False, PartialShape([2, -1])), ], ) diff --git a/src/bindings/python/tests/test_graph/test_ops.py b/src/bindings/python/tests/test_graph/test_ops.py index 6591cb8f577323..433b798dec0829 100644 --- a/src/bindings/python/tests/test_graph/test_ops.py +++ b/src/bindings/python/tests/test_graph/test_ops.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- # Copyright (C) 2018-2023 Intel Corporation # SPDX-License-Identifier: Apache-2.0 @@ -12,6 +13,7 @@ from openvino.runtime import AxisSet from openvino.runtime.op import Constant, Parameter + @pytest.mark.parametrize(("ov_op", "expected_ov_str", "expected_type"), [ (lambda a, b: a + b, "Add", Type.f32), (ov.add, "Add", Type.f32), @@ -34,9 +36,9 @@ def test_binary_op(ov_op, expected_ov_str, expected_type): element_type = Type.f32 shape = Shape([2, 2]) - A = Parameter(element_type, shape) - B = Parameter(element_type, shape) - node = ov_op(A, B) + param1 = Parameter(element_type, shape) + param2 = Parameter(element_type, shape) + node = ov_op(param1, param2) assert node.get_type_name() == expected_ov_str assert node.get_output_size() == 1 @@ -48,10 +50,10 @@ def test_add_with_mul(): element_type = Type.f32 shape = Shape([4]) - A = Parameter(element_type, shape) - B = Parameter(element_type, shape) - C = Parameter(element_type, shape) - node = ov.multiply(ov.add(A, B), C) + param1 = Parameter(element_type, shape) + param2 = Parameter(element_type, shape) + param3 = Parameter(element_type, shape) + node = ov.multiply(ov.add(param1, param2), param3) assert node.get_type_name() == "Multiply" assert node.get_output_size() == 1 @@ -85,8 +87,8 @@ def test_unary_op(ov_op, expected_ov_str): element_type = Type.f32 shape = Shape([4]) - A = Parameter(element_type, shape) - node = ov_op(A) + param1 = Parameter(element_type, shape) + node = ov_op(param1) assert node.get_type_name() == expected_ov_str assert node.get_output_size() == 1 @@ -97,8 +99,8 @@ def test_unary_op(ov_op, expected_ov_str): def test_reshape(): element_type = Type.f32 shape = Shape([2, 3]) - A = Parameter(element_type, shape) - node = ov.reshape(A, Shape([3, 2]), special_zero=False) + param1 = Parameter(element_type, shape) + node = ov.reshape(param1, Shape([3, 2]), special_zero=False) assert node.get_type_name() == "Reshape" assert node.get_output_size() == 1 @@ -108,8 +110,8 @@ def test_reshape(): def test_broadcast(): element_type = Type.f32 - A = Parameter(element_type, Shape([3])) - node = ov.broadcast(A, [3, 3]) + param1 = Parameter(element_type, Shape([3])) + node = ov.broadcast(param1, [3, 3]) assert node.get_type_name() == "Broadcast" assert node.get_output_size() == 1 assert list(node.get_output_shape(0)) == [3, 3] @@ -134,10 +136,10 @@ def test_constant(const, args, expectation): def test_concat(): element_type = Type.f32 - A = Parameter(element_type, Shape([1, 2])) - B = Parameter(element_type, Shape([1, 2])) - C = Parameter(element_type, Shape([1, 2])) - node = ov.concat([A, B, C], axis=0) + param1 = Parameter(element_type, Shape([1, 2])) + param2 = Parameter(element_type, Shape([1, 2])) + param3 = Parameter(element_type, Shape([1, 2])) + node = ov.concat([param1, param2, param3], axis=0) assert node.get_type_name() == "Concat" assert node.get_output_size() == 1 assert list(node.get_output_shape(0)) == [3, 2] @@ -162,10 +164,10 @@ def test_axisset(): def test_select(): element_type = Type.f32 - A = Parameter(Type.boolean, Shape([1, 2])) - B = Parameter(element_type, Shape([1, 2])) - C = Parameter(element_type, Shape([1, 2])) - node = ov.select(A, B, C) + param1 = Parameter(Type.boolean, Shape([1, 2])) + param2 = Parameter(element_type, Shape([1, 2])) + param3 = Parameter(element_type, Shape([1, 2])) + node = ov.select(param1, param2, param3) assert node.get_type_name() == "Select" assert node.get_output_size() == 1 assert list(node.get_output_shape(0)) == [1, 2] @@ -175,7 +177,7 @@ def test_select(): def test_max_pool_1d(): element_type = Type.f32 shape = Shape([1, 1, 10]) - A = Parameter(element_type, shape) + param1 = Parameter(element_type, shape) window_shape = [3] strides = [1] * len(window_shape) @@ -187,7 +189,7 @@ def test_max_pool_1d(): idx_elem_type = "i32" model = ov.max_pool( - A, + param1, strides, dilations, pads_begin, @@ -204,10 +206,11 @@ def test_max_pool_1d(): assert model.get_output_element_type(0) == element_type assert model.get_output_element_type(1) == Type.i32 + def test_max_pool_1d_with_strides(): element_type = Type.f32 shape = Shape([1, 1, 10]) - A = Parameter(element_type, shape) + param1 = Parameter(element_type, shape) window_shape = [3] strides = [2] pads_begin = [0] * len(window_shape) @@ -218,7 +221,7 @@ def test_max_pool_1d_with_strides(): idx_elem_type = "i32" model = ov.max_pool( - A, + param1, strides, dilations, pads_begin, @@ -236,10 +239,11 @@ def test_max_pool_1d_with_strides(): assert model.get_output_element_type(0) == element_type assert model.get_output_element_type(1) == Type.i32 + def test_max_pool_2d(): element_type = Type.f32 shape = Shape([1, 1, 10, 10]) - A = Parameter(element_type, shape) + param1 = Parameter(element_type, shape) window_shape = [3, 3] rounding_type = "floor" auto_pad = "explicit" @@ -251,7 +255,7 @@ def test_max_pool_2d(): pads_end = [0, 0] model = ov.max_pool( - A, + param1, strides, dilations, pads_begin, @@ -272,7 +276,7 @@ def test_max_pool_2d(): def test_max_pool_2d_with_strides(): element_type = Type.f32 shape = Shape([1, 1, 10, 10]) - A = Parameter(element_type, shape) + param1 = Parameter(element_type, shape) strides = [2, 2] dilations = [1, 1] pads_begin = [0, 0] @@ -283,7 +287,7 @@ def test_max_pool_2d_with_strides(): idx_elem_type = "i32" model = ov.max_pool( - A, + param1, strides, dilations, pads_begin, diff --git a/src/bindings/python/tests/test_graph/test_ops_result.py b/src/bindings/python/tests/test_graph/test_ops_result.py new file mode 100644 index 00000000000000..105ce81849ac86 --- /dev/null +++ b/src/bindings/python/tests/test_graph/test_ops_result.py @@ -0,0 +1,28 @@ +# -*- coding: utf-8 -*- +# Copyright (C) 2018-2023 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import numpy as np + +from openvino import PartialShape, Model, Type +import openvino.runtime.opset13 as ops +from openvino.runtime.op import Result + + +def test_result(): + param = ops.parameter(PartialShape([1]), dtype=np.float32, name="param") + relu1 = ops.relu(param, name="relu1") + result = Result(relu1.output(0)) + assert result.get_output_element_type(0) == Type.f32 + assert result.get_output_partial_shape(0) == PartialShape([1]) + model = Model([result], [param], "test_model") + + result2 = ops.result(relu1, "res2") + model.add_results([result2]) + + results = model.get_results() + assert len(results) == 2 + assert results[1].get_output_element_type(0) == Type.f32 + assert results[1].get_output_partial_shape(0) == PartialShape([1]) + model.remove_result(result) + assert len(model.results) == 1 diff --git a/src/bindings/python/tests/test_graph/test_pad.py b/src/bindings/python/tests/test_graph/test_pad.py index e5d993e59f3746..1a6b96c0c964cb 100644 --- a/src/bindings/python/tests/test_graph/test_pad.py +++ b/src/bindings/python/tests/test_graph/test_pad.py @@ -1,24 +1,18 @@ +# -*- coding: utf-8 -*- # Copyright (C) 2018-2023 Intel Corporation # SPDX-License-Identifier: Apache-2.0 -# flake8: noqa import numpy as np import pytest import openvino.runtime.opset13 as ov -from openvino import Type - - -@pytest.mark.parametrize( - "pad_mode", - [ - "constant", - "edge", - "reflect", - "symmetric", - ] -) +from openvino import Type + + +@pytest.mark.parametrize("pad_mode", [ + "constant", "edge", "reflect", "symmetric", +]) def test_pad_mode(pad_mode): pads_begin = np.array([0, 1], dtype=np.int32) pads_end = np.array([2, 3], dtype=np.int32) @@ -32,13 +26,10 @@ def test_pad_mode(pad_mode): assert model.get_output_element_type(0) == Type.i32 -@pytest.mark.parametrize( - ("pads_begin", "pads_end", "output_shape"), - [ - ([-1, -1], [-1, -1], [1, 2]), - ([2, -1], [-1, 3], [4, 6]), - ] -) +@pytest.mark.parametrize(("pads_begin", "pads_end", "output_shape"), [ + ([-1, -1], [-1, -1], [1, 2]), + ([2, -1], [-1, 3], [4, 6]), +]) def test_pad_being_and_end(pads_begin, pads_end, output_shape): input_param = ov.parameter((3, 4), name="input", dtype=np.int32) model = ov.pad(input_param, pads_begin, pads_end, "constant") diff --git a/src/bindings/python/tests/test_graph/test_preprocess.py b/src/bindings/python/tests/test_graph/test_preprocess.py index fea30eaddcd9b8..6fc302a351e583 100644 --- a/src/bindings/python/tests/test_graph/test_preprocess.py +++ b/src/bindings/python/tests/test_graph/test_preprocess.py @@ -17,17 +17,17 @@ def test_graph_preprocess_mean(): shape = [2, 2] parameter_a = ops.parameter(shape, dtype=np.float32, name="A") model = parameter_a - function = Model(model, [parameter_a], "TestFunction") - ppp = PrePostProcessor(function) + model = Model(model, [parameter_a], "TestModel") + ppp = PrePostProcessor(model) inp = ppp.input() prep = inp.preprocess() prep.mean(1.0) - function = ppp.build() - model_operators = [op.get_name().split("_")[0] for op in function.get_ordered_ops()] + model = ppp.build() + model_operators = [op.get_name().split("_")[0] for op in model.get_ordered_ops()] assert len(model_operators) == 4 - assert function.get_output_size() == 1 - assert list(function.get_output_shape(0)) == [2, 2] - assert function.get_output_element_type(0) == Type.f32 + assert model.get_output_size() == 1 + assert list(model.get_output_shape(0)) == [2, 2] + assert model.get_output_element_type(0) == Type.f32 assert "Constant" in model_operators assert "Subtract" in model_operators @@ -36,19 +36,19 @@ def test_graph_preprocess_mean_vector(): shape = [2, 2] parameter_a = ops.parameter(shape, dtype=np.float32, name="A") model = parameter_a - function = Model(model, [parameter_a], "TestFunction") + model = Model(model, [parameter_a], "TestModel") layout = Layout("NC") - ppp = PrePostProcessor(function) + ppp = PrePostProcessor(model) ppp.input().tensor().set_layout(layout) ppp.input().preprocess().mean([1., 2.]) - function = ppp.build() + model = ppp.build() - model_operators = [op.get_name().split("_")[0] for op in function.get_ordered_ops()] + model_operators = [op.get_name().split("_")[0] for op in model.get_ordered_ops()] assert len(model_operators) == 4 - assert function.get_output_size() == 1 - assert list(function.get_output_shape(0)) == [2, 2] - assert function.get_output_element_type(0) == Type.f32 + assert model.get_output_size() == 1 + assert list(model.get_output_shape(0)) == [2, 2] + assert model.get_output_element_type(0) == Type.f32 assert "Constant" in model_operators assert "Subtract" in model_operators @@ -57,20 +57,20 @@ def test_graph_preprocess_scale_vector(): shape = [2, 2] parameter_a = ops.parameter(shape, dtype=np.float32, name="A") model = parameter_a - function = Model(model, [parameter_a], "TestFunction") + model = Model(model, [parameter_a], "TestModel") layout = Layout("NC") - ppp = PrePostProcessor(function) + ppp = PrePostProcessor(model) inp = ppp.input() inp.tensor().set_layout(layout) inp.preprocess().scale([0.5, 2.0]) - function = ppp.build() + model = ppp.build() - model_operators = [op.get_name().split("_")[0] for op in function.get_ordered_ops()] + model_operators = [op.get_name().split("_")[0] for op in model.get_ordered_ops()] assert len(model_operators) == 4 - assert function.get_output_size() == 1 - assert list(function.get_output_shape(0)) == [2, 2] - assert function.get_output_element_type(0) == Type.f32 + assert model.get_output_size() == 1 + assert list(model.get_output_shape(0)) == [2, 2] + assert model.get_output_element_type(0) == Type.f32 assert "Constant" in model_operators assert "Divide" in model_operators @@ -79,22 +79,22 @@ def test_graph_preprocess_mean_scale_convert(): shape = [2, 2] param1 = ops.parameter(shape, dtype=np.int32, name="A") param2 = ops.parameter(shape, dtype=np.int32, name="B") - function = Model([param1, param2], [param1, param2], "TestFunction") + model = Model([param1, param2], [param1, param2], "TestModel") @custom_preprocess_function def custom_preprocess(output: Output): return ops.abs(output) - ppp = PrePostProcessor(function) + ppp = PrePostProcessor(model) inp2 = ppp.input(1) inp2.tensor().set_element_type(Type.i32) inp2.preprocess().convert_element_type(Type.f32).mean(1.).scale(2.) inp2.preprocess().convert_element_type() inp1 = ppp.input(0) inp1.preprocess().convert_element_type(Type.f32).mean(1.).custom(custom_preprocess) - function = ppp.build() + model = ppp.build() - model_operators = [op.get_name().split("_")[0] for op in function.get_ops()] + model_operators = [op.get_name().split("_")[0] for op in model.get_ops()] expected_ops = [ "Parameter", "Convert", @@ -105,11 +105,11 @@ def custom_preprocess(output: Output): "Abs", ] assert len(model_operators) == 15 - assert function.get_output_size() == 2 - assert list(function.get_output_shape(0)) == [2, 2] - assert list(function.get_output_shape(1)) == [2, 2] - assert function.get_output_element_type(0) == Type.i32 - assert function.get_output_element_type(1) == Type.i32 + assert model.get_output_size() == 2 + assert list(model.get_output_shape(0)) == [2, 2] + assert list(model.get_output_shape(1)) == [2, 2] + assert model.get_output_element_type(0) == Type.i32 + assert model.get_output_element_type(1) == Type.i32 for op in expected_ops: assert op in model_operators @@ -118,13 +118,13 @@ def test_graph_preprocess_input_output_by_name(): shape = [2, 2] param1 = ops.parameter(shape, dtype=np.int32, name="A") param2 = ops.parameter(shape, dtype=np.int32, name="B") - function = Model([param1, param2], [param1, param2], "TestFunction") + model = Model([param1, param2], [param1, param2], "TestModel") @custom_preprocess_function def custom_preprocess(output: Output): return ops.abs(output) - ppp = PrePostProcessor(function) + ppp = PrePostProcessor(model) inp2 = ppp.input("B") inp2.tensor().set_element_type(Type.i32) inp2.preprocess().convert_element_type(Type.f32).mean(1.).scale(2.) @@ -134,9 +134,9 @@ def custom_preprocess(output: Output): out1.postprocess().custom(custom_preprocess) out2 = ppp.output("B") out2.postprocess().custom(custom_preprocess) - function = ppp.build() + model = ppp.build() - model_operators = [op.get_name().split("_")[0] for op in function.get_ops()] + model_operators = [op.get_name().split("_")[0] for op in model.get_ops()] expected_ops = [ "Parameter", "Convert", @@ -147,11 +147,11 @@ def custom_preprocess(output: Output): "Abs", ] assert len(model_operators) == 16 - assert function.get_output_size() == 2 - assert list(function.get_output_shape(0)) == [2, 2] - assert list(function.get_output_shape(1)) == [2, 2] - assert function.get_output_element_type(0) == Type.i32 - assert function.get_output_element_type(1) == Type.i32 + assert model.get_output_size() == 2 + assert list(model.get_output_shape(0)) == [2, 2] + assert list(model.get_output_shape(1)) == [2, 2] + assert model.get_output_element_type(0) == Type.i32 + assert model.get_output_element_type(1) == Type.i32 for op in expected_ops: assert op in model_operators @@ -160,7 +160,7 @@ def test_graph_preprocess_output_postprocess(): shape = [2, 3] parameter_a = ops.parameter(shape, dtype=np.int32, name="A") model = parameter_a - function = Model(model, [parameter_a], "TestFunction") + model = Model(model, [parameter_a], "TestModel") layout1 = Layout("NC") layout2 = Layout("CN") layout3 = [1, 0] @@ -168,7 +168,7 @@ def test_graph_preprocess_output_postprocess(): @custom_preprocess_function def custom_postprocess(output: Output): return ops.abs(output) - ppp = PrePostProcessor(function) + ppp = PrePostProcessor(model) inp = ppp.input() inp.tensor().set_layout(layout1) inp.preprocess().convert_element_type(Type.f32).mean([1.0, 2.0, 3.0]) @@ -178,9 +178,9 @@ def custom_postprocess(output: Output): out.postprocess().convert_element_type(Type.f32) out.postprocess().convert_layout(layout2).convert_layout(layout3) out.postprocess().custom(custom_postprocess).convert_element_type(Type.f16).convert_element_type() - function = ppp.build() + model = ppp.build() - model_operators = [op.get_name().split("_")[0] for op in function.get_ops()] + model_operators = [op.get_name().split("_")[0] for op in model.get_ops()] expected_ops = [ "Parameter", "Convert", @@ -191,9 +191,9 @@ def custom_postprocess(output: Output): "Abs", ] assert len(model_operators) == 14 - assert function.get_output_size() == 1 - assert list(function.get_output_shape(0)) == [2, 3] - assert function.get_output_element_type(0) == Type.f32 + assert model.get_output_size() == 1 + assert list(model.get_output_shape(0)) == [2, 3] + assert model.get_output_element_type(0) == Type.f32 for op in expected_ops: assert op in model_operators @@ -202,12 +202,12 @@ def test_graph_preprocess_spatial_static_shape(): shape = [3, 2, 2] parameter_a = ops.parameter(shape, dtype=np.int32, name="A") model = parameter_a - function = Model(model, [parameter_a], "TestFunction") + model = Model(model, [parameter_a], "TestModel") layout = Layout("CHW") color_format = ColorFormat.RGB - ppp = PrePostProcessor(function) + ppp = PrePostProcessor(model) inp = ppp.input() inp.tensor().set_layout(layout).set_spatial_static_shape(2, 2).set_color_format(color_format) inp.preprocess().convert_element_type(Type.f32).mean([1., 2., 3.]) @@ -215,9 +215,9 @@ def test_graph_preprocess_spatial_static_shape(): out = ppp.output() out.tensor().set_layout(layout).set_element_type(Type.f32) out.model().set_layout(layout) - function = ppp.build() + model = ppp.build() - model_operators = [op.get_name().split("_")[0] for op in function.get_ops()] + model_operators = [op.get_name().split("_")[0] for op in model.get_ops()] expected_ops = [ "Parameter", "Convert", @@ -226,9 +226,9 @@ def test_graph_preprocess_spatial_static_shape(): "Result", ] assert len(model_operators) == 7 - assert function.get_output_size() == 1 - assert list(function.get_output_shape(0)) == [3, 2, 2] - assert function.get_output_element_type(0) == Type.f32 + assert model.get_output_size() == 1 + assert list(model.get_output_shape(0)) == [3, 2, 2] + assert model.get_output_element_type(0) == Type.f32 for op in expected_ops: assert op in model_operators @@ -237,7 +237,7 @@ def test_graph_preprocess_set_shape(): shape = [1, 1, 1] parameter_a = ops.parameter(shape, dtype=np.int32, name="A") model = parameter_a - function = Model(model, [parameter_a], "TestFunction") + model = Model(model, [parameter_a], "TestModel") @custom_preprocess_function def custom_crop(out_node: Output): @@ -247,13 +247,13 @@ def custom_crop(out_node: Output): axis = ops.constant(np.array([0, 1, 2]), dtype=np.int32) return ops.slice(out_node, start, stop, step, axis) - ppp = PrePostProcessor(function) + ppp = PrePostProcessor(model) inp = ppp.input() inp.tensor().set_shape([3, 3, 3]) inp.preprocess().custom(custom_crop) - function = ppp.build() + model = ppp.build() - model_operators = [op.get_name().split("_")[0] for op in function.get_ops()] + model_operators = [op.get_name().split("_")[0] for op in model.get_ops()] expected_ops = [ "Parameter", "Constant", @@ -261,9 +261,9 @@ def custom_crop(out_node: Output): "Slice", ] assert len(model_operators) == 7 - assert function.get_output_size() == 1 - assert list(function.get_output_shape(0)) == [1, 1, 1] - assert function.get_output_element_type(0) == Type.i32 + assert model.get_output_size() == 1 + assert list(model.get_output_shape(0)) == [1, 1, 1] + assert model.get_output_element_type(0) == Type.i32 for op in expected_ops: assert op in model_operators @@ -274,25 +274,25 @@ def test_graph_preprocess_set_from_tensor(): parameter_a = ops.parameter(shape, dtype=np.float32, name="A") parameter_a.set_layout(Layout("NHWC")) model = parameter_a - function = Model(model, [parameter_a], "TestFunction") + model = Model(model, [parameter_a], "TestModel") input_data = Tensor(Type.i32, inp_shape) - ppp = PrePostProcessor(function) + ppp = PrePostProcessor(model) inp = ppp.input() inp.tensor().set_from(input_data) inp.preprocess().resize(ResizeAlgorithm.RESIZE_LINEAR) - function = ppp.build() - assert function.input().shape == Shape(inp_shape) - assert function.input().element_type == Type.i32 - assert function.output().shape == Shape(shape) - assert function.output().element_type == Type.f32 + model = ppp.build() + assert model.input().shape == Shape(inp_shape) + assert model.input().element_type == Type.i32 + assert model.output().shape == Shape(shape) + assert model.output().element_type == Type.f32 def test_graph_preprocess_set_from_np_infer(): shape = [1, 1, 1] parameter_a = ops.parameter(shape, dtype=np.float32, name="A") model = parameter_a - function = Model(model, [parameter_a], "TestFunction") + model = Model(model, [parameter_a], "TestModel") @custom_preprocess_function def custom_crop(out_node: Output): @@ -306,15 +306,15 @@ def custom_crop(out_node: Output): [[9, 10, 11], [12, 13, 14], [15, 16, 17]], [[18, 19, 20], [21, 22, 23], [24, 25, 26]]]).astype(np.int32) - ppp = PrePostProcessor(function) + ppp = PrePostProcessor(model) inp = ppp.input() inp.tensor().set_from(input_data) inp.preprocess().convert_element_type().custom(custom_crop) - function = ppp.build() - assert function.input().shape == Shape([3, 3, 3]) - assert function.input().element_type == Type.i32 + model = ppp.build() + assert model.input().shape == Shape([3, 3, 3]) + assert model.input().element_type == Type.i32 - model_operators = [op.get_name().split("_")[0] for op in function.get_ops()] + model_operators = [op.get_name().split("_")[0] for op in model.get_ops()] expected_ops = [ "Parameter", "Convert", @@ -323,9 +323,9 @@ def custom_crop(out_node: Output): "Slice", ] assert len(model_operators) == 8 - assert function.get_output_size() == 1 - assert list(function.get_output_shape(0)) == [1, 1, 1] - assert function.get_output_element_type(0) == Type.f32 + assert model.get_output_size() == 1 + assert list(model.get_output_shape(0)) == [1, 1, 1] + assert model.get_output_element_type(0) == Type.f32 for op in expected_ops: assert op in model_operators @@ -335,13 +335,13 @@ def test_graph_preprocess_set_memory_type(): parameter_a = ops.parameter(shape, dtype=np.int32, name="A") op = ops.relu(parameter_a) model = op - function = Model(model, [parameter_a], "TestFunction") + model = Model(model, [parameter_a], "TestModel") - ppp = PrePostProcessor(function) + ppp = PrePostProcessor(model) ppp.input().tensor().set_memory_type("some_memory_type") - function = ppp.build() + model = ppp.build() - assert any(key for key in function.input().rt_info if "memory_type" in key) + assert any(key for key in model.input().rt_info if "memory_type" in key) @pytest.mark.parametrize( @@ -380,11 +380,11 @@ def test_graph_preprocess_steps(algorithm, color_format1, color_format2, is_fail shape = [1, 3, 3, 3] parameter_a = ops.parameter(shape, dtype=np.float32, name="A") model = parameter_a - function = Model(model, [parameter_a], "TestFunction") + model = Model(model, [parameter_a], "TestModel") layout1 = Layout("NCWH") layout2 = Layout("NCHW") - custom_processor = PrePostProcessor(function) + custom_processor = PrePostProcessor(model) inp = custom_processor.input() inp.tensor().set_layout(layout1).set_color_format(color_format1, []) inp.preprocess().mean(1.).resize(algorithm, 3, 3) @@ -392,11 +392,11 @@ def test_graph_preprocess_steps(algorithm, color_format1, color_format2, is_fail if is_failing: with pytest.raises(RuntimeError) as e: - function = custom_processor.build() + model = custom_processor.build() assert "is not convertible to" in str(e.value) else: - function = custom_processor.build() - model_operators = [op.get_name().split("_")[0] for op in function.get_ops()] + model = custom_processor.build() + model_operators = [op.get_name().split("_")[0] for op in model.get_ops()] expected_ops = [ "Parameter", "Constant", @@ -405,9 +405,9 @@ def test_graph_preprocess_steps(algorithm, color_format1, color_format2, is_fail "Interpolate", ] assert len(model_operators) == 15 - assert function.get_output_size() == 1 - assert list(function.get_output_shape(0)) == [1, 3, 3, 3] - assert function.get_output_element_type(0) == Type.f32 + assert model.get_output_size() == 1 + assert list(model.get_output_shape(0)) == [1, 3, 3, 3] + assert model.get_output_element_type(0) == Type.f32 for op in expected_ops: assert op in model_operators @@ -420,37 +420,37 @@ def test_graph_preprocess_steps(algorithm, color_format1, color_format2, is_fail def test_graph_preprocess_convert_color(color_format1, color_format2, tensor_in_shape, model_in_shape): parameter_a = ops.parameter(model_in_shape, dtype=np.float32, name="A") model = parameter_a - function = Model(model, [parameter_a], "TestFunction") + model = Model(model, [parameter_a], "TestModel") - custom_processor = PrePostProcessor(function) + custom_processor = PrePostProcessor(model) inp = custom_processor.input() inp.tensor().set_color_format(color_format1) inp.preprocess().convert_color(color_format2) - function = custom_processor.build() + model = custom_processor.build() - assert function.get_output_size() == 1 - assert list(function.inputs[0].shape) == tensor_in_shape - assert list(function.get_output_shape(0)) == model_in_shape - assert function.get_output_element_type(0) == Type.f32 + assert model.get_output_size() == 1 + assert list(model.inputs[0].shape) == tensor_in_shape + assert list(model.get_output_shape(0)) == model_in_shape + assert model.get_output_element_type(0) == Type.f32 def test_graph_preprocess_postprocess_layout(): shape = [1, 1, 3, 3] parameter_a = ops.parameter(shape, dtype=np.float32, name="A") model = parameter_a - function = Model(model, [parameter_a], "TestFunction") + model = Model(model, [parameter_a], "TestModel") layout1 = Layout("NCWH") layout2 = Layout("NCHW") - ppp = PrePostProcessor(function) + ppp = PrePostProcessor(model) inp = ppp.input() inp.tensor().set_layout(layout1) inp.preprocess().mean(1.).convert_layout(layout2).reverse_channels() out = ppp.output() out.postprocess().convert_layout([0, 1, 2, 3]) - function = ppp.build() + model = ppp.build() - model_operators = [op.get_name().split("_")[0] for op in function.get_ops()] + model_operators = [op.get_name().split("_")[0] for op in model.get_ops()] expected_ops = [ "Parameter", "Constant", @@ -460,9 +460,9 @@ def test_graph_preprocess_postprocess_layout(): "Transpose", ] assert len(model_operators) == 14 - assert function.get_output_size() == 1 - assert list(function.get_output_shape(0)) == [1, 1, 3, 3] - assert function.get_output_element_type(0) == Type.f32 + assert model.get_output_size() == 1 + assert list(model.get_output_shape(0)) == [1, 1, 3, 3] + assert model.get_output_element_type(0) == Type.f32 for op in expected_ops: assert op in model_operators @@ -471,16 +471,16 @@ def test_graph_preprocess_reverse_channels(): shape = [1, 2, 2, 2] parameter_a = ops.parameter(shape, dtype=np.float32, name="A") model = parameter_a - function = Model(model, [parameter_a], "TestFunction") + model = Model(model, [parameter_a], "TestModel") layout1 = Layout("NCWH") - ppp = PrePostProcessor(function) + ppp = PrePostProcessor(model) inp = ppp.input() inp.tensor().set_layout(layout1) inp.preprocess().mean(1.).reverse_channels() - function = ppp.build() + model = ppp.build() - model_operators = [op.get_name().split("_")[0] for op in function.get_ops()] + model_operators = [op.get_name().split("_")[0] for op in model.get_ops()] expected_ops = [ "Parameter", "Constant", @@ -489,9 +489,9 @@ def test_graph_preprocess_reverse_channels(): "Range", ] assert len(model_operators) == 10 - assert function.get_output_size() == 1 - assert list(function.get_output_shape(0)) == [1, 2, 2, 2] - assert function.get_output_element_type(0) == Type.f32 + assert model.get_output_size() == 1 + assert list(model.get_output_shape(0)) == [1, 2, 2, 2] + assert model.get_output_element_type(0) == Type.f32 for op in expected_ops: assert op in model_operators @@ -501,14 +501,14 @@ def test_graph_preprocess_crop(): tensor_shape = [1, 2, 3, 3] parameter_a = ops.parameter(orig_shape, dtype=np.float32, name="A") model = ops.relu(parameter_a) - function = Model(model, [parameter_a], "TestFunction") + model = Model(model, [parameter_a], "TestModel") - ppp = PrePostProcessor(function) + ppp = PrePostProcessor(model) ppp.input().tensor().set_shape(tensor_shape) ppp.input().preprocess().crop([0, 0, 1, 1], [1, 2, -1, -1]) - function = ppp.build() + model = ppp.build() - model_operators = [op.get_name().split("_")[0] for op in function.get_ops()] + model_operators = [op.get_name().split("_")[0] for op in model.get_ops()] expected_ops = [ "Parameter", "Constant", @@ -517,9 +517,9 @@ def test_graph_preprocess_crop(): "Slice", ] assert len(model_operators) == 8 - assert function.get_output_size() == 1 - assert list(function.get_output_shape(0)) == [1, 2, 1, 1] - assert function.get_output_element_type(0) == Type.f32 + assert model.get_output_size() == 1 + assert list(model.get_output_shape(0)) == [1, 2, 1, 1] + assert model.get_output_element_type(0) == Type.f32 for op in expected_ops: assert op in model_operators @@ -528,17 +528,17 @@ def test_graph_preprocess_resize_algorithm(): shape = [1, 1, 3, 3] parameter_a = ops.parameter(shape, dtype=np.float32, name="A") model = parameter_a - function = Model(model, [parameter_a], "TestFunction") + model = Model(model, [parameter_a], "TestModel") resize_alg = ResizeAlgorithm.RESIZE_CUBIC layout1 = Layout("NCWH") - ppp = PrePostProcessor(function) + ppp = PrePostProcessor(model) inp = ppp.input() inp.tensor().set_layout(layout1) inp.preprocess().mean(1.).resize(resize_alg, 3, 3) - function = ppp.build() + model = ppp.build() - model_operators = [op.get_name().split("_")[0] for op in function.get_ops()] + model_operators = [op.get_name().split("_")[0] for op in model.get_ops()] expected_ops = [ "Parameter", "Constant", @@ -547,9 +547,9 @@ def test_graph_preprocess_resize_algorithm(): "Interpolate", ] assert len(model_operators) == 7 - assert function.get_output_size() == 1 - assert list(function.get_output_shape(0)) == [1, 1, 3, 3] - assert function.get_output_element_type(0) == Type.f32 + assert model.get_output_size() == 1 + assert list(model.get_output_shape(0)) == [1, 1, 3, 3] + assert model.get_output_element_type(0) == Type.f32 for op in expected_ops: assert op in model_operators @@ -615,19 +615,19 @@ def test_graph_preprocess_model(): """) core = Core() - function = core.read_model(model=model) + model = core.read_model(model=model) @custom_preprocess_function def custom_preprocess(output: Output): return ops.abs(output) - ppp = PrePostProcessor(function) + ppp = PrePostProcessor(model) ppp.input(1).preprocess().convert_element_type(Type.f32).scale(0.5) ppp.input(0).preprocess().convert_element_type(Type.f32).mean(5.) ppp.output(0).postprocess().custom(custom_preprocess) - function = ppp.build() + model = ppp.build() - model_operators = [op.get_name().split("_")[0] for op in function.get_ops()] + model_operators = [op.get_name().split("_")[0] for op in model.get_ops()] expected_ops = [ "Parameter", "Constant", @@ -639,9 +639,9 @@ def custom_preprocess(output: Output): "Divide", ] assert len(model_operators) == 13 - assert function.get_output_size() == 1 - assert list(function.get_output_shape(0)) == [2, 2, 2] - assert function.get_output_element_type(0) == Type.i32 + assert model.get_output_size() == 1 + assert list(model.get_output_shape(0)) == [2, 2, 2] + assert model.get_output_element_type(0) == Type.i32 for op in expected_ops: assert op in model_operators @@ -650,9 +650,9 @@ def test_graph_preprocess_dump(): shape = [1, 3, 224, 224] parameter_a = ops.parameter(shape, dtype=np.float32, name="RGB_input") model = parameter_a - function = Model(model, [parameter_a], "TestFunction") + model = Model(model, [parameter_a], "TestModel") - ppp = PrePostProcessor(function) + ppp = PrePostProcessor(model) ppp.input().tensor().set_layout(Layout("NHWC")).set_element_type(Type.u8) ppp.input().tensor().set_spatial_dynamic_shape() ppp.input().preprocess().convert_element_type(Type.f32).reverse_channels() @@ -673,13 +673,13 @@ def test_graph_preprocess_dump(): @pytest.mark.parametrize( ("layout", "layout_str"), [("NHCW", "[N,H,C,W]"), ("NHWC", "[N,H,W,C]")]) -def test_ngraph_set_layout_by_string(layout, layout_str): +def test_graph_set_layout_by_string(layout, layout_str): shape = [1, 3, 224, 224] parameter_a = ops.parameter(shape, dtype=np.float32, name="RGB_input") model = parameter_a - function = Model(model, [parameter_a], "TestFunction") + model = Model(model, [parameter_a], "TestModel") - ppp = PrePostProcessor(function) + ppp = PrePostProcessor(model) ppp.input().model().set_layout(layout) p_str = str(ppp) assert f"{layout_str}" in p_str @@ -688,13 +688,13 @@ def test_ngraph_set_layout_by_string(layout, layout_str): @pytest.mark.parametrize( ("layout", "layout_str"), [(Layout("NHCW"), "[N,H,C,W]"), (Layout("NHWC"), "[N,H,W,C]")]) -def test_ngraph_set_layout_by_layout_class(layout, layout_str): +def test_graph_set_layout_by_layout_class(layout, layout_str): shape = [1, 3, 224, 224] parameter_a = ops.parameter(shape, dtype=np.float32, name="RGB_input") model = parameter_a - function = Model(model, [parameter_a], "TestFunction") + model = Model(model, [parameter_a], "TestModel") - ppp = PrePostProcessor(function) + ppp = PrePostProcessor(model) ppp.input().model().set_layout(layout) p_str = str(ppp) assert f"{layout_str}" in p_str @@ -703,26 +703,26 @@ def test_ngraph_set_layout_by_layout_class(layout, layout_str): @pytest.mark.parametrize( ("layout"), [("1-2-3D"), ("5-5")]) -def test_ngraph_set_layout_by_str_thow_exception(layout): +def test_graph_set_layout_by_str_thow_exception(layout): shape = [1, 3, 224, 224] parameter_a = ops.parameter(shape, dtype=np.float32, name="RGB_input") model = parameter_a - function = Model(model, [parameter_a], "TestFunction") + model = Model(model, [parameter_a], "TestModel") - ppp = PrePostProcessor(function) + ppp = PrePostProcessor(model) with pytest.raises(RuntimeError) as e: ppp.input().model().set_layout(layout) assert "Layout name is invalid" in str(e.value) -def test_ngraph_set_layout_by_layout_class_thow_exception(): +def test_graph_set_layout_by_layout_class_thow_exception(): shape = [1, 3, 224, 224] parameter_a = ops.parameter(shape, dtype=np.float32, name="RGB_input") model = parameter_a - function = Model(model, [parameter_a], "TestFunction") + model = Model(model, [parameter_a], "TestModel") - ppp = PrePostProcessor(function) + ppp = PrePostProcessor(model) with pytest.raises(RuntimeError) as e: layout = Layout("1-2-3D") diff --git a/src/bindings/python/tests/test_graph/util.py b/src/bindings/python/tests/test_graph/util.py index 34fc22deda923c..d048dc57797043 100644 --- a/src/bindings/python/tests/test_graph/util.py +++ b/src/bindings/python/tests/test_graph/util.py @@ -3,9 +3,9 @@ # SPDX-License-Identifier: Apache-2.0 -def count_ops_of_type(func, op_type): +def count_ops_of_type(model, op_type): count = 0 - for op in func.get_ops(): + for op in model.get_ops(): if (type(op) is type(op_type)): count += 1 return count diff --git a/src/bindings/python/tests/test_runtime/test_async_infer_request.py b/src/bindings/python/tests/test_runtime/test_async_infer_request.py new file mode 100644 index 00000000000000..1c6fd5f25511c7 --- /dev/null +++ b/src/bindings/python/tests/test_runtime/test_async_infer_request.py @@ -0,0 +1,330 @@ +# -*- coding: utf-8 -*- +# Copyright (C) 2018-2023 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +from collections.abc import Iterable +from copy import deepcopy +import numpy as np +import pytest + +import openvino.runtime.opset13 as ops +from openvino import ( + Core, + InferRequest, + AsyncInferQueue, + Model, + Shape, + Type, + Tensor, +) +from openvino.runtime import ProfilingInfo +from openvino.preprocess import PrePostProcessor + +from tests import skip_need_mock_op +from tests.utils.helpers import generate_image, get_relu_model, generate_model_with_memory + + +def concat_model_with_data(device, ov_type, numpy_dtype): + core = Core() + + input_shape = [5] + + params = [] + params += [ops.parameter(input_shape, ov_type)] + if ov_type == Type.bf16: + params += [ops.parameter(input_shape, ov_type)] + else: + params += [ops.parameter(input_shape, numpy_dtype)] + + model = Model(ops.concat(params, 0), params) + compiled_model = core.compile_model(model, device) + request = compiled_model.create_infer_request() + tensor1 = Tensor(ov_type, input_shape) + tensor1.data[:] = np.array([6, 7, 8, 9, 0]) + array1 = np.array([1, 2, 3, 4, 5], dtype=numpy_dtype) + + return request, tensor1, array1 + + +def create_model_with_memory(input_shape, data_type): + input_data = ops.parameter(input_shape, name="input_data", dtype=data_type) + rv = ops.read_value(input_data, "var_id_667", data_type, input_shape) + add = ops.add(rv, input_data, name="MemoryAdd") + node = ops.assign(add, "var_id_667") + res = ops.result(add, "res") + model = Model(results=[res], sinks=[node], parameters=[input_data], name="name") + return model + + +def abs_model_with_data(device, ov_type, numpy_dtype): + input_shape = [1, 4] + param = ops.parameter(input_shape, ov_type) + model = Model(ops.abs(param), [param]) + core = Core() + compiled_model = core.compile_model(model, device) + + request = compiled_model.create_infer_request() + + tensor1 = Tensor(ov_type, input_shape) + tensor1.data[:] = np.array([6, -7, -8, 9]) + + array1 = np.array([[-1, 2, 5, -3]]).astype(numpy_dtype) + + return compiled_model, request, tensor1, array1 + + +@pytest.mark.parametrize("share_inputs", [True, False]) +def test_infer_queue(device, share_inputs): + jobs = 8 + num_request = 4 + core = Core() + model = get_relu_model() + compiled_model = core.compile_model(model, device) + infer_queue = AsyncInferQueue(compiled_model, num_request) + jobs_done = [{"finished": False, "latency": 0} for _ in range(jobs)] + + def callback(request, job_id): + jobs_done[job_id]["finished"] = True + jobs_done[job_id]["latency"] = request.latency + + img = None + + if not share_inputs: + img = generate_image() + infer_queue.set_callback(callback) + assert infer_queue.is_ready() + + for i in range(jobs): + if share_inputs: + img = generate_image() + infer_queue.start_async({"data": img}, i, share_inputs=share_inputs) + infer_queue.wait_all() + assert all(job["finished"] for job in jobs_done) + assert all(job["latency"] > 0 for job in jobs_done) + + +def test_infer_queue_iteration(device): + core = Core() + param = ops.parameter([10]) + model = Model(ops.relu(param), [param]) + compiled_model = core.compile_model(model, device) + infer_queue = AsyncInferQueue(compiled_model, 1) + assert isinstance(infer_queue, Iterable) + for infer_req in infer_queue: + assert isinstance(infer_req, InferRequest) + + it = iter(infer_queue) + infer_request = next(it) + assert isinstance(infer_request, InferRequest) + assert infer_request.userdata is None + with pytest.raises(StopIteration): + next(it) + + +def test_infer_queue_userdata_is_empty(device): + core = Core() + param = ops.parameter([10]) + model = Model(ops.relu(param), [param]) + compiled_model = core.compile_model(model, device) + infer_queue = AsyncInferQueue(compiled_model, 1) + assert infer_queue.userdata == [None] + + +def test_infer_queue_userdata_is_empty_more_jobs(device): + core = Core() + param = ops.parameter([10]) + model = Model(ops.relu(param), [param]) + compiled_model = core.compile_model(model, device) + infer_queue = AsyncInferQueue(compiled_model, 5) + assert infer_queue.userdata == [None, None, None, None, None] + + +def test_infer_queue_fail_on_cpp_model(device): + jobs = 6 + num_request = 4 + core = Core() + model = get_relu_model() + compiled_model = core.compile_model(model, device) + infer_queue = AsyncInferQueue(compiled_model, num_request) + + def callback(request, _): + request.get_tensor("Unknown") + + img = generate_image() + infer_queue.set_callback(callback) + + with pytest.raises(RuntimeError) as e: + for _ in range(jobs): + infer_queue.start_async({"data": img}) + infer_queue.wait_all() + + assert "Port for tensor name Unknown was not found" in str(e.value) + + +def test_infer_queue_fail_on_py_model(device): + jobs = 1 + num_request = 1 + core = Core() + model = get_relu_model() + compiled_model = core.compile_model(model, device) + infer_queue = AsyncInferQueue(compiled_model, num_request) + + def callback(request, _): + request = request + 21 + + img = generate_image() + infer_queue.set_callback(callback) + + with pytest.raises(TypeError) as e: + for _ in range(jobs): + infer_queue.start_async({"data": img}) + infer_queue.wait_all() + + assert "unsupported operand type(s) for +" in str(e.value) + + +@skip_need_mock_op +@pytest.mark.parametrize("with_callback", [False, True]) +def test_infer_queue_fail_in_inference(device, with_callback): + jobs = 6 + num_request = 4 + core = Core() + data = ops.parameter([10], dtype=np.float32, name="data") + k_op = ops.parameter(Shape([]), dtype=np.int32, name="k") + emb = ops.topk(data, k_op, axis=0, mode="max", sort="value") + model = Model(emb, [data, k_op]) + compiled_model = core.compile_model(model, device) + infer_queue = AsyncInferQueue(compiled_model, num_request) + + def callback(request, _): + pytest.fail("Callback should not be called") + + if with_callback: + infer_queue.set_callback(callback) + + data_tensor = Tensor(np.arange(10).astype(np.float32)) + k_tensor = Tensor(np.array(11, dtype=np.int32)) + + with pytest.raises(RuntimeError) as e: + for _ in range(jobs): + infer_queue.start_async({"data": data_tensor, "k": k_tensor}) + infer_queue.wait_all() + + assert "Can not clone with new dims" in str(e.value) + + +def test_infer_queue_get_idle_handle(device): + param = ops.parameter([10]) + model = Model(ops.relu(param), [param]) + core = Core() + compiled_model = core.compile_model(model, device) + queue = AsyncInferQueue(compiled_model, 2) + niter = 10 + + for _ in range(len(queue)): + queue.start_async() + queue.wait_all() + for request in queue: + assert request.wait_for(0) + + for _ in range(niter): + idle_id = queue.get_idle_request_id() + assert queue[idle_id].wait_for(0) + queue.start_async() + queue.wait_all() + + +@pytest.mark.parametrize("share_inputs", [True, False]) +def test_results_async_infer(device, share_inputs): + jobs = 8 + num_request = 4 + core = Core() + model = get_relu_model() + compiled_model = core.compile_model(model, device) + infer_queue = AsyncInferQueue(compiled_model, num_request) + jobs_done = [{"finished": False, "latency": 0} for _ in range(jobs)] + + def callback(request, job_id): + jobs_done[job_id]["finished"] = True + jobs_done[job_id]["latency"] = request.latency + + img = generate_image() + infer_queue.set_callback(callback) + for i in range(jobs): + infer_queue.start_async({"data": img}, i, share_inputs=share_inputs) + infer_queue.wait_all() + + request = compiled_model.create_infer_request() + outputs = request.infer({0: img}) + + for i in range(num_request): + assert np.allclose(list(outputs.values()), list( + infer_queue[i].results.values())) + + +@pytest.mark.parametrize("share_inputs", [True, False]) +def test_array_like_input_async_infer_queue(device, share_inputs): + class ArrayLikeObject: + # Array-like object accepted by np.array to test inputs similar to torch tensor and tf.Tensor + def __init__(self, array) -> None: + self.data = array + + def __array__(self): + return self.data + + jobs = 8 + ov_type = Type.f32 + input_shape = [2, 2] + input_data = np.ascontiguousarray([[-2, -1], [0, 1]]) + param = ops.parameter(input_shape, ov_type) + layer = ops.abs(param) + model = Model([layer], [param]) + core = Core() + compiled_model = core.compile_model(model, "CPU") + + model_input_object = ArrayLikeObject(input_data) + model_input_list = [ + [ArrayLikeObject(deepcopy(input_data))] for _ in range(jobs)] + + # Test single array-like object in AsyncInferQueue.start_async() + infer_queue_object = AsyncInferQueue(compiled_model, jobs) + for _i in range(jobs): + infer_queue_object.start_async(model_input_object) + infer_queue_object.wait_all() + + for i in range(jobs): + assert np.array_equal( + infer_queue_object[i].get_output_tensor().data, np.abs(input_data)) + + # Test list of array-like objects in AsyncInferQueue.start_async() + infer_queue_list = AsyncInferQueue(compiled_model, jobs) + for i in range(jobs): + infer_queue_list.start_async( + model_input_list[i], share_inputs=share_inputs) + infer_queue_list.wait_all() + + for i in range(jobs): + assert np.array_equal( + infer_queue_list[i].get_output_tensor().data, np.abs(input_data)) + + +@pytest.mark.parametrize("shared_flag", [True, False]) +def test_shared_memory_deprecation(device, shared_flag): + compiled, request, _, input_data = abs_model_with_data( + device, Type.f32, np.float32) + + with pytest.warns(FutureWarning, match="`shared_memory` is deprecated and will be removed in 2024.0"): + _ = compiled(input_data, shared_memory=shared_flag) + + with pytest.warns(FutureWarning, match="`shared_memory` is deprecated and will be removed in 2024.0"): + _ = request.infer(input_data, shared_memory=shared_flag) + + with pytest.warns(FutureWarning, match="`shared_memory` is deprecated and will be removed in 2024.0"): + request.start_async(input_data, shared_memory=shared_flag) + request.wait() + + queue = AsyncInferQueue(compiled, jobs=1) + + with pytest.warns(FutureWarning, match="`shared_memory` is deprecated and will be removed in 2024.0"): + queue.start_async(input_data, shared_memory=shared_flag) + queue.wait_all() diff --git a/src/bindings/python/tests/test_runtime/test_core.py b/src/bindings/python/tests/test_runtime/test_core.py index 33540294117909..86700ea7804cbd 100644 --- a/src/bindings/python/tests/test_runtime/test_core.py +++ b/src/bindings/python/tests/test_runtime/test_core.py @@ -300,9 +300,9 @@ def test_query_model(device): model = get_relu_model() query_model = core.query_model(model=model, device_name=device) ops_model = model.get_ordered_ops() - ops_func_names = [op.friendly_name for op in ops_model] + ops_model_names = [op.friendly_name for op in ops_model] assert [ - key for key in query_model.keys() if key not in ops_func_names + key for key in query_model.keys() if key not in ops_model_names ] == [], "Not all network layers present in query_model results" assert device in next(iter(set(query_model.values()))), "Wrong device for some layers" diff --git a/src/bindings/python/tests/test_runtime/test_model.py b/src/bindings/python/tests/test_runtime/test_model.py index 53d0a4d27398f8..0e0529d7494a13 100644 --- a/src/bindings/python/tests/test_runtime/test_model.py +++ b/src/bindings/python/tests/test_runtime/test_model.py @@ -6,6 +6,7 @@ import numpy as np import pytest import math +from contextlib import nullcontext as does_not_raise import openvino.runtime.opset13 as ops from openvino import ( @@ -22,11 +23,12 @@ serialize, ) from openvino.runtime import Output +from openvino.runtime.op.util import VariableInfo, Variable -from tests.utils.helpers import generate_add_model, create_filename_for_test +from tests.utils.helpers import generate_add_model, generate_model_with_memory, create_filename_for_test -def test_test_descriptor_tensor(): +def test_descriptor_tensor(): input_shape = PartialShape([1]) param = ops.parameter(input_shape, dtype=np.float32, name="data") relu1 = ops.relu(param, name="relu1") @@ -40,125 +42,54 @@ def test_test_descriptor_tensor(): assert td.any_name == "relu_t1" -def test_function_add_outputs_tensor_name(): +@pytest.mark.parametrize(("output", "expectation", "raise_msg"), [ + ("relu_t1", does_not_raise(), ""), + (("relu1", 0), does_not_raise(), ""), + ("relu_t", pytest.raises(RuntimeError), "relu_t"), + (("relu1", 1234), pytest.raises(RuntimeError), "1234"), + (("relu_1", 0), pytest.raises(RuntimeError), "relu_1"), + (0, pytest.raises(TypeError), "Incorrect type of a value to add as output."), + ([0, 0], pytest.raises(TypeError), "Incorrect type of a value to add as output at index 0"), +]) +def test_add_outputs(output, expectation, raise_msg): input_shape = PartialShape([1]) param = ops.parameter(input_shape, dtype=np.float32, name="data") relu1 = ops.relu(param, name="relu1") relu1.get_output_tensor(0).set_names({"relu_t1"}) assert "relu_t1" in relu1.get_output_tensor(0).names relu2 = ops.relu(relu1, name="relu2") - function = Model(relu2, [param], "TestFunction") - assert len(function.get_results()) == 1 - assert len(function.results) == 1 - new_outs = function.add_outputs("relu_t1") - assert len(function.get_results()) == 2 - assert len(function.results) == 2 - assert "relu_t1" in function.outputs[1].get_tensor().names - assert len(new_outs) == 1 - assert new_outs[0].get_node() == function.outputs[1].get_node() - assert new_outs[0].get_index() == function.outputs[1].get_index() - - -def test_function_add_outputs_op_name(): - input_shape = PartialShape([1]) - param = ops.parameter(input_shape, dtype=np.float32, name="data") - relu1 = ops.relu(param, name="relu1") - relu1.get_output_tensor(0).set_names({"relu_t1"}) - relu2 = ops.relu(relu1, name="relu2") - function = Model(relu2, [param], "TestFunction") - assert len(function.get_results()) == 1 - assert len(function.results) == 1 - new_outs = function.add_outputs(("relu1", 0)) - assert len(function.get_results()) == 2 - assert len(function.results) == 2 - assert len(new_outs) == 1 - assert new_outs[0].get_node() == function.outputs[1].get_node() - assert new_outs[0].get_index() == function.outputs[1].get_index() - - -def test_function_add_output_port(): + model = Model(relu2, [param], "TestModel") + assert len(model.get_results()) == 1 + assert len(model.results) == 1 + with expectation as e: + new_outs = model.add_outputs(output) + assert len(model.get_results()) == 2 + assert len(model.results) == 2 + assert "relu_t1" in model.outputs[1].get_tensor().names + assert len(new_outs) == 1 + assert new_outs[0].get_node() == model.outputs[1].get_node() + assert new_outs[0].get_index() == model.outputs[1].get_index() + if e is not None: + assert raise_msg in str(e.value) + + +def test_add_output_port(): input_shape = PartialShape([1]) param = ops.parameter(input_shape, dtype=np.float32, name="data") relu1 = ops.relu(param, name="relu1") relu1.get_output_tensor(0).set_names({"relu_t1"}) relu2 = ops.relu(relu1, name="relu2") - function = Model(relu2, [param], "TestFunction") - assert len(function.results) == 1 - new_outs = function.add_outputs(relu1.output(0)) - assert len(function.results) == 2 + model = Model(relu2, [param], "TestModel") + assert len(model.results) == 1 + new_outs = model.add_outputs(relu1.output(0)) + assert len(model.results) == 2 assert len(new_outs) == 1 - assert new_outs[0].get_node() == function.outputs[1].get_node() - assert new_outs[0].get_index() == function.outputs[1].get_index() - - -def test_function_add_output_incorrect_tensor_name(): - input_shape = PartialShape([1]) - param = ops.parameter(input_shape, dtype=np.float32, name="data") - relu1 = ops.relu(param, name="relu1") - relu1.get_output_tensor(0).set_names({"relu_t1"}) - relu2 = ops.relu(relu1, name="relu2") - function = Model(relu2, [param], "TestFunction") - assert len(function.get_results()) == 1 - assert len(function.results) == 1 - with pytest.raises(RuntimeError) as e: - function.add_outputs("relu_t") - # Verify that absent output name is present in error message - assert "relu_t" in str(e.value) - - -def test_function_add_output_incorrect_idx(): - input_shape = PartialShape([1]) - param = ops.parameter(input_shape, dtype=np.float32, name="data") - relu1 = ops.relu(param, name="relu1") - relu1.get_output_tensor(0).set_names({"relu_t1"}) - relu2 = ops.relu(relu1, name="relu2") - function = Model(relu2, [param], "TestFunction") - assert len(function.get_results()) == 1 - assert len(function.results) == 1 - with pytest.raises(RuntimeError) as e: - function.add_outputs(("relu1", 1234)) - # Verify that op name and port number are present in error message - assert "relu1" in str(e.value) - assert "1234" in str(e.value) - - -def test_function_add_output_incorrect_name(): - input_shape = PartialShape([1]) - param = ops.parameter(input_shape, dtype=np.float32, name="data") - relu1 = ops.relu(param, name="relu1") - relu1.get_output_tensor(0).set_names({"relu_t1"}) - relu2 = ops.relu(relu1, name="relu2") - function = Model(relu2, [param], "TestFunction") - assert len(function.get_results()) == 1 - assert len(function.results) == 1 - with pytest.raises(RuntimeError) as e: - function.add_outputs(("relu_1", 0)) - # Verify that absent op name is present in error message - assert "relu_1" in str(e.value) - - -def test_add_outputs_several_tensors(): - input_shape = PartialShape([1]) - param = ops.parameter(input_shape, dtype=np.float32, name="data") - relu1 = ops.relu(param, name="relu1") - relu1.get_output_tensor(0).set_names({"relu_t1"}) - relu2 = ops.relu(relu1, name="relu2") - relu2.get_output_tensor(0).set_names({"relu_t2"}) - relu3 = ops.relu(relu2, name="relu3") - function = Model(relu3, [param], "TestFunction") - assert len(function.get_results()) == 1 - assert len(function.results) == 1 - new_outs = function.add_outputs(["relu_t1", "relu_t2"]) - assert len(function.get_results()) == 3 - assert len(function.results) == 3 - assert len(new_outs) == 2 - assert new_outs[0].get_node() == function.outputs[1].get_node() - assert new_outs[0].get_index() == function.outputs[1].get_index() - assert new_outs[1].get_node() == function.outputs[2].get_node() - assert new_outs[1].get_index() == function.outputs[2].get_index() + assert new_outs[0].get_node() == model.outputs[1].get_node() + assert new_outs[0].get_index() == model.outputs[1].get_index() -def test_add_outputs_several_ports(): +@pytest.mark.parametrize("args", [["relu_t1", "relu_t2"], [("relu1", 0), ("relu2", 0)]]) +def test_add_outputs_several_outputs(args): input_shape = PartialShape([1]) param = ops.parameter(input_shape, dtype=np.float32, name="data") relu1 = ops.relu(param, name="relu1") @@ -166,44 +97,17 @@ def test_add_outputs_several_ports(): relu2 = ops.relu(relu1, name="relu2") relu2.get_output_tensor(0).set_names({"relu_t2"}) relu3 = ops.relu(relu2, name="relu3") - function = Model(relu3, [param], "TestFunction") - assert len(function.get_results()) == 1 - assert len(function.results) == 1 - new_outs = function.add_outputs([("relu1", 0), ("relu2", 0)]) - assert len(function.get_results()) == 3 - assert len(function.results) == 3 + model = Model(relu3, [param], "TestModel") + assert len(model.get_results()) == 1 + assert len(model.results) == 1 + new_outs = model.add_outputs(args) + assert len(model.get_results()) == 3 + assert len(model.results) == 3 assert len(new_outs) == 2 - assert new_outs[0].get_node() == function.outputs[1].get_node() - assert new_outs[0].get_index() == function.outputs[1].get_index() - assert new_outs[1].get_node() == function.outputs[2].get_node() - assert new_outs[1].get_index() == function.outputs[2].get_index() - - -def test_add_outputs_incorrect_value(): - input_shape = PartialShape([1]) - param = ops.parameter(input_shape, dtype=np.float32, name="data") - relu1 = ops.relu(param, name="relu1") - relu1.get_output_tensor(0).set_names({"relu_t1"}) - relu2 = ops.relu(relu1, name="relu2") - function = Model(relu2, [param], "TestFunction") - assert len(function.get_results()) == 1 - assert len(function.results) == 1 - with pytest.raises(TypeError) as e: - function.add_outputs(0) - assert "Incorrect type of a value to add as output." in str(e.value) - - -def test_add_outputs_incorrect_outputs_list(): - input_shape = PartialShape([1]) - param = ops.parameter(input_shape, dtype=np.float32, name="data") - relu1 = ops.relu(param, name="relu1") - relu1.get_output_tensor(0).set_names({"relu_t1"}) - function = Model(relu1, [param], "TestFunction") - assert len(function.get_results()) == 1 - assert len(function.results) == 1 - with pytest.raises(TypeError) as e: - function.add_outputs([0, 0]) - assert "Incorrect type of a value to add as output at index 0" in str(e.value) + assert new_outs[0].get_node() == model.outputs[1].get_node() + assert new_outs[0].get_index() == model.outputs[1].get_index() + assert new_outs[1].get_node() == model.outputs[2].get_node() + assert new_outs[1].get_index() == model.outputs[2].get_index() def test_validate_nodes_and_infer_types(): @@ -221,41 +125,41 @@ def test_get_result_index(): input_shape = PartialShape([1]) param = ops.parameter(input_shape, dtype=np.float32, name="data") relu = ops.relu(param, name="relu") - function = Model(relu, [param], "TestFunction") - assert len(function.outputs) == 1 - assert function.get_result_index(function.outputs[0]) == 0 + model = Model(relu, [param], "TestModel") + assert len(model.outputs) == 1 + assert model.get_result_index(model.outputs[0]) == 0 def test_get_result_index_invalid(): shape1 = PartialShape([1]) param1 = ops.parameter(shape1, dtype=np.float32, name="data1") relu1 = ops.relu(param1, name="relu1") - function = Model(relu1, [param1], "TestFunction") + model = Model(relu1, [param1], "TestModel") shape2 = PartialShape([2]) param2 = ops.parameter(shape2, dtype=np.float32, name="data2") relu2 = ops.relu(param2, name="relu2") invalid_output = relu2.outputs()[0] - assert len(function.outputs) == 1 - assert function.get_result_index(invalid_output) == -1 + assert len(model.outputs) == 1 + assert model.get_result_index(invalid_output) == -1 def test_parameter_index(): input_shape = PartialShape([1]) param = ops.parameter(input_shape, dtype=np.float32, name="data") relu = ops.relu(param, name="relu") - function = Model(relu, [param], "TestFunction") - assert function.get_parameter_index(param) == 0 + model = Model(relu, [param], "TestModel") + assert model.get_parameter_index(param) == 0 def test_parameter_index_invalid(): shape1 = PartialShape([1]) param1 = ops.parameter(shape1, dtype=np.float32, name="data1") relu = ops.relu(param1, name="relu") - function = Model(relu, [param1], "TestFunction") + model = Model(relu, [param1], "TestModel") shape2 = PartialShape([2]) param2 = ops.parameter(shape2, dtype=np.float32, name="data2") - assert function.get_parameter_index(param2) == -1 + assert model.get_parameter_index(param2) == -1 def test_replace_parameter(): @@ -265,31 +169,29 @@ def test_replace_parameter(): param2 = ops.parameter(shape2, dtype=np.float32, name="data") relu = ops.relu(param1, name="relu") - function = Model(relu, [param1], "TestFunction") - param_index = function.get_parameter_index(param1) - function.replace_parameter(param_index, param2) - assert function.get_parameter_index(param2) == param_index - assert function.get_parameter_index(param1) == -1 - - -def test_evaluate(): + model = Model(relu, [param1], "TestModel") + param_index = model.get_parameter_index(param1) + model.replace_parameter(param_index, param2) + assert model.get_parameter_index(param2) == param_index + assert model.get_parameter_index(param1) == -1 + + +@pytest.mark.parametrize(("args1", "args2", "expectation", "raise_msg"), [ + (Tensor("float32", Shape([2, 1])), + [Tensor(np.array([2, 1], dtype=np.float32).reshape(2, 1)), + Tensor(np.array([3, 7], dtype=np.float32).reshape(2, 1))], does_not_raise(), ""), + (Tensor("float32", Shape([2, 1])), + [Tensor("float32", Shape([3, 1])), + Tensor("float32", Shape([3, 1]))], pytest.raises(RuntimeError), "Cannot evaluate model!"), +]) +def test_evaluate(args1, args2, expectation, raise_msg): model = generate_add_model() - input1 = np.array([2, 1], dtype=np.float32).reshape(2, 1) - input2 = np.array([3, 7], dtype=np.float32).reshape(2, 1) - out_tensor = Tensor("float32", Shape([2, 1])) - - assert model.evaluate([out_tensor], [Tensor(input1), Tensor(input2)]) - assert np.allclose(out_tensor.data, np.array([5, 8]).reshape(2, 1)) - - -def test_evaluate_invalid_input_shape(): - model = generate_add_model() - with pytest.raises(RuntimeError) as e: - assert model.evaluate( - [Tensor("float32", Shape([2, 1]))], - [Tensor("float32", Shape([3, 1])), Tensor("float32", Shape([3, 1]))], - ) - assert "Cannot evaluate model!" in str(e.value) + with expectation as e: + out_tensor = args1 + assert model.evaluate([out_tensor], args2) + assert np.allclose(out_tensor.data, np.array([5, 8]).reshape(2, 1)) + if e is not None: + assert raise_msg in str(e.value) def test_get_batch(): @@ -308,7 +210,7 @@ def test_get_batch_chwn(): param3 = ops.parameter(Shape([3, 1, 3, 4]), dtype=np.float32, name="data3") add = ops.add(param1, param2) add2 = ops.add(add, param3) - model = Model(add2, [param1, param2, param3], "TestFunction") + model = Model(add2, [param1, param2, param3], "TestModel") param_method = model.get_parameters()[0] param_attr = model.parameters[0] param_method.set_layout(Layout("CHWN")) @@ -316,7 +218,8 @@ def test_get_batch_chwn(): assert get_batch(model) == 4 -def test_set_batch_dimension(): +@pytest.mark.parametrize("batch_arg", [Dimension(1), 1]) +def test_set_batch(batch_arg): model = generate_add_model() model_param1_method = model.get_parameters()[0] model_param2_method = model.get_parameters()[1] @@ -327,28 +230,7 @@ def test_set_batch_dimension(): model_param1_attr.set_layout(Layout("NC")) assert get_batch(model) == 2 # set batch to 1 - set_batch(model, Dimension(1)) - assert get_batch(model) == 1 - # check if shape of param 1 has changed - assert model_param1_method.get_output_shape(0) == PartialShape([1, 1]) - assert model_param1_attr.get_output_shape(0) == PartialShape([1, 1]) - # check if shape of param 2 has not changed - assert model_param2_method.get_output_shape(0) == PartialShape([2, 1]) - assert model_param2_attr.get_output_shape(0) == PartialShape([2, 1]) - - -def test_set_batch_int(): - model = generate_add_model() - model_param1_method = model.get_parameters()[0] - model_param2_method = model.get_parameters()[1] - model_param1_attr = model.parameters[0] - model_param2_attr = model.parameters[1] - # check batch == 2 - model_param1_method.set_layout(Layout("NC")) - model_param1_attr.set_layout(Layout("NC")) - assert get_batch(model) == 2 - # set batch to 1 - set_batch(model, 1) + set_batch(model, batch_arg) assert get_batch(model) == 1 # check if shape of param 1 has changed assert model_param1_method.get_output_shape(0) == PartialShape([1, 1]) @@ -511,7 +393,7 @@ def check_rt_info(model): relu1.get_output_tensor(0).set_names({"relu_t1"}) assert "relu_t1" in relu1.get_output_tensor(0).names relu2 = ops.relu(relu1, name="relu2") - model = Model(relu2, [param], "TestFunction") + model = Model(relu2, [param], "TestModel") assert model is not None @@ -594,7 +476,7 @@ def check_rt_info(model): relu1.get_output_tensor(0).set_names({"relu_t1"}) assert "relu_t1" in relu1.get_output_tensor(0).names relu2 = ops.relu(relu1, name="relu2") - model = Model(relu2, [param], "TestFunction") + model = Model(relu2, [param], "TestModel") assert model is not None @@ -666,3 +548,21 @@ def test_model_get_raw_address(): assert model._get_raw_address() == model_with_same_addr._get_raw_address() assert model._get_raw_address() != model_different._get_raw_address() + + +def test_model_add_remove_variable(): + model = generate_model_with_memory(input_shape=Shape([2, 1]), data_type=Type.f32) + + var_info = VariableInfo() + var_info.data_shape = PartialShape([2, 1]) + var_info.data_type = Type.f32 + var_info.variable_id = "v1" + variable_1 = Variable(var_info) + + assert len(model.get_variables()) == 1 + model.add_variables([variable_1]) + assert len(model.get_variables()) == 2 + variable_by_id = model.get_variable_by_id("var_id_667") + assert variable_by_id.info.variable_id == "var_id_667" + model.remove_variable(variable_1) + assert len(model.get_variables()) == 1 diff --git a/src/bindings/python/tests/test_runtime/test_properties.py b/src/bindings/python/tests/test_runtime/test_properties.py index 6a76ccb57cb6ab..44d38fb4afeabd 100644 --- a/src/bindings/python/tests/test_runtime/test_properties.py +++ b/src/bindings/python/tests/test_runtime/test_properties.py @@ -110,6 +110,14 @@ def test_deprecation(): (log.Level.TRACE, "Level.TRACE", 4), ), ), + ( + intel_auto.SchedulePolicy, + ( + (intel_auto.SchedulePolicy.ROUND_ROBIN, "SchedulePolicy.ROUND_ROBIN", 0), + (intel_auto.SchedulePolicy.DEVICE_PRIORITY, "SchedulePolicy.DEVICE_PRIORITY", 1), + (intel_auto.SchedulePolicy.DEFAULT, "SchedulePolicy.DEVICE_PRIORITY", 1), + ), + ), ], ) def test_properties_enums(ov_enum, expected_values): diff --git a/src/bindings/python/tests/test_runtime/test_infer_request.py b/src/bindings/python/tests/test_runtime/test_sync_infer_request.py similarity index 79% rename from src/bindings/python/tests/test_runtime/test_infer_request.py rename to src/bindings/python/tests/test_runtime/test_sync_infer_request.py index cc0bce2073da04..27a6503f16fff8 100644 --- a/src/bindings/python/tests/test_runtime/test_infer_request.py +++ b/src/bindings/python/tests/test_runtime/test_sync_infer_request.py @@ -15,7 +15,6 @@ Core, CompiledModel, InferRequest, - AsyncInferQueue, Model, Layout, PartialShape, @@ -27,17 +26,7 @@ from openvino.preprocess import PrePostProcessor from tests import skip_need_mock_op -from tests.utils.helpers import generate_image, get_relu_model - - -def create_model_with_memory(input_shape, data_type): - input_data = ops.parameter(input_shape, name="input_data", dtype=data_type) - rv = ops.read_value(input_data, "var_id_667", data_type, input_shape) - add = ops.add(rv, input_data, name="MemoryAdd") - node = ops.assign(add, "var_id_667") - res = ops.result(add, "res") - model = Model(results=[res], sinks=[node], parameters=[input_data], name="name") - return model +from tests.utils.helpers import generate_image, get_relu_model, generate_model_with_memory def create_simple_request_and_inputs(device): @@ -483,54 +472,6 @@ def test_async_single_input(device, ov_type, numpy_dtype, share_inputs): assert np.array_equal(request.get_output_tensor().data, np.abs(tensor1.data)) -@pytest.mark.parametrize("share_inputs", [True, False]) -def test_infer_queue(device, share_inputs): - jobs = 8 - num_request = 4 - core = Core() - model = get_relu_model() - compiled_model = core.compile_model(model, device) - infer_queue = AsyncInferQueue(compiled_model, num_request) - jobs_done = [{"finished": False, "latency": 0} for _ in range(jobs)] - - def callback(request, job_id): - jobs_done[job_id]["finished"] = True - jobs_done[job_id]["latency"] = request.latency - - img = None - - if not share_inputs: - img = generate_image() - infer_queue.set_callback(callback) - assert infer_queue.is_ready() - - for i in range(jobs): - if share_inputs: - img = generate_image() - infer_queue.start_async({"data": img}, i, share_inputs=share_inputs) - infer_queue.wait_all() - assert all(job["finished"] for job in jobs_done) - assert all(job["latency"] > 0 for job in jobs_done) - - -def test_infer_queue_iteration(device): - core = Core() - param = ops.parameter([10]) - model = Model(ops.relu(param), [param]) - compiled_model = core.compile_model(model, device) - infer_queue = AsyncInferQueue(compiled_model, 1) - assert isinstance(infer_queue, Iterable) - for infer_req in infer_queue: - assert isinstance(infer_req, InferRequest) - - it = iter(infer_queue) - infer_request = next(it) - assert isinstance(infer_request, InferRequest) - assert infer_request.userdata is None - with pytest.raises(StopIteration): - next(it) - - def test_get_compiled_model(device): core = Core() param = ops.parameter([10]) @@ -547,119 +488,6 @@ def test_get_compiled_model(device): assert np.allclose(ref[0], test[0]) -def test_infer_queue_userdata_is_empty(device): - core = Core() - param = ops.parameter([10]) - model = Model(ops.relu(param), [param]) - compiled_model = core.compile_model(model, device) - infer_queue = AsyncInferQueue(compiled_model, 1) - assert infer_queue.userdata == [None] - - -def test_infer_queue_userdata_is_empty_more_jobs(device): - core = Core() - param = ops.parameter([10]) - model = Model(ops.relu(param), [param]) - compiled_model = core.compile_model(model, device) - infer_queue = AsyncInferQueue(compiled_model, 5) - assert infer_queue.userdata == [None, None, None, None, None] - - -def test_infer_queue_fail_on_cpp_model(device): - jobs = 6 - num_request = 4 - core = Core() - model = get_relu_model() - compiled_model = core.compile_model(model, device) - infer_queue = AsyncInferQueue(compiled_model, num_request) - - def callback(request, _): - request.get_tensor("Unknown") - - img = generate_image() - infer_queue.set_callback(callback) - - with pytest.raises(RuntimeError) as e: - for _ in range(jobs): - infer_queue.start_async({"data": img}) - infer_queue.wait_all() - - assert "Port for tensor name Unknown was not found" in str(e.value) - - -def test_infer_queue_fail_on_py_model(device): - jobs = 1 - num_request = 1 - core = Core() - model = get_relu_model() - compiled_model = core.compile_model(model, device) - infer_queue = AsyncInferQueue(compiled_model, num_request) - - def callback(request, _): - request = request + 21 - - img = generate_image() - infer_queue.set_callback(callback) - - with pytest.raises(TypeError) as e: - for _ in range(jobs): - infer_queue.start_async({"data": img}) - infer_queue.wait_all() - - assert "unsupported operand type(s) for +" in str(e.value) - - -@skip_need_mock_op -@pytest.mark.parametrize("with_callback", [False, True]) -def test_infer_queue_fail_in_inference(device, with_callback): - jobs = 6 - num_request = 4 - core = Core() - data = ops.parameter([10], dtype=np.float32, name="data") - k_op = ops.parameter(Shape([]), dtype=np.int32, name="k") - emb = ops.topk(data, k_op, axis=0, mode="max", sort="value") - model = Model(emb, [data, k_op]) - compiled_model = core.compile_model(model, device) - infer_queue = AsyncInferQueue(compiled_model, num_request) - - def callback(request, _): - pytest.fail("Callback should not be called") - - if with_callback: - infer_queue.set_callback(callback) - - data_tensor = Tensor(np.arange(10).astype(np.float32)) - k_tensor = Tensor(np.array(11, dtype=np.int32)) - - with pytest.raises(RuntimeError) as e: - for _ in range(jobs): - infer_queue.start_async({"data": data_tensor, "k": k_tensor}) - infer_queue.wait_all() - - assert "Can not clone with new dims" in str(e.value) - - -def test_infer_queue_get_idle_handle(device): - param = ops.parameter([10]) - model = Model(ops.relu(param), [param]) - core = Core() - compiled_model = core.compile_model(model, device) - queue = AsyncInferQueue(compiled_model, 2) - niter = 10 - - for _ in range(len(queue)): - queue.start_async() - queue.wait_all() - for request in queue: - assert request.wait_for(0) - - for _ in range(niter): - idle_id = queue.get_idle_request_id() - assert queue[idle_id].wait_for(0) - queue.start_async() - queue.wait_all() - - @pytest.mark.parametrize("data_type", [np.float32, np.int32, @@ -677,7 +505,7 @@ def test_query_state_write_buffer(device, input_shape, data_type, mode): from openvino import Tensor from openvino.runtime.utils.types import get_dtype - model = create_model_with_memory(input_shape, data_type) + model = generate_model_with_memory(input_shape, data_type) model.validate_nodes_and_infer_types() compiled_model = core.compile_model(model=model, device_name=device) request = compiled_model.create_infer_request() @@ -723,33 +551,6 @@ def test_get_results(device, share_inputs): assert np.array_equal(results[output], request.results[output]) -@pytest.mark.parametrize("share_inputs", [True, False]) -def test_results_async_infer(device, share_inputs): - jobs = 8 - num_request = 4 - core = Core() - model = get_relu_model() - compiled_model = core.compile_model(model, device) - infer_queue = AsyncInferQueue(compiled_model, num_request) - jobs_done = [{"finished": False, "latency": 0} for _ in range(jobs)] - - def callback(request, job_id): - jobs_done[job_id]["finished"] = True - jobs_done[job_id]["latency"] = request.latency - - img = generate_image() - infer_queue.set_callback(callback) - for i in range(jobs): - infer_queue.start_async({"data": img}, i, share_inputs=share_inputs) - infer_queue.wait_all() - - request = compiled_model.create_infer_request() - outputs = request.infer({0: img}) - - for i in range(num_request): - assert np.allclose(list(outputs.values()), list(infer_queue[i].results.values())) - - @pytest.mark.skipif( os.environ.get("TEST_DEVICE") not in ["GPU"], reason="Device dependent test", @@ -989,48 +790,6 @@ def __array__(self): assert np.array_equal(request.get_output_tensor().data, np.abs(input_data)) -@pytest.mark.parametrize("share_inputs", [True, False]) -def test_array_like_input_async_infer_queue(device, share_inputs): - class ArrayLikeObject: - # Array-like object accepted by np.array to test inputs similar to torch tensor and tf.Tensor - def __init__(self, array) -> None: - self.data = array - - def __array__(self): - return self.data - - jobs = 8 - ov_type = Type.f32 - input_shape = [2, 2] - input_data = np.ascontiguousarray([[-2, -1], [0, 1]]) - param = ops.parameter(input_shape, ov_type) - layer = ops.abs(param) - model = Model([layer], [param]) - core = Core() - compiled_model = core.compile_model(model, "CPU") - - model_input_object = ArrayLikeObject(input_data) - model_input_list = [[ArrayLikeObject(deepcopy(input_data))] for _ in range(jobs)] - - # Test single array-like object in AsyncInferQueue.start_async() - infer_queue_object = AsyncInferQueue(compiled_model, jobs) - for _i in range(jobs): - infer_queue_object.start_async(model_input_object) - infer_queue_object.wait_all() - - for i in range(jobs): - assert np.array_equal(infer_queue_object[i].get_output_tensor().data, np.abs(input_data)) - - # Test list of array-like objects in AsyncInferQueue.start_async() - infer_queue_list = AsyncInferQueue(compiled_model, jobs) - for i in range(jobs): - infer_queue_list.start_async(model_input_list[i], share_inputs=share_inputs) - infer_queue_list.wait_all() - - for i in range(jobs): - assert np.array_equal(infer_queue_list[i].get_output_tensor().data, np.abs(input_data)) - - def test_convert_infer_request(device): request, arr_1, arr_2 = create_simple_request_and_inputs(device) inputs = [arr_1, arr_2] @@ -1176,27 +935,6 @@ def test_not_writable_inputs_infer(device, share_inputs, input_data, change_flag assert not np.shares_memory(input_data[0], input_tensor.data) -@pytest.mark.parametrize("shared_flag", [True, False]) -def test_shared_memory_deprecation(device, shared_flag): - compiled, request, _, input_data = abs_model_with_data(device, Type.f32, np.float32) - - with pytest.warns(FutureWarning, match="`shared_memory` is deprecated and will be removed in 2024.0"): - _ = compiled(input_data, shared_memory=shared_flag) - - with pytest.warns(FutureWarning, match="`shared_memory` is deprecated and will be removed in 2024.0"): - _ = request.infer(input_data, shared_memory=shared_flag) - - with pytest.warns(FutureWarning, match="`shared_memory` is deprecated and will be removed in 2024.0"): - request.start_async(input_data, shared_memory=shared_flag) - request.wait() - - queue = AsyncInferQueue(compiled, jobs=1) - - with pytest.warns(FutureWarning, match="`shared_memory` is deprecated and will be removed in 2024.0"): - queue.start_async(input_data, shared_memory=shared_flag) - queue.wait_all() - - @pytest.mark.parametrize("share_inputs", [True, False]) @pytest.mark.parametrize("share_outputs", [True, False]) @pytest.mark.parametrize("is_positional", [True, False]) diff --git a/src/bindings/python/tests/test_runtime/test_tensor.py b/src/bindings/python/tests/test_runtime/test_tensor.py index 6f6b9c199512ae..4b0a4755a1347f 100644 --- a/src/bindings/python/tests/test_runtime/test_tensor.py +++ b/src/bindings/python/tests/test_runtime/test_tensor.py @@ -38,7 +38,7 @@ (ov.Type.i4, np.int8), ], ) -def test_init_with_ngraph(ov_type, numpy_dtype): +def test_init_with_ov_type(ov_type, numpy_dtype): ov_tensors = [] ov_tensors.append(ov.Tensor(type=ov_type, shape=ov.Shape([1, 3, 32, 32]))) ov_tensors.append(ov.Tensor(type=ov_type, shape=[1, 3, 32, 32])) diff --git a/src/bindings/python/tests/utils/helpers.py b/src/bindings/python/tests/utils/helpers.py index bfd791fd1a87aa..ed687b33f52f9d 100644 --- a/src/bindings/python/tests/utils/helpers.py +++ b/src/bindings/python/tests/utils/helpers.py @@ -206,7 +206,17 @@ def generate_add_model() -> openvino._pyopenvino.Model: param1 = ops.parameter(Shape([2, 1]), dtype=np.float32, name="data1") param2 = ops.parameter(Shape([2, 1]), dtype=np.float32, name="data2") add = ops.add(param1, param2) - return Model(add, [param1, param2], "TestFunction") + return Model(add, [param1, param2], "TestModel") + + +def generate_model_with_memory(input_shape, data_type) -> openvino._pyopenvino.Model: + input_data = ops.parameter(input_shape, name="input_data", dtype=data_type) + rv = ops.read_value(input_data, "var_id_667", data_type, input_shape) + add = ops.add(rv, input_data, name="MemoryAdd") + node = ops.assign(add, "var_id_667") + res = ops.result(add, "res") + model = Model(results=[res], sinks=[node], parameters=[input_data], name="TestModel") + return model def create_filename_for_test(test_name, tmp_path, is_xml_path=False, is_bin_path=False): diff --git a/src/cmake/openvino.cmake b/src/cmake/openvino.cmake index ad73269d475748..80ff498d548182 100644 --- a/src/cmake/openvino.cmake +++ b/src/cmake/openvino.cmake @@ -21,7 +21,7 @@ endif() add_library(${TARGET_NAME} $ $ - $ + $ $ $ $ @@ -96,9 +96,9 @@ export(TARGETS ${TARGET_NAME} NAMESPACE openvino:: APPEND FILE "${CMAKE_BINARY_DIR}/OpenVINOTargets.cmake") install(TARGETS ${TARGET_NAME} EXPORT OpenVINOTargets - RUNTIME DESTINATION ${OV_CPACK_RUNTIMEDIR} COMPONENT ${OV_CPACK_COMP_CORE} - ARCHIVE DESTINATION ${OV_CPACK_ARCHIVEDIR} COMPONENT ${OV_CPACK_COMP_CORE} - LIBRARY DESTINATION ${OV_CPACK_LIBRARYDIR} COMPONENT ${OV_CPACK_COMP_CORE} + RUNTIME DESTINATION ${OV_CPACK_RUNTIMEDIR} COMPONENT ${OV_CPACK_COMP_CORE} ${OV_CPACK_COMP_CORE_EXCLUDE_ALL} + ARCHIVE DESTINATION ${OV_CPACK_ARCHIVEDIR} COMPONENT ${OV_CPACK_COMP_CORE} ${OV_CPACK_COMP_CORE_EXCLUDE_ALL} + LIBRARY DESTINATION ${OV_CPACK_LIBRARYDIR} COMPONENT ${OV_CPACK_COMP_CORE} ${OV_CPACK_COMP_CORE_EXCLUDE_ALL} NAMELINK_COMPONENT ${OV_CPACK_COMP_CORE_DEV} INCLUDES DESTINATION ${OV_CPACK_INCLUDEDIR} ${OV_CPACK_INCLUDEDIR}/ie) @@ -147,7 +147,8 @@ ov_cpack_add_component(${OV_CPACK_COMP_CORE_DEV} if(ENABLE_PLUGINS_XML) install(FILES $/plugins.xml DESTINATION ${OV_CPACK_PLUGINSDIR} - COMPONENT ${OV_CPACK_COMP_CORE}) + COMPONENT ${OV_CPACK_COMP_CORE} + ${OV_CPACK_COMP_CORE_EXCLUDE_ALL}) if(ENABLE_TESTS) # for InferenceEngineUnitTest @@ -164,7 +165,8 @@ install(EXPORT OpenVINOTargets FILE OpenVINOTargets.cmake NAMESPACE openvino:: DESTINATION ${OV_CPACK_OPENVINO_CMAKEDIR} - COMPONENT ${OV_CPACK_COMP_CORE_DEV}) + COMPONENT ${OV_CPACK_COMP_CORE_DEV} + ${OV_CPACK_COMP_CORE_DEV_EXCLUDE_ALL}) # build tree @@ -227,12 +229,14 @@ configure_file("${OpenVINO_SOURCE_DIR}/cmake/templates/OpenVINOConfig-version.cm install(FILES "${CMAKE_BINARY_DIR}/share/InferenceEngineConfig.cmake" "${CMAKE_BINARY_DIR}/InferenceEngineConfig-version.cmake" DESTINATION ${OV_CPACK_IE_CMAKEDIR} - COMPONENT ${OV_CPACK_COMP_CORE_DEV}) + COMPONENT ${OV_CPACK_COMP_CORE_DEV} + ${OV_CPACK_COMP_CORE_DEV_EXCLUDE_ALL}) install(FILES "${CMAKE_BINARY_DIR}/share/OpenVINOConfig.cmake" "${CMAKE_BINARY_DIR}/OpenVINOConfig-version.cmake" DESTINATION ${OV_CPACK_OPENVINO_CMAKEDIR} - COMPONENT ${OV_CPACK_COMP_CORE_DEV}) + COMPONENT ${OV_CPACK_COMP_CORE_DEV} + ${OV_CPACK_COMP_CORE_DEV_EXCLUDE_ALL}) # # Generate and install openvino.pc pkg-config file @@ -313,5 +317,6 @@ if(ENABLE_PKGCONFIG_GEN) install(FILES "${pkgconfig_out}" DESTINATION "${OV_CPACK_RUNTIMEDIR}/pkgconfig" - COMPONENT ${OV_CPACK_COMP_CORE_DEV}) + COMPONENT ${OV_CPACK_COMP_CORE_DEV} + ${OV_CPACK_COMP_CORE_DEV_EXCLUDE_ALL}) endif() diff --git a/src/common/low_precision_transformations/tests/fold_fake_quantize_in_transformations.cpp b/src/common/low_precision_transformations/tests/fold_fake_quantize_in_transformations.cpp index 91d101559c6b36..566806e7ee7af1 100644 --- a/src/common/low_precision_transformations/tests/fold_fake_quantize_in_transformations.cpp +++ b/src/common/low_precision_transformations/tests/fold_fake_quantize_in_transformations.cpp @@ -115,11 +115,20 @@ class FoldFakeQuantizeInTransformations } }; +#ifdef OPENVINO_ARCH_ARM64 +// Ticket: 122660 +TEST_P(FoldFakeQuantizeInTransformations, DISABLED_CompareFunctions) { + actualFunction->validate_nodes_and_infer_types(); + auto res = compare_functions(actualFunction, referenceFunction, true, false); + ASSERT_TRUE(res.first) << res.second; +} +#else TEST_P(FoldFakeQuantizeInTransformations, CompareFunctions) { actualFunction->validate_nodes_and_infer_types(); auto res = compare_functions(actualFunction, referenceFunction, true, false); ASSERT_TRUE(res.first) << res.second; } +#endif const std::vector testValues = { { diff --git a/src/common/preprocessing/src/CMakeLists.txt b/src/common/preprocessing/src/CMakeLists.txt index 9e3fd2d3789a02..80eafe970a6455 100644 --- a/src/common/preprocessing/src/CMakeLists.txt +++ b/src/common/preprocessing/src/CMakeLists.txt @@ -217,7 +217,8 @@ ov_developer_package_export_targets(TARGET ${TARGET_NAME}) if(BUILD_SHARED_LIBS) install(TARGETS ${TARGET_NAME} - LIBRARY DESTINATION ${OV_CPACK_PLUGINSDIR} COMPONENT ${OV_CPACK_COMP_CORE}) + LIBRARY DESTINATION ${OV_CPACK_PLUGINSDIR} COMPONENT ${OV_CPACK_COMP_CORE} + ${OV_CPACK_COMP_CORE_EXCLUDE_ALL}) else() ov_install_static_lib(${TARGET_NAME} ${OV_CPACK_COMP_CORE}) endif() diff --git a/src/common/snippets/include/snippets/generator.hpp b/src/common/snippets/include/snippets/generator.hpp index 32b44b9e6abc81..1647ccf1e771a0 100644 --- a/src/common/snippets/include/snippets/generator.hpp +++ b/src/common/snippets/include/snippets/generator.hpp @@ -29,7 +29,7 @@ class Generator; class LoweringResult { friend class Generator; // Some emitters rely on other precompiled kernels. - // We need to keep the pointers to such emitters alive, so the kernels would still be accessible at runtime. + // We need to keep the pointers to such emitters alive, so the kernels or nodes would still be accessible at runtime. std::vector> m_saved_emitters{}; public: diff --git a/src/common/snippets/include/snippets/lowered/linear_ir.hpp b/src/common/snippets/include/snippets/lowered/linear_ir.hpp index 22ffc7ff36d324..73d3ab573e6254 100644 --- a/src/common/snippets/include/snippets/lowered/linear_ir.hpp +++ b/src/common/snippets/include/snippets/lowered/linear_ir.hpp @@ -14,6 +14,18 @@ namespace ov { namespace snippets { namespace lowered { +// Snippets performance count mode +// Disabled - default, w/o perf count for snippets +// Chrono - perf count with chrono call. This is a universal method, and support multi-thread case to output perf count data for each thread. +// BackendSpecific - perf count provided by backend. This is for device specific requirment. +// For example, in sake of more light overhead and more accurate result, x86 CPU specific mode via read RDTSC register is implemented, +// which take ~50ns, while Chrono mode take 260ns for a pair of perf count start and perf count end execution, on ICX. This mode only support single thread. +enum PerfCountMode { + Disabled, + Chrono, + BackendSpecific, +}; + class Config { public: // True if the lowered Emitters need to be accessed during runtime. Normally they're destroyed after code emission. @@ -21,6 +33,7 @@ class Config { // True if we should check runtime info for nodes to call specific needed transformations bool m_need_fill_tail_register = false; size_t m_loop_depth = 1; + PerfCountMode perf_count_mode = PerfCountMode::Disabled; // Some Subgraphs doesn't support domain optimization due to operations' semantics bool m_enable_domain_optimization = false; // Minimal advised work amount for parallel execution. @@ -50,7 +63,7 @@ class LinearIR { LinearIR() = default; LinearIR(const std::shared_ptr& m, const std::shared_ptr& factory, Config config = {}); - ExpressionPtr create_expression(const std::shared_ptr& n, const std::vector& inputs); + ExpressionPtr create_expression(const std::shared_ptr& n, const std::vector& inputs) const; std::shared_ptr clone() const; static LinearIR::container deep_copy_range(LinearIR::container::const_iterator begin, diff --git a/src/common/snippets/include/snippets/lowered/loop_manager.hpp b/src/common/snippets/include/snippets/lowered/loop_manager.hpp index b530e96c7d7a2d..93d1620f5fdbe7 100644 --- a/src/common/snippets/include/snippets/lowered/loop_manager.hpp +++ b/src/common/snippets/include/snippets/lowered/loop_manager.hpp @@ -21,9 +21,7 @@ class LinearIR::LoopManager { struct LoopPort { LoopPort() = default; - LoopPort(const ExpressionPort& port, bool is_scheduled = true) - : expr_port(std::make_shared(port)), is_incremented(is_scheduled) {} - + LoopPort(const ExpressionPort& port, bool is_incremented = true, size_t dim_idx = 0); std::shared_ptr clone_with_new_expr(const ExpressionPtr& new_expr) const; friend bool operator==(const LoopPort& lhs, const LoopPort& rhs); @@ -37,33 +35,68 @@ class LinearIR::LoopManager { int64_t ptr_increment = 0; int64_t finalization_offset = 0; int64_t data_size = 0; + size_t dim_idx = 0; // The numeration starts from the end (dim_idx = 0 -> is the most inner dimension) }; class LoopInfo { public: + enum {UNDEFINED_DIM_IDX = std::numeric_limits::max()}; LoopInfo() = default; - LoopInfo(size_t work_amount, size_t increment, size_t dim_idx, + LoopInfo(size_t work_amount, size_t increment, const std::vector& entries, - const std::vector& exits) - : work_amount(work_amount), increment(increment), dim_idx(dim_idx), - entry_points(entries), exit_points(exits), outer_splited_loop(false) {} - LoopInfo(size_t work_amount, size_t increment, size_t dim_idx, + const std::vector& exits, + bool outer_splited_loop = false) + : m_work_amount(work_amount), m_increment(increment), + m_entry_points(entries), m_exit_points(exits), m_outer_splited_loop(outer_splited_loop) {} + LoopInfo(size_t work_amount, size_t increment, const std::vector& entries, - const std::vector& exits); + const std::vector& exits, + bool outer_splited_loop = false); std::shared_ptr clone_with_new_expr(const ExressionMap& expr_map) const; - size_t work_amount = 0; - size_t increment = 0; - size_t dim_idx = 0; // The numeration begins from the end (dim_idx = 0 -> is the most inner dimension) + // Returns dimension index if dimension indices for all entry and exit points are equal, and UNDEFINED_DIM_IDX otherwise + size_t get_dim_idx() const; + size_t get_work_amount() const; + size_t get_increment() const; + const std::vector& get_entry_points() const; + const std::vector& get_exit_points() const; + bool get_outer_splited_loop() const; + + /** + * \brief Inserts a separate body for first loop iteration processing if needed. + * Can also modify both main and first iter loop bodies. + * TODO: replace this temporary solution when ticket 119851 is implemented + * + * \param linear_ir LIR which should be modified + * \param loop_end_it iterator on LoopEnd expression for which the handler is called + * + * \return bool value which indicates whether the linear_ir was changed or not. + */ + using FirstIterHandler = std::function; + const FirstIterHandler& get_first_iter_handler() const; + + // Sets dim_idx to all entry and exit points + void set_dim_idx(size_t dim_idx); + void set_work_amount(size_t work_amount); + void set_increment(size_t increment); + void set_entry_points(std::vector entry_points); + void set_exit_points(std::vector exit_points); + void set_outer_splited_loop(bool outer_splited_loop); + void set_first_iter_handler(FirstIterHandler handler); + + private: + size_t m_work_amount = 0; + size_t m_increment = 0; // The order of entry and exit expressions is important: // - The position before first entry expr is Loop Begin position // - The position after last exit expr is Loop End position // Note: Scalars aren't entry expressions but can be before first entry expr in Linear IR - std::vector entry_points = {}; - std::vector exit_points = {}; + std::vector m_entry_points = {}; + std::vector m_exit_points = {}; // True if this Loop is outer Loop for nested Loops that splits the same dimension - bool outer_splited_loop = false; + bool m_outer_splited_loop = false; + FirstIterHandler m_first_iter_handler = nullptr; }; using LoopInfoPtr = std::shared_ptr; @@ -83,11 +116,14 @@ class LinearIR::LoopManager { // Return Loop ID template size_t mark_loop(LinearIR::constExprIt loop_begin_pos, - LinearIR::constExprIt loop_end_pos, - size_t work_amount, size_t work_amount_increment, size_t dim_idx, - const std::vector& entries, - const std::vector& exits) { - const auto loop_info = std::make_shared(work_amount, work_amount_increment, dim_idx, entries, exits); + LinearIR::constExprIt loop_end_pos, + size_t work_amount, + size_t work_amount_increment, + size_t dim_idx, + const std::vector& entries, + const std::vector& exits) { + const auto loop_info = std::make_shared(work_amount, work_amount_increment, entries, exits); + loop_info->set_dim_idx(dim_idx); const auto loop_id = this->add_loop_info(loop_info); for (auto expr_it = loop_begin_pos; expr_it != loop_end_pos; ++expr_it) { insert_loop_id(*expr_it, loop_id); @@ -95,6 +131,30 @@ class LinearIR::LoopManager { return loop_id; } + template + size_t mark_loop(LinearIR::constExprIt loop_begin_pos, + LinearIR::constExprIt loop_end_pos, + size_t work_amount, + size_t increment, + const std::vector& entries, + const std::vector& exits) { + const auto loop_info = std::make_shared(work_amount, increment, entries, exits); + const auto loop_id = this->add_loop_info(loop_info); + for (auto expr_it = loop_begin_pos; expr_it != loop_end_pos; ++expr_it) { + insert_loop_id(*expr_it, loop_id); + } + return loop_id; + } + + size_t replace_with_new_loop(const LinearIR& linear_ir, + LinearIR::constExprIt loop_begin_pos, + LinearIR::constExprIt loop_end_pos, + size_t work_amount, + size_t increment, + const std::vector& entries, + const std::vector& exits, + const size_t old_id); + void fuse_loops(const LinearIR& linear_ir, size_t loop_id_upper, size_t loop_id_lower, bool fuse_into_upper = true); void fuse_loops(LinearIR::constExprIt loop_begin_target, LinearIR::constExprIt loop_end_target, size_t loop_id_upper, size_t loop_id_lower, bool fuse_into_upper = true); diff --git a/src/common/snippets/include/snippets/lowered/pass/init_loops.hpp b/src/common/snippets/include/snippets/lowered/pass/init_loops.hpp index 39c51f890f2f5d..e98c6caaafa49c 100644 --- a/src/common/snippets/include/snippets/lowered/pass/init_loops.hpp +++ b/src/common/snippets/include/snippets/lowered/pass/init_loops.hpp @@ -25,14 +25,9 @@ class InitLoops : public Pass { bool run(LinearIR& linear_ir) override; private: - static void init_ptr_increments(std::vector& loop_inputs, - std::vector& loop_outputs, - size_t work_amount, size_t dim_idx); - static void init_finalization_offsets(std::vector& loop_inputs, - std::vector& loop_outputs, - size_t work_amount); - static void init_element_type_sizes(std::vector& loop_inputs, - std::vector& loop_outputs); + static void init_ptr_increments(const LinearIR::LoopManager::LoopInfoPtr& loop_info); + static void init_finalization_offsets(const LinearIR::LoopManager::LoopInfoPtr& loop_info); + static void init_element_type_sizes(const LinearIR::LoopManager::LoopInfoPtr& loop_info); }; } // namespace pass diff --git a/src/common/snippets/include/snippets/lowered/pass/insert_perf_count.hpp b/src/common/snippets/include/snippets/lowered/pass/insert_perf_count.hpp new file mode 100644 index 00000000000000..8478a0d931f182 --- /dev/null +++ b/src/common/snippets/include/snippets/lowered/pass/insert_perf_count.hpp @@ -0,0 +1,33 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include "pass.hpp" + +#include "snippets/op/perf_count.hpp" + +namespace ov { +namespace snippets { +namespace lowered { +namespace pass { + +/** + * @interface InsertPerfCount + * @brief Insert PerfCountBegin node after last parameter and insert PerfCountEnd node before first result. + * This is a illustration transformation to enable perf count in snippets. + * Developers could modify this to insert perf count pairs around interested sequence of nodes. + * @ingroup snippets + */ +class InsertPerfCount: public Pass { +public: + OPENVINO_RTTI("InsertPerfCount", "Pass") + InsertPerfCount() = default; + bool run(LinearIR& linear_ir) override; +}; + +} // namespace pass +} // namespace lowered +} // namespace snippets +} // namespace ov diff --git a/src/common/snippets/include/snippets/lowered/pass/insert_tail_loop.hpp b/src/common/snippets/include/snippets/lowered/pass/insert_tail_loop.hpp index 8801d4c7130ec4..faafd8186b8448 100644 --- a/src/common/snippets/include/snippets/lowered/pass/insert_tail_loop.hpp +++ b/src/common/snippets/include/snippets/lowered/pass/insert_tail_loop.hpp @@ -7,6 +7,7 @@ #include "pass.hpp" #include "snippets/op/loop.hpp" +#include "snippets/lowered/loop_manager.hpp" namespace ov { namespace snippets { @@ -23,21 +24,26 @@ class InsertTailLoop : public Pass { public: OPENVINO_RTTI("InsertTailLoop", "Pass") bool run(LinearIR& linear_ir) override; + static LinearIR::container copy_loop(const LinearIR& linear_ir, const size_t loop_id); + + static constexpr size_t existing_subtensor_value = SIZE_MAX; + static void propagate_updated_subtensor_through_loop(const LinearIR& linear_ir, + const LinearIR::LoopManager::LoopInfoPtr& loop_info, + LinearIR::container::const_iterator begin, + LinearIR::container::const_iterator end, + const size_t new_dim_value = existing_subtensor_value); private: - static std::shared_ptr create_tail_loop(LinearIR& linear_ir, - LinearIR::constExprIt vector_begin, - LinearIR::constExprIt vector_end, - LinearIR::constExprIt& tail_begin, - LinearIR::constExprIt& tail_end, - const std::shared_ptr& vector_loop_end, - bool need_vector_loop, - size_t tail_size, const std::vector& tail_finalization_offsets); + static void create_tail_loop(LinearIR& linear_ir, + LinearIR::constExprIt begin, + LinearIR::constExprIt end, + const std::shared_ptr& loop_end, + bool need_vector_loop, + size_t tail_size); static void tail_transformations(LinearIR& linear_ir, LinearIR::constExprIt tail_begin, LinearIR::constExprIt tail_end, size_t tail_size); - static bool optimize_single_evaluation(const std::shared_ptr& loop); }; } // namespace pass diff --git a/src/common/snippets/include/snippets/lowered/pass/optimize_loop_single_evaluation.hpp b/src/common/snippets/include/snippets/lowered/pass/optimize_loop_single_evaluation.hpp new file mode 100644 index 00000000000000..9ac4181e61e861 --- /dev/null +++ b/src/common/snippets/include/snippets/lowered/pass/optimize_loop_single_evaluation.hpp @@ -0,0 +1,30 @@ +// Copyright (C) 2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include "pass.hpp" + +namespace ov { +namespace snippets { +namespace lowered { +namespace pass { + +/** + * @interface OptimizeLoopSingleEvaluation + * @brief Does the following optimizations if the Loop body can be executed only once: + * - sets evaluate_once parameter to true + * - moves all ptr arithmetic to finalization offsets + * @ingroup snippets + */ +class OptimizeLoopSingleEvaluation : public Pass { +public: + OPENVINO_RTTI("OptimizeLoopSingleEvaluation", "Pass") + bool run(LinearIR& linear_ir) override; +}; + +} // namespace pass +} // namespace lowered +} // namespace snippets +} // namespace ov diff --git a/src/common/snippets/include/snippets/op/broadcastload.hpp b/src/common/snippets/include/snippets/op/broadcastload.hpp index 540be423bb8eb5..a46311d30151ff 100644 --- a/src/common/snippets/include/snippets/op/broadcastload.hpp +++ b/src/common/snippets/include/snippets/op/broadcastload.hpp @@ -21,7 +21,7 @@ class BroadcastLoad : public MemoryAccess { public: OPENVINO_OP("BroadcastLoad", "SnippetsOpset", ov::snippets::op::MemoryAccess); - BroadcastLoad(const Output& x, ov::PartialShape output_shape, size_t offset = 0lu); + BroadcastLoad(const Output& x, ov::Dimension bcast_dimension, size_t offset = 0lu); BroadcastLoad() = default; size_t get_offset() const { return get_input_offset(0); } @@ -29,7 +29,8 @@ class BroadcastLoad : public MemoryAccess { bool visit_attributes(AttributeVisitor& visitor) override; std::shared_ptr clone_with_new_inputs(const OutputVector& new_args) const override; void validate_and_infer_types() override; - ov::PartialShape get_output_shape() {return output_shape;} + const ov::Dimension& get_bcast_dimension() {return bcast_dimension;} + void set_bcast_dimension(ov::Dimension new_dim) {bcast_dimension = std::move(new_dim);} // Note:BroadcastMove and BroadcastLoad are implemented as separate classes, // but have identical shapeInfer semantics. In order to avoid code duplication, @@ -39,7 +40,7 @@ class BroadcastLoad : public MemoryAccess { explicit ShapeInfer(const std::shared_ptr& n) : BroadcastShapeInfer(n) {} }; private: - ov::PartialShape output_shape; + ov::Dimension bcast_dimension; }; } // namespace op diff --git a/src/common/snippets/include/snippets/op/broadcastmove.hpp b/src/common/snippets/include/snippets/op/broadcastmove.hpp index d915fbc286330a..95579c174841c5 100644 --- a/src/common/snippets/include/snippets/op/broadcastmove.hpp +++ b/src/common/snippets/include/snippets/op/broadcastmove.hpp @@ -20,7 +20,7 @@ class BroadcastMove : public ov::op::Op { public: OPENVINO_OP("BroadcastMove", "SnippetsOpset"); - BroadcastMove(const Output& x, ov::PartialShape output_shape); + BroadcastMove(const Output& x, ov::Dimension bcast_dimension); BroadcastMove() = default; bool visit_attributes(AttributeVisitor& visitor) override; @@ -28,7 +28,8 @@ class BroadcastMove : public ov::op::Op { std::shared_ptr clone_with_new_inputs(const OutputVector& new_args) const override; void validate_and_infer_types() override; - ov::PartialShape get_output_shape() {return output_shape;} + const ov::Dimension& get_bcast_dimension() {return bcast_dimension;} + void set_bcast_dimension(ov::Dimension new_dim) {bcast_dimension = std::move(new_dim);} // Note:BroadcastMove and BroadcastLoad are implemented as separate classes, // but have identical shapeInfer semantics. In order to avoid code duplication, // we created dummy ShapeInfer classes that are essentially instantiations @@ -38,7 +39,7 @@ class BroadcastMove : public ov::op::Op { }; protected: - ov::PartialShape output_shape; + ov::Dimension bcast_dimension; }; } // namespace op diff --git a/src/common/snippets/include/snippets/op/buffer.hpp b/src/common/snippets/include/snippets/op/buffer.hpp index 9f522ed3d45688..d0e1152b589486 100644 --- a/src/common/snippets/include/snippets/op/buffer.hpp +++ b/src/common/snippets/include/snippets/op/buffer.hpp @@ -5,6 +5,7 @@ #pragma once #include "openvino/op/op.hpp" +#include "snippets/shape_inference/shape_inference.hpp" namespace ov { namespace snippets { @@ -13,13 +14,10 @@ namespace op { /** * @interface Buffer * @brief This is a base class for memory storage. - * If Buffer has a parent, the operation is for intermediate data storage - IntermediateMemory type. - * Otherwise, the operation is for allocation of new empty memory with shape `m_shape` - NewMemory type * Notes: * - All buffers with the same ID in a graph have the same memory pointer. So if we have a few buffers, * each the corresponding MemoryAccess op for Buffer should have offset for common memory pointer of this Buffer * - Buffer should be a single consumer for operation output port - * @param m_type - type of Buffer: IntermediateMemory/NewMemory * @param m_shape - output allocation shape for Buffer with type NewMemory * @param m_offset - offset in common Buffer scratchpad * @param m_id - Buffer ID in common Buffer system @@ -29,21 +27,11 @@ class Buffer : public ov::op::Op { public: OPENVINO_OP("Buffer", "SnippetsOpset"); Buffer() = default; - Buffer(const ov::Shape& shape, ov::element::Type element_type = ov::element::u8, size_t id = 0); - Buffer(const ov::Output& arg, const ov::Shape& shape, size_t id = 0); - Buffer(const ov::Output& arg, int32_t allocation_rank = -1, size_t id = 0); + Buffer(const OutputVector& arguments, const ov::Shape& shape, size_t id, ov::element::Type element_type = ov::element::u8); bool visit_attributes(AttributeVisitor& visitor) override; - void validate_and_infer_types() override; - std::shared_ptr clone_with_new_inputs(const OutputVector& new_args) const override; - - enum Type { - NewMemory, - IntermediateMemory - }; size_t get_id() const { return m_id; } - Type get_type() const { return m_type; } int64_t get_offset() const { return m_offset; } void set_id(size_t id) { m_id = id; } const ov::Shape& get_allocation_shape() const { return m_shape; } @@ -51,17 +39,55 @@ class Buffer : public ov::op::Op { void set_offset(int64_t offset) { m_offset = offset; } size_t get_byte_size() const; - void set_element_type(ov::element::Type element_type); - - bool is_intermediate_memory() const { return m_type == Type::IntermediateMemory; } - bool is_new_memory() const { return m_type == Type::NewMemory; } - -private: - Type m_type = Type::IntermediateMemory; +protected: ov::Shape m_shape = {}; - int64_t m_offset = 0; size_t m_id = 0; // Default ID - 0. All Buffers are from the same set ov::element::Type m_element_type = ov::element::u8; // u8 - default 1 byte + int64_t m_offset = 0; +}; + +/** + * @interface IntermediateMemoryBuffer + * @brief Represents an intermediate memory storage operation. It always has a parent. + * @ingroup snippets + * + */ +class IntermediateMemoryBuffer : public Buffer { +public: + OPENVINO_OP("IntermediateMemoryBuffer", "SnippetsOpset", Buffer); + IntermediateMemoryBuffer() = default; + IntermediateMemoryBuffer(const ov::Output& arg, const ov::Shape& shape, size_t id = 0); + IntermediateMemoryBuffer(const ov::Output& arg, int32_t allocation_rank = -1, size_t id = 0); + + void validate_and_infer_types() override; + std::shared_ptr clone_with_new_inputs(const OutputVector& new_args) const override; + +private: + ov::Shape compute_shape_from_allocation_rank(const ov::Output& arg, int32_t allocation_rank); +}; + +/** + * @interface NewMemoryBuffer + * @brief Represents a new empty memory for allocation with specified shape. It has no parent operations. + * @ingroup snippets + * + */ +class NewMemoryBuffer : public Buffer { +public: + OPENVINO_OP("NewMemoryBuffer", "SnippetsOpset", Buffer); + NewMemoryBuffer() = default; + NewMemoryBuffer(const ov::Shape& shape, size_t id = 0, ov::element::Type element_type = ov::element::u8); + + void validate_and_infer_types() override; + void set_element_type(ov::element::Type element_type); + std::shared_ptr clone_with_new_inputs(const OutputVector& new_args) const override; + + class ShapeInfer : public IShapeInferSnippets { + ov::Shape m_shape; + public: + explicit ShapeInfer(const std::shared_ptr& n); + Result infer(const std::vector& input_shapes) override; + }; }; } // namespace op diff --git a/src/common/snippets/include/snippets/op/loop.hpp b/src/common/snippets/include/snippets/op/loop.hpp index 1fd51649fc65d1..1740c00ccc3a64 100644 --- a/src/common/snippets/include/snippets/op/loop.hpp +++ b/src/common/snippets/include/snippets/op/loop.hpp @@ -56,11 +56,8 @@ class LoopBegin : public LoopBase { * @param args vector of input values + LoopBegin, all values except for the LoopBegin are passed directly to output. * @param work_amount total number of evaluations to be processed by the loop * @param increment number of evaluations processed in one iteration of the loop. - * @param apply_increment describes which data pointers attributed to the loop should be incremented on every iteration. - * should be used when Loop is connected to Parameters and/or Results. If apply_increment[i] == true then i-th i/o data - * pointer will be incremented by work_amount*data_size on every iteration. - * @param ptr_increments specifies i/o pointer increment performed on every iteration. This is an alternative to - * apply_increments, which enables more flexibility. + * @param is_incremented describes which data pointers attributed to the loop should be incremented on every iteration. + * @param ptr_increments specifies i/o pointer increment performed on every iteration if the following is_incremented[i] is true * @param finalization_offsets pointer increments that are be applied to i/o pointers before exiting the loop * @param id the identifier of Loop in Loop system in LoopManager * @ingroup snippets @@ -69,16 +66,14 @@ class LoopEnd : public LoopBase { public: OPENVINO_OP("LoopEnd", "SnippetsOpset", LoopBase); LoopEnd(const Output& loop_begin, size_t work_amount, size_t work_amount_increment, - std::vector apply_increment, std::vector finalization_offsets, - std::vector element_type_sizes, size_t input_num, size_t output_num, size_t id); - LoopEnd(const Output& loop_begin, size_t work_amount, size_t work_amount_increment, - std::vector ptr_increments, std::vector finalization_offsets, + std::vector is_incremented, std::vector ptr_increments, std::vector finalization_offsets, std::vector element_type_sizes, size_t input_num, size_t output_num, size_t id); LoopEnd() = default; std::shared_ptr get_loop_begin(); void validate_and_infer_types() override; std::shared_ptr clone_with_new_inputs(const OutputVector& inputs) const override; const std::vector& get_finalization_offsets() const; + const std::vector& get_is_incremented() const; const std::vector& get_ptr_increments() const; const std::vector& get_element_type_sizes() const; size_t get_input_num() const; @@ -91,6 +86,7 @@ class LoopEnd : public LoopBase { void set_work_amount(size_t new_work_amount); void set_increment(size_t new_increment); void set_evaluate_once(bool once); + void set_id(size_t new_id); // Used to propagate information about Loop structure, needed to simplify some optimizations. For example, // to skip pointer increments when outer Loop is empty, and work_amount == vector_size (one inner vector Loop) // true by default, the optimizations enabled if it's false; @@ -102,6 +98,7 @@ class LoopEnd : public LoopBase { bool visit_attributes(AttributeVisitor& visitor) override; private: + std::vector m_is_incremented = {}; std::vector m_ptr_increments = {}; std::vector m_finalization_offsets = {}; std::vector m_element_type_sizes = {}; diff --git a/src/common/snippets/include/snippets/op/perf_count.hpp b/src/common/snippets/include/snippets/op/perf_count.hpp new file mode 100644 index 00000000000000..be7eccfc5b44aa --- /dev/null +++ b/src/common/snippets/include/snippets/op/perf_count.hpp @@ -0,0 +1,93 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include "openvino/op/op.hpp" +#include "openvino/runtime/threading/thread_local.hpp" + +namespace ov { +namespace snippets { +namespace op { + +/** + * @interface PerfCountBeginBase + * @brief Base class for PerfCountBegin and PerfCountRdtscBegin(cpu) + * @ingroup snippets + */ +class PerfCountBeginBase : public ov::op::Op { +public: + OPENVINO_OP("PerfCountBeginBase", "SnippetsOpset"); + PerfCountBeginBase(const std::vector>& args); + PerfCountBeginBase() = default; + + void validate_and_infer_types() override; + bool visit_attributes(AttributeVisitor& visitor) override; + +protected: + void validate_and_infer_types_except_PerfCountEnd(); +}; + +/** + * @interface PerfCountEndBase + * @brief Base class for PerfCountEnd and PerfCountRdtscEnd + * @ingroup snippets + */ +class PerfCountEndBase : public ov::op::Op { +public: + OPENVINO_OP("PerfCountEndBase", "SnippetsOpset"); + PerfCountEndBase(const std::vector>& args); + PerfCountEndBase() = default; + + void validate_and_infer_types() override; + bool visit_attributes(AttributeVisitor& visitor) override; +}; + +/** + * @interface PerfCountBegin + * @brief Performance count start time with chrono call + * @ingroup snippets + */ +class PerfCountBegin : public PerfCountBeginBase { +public: + OPENVINO_OP("PerfCountBegin", "SnippetsOpset", PerfCountBeginBase); + PerfCountBegin(); + + std::shared_ptr clone_with_new_inputs(const OutputVector& inputs) const override; + + void set_start_time(); + std::chrono::high_resolution_clock::time_point& get_start_time(); + +private: + ov::threading::ThreadLocal start_time_stamp; +}; + +/** + * @interface PerfCountEnd + * @brief Performance count end time and duration with chrono call + * @ingroup snippets + */ +class PerfCountEnd : public PerfCountEndBase { +public: + OPENVINO_OP("PerfCountEnd", "SnippetsOpset", PerfCountEndBase); + PerfCountEnd(const Output& pc_begin); + PerfCountEnd() = default; + ~PerfCountEnd() { + output_perf_count(); + } + void output_perf_count(); + std::shared_ptr clone_with_new_inputs(const OutputVector& inputs) const override; + + void init_pc_begin(); + void set_accumulated_time(); + +private: + ov::threading::ThreadLocal accumulation; + ov::threading::ThreadLocal iteration; + std::shared_ptr m_pc_begin = nullptr; +}; + +} // namespace op +} // namespace snippets +} // namespace ov diff --git a/src/common/snippets/include/snippets/shape_inference/shape_infer_instances.hpp b/src/common/snippets/include/snippets/shape_inference/shape_infer_instances.hpp index af69ad905111e8..43ad0aa3d5ac97 100644 --- a/src/common/snippets/include/snippets/shape_inference/shape_infer_instances.hpp +++ b/src/common/snippets/include/snippets/shape_inference/shape_infer_instances.hpp @@ -21,7 +21,7 @@ class NumpyBroadcastShapeInfer : public IShapeInferSnippets { template class BroadcastShapeInfer : public IShapeInferSnippets { - VectorDims::value_type m_broadcasted_dim; + std::shared_ptr broadcast_op; public: explicit BroadcastShapeInfer(const std::shared_ptr& n); Result infer(const std::vector& input_shapes) override; diff --git a/src/common/snippets/include/snippets/snippets_isa.hpp b/src/common/snippets/include/snippets/snippets_isa.hpp index ba85ae68eeb634..b2c6d46b722b0b 100644 --- a/src/common/snippets/include/snippets/snippets_isa.hpp +++ b/src/common/snippets/include/snippets/snippets_isa.hpp @@ -25,6 +25,7 @@ #include "op/brgemm.hpp" #include "op/vector_buffer.hpp" #include "op/rank_normalization.hpp" +#include "op/perf_count.hpp" namespace ov { namespace snippets { diff --git a/src/common/snippets/include/snippets/snippets_isa_tbl.hpp b/src/common/snippets/include/snippets/snippets_isa_tbl.hpp index 351770bdab746f..163329d63948e6 100644 --- a/src/common/snippets/include/snippets/snippets_isa_tbl.hpp +++ b/src/common/snippets/include/snippets/snippets_isa_tbl.hpp @@ -24,6 +24,9 @@ OV_OP(Scalar, ov::snippets::op) OV_OP(Nop, ov::snippets::op) OV_OP(RankNormalization, ov::snippets::op) +OV_OP(PerfCountBegin, ov::snippets::op) +OV_OP(PerfCountEnd, ov::snippets::op) + // Layout-oblivious from opset1 // opset completeness diff --git a/src/common/snippets/src/generator.cpp b/src/common/snippets/src/generator.cpp index cede4c4a6e532c..c0a2583aef23b4 100644 --- a/src/common/snippets/src/generator.cpp +++ b/src/common/snippets/src/generator.cpp @@ -6,7 +6,9 @@ #include "snippets/lowered/linear_ir.hpp" #include "snippets/lowered/pass/assign_registers.hpp" +#include "snippets/lowered/pass/cleanup_loop_offsets.hpp" #include "snippets/lowered/pass/insert_tail_loop.hpp" +#include "snippets/lowered/pass/optimize_loop_single_evaluation.hpp" #include "snippets/op/kernel.hpp" @@ -25,8 +27,17 @@ void Generator::generate(lowered::LinearIR& linear_ir, LoweringResult& result, c return get_op_reg_type(op); }; lowered::pass::PassPipeline lowered_pipeline; + // Note: the order of all passes in this pipeline must not be changed since they have hard dependencies + // 1. InsertTailLoop must be called after AssignRegisters since tail loop expressions must have the same + // assigned registers as the corresponding ops in the main body. + // 2. CleanupLoopOffsets must be called after InsertTailLoop to avoid violating the proportionality of the pointer increments + // (this might happen if tail loop and main loop have different increments) + // 3. OptimizeLoopSingleEvaluation must be called after CleanupLoopOffsets + // since CleanupLoopOffsets can't handle loops with evaluate_once = true lowered_pipeline.register_pass(reg_type_mapper); lowered_pipeline.register_pass(); + lowered_pipeline.register_pass(); + lowered_pipeline.register_pass(); lowered_pipeline.run(linear_ir); linear_ir.init_emitters(target); @@ -44,7 +55,8 @@ void Generator::generate(lowered::LinearIR& linear_ir, LoweringResult& result, c } OV_ITT_TASK_NEXT(GENERATE, "::GetSnippet") - // Note: some emitters use precompiled kernels. They need to be saved, so the kernels are accessible at runtime. + // 1. some emitters use precompiled kernels. They need to be saved, so the kernels are accessible at runtime. + // 2. perf count node as field of emitter should be alive at runtime. if (linear_ir.get_config().m_save_expressions) { for (const auto& expr : linear_ir) { const auto& emitter = expr->get_emitter(); @@ -65,8 +77,11 @@ Generator::opRegType Generator::get_op_reg_type(const std::shared_ptr& op) std::dynamic_pointer_cast(op) || std::dynamic_pointer_cast(op) || std::dynamic_pointer_cast(op) || - std::dynamic_pointer_cast(op) || - std::dynamic_pointer_cast(op)) + std::dynamic_pointer_cast(op) || + std::dynamic_pointer_cast(op) || + std::dynamic_pointer_cast(op) || + std::dynamic_pointer_cast(op) || + std::dynamic_pointer_cast(op)) return gpr2gpr; else if (std::dynamic_pointer_cast(op) || std::dynamic_pointer_cast(op)) diff --git a/src/common/snippets/src/lowered/linear_ir.cpp b/src/common/snippets/src/lowered/linear_ir.cpp index 8f5978638364d3..2fe20eba4d8ee0 100644 --- a/src/common/snippets/src/lowered/linear_ir.cpp +++ b/src/common/snippets/src/lowered/linear_ir.cpp @@ -67,7 +67,7 @@ ExpressionPtr LinearIR::create_expression(const std::shared_ptr& n, const return ExpressionFactory::build(n, *this, model); } -ExpressionPtr LinearIR::create_expression(const std::shared_ptr& n, const std::vector& inputs) { +ExpressionPtr LinearIR::create_expression(const std::shared_ptr& n, const std::vector& inputs) const { return ExpressionFactory::build(n, inputs, *this); } @@ -124,8 +124,9 @@ LinearIR::container LinearIR::deep_copy_range(LinearIR::container::const_iterato OPENVINO_ASSERT(expression_map.empty(), "deep_copy_range expects empty expression_map as an input"); LinearIR::container result; NodeVector original_nodes; - for (auto it = begin; it != end; it++) + for (auto it = begin; it != end; it++) { original_nodes.push_back((*it)->get_node()); + } // node_map and expr_map map original node pointer (expression) to a new pointer (expression) ngraph::NodeMap node_map; diff --git a/src/common/snippets/src/lowered/loop_manager.cpp b/src/common/snippets/src/lowered/loop_manager.cpp index 7747ec2d247f96..e7e83361ee0a39 100644 --- a/src/common/snippets/src/lowered/loop_manager.cpp +++ b/src/common/snippets/src/lowered/loop_manager.cpp @@ -19,21 +19,38 @@ using LoopManager = LinearIR::LoopManager; using LoopPort = LoopManager::LoopPort; using LoopInfo = LoopManager::LoopInfo; +LoopPort::LoopPort(const ExpressionPort& port, bool is_incremented, size_t dim_idx) + : expr_port(std::make_shared(port)), + is_incremented(is_incremented), + dim_idx(dim_idx) { + OPENVINO_ASSERT(dim_idx < port.get_descriptor_ptr()->get_shape().size(), + "LoopPort dim_idx (", + dim_idx, + ") must be less than the corresponding expression port shape rank (", + port.get_descriptor_ptr()->get_shape().size(), + ")"); +} + std::shared_ptr LoopPort::clone_with_new_expr(const ExpressionPtr& new_expr) const { auto new_loop_port = std::make_shared(*this); new_loop_port->expr_port = expr_port->clone_with_new_expr(new_expr); return new_loop_port; } -LoopInfo::LoopInfo(size_t work_amount, size_t increment, size_t dim_idx, - const std::vector& entries, const std::vector& exits) - : work_amount(work_amount), increment(increment), dim_idx(dim_idx), outer_splited_loop(false) { - entry_points.reserve(entries.size()); - exit_points.reserve(exits.size()); +LinearIR::LoopManager::LoopInfo::LoopInfo(size_t work_amount, + size_t increment, + const std::vector& entries, + const std::vector& exits, + bool outer_splited_loop) + : m_work_amount(work_amount), + m_increment(increment), + m_outer_splited_loop(outer_splited_loop) { + m_entry_points.reserve(entries.size()); + m_exit_points.reserve(exits.size()); for (const auto& port : entries) - entry_points.emplace_back(port); + m_entry_points.emplace_back(port); for (const auto& port : exits) - exit_points.emplace_back(port); + m_exit_points.emplace_back(port); } std::shared_ptr LoopInfo::clone_with_new_expr(const ExressionMap& expr_map) const { @@ -48,33 +65,103 @@ std::shared_ptr LoopInfo::clone_with_new_expr(const ExressionMap& expr } return cloned_port_points; }; - const auto& new_entry_points = clone_loop_ports(entry_points); - const auto& new_exit_points = clone_loop_ports(exit_points); + const auto& new_entry_points = clone_loop_ports(m_entry_points); + const auto& new_exit_points = clone_loop_ports(m_exit_points); - auto new_loop_info = std::make_shared(work_amount, increment, dim_idx, new_entry_points, new_exit_points); - new_loop_info->outer_splited_loop = outer_splited_loop; + return std::make_shared(m_work_amount, m_increment, new_entry_points, new_exit_points, m_outer_splited_loop); +} - return new_loop_info; +size_t LoopInfo::get_work_amount() const { + return m_work_amount; } -std::shared_ptr LoopManager::clone_with_new_expr(const ExressionMap& expr_map) const { - auto new_loop_manager = std::make_shared(); - for (const auto& id_info : m_map) - new_loop_manager->m_map.insert({id_info.first, id_info.second->clone_with_new_expr(expr_map)}); - new_loop_manager->next_id = next_id; - return new_loop_manager; +size_t LoopInfo::get_increment() const { + return m_increment; +} + +const std::vector& LoopInfo::get_entry_points() const { + return m_entry_points; +} + +const std::vector& LoopInfo::get_exit_points() const { + return m_exit_points; +} + +bool LoopInfo::get_outer_splited_loop() const { + return m_outer_splited_loop; +} + +const LoopInfo::FirstIterHandler& LoopInfo::get_first_iter_handler() const { + return m_first_iter_handler; +} + +size_t LinearIR::LoopManager::LoopInfo::get_dim_idx() const { + OPENVINO_ASSERT(!m_entry_points.empty(), "Loop info must have at least one entry point"); + auto equal_dim_idxes = [&](const LinearIR::LoopManager::LoopPort& p) { + return p.dim_idx == m_entry_points[0].dim_idx; + }; + if (std::all_of(m_entry_points.begin(), m_entry_points.end(), equal_dim_idxes) && + std::all_of(m_exit_points.begin(), m_exit_points.end(), equal_dim_idxes)) { + return m_entry_points[0].dim_idx; + } else { + return UNDEFINED_DIM_IDX; + } +} + +void LoopInfo::set_dim_idx(size_t dim_idx) { + auto set_common_dim_idx = [dim_idx](std::vector& ports) { + for (auto& port : ports) + port.dim_idx = dim_idx; + }; + set_common_dim_idx(m_entry_points); + set_common_dim_idx(m_exit_points); +} + +void LoopInfo::set_work_amount(size_t work_amount) { + m_work_amount = work_amount; +} + +void LoopInfo::set_increment(size_t increment) { + m_increment = increment; +} + +void LoopInfo::set_entry_points(std::vector entry_points) { + m_entry_points = std::move(entry_points); +} + +void LoopInfo::set_exit_points(std::vector exit_points) { + m_exit_points = std::move(exit_points);; +} + +void LoopInfo::set_outer_splited_loop(bool outer_splited_loop) { + m_outer_splited_loop = outer_splited_loop; +} + +void LoopInfo::set_first_iter_handler(LoopInfo::FirstIterHandler first_iter_handler) { + m_first_iter_handler = std::move(first_iter_handler); } bool operator==(const LinearIR::LoopManager::LoopPort& lhs, const LinearIR::LoopManager::LoopPort& rhs) { if (&lhs == &rhs) return true; - return lhs.expr_port == rhs.expr_port && lhs.is_incremented == rhs.is_incremented; + return lhs.expr_port == rhs.expr_port && lhs.is_incremented == rhs.is_incremented && lhs.dim_idx == rhs.dim_idx; } bool operator!=(const LinearIR::LoopManager::LoopPort& lhs, const LinearIR::LoopManager::LoopPort& rhs) { return !(lhs == rhs); } bool operator<(const LinearIR::LoopManager::LoopPort& lhs, const LinearIR::LoopManager::LoopPort& rhs) { - return (lhs.expr_port < rhs.expr_port) || (lhs.expr_port == rhs.expr_port && (lhs.is_incremented < rhs.is_incremented)); + return (lhs.expr_port < rhs.expr_port) || + (lhs.expr_port == rhs.expr_port && + (lhs.is_incremented < rhs.is_incremented || + (lhs.is_incremented == rhs.is_incremented && lhs.dim_idx < rhs.dim_idx))); +} + +std::shared_ptr LoopManager::clone_with_new_expr(const ExressionMap& expr_map) const { + auto new_loop_manager = std::make_shared(); + for (const auto& id_info : m_map) + new_loop_manager->m_map.insert({id_info.first, id_info.second->clone_with_new_expr(expr_map)}); + new_loop_manager->next_id = next_id; + return new_loop_manager; } size_t LinearIR::LoopManager::add_loop_info(const LoopInfoPtr &loop) { @@ -113,7 +200,7 @@ void LinearIR::LoopManager::get_loop_bounds(const LinearIR &linear_ir, LinearIR::constExprIt &loop_end_pos, bool loop_ops_inserted) const { const auto loop_info = get_loop_info(loop_id); - get_loop_bounds(linear_ir, loop_info->entry_points, loop_info->exit_points, loop_begin_pos, loop_end_pos, loop_id, loop_ops_inserted); + get_loop_bounds(linear_ir, loop_info->get_entry_points(), loop_info->get_exit_points(), loop_begin_pos, loop_end_pos, loop_id, loop_ops_inserted); } void LinearIR::LoopManager::get_loop_bounds(const LinearIR &linear_ir, @@ -157,8 +244,8 @@ LinearIR::LoopManager::LoopPort LinearIR::LoopManager::get_loop_port_by_expr_por return *it; }; const auto& loop_info = get_loop_info(loop_id); - return expr_port.get_type() == ExpressionPort::Input ? get_loop_port(loop_info->entry_points) - : get_loop_port(loop_info->exit_points); + return expr_port.get_type() == ExpressionPort::Input ? get_loop_port(loop_info->get_entry_points()) + : get_loop_port(loop_info->get_exit_points()); } void LinearIR::LoopManager::get_io_loop_ports(LinearIR::constExprIt loop_begin_pos, @@ -258,6 +345,31 @@ void LinearIR::LoopManager::mark_loop(LinearIR::constExprIt loop_begin_pos, } } +size_t LinearIR::LoopManager::replace_with_new_loop(const LinearIR& linear_ir, + LinearIR::constExprIt loop_begin_pos, + LinearIR::constExprIt loop_end_pos, + size_t work_amount, + size_t increment, + const std::vector& entries, + const std::vector& exits, + const size_t old_id) { + const auto loop_info = std::make_shared(work_amount, increment, entries, exits); + const auto loop_id = this->add_loop_info(loop_info); + for (auto expr_it = loop_begin_pos; expr_it != loop_end_pos; ++expr_it) { + replace_loop_id(*expr_it, old_id, loop_id); + } + + const auto old_loop_info = this->get_loop_info(old_id); + const auto old_loop_begin_pos = linear_ir.find(old_loop_info->get_entry_points().front().expr_port->get_expr()); + const auto old_loop_end_pos = linear_ir.find(old_loop_info->get_exit_points().back().expr_port->get_expr()); + // If new bounds are equal to old loop bounds, this means that old Loop is removed totally from LIR + // In this case old loop info must be completely removed from loop manager + if (loop_begin_pos == old_loop_begin_pos && loop_end_pos == old_loop_end_pos) { + this->remove_loop_info(old_id); + } + return loop_id; +} + void LinearIR::LoopManager::fuse_loops(const LinearIR& linear_ir, size_t loop_id_upper, size_t loop_id_lower, bool fuse_into_upper) { LinearIR::constExprIt loop_begin_target, loop_end_target; get_loop_bounds(linear_ir, fuse_into_upper ? loop_id_lower : loop_id_upper, loop_begin_target, loop_end_target); @@ -272,10 +384,10 @@ void LinearIR::LoopManager::fuse_loops(LinearIR::constExprIt loop_begin_target, const auto& loop_info_upper = m_map[loop_id_upper]; const auto& loop_info_lower = m_map[loop_id_lower]; - auto entry_points_upper = loop_info_upper->entry_points; - auto exit_points_upper = loop_info_upper->exit_points; - auto entry_points_lower = loop_info_lower->entry_points; - auto exit_points_lower = loop_info_lower->exit_points; + auto entry_points_upper = loop_info_upper->get_entry_points(); + auto exit_points_upper = loop_info_upper->get_exit_points(); + auto entry_points_lower = loop_info_lower->get_entry_points(); + auto exit_points_lower = loop_info_lower->get_exit_points(); fuse_loop_ports(exit_points_upper, entry_points_lower, loop_id_upper); std::vector new_entries = entry_points_upper; @@ -284,8 +396,8 @@ void LinearIR::LoopManager::fuse_loops(LinearIR::constExprIt loop_begin_target, new_exits.insert(new_exits.end(), exit_points_lower.begin(), exit_points_lower.end()); auto& loop_info = fuse_into_upper ? loop_info_upper : loop_info_lower; - loop_info->entry_points = new_entries; - loop_info->exit_points = new_exits; + loop_info->set_entry_points(new_entries); + loop_info->set_exit_points(new_exits); const auto& from = fuse_into_upper ? loop_id_lower : loop_id_upper; const auto& to = fuse_into_upper ? loop_id_upper : loop_id_lower; @@ -347,7 +459,7 @@ template<> void LinearIR::LoopManager::update_loop_port(size_t loop_id, const ExpressionPort& actual_port, const std::vector& target_ports, bool is_entry) { const auto& loop_info = get_loop_info(loop_id); - auto& ports = is_entry ? loop_info->entry_points : loop_info->exit_points; + auto ports = is_entry ? loop_info->get_entry_points() : loop_info->get_exit_points(); auto port_it = std::find_if(ports.begin(), ports.end(), [&actual_port](const LoopPort& point) { return *point.expr_port.get() == actual_port; }); // In some cases actual ExpressionPort may not be LoopPort. We shouldn't throw exception here since ExpressionPort is not strong condition as LoopPort @@ -364,19 +476,21 @@ void LinearIR::LoopManager::update_loop_port(size_t loop_id, const ExpressionPor return copy; }); port_it = ports.erase(port_it); - ports.insert(port_it, target_ports.cbegin(), target_ports.cend()); + ports.insert(port_it, target_loop_ports.cbegin(), target_loop_ports.cend()); + is_entry ? loop_info->set_entry_points(ports) : loop_info->set_exit_points(ports); } template<> void LinearIR::LoopManager::update_loop_port(size_t loop_id, const LoopPort& actual_port, const std::vector& target_ports, bool is_entry) { const auto& loop_info = get_loop_info(loop_id); - auto& ports = is_entry ? loop_info->entry_points : loop_info->exit_points; + auto ports = is_entry ? loop_info->get_entry_points() : loop_info->get_exit_points(); auto port_it = std::find_if(ports.begin(), ports.end(), [&actual_port](const LoopPort& point) { return point == actual_port; }); OPENVINO_ASSERT(port_it != ports.end(), "Failed update_loop_port: existing loop ports has not been found"); port_it = ports.erase(port_it); ports.insert(port_it, target_ports.cbegin(), target_ports.cend()); + is_entry ? loop_info->set_entry_points(ports) : loop_info->set_exit_points(ports); } void LinearIR::LoopManager::expression_replacement(constExprIt new_expr_begin, constExprIt new_expr_end, const ExpressionPtr& decomposed_expr, @@ -411,8 +525,8 @@ void LinearIR::LoopManager::sort_loop_ports(LinearIR::constExprIt& loop_begin_po } }; auto loop_info = get_loop_info(loop_id); - const auto& loop_entries = loop_info->entry_points; - const auto& loop_exits = loop_info->exit_points; + const auto& loop_entries = loop_info->get_entry_points(); + const auto& loop_exits = loop_info->get_exit_points(); std::vector entries, exits; entries.reserve(loop_entries.size()); exits.reserve(loop_exits.size()); @@ -421,8 +535,8 @@ void LinearIR::LoopManager::sort_loop_ports(LinearIR::constExprIt& loop_begin_po push(loop_entries, entries, expr); push(loop_exits, exits, expr); } - loop_info->entry_points = entries; - loop_info->exit_points = exits; + loop_info->set_entry_points(entries); + loop_info->set_exit_points(exits); } void LinearIR::LoopManager::insert_loop_id(const ExpressionPtr& expr, size_t new_id, bool before, size_t target_id) { diff --git a/src/common/snippets/src/lowered/pass/allocate_buffers.cpp b/src/common/snippets/src/lowered/pass/allocate_buffers.cpp index d285320701cc62..18ef0d09b9704e 100644 --- a/src/common/snippets/src/lowered/pass/allocate_buffers.cpp +++ b/src/common/snippets/src/lowered/pass/allocate_buffers.cpp @@ -31,20 +31,18 @@ void AllocateBuffers::set_buffer_offset(const ExpressionPtr& buffer_expr, const buffer->set_offset(static_cast(offset)); // Propagate to up: in Store. Buffer can have only one Store - { - if (buffer->is_intermediate_memory()) { - OPENVINO_ASSERT(buffer_expr->get_input_port_connectors().size() == 1, "Buffer with intermediate memory must have one parent"); - const auto& parent_output = buffer_expr->get_input_port_connector(0)->get_source(); - const auto& parent_expr = parent_output.get_expr(); - const auto port = parent_output.get_index(); - const auto& parent_node = parent_expr->get_node(); - auto memory_access = ov::as_type_ptr(parent_node); - if (memory_access && memory_access->is_memory_access_output_port(port)) { - memory_access->set_output_offset(offset, port); - } else { - OPENVINO_THROW( - "Buffer::set_offset() was called when Buffer didn't have the corresponding MemoryAccess op for offset propagation"); - } + if (ov::is_type(buffer)) { + OPENVINO_ASSERT(buffer_expr->get_input_port_connectors().size() == 1, "Buffer with intermediate memory must have one parent"); + const auto& parent_output = buffer_expr->get_input_port_connector(0)->get_source(); + const auto& parent_expr = parent_output.get_expr(); + const auto port = parent_output.get_index(); + const auto& parent_node = parent_expr->get_node(); + auto memory_access = ov::as_type_ptr(parent_node); + if (memory_access && memory_access->is_memory_access_output_port(port)) { + memory_access->set_output_offset(offset, port); + } else { + OPENVINO_THROW( + "Buffer::set_offset() was called when Buffer didn't have the corresponding MemoryAccess op for offset propagation"); } } // Propagate to down: in Load. Buffer can have several Load diff --git a/src/common/snippets/src/lowered/pass/assign_registers.cpp b/src/common/snippets/src/lowered/pass/assign_registers.cpp index 7755cfebe7cc38..d49cf8d63155a7 100644 --- a/src/common/snippets/src/lowered/pass/assign_registers.cpp +++ b/src/common/snippets/src/lowered/pass/assign_registers.cpp @@ -64,7 +64,7 @@ bool AssignRegisters::run(LinearIR& linear_ir) { } else if (const auto& buffer = ov::as_type_ptr(op)) { const auto buffer_id = buffer->get_id(); // All buffers have one common data pointer - if (buffer->is_intermediate_memory()) { + if (ov::is_type(buffer)) { manually_assigned_gprs[expr->get_input_port_connector(0)] = static_cast(num_results + num_parameters + buffer_id); } diff --git a/src/common/snippets/src/lowered/pass/cleanup_loop_offsets.cpp b/src/common/snippets/src/lowered/pass/cleanup_loop_offsets.cpp index 8d4a529c1667ca..79c9a115718c1f 100644 --- a/src/common/snippets/src/lowered/pass/cleanup_loop_offsets.cpp +++ b/src/common/snippets/src/lowered/pass/cleanup_loop_offsets.cpp @@ -48,16 +48,23 @@ bool CleanupLoopOffsets::run(LinearIR& linear_ir) { const auto& found = per_port_connector_offset.find(managed_connector); if (found != per_port_connector_offset.end()) { // Since data ptr is incremented on [ptr_increment x increment], - // we should guarantee proportionality of ptr shifts + // we should guarantee proportionality of ptr shifts. + // If the data ptr can't be proportionally shifted, the optimization is not applied // For example, // Inner Loop: WA = 32, Inc = 1, ptr_increment[0] = 20, final_offset[0] = -640 // Outer Loop: WA = 70, Inc = 32, ptr_increment[0] = 20, final_offset[0] = -1400 // To save data ptr shift proportionality, we have to calculate so: // outer_ptr_increment[0] = (inner_final_offset[0] + outer_ptr_increment[0] * outer_Inc) / outer_Inc // outer_ptr_increment[0] = (-640 + 20 x 32) / 32 = 0 - outer_ptr_increments[i] = (fin_offsets[found->second] + outer_ptr_increments[i] * outer_increment) / outer_increment; - fin_offsets[found->second] = 0; - is_modified = true; + + const auto full_outer_increment = outer_ptr_increments[i] * outer_increment; + const auto new_final_outer_increment = full_outer_increment + fin_offsets[found->second]; + + if (new_final_outer_increment % outer_increment == 0) { + outer_ptr_increments[i] = new_final_outer_increment / outer_increment; + fin_offsets[found->second] = 0; + is_modified = true; + } } } outer_loop_end->set_ptr_increments(outer_ptr_increments); diff --git a/src/common/snippets/src/lowered/pass/fuse_loops.cpp b/src/common/snippets/src/lowered/pass/fuse_loops.cpp index 39fe42c49dd810..1738d6d8fe9574 100644 --- a/src/common/snippets/src/lowered/pass/fuse_loops.cpp +++ b/src/common/snippets/src/lowered/pass/fuse_loops.cpp @@ -28,7 +28,7 @@ bool FuseLoops::loop_ports_are_compatible(const LinearIR::LoopManagerPtr& loop_m const size_t loop_lower_id, const size_t loop_upper_id) { const auto loop_lower = loop_manager->get_loop_info(loop_lower_id); - for (const auto& entry : loop_lower->entry_points) { + for (const auto& entry : loop_lower->get_entry_points()) { const auto& src_port = entry.expr_port->get_port_connector_ptr()->get_source(); if (is_loop_id_found(src_port.get_expr()->get_loop_ids(), loop_upper_id)) { if (!entry.is_incremented) @@ -36,14 +36,16 @@ bool FuseLoops::loop_ports_are_compatible(const LinearIR::LoopManagerPtr& loop_m auto src_loop_port = loop_manager->get_loop_port_by_expr_port(src_port, loop_upper_id); if (!src_loop_port.is_incremented) return false; + if (entry.dim_idx != src_loop_port.dim_idx) + return false; } } return true; } bool FuseLoops::can_be_fused(const LoopInfoPtr& loop_current, const LoopInfoPtr& loop_target) { - auto current_work_amount = loop_current->work_amount; - auto target_work_amount = loop_target->work_amount; + auto current_work_amount = loop_current->get_work_amount(); + auto target_work_amount = loop_target->get_work_amount(); // Loop fusion is supported only if Loops have equal increments and the equal/broadcastable work amounts. // Note: For example, Broadcastable work amounts are possible in the following case: // Relu_0 [16x1] Relu_1 [16x128] @@ -54,9 +56,8 @@ bool FuseLoops::can_be_fused(const LoopInfoPtr& loop_current, const LoopInfoPtr& // - Relu_1 and Add with work amount `128` and increment `vector size` // We can fuse them into one Loop with work amount `128` and increment `vector size` const auto supported_work_amount = current_work_amount == target_work_amount || current_work_amount == 1 || target_work_amount == 1; - const auto supported_increment = loop_current->increment == loop_target->increment; - const auto supported_dim_idxs = loop_current->dim_idx == loop_target->dim_idx; - return supported_work_amount && supported_increment && supported_dim_idxs; + const auto supported_increment = loop_current->get_increment() == loop_target->get_increment(); + return supported_work_amount && supported_increment; } void FuseLoops::move(LinearIR& linear_ir, const LinearIR::LoopManagerPtr& loop_manager, size_t loop_id, @@ -102,8 +103,8 @@ bool FuseLoops::fuse_upper_into_current(LinearIR& linear_ir, const LinearIR::Loo // We can fuse Loop_up to Loop_down only in cases when other consumers of Loop_up are after Loop_down // Because Loop_up should be explicitly moved before Loop_down in linear IR, and we must save control dependency bool is_fusion_allowed = true; - for (size_t i = 0; i < loop_target->exit_points.size() && is_fusion_allowed; ++i) { - const auto target_exit_point = loop_target->exit_points[i]; + for (size_t i = 0; i < loop_target->get_exit_points().size() && is_fusion_allowed; ++i) { + const auto target_exit_point = loop_target->get_exit_points()[i]; const auto consumer_inputs = target_exit_point.expr_port->get_connected_ports(); for (const auto& consumer_input : consumer_inputs) { const auto& consumer = consumer_input.get_expr(); @@ -124,10 +125,10 @@ bool FuseLoops::fuse_upper_into_current(LinearIR& linear_ir, const LinearIR::Loo loop_manager->get_loop_bounds(linear_ir, target_loop_id, target_loop_begin_pos, target_loop_end_pos); loop_manager->fuse_loops(target_loop_begin_pos, target_loop_end_pos, target_loop_id, current_loop_id, false); // Update work_amount for Loop (increment is constant because increments must be the identical for fusion): - loop_current->work_amount = std::max(loop_current->work_amount, loop_target->work_amount); + loop_current->set_work_amount(std::max(loop_current->get_work_amount(), loop_target->get_work_amount())); // If one of the Loops is outer for nested loops that splits the same dimension, // after fusion new common Loop save this status - loop_current->outer_splited_loop = loop_current->outer_splited_loop || loop_target->outer_splited_loop; + loop_current->set_outer_splited_loop(loop_current->get_outer_splited_loop() || loop_target->get_outer_splited_loop()); const auto insertion_place = current_loop_begin_pos; const auto is_move_needed = target_loop_end_pos != current_loop_begin_pos; @@ -152,8 +153,8 @@ bool FuseLoops::fuse_lower_into_current(LinearIR& linear_ir, const LinearIR::Loo // We can fuse Loop_down to Loop_up only in cases when other parents of Loop_down are before Loop_up // Because Loop_down should be explicitly moved after Loop_up in linear IR, and we must save control dependency bool is_fusion_allowed = true; - for (size_t i = 0; i < loop_target->entry_points.size() && is_fusion_allowed; ++i) { - const auto target_entry_port = loop_target->entry_points[i]; + for (size_t i = 0; i < loop_target->get_entry_points().size() && is_fusion_allowed; ++i) { + const auto target_entry_port = loop_target->get_entry_points()[i]; const auto parent_expr_output = *target_entry_port.expr_port->get_connected_ports().begin(); const auto& parent_expr = parent_expr_output.get_expr(); if (ov::is_type(parent_expr->get_node()) || parent_expr == current_exit_point->get_expr()) @@ -169,10 +170,10 @@ bool FuseLoops::fuse_lower_into_current(LinearIR& linear_ir, const LinearIR::Loo loop_manager->get_loop_bounds(linear_ir, target_loop_id, target_loop_begin_pos, target_loop_end_pos); loop_manager->fuse_loops(target_loop_begin_pos, target_loop_end_pos, current_loop_id, target_loop_id); // Update work_amount for Loop (increment is constant because increments must be the identical for fusion): - loop_current->work_amount = std::max(loop_current->work_amount, loop_target->work_amount); + loop_current->set_work_amount(std::max(loop_current->get_work_amount(), loop_target->get_work_amount())); // If one of the Loops is outer for nested loops that splits the same dimension, // after fusion new common Loop save this status - loop_current->outer_splited_loop = loop_current->outer_splited_loop || loop_target->outer_splited_loop; + loop_current->set_outer_splited_loop(loop_current->get_outer_splited_loop() || loop_target->get_outer_splited_loop()); const auto insertion_place = current_loop_end_pos; const auto is_move_needed = insertion_place != target_loop_begin_pos; @@ -221,7 +222,7 @@ bool FuseLoops::run(LinearIR& linear_ir) { // Loop_0 (Upper) | // | => | // Loop_1 (Current) Loop_0 + Loop_1 => new `Loop_1` - auto entry_points = current_loop_info->entry_points; + auto entry_points = current_loop_info->get_entry_points(); bool was_fusion_up = false; for (size_t in_port = 0; in_port < entry_points.size() && !was_fusion_up; ++in_port) { const auto entry_point = entry_points[in_port]; @@ -259,13 +260,13 @@ bool FuseLoops::run(LinearIR& linear_ir) { } // If Loops were fused and there are new entry_points, we should check for possible fusion again - if (was_fusion_up && entry_points != current_loop_info->entry_points) + if (was_fusion_up && entry_points != current_loop_info->get_entry_points()) continue; // Loop_0 (Current) Loop_0 + Loop_1 => new `Loop_0` // | => | // Loop_1 (Lower) | - auto exit_points = current_loop_info->exit_points; + auto exit_points = current_loop_info->get_exit_points(); bool was_fusion_down = false; for (size_t out_port = 0; out_port < exit_points.size() && !was_fusion_down; ++out_port) { const auto exit_point = exit_points[out_port]; diff --git a/src/common/snippets/src/lowered/pass/identify_buffers.cpp b/src/common/snippets/src/lowered/pass/identify_buffers.cpp index a92cd875daa5a5..7b19693c7c3b7c 100644 --- a/src/common/snippets/src/lowered/pass/identify_buffers.cpp +++ b/src/common/snippets/src/lowered/pass/identify_buffers.cpp @@ -74,48 +74,16 @@ void IdentifyBuffers::update_adj_matrix(const std::pair IdentifyBuffers::create_adjacency_matrix(const LinearIR& linear_ir, const BufferPool& pool) { - // There are several sync points for adjacency check: - // 1. Loop because only in Loop we increment pointers. So if some Buffers in the one Loop have conflict - // (cannot be inplace: the different ptr increment and data sizes) they are called as adjacent - // 2. Brgemm because its blocking implementation requires Buffers with unique memory on all inputs and outputs + // The sync point to check for adjacency is Loop because only in Loop we increment pointers. + // So if some Buffers in the one Loop have conflict (cannot be inplace: the different ptr increment and data sizes) + // they are called as adjacent const auto size = pool.size(); std::vector adj(size * size, false); for (size_t i = 0; i < size; ++i) adj[index(size, i, i)] = true; - auto is_buffer = [](const ExpressionPort& port) { - return ov::is_type(port.get_expr()->get_node()); - }; - for (auto expr_it = linear_ir.cbegin(); expr_it != linear_ir.cend(); expr_it++) { const auto &expr = *expr_it; - if (const auto brgemm = ov::as_type_ptr(expr->get_node())) { - const auto consumers = expr->get_output_port_connector(0)->get_consumers(); - - auto buffer_it = std::find_if(consumers.begin(), consumers.end(), is_buffer); - if (buffer_it == consumers.end()) - continue; - OPENVINO_ASSERT(std::count_if(consumers.begin(), consumers.end(), is_buffer) == 1, "Brgemm mustn't have more than 1 consumer buffer"); - - BufferPool adjacency_buffers; - adjacency_buffers.push_back(buffer_it->get_expr()); - - for (const auto& input_connector : expr->get_input_port_connectors()) { - const auto parent_expr = input_connector->get_source().get_expr(); - if (ov::is_type(parent_expr->get_node())) { - adjacency_buffers.push_back(parent_expr); - } - } - for (auto buffer_it = adjacency_buffers.begin(); buffer_it != adjacency_buffers.end(); ++buffer_it) { - for (auto neighbour_it = std::next(buffer_it); neighbour_it != adjacency_buffers.end(); ++neighbour_it) { - const auto buffer_idx = get_buffer_idx(*buffer_it, pool); - const auto neighbour_idx = get_buffer_idx(*neighbour_it, pool); - adj[index(size, neighbour_idx, buffer_idx)] = adj[index(size, buffer_idx, neighbour_idx)] = true; - } - } - continue; - } - const auto& loop_end = ov::as_type_ptr(expr->get_node()); if (!loop_end) continue; @@ -234,9 +202,7 @@ auto IdentifyBuffers::coloring(BufferPool& buffers, std::vector& adj) -> s bool IdentifyBuffers::run(LinearIR& linear_ir) { OV_ITT_SCOPED_TASK(ov::pass::itt::domains::SnippetsTransform, "Snippets::IdentifyBuffers") - // Unite Buffers using Graph coloring algorithm. - // Notes: We identify only Buffer with Intermediate memory because Buffers with new memory are used only in Brgemm case - // so these Buffers are always IntermediateBuffer nonadjacent + // Identify Buffers using Graph coloring algorithm. BufferPool buffer_pool; for (const auto& expr : linear_ir) { diff --git a/src/common/snippets/src/lowered/pass/init_loops.cpp b/src/common/snippets/src/lowered/pass/init_loops.cpp index 8128ea0253d2a7..68e8cc7757e13f 100644 --- a/src/common/snippets/src/lowered/pass/init_loops.cpp +++ b/src/common/snippets/src/lowered/pass/init_loops.cpp @@ -37,63 +37,75 @@ int64_t get_output_stride(size_t dim, const VectorDims& shape) { InitLoops::InitLoops() : Pass() {} -void InitLoops::init_ptr_increments(std::vector& loop_inputs, std::vector& loop_outputs, size_t work_amount, size_t dim_idx) { - for (auto& loop_input : loop_inputs) { - loop_input.ptr_increment = 0; - if (loop_input.is_incremented) { - const auto& port = loop_input.expr_port; +void InitLoops::init_ptr_increments(const LinearIR::LoopManager::LoopInfoPtr& loop_info) { + const auto work_amount = loop_info->get_work_amount(); + auto loop_entries = loop_info->get_entry_points(); + auto loop_exits = loop_info->get_exit_points(); + + for (auto& loop_entry : loop_entries) { + loop_entry.ptr_increment = 0; + if (loop_entry.is_incremented) { + const auto& port = loop_entry.expr_port; const auto source = *port->get_connected_ports().begin(); const auto loop_ids = port->get_expr()->get_loop_ids(); const auto& layout = port->get_descriptor_ptr()->get_layout(); const auto& shape = port->get_descriptor_ptr()->get_shape(); - const auto& dim = *(layout.rbegin() + dim_idx); + const auto& dim = *(layout.rbegin() + loop_entry.dim_idx); // If relevant dim is not broadcasted, then ptr_increment is the dim stride in the new layout if (!(shape[dim] == 1 && work_amount != 1)) { // Input layout shows how we should read data by which order and strides - loop_input.ptr_increment = get_input_stride(dim, source.get_descriptor_ptr()->get_layout(), shape); + loop_entry.ptr_increment = get_input_stride(dim, source.get_descriptor_ptr()->get_layout(), shape); } } } - for (auto& loop_output : loop_outputs) { - loop_output.ptr_increment = 0; - if (loop_output.is_incremented) { - const auto& port = loop_output.expr_port; + for (auto& loop_exit : loop_exits) { + loop_exit.ptr_increment = 0; + if (loop_exit.is_incremented) { + const auto& port = loop_exit.expr_port; const auto loop_ids = port->get_expr()->get_loop_ids(); const auto& layout = port->get_descriptor_ptr()->get_layout(); const auto& shape = port->get_descriptor_ptr()->get_shape(); - const auto original_dim = layout.size() - 1 - dim_idx; + const auto original_dim = layout.size() - 1 - loop_exit.dim_idx; const auto& dim = std::distance(layout.cbegin(), std::find(layout.cbegin(), layout.cend(), original_dim)); // If relevant dim is not broadcasted, then ptr_increment is the dim stride in the new layout if (!(shape[dim] == 1 && work_amount != 1)) { // Output layout shows how we already written data by which order and strides - loop_output.ptr_increment = get_output_stride(dim, shape); + loop_exit.ptr_increment = get_output_stride(dim, shape); } } } + loop_info->set_entry_points(loop_entries); + loop_info->set_exit_points(loop_exits); } -void InitLoops::init_finalization_offsets(std::vector& loop_inputs, - std::vector& loop_outputs, - size_t work_amount) { - for (auto& loop_input : loop_inputs) { - loop_input.finalization_offset = -1 * loop_input.ptr_increment * work_amount; +void InitLoops::init_finalization_offsets(const LinearIR::LoopManager::LoopInfoPtr& loop_info) { + const auto work_amount = loop_info->get_work_amount(); + auto loop_entries = loop_info->get_entry_points(); + auto loop_exits = loop_info->get_exit_points(); + for (auto& loop_entry : loop_entries) { + loop_entry.finalization_offset = -1 * loop_entry.ptr_increment * work_amount; } - for (auto& loop_output : loop_outputs) { - loop_output.finalization_offset = -1 * loop_output.ptr_increment * work_amount; + for (auto& loop_exit : loop_exits) { + loop_exit.finalization_offset = -1 * loop_exit.ptr_increment * work_amount; } + loop_info->set_entry_points(loop_entries); + loop_info->set_exit_points(loop_exits); } -void InitLoops::init_element_type_sizes(std::vector& loop_inputs, - std::vector& loop_outputs) { - for (auto& loop_input : loop_inputs) { - const auto& port = loop_input.expr_port; - loop_input.data_size = static_cast(port->get_expr()->get_node()->get_input_element_type(port->get_index()).size()); +void InitLoops::init_element_type_sizes(const LinearIR::LoopManager::LoopInfoPtr& loop_info) { + auto loop_entries = loop_info->get_entry_points(); + auto loop_exits = loop_info->get_exit_points(); + for (auto& loop_entry : loop_entries) { + const auto& port = loop_entry.expr_port; + loop_entry.data_size = static_cast(port->get_expr()->get_node()->get_input_element_type(port->get_index()).size()); } - for (auto& loop_output : loop_outputs) { - const auto& port = loop_output.expr_port; - loop_output.data_size = static_cast(port->get_expr()->get_node()->get_output_element_type(port->get_index()).size()); + for (auto& loop_exit : loop_exits) { + const auto& port = loop_exit.expr_port; + loop_exit.data_size = static_cast(port->get_expr()->get_node()->get_output_element_type(port->get_index()).size()); } + loop_info->set_entry_points(loop_entries); + loop_info->set_exit_points(loop_exits); } bool InitLoops::run(LinearIR& linear_ir) { @@ -105,13 +117,9 @@ bool InitLoops::run(LinearIR& linear_ir) { const auto& loops = loop_manager->get_map(); for (const auto& loop : loops) { const auto loop_info = loop.second; - - const auto work_amount = loop_info->work_amount; - const auto dim_idx = loop_info->dim_idx; - - init_ptr_increments(loop_info->entry_points, loop_info->exit_points, work_amount, dim_idx); - init_finalization_offsets(loop_info->entry_points, loop_info->exit_points, work_amount); - init_element_type_sizes(loop_info->entry_points, loop_info->exit_points); + init_ptr_increments(loop_info); + init_finalization_offsets(loop_info); + init_element_type_sizes(loop_info); } return true; diff --git a/src/common/snippets/src/lowered/pass/insert_broadcastmove.cpp b/src/common/snippets/src/lowered/pass/insert_broadcastmove.cpp index a70698580a61e3..723b97b5a25788 100644 --- a/src/common/snippets/src/lowered/pass/insert_broadcastmove.cpp +++ b/src/common/snippets/src/lowered/pass/insert_broadcastmove.cpp @@ -56,12 +56,7 @@ bool InsertBroadcastMove::run(LinearIR& linear_ir) { OPENVINO_ASSERT(last_dims[i] == 1, "Attempt to broadcast non-1 dimension. Target dim: ", broadcasted_dim, " This dim: ", last_dims[i]); - auto input_shape = descriptors[i]->get_shape(); - // Note that input_shape could be empty (aka ngraph scalar), so we can't just replace the last dim - if (input_shape.empty()) - input_shape.resize(1); - input_shape.back() = last_dims[i]; - const auto broadcast = std::make_shared(node->get_input_source_output(i), utils::vdims_to_pshape(input_shape)); + const auto broadcast = std::make_shared(node->get_input_source_output(i), broadcasted_dim); PortDescriptorUtils::set_port_descriptor_ptr(broadcast->output(0), connectors[i]->get_source().get_descriptor_ptr()->clone()); const auto broadcast_expr = linear_ir.create_expression(broadcast, {connectors[i]}); diff --git a/src/common/snippets/src/lowered/pass/insert_buffers.cpp b/src/common/snippets/src/lowered/pass/insert_buffers.cpp index aefaca42f4094e..81835a4ca390ae 100644 --- a/src/common/snippets/src/lowered/pass/insert_buffers.cpp +++ b/src/common/snippets/src/lowered/pass/insert_buffers.cpp @@ -49,26 +49,52 @@ ov::Shape compute_allocation_shape(const LinearIR::LoopManagerPtr& loop_manager, return allocation_shape; } - auto set_rest_dims_to_ones = [&](const int filled_dims_count) { - for (int i = 0; i < static_cast(allocation_shape.size()) - filled_dims_count; ++i) { - allocation_shape[i] = 1; + // If subtensor is set, its information is used for allocation shape computation. Two situations are possible: + // 1. Buffer is outside the parent loop: the corresponding subtensor value is ignored, parent loop work amount is set instead + // 2. Buffer is inside the parent loop: the corresponding subtensor value is used in allocation shape. + // Since we can defenitely know which subtensor value corresponds to the loop only for 1st case + // (we can extract this info from loop exit port), we copy subtensor, and then replace subtensor values with parent loop work amount if needed. + // Example: + // Parent subtensor: [M_blk, N_blk] + // Buffer loop idces: [M_loop_idx], parent loop idces: [M_loop_idx, N_loop_idx] + // + // 1. Allocation shape is set to subtensor: [M_blk, N_blk] + // 2. Buffer is inside M_loop_idx loop => allocation shape is not changed + // 3. Buffer is outside N_loop_idx loop => the corresponding allocation shape value is replaced with N loop work amount + // So the result allocation shape is [M_blk, N_loop_work_amount] + const auto& subtensor = expr_port.get_descriptor_ptr()->get_subtensor(); + if (!subtensor.empty()) { + for (size_t i = 0; i < std::min(rank, subtensor.size()); ++i) { + auto& cur_val = *(allocation_shape.rbegin() + i); + const auto& subtensor_val = *(subtensor.rbegin() + i); + cur_val = std::min(cur_val, subtensor_val); + } + for (const auto& parent_loop : parent_loop_ids) { + if (std::find(buffer_loop_ids.begin(), buffer_loop_ids.end(), parent_loop) == buffer_loop_ids.end()) { + const auto loop_info = loop_manager->get_loop_info(parent_loop); + const auto& exit_points = loop_info->get_exit_points(); + auto it = std::find_if(exit_points.begin(), + exit_points.end(), + [&expr_port](const LinearIR::LoopManager::LoopPort& port) { + return *port.expr_port == expr_port; + }); + OPENVINO_ASSERT(it != exit_points.end(), "compute_allocation_shape: exit point of parent loop can not be found"); + const auto& loop_port = *it; + if (loop_port.is_incremented && loop_port.dim_idx < allocation_shape.size()) { + *(allocation_shape.rbegin() + loop_port.dim_idx) = loop_info->get_work_amount(); + } + } } - }; - - // In some cases it's possible to allocate less shape - // 1. Buffer and its parent are in the same loop: allocation size for the outer dimension can be extracted from loop increment - // 2. Buffer is outside the parent's loops: allocation size can be extracted from the corresponding loop work amount - // TODO: Use general logic with the help of memory counts for allocation shape computation - if (buffer_loop_ids.back() == parent_loop_ids.back()) { - const auto buffer_loop = loop_manager->get_loop_info(buffer_loop_ids.back()); - *(allocation_shape.rbegin() + 1) = buffer_loop->increment; - set_rest_dims_to_ones(2); } else { + // WA: In case of empty subtensors another information have to be used to update allocation shape. for (size_t i = 0; i < std::min(rank, parent_loop_ids.size()); ++i) { const auto loop = loop_manager->get_loop_info(*(parent_loop_ids.rbegin() + i)); - *(allocation_shape.rbegin() + i) = loop->work_amount; + OPENVINO_ASSERT(loop->get_dim_idx() == i, "compute_allocation_shape: eltwise loop has unexpected dimension index"); + *(allocation_shape.rbegin() + i) = loop->get_work_amount(); + } + for (int i = 0; i < allocation_rank - static_cast(parent_loop_ids.size()); ++i) { + allocation_shape[i] = 1; } - set_rest_dims_to_ones(static_cast(parent_loop_ids.size())); } return allocation_shape; } @@ -155,7 +181,7 @@ void InsertBuffers::insertion(LinearIR& linear_ir, const LinearIR::constExprIt& parent_loops, parent_expr_output, m_buffer_allocation_rank); - const auto buffer = std::make_shared(parent->output(parent_port), allocation_shape); + const auto buffer = std::make_shared(parent->output(parent_port), allocation_shape); PortDescriptorUtils::set_port_descriptor_ptr(buffer->output(0), parent_expr_output.get_descriptor_ptr()->clone()); // Output connector is automatically filled from PortDescriptor const auto buffer_expr = linear_ir.create_expression(buffer, {input_connector}); @@ -248,7 +274,7 @@ void InsertBuffers::insertion(LinearIR& linear_ir, const LinearIR::constExprIt& current_loops, *exit_port, m_buffer_allocation_rank); - auto buffer = std::make_shared(node->output(port_idx), allocation_shape); + auto buffer = std::make_shared(node->output(port_idx), allocation_shape); PortDescriptorUtils::set_port_descriptor_ptr(buffer->output(0), exit_port->get_descriptor_ptr()->clone()); // We cannot insert Node output connector on Buffer output because not all consumers of Node needs Buffer // Example: @@ -275,8 +301,8 @@ bool InsertBuffers::run(LinearIR& linear_ir) { const auto loop_data_map = loop_manager->get_map(); for (const auto& loop_data : loop_data_map) { const auto loop_info = loop_data.second; - const auto loop_entries = loop_info->entry_points; - const auto loop_exits = loop_info->exit_points; + const auto loop_entries = loop_info->get_entry_points(); + const auto loop_exits = loop_info->get_exit_points(); // using begin() as expr_it because we work with LoopInfo, not expressions in Linear IR insertion(linear_ir, linear_ir.cbegin(), loop_manager, loop_entries, loop_exits); } diff --git a/src/common/snippets/src/lowered/pass/insert_load_store.cpp b/src/common/snippets/src/lowered/pass/insert_load_store.cpp index ff75a5be0e6c5c..75e70c9c553c88 100644 --- a/src/common/snippets/src/lowered/pass/insert_load_store.cpp +++ b/src/common/snippets/src/lowered/pass/insert_load_store.cpp @@ -122,9 +122,9 @@ bool InsertLoadStore::run(LinearIR& linear_ir) { modified |= insert_load(linear_ir, expr_it); } else if (ov::is_type(node)) { modified |= insert_store(linear_ir, expr_it); - } else if (auto buffer = ov::as_type_ptr(node)) { + } else if (ov::is_type(node)) { modified |= insert_load(linear_ir, expr_it); - if (buffer->is_intermediate_memory()) + if (ov::is_type(node)) modified |= insert_store(linear_ir, expr_it); } } diff --git a/src/common/snippets/src/lowered/pass/insert_loops.cpp b/src/common/snippets/src/lowered/pass/insert_loops.cpp index 32d4151cb38b95..3eab6e97df33fb 100644 --- a/src/common/snippets/src/lowered/pass/insert_loops.cpp +++ b/src/common/snippets/src/lowered/pass/insert_loops.cpp @@ -55,10 +55,10 @@ void InsertLoops::filter_ports(std::vector& loop_entries, std::vector< void InsertLoops::insertion(LinearIR& linear_ir, const LinearIR::LoopManagerPtr& loop_manager, size_t loop_id, bool has_outer_loop) { const auto loop_info = loop_manager->get_loop_info(loop_id); - auto loop_entries = loop_info->entry_points; - auto loop_exits = loop_info->exit_points; - const auto work_amount = loop_info->work_amount; - const auto work_amount_increment = loop_info->increment; + auto loop_entries = loop_info->get_entry_points(); + auto loop_exits = loop_info->get_exit_points(); + const auto work_amount = loop_info->get_work_amount(); + const auto work_amount_increment = loop_info->get_increment(); LinearIR::constExprIt loop_begin_pos, loop_end_pos; loop_manager->get_loop_bounds(linear_ir, loop_id, loop_begin_pos, loop_end_pos); @@ -67,15 +67,18 @@ void InsertLoops::insertion(LinearIR& linear_ir, const LinearIR::LoopManagerPtr& filter_ports(loop_entries, loop_exits); const auto in_out_num = loop_entries.size() + loop_exits.size(); + std::vector is_incremented; std::vector ptr_increments, finalization_offsets, io_data_sizes; std::vector loop_end_inputs; + is_incremented.reserve(in_out_num); ptr_increments.reserve(in_out_num); finalization_offsets.reserve(in_out_num); io_data_sizes.reserve(in_out_num); loop_end_inputs.reserve(in_out_num); - auto init_params = [&ptr_increments, &finalization_offsets, &io_data_sizes, &loop_end_inputs](const std::vector& ports) { + auto init_params = [&](const std::vector& ports) { for (const auto& port : ports) { + is_incremented.push_back(port.is_incremented); ptr_increments.push_back(port.ptr_increment); finalization_offsets.push_back(port.finalization_offset); io_data_sizes.push_back(port.data_size); @@ -90,8 +93,8 @@ void InsertLoops::insertion(LinearIR& linear_ir, const LinearIR::LoopManagerPtr& linear_ir.insert(loop_begin_pos, loop_begin_expr); const auto& loop_end = std::make_shared( - loop_begin->output(0), work_amount, work_amount_increment, ptr_increments, finalization_offsets, - io_data_sizes, loop_entries.size(), loop_exits.size(), loop_id); + loop_begin->output(0), work_amount, work_amount_increment, is_incremented, ptr_increments, + finalization_offsets, io_data_sizes, loop_entries.size(), loop_exits.size(), loop_id); loop_end->has_outer_loop = has_outer_loop; // Add LoopBegin port connector diff --git a/src/common/snippets/src/lowered/pass/insert_perf_count.cpp b/src/common/snippets/src/lowered/pass/insert_perf_count.cpp new file mode 100644 index 00000000000000..2ed02c9010d063 --- /dev/null +++ b/src/common/snippets/src/lowered/pass/insert_perf_count.cpp @@ -0,0 +1,62 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "snippets/lowered/pass/insert_perf_count.hpp" +#include "snippets/lowered/linear_ir.hpp" +#include "snippets/snippets_isa.hpp" +#include "snippets/itt.hpp" + +namespace ov { +namespace snippets { +namespace lowered { +namespace pass { + +bool InsertPerfCount::run(LinearIR& linear_ir) { + OV_ITT_SCOPED_TASK(ov::pass::itt::domains::SnippetsTransform, "Snippets::InsertPerfCount") + if (linear_ir.empty()) + return false; + + auto is_parameter = [](const std::shared_ptr& node) { + return ov::is_type(node); + }; + auto is_result = [](const std::shared_ptr& node) { + return ov::is_type(node); + }; + + // mark perf_count_begin and perf_count_end position + auto perf_count_begin_pos = linear_ir.cbegin(); + auto perf_count_end_pos = perf_count_begin_pos; + bool first_result_marked = false; + for (auto expr_it = linear_ir.cbegin(); expr_it != linear_ir.cend(); expr_it++) { + const auto expr = *expr_it; + const auto& node = expr->get_node(); + if (is_parameter(node)) + perf_count_begin_pos = expr_it; + + if (is_result(node) && !first_result_marked) { + perf_count_end_pos = expr_it; + first_result_marked = true; + } + } + + // insert perf_count_begin after last parameter + // linear_ir.insert has insert before behavior, need move to next. + perf_count_begin_pos = std::next(perf_count_begin_pos); + const auto& perf_count_begin = std::make_shared(); + const auto& perf_count_begin_expr = linear_ir.create_expression(perf_count_begin, std::vector{}); + linear_ir.insert(perf_count_begin_pos, perf_count_begin_expr); + + // insert perf_count_end before first result + const auto& perf_count_end = std::make_shared(perf_count_begin->output(0)); + perf_count_end->set_friendly_name("last_parameter_to_first_result"); + const auto& perf_count_end_expr = linear_ir.create_expression(perf_count_end, std::vector{}); + linear_ir.insert(perf_count_end_pos, perf_count_end_expr); + + return true; +} + +} // namespace pass +} // namespace lowered +} // namespace snippets +} // namespace ov diff --git a/src/common/snippets/src/lowered/pass/insert_tail_loop.cpp b/src/common/snippets/src/lowered/pass/insert_tail_loop.cpp index 50d684d4d7ddc3..cc685c1851157a 100644 --- a/src/common/snippets/src/lowered/pass/insert_tail_loop.cpp +++ b/src/common/snippets/src/lowered/pass/insert_tail_loop.cpp @@ -8,48 +8,223 @@ #include "snippets/lowered/loop_manager.hpp" #include "snippets/lowered/pass/init_loops.hpp" #include "snippets/snippets_isa.hpp" +#include "snippets/utils.hpp" #include "snippets/itt.hpp" namespace ov { namespace snippets { namespace lowered { namespace pass { +void InsertTailLoop::propagate_updated_subtensor_through_loop(const LinearIR& linear_ir, + const LinearIR::LoopManager::LoopInfoPtr& loop_info, + LinearIR::container::const_iterator begin, + LinearIR::container::const_iterator end, + const size_t new_dim_value) { + std::map original_shapes; + // First step: set new dim value to the corresponding entry_points' dimensions + if (new_dim_value != existing_subtensor_value) { + for (const auto& port : loop_info->get_entry_points()) { + if (port.is_incremented) { + const auto& expr = port.expr_port->get_expr(); + const auto node = expr->get_node(); + auto desc = port.expr_port->get_descriptor_ptr(); + auto subtensor = desc->get_subtensor(); + if (port.dim_idx < subtensor.size()) { + *(subtensor.rbegin() + port.dim_idx) = new_dim_value; + desc->set_subtensor(subtensor); + } + + const auto parent_desc = expr->get_input_port_connector(port.expr_port->get_index())->get_source().get_descriptor_ptr(); + const auto& layout = parent_desc->get_layout(); + const auto& shape = parent_desc->get_shape(); + if (original_shapes.find(parent_desc) == original_shapes.end()) { + original_shapes[parent_desc] = shape; + } + auto new_shape = shape; + new_shape[*(layout.rbegin() + port.dim_idx)] = new_dim_value; + parent_desc->set_shape(new_shape); + } + } + } + + auto update_only_dim_idx_with_subtensor_value = [&](const LinearIR::LoopManager::LoopPort& port) { + if (port.is_incremented) { + auto desc = port.expr_port->get_descriptor_ptr(); + const auto expr = port.expr_port->get_expr(); + const auto parent_desc = expr->get_input_port_connector(port.expr_port->get_index())->get_source().get_descriptor_ptr(); + + const auto& layout = parent_desc->get_layout(); + const auto& shape = parent_desc->get_shape(); + const auto& desc_subtensor = desc->get_subtensor(); + if (port.dim_idx < desc_subtensor.size()) { + if (original_shapes.find(parent_desc) == original_shapes.end()) { + original_shapes[parent_desc] = shape; + } + auto new_shape = shape; + new_shape[*(layout.rbegin() + port.dim_idx)] = *(desc_subtensor.rbegin() + port.dim_idx); + parent_desc->set_shape(new_shape); + } + } + }; + + auto update_subtensors = [](const std::vector& descs, bool is_input) { + for (const auto& desc : descs) { + const auto& subtensor = desc->get_subtensor(); + if (!subtensor.empty()) { + auto planar_dims = is_input ? snippets::utils::get_planar_vdims(desc->get_shape(), desc->get_layout()) + : snippets::utils::get_preordered_vdims(desc->get_shape(), desc->get_layout()); + const size_t subtensor_start = planar_dims.size() - subtensor.size(); + VectorDims new_subtensor(planar_dims.begin() + subtensor_start, planar_dims.end()); + for (size_t i = 0; i < new_subtensor.size(); ++i) { + new_subtensor[i] = std::min(new_subtensor[i], subtensor[i]); + } + desc->set_subtensor(new_subtensor); + } + } + }; + + auto shape_inference_end_it = end; + const bool loop_by_last_dim = loop_info->get_dim_idx() == 0; + // Subtensors are updated using shape inference infrastructure: + // For inner loops propagation function is called recursively + for (auto expr_it = begin; expr_it != end; expr_it++) { + const auto expr = *expr_it; + if (ov::is_type(expr->get_node())) + continue; + if (auto loop_begin = ov::as_type_ptr(expr->get_node())) { + const auto loop_end = loop_begin->get_loop_end(); + const auto inner_loop_info = linear_ir.get_loop_manager()->get_loop_info(loop_end->get_id()); + const auto inner_begin = std::next(expr_it); + const auto inner_end = linear_ir.find(linear_ir.get_expr_by_node(loop_end)); + + // The corresponding shapes of inner loops entry points must be updated using existing subtensor values + if (new_dim_value == existing_subtensor_value) { + for (const auto& port : loop_info->get_entry_points()) + update_only_dim_idx_with_subtensor_value(port); + } + propagate_updated_subtensor_through_loop(linear_ir, inner_loop_info, inner_begin, inner_end); + expr_it = inner_end; + continue; + } + if ((ov::is_type(expr_it->get()->get_node()) || + ov::is_type(expr_it->get()->get_node())) && + loop_by_last_dim) { + // WA: we have to break subtensor propagation if we try to propagate new last dim through Broadcast nodes + // which broadcast last dim in original dimension value anyway + // This workaround might be avoided if blocked shape are used for tail size propagation + shape_inference_end_it = expr_it; + break; + } + expr->updateShapes(); + update_subtensors(expr->get_input_port_descriptors(), true); + update_subtensors(expr->get_output_port_descriptors(), false); + } -std::shared_ptr InsertTailLoop::create_tail_loop(LinearIR& linear_ir, - LinearIR::constExprIt vector_begin, - LinearIR::constExprIt vector_end, - LinearIR::constExprIt& tail_begin, - LinearIR::constExprIt& tail_end, - const std::shared_ptr& vector_loop_end, - bool need_vector_loop, - size_t tail_size, - const std::vector& tail_finalization_offsets) { + // After subtensor propagation, the original shapes must be restored + for (const auto& elem : original_shapes) + elem.first->set_shape(elem.second); + for (auto expr_it = begin; expr_it != shape_inference_end_it; expr_it++) + (*expr_it)->updateShapes(); +} + +LinearIR::container InsertTailLoop::copy_loop(const LinearIR& linear_ir, const size_t loop_id) { + const auto& loop_manager = linear_ir.get_loop_manager(); + LinearIR::constExprIt loop_begin_pos, loop_end_pos; + loop_manager->get_loop_bounds(linear_ir, loop_id, loop_begin_pos, loop_end_pos, true); + ExressionMap expression_map; + const auto& loop_copy_range = LinearIR::deep_copy_range(loop_begin_pos, std::next(loop_end_pos), expression_map); + + const auto original_loop_info = loop_manager->get_loop_info(loop_id); + std::vector new_entry_points, new_exit_points; + // Clone loop ports from original loop info to new loop info + for (const auto& entry : original_loop_info->get_entry_points()) + new_entry_points.push_back(*entry.clone_with_new_expr(expression_map[entry.expr_port->get_expr().get()])); + for (const auto& exit : original_loop_info->get_exit_points()) + new_exit_points.push_back(*exit.clone_with_new_expr(expression_map[exit.expr_port->get_expr().get()])); + + for (const auto& elem : expression_map) { + const auto expr = elem.first->shared_from_this(); + const auto& new_expr = elem.second; + // Loop begin/end ops can't be loop ports + if (ov::is_type(expr->get_node())) + continue; + // Update loop info of all outer loops with new loop ports + const auto outer_loop_ids = LinearIR::LoopManager::get_outer_expr_loops(expr, loop_id); + for (size_t i = 0; i < expr->get_input_count(); ++i) + loop_manager->update_loops_port(outer_loop_ids, expr->get_input_port(i), {expr->get_input_port(i), new_expr->get_input_port(i)}, true); + for (size_t i = 0; i < expr->get_output_count(); ++i) + loop_manager->update_loops_port(outer_loop_ids, expr->get_output_port(i), {expr->get_output_port(i), new_expr->get_output_port(i)}, false); + } + + const auto new_loop_begin_pos = loop_copy_range.begin(); + const auto new_loop_end_pos = loop_copy_range.end(); + const auto new_id = loop_manager->replace_with_new_loop(linear_ir, + std::next(new_loop_begin_pos), + std::prev(new_loop_end_pos), + original_loop_info->get_work_amount(), + original_loop_info->get_increment(), + new_entry_points, + new_exit_points, + loop_id); + const auto loop_end = ov::as_type_ptr(std::prev(new_loop_end_pos)->get()->get_node()); + OPENVINO_ASSERT(loop_end, "Cloned Loop does not contain LoopEnd op at the expected place."); + loop_end->set_id(new_id); + return loop_copy_range; +} + +void InsertTailLoop::create_tail_loop(LinearIR& linear_ir, + LinearIR::constExprIt begin, + LinearIR::constExprIt end, + const std::shared_ptr& loop_end, + bool need_vector_loop, + size_t tail_size) { // tail is required => transform the body into a tail representation // tail loop is fake loop because for tail we should calculate only // finalization offsets which are supported by LoopEnd. + const auto& loop_manager = linear_ir.get_loop_manager(); + const auto original_loop_id = loop_end->get_id(); + auto original_loop_info = loop_manager->get_loop_info(original_loop_id); + auto tail_loop_info = original_loop_info; if (need_vector_loop) { - ExressionMap expression_map; - auto vector_loop_deep_copy = LinearIR::deep_copy_range(vector_begin, vector_end, expression_map); - tail_begin = linear_ir.insert(vector_end, vector_loop_deep_copy.begin(), vector_loop_deep_copy.end()); - tail_end = vector_end; - } else { - tail_begin = vector_begin; - tail_end = vector_end; + const auto new_loop_range = copy_loop(linear_ir, original_loop_id); + const auto new_loop_end = ov::as_type_ptr(std::prev(new_loop_range.end())->get()->get_node()); + OPENVINO_ASSERT(new_loop_end, "Cloned Loop does not contain LoopEnd op at the expected place."); + tail_loop_info = original_loop_info; + original_loop_info = loop_manager->get_loop_info(new_loop_end->get_id()); + + // Note: new loop body is inserted before the original loop + // So new loop becomes a main vector loop, the original loop becomes tail loop + // This is done in such way to have original ops from the main body at the end: + // this allows us to conveniently interact with outer loops in further passes + linear_ir.insert(begin, new_loop_range.begin(), new_loop_range.end()); + + const auto new_vector_loop_wa = original_loop_info->get_work_amount() - tail_size; + original_loop_info->set_work_amount(new_vector_loop_wa); + new_loop_end->set_work_amount(new_vector_loop_wa); + original_loop_info->set_outer_splited_loop(tail_loop_info->get_outer_splited_loop()); + // Note that finalization offsets should be applied after the last iteration. + // So if there is a tail, then we should apply offsets after it, but not now. + new_loop_end->set_finalization_offsets(std::vector(loop_end->get_finalization_offsets().size(), 0)); } + loop_end->set_increment(tail_size); + loop_end->set_work_amount(tail_size); + tail_loop_info->set_increment(tail_size); + tail_loop_info->set_work_amount(tail_size); // We have to check the loop body for any nested loops that work on the same dimension // and rescale their work_amount and increment accordingly - const auto& loop_manager = linear_ir.get_loop_manager(); - const auto& current_loop_Info = loop_manager->get_loop_info(vector_loop_end->get_id()); - if (current_loop_Info->outer_splited_loop) { - const auto current_dim_idx = current_loop_Info->dim_idx; - for (auto it = std::next(tail_begin); it != std::prev(tail_end); ++it) { + if (original_loop_info->get_outer_splited_loop()) { + const auto current_dim_idx = original_loop_info->get_dim_idx(); + OPENVINO_ASSERT(current_dim_idx != LinearIR::LoopManager::LoopInfo::UNDEFINED_DIM_IDX, + "Outer splitted loop unexpectedly iterates by several dimension indices"); + for (auto it = std::next(begin); it != std::prev(end); ++it) { const auto& expr = *it; const auto inner_loop_end = ov::as_type_ptr(expr->get_node()); if (!inner_loop_end) continue; - const auto loop_info = loop_manager->get_loop_info(inner_loop_end->get_id()); - if (loop_info->dim_idx != current_dim_idx) + const auto inner_loop_info = loop_manager->get_loop_info(inner_loop_end->get_id()); + const auto inner_dim_idx = inner_loop_info->get_dim_idx(); + if (inner_dim_idx != current_dim_idx) continue; const auto inner_loop_begin = inner_loop_end->get_loop_begin(); const auto inner_tail_work_amount = static_cast(inner_loop_end->get_work_amount()); @@ -61,21 +236,14 @@ std::shared_ptr InsertTailLoop::create_tail_loop(LinearIR& linear_i inner_loop_end->set_work_amount(tail_size); inner_loop_end->set_increment(std::min(inner_tail_increment, tail_size)); inner_loop_end->set_finalization_offsets(inner_finalization_offsets); - const auto inner_loop_begin_it = std::find(tail_begin, it, linear_ir.get_expr_by_node(inner_loop_begin)); - const auto inner_loop_end_it = std::next(tail_end); + const auto inner_loop_begin_it = std::find(begin, it, linear_ir.get_expr_by_node(inner_loop_begin)); + const auto inner_loop_end_it = std::next(end); OPENVINO_ASSERT(inner_loop_begin_it != it, "LoopBegin has not been found!"); tail_transformations(linear_ir, inner_loop_begin_it, inner_loop_end_it, tail_size); } } - - tail_transformations(linear_ir, tail_begin, tail_end, tail_size); - std::shared_ptr tail_loop_end = ov::as_type_ptr((*tail_begin)->get_node())->get_loop_end(); - tail_loop_end->set_increment(tail_size); - // ptr increments were set to the old increment, need to update them in accordance with the new one - tail_loop_end->set_work_amount(tail_size); - tail_loop_end->set_finalization_offsets(tail_finalization_offsets); - tail_loop_end->has_outer_loop = vector_loop_end->has_outer_loop; - return tail_loop_end; + tail_transformations(linear_ir, begin, end, tail_size); + propagate_updated_subtensor_through_loop(linear_ir, tail_loop_info, std::next(begin), end, tail_size); } void InsertTailLoop::tail_transformations(LinearIR& linear_ir, @@ -106,21 +274,30 @@ void InsertTailLoop::tail_transformations(LinearIR& linear_ir, // correct math calculations for ReduceMax and ReduceSum in scalar case. // Note: We find Maximum and Add ops because HorizonMax and HorizonSum are outside Loop, // so they are missed in - auto op = (*expr_it)->get_node(); + const auto& expr = *expr_it; + const auto op = expr->get_node(); if (config.m_need_fill_tail_register && (ov::is_type(op) || ov::is_type(op))) { for (size_t i = 0; i < op->inputs().size(); ++i) { if (auto fill = insertFill(op->input(i))) { - const auto& input = expr_it->get()->get_input_port_connector(i); + const auto& input = expr->get_input_port_connector(i); const auto consumers = input->get_consumers(); + // If there are several consumers, fill expression must be inserted before first of them + auto fst_consumer = std::min_element(consumers.cbegin(), consumers.cend(), [&](ExpressionPort lhs, ExpressionPort rhs) { + auto lhs_it = linear_ir.find(lhs.get_expr()); + auto rhs_it = linear_ir.find(rhs.get_expr()); + return std::distance(linear_ir.cbegin(), lhs_it) < std::distance(linear_ir.cbegin(), rhs_it); + }); + const auto insert_pos = linear_ir.find(fst_consumer->get_expr()); auto fill_expr = linear_ir.create_expression(fill, {input}); - linear_ir.insert(expr_it, fill_expr); + linear_ir.insert(insert_pos, fill_expr); linear_ir.replace_input(consumers, fill_expr->get_output_port_connector(0)); // in_reg == out_reg since we want to modify vector reg inplace - const auto reg = expr_it->get()->get_input_port_descriptor(0)->get_reg(); + const auto reg = expr->get_input_port_descriptor(0)->get_reg(); fill_expr->get_input_port_descriptor(0)->set_reg(reg); fill_expr->get_output_port_descriptor(0)->set_reg(reg); + fill_expr->set_loop_ids(expr->get_loop_ids()); } } } else if (const auto memory_access = std::dynamic_pointer_cast(op)) { @@ -140,28 +317,6 @@ void InsertTailLoop::tail_transformations(LinearIR& linear_ir, } } -bool InsertTailLoop::optimize_single_evaluation(const std::shared_ptr& loop) { - // *1* solo vector/tail loop + empty outer loop - // => skip increments (both counter & ptr) : set evaluate_once flag - // *2* solo vector/tail loop + non-empty outer loop - // => skip counter increments but perform ptr increments : set evaluate_once, - // and perform pointer increments through finalization offsets - // *3* vector loop(s) + one tail loop - // => vector as usual, tail depends on outer loop, see *1* and *2* - if (loop->get_work_amount() >= 2 * loop->get_increment()) - return false; - - std::vector new_finalization_offsets(loop->get_finalization_offsets()); - const auto& ptr_increments = loop->get_ptr_increments(); - const auto work_amount_incr = static_cast(loop->get_increment()); - for (size_t i = 0; i < new_finalization_offsets.size(); i++) { - new_finalization_offsets[i] += ptr_increments[i] * work_amount_incr; - } - loop->set_finalization_offsets(new_finalization_offsets); - loop->set_evaluate_once(true); - return true; -} - bool InsertTailLoop::run(LinearIR& linear_ir) { OV_ITT_SCOPED_TASK(ov::pass::itt::domains::SnippetsTransform, "Snippets::insertTailLoop") const auto& loop_manager = linear_ir.get_loop_manager(); @@ -174,37 +329,24 @@ bool InsertTailLoop::run(LinearIR& linear_ir) { if (!loop_end) continue; + const auto loop_info = loop_manager->get_loop_info(loop_end->get_id()); + const auto& first_iter_handler = loop_info->get_first_iter_handler(); + if (first_iter_handler) { + modified |= first_iter_handler(linear_ir, expr_it); + } + const auto work_amount = loop_end->get_work_amount(); const auto increment = loop_end->get_increment(); - const auto loop_info = loop_manager->get_loop_info(loop_end->get_id()); const auto tail_size = work_amount % increment; - const auto need_tail = tail_size != 0; - const auto need_vector_loop = work_amount >= increment; - // Note, that finalization_offsets could be modified inside optimize_single_evaluation, - // so need to save them here to cover (evaluate_once vector with non-zero finalization_offsets + tail) - const auto tail_finalization_offsets = need_tail ? loop_end->get_finalization_offsets() : std::vector{}; - // vector loops are required => Just copy the body, original loop is already a vector one - if (need_vector_loop) { - // Note that finalization offsets should be applied after the last iteration. - // So if there is a tail, then we should apply offsets after it, but not now. - if (need_tail) - loop_end->set_finalization_offsets(std::vector(tail_finalization_offsets.size(), 0)); - - optimize_single_evaluation(loop_end); - } // tail is required => transform the body into a tail representation // tail loop is fake loop because for tail we should calculate only // finalization offsets which are supported by LoopEnd. - if (need_tail) { + if (tail_size != 0) { const auto loop_begin = loop_end->get_loop_begin(); const auto begin_it = linear_ir.find(linear_ir.get_expr_by_node(loop_begin)); - LinearIR::constExprIt tail_begin, tail_end; - const auto tail_loop_end = create_tail_loop(linear_ir, begin_it, std::next(expr_it), tail_begin, tail_end, - loop_end, need_vector_loop, tail_size, tail_finalization_offsets); - optimize_single_evaluation(tail_loop_end); - // Skip new tail loop. Note: tail_end refs to the next expression after LoopEnd of tail - expr_it = std::prev(tail_end); + const auto need_vector_loop = work_amount >= increment; + create_tail_loop(linear_ir, begin_it, std::next(expr_it), loop_end, need_vector_loop, tail_size); } modified = true; } diff --git a/src/common/snippets/src/lowered/pass/load_movebroadcast_to_broadcastload.cpp b/src/common/snippets/src/lowered/pass/load_movebroadcast_to_broadcastload.cpp index cd4d57cfd2c941..48f86cb2092972 100644 --- a/src/common/snippets/src/lowered/pass/load_movebroadcast_to_broadcastload.cpp +++ b/src/common/snippets/src/lowered/pass/load_movebroadcast_to_broadcastload.cpp @@ -44,7 +44,7 @@ bool LoadMoveBroadcastToBroadcastLoad::run(LinearIR& linear_ir) { continue; const auto& outshape = move_broadcast->get_output_partial_shape(0); - const auto broadcastload = std::make_shared(load->input_value(0), outshape, load->get_offset()); + const auto broadcastload = std::make_shared(load->input_value(0), *outshape.rbegin(), load->get_offset()); const auto move_consumers = expr->get_output_port_connector(0)->get_consumers(); PortDescriptorUtils::set_port_descriptor_ptr(broadcastload->output(0), expr->get_output_port(0).get_descriptor_ptr()->clone()); const auto broadcastload_expr = linear_ir.create_expression(broadcastload, { parent_expr->get_input_port_connector(0) }); diff --git a/src/common/snippets/src/lowered/pass/optimize_loop_single_evaluation.cpp b/src/common/snippets/src/lowered/pass/optimize_loop_single_evaluation.cpp new file mode 100644 index 00000000000000..317eb32f7ab1fe --- /dev/null +++ b/src/common/snippets/src/lowered/pass/optimize_loop_single_evaluation.cpp @@ -0,0 +1,53 @@ +// Copyright (C) 2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "snippets/lowered/pass/optimize_loop_single_evaluation.hpp" + +#include "snippets/lowered/linear_ir.hpp" +#include "snippets/snippets_isa.hpp" +#include "snippets/itt.hpp" + +namespace ov { +namespace snippets { +namespace lowered { +namespace pass { + +bool OptimizeLoopSingleEvaluation::run(LinearIR& linear_ir) { + OV_ITT_SCOPED_TASK(ov::pass::itt::domains::SnippetsTransform, "Snippets::OptimizeLoopSingleEvaluation") + if (linear_ir.empty()) + return false; + + bool is_modified = false; + for (const auto& expr : linear_ir) { + if (auto loop_end = ov::as_type_ptr(expr->get_node())) { + // *1* solo vector/tail loop + empty outer loop + // => skip increments (both counter & ptr) : set evaluate_once flag + // *2* solo vector/tail loop + non-empty outer loop + // => skip counter increments but perform ptr increments : set evaluate_once, + // and perform pointer increments through finalization offsets + // *3* vector loop(s) + one tail loop + // => vector as usual, tail depends on outer loop, see *1* and *2* + if (loop_end->get_work_amount() >= 2 * loop_end->get_increment()) + continue; + + auto new_finalization_offsets = loop_end->get_finalization_offsets(); + const auto& ptr_increments = loop_end->get_ptr_increments(); + const auto work_amount_incr = static_cast(loop_end->get_increment()); + for (size_t i = 0; i < new_finalization_offsets.size(); i++) { + new_finalization_offsets[i] += ptr_increments[i] * work_amount_incr; + } + loop_end->set_finalization_offsets(new_finalization_offsets); + loop_end->set_ptr_increments(std::vector(new_finalization_offsets.size(), 0)); + loop_end->set_evaluate_once(true); + is_modified = true; + } + } + return is_modified; +} + +} // namespace pass +} // namespace lowered +} // namespace snippets +} // namespace ov + diff --git a/src/common/snippets/src/lowered/pass/softmax_decomposition.cpp b/src/common/snippets/src/lowered/pass/softmax_decomposition.cpp index b434e0f974beb3..4174f928352289 100644 --- a/src/common/snippets/src/lowered/pass/softmax_decomposition.cpp +++ b/src/common/snippets/src/lowered/pass/softmax_decomposition.cpp @@ -52,7 +52,7 @@ bool SoftmaxDecomposition::run(LinearIR& linear_ir) { expr->get()->updateShapes(); return std::make_pair(expr, n); }; - const ov::PartialShape broadcasted_shape(softmax_expr->get_input_port_descriptor(0)->get_shape()); + const ov::Dimension broadcasted_dim(*(softmax_expr->get_input_port_descriptor(0)->get_shape().rbegin())); // Note: VectorBuffer is a special case, since it should go before the initial Load. So we handle it separately const auto& vector_buffer_max = push_node(std::make_shared()); // Init value of vector buffer for ReduceMax is -FLOAT_MIN. @@ -67,8 +67,7 @@ bool SoftmaxDecomposition::run(LinearIR& linear_ir) { std::vector{(*max.first)->get_input_port(0), (*max.first)->get_input_port(1)}, std::vector{(*max.first)->get_output_port(0)}); - const auto broadcast_horizon_max = push_node( - std::make_shared(horizon_max.second, broadcasted_shape)); + const auto broadcast_horizon_max = push_node(std::make_shared(horizon_max.second, broadcasted_dim)); const auto vector_buffer_sum = push_node(std::make_shared()); // Init value of vector buffer for ReduceSum is zero. const auto fill_sum = push_node(std::make_shared(vector_buffer_sum.second, 0, zero_constant)); @@ -90,7 +89,7 @@ bool SoftmaxDecomposition::run(LinearIR& linear_ir) { // Divide is expensive operation, so we decompose it into 1 / x * y, where 1 / x is executed outside loop const auto pow = push_node(std::make_shared(horizon_sum.second, -1.f)); - const auto broadcast_pow = push_node(std::make_shared(pow.second, broadcasted_shape)); + const auto broadcast_pow = push_node(std::make_shared(pow.second, broadcasted_dim)); // Mul (pseudo-Divide loop) const auto mul = push_node(std::make_shared(exp.second, broadcast_pow.second)); diff --git a/src/common/snippets/src/lowered/pass/split_loops.cpp b/src/common/snippets/src/lowered/pass/split_loops.cpp index af5a4d9cceda9a..ba036eca8011f9 100644 --- a/src/common/snippets/src/lowered/pass/split_loops.cpp +++ b/src/common/snippets/src/lowered/pass/split_loops.cpp @@ -15,13 +15,16 @@ namespace snippets { namespace lowered { namespace pass { using LoopManager = LinearIR::LoopManager; +using LoopInfo = LoopManager::LoopInfo; using LoopInfoPtr = LoopManager::LoopInfoPtr; SplitLoops::SplitLoops() : Pass() {} bool SplitLoops::can_be_split(const LoopInfoPtr& current, const LoopInfoPtr& parent) { - return current->work_amount == parent->work_amount && current->dim_idx == parent->dim_idx && - current->increment != parent->increment; + const auto current_dim_idx = current->get_dim_idx(); + const auto parent_dim_idx = parent->get_dim_idx(); + const bool equal_dim_idxes = current_dim_idx != LoopInfo::UNDEFINED_DIM_IDX && current_dim_idx == parent_dim_idx; + return current->get_work_amount() == parent->get_work_amount() && current->get_increment() != parent->get_increment() && equal_dim_idxes; } bool SplitLoops::run(LinearIR& linear_ir) { @@ -42,7 +45,7 @@ bool SplitLoops::run(LinearIR& linear_ir) { // be in the same set of outer loops. Otherwise they won't be fused. const auto& loop_id = loop_ids.front(); const auto loop = loop_manager->get_loop_info(loop_id); - for (const auto& entry_point : loop->entry_points) { + for (const auto& entry_point : loop->get_entry_points()) { const auto& parent_port = entry_point.expr_port->get_port_connector_ptr()->get_source(); const auto& parent_expr = parent_port.get_expr(); const auto parent_loop_ids = parent_expr->get_loop_ids(); @@ -58,27 +61,27 @@ bool SplitLoops::run(LinearIR& linear_ir) { const auto parent_loop = loop_manager->get_loop_info(parent_loop_id); if (can_be_split(loop, parent_loop)) { loop_was_split = true; - const bool split_parent = parent_loop->increment < loop->increment; + const bool split_parent = parent_loop->get_increment() < loop->get_increment(); const auto& loop_to_split = split_parent ? parent_loop : loop; const auto& loop_to_split_id = split_parent ? parent_loop_id : loop_id; const auto& loop_to_fuse = !split_parent ? parent_loop : loop; - loop_to_split->work_amount = loop_to_fuse->increment; + loop_to_split->set_work_amount(loop_to_fuse->get_increment()); LinearIR::constExprIt loop_begin_pos, loop_end_pos; LoopManager::get_loop_bounds(linear_ir, - loop_to_split->entry_points, - loop_to_split->exit_points, + loop_to_split->get_entry_points(), + loop_to_split->get_exit_points(), loop_begin_pos, loop_end_pos, loop_to_split_id); const auto split_loop_id = loop_manager->mark_loop(loop_begin_pos, loop_end_pos, - loop_to_fuse->work_amount, - loop_to_fuse->increment, - loop_to_split->dim_idx, - loop_to_split->entry_points, - loop_to_split->exit_points); - loop_manager->get_loop_info(split_loop_id)->outer_splited_loop = true; + loop_to_fuse->get_work_amount(), + loop_to_fuse->get_increment(), + loop_to_split->get_dim_idx(), + loop_to_split->get_entry_points(), + loop_to_split->get_exit_points()); + loop_manager->get_loop_info(split_loop_id)->set_outer_splited_loop(true); break; } } diff --git a/src/common/snippets/src/lowered/pass/validate_loops.cpp b/src/common/snippets/src/lowered/pass/validate_loops.cpp index d618e84149b8fc..2377feec95c477 100644 --- a/src/common/snippets/src/lowered/pass/validate_loops.cpp +++ b/src/common/snippets/src/lowered/pass/validate_loops.cpp @@ -4,9 +4,10 @@ #include "snippets/lowered/pass/validate_loops.hpp" +#include "snippets/itt.hpp" #include "snippets/lowered/linear_ir.hpp" #include "snippets/lowered/loop_manager.hpp" -#include "snippets/itt.hpp" +#include "snippets/utils.hpp" namespace ov { namespace snippets { @@ -40,8 +41,8 @@ bool ValidateLoops::run(LinearIR& linear_ir) { std::vector dim_indexes; - auto validate_loop_ports = [&loop_manager, &dim_indexes, &validated_nested_loops, &is_already_verified](std::vector& loop_ports) { - for (auto& loop_port : loop_ports) { + auto validate_loop_ports = [&loop_manager, &dim_indexes, &validated_nested_loops, &is_already_verified](const std::vector& loop_ports) { + for (const auto& loop_port : loop_ports) { const auto expr = loop_port.expr_port->get_expr(); const auto loop_ids = expr->get_loop_ids(); // If loop_ids of the current port is subsequence of already validated IDs, skip @@ -53,27 +54,49 @@ bool ValidateLoops::run(LinearIR& linear_ir) { // Outer Loop -> Inner Loop for (size_t i = 0; i < loop_ids.size(); ++i) { const auto id = loop_ids[i]; - const auto dim_idx = loop_manager->get_loop_info(id)->dim_idx; + const auto dim_idx = loop_manager->get_loop_info(id)->get_dim_idx(); + // if the loop has different dimension indexes, it don't have to meet the split loop related requirements + if (dim_idx == LinearIR::LoopManager::LoopInfo::UNDEFINED_DIM_IDX) + continue; if (std::find(dim_indexes.cbegin(), dim_indexes.cend(), dim_idx) != dim_indexes.cend()) { OPENVINO_ASSERT(*dim_indexes.rbegin() == dim_idx, "Incorrect Loop ID configuration: the Loops with splitted dimension should be successively nested"); - OPENVINO_ASSERT(loop_manager->get_loop_info(loop_ids[i - 1])->increment == loop_manager->get_loop_info(id)->work_amount, + OPENVINO_ASSERT(loop_manager->get_loop_info(loop_ids[i - 1])->get_increment() == loop_manager->get_loop_info(id)->get_work_amount(), "Incorrect Loop ID configuration: the Loops with splitted dimension should be successively nested"); - OPENVINO_ASSERT(loop_manager->get_loop_info(loop_ids[i - 1])->outer_splited_loop, + OPENVINO_ASSERT(loop_manager->get_loop_info(loop_ids[i - 1])->get_outer_splited_loop(), "Incorrect Loop ID configuration: the outer Loop with splitted dimension should have `outer_splited_loop=True`"); } - OPENVINO_ASSERT(i == 0 || loop_manager->get_loop_info(loop_ids[i - 1])->dim_idx >= dim_idx, - "Incorrect Loop ID configuration: dim_idx should be sorted in accordance with loop nesting"); dim_indexes.push_back(dim_idx); } validated_nested_loops.insert(loop_ids); } }; + auto add_ports_dims_to_unique_dims = [](const std::vector& loop_ports, std::set& unique_dims, bool is_entry) { + for (const auto& loop_port : loop_ports) { + if (!loop_port.is_incremented) + continue; + const auto planar_shape = is_entry ? ov::snippets::utils::get_planar_vdims(*loop_port.expr_port) + : ov::snippets::utils::get_preordered_vdims(*loop_port.expr_port); + const auto& dim = *(planar_shape.rbegin() + loop_port.dim_idx); + // Since dim == 1 can be broadcasted to any value, it's not necessary to add it to unique dims + if (dim != 1) + unique_dims.insert(dim); + } + }; + for (const auto& pair : loops) { const auto& loop_info = pair.second; - validate_loop_ports(loop_info->entry_points); - validate_loop_ports(loop_info->exit_points); + const auto& entry_points = loop_info->get_entry_points(); + const auto& exit_points = loop_info->get_exit_points(); + validate_loop_ports(entry_points); + validate_loop_ports(exit_points); + + std::set unique_dimensions; + add_ports_dims_to_unique_dims(entry_points, unique_dimensions, true); + add_ports_dims_to_unique_dims(exit_points, unique_dimensions, false); + OPENVINO_ASSERT(unique_dimensions.size() <= 1, + "Loop ports have incompatible dimensions, by which the loop iterates"); } return true; diff --git a/src/common/snippets/src/op/broadcastload.cpp b/src/common/snippets/src/op/broadcastload.cpp index 68fd39c0610560..9775b2cc572421 100644 --- a/src/common/snippets/src/op/broadcastload.cpp +++ b/src/common/snippets/src/op/broadcastload.cpp @@ -11,8 +11,8 @@ namespace ov { namespace snippets { namespace op { -BroadcastLoad::BroadcastLoad(const Output& x, ov::PartialShape shape, size_t offset) - : MemoryAccess({x}, std::set{0}, std::set{}), output_shape(std::move(shape)) { +BroadcastLoad::BroadcastLoad(const Output& x, ov::Dimension bcast_dimension, size_t offset) + : MemoryAccess({x}, std::set{0}, std::set{}), bcast_dimension(std::move(bcast_dimension)) { set_input_port_descriptor({1, offset}, 0); constructor_validate_and_infer_types(); } @@ -25,7 +25,7 @@ bool BroadcastLoad::visit_attributes(AttributeVisitor& visitor) { std::shared_ptr BroadcastLoad::clone_with_new_inputs(const OutputVector& new_args) const { INTERNAL_OP_SCOPE(BroadcastLoad); check_new_args_count(this, new_args); - return std::make_shared(new_args.at(0), output_shape, get_offset()); + return std::make_shared(new_args.at(0), bcast_dimension, get_offset()); } void BroadcastLoad::validate_and_infer_types() { @@ -34,7 +34,11 @@ void BroadcastLoad::validate_and_infer_types() { const auto output_ma_ports = get_memory_access_output_ports(); OPENVINO_ASSERT(input_ma_ports.size() == 1 && is_memory_access_input_port(0), "BroadcastLoad node must have memory access input port"); OPENVINO_ASSERT(output_ma_ports.size() == 0, "BroadcastLoad node mustn't have memory access output port"); - set_output_type(0, get_input_element_type(0), output_shape); + auto broadcasted_shape = get_input_partial_shape(0); + if (broadcasted_shape.size() == 0) + broadcasted_shape.resize(1); + *broadcasted_shape.rbegin() = bcast_dimension; + set_output_type(0, get_input_element_type(0), broadcasted_shape); } } // namespace op diff --git a/src/common/snippets/src/op/broadcastmove.cpp b/src/common/snippets/src/op/broadcastmove.cpp index 12242d4ba76c44..ee9b715077beef 100644 --- a/src/common/snippets/src/op/broadcastmove.cpp +++ b/src/common/snippets/src/op/broadcastmove.cpp @@ -11,23 +11,27 @@ namespace ov { namespace snippets { namespace op { -BroadcastMove::BroadcastMove(const Output& x, ov::PartialShape shape) : Op({x}), output_shape(std::move(shape)) { +BroadcastMove::BroadcastMove(const Output& x, ov::Dimension bcast_dimension) : Op({x}), bcast_dimension(std::move(bcast_dimension)) { constructor_validate_and_infer_types(); } bool BroadcastMove::visit_attributes(AttributeVisitor& visitor) { - visitor.on_attribute("output_shape", output_shape); + visitor.on_attribute("bcast_dimension", bcast_dimension); return true; } std::shared_ptr BroadcastMove::clone_with_new_inputs(const OutputVector& new_args) const { INTERNAL_OP_SCOPE(BroadcastMove); check_new_args_count(this, new_args); - return std::make_shared(new_args.at(0), output_shape); + return std::make_shared(new_args.at(0), bcast_dimension); } void BroadcastMove::validate_and_infer_types() { - set_output_type(0, get_input_element_type(0), this->output_shape); + auto broadcasted_shape = get_input_partial_shape(0); + if (broadcasted_shape.size() == 0) + broadcasted_shape.resize(1); + *broadcasted_shape.rbegin() = bcast_dimension; + set_output_type(0, get_input_element_type(0), broadcasted_shape); } } // namespace op diff --git a/src/common/snippets/src/op/buffer.cpp b/src/common/snippets/src/op/buffer.cpp index 615979ec5e3281..36bc185dd8b2a9 100644 --- a/src/common/snippets/src/op/buffer.cpp +++ b/src/common/snippets/src/op/buffer.cpp @@ -13,79 +13,96 @@ namespace ov { namespace snippets { namespace op { +Buffer::Buffer(const OutputVector& arguments, const ov::Shape& shape, size_t id, ov::element::Type element_type) + : Op(arguments), m_shape(shape), m_id(id), m_element_type(std::move(element_type)), m_offset(0) { + constructor_validate_and_infer_types(); +} + +bool Buffer::visit_attributes(AttributeVisitor& visitor) { + INTERNAL_OP_SCOPE(Buffer_visit_attributes); + visitor.on_attribute("allocation_shape", m_shape); + visitor.on_attribute("offset", m_offset); + visitor.on_attribute("id", m_id); + visitor.on_attribute("element_type", m_element_type); + return true; +} + +size_t Buffer::get_byte_size() const { + const auto shape = get_allocation_shape(); + return ov::shape_size(shape) * m_element_type.size(); +} -Buffer::Buffer(const ov::Shape& shape, ov::element::Type element_type, size_t id) - : Op(), m_type(Type::NewMemory), m_shape(shape), m_offset(0), m_id(id), m_element_type(std::move(element_type)) { +IntermediateMemoryBuffer::IntermediateMemoryBuffer(const ov::Output& arg, const ov::Shape& shape, size_t id) + : Buffer({arg}, shape, id) { constructor_validate_and_infer_types(); } -Buffer::Buffer(const ov::Output& arg, const ov::Shape& shape, size_t id) - : Op({arg}), m_type(Type::IntermediateMemory), m_shape(shape), m_offset(0), m_id(id) { +IntermediateMemoryBuffer::IntermediateMemoryBuffer(const ov::Output& arg, int32_t allocation_rank, size_t id) + : Buffer({arg}, compute_shape_from_allocation_rank(arg, allocation_rank), id) { constructor_validate_and_infer_types(); } -Buffer::Buffer(const ov::Output& arg, int32_t allocation_rank, size_t id) - : Op({arg}), m_type(Type::IntermediateMemory), m_offset(0), m_id(id) { +ov::Shape IntermediateMemoryBuffer::compute_shape_from_allocation_rank(const ov::Output& arg, int32_t allocation_rank) { const auto& pshape = arg.get_partial_shape(); OPENVINO_ASSERT(pshape.is_static(), "Buffer supports only static input shape"); const auto shape = pshape.get_shape(); const auto normalize_rank = utils::normalize_rank(static_cast(allocation_rank), shape.size()); const auto offset = static_cast(shape.size()) - normalize_rank; - m_shape = {shape.begin() + offset, shape.end()}; - constructor_validate_and_infer_types(); -} - -bool Buffer::visit_attributes(AttributeVisitor& visitor) { - INTERNAL_OP_SCOPE(Buffer_visit_attributes); - visitor.on_attribute("allocation_shape", m_shape); - visitor.on_attribute("offset", m_offset); - visitor.on_attribute("id", m_id); - visitor.on_attribute("element_type", m_element_type); - return true; + return ov::Shape{shape.begin() + offset, shape.end()}; } -void Buffer::validate_and_infer_types() { +void IntermediateMemoryBuffer::validate_and_infer_types() { INTERNAL_OP_SCOPE(Buffer_validate_and_infer_types); ov::PartialShape output_shape; - if (m_type == Type::NewMemory) { - OPENVINO_ASSERT(get_input_size() == 0, "Buffer with new allocated memory must to not have arguments!"); - output_shape = m_shape; - } else if (m_type == Type::IntermediateMemory) { - m_element_type = get_input_element_type(0); - output_shape = get_input_partial_shape(0); - } else { - OPENVINO_THROW("Buffer supports only the following types: NewMemory and IntermediateMemory"); - } + m_element_type = get_input_element_type(0); + output_shape = get_input_partial_shape(0); set_output_type(0, m_element_type, output_shape); } -std::shared_ptr Buffer::clone_with_new_inputs(const OutputVector& new_args) const { +std::shared_ptr IntermediateMemoryBuffer::clone_with_new_inputs(const OutputVector& new_args) const { INTERNAL_OP_SCOPE(Buffer_clone_with_new_inputs); check_new_args_count(this, new_args); - std::shared_ptr new_buffer = nullptr; - if (m_type == Type::NewMemory) { - new_buffer = std::make_shared(m_shape, m_element_type, m_id); - } else if (m_type == Type::IntermediateMemory) { - new_buffer = std::make_shared(new_args.at(0), m_shape, m_id); - } else { - OPENVINO_THROW("Buffer supports only the following types: NewMemory and IntermediateMemory"); - } - new_buffer->m_offset = m_offset; + auto new_buffer = std::make_shared(new_args.at(0), m_shape, m_id); + new_buffer->set_offset(m_offset); return new_buffer; } -size_t Buffer::get_byte_size() const { - const auto shape = get_allocation_shape(); - return ov::shape_size(shape) * get_element_type().size(); +NewMemoryBuffer::NewMemoryBuffer(const ov::Shape& shape, size_t id, ov::element::Type element_type) + : Buffer({}, shape, id, element_type) { + constructor_validate_and_infer_types(); +} + +void NewMemoryBuffer::validate_and_infer_types() { + INTERNAL_OP_SCOPE(Buffer_validate_and_infer_types); + OPENVINO_ASSERT(get_input_size() == 0, "Buffer with new allocated memory mustn't have arguments!"); + set_output_type(0, m_element_type, m_shape); +} + +std::shared_ptr NewMemoryBuffer::clone_with_new_inputs(const OutputVector& new_args) const { + INTERNAL_OP_SCOPE(Buffer_clone_with_new_inputs); + check_new_args_count(this, new_args); + auto new_buffer = std::make_shared(m_shape, m_id, m_element_type); + new_buffer->set_offset(m_offset); + return new_buffer; } -void Buffer::set_element_type(ov::element::Type element_type) { - OPENVINO_ASSERT(is_new_memory(), "Only Buffer with NewMemory can change his output precision!"); +void NewMemoryBuffer::set_element_type(ov::element::Type element_type) { m_element_type = std::move(element_type); // Apply the change validate_and_infer_types(); } +NewMemoryBuffer::ShapeInfer::ShapeInfer(const std::shared_ptr& n) { + const auto& buffer = ov::as_type_ptr(n); + OPENVINO_ASSERT(buffer, "Got invalid node in NewMemoryBuffer::ShapeInfer"); + m_shape = buffer->get_shape(); +} + +IShapeInferSnippets::Result NewMemoryBuffer::ShapeInfer::infer(const std::vector& input_shapes) { + OPENVINO_ASSERT(input_shapes.empty(), "NewMemoryBuffer shape inference mustn't have input shapes"); + return {{m_shape}, ShapeInferStatus::success}; +} + } // namespace op } // namespace snippets } // namespace ov diff --git a/src/common/snippets/src/op/loop.cpp b/src/common/snippets/src/op/loop.cpp index 47e3936e388b53..32fed5a6b28ed7 100644 --- a/src/common/snippets/src/op/loop.cpp +++ b/src/common/snippets/src/op/loop.cpp @@ -49,31 +49,11 @@ bool LoopBegin::visit_attributes(AttributeVisitor &visitor) { } LoopEnd::LoopEnd(const Output& loop_begin, size_t work_amount, size_t work_amount_increment, - std::vector apply_increments, std::vector finalization_offsets, - std::vector element_type_sizes, size_t input_num, size_t output_num, size_t id) - : LoopBase({loop_begin}), - has_outer_loop(true), - m_finalization_offsets(std::move(finalization_offsets)), - m_element_type_sizes(std::move(element_type_sizes)), - m_work_amount(work_amount), - m_work_amount_increment(work_amount_increment), - m_input_num(input_num), - m_output_num(output_num), - m_id(id), - m_evaluate_once(false) { - m_ptr_increments.resize(apply_increments.size()); - std::transform(apply_increments.begin(), apply_increments.end(), m_ptr_increments.begin(), - [](bool apply) { - return apply ? 1 : 0; - }); - constructor_validate_and_infer_types(); -} - -LoopEnd::LoopEnd(const Output& loop_begin, size_t work_amount, size_t work_amount_increment, - std::vector ptr_increments, std::vector finalization_offsets, + std::vector is_incremented, std::vector ptr_increments, std::vector finalization_offsets, std::vector element_type_sizes, size_t input_num, size_t output_num, size_t id) : LoopBase({loop_begin}), has_outer_loop(true), + m_is_incremented(std::move(is_incremented)), m_ptr_increments(std::move(ptr_increments)), m_finalization_offsets(std::move(finalization_offsets)), m_element_type_sizes(std::move(element_type_sizes)), @@ -88,7 +68,7 @@ LoopEnd::LoopEnd(const Output& loop_begin, size_t work_amount, size_t work std::shared_ptr LoopEnd::clone_with_new_inputs(const OutputVector& inputs) const { check_new_args_count(this, inputs); - const auto loop_end = std::make_shared(inputs.at(0), m_work_amount, m_work_amount_increment, m_ptr_increments, + const auto loop_end = std::make_shared(inputs.at(0), m_work_amount, m_work_amount_increment, m_is_incremented, m_ptr_increments, m_finalization_offsets, m_element_type_sizes, m_input_num, m_output_num, m_id); loop_end->m_evaluate_once = m_evaluate_once; return loop_end; @@ -105,6 +85,10 @@ const std::vector& LoopEnd::get_finalization_offsets() const { return m_finalization_offsets; } +const std::vector& LoopEnd::get_is_incremented() const { + return m_is_incremented; +} + const std::vector& LoopEnd::get_ptr_increments()const { return m_ptr_increments; } @@ -168,6 +152,10 @@ void LoopEnd::set_evaluate_once(bool once) { m_evaluate_once = once; } +void LoopEnd::set_id(size_t new_id) { + m_id = new_id; +} + void LoopEnd::validate_and_infer_types() { NODE_VALIDATION_CHECK(this, get_input_size() == 1, "LoopEnd must have one input"); const auto loop_begin = ov::as_type_ptr(get_input_node_shared_ptr(0)); @@ -194,6 +182,7 @@ bool LoopEnd::visit_attributes(AttributeVisitor &visitor) { visitor.on_attribute("input_num", m_input_num); visitor.on_attribute("output_num", m_output_num); visitor.on_attribute("id", m_id); + visitor.on_attribute("evaluate_once", m_evaluate_once); return true; } diff --git a/src/common/snippets/src/op/perf_count.cpp b/src/common/snippets/src/op/perf_count.cpp new file mode 100644 index 00000000000000..66061753373e18 --- /dev/null +++ b/src/common/snippets/src/op/perf_count.cpp @@ -0,0 +1,115 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "snippets/op/perf_count.hpp" + +namespace ov { +namespace snippets { +namespace op { + +/////////////////PerfCountBeginBase///////////////// +PerfCountBeginBase::PerfCountBeginBase(const std::vector>& args) : Op() {} + +void PerfCountBeginBase::validate_and_infer_types() { + validate_and_infer_types_except_PerfCountEnd(); + OPENVINO_ASSERT(get_output_size() == 1, "PerfCountBegin must have only one output"); + const auto& last_output_inputs = get_output_target_inputs(0); + OPENVINO_ASSERT(last_output_inputs.size() == 1, "PerfCountBegin must have exactly one input attached to the last output"); + const auto& pc_end = ov::as_type_ptr(last_output_inputs.begin()->get_node()->shared_from_this()); + OPENVINO_ASSERT(pc_end != nullptr, "PerfCountBegin must have PerfCountEnd connected to its last output"); +} + +bool PerfCountBeginBase::visit_attributes(AttributeVisitor &visitor) { + return true; +} + +void PerfCountBeginBase::validate_and_infer_types_except_PerfCountEnd() { + NODE_VALIDATION_CHECK(this, get_input_size() == 0, "PerfCountBegin doesn't expect any inputs"); + set_output_type(0, element::f32, {}); +} + +//////////////////PerfCountEndBase///////////////// +PerfCountEndBase::PerfCountEndBase(const std::vector> &args) : Op(args) {} + +void PerfCountEndBase::validate_and_infer_types() { + NODE_VALIDATION_CHECK(this, get_input_size() == 1, "PerfCountEndBase must have one input"); + const auto& pc_begin = ov::as_type_ptr(get_input_node_shared_ptr(0)); + NODE_VALIDATION_CHECK(this, pc_begin != nullptr, "PerfCountEndBase must have PerfCountBeginBase as the last argument"); + set_output_type(0, element::f32, {}); +} + +bool PerfCountEndBase::visit_attributes(AttributeVisitor &visitor) { + return true; +} + +/////////////////PerfCountBegin///////////////// +PerfCountBegin::PerfCountBegin() : PerfCountBeginBase() { + validate_and_infer_types_except_PerfCountEnd(); +} + +std::shared_ptr PerfCountBegin::clone_with_new_inputs(const OutputVector& inputs) const { + return std::make_shared(); +} + +std::chrono::high_resolution_clock::time_point& PerfCountBegin::get_start_time() { + return start_time_stamp.local(); +} + +void PerfCountBegin::set_start_time() { + start_time_stamp.local() = std::chrono::high_resolution_clock::now(); +} + +//////////////////PerfCountEnd/////////////// +PerfCountEnd::PerfCountEnd(const Output& pc_begin) : PerfCountEndBase({pc_begin}), accumulation(0ul), iteration(0u) { + constructor_validate_and_infer_types(); + init_pc_begin(); +} + +std::shared_ptr PerfCountEnd::clone_with_new_inputs(const OutputVector& inputs) const { + return std::make_shared(inputs.at(0)); +} + +void PerfCountEnd::set_accumulated_time() { + auto current_time = std::chrono::high_resolution_clock::now(); + auto& start_time = m_pc_begin->get_start_time(); + accumulation.local() += std::chrono::duration_cast(current_time - start_time).count(); + iteration.local()++; +} + +void PerfCountEnd::init_pc_begin() { + m_pc_begin = ov::as_type_ptr(get_input_source_output(get_input_size() - 1).get_node_shared_ptr()); + NODE_VALIDATION_CHECK(this, m_pc_begin != nullptr, "PerfCountEnd last input is not connected to PerfCountBegin"); +} + +void PerfCountEnd::output_perf_count() { + OPENVINO_ASSERT(accumulation.size() == iteration.size(), "accumulation size should be the same as iteration size in perf_count_end node."); + auto iterator_iter = iteration.begin(); + auto iterator_acc = accumulation.begin(); + int t_num = 0; + uint64_t avg_max = 0; + std::cout << "Perf count data in perfCountEnd node with name " << get_friendly_name() << " is:"<< std::endl; + for (; iterator_iter != iteration.end(); ++iterator_iter, ++iterator_acc) { + const auto iter = *iterator_iter; + const auto acc = *iterator_acc; + uint64_t avg = iter == 0 ? 0 : acc / iter; + if (avg > avg_max) + avg_max = avg; + std::cout << "accumulated time:" << acc << "ns, iteration:" << iter << " avg time:" << avg << "ns"<< " on thread:" << t_num << std::endl; + t_num++; + } + + // max time of all threads: combine for reduce max + auto BinaryFunc = [](const uint64_t& a, const uint64_t& b) { + return a >= b ? a : b; + }; + // max accumulation + uint64_t acc_max = accumulation.combine(BinaryFunc); + std::cout << "max accumulated time:" << acc_max << "ns" << std::endl; + // max avg + std::cout << "max avg time:" << avg_max << "ns" << std::endl; +} + +} // namespace op +} // namespace snippets +} // namespace ov diff --git a/src/common/snippets/src/op/serialization_node.cpp b/src/common/snippets/src/op/serialization_node.cpp index 6c521cc856f214..263294e5712c7d 100644 --- a/src/common/snippets/src/op/serialization_node.cpp +++ b/src/common/snippets/src/op/serialization_node.cpp @@ -23,7 +23,7 @@ SerializationNode::SerializationNode(const ov::OutputVector& args, const std::sh } void SerializationNode::validate_and_infer_types() { - set_output_type(0, element::f32, {}); + set_output_type(0, element::f32, ov::PartialShape{}); } std::shared_ptr SerializationNode::clone_with_new_inputs(const OutputVector &new_args) const { diff --git a/src/common/snippets/src/op/subgraph.cpp b/src/common/snippets/src/op/subgraph.cpp index 02e87459056d3b..f71042be6289ff 100644 --- a/src/common/snippets/src/op/subgraph.cpp +++ b/src/common/snippets/src/op/subgraph.cpp @@ -34,7 +34,6 @@ #include "snippets/lowered/pass/load_movebroadcast_to_broadcastload.hpp" #include "snippets/lowered/pass/allocate_buffers.hpp" #include "snippets/lowered/pass/propagate_layout.hpp" -#include "snippets/lowered/pass/cleanup_loop_offsets.hpp" #include "snippets/lowered/pass/softmax_decomposition.hpp" #include "snippets/lowered/pass/move_scalar_to_consumer.hpp" #include "snippets/lowered/pass/move_result_out_of_loop.hpp" @@ -42,6 +41,7 @@ #include "snippets/lowered/pass/validate_loops.hpp" #include "snippets/lowered/pass/insert_loops.hpp" #include "snippets/lowered/pass/optimize_domain.hpp" +#include "snippets/lowered/pass/insert_perf_count.hpp" #include "transformations/utils/utils.hpp" @@ -349,7 +349,8 @@ VectorDims Subgraph::infer_master_shape() { std::shared_ptr Subgraph::convert_body_to_linear_ir(const std::shared_ptr& shape_infer_factory) { lowered::Config lowering_config; - lowering_config.m_save_expressions = config.m_has_domain_sensitive_ops; + lowering_config.m_save_expressions = config.m_has_domain_sensitive_ops || + (lowering_config.perf_count_mode != lowered::PerfCountMode::Disabled); lowering_config.m_need_fill_tail_register = config.m_has_domain_sensitive_ops; lowering_config.m_loop_depth = tileRank; lowering_config.m_enable_domain_optimization = !config.m_has_domain_sensitive_ops; @@ -427,12 +428,19 @@ void Subgraph::control_flow_transformations(lowered::LinearIR& linear_ir, const size_t vector_size = get_generator()->get_target_machine()->get_lanes(); const int32_t buffer_allocation_rank = static_cast(linear_ir.get_config().m_loop_depth); + // We have to call MarkLoops before backend markup passes + // because these passes can update subtensor but not insert Loop (e.g. when loop increment is equal to the corresponding dim) + // If MarkLoops is called on such LIR, it inserts Eltwise-like loops which might not reflect backend expectations + // It should be fixed by ticket 113666 + lowered::pass::PassPipeline markup_pipeline; + markup_pipeline.register_pass(vector_size); + markup_pipeline.run(linear_ir); + // Ticket: 113666 // TODO: Make pass pipeline with backend passes more flexible backend_passes_pre_common.run(linear_ir); lowered::pass::PassPipeline common_pipeline; - common_pipeline.register_pass(vector_size); common_pipeline.register_pass(vector_size); common_pipeline.register_pass(); common_pipeline.register_pass(); @@ -456,7 +464,6 @@ void Subgraph::control_flow_transformations(lowered::LinearIR& linear_ir, final_pipeline.register_pass(lowering_result.buffer_scratchpad_size, linear_ir.get_config().m_are_buffers_optimized); final_pipeline.register_pass(); final_pipeline.register_pass(); - final_pipeline.register_pass(); final_pipeline.run(linear_ir); } @@ -487,6 +494,10 @@ snippets::Schedule Subgraph::generate_from_linear_ir(const lowered::pass::PassPi auto linear_ir {*m_linear_ir->clone()}; LoweringResult lowering_result; control_flow_transformations(linear_ir, lowering_result, backend_passes_pre_common, backend_passes_post_common); + if (linear_ir.get_config().perf_count_mode == lowered::PerfCountMode::Chrono) { + lowered::pass::InsertPerfCount perf_count_pass; + perf_count_pass.run(linear_ir); + } m_generator->generate(linear_ir, lowering_result, compile_params); VectorDims parallel_exec_domain = linear_ir.get_master_shape(); diff --git a/src/common/snippets/src/pass/broadcast_to_movebroadcast.cpp b/src/common/snippets/src/pass/broadcast_to_movebroadcast.cpp index cd803b163b5bbf..a3e687d44b3b38 100644 --- a/src/common/snippets/src/pass/broadcast_to_movebroadcast.cpp +++ b/src/common/snippets/src/pass/broadcast_to_movebroadcast.cpp @@ -35,9 +35,8 @@ ov::snippets::pass::BroadcastToMoveBroadcast::BroadcastToMoveBroadcast() { // will be handled by pointer arithmetics. Note that this behavior should be changed in case of full op::Boradcast support. Output in_value = root->input_value(0); if (*target_shape.rbegin() != *value_shape.rbegin()) { - auto broadcasted_shape = value_shape; - *broadcasted_shape.rbegin() = *target_shape.rbegin(); - const auto& broadcast_node = std::make_shared(in_value, broadcasted_shape); + auto broadcasted_dim = ov::Dimension(*target_shape.rbegin()); + const auto& broadcast_node = std::make_shared(in_value, broadcasted_dim); in_value = broadcast_node->output(0); } diff --git a/src/common/snippets/src/pass/insert_movebroadcast.cpp b/src/common/snippets/src/pass/insert_movebroadcast.cpp index bbc2865fdb42a8..38b85d11a19c07 100644 --- a/src/common/snippets/src/pass/insert_movebroadcast.cpp +++ b/src/common/snippets/src/pass/insert_movebroadcast.cpp @@ -44,8 +44,7 @@ ov::Output ov::snippets::pass::InsertMoveBroadcast::BroadcastNodeLastD // will be handled by pointer arithmetics inside outer LoopEmitter if (*target_shape.rbegin() != *normalized_shape.rbegin()) { ov::PartialShape broadcasted_shape = normalized_shape; - *broadcasted_shape.rbegin() = *target_shape.rbegin(); - const auto broadcast_node = std::make_shared(value, broadcasted_shape); + const auto broadcast_node = std::make_shared(value, *target_shape.rbegin()); copy_runtime_info(value.get_node_shared_ptr(), broadcast_node); return broadcast_node->output(0); diff --git a/src/common/snippets/src/shape_inference/shape_infer_instances.cpp b/src/common/snippets/src/shape_inference/shape_infer_instances.cpp index 61404d208fd5a7..44c1065d8260a7 100644 --- a/src/common/snippets/src/shape_inference/shape_infer_instances.cpp +++ b/src/common/snippets/src/shape_inference/shape_infer_instances.cpp @@ -103,16 +103,17 @@ BroadcastShapeInfer::BroadcastShapeInfer(const std::shared_ptr() || std::is_base_of(), "This ShapeInfer class could be used only for BroadcastMove and BroadcastLoad operations."); - const auto& broadcast = as_type_ptr(n); - OPENVINO_ASSERT(broadcast, "Invalid node passed to BroadcastShapeInfer.", + broadcast_op = as_type_ptr(n); + OPENVINO_ASSERT(broadcast_op, "Invalid node passed to BroadcastShapeInfer.", "Expected ", typeid(BroadcastOP).name(), "got ", n->get_type_name()); - const auto last_dim = *broadcast->get_output_shape().rbegin(); - m_broadcasted_dim = last_dim.is_dynamic() ? IShapeInferSnippets::DYNAMIC_DIMENSION : last_dim.get_length(); } + template Result BroadcastShapeInfer::infer(const std::vector& input_shapes) { auto out_shape = input_shapes[0].get(); - out_shape.back() = m_broadcasted_dim; + const auto& bcasted_dim = broadcast_op->get_bcast_dimension(); + OPENVINO_ASSERT(bcasted_dim.is_static()); + out_shape.back() = bcasted_dim.get_length(); return {{out_shape}, ShapeInferStatus::success}; } diff --git a/src/common/snippets/src/shape_inference/shape_inference.cpp b/src/common/snippets/src/shape_inference/shape_inference.cpp index 0b9117d05d0477..2ae7487128b978 100644 --- a/src/common/snippets/src/shape_inference/shape_inference.cpp +++ b/src/common/snippets/src/shape_inference/shape_inference.cpp @@ -39,7 +39,7 @@ const IShapeInferSnippetsFactory::TRegistry IShapeInferSnippetsFactory::registry SHAPE_INFER_PREDEFINED(op::ConvertSaturation, PassThroughShapeInfer), SHAPE_INFER_PREDEFINED(op::Load, PassThroughShapeInfer), SHAPE_INFER_PREDEFINED(op::Store, PassThroughShapeInfer), - SHAPE_INFER_PREDEFINED(op::Buffer, PassThroughShapeInfer), + SHAPE_INFER_PREDEFINED(op::IntermediateMemoryBuffer, PassThroughShapeInfer), SHAPE_INFER_PREDEFINED(op::Fill, PassThroughShapeInfer), SHAPE_INFER_PREDEFINED(ov::op::v0::Parameter, PassThroughShapeInfer), // Note: We should remove Softmax shape infers after the decomposition activity, @@ -55,6 +55,8 @@ const IShapeInferSnippetsFactory::TRegistry IShapeInferSnippetsFactory::registry SHAPE_INFER_PREDEFINED(op::Scalar, SingleElementShapeInfer), SHAPE_INFER_PREDEFINED(op::VectorBuffer, SingleElementShapeInfer), SHAPE_INFER_PREDEFINED(op::LoopEnd, EmptyShapeInfer), + SHAPE_INFER_PREDEFINED(op::PerfCountBegin, EmptyShapeInfer), + SHAPE_INFER_PREDEFINED(op::PerfCountEnd, EmptyShapeInfer), SHAPE_INFER_PREDEFINED(op::Kernel, EmptyShapeInfer), SHAPE_INFER_PREDEFINED(op::Nop, EmptyShapeInfer), SHAPE_INFER_OP_SPECIFIC_EXTERNAL(opset1::Select, SelectShapeInfer), @@ -66,6 +68,7 @@ const IShapeInferSnippetsFactory::TRegistry IShapeInferSnippetsFactory::registry SHAPE_INFER_OP_SPECIFIC(op::RankNormalization), SHAPE_INFER_OP_SPECIFIC(op::BroadcastLoad), SHAPE_INFER_OP_SPECIFIC(op::BroadcastMove), + SHAPE_INFER_OP_SPECIFIC(op::NewMemoryBuffer), }; #undef SHAPE_INFER_OP_SPECIFIC_EXTERNAL #undef SHAPE_INFER_OP_SPECIFIC diff --git a/src/common/snippets/tests/src/lowered/pass/buffer_allocation.cpp b/src/common/snippets/tests/src/lowered/pass/buffer_allocation.cpp index 4dc6ac8d365208..fe887cecd96f17 100644 --- a/src/common/snippets/tests/src/lowered/pass/buffer_allocation.cpp +++ b/src/common/snippets/tests/src/lowered/pass/buffer_allocation.cpp @@ -92,9 +92,9 @@ std::shared_ptr EltwiseBufferAllocationTest::GetModel() const { const auto parameter0 = std::make_shared(ov::element::f32, ov::PartialShape({1, 3, 100, 100})); const auto parameter1 = std::make_shared(ov::element::f32, ov::PartialShape({1, 3, 100, 100})); const auto add = std::make_shared(parameter0, parameter1); - const auto buffer0 = std::make_shared(add, static_cast(subtensor_buffer.size())); + const auto buffer0 = std::make_shared(add, static_cast(subtensor_buffer.size())); const auto relu = std::make_shared(buffer0); - const auto buffer1 = std::make_shared(relu, static_cast(subtensor_buffer.size())); + const auto buffer1 = std::make_shared(relu, static_cast(subtensor_buffer.size())); const auto exp = std::make_shared(buffer1); const auto body = std::make_shared(std::make_shared(exp), ov::ParameterVector{parameter0, parameter1}); @@ -119,7 +119,7 @@ void MHABufferAllocationTest::MarkBrgemm(const std::shared_ptr MHABufferAllocationTest::GetModel() const { - const auto subtensor_scalar = std::vector{1, 1}; + const auto subtensor_scalar = std::vector{1}; const auto subtensor_eltwise = std::vector{1, m_vector_size}; const auto subtensor_brgemm = std::vector{32, ov::snippets::lowered::PortDescriptor::ServiceDimensions::FULL_DIM}; const auto subtensor_softmax = std::vector{1, ov::snippets::lowered::PortDescriptor::ServiceDimensions::FULL_DIM}; @@ -187,7 +187,7 @@ INSTANTIATE_TEST_SUITE_P(smoke_Snippets_BufferAllocation_MHAOptimizedWSplit, MHA ::testing::Values(true), ::testing::Values(true), ::testing::Values(57344), // (Buffer before brgemm) + (between brgemms) + (after brgemm) - ::testing::Values(3)), // (Buffer before brgemm) + (between brgemms) + (after brgemm) + ::testing::Values(2)), // (Buffer before brgemm0 and after brgemm1) + (between brgemms) BufferAllocationTest::getTestCaseName); INSTANTIATE_TEST_SUITE_P(smoke_Snippets_BufferAllocation_MHANotOptimizedWOSplit, MHABufferAllocationTest, diff --git a/src/common/snippets/tests/src/lowered/pass/loop.cpp b/src/common/snippets/tests/src/lowered/pass/loop.cpp index 27b4e3ce95bdca..1e29efa955d517 100644 --- a/src/common/snippets/tests/src/lowered/pass/loop.cpp +++ b/src/common/snippets/tests/src/lowered/pass/loop.cpp @@ -2,21 +2,20 @@ // SPDX-License-Identifier: Apache-2.0 // -#include +#include "snippets/op/loop.hpp" -#include "subgraph_simple.hpp" +#include #include "snippets/lowered/linear_ir.hpp" +#include "snippets/lowered/pass/cleanup_loop_offsets.hpp" #include "snippets/lowered/pass/init_loops.hpp" #include "snippets/lowered/pass/insert_load_store.hpp" -#include "snippets/lowered/pass/cleanup_loop_offsets.hpp" -#include "snippets/lowered/pass/validate_loops.hpp" #include "snippets/lowered/pass/insert_loops.hpp" #include "snippets/lowered/pass/insert_tail_loop.hpp" +#include "snippets/lowered/pass/optimize_loop_single_evaluation.hpp" +#include "snippets/lowered/pass/validate_loops.hpp" #include "snippets/shape_inference/shape_inference.hpp" - -#include "snippets/op/loop.hpp" - +#include "subgraph_simple.hpp" using Snippets_TailProcessingTransformation = ::testing::Test; // [Inserted Loop number, [ptr_increments, final_offsets] @@ -47,7 +46,7 @@ static void init_linear_ir(const std::vector& in_shapes, Linea loop_manager->mark_loop(expr_it, std::next(expr_it), inner_wa, inner_inc, 0, loop_entry_points, loop_exit_points); loop_manager->mark_loop(expr_it, std::next(expr_it), blocked_wa, blocked_inc, 1, loop_entry_points, loop_exit_points); const auto loop_id = loop_manager->mark_loop(expr_it, std::next(expr_it), outer_wa, outer_inc, 1, loop_entry_points, loop_exit_points); - loop_manager->get_loop_info(loop_id)->outer_splited_loop = true; + loop_manager->get_loop_info(loop_id)->set_outer_splited_loop(true); } static void init_pipeline(pass::PassPipeline& pass_pipeline) { @@ -69,6 +68,7 @@ static void validate(const LinearIR& linear_ir, const ref_map& reference) { ASSERT_TRUE(loop_end->get_finalization_offsets() == reference.at(loop_num).second); loop_num++; } + ASSERT_EQ(loop_num, reference.size()); } TEST(Snippets_TailProcessingTransformation, BlockedWOTail_OriginalPtrShifts) { @@ -119,19 +119,20 @@ TEST(Snippets_TailProcessingTransformation, BlockedTail_OriginalPtrShifts) { pass::PassPipeline pass_pipeline; init_pipeline(pass_pipeline); pass_pipeline.register_pass(); + pass_pipeline.register_pass(); pass_pipeline.run(linear_ir); // [Inserted Loop number, [ptr_increments, final_offsets] std::map, std::vector>> reference; - reference[0] = { std::vector(3, 1), std::vector(3, 16)}; // Vector Inner - reference[1] = { std::vector(3, 1), std::vector(3, -16)}; // Blocked Inner + reference[0] = { std::vector(3, 0), std::vector(3, 16)}; // Vector Inner + reference[1] = { std::vector(3, 0), std::vector(3, -16)}; // Blocked Inner reference[2] = { std::vector(3, 20), std::vector(3, -80)}; // Vector Blocked reference[3] = { std::vector(3, 20), std::vector(3, 0)}; // Vector Outer - reference[4] = { std::vector(3, 1), std::vector(3, 16)}; // Vector Inner - reference[5] = { std::vector(3, 1), std::vector(3, -16)}; // Blocked Inner + reference[4] = { std::vector(3, 0), std::vector(3, 16)}; // Vector Inner + reference[5] = { std::vector(3, 0), std::vector(3, -16)}; // Blocked Inner reference[6] = { std::vector(3, 20), std::vector(3, -40)}; // Tail Blocked - reference[7] = { std::vector(3, 20), std::vector(3, -320)}; // Tail Blocked + reference[7] = { std::vector(3, 0), std::vector(3, -320)}; // Tail Blocked validate(linear_ir, reference); } @@ -144,19 +145,20 @@ TEST(Snippets_TailProcessingTransformation, BlockedTail_CleanUpPtrShifts) { pass::PassPipeline pass_pipeline; init_pipeline(pass_pipeline); - pass_pipeline.register_pass(); pass_pipeline.register_pass(); + pass_pipeline.register_pass(); + pass_pipeline.register_pass(); pass_pipeline.run(linear_ir); // [Inserted Loop number, [ptr_increments, final_offsets] std::map, std::vector>> reference; - reference[0] = { std::vector(3, 1), std::vector(3, 16)}; // Vector Inner - reference[1] = { std::vector(3, 1), std::vector(3, 4)}; // Blocked Inner - reference[2] = { std::vector(3, 0), std::vector(3, 0)}; // Vector Blocked + reference[0] = { std::vector(3, 0), std::vector(3, 16)}; // Vector Inner + reference[1] = { std::vector(3, 0), std::vector(3, 4)}; // Blocked Inner + reference[2] = {std::vector(3, 0), std::vector(3, 0)}; // Vector Blocked reference[3] = { std::vector(3, 0), std::vector(3, 0)}; // Vector Outer - reference[4] = { std::vector(3, 1), std::vector(3, 16)}; // Vector Inner - reference[5] = { std::vector(3, 1), std::vector(3, 4)}; // Blocked Inner + reference[4] = { std::vector(3, 0), std::vector(3, 16)}; // Vector Inner + reference[5] = { std::vector(3, 0), std::vector(3, 4)}; // Blocked Inner reference[6] = { std::vector(3, 0), std::vector(3, 0)}; // Tail Blocked reference[7] = { std::vector(3, 0), std::vector(3, 0)}; // Tail Blocked diff --git a/src/common/snippets/tests/src/lowering_utils.cpp b/src/common/snippets/tests/src/lowering_utils.cpp index 5d49d38a6af2e7..0f7c86b48028d3 100644 --- a/src/common/snippets/tests/src/lowering_utils.cpp +++ b/src/common/snippets/tests/src/lowering_utils.cpp @@ -41,8 +41,11 @@ DummyTargetMachine::DummyTargetMachine(const std::vector& jitters[ov::snippets::op::Kernel::get_type_info_static()] = dummy_functor; jitters[ov::snippets::op::LoopBegin::get_type_info_static()] = dummy_functor; jitters[ov::snippets::op::LoopEnd::get_type_info_static()] = dummy_functor; + jitters[ov::snippets::op::PerfCountBegin::get_type_info_static()] = dummy_functor; + jitters[ov::snippets::op::PerfCountEnd::get_type_info_static()] = dummy_functor; jitters[ov::snippets::op::Brgemm::get_type_info_static()] = dummy_functor; - jitters[ov::snippets::op::Buffer::get_type_info_static()] = dummy_functor; + jitters[ov::snippets::op::IntermediateMemoryBuffer::get_type_info_static()] = dummy_functor; + jitters[ov::snippets::op::NewMemoryBuffer::get_type_info_static()] = dummy_functor; jitters[ov::snippets::op::VectorBuffer::get_type_info_static()] = dummy_functor; jitters[ov::snippets::op::Fill::get_type_info_static()] = dummy_functor; diff --git a/src/common/snippets/tests/src/pass/movebroadcast.cpp b/src/common/snippets/tests/src/pass/movebroadcast.cpp index 3779cfaae9f532..caf48b76383d8b 100644 --- a/src/common/snippets/tests/src/pass/movebroadcast.cpp +++ b/src/common/snippets/tests/src/pass/movebroadcast.cpp @@ -28,7 +28,7 @@ TEST_F(TransformationTestsF, InsertBroadcastMove) { { auto data0 = std::make_shared(element::f32, Shape{2, 3}); auto data1 = std::make_shared(element::f32, Shape{1, 2, 1}); - auto move1 = std::make_shared(data1, Shape{1, 2, 3}); + auto move1 = std::make_shared(data1, ov::Dimension{3}); auto add = std::make_shared(data0, move1); model_ref = std::make_shared(NodeVector{add}, ParameterVector{data0, data1}); } diff --git a/src/common/transformations/include/ov_ops/rotary_positional_embeddings.hpp b/src/common/transformations/include/ov_ops/rotary_positional_embeddings.hpp new file mode 100644 index 00000000000000..0ae6db9ddcc3ad --- /dev/null +++ b/src/common/transformations/include/ov_ops/rotary_positional_embeddings.hpp @@ -0,0 +1,38 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include "openvino/op/op.hpp" +#include "transformations_visibility.hpp" + +namespace ov { +namespace op { +namespace internal { + +/// +/// \brief Rotary Positional Embeddings operation +/// Internal operation which may change in the future +/// \ingroup ov_ops_cpp_api +class TRANSFORMATIONS_API RPE : public ov::op::Op { +public: + OPENVINO_OP("RPE", "ie_internal_opset", op::Op); + + RPE() = default; + RPE(const Output& data, const Output& sin, const Output& cos, int64_t axis); + + void set_axis(int64_t axis); + int64_t get_axis() const; + + bool visit_attributes(AttributeVisitor& visitor) override; + void validate_and_infer_types() override; + std::shared_ptr clone_with_new_inputs(const OutputVector& new_args) const override; + +private: + int64_t m_axis{}; +}; + +} // namespace internal +} // namespace op +} // namespace ov diff --git a/src/common/transformations/include/transformations/common_optimizations/fuse_rotary_positional_embeddings.hpp b/src/common/transformations/include/transformations/common_optimizations/fuse_rotary_positional_embeddings.hpp new file mode 100644 index 00000000000000..9c756b48896f62 --- /dev/null +++ b/src/common/transformations/include/transformations/common_optimizations/fuse_rotary_positional_embeddings.hpp @@ -0,0 +1,24 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include "openvino/pass/graph_rewrite.hpp" +#include "transformations_visibility.hpp" + +namespace ov { +namespace pass { +class TRANSFORMATIONS_API RPE_Fusion; +} // namespace pass +} // namespace ov + +/** + * @ingroup ie_transformation_common_api + * @brief Fuses special sub-graph into an internal Rotary Positional Embedding operation + */ +class ov::pass::RPE_Fusion : public ov::pass::MatcherPass { +public: + OPENVINO_RTTI("RPE_Fusion", "0"); + RPE_Fusion(); +}; diff --git a/src/common/transformations/include/transformations/symbolic_transformations/chained_maximum.hpp b/src/common/transformations/include/transformations/symbolic_transformations/chained_maximum.hpp index caa2586ebeeea4..48f80c72cec845 100644 --- a/src/common/transformations/include/transformations/symbolic_transformations/chained_maximum.hpp +++ b/src/common/transformations/include/transformations/symbolic_transformations/chained_maximum.hpp @@ -4,8 +4,8 @@ #pragma once -#include -#include +#include "openvino/pass/graph_rewrite.hpp" +#include "transformations_visibility.hpp" namespace ov { namespace pass { diff --git a/src/common/transformations/include/transformations/symbolic_transformations/dereshape_matmul.hpp b/src/common/transformations/include/transformations/symbolic_transformations/dereshape_matmul.hpp index 6df2e406ee8154..dbe44093623fe4 100644 --- a/src/common/transformations/include/transformations/symbolic_transformations/dereshape_matmul.hpp +++ b/src/common/transformations/include/transformations/symbolic_transformations/dereshape_matmul.hpp @@ -10,6 +10,7 @@ namespace ov { namespace pass { class TRANSFORMATIONS_API DeReshapeMatMul; +class TRANSFORMATIONS_API DeReshapeFullyConnected; } // namespace pass } // namespace ov @@ -64,3 +65,28 @@ class ov::pass::DeReshapeMatMul : public ov::pass::MatcherPass { OPENVINO_RTTI("DeReshapeMatMul", "0"); DeReshapeMatMul(); }; + +/** + * @ingroup ie_transformation_common_api + * @brief Transformation uses symbol / label information to optimize out Reshape operations surrounding special cases of + * MatMul. It checks that surrounding Reshapes are only manipulating with batch dimensions of tensor in a do-undo kind + * of way. The difference with previous optimization is that this case has Reshape only on one input of MatMul and the + * other input is strictly 2D. Such MatMuls are also called FullyConnected + * + * Example: + * Before: + * [A,B,4096] -> Reshape -> [A*B,4096] + * MatMul [A*B,4608] -> Reshape -> [A,B,4608] + * [4096,4608] + * + * After: + * [A,B,4096] -> + * MatMul -> [A,B,4608] + * [4096,4608] -> + * + */ +class ov::pass::DeReshapeFullyConnected : public ov::pass::MatcherPass { +public: + OPENVINO_RTTI("DeReshapeFullyConnected", "0"); + DeReshapeFullyConnected(); +}; diff --git a/src/common/transformations/include/transformations/symbolic_transformations/label_optimization.hpp b/src/common/transformations/include/transformations/symbolic_transformations/label_optimization.hpp index 9260be86d2744a..7d76a106caeb31 100644 --- a/src/common/transformations/include/transformations/symbolic_transformations/label_optimization.hpp +++ b/src/common/transformations/include/transformations/symbolic_transformations/label_optimization.hpp @@ -3,9 +3,9 @@ // #pragma once -#include -#include -#include +#include "openvino/pass/graph_rewrite.hpp" +#include "openvino/pass/pass.hpp" +#include "transformations_visibility.hpp" namespace ov { namespace pass { diff --git a/src/common/transformations/include/transformations/symbolic_transformations/nop_broadcast.hpp b/src/common/transformations/include/transformations/symbolic_transformations/nop_broadcast.hpp index c6356277a42e81..1779ddbaea0dc6 100644 --- a/src/common/transformations/include/transformations/symbolic_transformations/nop_broadcast.hpp +++ b/src/common/transformations/include/transformations/symbolic_transformations/nop_broadcast.hpp @@ -4,8 +4,8 @@ #pragma once -#include -#include +#include "openvino/pass/graph_rewrite.hpp" +#include "transformations_visibility.hpp" namespace ov { namespace pass { diff --git a/src/common/transformations/include/transformations/symbolic_transformations/reshape_optimizations.hpp b/src/common/transformations/include/transformations/symbolic_transformations/reshape_optimizations.hpp index 9683f4e231bc59..eb8b88c7ac3560 100644 --- a/src/common/transformations/include/transformations/symbolic_transformations/reshape_optimizations.hpp +++ b/src/common/transformations/include/transformations/symbolic_transformations/reshape_optimizations.hpp @@ -4,8 +4,8 @@ #pragma once -#include -#include +#include "openvino/pass/graph_rewrite.hpp" +#include "transformations_visibility.hpp" namespace ov { namespace pass { diff --git a/src/common/transformations/src/ov_ops/rotary_positional_embeddings.cpp b/src/common/transformations/src/ov_ops/rotary_positional_embeddings.cpp new file mode 100644 index 00000000000000..02f16f01ce5298 --- /dev/null +++ b/src/common/transformations/src/ov_ops/rotary_positional_embeddings.cpp @@ -0,0 +1,46 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "ov_ops/rotary_positional_embeddings.hpp" + +#include "itt.hpp" + +namespace ov { +namespace op { +namespace internal { + +RPE::RPE(const Output& data, const Output& sin, const Output& cos, int64_t axis) + : Op({data, sin, cos}), + m_axis{axis} { + constructor_validate_and_infer_types(); +} + +void RPE::set_axis(int64_t axis) { + m_axis = axis; +} + +int64_t RPE::get_axis() const { + return m_axis; +} + +void RPE::validate_and_infer_types() { + INTERNAL_OP_SCOPE(internal_RoPE_validate_and_infer_types); + set_output_type(0, get_input_element_type(0), get_input_partial_shape(0)); +} + +bool RPE::visit_attributes(ov::AttributeVisitor& visitor) { + INTERNAL_OP_SCOPE(internal_RoPE_visit_attributes); + visitor.on_attribute("axis", m_axis); + return true; +} + +std::shared_ptr RPE::clone_with_new_inputs(const ov::OutputVector& new_args) const { + INTERNAL_OP_SCOPE(internal_RoPE_clone_with_new_inputs); + check_new_args_count(this, new_args); + return std::make_shared(new_args.at(0), new_args.at(1), new_args.at(2), m_axis); +} + +} // namespace internal +} // namespace op +} // namespace ov \ No newline at end of file diff --git a/src/common/transformations/src/transformations/common_optimizations/clamp_fusion.cpp b/src/common/transformations/src/transformations/common_optimizations/clamp_fusion.cpp index 49f1a0e2cab241..2c12b61443a0d0 100644 --- a/src/common/transformations/src/transformations/common_optimizations/clamp_fusion.cpp +++ b/src/common/transformations/src/transformations/common_optimizations/clamp_fusion.cpp @@ -48,6 +48,8 @@ ov::pass::ClampFusion::ClampFusion() { double min_value = min_const->cast_vector()[0]; double max_value = max_const->cast_vector()[0]; + if (min_value > max_value) + return false; auto clamp = register_new_node(data, min_value, max_value); diff --git a/src/common/transformations/src/transformations/common_optimizations/concat_fusion.cpp b/src/common/transformations/src/transformations/common_optimizations/concat_fusion.cpp index 2975a6c9fe59e0..49994d809aa73b 100644 --- a/src/common/transformations/src/transformations/common_optimizations/concat_fusion.cpp +++ b/src/common/transformations/src/transformations/common_optimizations/concat_fusion.cpp @@ -23,7 +23,7 @@ ov::pass::ConcatFusion::ConcatFusion() { auto is_aplicable = false; for (auto input : concat->input_values()) { const auto inp_concat = std::dynamic_pointer_cast(input.get_node_shared_ptr()); - if (inp_concat && inp_concat->get_axis() == axis) { + if (inp_concat && inp_concat->get_axis() == axis && inp_concat->output(0).get_target_inputs().size() == 1) { is_aplicable = true; } } @@ -40,7 +40,7 @@ ov::pass::ConcatFusion::ConcatFusion() { OutputVector new_inputs; for (auto input : concat->input_values()) { const auto inp_concat = std::dynamic_pointer_cast(input.get_node_shared_ptr()); - if (inp_concat && inp_concat->get_axis() == axis) { + if (inp_concat && inp_concat->get_axis() == axis && inp_concat->output(0).get_target_inputs().size() == 1) { const auto inp_concat_inps = inp_concat->input_values(); new_inputs.insert(new_inputs.end(), inp_concat_inps.begin(), inp_concat_inps.end()); } else { diff --git a/src/common/transformations/src/transformations/common_optimizations/convert_quantize_dequantize.cpp b/src/common/transformations/src/transformations/common_optimizations/convert_quantize_dequantize.cpp index 233f84cd0c836f..ba238893189644 100644 --- a/src/common/transformations/src/transformations/common_optimizations/convert_quantize_dequantize.cpp +++ b/src/common/transformations/src/transformations/common_optimizations/convert_quantize_dequantize.cpp @@ -22,8 +22,9 @@ // Since Quantize is decomposed to FakeQuantize and Dequantize is decomposed to Subtract->Multiply, // the full pattern to match is presented on the left hand side of the graph below. // On the right hand side is the graph after transformation. -// Currently transformation supports only i8 and u8 quantized data type. -// That implies 'levels' attribute to be 256, as well as (output_low, output_high) be (-128, 127) or (0, 255) (depends +// Currently transformation supports only i8, u8, i16, u16 quantized data type. +// That implies 'levels' attribute to be 256 or 65536, as well as (output_low, output_high) +// be (-128, 127) or (0, 255) or (-32768, 32767) or (0, 65535) (depends on type and depends // on sign of the quantized data type). Another limitation is that 'zero_point' and 'scale' have to be broadcastable to // the output of FakeQuantize. // @@ -69,9 +70,9 @@ ov::pass::ConvertQuantizeDequantize::ConvertQuantizeDequantize() { auto output_high_pattern = ov::pass::pattern::wrap_type(); auto fq_pattern = ov::pass::pattern::wrap_type( {data_pattern, input_low_pattern, input_high_pattern, output_low_pattern, output_high_pattern}); - auto convert1_pattern = - ov::pass::pattern::wrap_type({fq_pattern}, - pattern::type_matches_any({element::i8, element::u8})); + auto convert1_pattern = ov::pass::pattern::wrap_type( + {fq_pattern}, + pattern::type_matches_any({element::i8, element::u8, element::i16, element::u16})); auto convert2_pattern = ov::pass::pattern::wrap_type({convert1_pattern}, pattern::type_matches(element::f32)); auto zero_point_pattern = pass::pattern::any_input(); @@ -113,12 +114,14 @@ ov::pass::ConvertQuantizeDequantize::ConvertQuantizeDequantize() { if (convert2.get_target_inputs().size() != 1) return false; - // we support only i8 or u8 so 'levels' attribute must be 256 + // we support: + // i8 or u8: 'levels' attribute must be 256 + // i16 or u16: 'levels' attribute must be 65536 size_t levels = fq->get_levels(); - if (levels != 256) + if (levels != 256 && levels != 65536) return false; - // check if (out_low_val, out_high_val) is (-128, 127) or (0, 255) + // check if (out_low_val, out_high_val) is (-128, 127) or (0, 255) or (-32768, 32767) or (0, 65535) float out_low_val; if (!op::util::get_single_value(output_low, out_low_val)) return false; @@ -135,6 +138,14 @@ ov::pass::ConvertQuantizeDequantize::ConvertQuantizeDequantize() { if (out_low_val != 0 || out_high_val != 255) return false; break; + case element::Type_t::i16: + if (out_low_val != -32768 || out_high_val != 32767) + return false; + break; + case element::Type_t::u16: + if (out_low_val != 0 || out_high_val != 65535) + return false; + break; default: return false; } 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 new file mode 100644 index 00000000000000..689664922486b7 --- /dev/null +++ b/src/common/transformations/src/transformations/common_optimizations/fuse_rotary_positional_embeddings.cpp @@ -0,0 +1,98 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#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" +#include "openvino/op/op.hpp" +#include "openvino/op/variadic_split.hpp" +#include "openvino/pass/pattern/op/wrap_type.hpp" +#include "ov_ops/rotary_positional_embeddings.hpp" +#include "transformations/utils/utils.hpp" +#include "validation_util.hpp" + +using ov::op::v0::Concat; +using ov::op::v1::Add; +using ov::op::v1::Multiply; +using ov::op::v1::VariadicSplit; + +ov::pass::RPE_Fusion::RPE_Fusion() { + MATCHER_SCOPE(RPE_Fusion); + + auto sin = pattern::any_input(); + auto cos = pattern::any_input(); + + // FIXME: should be a single node match + auto source_1 = pattern::any_input(); + auto source = pattern::any_input(); + // BEGIN: rotate_half + + // Variadic Split into two equal parts + auto axis = pattern::any_input(); + auto split_length = INT_CONSTANT_WITH_PREDICATE(value.size() == 2 && value[0] == value[1]); + auto vsplit = pattern::wrap_type({source, axis, split_length}); + vsplit->set_output_size(2); + + // Negate + auto minus_1 = FLOAT_CONSTANT_WITH_PREDICATE(value.size() == 1 && value[0] == -1); + auto neg = pattern::wrap_type({vsplit->output(1), minus_1}); + + // Concat two splitted parts in the opposite order, first of them is negated + auto concat = pattern::wrap_type({neg, vsplit->output(0)}); // make sure axis eq to vsplit eq -1 + + // END: rotate half + + auto mul_sin = pattern::wrap_type({concat, sin}); + auto mul_cos = pattern::wrap_type({source_1, cos}); + auto add = pattern::wrap_type({mul_cos, mul_sin}); + + ov::matcher_pass_callback matcher_pass_callback = [=](pattern::Matcher& m) { + auto value_map = m.get_pattern_value_map(); + + auto actual_source = value_map.at(vsplit).get_node_shared_ptr()->input_value(0); + auto potential_source = value_map.at(mul_cos).get_node_shared_ptr()->input_value(0); + auto cos_output = value_map.at(mul_cos).get_node_shared_ptr()->input_value(1); + + if (actual_source != potential_source && actual_source != cos_output) + return false; // flawed match + if (actual_source == potential_source && actual_source == cos_output) + return false; // flawed match + if (actual_source != potential_source && actual_source == cos_output) + cos_output = potential_source; + + auto input = value_map.at(source); + auto concat_node = ov::as_type_ptr(value_map.at(concat).get_node_shared_ptr()); + if (!concat_node) + return false; + auto split_axis_node = ov::util::get_constant_from_source(value_map.at(axis)); + if (!split_axis_node) + return false; + auto value = split_axis_node->cast_vector(); + if (value.size() != 1) + return false; + auto concat_axis = concat_node->get_concatenation_axis(); + auto split_axis = value[0]; + if (concat_axis != split_axis) { + if (input.get_partial_shape().rank().is_static()) { + auto rank = input.get_partial_shape().rank().get_length(); + concat_axis = ov::util::normalize(concat_axis, rank); + split_axis = ov::util::normalize(split_axis, rank); + } + if (concat_axis != split_axis) + return false; + } + auto rpe = + std::make_shared(input, value_map.at(sin), cos_output, concat_node->get_axis()); + + for (const auto& label : {vsplit, neg, concat, mul_sin, mul_cos, add}) + ov::copy_runtime_info(value_map.at(label).get_node_shared_ptr(), rpe); + return ov::replace_output_update_name(value_map.at(add), rpe->output(0)); + }; + auto m = std::make_shared(add, matcher_name); + register_matcher(m, matcher_pass_callback); +} diff --git a/src/common/transformations/src/transformations/common_optimizations/gru_cell_fusion.cpp b/src/common/transformations/src/transformations/common_optimizations/gru_cell_fusion.cpp index 5b3aaec614ff17..d126bb6c0c18d1 100644 --- a/src/common/transformations/src/transformations/common_optimizations/gru_cell_fusion.cpp +++ b/src/common/transformations/src/transformations/common_optimizations/gru_cell_fusion.cpp @@ -172,8 +172,8 @@ ov::pass::GRUCellFusion::GRUCellFusion() { auto squeeze_B = rg.make(Bzrh, axis_0); - string act_name_1 = pattern_map.at(activation_1)->get_type_name(); - string act_name_2 = pattern_map.at(activation_2)->get_type_name(); + std::string act_name_1 = pattern_map.at(activation_1)->get_type_name(); + std::string act_name_2 = pattern_map.at(activation_2)->get_type_name(); auto to_lower = [](unsigned char c) { return std::tolower(c); }; @@ -186,7 +186,7 @@ ov::pass::GRUCellFusion::GRUCellFusion() { Rzrh, squeeze_B, hidden_size, - vector{act_name_1, act_name_2}); + vector{act_name_1, act_name_2}); cell->set_friendly_name(m.get_match_root()->get_friendly_name()); copy_runtime_info(m.get_matched_nodes(), rg.get()); diff --git a/src/common/transformations/src/transformations/convert_precision.cpp b/src/common/transformations/src/transformations/convert_precision.cpp index 5e8436508009b1..e9bb4584da58d3 100644 --- a/src/common/transformations/src/transformations/convert_precision.cpp +++ b/src/common/transformations/src/transformations/convert_precision.cpp @@ -1267,6 +1267,12 @@ bool fuse_type_to_constant(const std::shared_ptr& node, new_const = change_constant_precision(constant); } else if (from == ov::element::boolean && to == ov::element::i32) { new_const = change_constant_precision(constant); + } else if (from == ov::element::i8 && to == ov::element::f32) { + new_const = change_constant_precision(constant); + } else if (from == ov::element::u8 && to == ov::element::f32) { + new_const = change_constant_precision(constant); + } else if (from == ov::element::i8 && to == ov::element::i64) { + new_const = change_constant_precision(constant); } else if (from == ov::element::i4 || from == ov::element::u4 || from == ov::element::u1) { new_const = convert_low_precisions_int(constant, to); } else { diff --git a/src/common/transformations/src/transformations/symbolic_transformations/chained_maximum.cpp b/src/common/transformations/src/transformations/symbolic_transformations/chained_maximum.cpp index 02510be34dcb4a..c6bb082990db83 100644 --- a/src/common/transformations/src/transformations/symbolic_transformations/chained_maximum.cpp +++ b/src/common/transformations/src/transformations/symbolic_transformations/chained_maximum.cpp @@ -4,11 +4,10 @@ #include "transformations/symbolic_transformations/chained_maximum.hpp" -#include -#include - #include "itt.hpp" #include "openvino/core/dimension_tracker.hpp" +#include "openvino/op/maximum.hpp" +#include "openvino/pass/pattern/op/wrap_type.hpp" #include "transformations/symbolic_transformations/utils.hpp" using namespace ov::symbol::util; diff --git a/src/common/transformations/src/transformations/symbolic_transformations/dereshape_matmul.cpp b/src/common/transformations/src/transformations/symbolic_transformations/dereshape_matmul.cpp index 2c7ee44c6328d9..943c912bf68cf9 100644 --- a/src/common/transformations/src/transformations/symbolic_transformations/dereshape_matmul.cpp +++ b/src/common/transformations/src/transformations/symbolic_transformations/dereshape_matmul.cpp @@ -8,6 +8,7 @@ #include "openvino/core/dimension_tracker.hpp" #include "openvino/core/validation_util.hpp" #include "openvino/op/concat.hpp" +#include "openvino/op/convert.hpp" #include "openvino/op/matmul.hpp" #include "openvino/op/reshape.hpp" #include "openvino/op/util/binary_elementwise_arithmetic.hpp" @@ -334,3 +335,68 @@ ov::pass::DeReshapeMatMul::DeReshapeMatMul() { auto m = std::make_shared(final_reshape, matcher_name); register_matcher(m, matcher_pass_callback); } + +ov::pass::DeReshapeFullyConnected::DeReshapeFullyConnected() { + MATCHER_SCOPE(DeReshapeFullyConnected); + + auto reshaped_input = pattern::wrap_type([](Output out) -> bool { + const auto& input_shape = out.get_node_shared_ptr()->get_input_partial_shape(0); + if (input_shape.rank().is_dynamic() || input_shape.size() < 3) + return false; + const auto& output_shape = out.get_partial_shape(); + if (output_shape.rank().is_dynamic() || output_shape.size() < 2) + return false; + return dims_are_equal(input_shape[input_shape.size() - 1], output_shape[output_shape.size() - 1]); + }); + auto converted = + pattern::wrap_type({reshaped_input}, pattern::consumers_count(1)); // optional convert + + auto dynamic_input = std::make_shared(OutputVector{reshaped_input, converted}); + auto static_input = pattern::any_input(pattern::rank_equals(2)); + auto mm_label = pattern::wrap_type({dynamic_input, static_input}, [](Output out) -> bool { + auto mm = ov::as_type_ptr(out.get_node_shared_ptr()); + return mm && !mm->get_transpose_a() && pattern::consumers_count(1)(out); + }); + + auto reshaped_output = + pattern::wrap_type({mm_label, pattern::any_input()}, [](Output out) -> bool { + const auto& input_shape = out.get_node_shared_ptr()->get_input_partial_shape(0); + if (input_shape.rank().is_dynamic() || input_shape.size() < 2) + return false; + const auto& output_shape = out.get_partial_shape(); + if (output_shape.rank().is_dynamic() || output_shape.size() < 3) + return false; + return dims_are_equal(input_shape[input_shape.size() - 1], output_shape[output_shape.size() - 1]); + }); + + ov::matcher_pass_callback matcher_pass_callback = [=](pattern::Matcher& m) { + const auto& pm = m.get_pattern_map(); + + const auto& in_reshape = pm.at(reshaped_input); + const auto& out_reshape = pm.at(reshaped_output); + const auto& matmul = pm.at(mm_label); + + const auto& in_shape = in_reshape->get_input_partial_shape(0); + const auto& out_shape = out_reshape->get_output_partial_shape(0); + + if (in_shape.size() != out_shape.size()) + return false; + + for (size_t i = 0; i < in_shape.size() - 1; ++i) + if (!dims_are_equal(in_shape[i], out_shape[i])) + return false; + if (pm.count(converted)) { + const auto& convert = pm.at(converted); + convert->input(0).replace_source_output(in_reshape->input_value(0)); + convert->validate_and_infer_types(); + } else { + matmul->input(0).replace_source_output(in_reshape->input_value(0)); + } + ov::replace_output_update_name(out_reshape->output(0), matmul->output(0)); + matmul->validate_and_infer_types(); + return true; + }; + + auto m = std::make_shared(reshaped_output, matcher_name); + register_matcher(m, matcher_pass_callback); +} diff --git a/src/common/transformations/src/transformations/symbolic_transformations/label_optimization.cpp b/src/common/transformations/src/transformations/symbolic_transformations/label_optimization.cpp index 049fd0e72c06c3..06a046c3bfa5f2 100644 --- a/src/common/transformations/src/transformations/symbolic_transformations/label_optimization.cpp +++ b/src/common/transformations/src/transformations/symbolic_transformations/label_optimization.cpp @@ -4,20 +4,19 @@ #include "transformations/symbolic_transformations/label_optimization.hpp" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - #include "itt.hpp" +#include "openvino/core/bound_evaluation_util.hpp" +#include "openvino/core/dimension_tracker.hpp" #include "openvino/core/rt_info.hpp" +#include "openvino/op/add.hpp" +#include "openvino/op/concat.hpp" +#include "openvino/op/convert.hpp" +#include "openvino/op/gather.hpp" +#include "openvino/op/reshape.hpp" +#include "openvino/op/shape_of.hpp" +#include "openvino/op/squeeze.hpp" #include "openvino/op/util/multi_subgraph_base.hpp" +#include "openvino/op/util/symbolic_info.hpp" namespace { void update_label(const ov::EqTable& table, ov::label_t& label) { diff --git a/src/common/transformations/src/transformations/symbolic_transformations/nop_broadcast.cpp b/src/common/transformations/src/transformations/symbolic_transformations/nop_broadcast.cpp index 889bdd4b209d20..6890446f455ee8 100644 --- a/src/common/transformations/src/transformations/symbolic_transformations/nop_broadcast.cpp +++ b/src/common/transformations/src/transformations/symbolic_transformations/nop_broadcast.cpp @@ -4,15 +4,14 @@ #include "transformations/symbolic_transformations/nop_broadcast.hpp" -#include -#include -#include -#include -#include - #include "compare.hpp" #include "itt.hpp" +#include "openvino/core/dimension_tracker.hpp" +#include "openvino/op/broadcast.hpp" +#include "openvino/op/maximum.hpp" +#include "openvino/op/shape_of.hpp" #include "openvino/pass/pattern/op/or.hpp" +#include "openvino/pass/pattern/op/wrap_type.hpp" #include "transformations/symbolic_transformations/utils.hpp" #include "transformations/utils/utils.hpp" diff --git a/src/common/transformations/src/transformations/symbolic_transformations/reshape_optimizations.cpp b/src/common/transformations/src/transformations/symbolic_transformations/reshape_optimizations.cpp index 051370354f6661..c533a752eed731 100644 --- a/src/common/transformations/src/transformations/symbolic_transformations/reshape_optimizations.cpp +++ b/src/common/transformations/src/transformations/symbolic_transformations/reshape_optimizations.cpp @@ -4,11 +4,10 @@ #include "transformations/symbolic_transformations/reshape_optimizations.hpp" -#include -#include - #include "compare.hpp" #include "itt.hpp" +#include "openvino/core/dimension_tracker.hpp" +#include "openvino/pass/pattern/op/wrap_type.hpp" #include "transformations/symbolic_transformations/utils.hpp" #include "transformations/utils/utils.hpp" @@ -30,21 +29,25 @@ ov::pass::ReshapeOptimizations::ReshapeOptimizations() { if (!reshape) return false; const auto& in_shape = reshape->get_input_partial_shape(0); + const auto& in_rank = in_shape.size(); const auto& out_shape = reshape->get_output_partial_shape(0); - - if (in_shape.size() > out_shape.size()) { - std::vector output_pattern(out_shape.size(), -1); - for (size_t i = 0; i < out_shape.size(); ++i) - if (dims_are_equal(in_shape[i], out_shape[i])) - output_pattern[i] = 0; - if (std::count(output_pattern.begin(), output_pattern.end(), -1) == 1) { - auto new_pattern = - ov::op::v0::Constant::create(element::i64, Shape{output_pattern.size()}, output_pattern); - ov::copy_runtime_info(reshape->get_input_node_shared_ptr(1), new_pattern); - reshape->set_special_zero(true); - reshape->input(1).replace_source_output(new_pattern->output(0)); - return true; - } + const auto& out_rank = out_shape.size(); + + std::vector output_pattern(out_rank, -1); + for (size_t i = 0; i < out_rank; ++i) { + if (out_shape[i].is_static()) + output_pattern[i] = out_shape[i].get_length(); + else if (i >= in_rank) + break; + else if (dims_are_equal(in_shape[i], out_shape[i])) + output_pattern[i] = 0; + } + if (std::count(output_pattern.begin(), output_pattern.end(), -1) <= 1) { + auto new_pattern = ov::op::v0::Constant::create(element::i64, Shape{output_pattern.size()}, output_pattern); + ov::copy_runtime_info(reshape->get_input_node_shared_ptr(1), new_pattern); + reshape->set_special_zero(true); + reshape->input(1).replace_source_output(new_pattern->output(0)); + return true; } return false; }; diff --git a/src/common/transformations/src/transformations/symbolic_transformations/symbolic_optimizations.cpp b/src/common/transformations/src/transformations/symbolic_transformations/symbolic_optimizations.cpp index dc9799642996ff..1437845fb9ad60 100644 --- a/src/common/transformations/src/transformations/symbolic_transformations/symbolic_optimizations.cpp +++ b/src/common/transformations/src/transformations/symbolic_transformations/symbolic_optimizations.cpp @@ -202,6 +202,7 @@ ov::pass::SymbolicOptimizations::SymbolicOptimizations(bool full_run) { REGISTER_SYMBOLIC(OptimizeLabelsUsedAsValues) // reduce shape sub-graphs REGISTER_SYMBOLIC(LabelResolvingThroughSelect) // figures out that broadcasting didn't happen through Select op REGISTER_SYMBOLIC(DeReshapeMatMul) + REGISTER_SYMBOLIC(DeReshapeFullyConnected) REGISTER_SYMBOLIC(ReshapeOptimizations) REGISTER_SYMBOLIC(SimplifyShapeOfSubGraph) } diff --git a/src/common/transformations/tests/common_optimizations/concat_fusion.cpp b/src/common/transformations/tests/common_optimizations/concat_fusion.cpp index 1b3031622ee1af..9e2defae9777bb 100644 --- a/src/common/transformations/tests/common_optimizations/concat_fusion.cpp +++ b/src/common/transformations/tests/common_optimizations/concat_fusion.cpp @@ -32,3 +32,24 @@ TEST_F(TransformationTestsF, ConcatFusedToConcat) { model_ref = std::make_shared(ResultVector{result}, ParameterVector{data, data2}); } } + +TEST_F(TransformationTestsF, ConcatWithSeveralConsumersNotFused) { + { + auto data = std::make_shared(element::f32, PartialShape{1, 3, 14, 14}); + auto concat1 = std::make_shared(OutputVector{data, data}, 1); + auto concat2 = std::make_shared(OutputVector{concat1, data}, 1); + auto mul = std::make_shared(concat1, concat1); + auto concat3 = std::make_shared(OutputVector{mul, concat2}, 1); + auto result = std::make_shared(concat3); + model = std::make_shared(ResultVector{result}, ParameterVector{data}); + manager.register_pass(); + } + { + auto data = std::make_shared(element::f32, PartialShape{1, 3, 14, 14}); + auto concat1 = std::make_shared(OutputVector{data, data}, 1); + auto mul = std::make_shared(concat1, concat1); + auto concat3 = std::make_shared(OutputVector{mul, concat1, data}, 1); + auto result = std::make_shared(concat3); + model_ref = std::make_shared(ResultVector{result}, ParameterVector{data}); + } +} diff --git a/src/common/transformations/tests/common_optimizations/fuse_rotary_positional_embeddings.cpp b/src/common/transformations/tests/common_optimizations/fuse_rotary_positional_embeddings.cpp new file mode 100644 index 00000000000000..48ee524c1fb182 --- /dev/null +++ b/src/common/transformations/tests/common_optimizations/fuse_rotary_positional_embeddings.cpp @@ -0,0 +1,97 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "transformations/common_optimizations/fuse_rotary_positional_embeddings.hpp" + +#include + +#include "common_test_utils/ov_test_utils.hpp" +#include "openvino/op/parameter.hpp" +#include "openvino/op/variadic_split.hpp" +#include "ov_ops/rotary_positional_embeddings.hpp" +#include "transformations/utils/utils.hpp" + +using namespace std; +using namespace ov; +using namespace ov::op; + +void name_node_and_output(const shared_ptr& op, const std::string& name) { + op->set_friendly_name(name); + op->output(0).set_names({name}); +} + +TEST_F(TransformationTestsF, FuseRPE) { + { + auto data = make_shared(element::f32, PartialShape::dynamic()); + name_node_and_output(data, "source"); + auto sin = make_shared(element::f32, PartialShape::dynamic()); + name_node_and_output(sin, "sin"); + auto cos = make_shared(element::f32, PartialShape::dynamic()); + name_node_and_output(cos, "cos"); + auto axis = v0::Constant::create(element::i64, {}, {-1}); + auto split_lengths = v0::Constant::create(element::i64, {2}, {10, 10}); + auto split = make_shared(data, axis, split_lengths); + + auto minus_one = v0::Constant::create(element::f32, {}, {-1}); + auto negate = make_shared(split->output(1), minus_one); + + auto concat = make_shared(OutputVector{negate, split->output(0)}, -1); + + auto mul_sin = make_shared(concat, sin); + auto mul_cos = make_shared(data, cos); + auto add = make_shared(mul_cos, mul_sin); + name_node_and_output(add, "rpe"); + + model = std::make_shared(NodeVector{add}, ParameterVector{data, sin, cos}); + + manager.register_pass(); + } + { + auto data = make_shared(element::f32, PartialShape::dynamic()); + name_node_and_output(data, "source"); + auto sin = make_shared(element::f32, PartialShape::dynamic()); + name_node_and_output(sin, "sin"); + auto cos = make_shared(element::f32, PartialShape::dynamic()); + name_node_and_output(cos, "cos"); + auto rpe = make_shared(data, sin, cos, -1); + name_node_and_output(rpe, "rpe"); + model_ref = std::make_shared(NodeVector{rpe}, ParameterVector{data, sin, cos}); + } + comparator.enable(FunctionsComparator::CmpValues::NAMES); +} + +TEST_F(TransformationTestsF, FuseRPESorcesAreMultiOutputed) { + /* Transformation matcher searches for a single source as a beginning of the pattern: + VariadicSplit ... + source ____/ + \ + Multiply ... + This test is designed to check that in case we feed VariadicSplit and Multiply from different outputs of the same + node, the transformation won't happen since the source isn't the same + */ + { + auto data_ = make_shared(element::f32, PartialShape::dynamic()); + auto sin = make_shared(element::f32, PartialShape::dynamic()); + auto cos = make_shared(element::f32, PartialShape::dynamic()); + + auto data = make_shared(data_, v0::Constant::create(element::i64, {}, {-1}), 2); + + auto axis = v0::Constant::create(element::i64, {}, {-1}); + auto split_lengths = v0::Constant::create(element::i64, {2}, {10, 10}); + auto split = make_shared(data->output(0), axis, split_lengths); + + auto minus_one = v0::Constant::create(element::f32, {}, {-1}); + auto negate = make_shared(split->output(1), minus_one); + + auto concat = make_shared(OutputVector{negate, split->output(0)}, -1); + + auto mul_sin = make_shared(concat, sin); + auto mul_cos = make_shared(data->output(1), cos); + auto add = make_shared(mul_cos, mul_sin); + + model = std::make_shared(NodeVector{add}, ParameterVector{data_, sin, cos}); + + manager.register_pass(); + } +} \ No newline at end of file diff --git a/src/common/transformations/tests/common_optimizations/gru_cell_fusion.cpp b/src/common/transformations/tests/common_optimizations/gru_cell_fusion.cpp index 7858ab7626930f..f9419ff46712dc 100644 --- a/src/common/transformations/tests/common_optimizations/gru_cell_fusion.cpp +++ b/src/common/transformations/tests/common_optimizations/gru_cell_fusion.cpp @@ -21,7 +21,7 @@ namespace { enum class WeightsFormat { zr, rz }; -Output create_activation_by_name(const string& activation_name, const Output& input) { +Output create_activation_by_name(const std::string& activation_name, const Output& input) { if (activation_name == "sigmoid") { return make_shared(input); } else if (activation_name == "tanh") { @@ -33,8 +33,8 @@ Output create_activation_by_name(const string& activation_name, const Outp } shared_ptr gen_model(WeightsFormat format, - const string& activation_1, - const string& activation_2, + const std::string& activation_1, + const std::string& activation_2, size_t batch, size_t hidden_size, size_t input_size, @@ -83,8 +83,8 @@ shared_ptr gen_model(WeightsFormat format, } shared_ptr gen_reference(WeightsFormat format, - const string& activation_1, - const string& activation_2, + const std::string& activation_1, + const std::string& activation_2, size_t batch, size_t hidden_size, size_t input_size, @@ -132,15 +132,15 @@ shared_ptr gen_reference(WeightsFormat format, auto squeeze_B = make_shared(Bzrh, axis_0); auto cell = - make_shared(X, H, Wzrh, Rzrh, squeeze_B, hidden_size, vector{activation_1, activation_2}); + make_shared(X, H, Wzrh, Rzrh, squeeze_B, hidden_size, vector{activation_1, activation_2}); return make_shared(OutputVector{cell}, params); } } // namespace struct GRUFusionParams { WeightsFormat format; - string activation_1; - string activation_2; + std::string activation_1; + std::string activation_2; size_t batch; size_t hidden_size; size_t input_size; diff --git a/src/common/transformations/tests/symbolic_transformations/chained_maximum.cpp b/src/common/transformations/tests/symbolic_transformations/chained_maximum.cpp index f0507897fc4a36..9b5506ac2c0fd0 100644 --- a/src/common/transformations/tests/symbolic_transformations/chained_maximum.cpp +++ b/src/common/transformations/tests/symbolic_transformations/chained_maximum.cpp @@ -6,14 +6,13 @@ #include -#include -#include -#include -#include -#include - #include "common_test_utils/ov_test_utils.hpp" #include "openvino/core/dimension_tracker.hpp" +#include "openvino/core/model.hpp" +#include "openvino/op/broadcast.hpp" +#include "openvino/op/maximum.hpp" +#include "openvino/op/parameter.hpp" +#include "openvino/op/shape_of.hpp" #include "transformations/symbolic_transformations/symbolic_optimizations.hpp" using namespace ov; diff --git a/src/common/transformations/tests/symbolic_transformations/dereshape_fullyconnected.cpp b/src/common/transformations/tests/symbolic_transformations/dereshape_fullyconnected.cpp new file mode 100644 index 00000000000000..8b2fc3075beb68 --- /dev/null +++ b/src/common/transformations/tests/symbolic_transformations/dereshape_fullyconnected.cpp @@ -0,0 +1,112 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include + +#include "common_test_utils/ov_test_utils.hpp" +#include "openvino/core/dimension_tracker.hpp" +#include "openvino/core/model.hpp" +#include "openvino/op/concat.hpp" +#include "openvino/op/convert.hpp" +#include "openvino/op/matmul.hpp" +#include "openvino/op/parameter.hpp" +#include "openvino/op/reshape.hpp" +#include "transformations/symbolic_transformations/dereshape_matmul.hpp" +#include "transformations/utils/utils.hpp" + +using namespace ov; +using namespace ov::op; +using namespace std; + +namespace { +void label_shape(ov::PartialShape& shape) { + auto table = std::make_shared(42); + auto tracker = ov::DimensionTracker(table); + tracker.set_up_for_tracking(shape); +} +} // namespace + +TEST_F(TransformationTestsF, DeReshapeFC) { + { + auto shape = PartialShape{-1, -1, 40}; + label_shape(shape); // we label shape with consecutive labels: 42, 43, 44 + + auto data = make_shared(element::f32, shape); + auto in_reshape = make_shared(data, v0::Constant::create(element::i64, {2}, {-1, 40}), true); + auto second_input = make_shared(element::f32, Shape{40, 80}); + + auto matmul = make_shared(in_reshape, second_input); + + auto batch_dims = ov::op::util::node_to_get_shape_value_of_indices_from_shape_source(data, {0, 1}); + auto pattern = + make_shared(OutputVector{batch_dims, v0::Constant::create(element::i64, {1}, {80})}, 0); + auto out_reshape = make_shared(matmul, pattern, false); + + model = make_shared(NodeVector{out_reshape}, ParameterVector{data, second_input}); + manager.register_pass(); + } + { + auto shape = PartialShape{-1, -1, 40}; + label_shape(shape); // we label shape with consecutive labels: 42, 43, 44 + + auto data = make_shared(element::f32, shape); + auto second_input = make_shared(element::f32, Shape{40, 80}); + auto matmul = make_shared(data, second_input); + + model_ref = make_shared(NodeVector{matmul}, ParameterVector{data, second_input}); + } +} + +TEST_F(TransformationTestsF, DeReshapeFCWithConvert) { + { + auto shape = PartialShape{-1, -1, 40}; + label_shape(shape); // we label shape with consecutive labels: 42, 43, 44 + + auto data = make_shared(element::f16, shape); + auto in_reshape = make_shared(data, v0::Constant::create(element::i64, {2}, {-1, 40}), true); + auto convert = make_shared(in_reshape, element::f32); + auto second_input = make_shared(element::f32, Shape{40, 80}); + + auto matmul = make_shared(convert, second_input); + + auto batch_dims = ov::op::util::node_to_get_shape_value_of_indices_from_shape_source(data, {0, 1}); + auto pattern = + make_shared(OutputVector{batch_dims, v0::Constant::create(element::i64, {1}, {80})}, 0); + auto out_reshape = make_shared(matmul, pattern, false); + + model = make_shared(NodeVector{out_reshape}, ParameterVector{data, second_input}); + manager.register_pass(); + } + { + auto shape = PartialShape{-1, -1, 40}; + label_shape(shape); // we label shape with consecutive labels: 42, 43, 44 + + auto data = make_shared(element::f16, shape); + auto convert = make_shared(data, element::f32); + auto second_input = make_shared(element::f32, Shape{40, 80}); + auto matmul = make_shared(convert, second_input); + + model_ref = make_shared(NodeVector{matmul}, ParameterVector{data, second_input}); + } +} + +TEST_F(TransformationTestsF, DeReshapeFCNegative) { + { + auto shape = PartialShape{-1, -1, 40}; + label_shape(shape); // we label shape with consecutive labels: 42, 43, 44 + + auto data = make_shared(element::f16, shape); + auto in_reshape = make_shared(data, v0::Constant::create(element::i64, {2}, {-1, 40}), true); + auto convert = make_shared(in_reshape, element::f32); + auto second_input = make_shared(element::f32, Shape{40, 80}); + + auto matmul = make_shared(convert, second_input); + + auto pattern = v0::Constant::create(element::i64, {3}, {4, -1, 80}); + auto out_reshape = make_shared(matmul, pattern, false); + + model = make_shared(NodeVector{out_reshape}, ParameterVector{data, second_input}); + manager.register_pass(); + } +} \ No newline at end of file diff --git a/src/common/transformations/tests/symbolic_transformations/label_optimization.cpp b/src/common/transformations/tests/symbolic_transformations/label_optimization.cpp index 408467db47779f..798fd3aa5a1f88 100644 --- a/src/common/transformations/tests/symbolic_transformations/label_optimization.cpp +++ b/src/common/transformations/tests/symbolic_transformations/label_optimization.cpp @@ -13,7 +13,6 @@ #include "openvino/op/gather.hpp" #include "openvino/op/reshape.hpp" #include "openvino/op/shape_of.hpp" -#include "openvino/op/util/symbolic_info.hpp" #include "openvino/pass/manager.hpp" #include "transformations/symbolic_transformations/symbolic_optimizations.hpp" #include "transformations/symbolic_transformations/utils.hpp" diff --git a/src/common/transformations/tests/symbolic_transformations/nop_broadcast.cpp b/src/common/transformations/tests/symbolic_transformations/nop_broadcast.cpp index 63f97dfc7cb04b..b3b6b27f011d3c 100644 --- a/src/common/transformations/tests/symbolic_transformations/nop_broadcast.cpp +++ b/src/common/transformations/tests/symbolic_transformations/nop_broadcast.cpp @@ -6,15 +6,14 @@ #include -#include -#include -#include -#include -#include -#include - #include "common_test_utils/ov_test_utils.hpp" #include "openvino/core/dimension_tracker.hpp" +#include "openvino/core/model.hpp" +#include "openvino/op/broadcast.hpp" +#include "openvino/op/maximum.hpp" +#include "openvino/op/parameter.hpp" +#include "openvino/op/relu.hpp" +#include "openvino/op/shape_of.hpp" using namespace ov; using namespace ov::op; diff --git a/src/common/transformations/tests/symbolic_transformations/reshape_optimizations.cpp b/src/common/transformations/tests/symbolic_transformations/reshape_optimizations.cpp index 4942263ecb272f..07af3a6a4eedd1 100644 --- a/src/common/transformations/tests/symbolic_transformations/reshape_optimizations.cpp +++ b/src/common/transformations/tests/symbolic_transformations/reshape_optimizations.cpp @@ -6,16 +6,16 @@ #include -#include -#include -#include -#include -#include -#include -#include - #include "common_test_utils/ov_test_utils.hpp" #include "openvino/core/dimension_tracker.hpp" +#include "openvino/core/model.hpp" +#include "openvino/op/concat.hpp" +#include "openvino/op/divide.hpp" +#include "openvino/op/gather.hpp" +#include "openvino/op/multiply.hpp" +#include "openvino/op/parameter.hpp" +#include "openvino/op/reshape.hpp" +#include "openvino/op/shape_of.hpp" using namespace ov; using namespace ov::op; @@ -30,6 +30,7 @@ void label_shape(ov::PartialShape& shape) { } // namespace TEST_F(TransformationTestsF, FlattenOptimization) { + // [A, B, C, D] -> [A, B, C*D] { auto shape = PartialShape::dynamic(4); label_shape(shape); // we label shape with consecutive labels: 42, 43, 44, 45 @@ -65,3 +66,100 @@ TEST_F(TransformationTestsF, FlattenOptimization) { model_ref = make_shared(NodeVector{reshape}, ParameterVector{data}); } } + +TEST_F(TransformationTestsF, LastDimSplitStaticLast) { + // [A, B, C, D] -> [A, B, C, D/8, 8] + { + auto shape = PartialShape::dynamic(4); + label_shape(shape); // we label shape with consecutive labels: 42, 43, 44, 45 + + auto data = make_shared(element::f32, shape); + + auto shape_of = make_shared(data); + auto indices = ov::op::v0::Constant::create(element::i64, {3}, {0, 1, 2}); + auto axis = ov::op::v0::Constant::create(element::i64, {}, {0}); + + auto as_is_dims = make_shared(shape_of, indices, axis); + auto splited_dim = ov::op::v0::Constant::create(element::i64, {2}, {-1, 8}); + + auto pattern = make_shared(OutputVector{as_is_dims, splited_dim}, 0); + + auto reshape = make_shared(data, pattern, false); + + model = make_shared(NodeVector{reshape}, ParameterVector{data}); + manager.register_pass(); + } + { + auto shape = PartialShape::dynamic(4); + label_shape(shape); // we label shape with consecutive labels: 42, 43, 44, 45 + + auto data = make_shared(element::f32, shape); + auto pattern = ov::op::v0::Constant::create(element::i64, {5}, {0, 0, 0, -1, 8}); + + auto reshape = make_shared(data, pattern, true); + + model_ref = make_shared(NodeVector{reshape}, ParameterVector{data}); + } +} + +TEST_F(TransformationTestsF, LastDimSplitDymanicLast) { + // [A, B, C, D] -> [A, B, C, 8, D/8] + { + auto shape = PartialShape::dynamic(4); + label_shape(shape); // we label shape with consecutive labels: 42, 43, 44, 45 + + auto data = make_shared(element::f32, shape); + + auto shape_of = make_shared(data); + auto indices = ov::op::v0::Constant::create(element::i64, {3}, {0, 1, 2}); + auto axis = ov::op::v0::Constant::create(element::i64, {}, {0}); + + auto as_is_dims = make_shared(shape_of, indices, axis); + auto splited_dim = ov::op::v0::Constant::create(element::i64, {2}, {8, -1}); + + auto pattern = make_shared(OutputVector{as_is_dims, splited_dim}, 0); + + auto reshape = make_shared(data, pattern, false); + + model = make_shared(NodeVector{reshape}, ParameterVector{data}); + manager.register_pass(); + } + { + auto shape = PartialShape::dynamic(4); + label_shape(shape); // we label shape with consecutive labels: 42, 43, 44, 45 + + auto data = make_shared(element::f32, shape); + auto pattern = ov::op::v0::Constant::create(element::i64, {5}, {0, 0, 0, 8, -1}); + + auto reshape = make_shared(data, pattern, true); + + model_ref = make_shared(NodeVector{reshape}, ParameterVector{data}); + } +} + +TEST_F(TransformationTestsF, NegativeTest) { + // [A, B, C, D] -> [A, B, C, D/2, D/3, 6] + { + auto shape = PartialShape::dynamic(4); + label_shape(shape); // we label shape with consecutive labels: 42, 43, 44, 45 + + auto data = make_shared(element::f32, shape); + + auto shape_of = make_shared(data); + auto indices = ov::op::v0::Constant::create(element::i64, {3}, {0, 1, 2}); + auto axis = ov::op::v0::Constant::create(element::i64, {}, {0}); + auto as_is_dims = make_shared(shape_of, indices, axis); + + auto D = make_shared(shape_of, ov::op::v0::Constant::create(element::i64, {1}, {3}), axis); + auto D_2 = make_shared(D, ov::op::v0::Constant::create(element::i64, {}, {2})); + auto D_3 = make_shared(D, ov::op::v0::Constant::create(element::i64, {}, {3})); + auto six = ov::op::v0::Constant::create(element::i64, {1}, {6}); + + auto pattern = make_shared(OutputVector{as_is_dims, D_2, D_3, six}, 0); + + auto reshape = make_shared(data, pattern, false); + + model = make_shared(NodeVector{reshape}, ParameterVector{data}); + manager.register_pass(); + } +} diff --git a/src/common/transformations/tests/utils/compress_quantize_weights.cpp b/src/common/transformations/tests/utils/compress_quantize_weights.cpp index 15d07188f805f2..f76b4c901321d6 100644 --- a/src/common/transformations/tests/utils/compress_quantize_weights.cpp +++ b/src/common/transformations/tests/utils/compress_quantize_weights.cpp @@ -82,7 +82,12 @@ class CompressQuantizeWeightsTests } }; +#ifdef OPENVINO_ARCH_ARM64 +// Ticket: CVS-122397 +TEST_P(CompressQuantizeWeightsTests, DISABLED_FusionTest) {} +#else TEST_P(CompressQuantizeWeightsTests, FusionTest) {} +#endif static std::vector params = { {Shape{2, 3, 1, 1}, @@ -141,7 +146,12 @@ INSTANTIATE_TEST_SUITE_P(TransformationTests, CompressQuantizeWeightsTests, ::testing::Combine(::testing::ValuesIn(params), ::testing::ValuesIn(data_precisions))); +#ifdef OPENVINO_ARCH_ARM64 +// Ticket: 122666 +TEST_F(TransformationTestsF, DISABLED_CompressQuantizeWeightsWithDequantizationSubgraph) { +#else TEST_F(TransformationTestsF, CompressQuantizeWeightsWithDequantizationSubgraph) { +#endif { auto data = opset8::Constant::create(element::f32, Shape{2, 4, 1, 1}, {-1, 0, 1, 2, 3, 4, 5, 11}); auto input_low = opset8::Constant::create(element::f32, Shape{}, {1}); @@ -173,7 +183,12 @@ TEST_F(TransformationTestsF, CompressQuantizeWeightsWithDequantizationSubgraph) comparator.enable(FunctionsComparator::CmpValues::ACCURACY); } +#ifdef OPENVINO_ARCH_ARM64 +// Ticket: 122666 +TEST_F(TransformationTestsF, DISABLED_CompressQuantizeWeightsWithDequantizationSubgraphFP16) { +#else TEST_F(TransformationTestsF, CompressQuantizeWeightsWithDequantizationSubgraphFP16) { +#endif { auto data = opset8::Constant::create(element::f16, Shape{2, 4, 1, 1}, {-1, 0, 1, 2, 3, 4, 5, 11}); auto convert_to_f32 = std::make_shared(data, element::f32); @@ -208,7 +223,12 @@ TEST_F(TransformationTestsF, CompressQuantizeWeightsWithDequantizationSubgraphFP comparator.enable(FunctionsComparator::CmpValues::ACCURACY); } +#ifdef OPENVINO_ARCH_ARM64 +// Ticket: 122666 +TEST_F(TransformationTestsF, DISABLED_CompressQuantizeWeightsWithZeroPointEliminated) { +#else TEST_F(TransformationTestsF, CompressQuantizeWeightsWithZeroPointEliminated) { +#endif { auto data = opset8::Constant::create(element::f32, Shape{3, 1, 1, 1}, {-0.144816, 0.0858578, 0.110928}); auto input_low = opset8::Constant::create(element::f32, Shape{3, 1, 1, 1}, {-0.402659, -0.383148, -0.34054}); @@ -232,7 +252,12 @@ TEST_F(TransformationTestsF, CompressQuantizeWeightsWithZeroPointEliminated) { comparator.enable(FunctionsComparator::CmpValues::ACCURACY); } +#ifdef OPENVINO_ARCH_ARM64 +// Ticket: 122666 +TEST_F(TransformationTestsF, DISABLED_CompressQuantizeWeightsWithZeroPointEliminatedZeroScale) { +#else TEST_F(TransformationTestsF, CompressQuantizeWeightsWithZeroPointEliminatedZeroScale) { +#endif { auto data = opset8::Constant::create(element::f32, Shape{3, 1, 1, 1}, {-0.144816, 0.0858578, 0.110928}); auto input_low = opset8::Constant::create(element::f32, Shape{3, 1, 1, 1}, {-0.402659, -0.383148, -0.34054}); @@ -256,7 +281,12 @@ TEST_F(TransformationTestsF, CompressQuantizeWeightsWithZeroPointEliminatedZeroS comparator.enable(FunctionsComparator::CmpValues::ACCURACY); } +#ifdef OPENVINO_ARCH_ARM64 +// Ticket: 122666 +TEST_F(TransformationTestsF, DISABLED_CompressQuantizeWeightsWithZeroPointEliminatedFP16) { +#else TEST_F(TransformationTestsF, CompressQuantizeWeightsWithZeroPointEliminatedFP16) { +#endif { auto data = opset8::Constant::create(element::f16, Shape{3, 1, 1, 1}, {0.2, 1.2, 1.2}); auto input_low = @@ -285,7 +315,12 @@ TEST_F(TransformationTestsF, CompressQuantizeWeightsWithZeroPointEliminatedFP16) comparator.enable(FunctionsComparator::CmpValues::ACCURACY); } +#ifdef OPENVINO_ARCH_ARM64 +// Ticket: 122666 +TEST_F(TransformationTestsF, DISABLED_NegativeCompressQuantizeWeights) { +#else TEST_F(TransformationTestsF, NegativeCompressQuantizeWeights) { +#endif { auto data = opset8::Constant::create(element::f32, Shape{2, 4, 1, 1}, {-1, 0, 1, 2, 3, 4, 5, 11}); auto input_low = opset8::Constant::create(element::f32, Shape{}, {1}); @@ -310,7 +345,12 @@ TEST_F(TransformationTestsF, NegativeCompressQuantizeWeights) { comparator.enable(FunctionsComparator::CmpValues::ACCURACY); } +#ifdef OPENVINO_ARCH_ARM64 +// Ticket: 122666 +TEST_F(TransformationTestsF, DISABLED_NegativeCompressQuantizeWeightsNonConstantInput) { +#else TEST_F(TransformationTestsF, NegativeCompressQuantizeWeightsNonConstantInput) { +#endif auto data = std::make_shared(element::f32, Shape{2, 4, 1, 1}); auto input_low = opset8::Constant::create(element::f32, Shape{}, {1}); auto input_high = opset8::Constant::create(element::f32, Shape{}, {9}); diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index d389c1862703bf..0d0d42795ccac2 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -154,6 +154,7 @@ target_include_directories(ngraph INTERFACE $ make_constant(const element::Type& type, const Shape& shap case element::Type_t::nf4: unsupported_data_type = "nf4"; break; + case element::Type_t::string: + unsupported_data_type = "string"; + break; case element::Type_t::undefined: unsupported_data_type = "undefined"; break; diff --git a/src/core/dev_api/openvino/core/shape_util.hpp b/src/core/dev_api/openvino/core/shape_util.hpp index 10acfcbc80f2fe..89688526d4f286 100644 --- a/src/core/dev_api/openvino/core/shape_util.hpp +++ b/src/core/dev_api/openvino/core/shape_util.hpp @@ -9,24 +9,6 @@ namespace ov { namespace util { -/** - * @brief Makes spacial version of 2D ov::Shape which is recognize as dynamic. - * - * This is special case used for tensor <-> host tensor conversion to indicate that tensor got dynamic shape. - * - * @return 2-D shape with {0, SIZE_MAX} - */ -OPENVINO_DEPRECATED("This function is deprecated and will be removed soon.") -OPENVINO_API Shape make_dynamic_shape(); - -/** - * @brief Check if Shape is marked as dynamic. - * - * @param s Shape for check. - * @return True if shape is dynamic otherwise false. - */ -OPENVINO_DEPRECATED("This function is deprecated and will be removed soon.") -OPENVINO_API bool is_dynamic_shape(const Shape& s); /** * @brief Creates reduced shape from input by removing dimensions. diff --git a/src/core/dev_api/openvino/core/so_extension.hpp b/src/core/dev_api/openvino/core/so_extension.hpp index 98fb1e9f67a65a..cbba0d29c68d37 100644 --- a/src/core/dev_api/openvino/core/so_extension.hpp +++ b/src/core/dev_api/openvino/core/so_extension.hpp @@ -28,8 +28,20 @@ class OPENVINO_API SOExtension : public Extension { std::shared_ptr m_so; }; +inline std::string resolve_extension_path(const std::string& path) { + std::string retvalue; + try { + const std::string absolute_path = ov::util::get_absolute_file_path(path); + retvalue = ov::util::file_exists(absolute_path) ? absolute_path : path; + } catch (const std::runtime_error&) { + retvalue = path; + } + return retvalue; +} + inline std::vector load_extensions(const std::string& path) { - auto so = ov::util::load_shared_object(path.c_str()); + const std::string resolved_path = resolve_extension_path(path); + auto so = ov::util::load_shared_object(resolved_path.c_str()); using CreateFunction = void(std::vector&); std::vector extensions; reinterpret_cast(ov::util::get_symbol(so, "create_extensions"))(extensions); diff --git a/src/core/dev_api/openvino/runtime/string_aligned_buffer.hpp b/src/core/dev_api/openvino/runtime/string_aligned_buffer.hpp new file mode 100644 index 00000000000000..689b0b680c7c2c --- /dev/null +++ b/src/core/dev_api/openvino/runtime/string_aligned_buffer.hpp @@ -0,0 +1,28 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include "openvino/runtime/aligned_buffer.hpp" + +namespace ov { + +/// \brief StringAlignedBuffer class to store pointer to pre-allocated buffer with std::string objects +/// it is responsible for deallocation of std::string objects that will be stored in the buffer +class StringAlignedBuffer : public ov::AlignedBuffer { +public: + StringAlignedBuffer() = default; + StringAlignedBuffer(size_t num_elements, size_t byte_size, size_t alignment, bool initialize); + + virtual ~StringAlignedBuffer(); + +private: + StringAlignedBuffer(const StringAlignedBuffer&) = delete; + StringAlignedBuffer& operator=(const StringAlignedBuffer&) = delete; + +protected: + size_t m_num_elements; +}; + +} // namespace ov diff --git a/src/core/dev_api/tensor_conversion_util.hpp b/src/core/dev_api/tensor_conversion_util.hpp deleted file mode 100644 index 47a906ff9f0235..00000000000000 --- a/src/core/dev_api/tensor_conversion_util.hpp +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "ngraph/runtime/host_tensor.hpp" -#include "openvino/runtime/tensor.hpp" - -namespace ov { -namespace util { - -/** - * @brief Wrap host tensor into ov::Tensor. - * - * @param t Input tensor for conversion. - * @return ov::Tensor which points to host tensor data. Can return not allocated or special dynamic depends on input - * tensor state. - */ -OPENVINO_DEPRECATED("This function is deprecated and will be removed soon.") -OPENVINO_API Tensor wrap_tensor(const ngraph::HostTensorPtr& t); - -/** - * @brief Wrap node output into ov::Tensor. - * - * @param output Node output to make tensor. - * @return ov::Tensor from output properties. - */ -OPENVINO_DEPRECATED("This function is deprecated and will be removed soon.") -OPENVINO_API Tensor wrap_tensor(const Output& output); - -/** - * @brief Make vector of wrapped tensors. - * - * @param tensors Input vector of host tensor to convert. - * @return ov::TensorVectors, can contains not allocated or dynamic tensor depends on input tensor properties. - */ -OPENVINO_DEPRECATED("This function is deprecated and will be removed soon.") -OPENVINO_API TensorVector wrap_tensors(const std::vector& tensors); - -/** - * @brief Update output host tensors if they got dynamic shape before evaluation (not allocated). - * - * Other tensor not requires update as they are created from outputs and points to same data blob. - * - * @param output_values Temporary ov::Tensor vector created from outputs for evaluation - * @param outputs Output host tensors vector to update. - */ -OPENVINO_DEPRECATED("This function is deprecated and will be removed soon.") -OPENVINO_API void update_output_host_tensors(const std::vector& output_values, - const ov::TensorVector& outputs); - -} // namespace util -} // namespace ov diff --git a/src/core/include/ngraph/type/element_type.hpp b/src/core/include/ngraph/type/element_type.hpp index e3db087ccf7f16..cd125409db5bc6 100644 --- a/src/core/include/ngraph/type/element_type.hpp +++ b/src/core/include/ngraph/type/element_type.hpp @@ -41,6 +41,7 @@ using ov::element::i4; using ov::element::i64; using ov::element::i8; using ov::element::nf4; +using ov::element::string; using ov::element::u1; using ov::element::u16; using ov::element::u32; diff --git a/src/core/include/openvino/core/type/element_type.hpp b/src/core/include/openvino/core/type/element_type.hpp index 78e200d5035f79..88e79a75d25174 100644 --- a/src/core/include/openvino/core/type/element_type.hpp +++ b/src/core/include/openvino/core/type/element_type.hpp @@ -51,7 +51,8 @@ enum class Type_t { u16, //!< u16 element type u32, //!< u32 element type u64, //!< u64 element type - nf4 //!< nf4 element type + nf4, //!< nf4 element type + string //!< string element type }; /// \brief Base class to define element type @@ -181,6 +182,9 @@ constexpr Type u64(Type_t::u64); /// \brief nf4 element type /// \ingroup ov_element_cpp_api constexpr Type nf4(Type_t::nf4); +/// \brief string element type +/// \ingroup ov_element_cpp_api +constexpr Type string(Type_t::string); template Type from() { @@ -214,6 +218,8 @@ template <> OPENVINO_API Type from(); template <> OPENVINO_API Type from(); +template <> +OPENVINO_API Type from(); OPENVINO_API Type fundamental_type_for(const Type& type); diff --git a/src/core/include/openvino/core/type/element_type_traits.hpp b/src/core/include/openvino/core/type/element_type_traits.hpp index e26cf8e88857e3..33f0bbd059a99d 100644 --- a/src/core/include/openvino/core/type/element_type_traits.hpp +++ b/src/core/include/openvino/core/type/element_type_traits.hpp @@ -97,4 +97,9 @@ template <> struct element_type_traits { using value_type = int8_t; }; + +template <> +struct element_type_traits { + using value_type = std::string; +}; } // namespace ov diff --git a/src/core/include/openvino/op/constant.hpp b/src/core/include/openvino/op/constant.hpp index ff5dacd75daf79..fe91da44baf6f4 100644 --- a/src/core/include/openvino/op/constant.hpp +++ b/src/core/include/openvino/op/constant.hpp @@ -70,19 +70,22 @@ class OPENVINO_API Constant : public Op { template Constant(const element::Type& type, const Shape& shape, const std::vector& values) : Constant(false, type, shape) { + const auto this_shape_size = shape_size(m_shape); + const auto values_size = values.size(); + const auto has_single_value = (values_size == 1); NODE_VALIDATION_CHECK(this, - values.size() == 1 || values.size() == shape_size(m_shape), + has_single_value || values_size == this_shape_size, "Did not get the expected number of literals for a constant of shape ", m_shape, " (got ", - values.size(), + values_size, ", expected ", - (shape_size(m_shape) == 1 ? "" : "1 or "), - shape_size(m_shape), + (this_shape_size == 1 ? "" : "1 or "), + this_shape_size, ")."); - if (values.size() == 1) { - fill_data(type, values.front()); + if (has_single_value) { + fill_data(type, values[0]); } else { write_values(values); } @@ -161,6 +164,9 @@ class OPENVINO_API Constant : public Op { case Type_t::nf4: fill_data(value); break; + case Type_t::string: + fill_data(value); + break; case Type_t::undefined: case Type_t::dynamic: OPENVINO_THROW("unsupported type"); @@ -364,6 +370,9 @@ class OPENVINO_API Constant : public Op { case Type_t::u64: cast_vector(rc, num_elements_to_cast); break; + case Type_t::string: + cast_vector(rc, num_elements_to_cast); + break; default: OPENVINO_THROW("unsupported type"); } @@ -454,7 +463,7 @@ class OPENVINO_API Constant : public Op { template ::type = true> void cast_vector(std::vector& output_vector, size_t num_elements) const { // this function is workaround for waring during windows building @@ -511,6 +520,29 @@ class OPENVINO_API Constant : public Op { }); } + template ::type = true> + void cast_vector(std::vector& output_vector, size_t num_elements) const { + auto output_size = std::min(num_elements, shape_size(m_shape)); + output_vector.reserve(output_size); + const auto p = get_data_ptr(); + std::copy_n(p, output_size, std::back_inserter(output_vector)); + } + + template ::type = true> + void cast_vector(std::vector& output_vector, size_t num_elements) const { + OPENVINO_THROW("cast_vector does not support casting ov::Tensor of type " + + ov::element::Type(Type).to_string() + "to std::vector of std::string elements"); + } + + template ::type = true> + void cast_vector(std::vector& output_vector, size_t num_elements) const { + auto output_type = std::string(typeid(OUT_T{}).name()); + OPENVINO_THROW("cast_vector does not support casting string ov::Tensor to std::vector with elements of type " + + output_type); + } + template ::type = true> @@ -569,11 +601,19 @@ class OPENVINO_API Constant : public Op { output.resize(element_number); } + template , + typename std::enable_if::type = true> + void fill_data(const std::string& value) { + OPENVINO_THROW("Called fill_data(std::string) with non-string element_type"); + } + template , typename std::enable_if::type = true> void fill_data(const T& value) { #ifdef __clang__ @@ -614,6 +654,21 @@ class OPENVINO_API Constant : public Op { std::fill_n(get_data_ptr_nc(), size, v); } + template ::type = true> + void fill_data(const std::string& value) { + auto num_elements = shape_size(m_shape); + std::uninitialized_fill_n(get_data_ptr_nc(), num_elements, value); + } + + template , + typename std::enable_if::type = true> + void fill_data(const T& value) { + std::string type_name(typeid(value).name()); + OPENVINO_THROW("fill_data does not support to fill ov::Tensor of string type with value of " + type_name); + } + template , @@ -658,7 +713,8 @@ class OPENVINO_API Constant : public Op { typename T, typename StorageDataType = fundamental_type_for, typename std::enable_if::type = true> void write_buffer(const std::vector& source) { auto p = get_data_ptr_nc(); @@ -667,6 +723,31 @@ class OPENVINO_API Constant : public Op { } } + template ::type = true> + void write_buffer(const std::vector& source) { + // elements of string ov::Tensor is already pre-initialized in allocate_buffer + auto p = get_data_ptr_nc(); + auto num_elements = std::min(shape_size(m_shape), source.size()); + std::uninitialized_copy_n(source.begin(), num_elements, p); + } + + template ::type = true> + void write_buffer(const std::vector& source) { + OPENVINO_THROW("write_buffer does not support writing std::string elements into ov::Tensor of type:" + + ov::element::Type(Type).to_string()); + } + + template ::type = true> + void write_buffer(const std::vector& source) { + if (source.size() > 0) { + auto source_type = std::string(typeid(source[0]).name()); + OPENVINO_THROW("write_buffer does not support writing elements of type " + source_type + + " into string ov::Tensor"); + } + } + template , @@ -801,6 +882,9 @@ class OPENVINO_API Constant : public Op { case Type_t::nf4: write_buffer(source); break; + case Type_t::string: + write_buffer(source); + break; case element::Type_t::undefined: case element::Type_t::dynamic: OPENVINO_THROW("unsupported type"); @@ -809,6 +893,16 @@ class OPENVINO_API Constant : public Op { # pragma GCC diagnostic pop #endif } + + template + void fill_or_write(const bool fill, const element::Type& et, const std::vector& values) { + if (fill) { + fill_data(et, values[0]); + } else { + write_values(values); + } + } + template & arg, + + /// \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, std::string destination_type = "f8e4m3"); - FakeConvert(const ov::Output& arg, + /// \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, std::string destination_type = "f8e4m3"); diff --git a/src/core/include/openvino/op/multinomial.hpp b/src/core/include/openvino/op/multinomial.hpp index 7cf6318e5035e8..85016dd555050d 100644 --- a/src/core/include/openvino/op/multinomial.hpp +++ b/src/core/include/openvino/op/multinomial.hpp @@ -33,7 +33,7 @@ class OPENVINO_API Multinomial : public Op { */ Multinomial(const Output& input, const Output& num_samples, - const ov::element::Type_t output_type, + const ov::element::Type_t convert_type, const bool with_replacement, const bool log_probs, const uint64_t global_seed = 0, @@ -49,7 +49,7 @@ class OPENVINO_API Multinomial : public Op { uint64_t get_global_seed() const; uint64_t get_op_seed() const; - void set_convert_type(const ov::element::Type_t output_type); + void set_convert_type(const ov::element::Type_t convert_type); void set_with_replacement(const bool with_replacement); void set_log_probs(const bool log_probs); void set_global_seed(const uint64_t global_seed); diff --git a/src/core/include/openvino/op/util/gather_base.hpp b/src/core/include/openvino/op/util/gather_base.hpp index 2ead83fdac83d2..5a963b3a748a9f 100644 --- a/src/core/include/openvino/op/util/gather_base.hpp +++ b/src/core/include/openvino/op/util/gather_base.hpp @@ -27,10 +27,7 @@ class OPENVINO_API GatherBase : public Op { void validate_and_infer_types() override; virtual int64_t get_axis() const; - OPENVINO_SUPPRESS_DEPRECATED_START - bool evaluate(const HostTensorVector& outputs, const HostTensorVector& inputs) const override; - - OPENVINO_SUPPRESS_DEPRECATED_END + bool evaluate(TensorVector& outputs, const TensorVector& inputs) const override; bool evaluate_lower(TensorVector& outputs) const override; bool evaluate_upper(TensorVector& outputs) const override; bool evaluate_label(TensorLabelVector& output_labels) const override; diff --git a/src/core/include/openvino/runtime/tensor.hpp b/src/core/include/openvino/runtime/tensor.hpp index f09a5d30945222..43f63402e49da2 100644 --- a/src/core/include/openvino/runtime/tensor.hpp +++ b/src/core/include/openvino/runtime/tensor.hpp @@ -113,7 +113,7 @@ class OPENVINO_API Tensor { * @note Does not perform memory allocation internally * @param type Tensor element type * @param shape Tensor shape - * @param host_ptr Pointer to pre-allocated host memory + * @param host_ptr Pointer to pre-allocated host memory with initialized objects * @param strides Optional strides parameters in bytes. Strides are supposed to be computed automatically based * on shape and element size */ @@ -130,7 +130,7 @@ class OPENVINO_API Tensor { * @brief Constructs Tensor using port from node. Wraps allocated host memory. * @note Does not perform memory allocation internally * @param port port from node - * @param host_ptr Pointer to pre-allocated host memory + * @param host_ptr Pointer to pre-allocated host memory with initialized objects * @param strides Optional strides parameters in bytes. Strides are supposed to be computed automatically based * on shape and element size */ diff --git a/src/core/reference/include/openvino/reference/fake_convert.hpp b/src/core/reference/include/openvino/reference/fake_convert.hpp index a6e1283a568275..47410c79902426 100644 --- a/src/core/reference/include/openvino/reference/fake_convert.hpp +++ b/src/core/reference/include/openvino/reference/fake_convert.hpp @@ -4,17 +4,11 @@ #pragma once -#include #include -#include #include -#include "openvino/reference/add.hpp" #include "openvino/reference/autobroadcast_binop.hpp" #include "openvino/reference/convert.hpp" -#include "openvino/reference/divide.hpp" -#include "openvino/reference/multiply.hpp" -#include "openvino/reference/subtract.hpp" namespace ov { namespace reference { diff --git a/src/core/reference/include/openvino/reference/gather.hpp b/src/core/reference/include/openvino/reference/gather.hpp index 4324e0ffc5de4a..a580c20bc35b8c 100644 --- a/src/core/reference/include/openvino/reference/gather.hpp +++ b/src/core/reference/include/openvino/reference/gather.hpp @@ -28,7 +28,6 @@ void gather(const T* const data, int64_t batch_data_mul = shape_size(span(data_shape).subspan(batch_dims)); int64_t batch_out_mul = shape_size(span(out_shape).subspan(batch_dims)); - int64_t batch_indices_mul = shape_size(span(indices_shape).subspan(batch_dims)); int64_t axis_size = data_shape[axis]; int64_t data_offset, out_offset, idx; @@ -40,7 +39,7 @@ void gather(const T* const data, data_offset = batch_data_mul * batch + inner_size * axis_size * outer_idx; out_offset = batch_out_mul * batch + indices_size * inner_size * outer_idx; for (int64_t i = 0; i < indices_size; i++) { - idx = indices[i + batch_indices_mul * batch]; + idx = indices[i + indices_size * batch]; if (idx < 0) idx += axis_size; // for out of bound values have to be filled with zeros @@ -48,9 +47,8 @@ void gather(const T* const data, continue; const auto src_begin = std::next(data, data_offset + inner_size * idx); - const auto src_end = std::next(src_begin, inner_size); const auto out_ptr = std::next(out, out_offset + inner_size * i); - std::copy(src_begin, src_end, out_ptr); + std::copy_n(src_begin, inner_size, out_ptr); } } } diff --git a/src/core/reference/include/openvino/reference/multinomial.hpp b/src/core/reference/include/openvino/reference/multinomial.hpp index c98b4f6d67f62b..e18dee650eceed 100644 --- a/src/core/reference/include/openvino/reference/multinomial.hpp +++ b/src/core/reference/include/openvino/reference/multinomial.hpp @@ -135,7 +135,7 @@ void multinomial(const T* probs, if (!with_replacement) { T class_probability = selected_class_idx ? cdf[i_translated + selected_class_idx] - cdf[i_translated + selected_class_idx - 1] - : cdf[i_translated + selected_class_idx]; + : cdf[i_translated]; T divisor = 1 - class_probability; for (size_t k = 0; k < class_size; ++k) { if (k >= selected_class_idx) { diff --git a/src/core/reference/src/op/function.cpp b/src/core/reference/src/op/function.cpp index c70bf4020b17d0..37378d831f3ca7 100644 --- a/src/core/reference/src/op/function.cpp +++ b/src/core/reference/src/op/function.cpp @@ -12,14 +12,9 @@ namespace ov { namespace reference { void function(const std::shared_ptr& function, const ov::TensorVector& inputs, ov::TensorVector& outputs) { - const auto& results = function->get_results(); - outputs.reserve(results.size()); - for (size_t i = 0; i < results.size(); ++i) { - OPENVINO_SUPPRESS_DEPRECATED_START - auto shape = results[i]->get_output_partial_shape(0).is_static() ? results[i]->get_output_shape(0) - : ov::util::make_dynamic_shape(); - OPENVINO_SUPPRESS_DEPRECATED_END - outputs.push_back(ov::Tensor(results[i]->get_element_type(), shape)); + outputs.reserve(function->get_output_size()); + for (const auto& result : function->get_results()) { + outputs.emplace_back(result->output(0)); } function->evaluate(outputs, inputs); } diff --git a/src/core/shape_inference/include/matmul_shape_inference.hpp b/src/core/shape_inference/include/matmul_shape_inference.hpp index 425dd5839aca32..54cc7b1e8f2866 100644 --- a/src/core/shape_inference/include/matmul_shape_inference.hpp +++ b/src/core/shape_inference/include/matmul_shape_inference.hpp @@ -111,11 +111,11 @@ std::vector shape_infer(const MatMul* op, const std::vector& input_s // Output shape of two 1D tensors multiplication will be a 0D tensor (scalar). if (arg0_shape.rank().get_length() == 1) { // arg0 input temporary axis inserted at ROW_INDEX_DIM is removed - output_shape.erase(output_shape.begin() + output_shape.size() - 2); + output_shape.erase(output_shape.begin() + (output_shape.size() - 2)); } if (arg1_shape.rank().get_length() == 1) { // arg1 input temporary axis inserted at COL_INDEX_DIM is removed - output_shape.erase(output_shape.begin() + output_shape.size() - 1); + output_shape.erase(std::prev(output_shape.end())); } output_shapes.emplace_back(std::move(output_shape)); return output_shapes; diff --git a/src/core/shape_inference/include/multinomial_shape_inference.hpp b/src/core/shape_inference/include/multinomial_shape_inference.hpp index 950014d9a759b0..9271de3c7fa074 100644 --- a/src/core/shape_inference/include/multinomial_shape_inference.hpp +++ b/src/core/shape_inference/include/multinomial_shape_inference.hpp @@ -20,8 +20,8 @@ std::vector shape_infer(const Multinomial* op, const auto& input_shape = input_shapes[0]; NODE_SHAPE_INFER_CHECK(op, input_shapes, - input_shape.rank().compatible(1) || input_shape.rank().compatible(2), - "The rank of the 'probs' tensor defining output shape must be either 1 or 2."); + input_shape.rank().compatible(2), + "Input probabilities must be a 2D tensor."); const auto& num_samples_shape = input_shapes[1]; NODE_SHAPE_INFER_CHECK(op, @@ -33,19 +33,16 @@ std::vector shape_infer(const Multinomial* op, auto& result_shape = output_shapes[0]; const auto input_rank_static = input_shape.rank().is_static(); if (input_rank_static) { + result_shape.push_back(input_shape[0]); const auto& num_samples = get_input_const_data_as_shape(op, 1, ta); if (num_samples) { NODE_VALIDATION_CHECK(op, (*num_samples)[0].get_min_length() >= 0, "Number of samples must be non-negative. Got number of samples: ", (*num_samples)[0].get_min_length()); - result_shape = *num_samples; + result_shape.push_back((*num_samples)[0]); } else { - result_shape = ov::PartialShape::dynamic(1); - } - - if (input_shape.rank().compatible(2)) { - result_shape.insert(result_shape.begin(), input_shape[0]); + result_shape.push_back(ov::Dimension::dynamic()); } } else { result_shape = ov::PartialShape::dynamic(); diff --git a/src/core/src/bound_evaluate.cpp b/src/core/src/bound_evaluate.cpp index 1b1093b871c657..60d61126acc8f5 100644 --- a/src/core/src/bound_evaluate.cpp +++ b/src/core/src/bound_evaluate.cpp @@ -10,7 +10,6 @@ #include "openvino/core/shape_util.hpp" #include "openvino/op/util/symbolic_info.hpp" #include "openvino/opsets/opset10.hpp" -#include "tensor_conversion_util.hpp" #include "transformations/rt_info/decompression.hpp" #include "transformations/rt_info/is_shape_subgraph.hpp" @@ -70,6 +69,10 @@ bool are_equal(const ov::Tensor& lhs, const ov::Tensor& rhs) { return are_eq; } +bool is_type_allocable(const element::Type& type) { + return type != element::undefined && type.is_static(); +} + ov::Tensor evaluate_bound(const Output& output, bool is_upper, bool invalidate_all_unused_values = true) { if (is_upper && output.get_tensor().get_upper_value()) { return output.get_tensor().get_upper_value(); @@ -84,9 +87,11 @@ ov::Tensor evaluate_bound(const Output& output, bool is_upper, bool invali for (const auto& node : order) { ov::TensorVector outputs; for (const auto& out : node->outputs()) { - OPENVINO_SUPPRESS_DEPRECATED_START - outputs.push_back(util::wrap_tensor(out)); - OPENVINO_SUPPRESS_DEPRECATED_END + if (is_type_allocable(out.get_element_type())) { + outputs.emplace_back(out); + } else { + outputs.emplace_back(); + } } if (is_upper ? node->evaluate_upper(outputs) : node->evaluate_lower(outputs)) { @@ -312,10 +317,13 @@ std::pair ov::evaluate_both_bounds(const Output& o for (const auto& node : order) { ov::TensorVector outputs_lower, outputs_upper; for (const auto& out : node->outputs()) { - OPENVINO_SUPPRESS_DEPRECATED_START - outputs_lower.push_back(util::wrap_tensor(out)); - outputs_upper.push_back(util::wrap_tensor(out)); - OPENVINO_SUPPRESS_DEPRECATED_END + if (is_type_allocable(out.get_element_type())) { + outputs_lower.emplace_back(out); + outputs_upper.emplace_back(out); + } else { + outputs_lower.emplace_back(); + outputs_upper.emplace_back(); + } } if (!node->evaluate_lower(outputs_lower) || !node->evaluate_upper(outputs_upper)) { break; @@ -391,7 +399,7 @@ bool ov::interval_bound_evaluator(const Node* node, node->evaluate(lower_output_values, *input_variants.begin()); auto zero = op::v0::Constant::create(element::i64, {1}, {0}); - const auto zero_t = ov::Tensor(element::i64, Shape{1}); + const auto zero_t = ov::Tensor(element::i64, Shape{}); *zero_t.data() = 0; std::vector unsqueezed_output_variants; @@ -602,9 +610,7 @@ bool ov::default_label_evaluator(const Node* node, for (size_t i = 0; i < outputs_count; ++i) { const auto& partial_shape = node->get_output_partial_shape(i); // Set shape for static or special dynamic if partial shape is dynamic. - OPENVINO_SUPPRESS_DEPRECATED_START - auto shape = partial_shape.is_static() ? partial_shape.to_shape() : util::make_dynamic_shape(); - OPENVINO_SUPPRESS_DEPRECATED_END + const auto& shape = partial_shape.is_static() ? partial_shape.to_shape() : Shape{0}; outputs.emplace_back(element::from(), shape); } diff --git a/src/core/src/model.cpp b/src/core/src/model.cpp index b06bd5ece52933..c9ba2eb0416071 100644 --- a/src/core/src/model.cpp +++ b/src/core/src/model.cpp @@ -21,7 +21,6 @@ #include "openvino/op/util/variable_extension.hpp" #include "openvino/pass/manager.hpp" #include "shared_node_info.hpp" -#include "tensor_conversion_util.hpp" #include "transformations/smart_reshape/smart_reshape.hpp" using namespace std; @@ -487,24 +486,60 @@ int64_t ov::Model::get_result_index(const Output& value) const { return -1; } +OPENVINO_SUPPRESS_DEPRECATED_START +namespace { +ov::Tensor wrap_tensor(const ngraph::HostTensorPtr& t) { + const auto& et = t->get_element_type(); + const auto& p_shape = t->get_partial_shape(); + + if (et.is_dynamic() || et == ov::element::undefined) { + return {}; + } else if (p_shape.is_static()) { + return {et, p_shape.to_shape(), t->get_data_ptr()}; + } else { + return {et, ov::Shape{0}}; + } +} + +ov::TensorVector wrap_tensors(const std::vector& tensors) { + ov::TensorVector out; + out.reserve(tensors.size()); + for (const auto& ht : tensors) { + out.push_back(wrap_tensor(ht)); + } + return out; +} + +void update_output_host_tensors(const std::vector& output_values, + const ov::TensorVector& outputs) { + OPENVINO_ASSERT(output_values.size() == outputs.size()); + for (size_t i = 0; i < output_values.size(); ++i) { + auto& ht = output_values[i]; + auto& t = outputs[i]; + if (ht->get_partial_shape().is_dynamic()) { + ht->set_element_type(t.get_element_type()); + ht->set_shape(t.get_shape()); + std::memcpy(ht->get_data_ptr(), t.data(), t.get_byte_size()); + } + } +} +} // namespace + bool ov::Model::evaluate(const HostTensorVector& output_tensors, const HostTensorVector& input_tensors) const { ov::EvaluationContext evaluation_context; - OPENVINO_SUPPRESS_DEPRECATED_START return evaluate(output_tensors, input_tensors, evaluation_context); - OPENVINO_SUPPRESS_DEPRECATED_END } bool ov::Model::evaluate(const HostTensorVector& output_tensors, const HostTensorVector& input_tensors, EvaluationContext& evaluation_context) const { - OPENVINO_SUPPRESS_DEPRECATED_START - auto outputs = ov::util::wrap_tensors(output_tensors); - auto inputs = ov::util::wrap_tensors(input_tensors); + auto outputs = wrap_tensors(output_tensors); + auto inputs = wrap_tensors(input_tensors); bool sts = evaluate(outputs, inputs, evaluation_context); - ov::util::update_output_host_tensors(output_tensors, outputs); - OPENVINO_SUPPRESS_DEPRECATED_END + update_output_host_tensors(output_tensors, outputs); return sts; } +OPENVINO_SUPPRESS_DEPRECATED_END bool ov::Model::evaluate(ov::TensorVector& output_tensors, const ov::TensorVector& input_tensors) const { ov::EvaluationContext evaluation_context; @@ -550,7 +585,7 @@ bool ov::Model::evaluate(ov::TensorVector& output_tensors, for (const auto& v : node->outputs()) { auto it = output_tensor_map.find(v); if (it == output_tensor_map.end()) { - output_tensors.push_back(util::wrap_tensor(v)); + output_tensors.emplace_back(v); } else { output_tensors.push_back(it->second); } diff --git a/src/core/src/node.cpp b/src/core/src/node.cpp index e9a072d3cce0de..bbda98877044e4 100644 --- a/src/core/src/node.cpp +++ b/src/core/src/node.cpp @@ -19,7 +19,6 @@ #include "openvino/pass/pattern/matcher.hpp" #include "shape_validation.hpp" #include "shared_node_info.hpp" -#include "tensor_conversion_util.hpp" using namespace std; @@ -720,18 +719,27 @@ class DynamicTensor : public ngraph::runtime::HostTensor { inline ngraph::HostTensorPtr make_tmp_host_tensor(const ov::Tensor& t) { if (!t) { return std::make_shared(ov::element::dynamic); - } else if (ov::util::is_dynamic_shape(t.get_shape())) { + } else { + return std::make_shared(t.get_element_type(), t.get_shape(), t.data()); + } +} + +inline ngraph::HostTensorPtr make_tmp_out_host_tensor(const ov::Tensor& t) { + if (!t) { + return std::make_shared(ov::element::dynamic); + } else if (t.get_shape() == ov::Shape{0}) { return std::make_shared(t.get_element_type()); } else { return std::make_shared(t.get_element_type(), t.get_shape(), t.data()); } } -inline ngraph::HostTensorVector create_tmp_tensors(const ov::TensorVector& tensors) { +inline ngraph::HostTensorVector create_tmp_tensors(const ov::TensorVector& tensors, const bool is_output) { + const auto make_tmp_ht = is_output ? make_tmp_out_host_tensor : make_tmp_host_tensor; ngraph::HostTensorVector result; result.reserve(tensors.size()); for (const auto& tensor : tensors) { - result.push_back(make_tmp_host_tensor(tensor)); + result.push_back(make_tmp_ht(tensor)); } return result; } @@ -759,8 +767,8 @@ inline void update_output_tensors(ov::TensorVector& output_values, const ngraph: } // namespace bool ov::Node::evaluate(ov::TensorVector& output_values, const ov::TensorVector& input_values) const { - HostTensorVector output = create_tmp_tensors(output_values); - HostTensorVector input = create_tmp_tensors(input_values); + HostTensorVector output = create_tmp_tensors(output_values, true); + HostTensorVector input = create_tmp_tensors(input_values, false); bool sts = evaluate(output, input); if (sts) update_output_tensors(output_values, output); @@ -771,8 +779,8 @@ bool ov::Node::evaluate(ov::TensorVector& output_values, const ov::TensorVector& input_values, const ov::EvaluationContext& evaluationContext) const { // Call evaluate for old implementation with EvaluationContext - HostTensorVector output = create_tmp_tensors(output_values); - HostTensorVector input = create_tmp_tensors(input_values); + HostTensorVector output = create_tmp_tensors(output_values, true); + HostTensorVector input = create_tmp_tensors(input_values, false); bool sts = evaluate(output, input, evaluationContext); if (sts) update_output_tensors(output_values, output); @@ -826,9 +834,13 @@ bool ov::Node::constant_fold(OutputVector& output_values, const OutputVector& in } TensorVector output_tensors; - OPENVINO_SUPPRESS_DEPRECATED_START for (const auto& output : outputs()) { - output_tensors.push_back(ov::util::wrap_tensor(output)); + const auto& et = output.get_element_type(); + if (et != element::undefined && et.is_static()) { + output_tensors.emplace_back(output); + } else { + output_tensors.emplace_back(); + } } if (evaluate(output_tensors, input_tensors)) { @@ -838,7 +850,6 @@ bool ov::Node::constant_fold(OutputVector& output_values, const OutputVector& in } return true; } - OPENVINO_SUPPRESS_DEPRECATED_END return false; } diff --git a/src/core/src/op/abs.cpp b/src/core/src/op/abs.cpp index 43e034e3dc0560..8b87bd765794b0 100644 --- a/src/core/src/op/abs.cpp +++ b/src/core/src/op/abs.cpp @@ -42,10 +42,13 @@ bool Abs::evaluate(TensorVector& outputs, const TensorVector& inputs) const { outputs[0].set_shape(inputs[0].get_shape()); using namespace ov::element; - return IfTypeOf::apply(inputs[0].get_element_type(), - inputs[0], - outputs[0], - shape_size(inputs[0].get_shape())); + return IF_TYPE_OF(v0_Abs_evaluate, + OV_PP_ET_LIST(bf16, f16, f32, i32, i64, u32, u64), + abs::Evaluate, + inputs[0].get_element_type(), + inputs[0], + outputs[0], + shape_size(inputs[0].get_shape())); } bool Abs::has_evaluate() const { diff --git a/src/core/src/op/acos.cpp b/src/core/src/op/acos.cpp index 8721960f53b1f7..1aab9570405544 100644 --- a/src/core/src/op/acos.cpp +++ b/src/core/src/op/acos.cpp @@ -41,10 +41,13 @@ bool ov::op::v0::Acos::evaluate(TensorVector& outputs, const TensorVector& input outputs[0].set_shape(inputs[0].get_shape()); using namespace ov::element; - return IfTypeOf::apply(inputs[0].get_element_type(), - inputs[0], - outputs[0], - shape_size(inputs[0].get_shape())); + return IF_TYPE_OF(v0_Acos_evaluate, + OV_PP_ET_LIST(f16, f32, i32, i64, u32, u64), + acos::Evaluate, + inputs[0].get_element_type(), + inputs[0], + outputs[0], + shape_size(inputs[0].get_shape())); } bool ov::op::v0::Acos::has_evaluate() const { diff --git a/src/core/src/op/acosh.cpp b/src/core/src/op/acosh.cpp index 115ce76ac63335..85fbfb31115c61 100644 --- a/src/core/src/op/acosh.cpp +++ b/src/core/src/op/acosh.cpp @@ -41,10 +41,13 @@ bool ov::op::v3::Acosh::evaluate(TensorVector& outputs, const TensorVector& inpu outputs[0].set_shape(inputs[0].get_shape()); using namespace ov::element; - return IfTypeOf::apply(inputs[0].get_element_type(), - inputs[0], - outputs[0], - shape_size(inputs[0].get_shape())); + return IF_TYPE_OF(v3_Acosh_evaluate, + OV_PP_ET_LIST(f16, f32, i32, i64, u32, u64), + acosh::Evaluate, + inputs[0].get_element_type(), + inputs[0], + outputs[0], + shape_size(inputs[0].get_shape())); } bool ov::op::v3::Acosh::has_evaluate() const { diff --git a/src/core/src/op/add.cpp b/src/core/src/op/add.cpp index 0d09563b9ae201..ee81de632cf647 100644 --- a/src/core/src/op/add.cpp +++ b/src/core/src/op/add.cpp @@ -48,14 +48,16 @@ bool Add::evaluate(ov::TensorVector& outputs, const ov::TensorVector& inputs) co outputs[0].set_shape(infer_broadcast_shape(this, inputs)); using namespace ov::element; - return IfTypeOf::apply( - inputs[0].get_element_type(), - inputs[0], - inputs[1], - outputs[0], - inputs[0].get_shape(), - inputs[1].get_shape(), - get_autob()); + return IF_TYPE_OF(v1_Add_evaluate, + OV_PP_ET_LIST(bf16, f16, f32, i8, i16, i32, i64, u8, u16, u32, u64), + add::Evaluate, + inputs[0].get_element_type(), + inputs[0], + inputs[1], + outputs[0], + inputs[0].get_shape(), + inputs[1].get_shape(), + get_autob()); } bool Add::has_evaluate() const { diff --git a/src/core/src/op/asin.cpp b/src/core/src/op/asin.cpp index 00832dce255510..19183014f30bed 100644 --- a/src/core/src/op/asin.cpp +++ b/src/core/src/op/asin.cpp @@ -41,10 +41,13 @@ bool Asin::evaluate(TensorVector& outputs, const TensorVector& inputs) const { outputs[0].set_shape(inputs[0].get_shape()); using namespace ov::element; - return IfTypeOf::apply(inputs[0].get_element_type(), - inputs[0], - outputs[0], - shape_size(inputs[0].get_shape())); + return IF_TYPE_OF(v0_Asin_evaluate, + OV_PP_ET_LIST(f16, f32, i32, i64, u32, u64), + asin::Evaluate, + inputs[0].get_element_type(), + inputs[0], + outputs[0], + shape_size(inputs[0].get_shape())); } bool Asin::has_evaluate() const { diff --git a/src/core/src/op/asinh.cpp b/src/core/src/op/asinh.cpp index 80e7396f27da61..aa2ecdd432f944 100644 --- a/src/core/src/op/asinh.cpp +++ b/src/core/src/op/asinh.cpp @@ -40,10 +40,13 @@ bool Asinh::evaluate(TensorVector& outputs, const TensorVector& inputs) const { outputs[0].set_shape(inputs[0].get_shape()); using namespace ov::element; - return IfTypeOf::apply(inputs[0].get_element_type(), - inputs[0], - outputs[0], - shape_size(inputs[0].get_shape())); + return IF_TYPE_OF(v3_Asinh_evaluate, + OV_PP_ET_LIST(f16, f32, i32, i64, u32, u64), + asinh::Evaluate, + inputs[0].get_element_type(), + inputs[0], + outputs[0], + shape_size(inputs[0].get_shape())); } bool Asinh::has_evaluate() const { diff --git a/src/core/src/op/atan.cpp b/src/core/src/op/atan.cpp index 6732d4b952a29e..2004a3a3679248 100644 --- a/src/core/src/op/atan.cpp +++ b/src/core/src/op/atan.cpp @@ -43,10 +43,13 @@ bool Atan::evaluate(TensorVector& outputs, const TensorVector& inputs) const { outputs[0].set_shape(inputs[0].get_shape()); using namespace ov::element; - return IfTypeOf::apply(inputs[0].get_element_type(), - inputs[0], - outputs[0], - shape_size(inputs[0].get_shape())); + return IF_TYPE_OF(v0_Atan_evaluate, + OV_PP_ET_LIST(f16, f32, i32, i64, u32, u64), + atan::Evaluate, + inputs[0].get_element_type(), + inputs[0], + outputs[0], + shape_size(inputs[0].get_shape())); } bool Atan::has_evaluate() const { diff --git a/src/core/src/op/atanh.cpp b/src/core/src/op/atanh.cpp index b17431862fa997..c619f01796af96 100644 --- a/src/core/src/op/atanh.cpp +++ b/src/core/src/op/atanh.cpp @@ -40,10 +40,13 @@ bool op::v3::Atanh::evaluate(TensorVector& outputs, const TensorVector& inputs) outputs[0].set_shape(inputs[0].get_shape()); using namespace ov::element; - return IfTypeOf::apply(inputs[0].get_element_type(), - inputs[0], - outputs[0], - shape_size(inputs[0].get_shape())); + return IF_TYPE_OF(v3_Atanh_evaluate, + OV_PP_ET_LIST(f16, f32, i32, i64, u32, u64), + atanh::Evaluate, + inputs[0].get_element_type(), + inputs[0], + outputs[0], + shape_size(inputs[0].get_shape())); } bool op::v3::Atanh::has_evaluate() const { diff --git a/src/core/src/op/ceiling.cpp b/src/core/src/op/ceiling.cpp index c46ed21ae03ebc..17139143523ed4 100644 --- a/src/core/src/op/ceiling.cpp +++ b/src/core/src/op/ceiling.cpp @@ -44,11 +44,13 @@ bool Ceiling::evaluate(TensorVector& outputs, const TensorVector& inputs) const outputs[0].set_shape(inputs[0].get_shape()); using namespace ov::element; - return IfTypeOf::apply( - inputs[0].get_element_type(), - inputs[0], - outputs[0], - shape_size(inputs[0].get_shape())); + return IF_TYPE_OF(v0_Ceiling_evaluate, + OV_PP_ET_LIST(f16, f32, i8, i16, i32, i64, u8, u16, u32, u64), + ceiling::Evaluate, + inputs[0].get_element_type(), + inputs[0], + outputs[0], + shape_size(inputs[0].get_shape())); } bool Ceiling::has_evaluate() const { diff --git a/src/core/src/op/clamp.cpp b/src/core/src/op/clamp.cpp index f3b0d19af17b82..76350a49b24c42 100644 --- a/src/core/src/op/clamp.cpp +++ b/src/core/src/op/clamp.cpp @@ -68,13 +68,15 @@ bool Clamp::evaluate(TensorVector& outputs, const TensorVector& inputs) const { outputs[0].set_shape(in_shape); using namespace ov::element; - return IfTypeOf::apply( - inputs[0].get_element_type(), - inputs[0], - outputs[0], - get_min(), - get_max(), - shape_size(in_shape)); + return IF_TYPE_OF(v0_Clamp_evaluate, + OV_PP_ET_LIST(bf16, f16, f32, i8, i16, i32, i64, u8, u16, u32, u64), + clamp::Evaluate, + inputs[0].get_element_type(), + inputs[0], + outputs[0], + get_min(), + get_max(), + shape_size(in_shape)); } bool Clamp::has_evaluate() const { diff --git a/src/core/src/op/constant.cpp b/src/core/src/op/constant.cpp index e694865cc4ab2e..914324a5dc97c6 100644 --- a/src/core/src/op/constant.cpp +++ b/src/core/src/op/constant.cpp @@ -18,6 +18,7 @@ #include "openvino/core/type/nf4.hpp" #include "openvino/reference/utils/type_util.hpp" #include "openvino/runtime/shared_buffer.hpp" +#include "openvino/runtime/string_aligned_buffer.hpp" namespace ov { namespace op { @@ -43,12 +44,23 @@ std::string to_cpp_string(T value) { } } -std::vector from_string_vector(const std::vector& str_values) { - std::vector values; +template ::value>::type* = nullptr> +T str_to_value(const std::string& s, size_t* pos) { + return static_cast(std::is_signed::value ? std::stoll(s, pos) : std::stoull(s, pos)); +} + +template ::value>::type* = nullptr> +T str_to_value(const std::string& s, size_t* pos) { + return static_cast(std::stod(s, pos)); +} + +template +std::vector from_string_vector(const std::vector& str_values) { + std::vector values; values.reserve(str_values.size()); std::transform(str_values.cbegin(), str_values.cend(), std::back_inserter(values), [](const std::string& s) { size_t pos; - auto v = std::stold(s, &pos); + auto v = str_to_value(s, &pos); OPENVINO_ASSERT(s.size() == pos, "Could not parse literal '", s, "'"); return v; }); @@ -76,6 +88,8 @@ Constant::Constant(const std::shared_ptr& tensor) { tensor->get_size_in_bytes(), tensor); } else { + OPENVINO_ASSERT(m_element_type != ov::element::string, + "Creation of string constant for ngraph::runtime::Tensor is supported only for HostTensor"); constructor_validate_and_infer_types(); allocate_buffer(false); tensor->read(get_data_ptr_nc(), tensor->get_size_in_bytes()); @@ -93,9 +107,31 @@ Constant::Constant(const Tensor& tensor) } Constant::Constant(const element::Type& type, const Shape& shape, const std::vector& values) - : Constant(type, shape, from_string_vector(values)) { - const auto is_checked_and_identical = (values.size() == 1) && (shape_size(m_shape) != 1); - update_identical_flags(is_checked_and_identical, is_checked_and_identical); + : Constant(false, type, shape) { + const auto this_shape_size = shape_size(m_shape); + const auto values_size = values.size(); + const auto has_single_value = (values_size == 1); + NODE_VALIDATION_CHECK(this, + has_single_value || values_size == this_shape_size, + "Did not get the expected number of literals for a constant of shape ", + m_shape, + " (got ", + values_size, + ", expected ", + (this_shape_size == 1 ? "" : "1 or "), + this_shape_size, + ")."); + const auto is_checked_and_identical = has_single_value && (this_shape_size != 1); + + if (type == element::string) { + fill_or_write(is_checked_and_identical, type, values); + } else if (type.is_real()) { + fill_or_write(is_checked_and_identical, type, from_string_vector(values)); + } else if (type.is_signed()) { + fill_or_write(is_checked_and_identical, type, from_string_vector(values)); + } else { + fill_or_write(is_checked_and_identical, type, from_string_vector(values)); + } } Constant::Constant(const element::Type& type, const Shape& shape) : Constant(true, type, shape) {} @@ -108,14 +144,28 @@ Constant::Constant(bool memset_allocation, const element::Type& type, const Shap } void Constant::allocate_buffer(bool memset_allocation) { - m_data = std::make_shared(mem_size(), host_alignment()); - if (memset_allocation) { - std::memset(m_data->get_ptr(), 0, m_data->size()); + // memset_allocation flag is to switch on initialization of objects in memory for element::string type + // and set memory to zero for numeric element types + if (m_element_type == ov::element::string) { + auto num_elements = shape_size(m_shape); + m_data = std::make_shared(num_elements, mem_size(), host_alignment(), memset_allocation); + } else { + m_data = std::make_shared(mem_size(), host_alignment()); + if (memset_allocation) { + std::memset(m_data->get_ptr(), 0, m_data->size()); + } } } Constant::Constant(const element::Type& type, const Shape& shape, const void* data) : Constant(false, type, shape) { - std::memcpy(get_data_ptr_nc(), data, mem_size()); + if (m_element_type == ov::element::string) { + auto num_elements = shape_size(m_shape); + const std::string* src_strings = static_cast(data); + std::string* dst_strings = static_cast(get_data_ptr_nc()); + std::uninitialized_copy_n(src_strings, num_elements, dst_strings); + } else { + std::memcpy(get_data_ptr_nc(), data, mem_size()); + } } Constant::Constant(const Constant& other) @@ -161,11 +211,17 @@ struct ValueToString : ov::element::NotSupported { static result_type visit(const Constant* const c, const size_t index) { return std::to_string(c->get_element_value(index)); } + + template , std::string>::value>::type* = nullptr> + static result_type visit(const Constant* const c, const size_t index) { + return c->get_element_value(index); + } }; std::string Constant::convert_value_to_string(size_t index) const { using namespace ov::element; - return IfTypeOf::apply< + return IfTypeOf::apply< ValueToString>(get_element_type(), this, index); } @@ -211,12 +267,18 @@ struct ValuesToString : ov::element::NotSupported { strs.push_back(std::to_string(v)); } } + + template , std::string>::value>::type* = nullptr> + static result_type visit(const Constant* const c, std::vector& strs) { + strs = c->cast_vector(); + } }; std::vector Constant::get_value_strings() const { std::vector out; using namespace ov::element; - IfTypeOf::apply< + IfTypeOf::apply< ValuesToString>(get_element_type(), this, out); return out; } @@ -293,6 +355,9 @@ bool Constant::are_all_data_elements_bitwise_identical() const { case element::Type_t::u64: all_identical = test_bitwise_identical(get_data_ptr(), shape_size(m_shape)); break; + case element::Type_t::string: + all_identical = test_bitwise_identical(get_data_ptr(), shape_size(m_shape)); + break; default: all_identical = false; break; @@ -328,7 +393,16 @@ bool Constant::evaluate(TensorVector& outputs, const TensorVector& inputs) const outputs.emplace_back(m_element_type, m_shape); else outputs[0].set_shape(m_shape); - std::memcpy(outputs[0].data(), get_data_ptr(), outputs[0].get_byte_size()); + + if (m_element_type == ov::element::string) { + auto num_elements = shape_size(m_shape); + auto src_strings = static_cast(get_data_ptr()); + auto dst_strings = static_cast(outputs[0].data()); + std::copy_n(src_strings, num_elements, dst_strings); + } else { + std::memcpy(outputs[0].data(), get_data_ptr(), outputs[0].get_byte_size()); + } + return true; } diff --git a/src/core/src/op/cos.cpp b/src/core/src/op/cos.cpp index 9fd6562838adf6..575d148f2d96cb 100644 --- a/src/core/src/op/cos.cpp +++ b/src/core/src/op/cos.cpp @@ -47,10 +47,13 @@ bool Cos::evaluate(TensorVector& outputs, const TensorVector& inputs) const { outputs[0].set_shape(inputs[0].get_shape()); using namespace ov::element; - return IfTypeOf::apply(inputs[0].get_element_type(), - inputs[0], - outputs[0], - shape_size(inputs[0].get_shape())); + return IF_TYPE_OF(v0_Cos_evaluate, + OV_PP_ET_LIST(f16, f32, i32, i64, u32, u64), + cos::Evaluate, + inputs[0].get_element_type(), + inputs[0], + outputs[0], + shape_size(inputs[0].get_shape())); } bool Cos::has_evaluate() const { diff --git a/src/core/src/op/cosh.cpp b/src/core/src/op/cosh.cpp index 1792fba5c3e694..ebc05f7612770f 100644 --- a/src/core/src/op/cosh.cpp +++ b/src/core/src/op/cosh.cpp @@ -47,10 +47,13 @@ bool Cosh::evaluate(TensorVector& outputs, const TensorVector& inputs) const { outputs[0].set_shape(inputs[0].get_shape()); using namespace ov::element; - return IfTypeOf::apply(inputs[0].get_element_type(), - inputs[0], - outputs[0], - shape_size(inputs[0].get_shape())); + return IF_TYPE_OF(v0_Cosh_evaluate, + OV_PP_ET_LIST(f16, f32, i32, i64, u32, u64), + cosh::Evaluate, + inputs[0].get_element_type(), + inputs[0], + outputs[0], + shape_size(inputs[0].get_shape())); } bool Cosh::has_evaluate() const { diff --git a/src/core/src/op/cum_sum.cpp b/src/core/src/op/cum_sum.cpp index 774e2be80c8fbc..a8737d59b7c82d 100644 --- a/src/core/src/op/cum_sum.cpp +++ b/src/core/src/op/cum_sum.cpp @@ -35,12 +35,15 @@ bool evaluate(TensorVector& outputs, const TensorVector& inputs, const bool excl const auto axis = ov::get_tensor_data_as(inputs[1]).front(); using namespace ov::element; - return IfTypeOf::apply(inputs[0].get_element_type(), - inputs[0], - outputs[0], - axis, - exclusive, - reverse); + return IF_TYPE_OF(CumSum_evaluate, + f32, + cumsum::Evaluate, + inputs[0].get_element_type(), + inputs[0], + outputs[0], + axis, + exclusive, + reverse); } } // namespace } // namespace cumsum diff --git a/src/core/src/op/divide.cpp b/src/core/src/op/divide.cpp index c2a9020cb03654..67a0b6c7265b4a 100644 --- a/src/core/src/op/divide.cpp +++ b/src/core/src/op/divide.cpp @@ -242,14 +242,17 @@ bool Divide::evaluate(TensorVector& outputs, const TensorVector& inputs) const { outputs[0].set_shape(infer_broadcast_shape(this, inputs)); using namespace ov::element; - return IfTypeOf::apply(inputs[0].get_element_type(), - inputs[0], - inputs[1], - outputs[0], - inputs[0].get_shape(), - inputs[1].get_shape(), - get_autob(), - is_pythondiv()); + return IF_TYPE_OF(v1_Divide_evaluate, + OV_PP_ET_LIST(f16, bf16, f32, i32, i64, u32, u64), + divide::Evaluate, + inputs[0].get_element_type(), + inputs[0], + inputs[1], + outputs[0], + inputs[0].get_shape(), + inputs[1].get_shape(), + get_autob(), + is_pythondiv()); return true; } diff --git a/src/core/src/op/equal.cpp b/src/core/src/op/equal.cpp index 7f23b8970e204a..12d94685dcf6b1 100644 --- a/src/core/src/op/equal.cpp +++ b/src/core/src/op/equal.cpp @@ -32,13 +32,6 @@ Tensor and_tensor(const Tensor& lhs, const Tensor& rhs) { return outs.front(); } -Tensor or_tensor(const Tensor& lhs, const Tensor& rhs) { - const auto logical_or = v1::LogicalOr(); - auto outs = TensorVector{{element::boolean, Shape{}}}; - logical_or.evaluate(outs, {lhs, rhs}); - return outs.front(); -} - void all_equal(const TensorVector& tensors, TensorVector& outputs) { auto& output = outputs[0]; auto eq_result = TensorVector{{output.get_element_type(), output.get_shape()}}; @@ -54,12 +47,6 @@ void all_equal(const TensorVector& tensors, TensorVector& outputs) { output = and_tensor(output, eq_result[0]); } } - -Tensor within_interval(const Tensor& lower, const Tensor& upper, const Tensor& subject_to_check) { - const auto lower_check = less_equal_tensor(lower, subject_to_check); - const auto upper_check = less_equal_tensor(subject_to_check, upper); - return and_tensor(lower_check, upper_check); -} } // namespace struct Evaluate : public element::NoAction { @@ -101,14 +88,16 @@ bool Equal::evaluate(TensorVector& outputs, const TensorVector& inputs) const { outputs[0].set_shape(ov::op::infer_broadcast_shape(this, inputs)); using namespace ov::element; - return IfTypeOf::apply( - inputs[0].get_element_type(), - inputs[0], - inputs[1], - outputs[0], - inputs[0].get_shape(), - inputs[1].get_shape(), - get_autob()); + return IF_TYPE_OF(v1_Equal_evaluate, + OV_PP_ET_LIST(boolean, bf16, f16, f32, f64, i8, i16, i32, i64, u8, u16, u32, u64), + equal::Evaluate, + inputs[0].get_element_type(), + inputs[0], + inputs[1], + outputs[0], + inputs[0].get_shape(), + inputs[1].get_shape(), + get_autob()); } bool Equal::evaluate_lower(TensorVector& output_values) const { @@ -127,11 +116,11 @@ bool Equal::evaluate_upper(TensorVector& output_values) const { const auto &lhs = get_input_tensor(0), &rhs = get_input_tensor(1); const auto &lhs_lower = lhs.get_lower_value(), &lhs_upper = lhs.get_upper_value(); const auto &rhs_lower = rhs.get_lower_value(), &rhs_upper = rhs.get_upper_value(); - // check for intersection: - // ll <= rl <= lu or ll <= ru <= lu - const auto rl_check = equal::within_interval(lhs_lower, lhs_upper, rhs_lower); - const auto ru_check = equal::within_interval(lhs_lower, lhs_upper, rhs_upper); - output_values[0] = equal::or_tensor(rl_check, ru_check); + + // if (lhs_lower <= rhs_upper && rhs_lower <= lhs_upper) bounds have got intersection + const auto lb_check = equal::less_equal_tensor(lhs_lower, rhs_upper); + const auto ub_check = equal::less_equal_tensor(rhs_lower, lhs_upper); + output_values[0] = equal::and_tensor(lb_check, ub_check); return true; } diff --git a/src/core/src/op/erf.cpp b/src/core/src/op/erf.cpp index 1315453b2d626a..4aa2dda2091ed0 100644 --- a/src/core/src/op/erf.cpp +++ b/src/core/src/op/erf.cpp @@ -43,10 +43,13 @@ bool Erf::evaluate(TensorVector& outputs, const TensorVector& inputs) const { outputs[0].set_shape(in_shape); using namespace ov::element; - return IfTypeOf::apply(inputs[0].get_element_type(), - inputs[0], - outputs[0], - shape_size(in_shape)); + return IF_TYPE_OF(v0_Erf_evaluate, + OV_PP_ET_LIST(f16, f32, i32, i64, u32, u64), + erf::Evaluate, + inputs[0].get_element_type(), + inputs[0], + outputs[0], + shape_size(inputs[0].get_shape())); } bool Erf::has_evaluate() const { diff --git a/src/core/src/op/exp.cpp b/src/core/src/op/exp.cpp index ecd4d37913306b..c067c36748fce6 100644 --- a/src/core/src/op/exp.cpp +++ b/src/core/src/op/exp.cpp @@ -44,10 +44,13 @@ bool Exp::evaluate(TensorVector& outputs, const TensorVector& inputs) const { outputs[0].set_shape(in_shape); using namespace ov::element; - return IfTypeOf::apply(inputs[0].get_element_type(), - inputs[0], - outputs[0], - shape_size(in_shape)); + return IF_TYPE_OF(v0_Exp_evaluate, + OV_PP_ET_LIST(f16, f32, i32, i64, u32, u64), + exp::Evaluate, + inputs[0].get_element_type(), + inputs[0], + outputs[0], + shape_size(in_shape)); } bool Exp::has_evaluate() const { diff --git a/src/core/src/op/eye.cpp b/src/core/src/op/eye.cpp index 86fe1c62bafffa..a3612c40e61c3f 100644 --- a/src/core/src/op/eye.cpp +++ b/src/core/src/op/eye.cpp @@ -123,10 +123,13 @@ bool Eye::evaluate(TensorVector& outputs, const TensorVector& inputs) const { outputs[0].set_shape(output_shape); using namespace ov::element; - return IfTypeOf::apply(outputs[0].get_element_type(), - outputs[0], - output_shape, - diagonal_index); + return IF_TYPE_OF(v9_Eye_evaluate, + OV_PP_ET_LIST(bf16, f16, f32, f64, i8, i32, i64, u8), + eye::Evaluate, + outputs[0].get_element_type(), + outputs[0], + output_shape, + diagonal_index); } } // namespace v9 } // namespace op diff --git a/src/core/src/op/fake_convert.cpp b/src/core/src/op/fake_convert.cpp index e90f08dd8426bc..0aad25b58917d2 100644 --- a/src/core/src/op/fake_convert.cpp +++ b/src/core/src/op/fake_convert.cpp @@ -47,19 +47,19 @@ struct Evaluate : element::NoAction { }; } // namespace fake_convert_details -FakeConvert::FakeConvert(const ov::Output& arg, +FakeConvert::FakeConvert(const ov::Output& data, const ov::Output& scale, std::string destination_type) - : Op({arg, scale}), + : Op({data, scale}), m_destination_type(std::move(destination_type)) { constructor_validate_and_infer_types(); } -FakeConvert::FakeConvert(const ov::Output& arg, +FakeConvert::FakeConvert(const ov::Output& data, const ov::Output& scale, const ov::Output& shift, std::string destination_type) - : Op({arg, scale, shift}), + : Op({data, scale, shift}), m_destination_type(std::move(destination_type)) { constructor_validate_and_infer_types(); } @@ -135,10 +135,13 @@ bool FakeConvert::evaluate(ov::TensorVector& outputs, const ov::TensorVector& in outputs[0].set_shape(inputs[0].get_shape()); using namespace ov::element; - return IfTypeOf::apply(inputs[0].get_element_type(), - outputs, - inputs, - get_destination_type()); + return IF_TYPE_OF(v13_FakeConvert_evaluate, + OV_PP_ET_LIST(bf16, f16, f32), + fake_convert_details::Evaluate, + inputs[0].get_element_type(), + outputs, + inputs, + get_destination_type()); return true; } diff --git a/src/core/src/op/fake_quantize.cpp b/src/core/src/op/fake_quantize.cpp index 9b7ba0e991ae11..b15137e92038ed 100644 --- a/src/core/src/op/fake_quantize.cpp +++ b/src/core/src/op/fake_quantize.cpp @@ -113,20 +113,23 @@ bool FakeQuantize::evaluate(TensorVector& outputs, const TensorVector& inputs) c outputs[0].set_shape(shape0); using namespace ov::element; - return IfTypeOf::apply(inputs[0].get_element_type(), - inputs[0], - inputs[1], - inputs[2], - inputs[3], - inputs[4], - outputs[0], - shape0, - inputs[1].get_shape(), - inputs[2].get_shape(), - inputs[3].get_shape(), - inputs[4].get_shape(), - get_levels(), - get_auto_broadcast()); + return IF_TYPE_OF(v0_FakeQuantize_evaluate, + OV_PP_ET_LIST(f16, f32, i32, i64, u32, u64), + fake_quantize::Evaluate, + inputs[0].get_element_type(), + inputs[0], + inputs[1], + inputs[2], + inputs[3], + inputs[4], + outputs[0], + shape0, + inputs[1].get_shape(), + inputs[2].get_shape(), + inputs[3].get_shape(), + inputs[4].get_shape(), + get_levels(), + get_auto_broadcast()); } bool FakeQuantize::has_evaluate() const { diff --git a/src/core/src/op/floor.cpp b/src/core/src/op/floor.cpp index c884dac18cab36..e84e42a9cd7884 100644 --- a/src/core/src/op/floor.cpp +++ b/src/core/src/op/floor.cpp @@ -44,11 +44,13 @@ bool Floor::evaluate(TensorVector& outputs, const TensorVector& inputs) const { outputs[0].set_shape(in_shape); using namespace ov::element; - return IfTypeOf::apply( - inputs[0].get_element_type(), - inputs[0], - outputs[0], - shape_size(in_shape)); + return IF_TYPE_OF(v0_Floor_evaluate, + OV_PP_ET_LIST(f16, f32, i8, i16, i32, i64, u8, u16, u32, u64), + floor::Evaluate, + inputs[0].get_element_type(), + inputs[0], + outputs[0], + shape_size(in_shape)); } bool Floor::has_evaluate() const { diff --git a/src/core/src/op/floor_mod.cpp b/src/core/src/op/floor_mod.cpp index 225c70a5e5d5eb..1c45edf4af35d8 100644 --- a/src/core/src/op/floor_mod.cpp +++ b/src/core/src/op/floor_mod.cpp @@ -48,14 +48,16 @@ bool FloorMod::evaluate(TensorVector& outputs, const TensorVector& inputs) const outputs[0].set_shape(infer_broadcast_shape(this, inputs)); using namespace ov::element; - return IfTypeOf::apply( - inputs[0].get_element_type(), - inputs[0], - inputs[1], - outputs[0], - inputs[0].get_shape(), - inputs[1].get_shape(), - get_autob()); + return IF_TYPE_OF(v1_FloorMod_evaluate, + OV_PP_ET_LIST(bf16, f16, f32, i8, i32, i64, u8, u32, u64), + floor_mod::Evaluate, + inputs[0].get_element_type(), + inputs[0], + inputs[1], + outputs[0], + inputs[0].get_shape(), + inputs[1].get_shape(), + get_autob()); } bool FloorMod::has_evaluate() const { diff --git a/src/core/src/op/gather.cpp b/src/core/src/op/gather.cpp index 2680d161a0ad94..e53f290f1633c1 100644 --- a/src/core/src/op/gather.cpp +++ b/src/core/src/op/gather.cpp @@ -5,39 +5,37 @@ #include "openvino/op/gather.hpp" #include "itt.hpp" -#include "openvino/core/validation_util.hpp" +#include "validation_util.hpp" namespace ov { - -op::v1::Gather::Gather(const Output& params, const Output& indices, const Output& axes) +namespace op { +namespace v1 { +Gather::Gather(const Output& params, const Output& indices, const Output& axes) : GatherBase(params, indices, axes) { constructor_validate_and_infer_types(); } -int64_t op::v1::Gather::get_axis() const { - OPENVINO_SUPPRESS_DEPRECATED_START - if (!get_constant_from_source(input_value(2))) { - OPENVINO_SUPPRESS_DEPRECATED_END - return AXIS_NOT_SET_VALUE; - } - return GatherBase::get_axis(); +int64_t Gather::get_axis() const { + return ov::util::get_constant_from_source(input_value(2)) ? GatherBase::get_axis() : AXIS_NOT_SET_VALUE; } -std::shared_ptr op::v1::Gather::clone_with_new_inputs(const OutputVector& new_args) const { +std::shared_ptr Gather::clone_with_new_inputs(const OutputVector& new_args) const { OV_OP_SCOPE(v1_Gather_clone_with_new_inputs); check_new_args_count(this, new_args); - return std::make_shared(new_args.at(0), new_args.at(1), new_args.at(2)); + return std::make_shared(new_args.at(0), new_args.at(1), new_args.at(2)); } +} // namespace v1 -op::v7::Gather::Gather(const Output& data, - const Output& indices, - const Output& axis, - const int64_t batch_dims) +namespace v7 { +Gather::Gather(const Output& data, + const Output& indices, + const Output& axis, + const int64_t batch_dims) : GatherBase(data, indices, axis, batch_dims) { constructor_validate_and_infer_types(); } -void op::v7::Gather::validate_and_infer_types() { +void Gather::validate_and_infer_types() { OV_OP_SCOPE(v7_Gather_validate_and_infer_types); NODE_VALIDATION_CHECK(this, get_input_element_type(1).is_integral_number(), @@ -47,37 +45,39 @@ void op::v7::Gather::validate_and_infer_types() { get_input_element_type(2).is_integral_number(), "Axis element type must be of an integral number type."); - op::util::GatherBase::validate_and_infer_types(); + util::GatherBase::validate_and_infer_types(); } -int64_t op::v7::Gather::get_batch_dims() const { +int64_t Gather::get_batch_dims() const { if (m_batch_dims < 0 && get_input_partial_shape(1).rank().is_static()) return m_batch_dims + get_input_partial_shape(1).rank().get_length(); else return m_batch_dims; } -bool op::v7::Gather::visit_attributes(AttributeVisitor& visitor) { +bool Gather::visit_attributes(AttributeVisitor& visitor) { OV_OP_SCOPE(v7_Gather_visit_attributes); visitor.on_attribute("batch_dims", m_batch_dims); return true; } -std::shared_ptr op::v7::Gather::clone_with_new_inputs(const OutputVector& new_args) const { +std::shared_ptr Gather::clone_with_new_inputs(const OutputVector& new_args) const { OV_OP_SCOPE(v7_Gather_clone_with_new_inputs); check_new_args_count(this, new_args); - return std::make_shared(new_args.at(0), new_args.at(1), new_args.at(2), m_batch_dims); + return std::make_shared(new_args.at(0), new_args.at(1), new_args.at(2), m_batch_dims); } +} // namespace v7 -op::v8::Gather::Gather(const Output& data, - const Output& indices, - const Output& axis, - const int64_t batch_dims) +namespace v8 { +Gather::Gather(const Output& data, + const Output& indices, + const Output& axis, + const int64_t batch_dims) : GatherBase(data, indices, axis, batch_dims) { constructor_validate_and_infer_types(); } -void op::v8::Gather::validate_and_infer_types() { +void Gather::validate_and_infer_types() { OV_OP_SCOPE(v8_Gather_validate_and_infer_types); NODE_VALIDATION_CHECK(this, get_input_element_type(1).is_integral_number(), @@ -90,22 +90,24 @@ void op::v8::Gather::validate_and_infer_types() { op::util::GatherBase::validate_and_infer_types(); } -int64_t op::v8::Gather::get_batch_dims() const { +int64_t Gather::get_batch_dims() const { if (m_batch_dims < 0 && get_input_partial_shape(1).rank().is_static()) return m_batch_dims + get_input_partial_shape(1).rank().get_length(); else return m_batch_dims; } -bool op::v8::Gather::visit_attributes(AttributeVisitor& visitor) { +bool Gather::visit_attributes(AttributeVisitor& visitor) { OV_OP_SCOPE(v8_Gather_visit_attributes); visitor.on_attribute("batch_dims", m_batch_dims); return true; } -std::shared_ptr op::v8::Gather::clone_with_new_inputs(const OutputVector& new_args) const { +std::shared_ptr Gather::clone_with_new_inputs(const OutputVector& new_args) const { OV_OP_SCOPE(v8_Gather_clone_with_new_inputs); check_new_args_count(this, new_args); - return std::make_shared(new_args.at(0), new_args.at(1), new_args.at(2), m_batch_dims); + return std::make_shared(new_args.at(0), new_args.at(1), new_args.at(2), m_batch_dims); } +} // namespace v8 +} // namespace op } // namespace ov diff --git a/src/core/src/op/gelu.cpp b/src/core/src/op/gelu.cpp index cc261ca1650a1b..c8264e2ac76c9b 100644 --- a/src/core/src/op/gelu.cpp +++ b/src/core/src/op/gelu.cpp @@ -104,11 +104,14 @@ bool Gelu::evaluate(TensorVector& outputs, const TensorVector& inputs) const { const auto count = shape_size(input_shape); outputs[0].set_shape(input_shape); using namespace ov::element; - return IfTypeOf::apply(inputs[0].get_element_type(), - inputs[0], - outputs[0], - m_approximation_mode, - count); + return IF_TYPE_OF(v7_Gelu_evaluate, + OV_PP_ET_LIST(f16, f32), + gelu::Evaluate, + inputs[0].get_element_type(), + inputs[0], + outputs[0], + m_approximation_mode, + count); } bool Gelu::has_evaluate() const { diff --git a/src/core/src/op/greater.cpp b/src/core/src/op/greater.cpp index 76715745a5fba7..ed09e77f4b07d7 100644 --- a/src/core/src/op/greater.cpp +++ b/src/core/src/op/greater.cpp @@ -53,13 +53,16 @@ bool Greater::evaluate(TensorVector& outputs, const TensorVector& inputs) const outputs[0].set_shape(infer_broadcast_shape(this, inputs)); using namespace ov::element; - return IfTypeOf::apply(inputs[0].get_element_type(), - inputs[0], - inputs[1], - outputs[0], - inputs[0].get_shape(), - inputs[1].get_shape(), - get_autob()); + return IF_TYPE_OF(v1_Greater_evaluate, + OV_PP_ET_LIST(boolean, f16, f32, i32, i64, u32, u64), + greater::Evaluate, + inputs[0].get_element_type(), + inputs[0], + inputs[1], + outputs[0], + inputs[0].get_shape(), + inputs[1].get_shape(), + get_autob()); } bool Greater::has_evaluate() const { diff --git a/src/core/src/op/greater_eq.cpp b/src/core/src/op/greater_eq.cpp index a3bd099262a6b3..4f111431f8ab35 100644 --- a/src/core/src/op/greater_eq.cpp +++ b/src/core/src/op/greater_eq.cpp @@ -53,13 +53,16 @@ bool GreaterEqual::evaluate(TensorVector& outputs, const TensorVector& inputs) c outputs[0].set_shape(infer_broadcast_shape(this, inputs)); using namespace ov::element; - return IfTypeOf::apply(inputs[0].get_element_type(), - inputs[0], - inputs[1], - outputs[0], - inputs[0].get_shape(), - inputs[1].get_shape(), - get_autob()); + return IF_TYPE_OF(v1_GreaterEqual_evaluate, + OV_PP_ET_LIST(boolean, f16, f32, i32, i64, u32, u64), + greater_equal::Evaluate, + inputs[0].get_element_type(), + inputs[0], + inputs[1], + outputs[0], + inputs[0].get_shape(), + inputs[1].get_shape(), + get_autob()); } bool GreaterEqual::has_evaluate() const { diff --git a/src/core/src/op/grid_sample.cpp b/src/core/src/op/grid_sample.cpp index bb81c9778939cf..d5ed0790d4ae12 100644 --- a/src/core/src/op/grid_sample.cpp +++ b/src/core/src/op/grid_sample.cpp @@ -25,13 +25,16 @@ struct Evaluate : element::NoAction { const Shape& grid_shape, const GridSample::Attributes& attributes) { using namespace ov::element; - return IfTypeOf::apply(grid.get_element_type(), - output.data(), - data.data(), - grid, - data_shape, - grid_shape, - attributes); + return IF_TYPE_OF(eval_by_grid_type, + OV_PP_ET_LIST(f32), + EvalByGridType, + grid.get_element_type(), + output.data(), + data.data(), + grid, + data_shape, + grid_shape, + attributes); } private: @@ -100,13 +103,16 @@ bool GridSample::evaluate(TensorVector& outputs, const TensorVector& inputs) con outputs[0].set_shape(out_shape); using namespace ov::element; - return IfTypeOf::apply(inputs[0].get_element_type(), - outputs[0], - inputs[0], - inputs[1], - inputs[0].get_shape(), - inputs[1].get_shape(), - m_attributes); + return IF_TYPE_OF(v9_GridSample_evaluate, + OV_PP_ET_LIST(f32), + Evaluate, + inputs[0].get_element_type(), + outputs[0], + inputs[0], + inputs[1], + inputs[0].get_shape(), + inputs[1].get_shape(), + m_attributes); } bool GridSample::has_evaluate() const { diff --git a/src/core/src/op/hsigmoid.cpp b/src/core/src/op/hsigmoid.cpp index 2abc4c02c5da9d..9ed9ac3aa79860 100644 --- a/src/core/src/op/hsigmoid.cpp +++ b/src/core/src/op/hsigmoid.cpp @@ -42,11 +42,15 @@ bool HSigmoid::evaluate(TensorVector& outputs, const TensorVector& inputs) const const auto& input_shape = inputs[0].get_shape(); const auto count = shape_size(input_shape); outputs[0].set_shape(input_shape); + using namespace ov::element; - return IfTypeOf::apply(inputs[0].get_element_type(), - inputs[0], - outputs[0], - count); + return IF_TYPE_OF(v5_HSigmoid_evaluate, + OV_PP_ET_LIST(bf16, f16, f32), + hsigmoid::Evaluate, + inputs[0].get_element_type(), + inputs[0], + outputs[0], + count); } bool HSigmoid::has_evaluate() const { diff --git a/src/core/src/op/hswish.cpp b/src/core/src/op/hswish.cpp index fd2d89896c0460..dbb7e744cad146 100644 --- a/src/core/src/op/hswish.cpp +++ b/src/core/src/op/hswish.cpp @@ -43,10 +43,13 @@ bool HSwish::evaluate(TensorVector& outputs, const TensorVector& inputs) const { const auto count = shape_size(input_shape); outputs[0].set_shape(input_shape); using namespace ov::element; - return IfTypeOf::apply(inputs[0].get_element_type(), - inputs[0], - outputs[0], - count); + return IF_TYPE_OF(v4_HSwish_evaluate, + OV_PP_ET_LIST(bf16, f16, f32), + hswish::Evaluate, + inputs[0].get_element_type(), + inputs[0], + outputs[0], + count); } bool HSwish::has_evaluate() const { diff --git a/src/core/src/op/less.cpp b/src/core/src/op/less.cpp index 910876c3a58853..1f7f27dc850ff2 100644 --- a/src/core/src/op/less.cpp +++ b/src/core/src/op/less.cpp @@ -52,13 +52,16 @@ bool Less::evaluate(TensorVector& outputs, const TensorVector& inputs) const { outputs[0].set_shape(infer_broadcast_shape(this, inputs)); using namespace ov::element; - return IfTypeOf::apply(inputs[0].get_element_type(), - inputs[0], - inputs[1], - outputs[0], - inputs[0].get_shape(), - inputs[1].get_shape(), - get_autob()); + return IF_TYPE_OF(v1_Less_evaluate, + OV_PP_ET_LIST(boolean, f16, f32, i32, i64, u32, u64), + less::Evaluate, + inputs[0].get_element_type(), + inputs[0], + inputs[1], + outputs[0], + inputs[0].get_shape(), + inputs[1].get_shape(), + get_autob()); } bool Less::has_evaluate() const { diff --git a/src/core/src/op/less_eq.cpp b/src/core/src/op/less_eq.cpp index 76c94ad91cba65..5bc3837885fd1f 100644 --- a/src/core/src/op/less_eq.cpp +++ b/src/core/src/op/less_eq.cpp @@ -53,13 +53,16 @@ bool LessEqual::evaluate(TensorVector& outputs, const TensorVector& inputs) cons outputs[0].set_shape(infer_broadcast_shape(this, inputs)); using namespace ov::element; - return IfTypeOf::apply(inputs[0].get_element_type(), - inputs[0], - inputs[1], - outputs[0], - inputs[0].get_shape(), - inputs[1].get_shape(), - get_autob()); + return IF_TYPE_OF(v1_LessEqual_evaluate, + OV_PP_ET_LIST(boolean, f16, f32, i32, i64, u32, u64), + less_equal::Evaluate, + inputs[0].get_element_type(), + inputs[0], + inputs[1], + outputs[0], + inputs[0].get_shape(), + inputs[1].get_shape(), + get_autob()); } bool LessEqual::has_evaluate() const { diff --git a/src/core/src/op/log.cpp b/src/core/src/op/log.cpp index dacde7087e93d3..0bbaa1d250d65f 100644 --- a/src/core/src/op/log.cpp +++ b/src/core/src/op/log.cpp @@ -42,10 +42,13 @@ bool Log::evaluate(TensorVector& outputs, const TensorVector& inputs) const { const auto count = shape_size(input_shape); outputs[0].set_shape(input_shape); using namespace ov::element; - return IfTypeOf::apply(inputs[0].get_element_type(), - inputs[0], - outputs[0], - count); + return IF_TYPE_OF(v0_Log_evaluate, + OV_PP_ET_LIST(f16, f32, i32, i64, u32, u64), + log::Evaluate, + inputs[0].get_element_type(), + inputs[0], + outputs[0], + count); } bool Log::has_evaluate() const { diff --git a/src/core/src/op/logical_not.cpp b/src/core/src/op/logical_not.cpp index db9f939463651a..e3aab7c64a3c2f 100644 --- a/src/core/src/op/logical_not.cpp +++ b/src/core/src/op/logical_not.cpp @@ -51,11 +51,13 @@ bool LogicalNot::evaluate(TensorVector& outputs, const TensorVector& inputs) con outputs[0].set_shape(inputs[0].get_shape()); using namespace ov::element; - return IfTypeOf::apply( - inputs[0].get_element_type(), - inputs[0], - outputs[0], - shape_size(inputs[0].get_shape())); + return IF_TYPE_OF(v1_LogicalNot_evaluate, + OV_PP_ET_LIST(boolean, i32, i64, u32, u64, f16, f32), + logical_not::Evaluate, + inputs[0].get_element_type(), + inputs[0], + outputs[0], + shape_size(inputs[0].get_shape())); } bool LogicalNot::has_evaluate() const { diff --git a/src/core/src/op/matmul.cpp b/src/core/src/op/matmul.cpp index 06fd0a9f33e424..130b8a793d6f05 100644 --- a/src/core/src/op/matmul.cpp +++ b/src/core/src/op/matmul.cpp @@ -68,15 +68,18 @@ bool MatMul::evaluate(TensorVector& outputs, const TensorVector& inputs) const { outputs[0].set_shape(out_shape); using namespace ov::element; - return IfTypeOf::apply(inputs[0].get_element_type(), - inputs[0], - inputs[1], - outputs[0], - inputs[0].get_shape(), - inputs[1].get_shape(), - out_shape, - m_transpose_a, - m_transpose_b); + return IF_TYPE_OF(v0_MatMul_evaluate, + OV_PP_ET_LIST(f16, f32, i32, i64, u32, u64), + matmul::Evaluate, + inputs[0].get_element_type(), + inputs[0], + inputs[1], + outputs[0], + inputs[0].get_shape(), + inputs[1].get_shape(), + out_shape, + m_transpose_a, + m_transpose_b); } bool MatMul::has_evaluate() const { diff --git a/src/core/src/op/max_pool.cpp b/src/core/src/op/max_pool.cpp index 4dab91221f91f0..c7afdb77187adb 100644 --- a/src/core/src/op/max_pool.cpp +++ b/src/core/src/op/max_pool.cpp @@ -93,15 +93,18 @@ bool MaxPool::evaluate(TensorVector& outputs, const TensorVector& inputs) const outputs[0].set_shape(output_shape.get_shape()); using namespace ov::element; - return IfTypeOf::apply(inputs[0].get_element_type(), - inputs[0], - outputs[0], - inputs[0].get_shape(), - outputs[0].get_shape(), - get_kernel(), - get_strides(), - get_pads_begin(), - get_pads_end()); + return IF_TYPE_OF(v1_MaxPool_evaluate, + OV_PP_ET_LIST(f16, f32, i32, i64, u32, u64), + maxpool::Evaluate, + inputs[0].get_element_type(), + inputs[0], + outputs[0], + inputs[0].get_shape(), + outputs[0].get_shape(), + get_kernel(), + get_strides(), + get_pads_begin(), + get_pads_end()); } bool MaxPool::has_evaluate() const { @@ -208,18 +211,21 @@ struct Evaluate : element::NoAction { const Shape& pads_end, const int64_t axis) { using namespace ov::element; - return IfTypeOf::apply(out_indices.get_element_type(), - in.data(), - out_values.data(), - out_indices, - in_shape, - out_shape, - kernel, - strides, - dilations, - pads_begin, - pads_end, - axis); + return IF_TYPE_OF(maxpool_eval_by_idx_type, + OV_PP_ET_LIST(i32, i64), + EvalByIdxType, + out_indices.get_element_type(), + in.data(), + out_values.data(), + out_indices, + in_shape, + out_shape, + kernel, + strides, + dilations, + pads_begin, + pads_end, + axis); } private: @@ -265,18 +271,21 @@ bool MaxPool::evaluate(TensorVector& outputs, const TensorVector& inputs) const outputs[0].set_shape(output_shape.get_shape()); using namespace ov::element; - return IfTypeOf::apply(inputs[0].get_element_type(), - inputs[0], - outputs[0], - outputs[1], - inputs[0].get_shape(), - outputs[0].get_shape(), - get_kernel(), - get_strides(), - get_dilations(), - get_pads_begin(), - get_pads_end(), - get_axis()); + return IF_TYPE_OF(v8_MaxPool_evaluate, + OV_PP_ET_LIST(f16, f32, i8, i32, i64, u8, u32, u64), + maxpool::Evaluate, + inputs[0].get_element_type(), + inputs[0], + outputs[0], + outputs[1], + inputs[0].get_shape(), + outputs[0].get_shape(), + get_kernel(), + get_strides(), + get_dilations(), + get_pads_begin(), + get_pads_end(), + get_axis()); } bool MaxPool::has_evaluate() const { diff --git a/src/core/src/op/maximum.cpp b/src/core/src/op/maximum.cpp index 90a038d0b540cb..5a9e832bbb2c99 100644 --- a/src/core/src/op/maximum.cpp +++ b/src/core/src/op/maximum.cpp @@ -48,13 +48,16 @@ bool Maximum::evaluate(TensorVector& outputs, const TensorVector& inputs) const outputs[0].set_shape(infer_broadcast_shape(this, inputs)); using namespace ov::element; - return IfTypeOf::apply(inputs[0].get_element_type(), - inputs[0], - inputs[1], - outputs[0], - inputs[0].get_shape(), - inputs[1].get_shape(), - get_autob()); + return IF_TYPE_OF(v1_Maximum_evaluate, + OV_PP_ET_LIST(f16, f32, i32, i64, u32, u64), + maximum::Evaluate, + inputs[0].get_element_type(), + inputs[0], + inputs[1], + outputs[0], + inputs[0].get_shape(), + inputs[1].get_shape(), + get_autob()); } bool Maximum::has_evaluate() const { diff --git a/src/core/src/op/minimum.cpp b/src/core/src/op/minimum.cpp index 1844c6e5b25e36..544f33e5055262 100644 --- a/src/core/src/op/minimum.cpp +++ b/src/core/src/op/minimum.cpp @@ -49,13 +49,16 @@ bool Minimum::evaluate(TensorVector& outputs, const TensorVector& inputs) const outputs[0].set_shape(infer_broadcast_shape(this, inputs)); using namespace ov::element; - return IfTypeOf::apply(inputs[0].get_element_type(), - inputs[0], - inputs[1], - outputs[0], - inputs[0].get_shape(), - inputs[1].get_shape(), - get_autob()); + return IF_TYPE_OF(v1_Minimum_evaluate, + OV_PP_ET_LIST(f16, f32, i32, i64, u8, u16, u32, u64), + minimum::Evaluate, + inputs[0].get_element_type(), + inputs[0], + inputs[1], + outputs[0], + inputs[0].get_shape(), + inputs[1].get_shape(), + get_autob()); } bool Minimum::has_evaluate() const { diff --git a/src/core/src/op/mish.cpp b/src/core/src/op/mish.cpp index 606ff6239f59a4..406692baccd112 100644 --- a/src/core/src/op/mish.cpp +++ b/src/core/src/op/mish.cpp @@ -58,10 +58,13 @@ bool Mish::evaluate(TensorVector& outputs, const TensorVector& inputs) const { outputs[0].set_shape(in_shape); using namespace ov::element; - return IfTypeOf::apply(inputs[0].get_element_type(), - inputs[0], - outputs[0], - shape_size(in_shape)); + return IF_TYPE_OF(v4_Mish_evaluate, + OV_PP_ET_LIST(f16, f32), + mish::Evaluate, + inputs[0].get_element_type(), + inputs[0], + outputs[0], + shape_size(in_shape)); } bool Mish::has_evaluate() const { diff --git a/src/core/src/op/mod.cpp b/src/core/src/op/mod.cpp index 69ac9493052d20..b321b58d4c54a9 100644 --- a/src/core/src/op/mod.cpp +++ b/src/core/src/op/mod.cpp @@ -244,13 +244,16 @@ bool Mod::evaluate(ov::TensorVector& outputs, const ov::TensorVector& inputs) co outputs[0].set_shape(infer_broadcast_shape(this, inputs)); using namespace ov::element; - return IfTypeOf::apply(inputs[0].get_element_type(), - inputs[0], - inputs[1], - outputs[0], - inputs[0].get_shape(), - inputs[1].get_shape(), - get_autob()); + return IF_TYPE_OF(v1_Mod_evaluate, + OV_PP_ET_LIST(i8, i16, i32, i64, u8, u16, u32, u64), + mod::Evaluate, + inputs[0].get_element_type(), + inputs[0], + inputs[1], + outputs[0], + inputs[0].get_shape(), + inputs[1].get_shape(), + get_autob()); } bool Mod::evaluate_lower(TensorVector& outputs) const { diff --git a/src/core/src/op/multiply.cpp b/src/core/src/op/multiply.cpp index 2ae5f4304cfcbe..c1c47df1abd3ae 100644 --- a/src/core/src/op/multiply.cpp +++ b/src/core/src/op/multiply.cpp @@ -47,13 +47,16 @@ bool Multiply::evaluate(TensorVector& outputs, const TensorVector& inputs) const outputs[0].set_shape(infer_broadcast_shape(this, inputs)); using namespace ov::element; - return IfTypeOf::apply(inputs[0].get_element_type(), - inputs[0], - inputs[1], - outputs[0], - inputs[0].get_shape(), - inputs[1].get_shape(), - get_autob()); + return IF_TYPE_OF(v1_Multiply_evaluate, + OV_PP_ET_LIST(bf16, f16, f32, f64, i32, i64, u32, u64), + multiply::Evaluate, + inputs[0].get_element_type(), + inputs[0], + inputs[1], + outputs[0], + inputs[0].get_shape(), + inputs[1].get_shape(), + get_autob()); } bool Multiply::has_evaluate() const { diff --git a/src/core/src/op/negative.cpp b/src/core/src/op/negative.cpp index a34d29a479d83d..8f8f6a2cc513e2 100644 --- a/src/core/src/op/negative.cpp +++ b/src/core/src/op/negative.cpp @@ -42,10 +42,13 @@ bool Negative::evaluate(TensorVector& outputs, const TensorVector& inputs) const outputs[0].set_shape(inputs[0].get_shape()); using namespace ov::element; - return IfTypeOf::apply(inputs[0].get_element_type(), - inputs[0], - outputs[0], - shape_size(inputs[0].get_shape())); + return IF_TYPE_OF(v0_Negative_evaluate, + OV_PP_ET_LIST(bf16, f16, f32, i32, i64), + negative::Evaluate, + inputs[0].get_element_type(), + inputs[0], + outputs[0], + shape_size(inputs[0].get_shape())); } bool Negative::has_evaluate() const { diff --git a/src/core/src/op/non_zero.cpp b/src/core/src/op/non_zero.cpp index 8257c05924fae4..06c0df37d585a0 100644 --- a/src/core/src/op/non_zero.cpp +++ b/src/core/src/op/non_zero.cpp @@ -26,7 +26,13 @@ struct Evaluate : public element::NoAction { out.set_shape(out_shape); using namespace ov::element; - return IfTypeOf::apply(out.get_element_type(), in_data, out, in_shape); + return IF_TYPE_OF(non_zero_out_type, + OV_PP_ET_LIST(i32, i64), + EvalByOutType, + out.get_element_type(), + in_data, + out, + in_shape); } private: @@ -114,12 +120,14 @@ bool NonZero::evaluate(TensorVector& outputs, const TensorVector& inputs) const auto& output = outputs[0]; using namespace ov::element; const auto& input_shape = input.get_shape(); - return IfTypeOf::apply( - input.get_element_type(), - input, - input_shape, - input_shape.size(), - output); + return IF_TYPE_OF(v3_NonZero_evaluate, + OV_PP_ET_LIST(boolean, bf16, f16, f32, f64, i8, i16, i32, i64, u8, u16, u32, u64), + non_zero::Evaluate, + input.get_element_type(), + input, + input_shape, + input_shape.size(), + output); } bool NonZero::has_evaluate() const { diff --git a/src/core/src/op/not_equal.cpp b/src/core/src/op/not_equal.cpp index 55c0f5a3d9fa44..920b79064cb86c 100644 --- a/src/core/src/op/not_equal.cpp +++ b/src/core/src/op/not_equal.cpp @@ -51,13 +51,16 @@ bool NotEqual::evaluate(TensorVector& outputs, const TensorVector& inputs) const outputs[0].set_shape(infer_broadcast_shape(this, inputs)); using namespace ov::element; - return IfTypeOf::apply(inputs[0].get_element_type(), - inputs[0], - inputs[1], - outputs[0], - inputs[0].get_shape(), - inputs[1].get_shape(), - get_autob()); + return IF_TYPE_OF(v1_NotEqual_evaluate, + OV_PP_ET_LIST(boolean, f16, f32, i32, i64, u32, u64), + not_equal::Evaluate, + inputs[0].get_element_type(), + inputs[0], + inputs[1], + outputs[0], + inputs[0].get_shape(), + inputs[1].get_shape(), + get_autob()); } bool NotEqual::has_evaluate() const { diff --git a/src/core/src/op/one_hot.cpp b/src/core/src/op/one_hot.cpp index 8a3cd26e6fd45a..ac9ba016a702f3 100644 --- a/src/core/src/op/one_hot.cpp +++ b/src/core/src/op/one_hot.cpp @@ -118,15 +118,18 @@ bool OneHot::evaluate(TensorVector& outputs, const TensorVector& inputs) const { auto& output = outputs[0]; output.set_shape(output_shape); using namespace ov::element; - return IfTypeOf::apply(indices.get_element_type(), - indices, - indices_shape, - static_cast(output.data()), - output.get_element_type().size(), - output.get_shape()[axis], - on_value, - off_value, - axis); + return IF_TYPE_OF(v1_OneHot_evaluate, + OV_PP_ET_LIST(i32, i64), + one_hot::Evaluate, + indices.get_element_type(), + indices, + indices_shape, + static_cast(output.data()), + output.get_element_type().size(), + output.get_shape()[axis], + on_value, + off_value, + axis); } bool OneHot::has_evaluate() const { diff --git a/src/core/src/op/power.cpp b/src/core/src/op/power.cpp index 7eda718951e80f..88460b36e33965 100644 --- a/src/core/src/op/power.cpp +++ b/src/core/src/op/power.cpp @@ -49,13 +49,16 @@ bool Power::evaluate(TensorVector& outputs, const TensorVector& inputs) const { out.set_shape(infer_broadcast_shape(this, inputs)); using namespace ov::element; - return IfTypeOf::apply(inputs[0].get_element_type(), - inputs[0], - inputs[1], - out, - inputs[0].get_shape(), - inputs[1].get_shape(), - get_autob()); + return IF_TYPE_OF(v1_Power_evaluate, + OV_PP_ET_LIST(bf16, f16, f32, i32, i64, u32, u64), + power::Evaluate, + inputs[0].get_element_type(), + inputs[0], + inputs[1], + out, + inputs[0].get_shape(), + inputs[1].get_shape(), + get_autob()); } bool Power::has_evaluate() const { diff --git a/src/core/src/op/prelu.cpp b/src/core/src/op/prelu.cpp index ee417602cf023f..7c65f5c15cfbd9 100644 --- a/src/core/src/op/prelu.cpp +++ b/src/core/src/op/prelu.cpp @@ -55,12 +55,15 @@ bool PRelu::evaluate(TensorVector& outputs, const TensorVector& inputs) const { out.set_shape(arg_shape); using namespace ov::element; - return IfTypeOf::apply(inputs[0].get_element_type(), - inputs[0], - inputs[1], - out, - arg_shape, - inputs[1].get_shape()); + return IF_TYPE_OF(v0_PRelu_evaluate, + OV_PP_ET_LIST(bf16, f16, f32, i8), + prelu::Evaluate, + inputs[0].get_element_type(), + inputs[0], + inputs[1], + out, + arg_shape, + inputs[1].get_shape()); } bool PRelu::has_evaluate() const { diff --git a/src/core/src/op/range.cpp b/src/core/src/op/range.cpp index f048f778c31bce..fef5f15aa4f787 100644 --- a/src/core/src/op/range.cpp +++ b/src/core/src/op/range.cpp @@ -119,11 +119,14 @@ bool Range::evaluate(TensorVector& outputs, const TensorVector& inputs) const { const auto step = get_tensor_data_as(inputs[2])[0]; using namespace ov::element; - return IfTypeOf::apply(out.get_element_type(), - start, - step, - shape_size(out_shape), - out); + return IF_TYPE_OF(v4_Range_evaluate, + RANGE_ET_LIST, + range::Evaluate, + out.get_element_type(), + start, + step, + shape_size(out_shape), + out); } bool Range::has_evaluate() const { @@ -199,11 +202,14 @@ bool Range::evaluate(TensorVector& outputs, const TensorVector& inputs) const { out.set_shape(out_shape); using namespace ov::element; - return IfTypeOf::apply(out.get_element_type(), - start, - step, - shape_size(out_shape), - out); + return IF_TYPE_OF(v0_Range_evaluate, + RANGE_ET_LIST, + range::Evaluate, + out.get_element_type(), + start, + step, + shape_size(out_shape), + out); } bool Range::has_evaluate() const { diff --git a/src/core/src/op/reduce_l1.cpp b/src/core/src/op/reduce_l1.cpp index 75f8a000580bc3..fb44d686764200 100644 --- a/src/core/src/op/reduce_l1.cpp +++ b/src/core/src/op/reduce_l1.cpp @@ -48,10 +48,13 @@ bool ReduceL1::evaluate(TensorVector& outputs, const TensorVector& inputs) const outputs[0].set_shape(ov::util::reduce(inputs[0].get_shape(), reduction_axes, get_keep_dims())); using namespace ov::element; - return IfTypeOf::apply(inputs[0].get_element_type(), - inputs[0], - outputs[0], - reduction_axes); + return IF_TYPE_OF(v4_ReduceL1_evaluate, + OV_PP_ET_LIST(bf16, f16, f32, i32, i64), + reduce_l1::Evaluate, + inputs[0].get_element_type(), + inputs[0], + outputs[0], + reduction_axes); } bool ReduceL1::has_evaluate() const { diff --git a/src/core/src/op/reduce_l2.cpp b/src/core/src/op/reduce_l2.cpp index 5477a56986be16..9f3c48a21448f9 100644 --- a/src/core/src/op/reduce_l2.cpp +++ b/src/core/src/op/reduce_l2.cpp @@ -47,10 +47,13 @@ bool ReduceL2::evaluate(TensorVector& outputs, const TensorVector& inputs) const outputs[0].set_shape(ov::util::reduce(inputs[0].get_shape(), reduction_axes, get_keep_dims())); using namespace ov::element; - return IfTypeOf::apply(inputs[0].get_element_type(), - inputs[0], - outputs[0], - reduction_axes); + return IF_TYPE_OF(v4_ReduceL2_evaluate, + OV_PP_ET_LIST(bf16, f16, f32), + reduce_l2::Evaluate, + inputs[0].get_element_type(), + inputs[0], + outputs[0], + reduction_axes); } bool ReduceL2::has_evaluate() const { diff --git a/src/core/src/op/reduce_logical_and.cpp b/src/core/src/op/reduce_logical_and.cpp index adcfed43626306..0178917aae3665 100644 --- a/src/core/src/op/reduce_logical_and.cpp +++ b/src/core/src/op/reduce_logical_and.cpp @@ -47,10 +47,13 @@ bool ReduceLogicalAnd::evaluate(TensorVector& outputs, const TensorVector& input outputs[0].set_shape(ov::util::reduce(inputs[0].get_shape(), reduction_axes, get_keep_dims())); using namespace ov::element; - return IfTypeOf::apply(inputs[0].get_element_type(), - inputs[0], - outputs[0], - reduction_axes); + return IF_TYPE_OF(v1_ReduceLogicalAnd_evaluate, + boolean, + reduce_and::Evaluate, + inputs[0].get_element_type(), + inputs[0], + outputs[0], + reduction_axes); } bool ReduceLogicalAnd::has_evaluate() const { diff --git a/src/core/src/op/reduce_logical_or.cpp b/src/core/src/op/reduce_logical_or.cpp index a2e84d420e606d..b41c78fa859c58 100644 --- a/src/core/src/op/reduce_logical_or.cpp +++ b/src/core/src/op/reduce_logical_or.cpp @@ -48,10 +48,13 @@ bool ReduceLogicalOr::evaluate(TensorVector& outputs, const TensorVector& inputs outputs[0].set_shape(ov::util::reduce(inputs[0].get_shape(), reduction_axes, get_keep_dims())); using namespace ov::element; - return IfTypeOf::apply(inputs[0].get_element_type(), - inputs[0], - outputs[0], - reduction_axes); + return IF_TYPE_OF(v1_ReduceLogicalOr_evaluate, + boolean, + reduce_or::Evaluate, + inputs[0].get_element_type(), + inputs[0], + outputs[0], + reduction_axes); } bool ReduceLogicalOr::has_evaluate() const { diff --git a/src/core/src/op/reduce_max.cpp b/src/core/src/op/reduce_max.cpp index 989f0a771f2b1c..f64b7b1e6ec6ca 100644 --- a/src/core/src/op/reduce_max.cpp +++ b/src/core/src/op/reduce_max.cpp @@ -47,10 +47,13 @@ bool ReduceMax::evaluate(TensorVector& outputs, const TensorVector& inputs) cons outputs[0].set_shape(ov::util::reduce(inputs[0].get_shape(), reduction_axes, get_keep_dims())); using namespace ov::element; - return IfTypeOf::apply(inputs[0].get_element_type(), - inputs[0], - outputs[0], - reduction_axes); + return IF_TYPE_OF(v1_ReduceMax_evaluate, + OV_PP_ET_LIST(f16, f32, i8, i32, i64, u8, u32, u64), + reduce_max::Evaluate, + inputs[0].get_element_type(), + inputs[0], + outputs[0], + reduction_axes); } bool ReduceMax::has_evaluate() const { diff --git a/src/core/src/op/reduce_mean.cpp b/src/core/src/op/reduce_mean.cpp index 762bc1c09719ee..25f30d0235db3e 100644 --- a/src/core/src/op/reduce_mean.cpp +++ b/src/core/src/op/reduce_mean.cpp @@ -45,10 +45,13 @@ bool ReduceMean::evaluate(TensorVector& outputs, const TensorVector& inputs) con outputs[0].set_shape(ov::util::reduce(inputs[0].get_shape(), reduction_axes, get_keep_dims())); using namespace ov::element; - return IfTypeOf::apply(inputs[0].get_element_type(), - inputs[0], - outputs[0], - reduction_axes); + return IF_TYPE_OF(v1_ReduceMean_evaluate, + OV_PP_ET_LIST(f16, f32, i32, i64, u32, u64), + reduce_mean::Evaluate, + inputs[0].get_element_type(), + inputs[0], + outputs[0], + reduction_axes); } bool ReduceMean::has_evaluate() const { diff --git a/src/core/src/op/reduce_min.cpp b/src/core/src/op/reduce_min.cpp index 3334b02d5fa3ea..b60b0e9889eeda 100644 --- a/src/core/src/op/reduce_min.cpp +++ b/src/core/src/op/reduce_min.cpp @@ -45,10 +45,13 @@ bool ReduceMin::evaluate(TensorVector& outputs, const TensorVector& inputs) cons outputs[0].set_shape(ov::util::reduce(inputs[0].get_shape(), reduction_axes, get_keep_dims())); using namespace ov::element; - return IfTypeOf::apply(inputs[0].get_element_type(), - inputs[0], - outputs[0], - reduction_axes); + return IF_TYPE_OF(v1_ReduceMin_evaluate, + OV_PP_ET_LIST(f16, f32, i8, i32, i64, u8, u32, u64), + reduce_min::Evaluate, + inputs[0].get_element_type(), + inputs[0], + outputs[0], + reduction_axes); } bool ReduceMin::has_evaluate() const { diff --git a/src/core/src/op/reduce_prod.cpp b/src/core/src/op/reduce_prod.cpp index 9d2c4dee4a8c51..d80f040e5ef7ad 100644 --- a/src/core/src/op/reduce_prod.cpp +++ b/src/core/src/op/reduce_prod.cpp @@ -57,10 +57,13 @@ bool ReduceProd::evaluate(TensorVector& outputs, const TensorVector& inputs) con outputs[0].set_shape(ov::util::reduce(inputs[0].get_shape(), reduction_axes, get_keep_dims())); using namespace ov::element; - return IfTypeOf::apply(inputs[0].get_element_type(), - inputs[0], - outputs[0], - reduction_axes); + return IF_TYPE_OF(v1_ReduceProd_evaluate, + OV_PP_ET_LIST(f16, f32, i32, i64, u32, u64), + reduce_prod::Evaluate, + inputs[0].get_element_type(), + inputs[0], + outputs[0], + reduction_axes); } bool ReduceProd::has_evaluate() const { diff --git a/src/core/src/op/reduce_sum.cpp b/src/core/src/op/reduce_sum.cpp index 33e7ced8204faf..b661fbc1ea4a80 100644 --- a/src/core/src/op/reduce_sum.cpp +++ b/src/core/src/op/reduce_sum.cpp @@ -45,10 +45,13 @@ bool ReduceSum::evaluate(TensorVector& outputs, const TensorVector& inputs) cons outputs[0].set_shape(ov::util::reduce(inputs[0].get_shape(), reduction_axes, get_keep_dims())); using namespace ov::element; - return IfTypeOf::apply(inputs[0].get_element_type(), - inputs[0], - outputs[0], - reduction_axes); + return IF_TYPE_OF(v1_ReduceSum_evaluate, + OV_PP_ET_LIST(f16, f32, i32, i64, u32, u64), + reduce_sum::Evaluate, + inputs[0].get_element_type(), + inputs[0], + outputs[0], + reduction_axes); } bool ReduceSum::has_evaluate() const { diff --git a/src/core/src/op/relu.cpp b/src/core/src/op/relu.cpp index ebc8aa46d39053..eff1ecc0f755a3 100644 --- a/src/core/src/op/relu.cpp +++ b/src/core/src/op/relu.cpp @@ -42,10 +42,13 @@ bool Relu::evaluate(TensorVector& outputs, const TensorVector& inputs) const { outputs[0].set_shape(in_shape); using namespace ov::element; - return IfTypeOf::apply(inputs[0].get_element_type(), - inputs[0], - outputs[0], - shape_size(in_shape)); + return IF_TYPE_OF(v0_Relu_evaluate, + OV_PP_ET_LIST(f16, f32, i32, i64, u32, u64), + relu::Evaluate, + inputs[0].get_element_type(), + inputs[0], + outputs[0], + shape_size(in_shape)); } bool Relu::has_evaluate() const { diff --git a/src/core/src/op/result.cpp b/src/core/src/op/result.cpp index 3f0b538af89fd0..6fa49a40d9ed42 100644 --- a/src/core/src/op/result.cpp +++ b/src/core/src/op/result.cpp @@ -49,9 +49,15 @@ bool Result::evaluate(TensorVector& outputs, const TensorVector& inputs) const { } outputs[0].set_shape(inputs[0].get_shape()); - void* output = outputs[0].data(); - const void* input = inputs[0].data(); - memcpy(output, input, outputs[0].get_byte_size()); + if (inputs[0].get_element_type() == element::string) { + // memcpy for element::string Tensor does not work because output elements + // will refer to input string elements but they must be separate objects in memory + inputs[0].copy_to(outputs[0]); + } else { + void* output = outputs[0].data(); + const void* input = inputs[0].data(); + memcpy(output, input, outputs[0].get_byte_size()); + } return true; } diff --git a/src/core/src/op/round.cpp b/src/core/src/op/round.cpp index 16643086e715d4..24adc7e9bfe469 100644 --- a/src/core/src/op/round.cpp +++ b/src/core/src/op/round.cpp @@ -59,12 +59,14 @@ bool Round::evaluate(TensorVector& outputs, const TensorVector& inputs) const { auto& out = outputs.front(); using namespace ov::element; - return IfTypeOf::apply( - arg0.get_element_type(), - arg0, - out, - shape_size(arg0.get_shape()), - get_mode()); + return IF_TYPE_OF(v5_Round_evaluate, + OV_PP_ET_LIST(boolean, i8, i16, i32, i64, u8, u16, u32, u64, bf16, f16, f32), + round::Evaluate, + arg0.get_element_type(), + arg0, + out, + shape_size(arg0.get_shape()), + get_mode()); } bool Round::has_evaluate() const { diff --git a/src/core/src/op/scatter_elements_update.cpp b/src/core/src/op/scatter_elements_update.cpp index c9dabd1a91d8e9..2cec3ff0762c8a 100644 --- a/src/core/src/op/scatter_elements_update.cpp +++ b/src/core/src/op/scatter_elements_update.cpp @@ -101,16 +101,19 @@ struct Evaluate : public element::NoAction { ) { using namespace ov::element; - return IfTypeOf::apply(indices.get_element_type(), - data.data(), - indices, - updates.data(), - output.data
(), - data_shape, - indices_shape, - axis, - reduction, - use_init_value); + return IF_TYPE_OF(scatter_el_update_idx_type, + OV_PP_ET_LIST(i8, i16, i32, i64, u8, u16, u32, u64), + EvaluateByIndicesType, + indices.get_element_type(), + data.data(), + indices, + updates.data(), + output.data
(), + data_shape, + indices_shape, + axis, + reduction, + use_init_value); } private: @@ -156,18 +159,21 @@ bool evaluate(TensorVector& outputs, const auto& data_shape = data.get_shape(); const auto& indices_shape = indices.get_shape(); output.set_shape(data_shape); + using namespace ov::element; - return IfTypeOf::apply( - data.get_element_type(), - data, - indices, - updates, - output, - data_shape, - indices_shape, - axis, - reduction, - use_init_value); + return IF_TYPE_OF(scatter_evaluate, + OV_PP_ET_LIST(boolean, f16, f32, i16, i32, i64, u32, u64), + scatter_elements_update::Evaluate, + data.get_element_type(), + data, + indices, + updates, + output, + data_shape, + indices_shape, + axis, + reduction, + use_init_value); } } // namespace } // namespace scatter_elements_update diff --git a/src/core/src/op/scatter_nd_update.cpp b/src/core/src/op/scatter_nd_update.cpp index 3ca0d83686a12d..e6d79f99366dfe 100644 --- a/src/core/src/op/scatter_nd_update.cpp +++ b/src/core/src/op/scatter_nd_update.cpp @@ -24,14 +24,17 @@ struct Evaluate : public element::NoAction { const Shape& indices_shape, const Shape& updates_shape) { using namespace ov::element; - return IfTypeOf::apply(indices.get_element_type(), - data.data(), - indices, - updates.data(), - output.data
(), - data_shape, - indices_shape, - updates_shape); + return IF_TYPE_OF(sctter_nd_eval_idx_type, + OV_PP_ET_LIST(i32, i64), + EvaluateByIndicesType, + indices.get_element_type(), + data.data(), + indices, + updates.data(), + output.data
(), + data_shape, + indices_shape, + updates_shape); } private: @@ -82,14 +85,17 @@ bool ScatterNDUpdate::evaluate(TensorVector& outputs, const TensorVector& inputs const auto& updates_shape = updates.get_shape(); output.set_shape(data_shape); using namespace ov::element; - return IfTypeOf::apply(data.get_element_type(), - data, - indices, - updates, - output, - data_shape, - indices_shape, - updates_shape); + return IF_TYPE_OF(v3_ScatterNDUpdate_evaluate, + OV_PP_ET_LIST(boolean, f16, f32, i32, i64, u32, u64), + scatter_nd_update::Evaluate, + data.get_element_type(), + data, + indices, + updates, + output, + data_shape, + indices_shape, + updates_shape); } bool ScatterNDUpdate::has_evaluate() const { diff --git a/src/core/src/op/select.cpp b/src/core/src/op/select.cpp index 719dd532f18ec3..eaad0378ac13a7 100644 --- a/src/core/src/op/select.cpp +++ b/src/core/src/op/select.cpp @@ -120,6 +120,15 @@ bool op::v1::Select::evaluate(const HostTensorVector& output_values, const HostT OPENVINO_ASSERT(validate_host_tensor_vector(output_values, 1)); OPENVINO_SUPPRESS_DEPRECATED_END const auto autob = get_auto_broadcast(); + + auto out_shape = shape_infer(this, + std::vector{input_values[0]->get_partial_shape(), + input_values[1]->get_partial_shape(), + input_values[2]->get_partial_shape()})[0] + .to_shape(); + + output_values[0]->set_shape(out_shape); + return detail::evaluate_select(output_values, input_values, autob, output_values[0]->get_element_type()); } diff --git a/src/core/src/op/shape_of.cpp b/src/core/src/op/shape_of.cpp index 9aa59e60dcef22..f50447238754a6 100644 --- a/src/core/src/op/shape_of.cpp +++ b/src/core/src/op/shape_of.cpp @@ -12,6 +12,7 @@ #include "openvino/op/constant.hpp" #include "openvino/op/select.hpp" #include "openvino/reference/shape_of.hpp" +#include "utils.hpp" namespace ov { namespace op { @@ -52,59 +53,55 @@ bool constant_fold_shape_of(Node* shape_of_node, Output& replacement, cons return false; } -bool evaluate_bound_shape(const Node* shape_of_node, TensorVector& output_values, bool is_upper) { - OPENVINO_ASSERT(shape_of_node, output_values.size() == 1); - const auto& input_partial_shape = shape_of_node->get_input_partial_shape(0); - if (input_partial_shape.rank().is_dynamic()) - return false; - const auto rank = input_partial_shape.rank().get_length(); - auto pshape_low = PartialShape::dynamic(rank), pshape_up = PartialShape::dynamic(rank); - for (Dimension::value_type i = 0; i < rank; ++i) { - Interval interval = input_partial_shape[i].get_interval(); - pshape_low[i] = interval.get_min_val(); - pshape_up[i] = Dimension(interval.get_max_val()).is_dynamic() ? Dimension(interval.get_max_val() - 1) - : interval.get_max_val(); - } - OPENVINO_ASSERT(pshape_up.is_static() && pshape_low.is_static()); - const auto output_et = output_values[0].get_element_type(); +bool evaluate_bound(const Node* const node, ov::TensorVector& outputs, const bool is_upper) { + OPENVINO_ASSERT(outputs.size() == 1); + const auto& in_shape = node->get_input_partial_shape(0); - if (pshape_low.to_shape() == pshape_up.to_shape()) { - shape_of::evaluate_shape_of(output_values[0], pshape_low.to_shape()); - } else { - auto&& upper = is_upper ? output_values : TensorVector{{output_et, Shape{pshape_up.to_shape().size()}}}; - shape_of::evaluate_shape_of(upper[0], pshape_up.to_shape()); + if (in_shape.rank().is_static()) { + const auto& out_et = outputs[0].get_element_type(); + auto eval_status = + shape_of::evaluate_shape_of(outputs[0], is_upper ? in_shape.get_max_shape() : in_shape.get_min_shape()); - auto&& lower = is_upper ? TensorVector{{output_et, Shape{pshape_low.to_shape().size()}}} : output_values; - shape_of::evaluate_shape_of(lower[0], pshape_low.to_shape()); + // use node output type as it can be different than output tensor type + // e.g. when v3::ShapeOf is converted to v0::ShapeOf then the output tensor will have always i64 + // but node output type is transferred from v3 and can be i32 (dimension inf bound is i32 max) + const auto is_out_type_i32 = node->get_output_element_type(0) == element::i32; + if (is_out_type_i32 || !is_upper) { + const auto in_shape_rank = in_shape.size(); + const auto max_et_val = is_out_type_i32 ? static_cast(std::numeric_limits::max()) + : std::numeric_limits::max(); - std::vector dynamic_mask; // true if dimension is dynamic - for (const auto& i : input_partial_shape) - dynamic_mask.push_back(static_cast(Dimension(i.get_interval().get_max_val()).is_dynamic())); + auto limit_val = is_upper ? max_et_val : static_cast(0); - const auto mask_const = Tensor(element::boolean, Shape{dynamic_mask.size()}, dynamic_mask.data()); + auto dynamic_mask = std::vector(in_shape_rank); + std::transform(in_shape.begin(), in_shape.end(), dynamic_mask.begin(), [&](const Dimension& d) { + return static_cast(d.get_interval().get_max_val() >= max_et_val); + }); - auto&& min = output_et == element::i64 ? static_cast(0) : static_cast(0); - auto&& max = - output_et == element::i64 ? std::numeric_limits::max() : std::numeric_limits::max(); - - v1::Select().evaluate(lower, {mask_const, {output_et, Shape{}, &min}, lower.front()}); - v1::Select().evaluate(upper, {mask_const, {output_et, Shape{}, &max}, upper.front()}); + const auto limit = Tensor(out_et, Shape{}, &limit_val); + const auto mask = Tensor(element::boolean, Shape{in_shape_rank}, dynamic_mask.data()); + eval_status = v1::Select().evaluate(outputs, {mask, limit, outputs[0]}); + } + return eval_status; + } else { + return false; } - return true; } bool evaluate_label(const Node* shape_of_node, TensorLabelVector& output_labels) { const auto& shape = shape_of_node->get_input_partial_shape(0); OPENVINO_ASSERT(shape.rank().is_static()); // sanity check. at this point value propagation was successful - output_labels[0].reserve(shape.size()); - bool label_is_set = false; + + auto common_label = ov::no_label; + auto& labels = output_labels[0]; + labels.reserve(shape.size()); + for (const auto& d : shape) { - const auto& label = DimensionTracker::get_label(d); - if (label) - label_is_set = true; - output_labels[0].push_back(label); + const auto label = ov::DimensionTracker::get_label(d); + labels.emplace_back(label); + common_label |= label; } - return label_is_set; + return common_label != ov::no_label; } } // namespace } // namespace shape_of @@ -157,12 +154,12 @@ bool ShapeOf::has_evaluate() const { } } -bool ShapeOf::evaluate_lower(TensorVector& output_values) const { - return shape_of::evaluate_bound_shape(this, output_values, false); +bool ShapeOf::evaluate_lower(ov::TensorVector& output_values) const { + return shape_of::evaluate_bound(this, output_values, false); } -bool ShapeOf::evaluate_upper(TensorVector& output_values) const { - return shape_of::evaluate_bound_shape(this, output_values, true); +bool ShapeOf::evaluate_upper(ov::TensorVector& output_values) const { + return shape_of::evaluate_bound(this, output_values, true); } bool ShapeOf::evaluate_label(TensorLabelVector& output_labels) const { @@ -231,12 +228,12 @@ bool ShapeOf::constant_fold(OutputVector& output_values, const OutputVector& inp return shape_of::constant_fold_shape_of(this, output_values[0], input_values[0]); } -bool ShapeOf::evaluate_lower(TensorVector& output_values) const { - return shape_of::evaluate_bound_shape(this, output_values, false); +bool ShapeOf::evaluate_lower(ov::TensorVector& output_values) const { + return shape_of::evaluate_bound(this, output_values, false); } -bool ShapeOf::evaluate_upper(TensorVector& output_values) const { - return shape_of::evaluate_bound_shape(this, output_values, true); +bool ShapeOf::evaluate_upper(ov::TensorVector& output_values) const { + return shape_of::evaluate_bound(this, output_values, true); } bool ShapeOf::evaluate_label(TensorLabelVector& output_labels) const { diff --git a/src/core/src/op/sigmoid.cpp b/src/core/src/op/sigmoid.cpp index a4ce31db1e3a97..abe6105b45ddcd 100644 --- a/src/core/src/op/sigmoid.cpp +++ b/src/core/src/op/sigmoid.cpp @@ -44,10 +44,13 @@ bool Sigmoid::evaluate(TensorVector& outputs, const TensorVector& inputs) const outputs[0].set_shape(in_shape); using namespace ov::element; - return IfTypeOf::apply(inputs[0].get_element_type(), - inputs[0], - outputs[0], - shape_size(in_shape)); + return IF_TYPE_OF(v0_Sigmoid_evaluate, + OV_PP_ET_LIST(f16, f32, i32, i64, u32, u64), + sigmoid::Evaluate, + inputs[0].get_element_type(), + inputs[0], + outputs[0], + shape_size(in_shape)); } bool Sigmoid::has_evaluate() const { diff --git a/src/core/src/op/sign.cpp b/src/core/src/op/sign.cpp index f22798bfcdc79f..10aafb5f29a1ae 100644 --- a/src/core/src/op/sign.cpp +++ b/src/core/src/op/sign.cpp @@ -43,10 +43,13 @@ bool Sign::evaluate(TensorVector& outputs, const TensorVector& inputs) const { outputs[0].set_shape(in_shape); using namespace ov::element; - return IfTypeOf::apply(inputs[0].get_element_type(), - inputs[0], - outputs[0], - shape_size(in_shape)); + return IF_TYPE_OF(v0_Sign_evaluate, + OV_PP_ET_LIST(f16, f32, i32, i64, u32, u64), + sign::Evaluate, + inputs[0].get_element_type(), + inputs[0], + outputs[0], + shape_size(in_shape)); } bool Sign::has_evaluate() const { diff --git a/src/core/src/op/sin.cpp b/src/core/src/op/sin.cpp index dc224ada7e071e..083b14645f2135 100644 --- a/src/core/src/op/sin.cpp +++ b/src/core/src/op/sin.cpp @@ -47,10 +47,13 @@ bool Sin::evaluate(TensorVector& outputs, const TensorVector& inputs) const { outputs[0].set_shape(inputs[0].get_shape()); using namespace ov::element; - return IfTypeOf::apply(inputs[0].get_element_type(), - inputs[0], - outputs[0], - shape_size(inputs[0].get_shape())); + return IF_TYPE_OF(v0_Sin_evaluate, + OV_PP_ET_LIST(f16, f32, i32, i64, u32, u64), + sin::Evaluate, + inputs[0].get_element_type(), + inputs[0], + outputs[0], + shape_size(inputs[0].get_shape())); } bool Sin::has_evaluate() const { diff --git a/src/core/src/op/sinh.cpp b/src/core/src/op/sinh.cpp index f678118a0fa429..43cf622afcf6c0 100644 --- a/src/core/src/op/sinh.cpp +++ b/src/core/src/op/sinh.cpp @@ -45,10 +45,13 @@ bool Sinh::evaluate(TensorVector& outputs, const TensorVector& inputs) const { outputs[0].set_shape(inputs[0].get_shape()); using namespace ov::element; - return IfTypeOf::apply(inputs[0].get_element_type(), - inputs[0], - outputs[0], - shape_size(inputs[0].get_shape())); + return IF_TYPE_OF(v0_Sinh_evaluate, + OV_PP_ET_LIST(f16, f32, i32, i64, u32, u64), + sinh::Evaluate, + inputs[0].get_element_type(), + inputs[0], + outputs[0], + shape_size(inputs[0].get_shape())); } bool Sinh::has_evaluate() const { diff --git a/src/core/src/op/softmax.cpp b/src/core/src/op/softmax.cpp index d2e1326d76c58b..5166a42446f74c 100644 --- a/src/core/src/op/softmax.cpp +++ b/src/core/src/op/softmax.cpp @@ -68,11 +68,14 @@ bool Softmax::evaluate(TensorVector& outputs, const TensorVector& inputs) const const auto& input_shape = inputs[0].get_shape(); outputs[0].set_shape(input_shape); using namespace ov::element; - return IfTypeOf::apply(inputs[0].get_element_type(), - inputs[0], - outputs[0], - input_shape, - AxisSet{m_axis}); + return IF_TYPE_OF(v1_Softmax_evaluate, + OV_PP_ET_LIST(bf16, f16, f32, f64), + softmax::Evaluate, + inputs[0].get_element_type(), + inputs[0], + outputs[0], + input_shape, + AxisSet{m_axis}); } bool Softmax::has_evaluate() const { @@ -140,11 +143,14 @@ bool Softmax::evaluate(TensorVector& outputs, const TensorVector& inputs) const outputs[0].set_shape(input_shape); using namespace ov::element; - return IfTypeOf::apply(inputs[0].get_element_type(), - inputs[0], - outputs[0], - input_shape, - AxisSet{axis}); + return IF_TYPE_OF(v8_Softmax_evaluate, + OV_PP_ET_LIST(bf16, f16, f32, f64), + softmax::Evaluate, + inputs[0].get_element_type(), + inputs[0], + outputs[0], + input_shape, + AxisSet{axis}); } bool Softmax::has_evaluate() const { diff --git a/src/core/src/op/softplus.cpp b/src/core/src/op/softplus.cpp index a5896c00795665..39fe5eb257c7f2 100644 --- a/src/core/src/op/softplus.cpp +++ b/src/core/src/op/softplus.cpp @@ -57,10 +57,13 @@ bool SoftPlus::evaluate(TensorVector& outputs, const TensorVector& inputs) const const auto count = shape_size(input_shape); outputs[0].set_shape(input_shape); using namespace ov::element; - return IfTypeOf::apply(inputs[0].get_element_type(), - inputs[0], - outputs[0], - count); + return IF_TYPE_OF(v4_SoftPlus_evaluate, + OV_PP_ET_LIST(bf16, f16, f32), + softplus::Evaluate, + inputs[0].get_element_type(), + inputs[0], + outputs[0], + count); } bool SoftPlus::has_evaluate() const { diff --git a/src/core/src/op/softsign.cpp b/src/core/src/op/softsign.cpp index 733b193b7248a4..37183363c78090 100644 --- a/src/core/src/op/softsign.cpp +++ b/src/core/src/op/softsign.cpp @@ -75,10 +75,13 @@ bool SoftSign::evaluate(TensorVector& outputs, const auto& input_shape = inputs[0].get_shape(); outputs[0].set_shape(input_shape); using namespace ov::element; - return IfTypeOf::apply(inputs[0].get_element_type(), - inputs[0], - outputs[0], - shape_size(input_shape)); + return IF_TYPE_OF(v9_SoftSign_evaluate, + OV_PP_ET_LIST(bf16, f16, f32, f64), + softsign::Evaluate, + inputs[0].get_element_type(), + inputs[0], + outputs[0], + shape_size(input_shape)); } } // namespace v9 } // namespace op diff --git a/src/core/src/op/sqrt.cpp b/src/core/src/op/sqrt.cpp index 0c05c6833bfcf0..1a8c7501d7c2f9 100644 --- a/src/core/src/op/sqrt.cpp +++ b/src/core/src/op/sqrt.cpp @@ -41,10 +41,13 @@ bool Sqrt::evaluate(TensorVector& outputs, const TensorVector& inputs) const { const auto& in_shape = inputs[0].get_shape(); outputs[0].set_shape(in_shape); using namespace ov::element; - return IfTypeOf::apply(inputs[0].get_element_type(), - inputs[0], - outputs[0], - shape_size(in_shape)); + return IF_TYPE_OF(v0_Sqrt_evaluate, + OV_PP_ET_LIST(f16, f32, f64, i32, i64, u32, u64), + sqrt::Evaluate, + inputs[0].get_element_type(), + inputs[0], + outputs[0], + shape_size(in_shape)); } bool Sqrt::has_evaluate() const { diff --git a/src/core/src/op/subtract.cpp b/src/core/src/op/subtract.cpp index 6b21fa00483b78..22de7fa20bfaff 100644 --- a/src/core/src/op/subtract.cpp +++ b/src/core/src/op/subtract.cpp @@ -48,13 +48,16 @@ bool Subtract::evaluate(TensorVector& outputs, const TensorVector& inputs) const outputs[0].set_shape(infer_broadcast_shape(this, inputs)); using namespace ov::element; - return IfTypeOf::apply(inputs[0].get_element_type(), - inputs[0], - inputs[1], - outputs[0], - inputs[0].get_shape(), - inputs[1].get_shape(), - get_autob()); + return IF_TYPE_OF(v1_Subtract_evaluate, + OV_PP_ET_LIST(bf16, f16, f32, i8, i32, i64, u8, u32, u64), + subtract::Evaluate, + inputs[0].get_element_type(), + inputs[0], + inputs[1], + outputs[0], + inputs[0].get_shape(), + inputs[1].get_shape(), + get_autob()); } bool Subtract::has_evaluate() const { diff --git a/src/core/src/op/swish.cpp b/src/core/src/op/swish.cpp index ccc3d82b682137..448aaa67e51274 100644 --- a/src/core/src/op/swish.cpp +++ b/src/core/src/op/swish.cpp @@ -88,11 +88,14 @@ bool Swish::evaluate(TensorVector& outputs, const TensorVector& inputs) const { const auto& arg1 = inputs.size() == 2 ? inputs[1] : Tensor(); using namespace ov::element; - return IfTypeOf::apply(inputs[0].get_element_type(), - inputs[0], - arg1, - outputs[0], - shape_size(inputs[0].get_shape())); + return IF_TYPE_OF(v4_Swish_evaluate, + OV_PP_ET_LIST(f16, f32), + swish::Evaluate, + inputs[0].get_element_type(), + inputs[0], + arg1, + outputs[0], + shape_size(inputs[0].get_shape())); } bool Swish::has_evaluate() const { diff --git a/src/core/src/op/tan.cpp b/src/core/src/op/tan.cpp index 5fac393b36010f..2d3f2b5fa1e89d 100644 --- a/src/core/src/op/tan.cpp +++ b/src/core/src/op/tan.cpp @@ -45,10 +45,13 @@ bool Tan::evaluate(TensorVector& outputs, const TensorVector& inputs) const { outputs[0].set_shape(inputs[0].get_shape()); using namespace ov::element; - return IfTypeOf::apply(inputs[0].get_element_type(), - inputs[0], - outputs[0], - shape_size(inputs[0].get_shape())); + return IF_TYPE_OF(v0_Tan_evaluate, + OV_PP_ET_LIST(f16, f32, i32, i64, u32, u64), + tan::Evaluate, + inputs[0].get_element_type(), + inputs[0], + outputs[0], + shape_size(inputs[0].get_shape())); } bool Tan::has_evaluate() const { diff --git a/src/core/src/op/tanh.cpp b/src/core/src/op/tanh.cpp index 6be5ef3e2bf5ce..26613d6818a281 100644 --- a/src/core/src/op/tanh.cpp +++ b/src/core/src/op/tanh.cpp @@ -46,10 +46,13 @@ bool Tanh::evaluate(TensorVector& outputs, const TensorVector& inputs) const { outputs[0].set_shape(inputs[0].get_shape()); using namespace ov::element; - return IfTypeOf::apply(inputs[0].get_element_type(), - inputs[0], - outputs[0], - shape_size(inputs[0].get_shape())); + return IF_TYPE_OF(v0_Tanh_evaluate, + OV_PP_ET_LIST(f16, f32, i32, i64, u32, u64), + tanh::Evaluate, + inputs[0].get_element_type(), + inputs[0], + outputs[0], + shape_size(inputs[0].get_shape())); } bool Tanh::has_evaluate() const { diff --git a/src/core/src/op/topk.cpp b/src/core/src/op/topk.cpp index a84d0490d9bebd..3d11e5967d240a 100644 --- a/src/core/src/op/topk.cpp +++ b/src/core/src/op/topk.cpp @@ -59,16 +59,19 @@ struct Evaluate : public element::NoAction { const bool compute_max, const TopKSortType sort) { using namespace ov::element; - return IfTypeOf::apply(out_indices.get_element_type(), - in.data(), - out_values.data(), - out_indices, - in.get_shape(), - out_shape, - axis, - out_shape[axis], - compute_max, - sort); + return IF_TYPE_OF(topk_eval_by_idx_type, + OV_PP_ET_LIST(i32, i64), + EvalByIdxType, + out_indices.get_element_type(), + in.data(), + out_values.data(), + out_indices, + in.get_shape(), + out_shape, + axis, + out_shape[axis], + compute_max, + sort); } private: @@ -116,14 +119,17 @@ bool evaluate(const util::TopKBase* const node, TensorVector& outputs, const Ten } using namespace ov::element; - return IfTypeOf::apply(inputs[0].get_element_type(), - inputs[0], - outputs[0], - outputs[1], - output_shape, - axis, - (node->get_mode() == ov::op::TopKMode::MAX), - node->get_sort_type()); + return IF_TYPE_OF(topk_evaluate, + OV_PP_ET_LIST(f16, f32, i32, i64, u32, u64), + topk::Evaluate, + inputs[0].get_element_type(), + inputs[0], + outputs[0], + outputs[1], + output_shape, + axis, + (node->get_mode() == ov::op::TopKMode::MAX), + node->get_sort_type()); } } // namespace } // namespace topk diff --git a/src/core/src/op/util/gather_base.cpp b/src/core/src/op/util/gather_base.cpp index be0d0158dce9fd..6d6f338bb50b7e 100644 --- a/src/core/src/op/util/gather_base.cpp +++ b/src/core/src/op/util/gather_base.cpp @@ -5,145 +5,40 @@ #include "openvino/op/util/gather_base.hpp" #include "bound_evaluate.hpp" +#include "element_visitor.hpp" #include "gather_shape_inference.hpp" #include "itt.hpp" -#include "ngraph/validation_util.hpp" #include "openvino/op/concat.hpp" #include "openvino/op/constant.hpp" #include "openvino/op/squeeze.hpp" #include "openvino/reference/gather.hpp" +#include "validation_util.hpp" -ov::op::util::GatherBase::GatherBase(const Output& data, - const Output& indices, - const Output& axis, - const int64_t batch_dims) - : Op({data, indices, axis}), - m_batch_dims(batch_dims) { - constructor_validate_and_infer_types(); -} - -void ov::op::util::GatherBase::validate_and_infer_types() { - OV_OP_SCOPE(util_GatherBase_validate_and_infer_types); - const auto& data_type = get_input_element_type(0); - - const auto& data_pshape = get_input_partial_shape(0); - const auto& indices_pshape = get_input_partial_shape(1); - const auto& axis_pshape = get_input_partial_shape(2); - std::vector input_shapes = {data_pshape, indices_pshape, axis_pshape}; - const auto output_shapes = shape_infer(this, input_shapes); - set_output_type(0, data_type, output_shapes[0]); -} - -int64_t ov::op::util::GatherBase::get_axis() const { - OPENVINO_SUPPRESS_DEPRECATED_START - const auto& const_op = get_constant_from_source(input_value(2)); - OPENVINO_SUPPRESS_DEPRECATED_END - OPENVINO_ASSERT(const_op, "axis value is not set"); - - int64_t axis = const_op->cast_vector()[0]; - if (axis < 0) { - const auto& data_rank = get_input_partial_shape(0).rank(); - if (data_rank.is_static()) { - axis += data_rank.get_length(); - } - } - return axis; -} - -const int64_t& ov::op::util::GatherBase::get_batch_dims() const { - return m_batch_dims; -} - -void ov::op::util::GatherBase::set_batch_dims(int64_t batch_dims) { - m_batch_dims = batch_dims; -} - -OPENVINO_SUPPRESS_DEPRECATED_START +namespace ov { +namespace op { namespace gather { namespace { -template -bool evaluate(const ngraph::HostTensorPtr& arg0, - const ngraph::HostTensorPtr& arg1, - const ngraph::HostTensorPtr& out, - int64_t axis, - int64_t batch_dims) { - using T = typename ov::element_type_traits::value_type; - ov::Shape params_shape = arg0->get_shape(); - ov::Shape indices_shape = arg1->get_shape(); - ov::Shape out_shape(params_shape.size() + indices_shape.size() - 1 - batch_dims); - int64_t i = 0; - for (; i < axis; i++) { - out_shape[i] = params_shape[i]; - } - for (int64_t j = batch_dims; j < static_cast(indices_shape.size()); i++, j++) { - out_shape[i] = indices_shape[j]; - } - for (int64_t j = axis + 1; j < static_cast(params_shape.size()); i++, j++) { - out_shape[i] = params_shape[j]; - } - - out->set_shape(out_shape); - - if (arg1->get_element_type() == ov::element::i64) { - ov::reference::gather(arg0->get_data_ptr(), - arg1->get_data_ptr(), - out->get_data_ptr(), - arg0->get_shape(), - arg1->get_shape(), - out->get_shape(), - axis, - batch_dims); - } else if (arg1->get_element_type() == ov::element::i32) { - ov::reference::gather(arg0->get_data_ptr(), - arg1->get_data_ptr(), - out->get_data_ptr(), - arg0->get_shape(), - arg1->get_shape(), - out->get_shape(), - axis, - batch_dims); - } else { - OPENVINO_THROW("Unexpected type ", arg1->get_element_type().c_type_string(), " for Gather evaluate method."); - } - return true; -} +Shape out_shape_infer(const Shape& data_shape, const Shape& indices_shape, int64_t axis, int64_t batch_dims) { + Shape out_shape; + out_shape.reserve(data_shape.size() + indices_shape.size() - 1 - batch_dims); + auto out_dim_inserter = std::copy_n(data_shape.begin(), axis, std::back_inserter(out_shape)); + out_dim_inserter = std::copy(indices_shape.begin() + batch_dims, indices_shape.end(), out_dim_inserter); + std::copy(std::next(data_shape.begin(), axis + 1), data_shape.end(), out_dim_inserter); -bool evaluate_gather(const ngraph::HostTensorPtr& arg0, - const ngraph::HostTensorPtr& arg1, - const ngraph::HostTensorPtr& out, - int64_t axis, - int64_t batch_dims = 0) { - bool rc = true; - - using ov::element::Type_t; - switch (out->get_element_type()) { - OPENVINO_TYPE_CASE(evaluate_gather, i32, arg0, arg1, out, axis, batch_dims); - OPENVINO_TYPE_CASE(evaluate_gather, i64, arg0, arg1, out, axis, batch_dims); - OPENVINO_TYPE_CASE(evaluate_gather, i8, arg0, arg1, out, axis, batch_dims); - OPENVINO_TYPE_CASE(evaluate_gather, u8, arg0, arg1, out, axis, batch_dims); - OPENVINO_TYPE_CASE(evaluate_gather, u32, arg0, arg1, out, axis, batch_dims); - OPENVINO_TYPE_CASE(evaluate_gather, u64, arg0, arg1, out, axis, batch_dims); - OPENVINO_TYPE_CASE(evaluate_gather, f16, arg0, arg1, out, axis, batch_dims); - OPENVINO_TYPE_CASE(evaluate_gather, f32, arg0, arg1, out, axis, batch_dims); - OPENVINO_TYPE_CASE(evaluate_gather, boolean, arg0, arg1, out, axis, batch_dims); - default: - rc = false; - break; - } - return rc; + return out_shape; } -bool cf_gather_with_subgraph(ov::OutputVector& output_values, - const ov::OutputVector& input_values, - const ov::PartialShape& gather_ps) { +bool cf_gather_with_subgraph(OutputVector& output_values, + const OutputVector& input_values, + const PartialShape& gather_ps) { if (gather_ps.is_dynamic() || input_values.size() != 3) { return false; } - const auto concat = std::dynamic_pointer_cast(input_values[0].get_node_shared_ptr()); - const auto indices = std::dynamic_pointer_cast(input_values[1].get_node_shared_ptr()); - const auto axis = std::dynamic_pointer_cast(input_values[2].get_node_shared_ptr()); + const auto concat = std::dynamic_pointer_cast(input_values[0].get_node_shared_ptr()); + const auto indices = std::dynamic_pointer_cast(input_values[1].get_node_shared_ptr()); + const auto axis = std::dynamic_pointer_cast(input_values[2].get_node_shared_ptr()); if (!concat || !indices || !axis) { return false; @@ -169,8 +64,8 @@ bool cf_gather_with_subgraph(ov::OutputVector& output_values, } const int64_t rank = concat->get_shape()[0]; - const int64_t raw_index = indices->cast_vector()[0]; - const int64_t positive_index = raw_index < 0 ? rank + raw_index : raw_index; + const auto raw_index = indices->cast_vector()[0]; + const auto positive_index = ov::util::normalize(raw_index, rank); OPENVINO_ASSERT(positive_index >= 0 && positive_index < rank); // gather takes exactly one element out of the Concat output @@ -179,88 +74,164 @@ bool cf_gather_with_subgraph(ov::OutputVector& output_values, auto gathered = gathered_concat_input; if (indices_shape.empty()) { // gathering a scalar - const auto axis_const = ov::op::v0::Constant::create(ov::element::i64, ov::Shape{1}, {0}); - gathered = std::make_shared(gathered_concat_input, axis_const); + const auto axis_const = v0::Constant::create(element::i64, Shape{1}, {0}); + gathered = std::make_shared(gathered_concat_input, axis_const); } output_values[0] = gathered; return true; } + +bool have_indices_and_axis_bound_set(const util::GatherBase* const gather) { + return ov::have_node_inputs_bounds_set(gather, 1, 2); +} } // namespace + +struct Evaluate : element::NoAction { + using element::NoAction::visit; + + template > + static result_type visit(const Tensor& data, + const Tensor& indices, + Tensor& out, + const Shape& data_shape, + const Shape& indices_shape, + const Shape& out_shape, + const int64_t axis, + const int64_t batch_dims) { + using namespace ov::element; + return IF_TYPE_OF(util_GatherBase_indices_type, + OV_PP_ET_LIST(i32, i64), + EvaluateByIndicesType, + indices.get_element_type(), + data.data(), + indices, + out.data
(), + data_shape, + indices_shape, + out_shape, + axis, + batch_dims); + } + +private: + struct EvaluateByIndicesType : element::NoAction { + using element::NoAction::visit; + + template > + static result_type visit(const DT* const data, + const Tensor& indices, + DT* const output, + const Shape& data_shape, + const Shape& indices_shape, + const Shape& out_shape, + const int64_t axis, + const int64_t batch_dims) { + reference::gather(data, + indices.data(), + output, + data_shape, + indices_shape, + out_shape, + axis, + batch_dims); + return true; + } + }; +}; } // namespace gather -bool ov::op::util::GatherBase::evaluate(const HostTensorVector& outputs, const HostTensorVector& inputs) const { - OV_OP_SCOPE(util_GatherBase_evaluate); - OPENVINO_SUPPRESS_DEPRECATED_START - OPENVINO_ASSERT(ngraph::validate_host_tensor_vector(inputs, 3)); - OPENVINO_ASSERT(ngraph::validate_host_tensor_vector(outputs, 1)); - OPENVINO_SUPPRESS_DEPRECATED_END - int64_t axis = 0; - switch (inputs[2]->get_element_type()) { - case element::Type_t::i32: - axis = inputs[2]->get_data_ptr()[0]; - break; - case element::Type_t::i64: - axis = inputs[2]->get_data_ptr()[0]; - break; - case element::Type_t::i8: - axis = inputs[2]->get_data_ptr()[0]; - break; - case element::Type_t::i16: - axis = inputs[2]->get_data_ptr()[0]; - break; - case element::Type_t::u8: - axis = inputs[2]->get_data_ptr()[0]; - break; - case element::Type_t::u16: - axis = inputs[2]->get_data_ptr()[0]; - break; - case element::Type_t::u32: - axis = inputs[2]->get_data_ptr()[0]; - break; - case element::Type_t::u64: - axis = inputs[2]->get_data_ptr()[0]; - break; - default: - OPENVINO_THROW("axis must be of integral data type."); - } +namespace util { - if (axis < 0) { - const auto input_rank = inputs[0]->get_shape().size(); - axis += input_rank; - } +GatherBase::GatherBase(const Output& data, + const Output& indices, + const Output& axis, + const int64_t batch_dims) + : Op({data, indices, axis}), + m_batch_dims(batch_dims) { + constructor_validate_and_infer_types(); +} + +void GatherBase::validate_and_infer_types() { + OV_OP_SCOPE(util_GatherBase_validate_and_infer_types); + + const auto& data_type = get_input_element_type(0); + const auto output_shapes = shape_infer(this, ov::util::get_node_input_partial_shapes(*this)); + + set_output_type(0, data_type, output_shapes[0]); +} - int64_t batch_dims = m_batch_dims; - if (batch_dims < 0) { - const auto indices_rank = inputs[1]->get_shape().size(); - batch_dims += indices_rank; +int64_t GatherBase::get_axis() const { + const auto& const_op = ov::util::get_constant_from_source(input_value(2)); + OPENVINO_ASSERT(const_op, "axis value is not set"); + + const auto axis = const_op->cast_vector()[0]; + if (axis < 0 && get_input_partial_shape(0).rank().is_static()) { + return axis + get_input_partial_shape(0).rank().get_length(); + } else { + return axis; } +} - return gather::evaluate_gather(inputs[0], inputs[1], outputs[0], axis, batch_dims); +const int64_t& GatherBase::get_batch_dims() const { + return m_batch_dims; } -bool ov::op::util::GatherBase::evaluate_lower(ov::TensorVector& output_values) const { - if (!get_input_tensor(1).has_and_set_bound() || !get_input_tensor(2).has_and_set_bound()) - return false; - return default_lower_bound_evaluator(this, output_values); +void GatherBase::set_batch_dims(int64_t batch_dims) { + m_batch_dims = batch_dims; } -bool ov::op::util::GatherBase::evaluate_upper(ov::TensorVector& output_values) const { - if (!get_input_tensor(1).has_and_set_bound() || !get_input_tensor(2).has_and_set_bound()) - return false; - return default_upper_bound_evaluator(this, output_values); +bool GatherBase::evaluate(TensorVector& outputs, const TensorVector& inputs) const { + OV_OP_SCOPE(util_GatherBase_evaluate); + + OPENVINO_ASSERT(outputs.size() == 1); + OPENVINO_ASSERT(inputs.size() == 3); + + OPENVINO_ASSERT(inputs[2].get_element_type().is_integral_number(), "axis must be of integral data type."); + + const auto& data = inputs[0]; + const auto& data_shape = data.get_shape(); + const auto& indices = inputs[1]; + const auto& indices_shape = indices.get_shape(); + + const auto axis = ov::util::normalize(get_tensor_data_as(inputs[2])[0], data_shape.size()); + const auto batch_dims = ov::util::normalize(m_batch_dims, indices_shape.size()); + + const auto out_shape = gather::out_shape_infer(data_shape, indices_shape, axis, batch_dims); + auto& output = outputs[0]; + output.set_shape(out_shape); + + using namespace ov::element; + return IF_TYPE_OF(util_GatherBase_evaluate, + OV_PP_ET_LIST(boolean, f16, f32, i8, i32, i64, u8, u32, u64), + gather::Evaluate, + data.get_element_type(), + data, + indices, + output, + data_shape, + indices_shape, + out_shape, + axis, + batch_dims); } -bool ov::op::util::GatherBase::evaluate_label(TensorLabelVector& output_labels) const { - if (!get_input_tensor(1).has_and_set_bound() || !get_input_tensor(2).has_and_set_bound()) - return false; +bool GatherBase::evaluate_lower(TensorVector& output_values) const { + return gather::have_indices_and_axis_bound_set(this) && default_lower_bound_evaluator(this, output_values); +} + +bool GatherBase::evaluate_upper(TensorVector& output_values) const { + return gather::have_indices_and_axis_bound_set(this) && default_upper_bound_evaluator(this, output_values); +} + +bool GatherBase::evaluate_label(TensorLabelVector& output_labels) const { OPENVINO_SUPPRESS_DEPRECATED_START - return default_label_evaluator(this, output_labels); + return gather::have_indices_and_axis_bound_set(this) && default_label_evaluator(this, output_labels); OPENVINO_SUPPRESS_DEPRECATED_END } -bool ov::op::util::GatherBase::constant_fold(OutputVector& output_values, const OutputVector& input_values) { +bool GatherBase::constant_fold(OutputVector& output_values, const OutputVector& input_values) { // try the regular constant folding just for the Gather node if (Node::constant_fold(output_values, input_values)) { return true; @@ -268,3 +239,6 @@ bool ov::op::util::GatherBase::constant_fold(OutputVector& output_values, const return gather::cf_gather_with_subgraph(output_values, input_values, get_output_partial_shape(0)); } } +} // namespace util +} // namespace op +} // namespace ov diff --git a/src/core/src/op/util/variable_value.cpp b/src/core/src/op/util/variable_value.cpp index e1e434afc94b04..9de53857859f3b 100644 --- a/src/core/src/op/util/variable_value.cpp +++ b/src/core/src/op/util/variable_value.cpp @@ -35,13 +35,7 @@ class HostTensorWrapper : public ov::ITensor { HostTensorWrapper(const ngraph::HostTensorPtr& tensor) : tensor{tensor}, m_type(tensor->get_element_type()) { const auto& p_shape = tensor->get_partial_shape(); - if (p_shape.is_static()) { - m_shape = p_shape.to_shape(); - } else { - OPENVINO_SUPPRESS_DEPRECATED_START - m_shape = ov::util::make_dynamic_shape(); - OPENVINO_SUPPRESS_DEPRECATED_END - } + m_shape = p_shape.is_static() ? p_shape.to_shape() : ov::Shape{0}; update_strides(); } diff --git a/src/core/src/op/xor.cpp b/src/core/src/op/xor.cpp index c96599d9de3cef..df5286d72b6d73 100644 --- a/src/core/src/op/xor.cpp +++ b/src/core/src/op/xor.cpp @@ -45,13 +45,16 @@ bool evaluate(const Node* const op, TensorVector& outputs, const TensorVector& i outputs[0].set_shape(infer_broadcast_shape(op, inputs)); using namespace ov::element; - return IfTypeOf::apply(inputs[0].get_element_type(), - inputs[0], - inputs[1], - outputs[0], - inputs[0].get_shape(), - inputs[1].get_shape(), - op->get_autob()); + return IF_TYPE_OF(Xor_evaluate, + boolean, + logxor::Evaluate, + inputs[0].get_element_type(), + inputs[0], + inputs[1], + outputs[0], + inputs[0].get_shape(), + inputs[1].get_shape(), + op->get_autob()); } } // namespace } // namespace logxor diff --git a/src/core/src/pass/serialize.cpp b/src/core/src/pass/serialize.cpp index 29f037ad070b77..142fb71b345fdd 100644 --- a/src/core/src/pass/serialize.cpp +++ b/src/core/src/pass/serialize.cpp @@ -754,6 +754,8 @@ 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::string: + return "STRING"; default: OPENVINO_THROW("Unsupported precision: ", elem_type); } diff --git a/src/core/src/pass/visualize_tree.cpp b/src/core/src/pass/visualize_tree.cpp index 7e9192d4a1ac00..e981f7c4c95911 100644 --- a/src/core/src/pass/visualize_tree.cpp +++ b/src/core/src/pass/visualize_tree.cpp @@ -397,6 +397,9 @@ static std::string get_value(const std::shared_ptr& consta case ov::element::Type_t::u64: ss << pretty_value(constant->cast_vector(max_elements), allow_obfuscate); break; + case ov::element::Type_t::string: + ss << constant->get_output_element_type(0).get_type_name() << " value"; + break; } const auto num_elements_in_constant = static_cast(shape_size(constant->get_shape())); if (num_elements_in_constant == 0) diff --git a/src/core/src/runtime/itensor.cpp b/src/core/src/runtime/itensor.cpp index 2b3a6d49b84947..5068d94952649f 100644 --- a/src/core/src/runtime/itensor.cpp +++ b/src/core/src/runtime/itensor.cpp @@ -65,10 +65,10 @@ void ITensor::copy_to(const std::shared_ptr& dst) const { " != dst: ", dst->get_element_type(), ")"); - OPENVINO_SUPPRESS_DEPRECATED_START - if (dst->get_shape() == ov::Shape{0} || ov::util::is_dynamic_shape(dst->get_shape())) + + if (dst->get_shape() == ov::Shape{0}) dst->set_shape(get_shape()); - OPENVINO_SUPPRESS_DEPRECATED_END + OPENVINO_ASSERT(shapes_equal(get_shape(), dst->get_shape()), "Tensor shapes are not equal. (src: ", get_shape(), @@ -158,9 +158,24 @@ void ITensor::copy_to(const std::shared_ptr& dst) const { return offset; }; + using copy_function_def = std::function; + copy_function_def memcpy_based_copy = [](const uint8_t* src_data, uint8_t* dst_data, size_t bytes_size) { + memcpy(dst_data, src_data, bytes_size); + }; + copy_function_def strings_copy = [](const uint8_t* src_data, uint8_t* dst_data, size_t bytes_size) { + // in case string tensors, it needs to copy of new values for std::string objects + // memcpy is not suitable + auto dst_string = reinterpret_cast(dst_data); + auto src_string = reinterpret_cast(src_data); + size_t num_elements_stride = bytes_size / element::string.size(); + std::copy_n(src_string, num_elements_stride, dst_string); + }; + copy_function_def copy_function = (get_element_type() == element::string) ? strings_copy : memcpy_based_copy; + bool finish = false; for (size_t dst_idx = 0, src_idx = 0; !finish;) { - memcpy(dst_data + dst_idx, src_data + src_idx, src_strides[src_strides.size() - 1]); + copy_function(src_data + src_idx, dst_data + dst_idx, src_strides[src_strides.size() - 1]); + // update indexes for (size_t i = 0; i < cur_pos.size(); i++) { size_t inverted_idx = cur_pos.size() - i - 1; diff --git a/src/core/src/runtime/string_aligned_buffer.cpp b/src/core/src/runtime/string_aligned_buffer.cpp new file mode 100644 index 00000000000000..1410dbd6dc6fbf --- /dev/null +++ b/src/core/src/runtime/string_aligned_buffer.cpp @@ -0,0 +1,32 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "openvino/runtime/string_aligned_buffer.hpp" + +#include "openvino/runtime/aligned_buffer.hpp" + +namespace ov { +StringAlignedBuffer::StringAlignedBuffer(size_t num_elements, size_t byte_size, size_t alignment, bool initialize) + : AlignedBuffer(byte_size, alignment), + m_num_elements(num_elements) { + OPENVINO_ASSERT(sizeof(std::string) * num_elements <= byte_size + alignment, + "Allocated memory of size " + std::to_string(byte_size) + " bytes is not enough to store " + + std::to_string(num_elements) + " std::string objects"); + if (initialize) { + auto strings = reinterpret_cast(m_aligned_buffer); + std::uninitialized_fill_n(strings, m_num_elements, std::string()); + } +} + +StringAlignedBuffer::~StringAlignedBuffer() { + if (m_aligned_buffer) { + auto strings = reinterpret_cast(m_aligned_buffer); + for (size_t ind = 0; ind < m_num_elements; ++ind) { + using std::string; + strings[ind].~string(); + } + } +} + +} // namespace ov diff --git a/src/core/src/shape_util.cpp b/src/core/src/shape_util.cpp index 72c72c39b68d4f..1d6b8e1c49d165 100644 --- a/src/core/src/shape_util.cpp +++ b/src/core/src/shape_util.cpp @@ -103,16 +103,6 @@ TContainer replace_container(const TContainer& input, const TAxes& axes) { } namespace util { -Shape make_dynamic_shape() { - return Shape{0, std::numeric_limits::max()}; -} - -bool is_dynamic_shape(const Shape& s) { - OPENVINO_SUPPRESS_DEPRECATED_START - static const auto dyn_shape = make_dynamic_shape(); - OPENVINO_SUPPRESS_DEPRECATED_END - return s == dyn_shape; -} Shape reduce(const Shape& input, const AxisSet& axes) { return ov::reduce_container(input, axes); diff --git a/src/core/src/tensor_conversion_util.cpp b/src/core/src/tensor_conversion_util.cpp deleted file mode 100644 index 4e0c40d3f21aa2..00000000000000 --- a/src/core/src/tensor_conversion_util.cpp +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "tensor_conversion_util.hpp" - -#include "openvino/core/shape_util.hpp" - -namespace ov { -namespace util { -OPENVINO_SUPPRESS_DEPRECATED_START -Tensor wrap_tensor(const ngraph::HostTensorPtr& t) { - const auto& et = t->get_element_type(); - const auto& p_shape = t->get_partial_shape(); - - if (et.is_dynamic() || et == element::undefined) { - return {}; - } else if (p_shape.is_static()) { - return {et, p_shape.to_shape(), t->get_data_ptr()}; - } else { - return {et, make_dynamic_shape()}; - } -} - -Tensor wrap_tensor(const Output& output) { - const auto& et = output.get_element_type(); - const auto& p_shape = output.get_partial_shape(); - - if (et.is_dynamic() || et == element::undefined) { - return {}; - } else if (p_shape.is_static()) { - return {et, p_shape.to_shape()}; - } else { - return {et, make_dynamic_shape()}; - } -} - -ov::TensorVector wrap_tensors(const std::vector& tensors) { - ov::TensorVector out; - out.reserve(tensors.size()); - for (const auto& ht : tensors) { - out.push_back(ov::util::wrap_tensor(ht)); - } - return out; -} - -void update_output_host_tensors(const std::vector& output_values, - const ov::TensorVector& outputs) { - OPENVINO_ASSERT(output_values.size() == outputs.size()); - for (size_t i = 0; i < output_values.size(); ++i) { - auto& ht = output_values[i]; - auto& t = outputs[i]; - if (ht->get_partial_shape().is_dynamic()) { - ht->set_element_type(t.get_element_type()); - ht->set_shape(t.get_shape()); - std::memcpy(ht->get_data_ptr(), t.data(), t.get_byte_size()); - } - } -} -OPENVINO_SUPPRESS_DEPRECATED_END -} // namespace util -} // namespace ov diff --git a/src/core/src/type/element_type.cpp b/src/core/src/type/element_type.cpp index e7cf311c857836..e5607e6a60a4de 100644 --- a/src/core/src/type/element_type.cpp +++ b/src/core/src/type/element_type.cpp @@ -71,6 +71,8 @@ inline TypeInfo get_type_info(ov::element::Type_t type) { return {64, false, false, false, "uint64_t", "u64"}; case ov::element::Type_t::nf4: return {4, false, false, true, "nfloat4", "nf4"}; + case ov::element::Type_t::string: + return {8 * sizeof(std::string), false, false, false, "string", "string"}; default: OPENVINO_THROW("ov::element::Type_t not supported: ", type); } @@ -109,6 +111,8 @@ ov::element::Type type_from_string(const std::string& type) { return ::ov::element::Type(::ov::element::Type_t::u64); } else if (type == "boolean" || type == "BOOL") { return ::ov::element::Type(::ov::element::Type_t::boolean); + } else if (type == "string" || type == "STRING") { + return ::ov::element::Type(::ov::element::Type_t::string); } else if (type == "undefined" || type == "UNSPECIFIED") { return ::ov::element::Type(::ov::element::Type_t::undefined); } else if (type == "dynamic") { @@ -138,7 +142,8 @@ std::vector ov::element::Type::get_known_types() { &ov::element::u8, &ov::element::u16, &ov::element::u32, - &ov::element::u64}; + &ov::element::u64, + &ov::element::string}; return rc; } @@ -168,6 +173,7 @@ ov::element::Type::Type(size_t bitwidth, {ov::element::Type_t::u32, {32, false, false, false, "uint32_t", "u32"}}, {ov::element::Type_t::u64, {64, false, false, false, "uint64_t", "u64"}}, {ov::element::Type_t::u4, {4, false, false, false, "uint4_t", "nf4"}}, + {ov::element::Type_t::string, {8 * sizeof(std::string), false, false, false, "string", "string"}}, }; for (const auto& t : elements_map) { const TypeInfo& info = t.second; @@ -259,6 +265,10 @@ template <> Type from() { return Type_t::bf16; } +template <> +Type from() { + return Type_t::string; +} Type fundamental_type_for(const Type& type) { switch (type) { @@ -294,6 +304,8 @@ Type fundamental_type_for(const Type& type) { return from::value_type>(); case Type_t::u64: return from::value_type>(); + case Type_t::string: + return from::value_type>(); default: OPENVINO_THROW("Unsupported Data type: ", type); } @@ -325,6 +337,7 @@ std::istream& ov::element::operator>>(std::istream& in, ov::element::Type& obj) {"FP16", ov::element::f16}, {"BIN", ov::element::u1}, {"NF4", ov::element::nf4}, + {"STRING", ov::element::string}, }; std::string str; in >> str; @@ -407,6 +420,7 @@ inline size_t compiler_byte_size(ov::element::Type_t et) { ET_CASE(u32); ET_CASE(u64); ET_CASE(nf4); + ET_CASE(string); #undef ET_CASE case ov::element::Type_t::undefined: return 0; @@ -439,7 +453,8 @@ OPENVINO_API EnumNames& EnumNames::get() { {"u16", element::Type_t::u16}, {"u32", element::Type_t::u32}, {"u64", element::Type_t::u64}, - {"nf4", element::Type_t::nf4}}); + {"nf4", element::Type_t::nf4}, + {"string", element::Type_t::string}}); return enum_names; } diff --git a/src/core/tests/constant.cpp b/src/core/tests/constant.cpp index b6cffdc31f1799..1481f94f0e8053 100644 --- a/src/core/tests/constant.cpp +++ b/src/core/tests/constant.cpp @@ -701,6 +701,29 @@ TEST(constant, int64_vector_broadcast) { EXPECT_EQ(p[3], 1); } +TEST(constant, int64_string_max) { + Shape shape{4}; + vector input{"9223372036854775807", "9223372036854775807", "9223372036854775807", "9223372036854775807"}; + + constexpr auto exp_value = std::numeric_limits::max(); + ov::op::v0::Constant c(element::i64, shape, input); + auto v = c.get_vector(); + ASSERT_EQ(v.size(), shape_size(shape)); + EXPECT_THAT(v, testing::Each(exp_value)); + + const auto p = c.get_data_ptr(); + EXPECT_EQ(p[0], exp_value); + EXPECT_EQ(p[1], exp_value); + EXPECT_EQ(p[2], exp_value); + EXPECT_EQ(p[3], exp_value); + + EXPECT_EQ(input, c.get_value_strings()); + + for (unsigned i = 0; i != input.size(); ++i) { + EXPECT_EQ(input[i], c.convert_value_to_string(i)); + } +} + // // uint1 // @@ -1184,6 +1207,31 @@ TEST(constant, uint64_vector_broadcast) { EXPECT_EQ(p[3], 1); } +TEST(constant, uint64_string_max) { + Shape shape{4}; + vector input{"18446744073709551615", + "18446744073709551615", + "18446744073709551615", + "18446744073709551615"}; + ov::op::v0::Constant c(element::u64, shape, input); + constexpr auto exp_value = std::numeric_limits::max(); + auto v = c.get_vector(); + ASSERT_EQ(v.size(), shape_size(shape)); + EXPECT_THAT(v, testing::Each(exp_value)); + + const auto p = c.get_data_ptr(); + EXPECT_EQ(p[0], exp_value); + EXPECT_EQ(p[1], exp_value); + EXPECT_EQ(p[2], exp_value); + EXPECT_EQ(p[3], exp_value); + + EXPECT_EQ(input, c.get_value_strings()); + + for (unsigned i = 0; i != input.size(); ++i) { + EXPECT_EQ(input[i], c.convert_value_to_string(i)); + } +} + // // bfloat16 // @@ -1351,6 +1399,60 @@ TEST(constant, shared_data) { EXPECT_EQ(p1, p2); } +// +// string +// + +TEST(constant, ov_string) { + Shape shape{4}; + vector input{"abc", "one two three", "1", "0"}; + ov::op::v0::Constant c(element::string, shape, input); + auto v = c.get_vector(); + ASSERT_EQ(v.size(), shape_size(shape)); + EXPECT_EQ(v[0], "abc"); + EXPECT_EQ(v[1], "one two three"); + EXPECT_EQ(v[2], "1"); + EXPECT_EQ(v[3], "0"); + + const std::string* p = c.get_data_ptr(); + EXPECT_EQ(p[0], "abc"); + EXPECT_EQ(p[1], "one two three"); + EXPECT_EQ(p[2], "1"); + EXPECT_EQ(p[3], "0"); + + EXPECT_EQ(input, c.get_value_strings()); + + for (unsigned i = 0; i != input.size(); ++i) { + EXPECT_EQ(input[i], c.convert_value_to_string(i)); + } +} + +TEST(constant, ov_string_broadcast) { + Shape shape{4}; + ov::op::v0::Constant c(element::string, shape, vector{"one two "}); + auto v = c.get_vector(); + ASSERT_EQ(v.size(), shape_size(shape)); + EXPECT_EQ(v[0], "one two "); + EXPECT_EQ(v[1], "one two "); + EXPECT_EQ(v[2], "one two "); + EXPECT_EQ(v[3], "one two "); + + const std::string* p = c.get_data_ptr(); + EXPECT_EQ(p[0], "one two "); + EXPECT_EQ(p[1], "one two "); + EXPECT_EQ(p[2], "one two "); + EXPECT_EQ(p[3], "one two "); +} + +TEST(constant, ov_string_shared_data) { + Shape shape{100, 200}; + auto c1 = make_shared(element::string, shape, vector{"123"}); + auto c2 = static_pointer_cast(c1->clone_with_new_inputs({})); + const int16_t* p1 = c1->get_data_ptr(); + const int16_t* p2 = c2->get_data_ptr(); + EXPECT_EQ(p1, p2); +} + template ::testing::AssertionResult test_convert() { Shape shape{5}; @@ -1363,6 +1465,15 @@ ::testing::AssertionResult test_convert() { return rc; } +TEST(constant, convert_input_ov_string) { + Shape shape{5}; + vector expected{"1", "2", "3", "4", "5"}; + auto c1 = make_shared(ov::element::from(), shape, expected); + vector actual = c1->template cast_vector(); + + EXPECT_EQ(actual, expected); +} + TEST(constant, convert_input) { EXPECT_TRUE((test_convert())); EXPECT_TRUE((test_convert())); @@ -1708,6 +1819,23 @@ TEST(constant, bad_get_data_ptr) { } } +TEST(constant, bad_get_data_ptr_ov_string) { + ov::op::v0::Constant c(element::string, Shape{}, vector{"abc"}); + EXPECT_EQ(*c.get_data_ptr(), "abc"); + try { + c.get_data_ptr(); + FAIL() << "Bad type not detected."; + } catch (const AssertFailure& error) { + EXPECT_HAS_SUBSTRING(error.what(), std::string("get_data_ptr")); + } + try { + c.get_data_ptr(); + FAIL() << "Bad type not detected."; + } catch (const AssertFailure& error) { + EXPECT_HAS_SUBSTRING(error.what(), std::string("get_data_ptr")); + } +} + TEST(constant, hold_tensor) { Shape shape{4}; void* hostDataPtr = nullptr; @@ -1721,6 +1849,19 @@ TEST(constant, hold_tensor) { ASSERT_EQ(constDataPtr, hostDataPtr); } +TEST(constant, hold_tensor_ov_string) { + Shape shape{4}; + void* hostDataPtr = nullptr; + std::shared_ptr constOp; + { + auto tensor = ov::Tensor(element::string, Shape{1, 2, 3, 3}); + hostDataPtr = tensor.data(); + constOp = std::make_shared(tensor); + } + const void* constDataPtr = constOp->get_data_ptr(); + ASSERT_EQ(constDataPtr, hostDataPtr); +} + // Test verifies 2 things: // a) Checks that bitwise comparison happens on first call of 'get_all_data_elements_bitwise_identical' // b) Next call of 'get_all_data_elements_bitwise_identical' takes already calculated value @@ -1820,6 +1961,29 @@ TEST(constant, cast_vector) { } } +TEST(constant, cast_vector_ov_string) { + element::Type_t type = element::string; + std::vector data = {"a", "b", "c", "d", "e", "f", "g", "h"}; + std::vector expected_partial_data = {"a", "b", "c", "d", "e", "f"}; + + const auto& constant = op::v0::Constant::create(type, Shape{data.size()}, data); + + const auto& default_casted = constant->cast_vector(); + EXPECT_EQ(default_casted, data) << "Constant::cast_vector failed default casting for type " << type; + + int64_t num_elements_for_partial_casting = static_cast(expected_partial_data.size()); + const auto& partially_casted = constant->cast_vector(num_elements_for_partial_casting); + EXPECT_EQ(partially_casted, expected_partial_data) + << "Constant::cast_vector failed partial casting for type " << type; + + int64_t num_elements_for_over_casting = static_cast(data.size()) + 10; + const auto& over_casted = constant->cast_vector(num_elements_for_over_casting); + EXPECT_EQ(over_casted, data) << "Constant::cast_vector failed for partial casting for type " << type; + + EXPECT_TRUE(constant->cast_vector(0).empty()) + << "Constant::cast_vector failed empty casting for type " << type; +} + TEST(constant, get_values_as) { ov::op::v0::Constant c(element::i64, Shape{6}, std::vector{2, -3, 1, 0, 1, 5}); diff --git a/src/core/tests/element_type.cpp b/src/core/tests/element_type.cpp index d0d416e3fd5d17..abf8b3f8aa7603 100644 --- a/src/core/tests/element_type.cpp +++ b/src/core/tests/element_type.cpp @@ -24,6 +24,7 @@ TEST(element_type, from) { EXPECT_EQ(element::from(), element::u16); EXPECT_EQ(element::from(), element::u32); EXPECT_EQ(element::from(), element::u64); + EXPECT_EQ(element::from(), element::string); } TEST(element_type, from_string) { @@ -66,6 +67,8 @@ TEST(element_type, from_string) { EXPECT_EQ(element::Type("U64"), element::u64); EXPECT_EQ(element::Type("nf4"), element::nf4); EXPECT_EQ(element::Type("NF4"), element::nf4); + EXPECT_EQ(element::Type("string"), element::string); + EXPECT_EQ(element::Type("STRING"), element::string); EXPECT_EQ(element::Type("undefined"), element::undefined); EXPECT_EQ(element::Type("UNSPECIFIED"), element::undefined); diff --git a/src/core/tests/frontend/CMakeLists.txt b/src/core/tests/frontend/CMakeLists.txt index dd096fed759a94..a03ed97cac9ca9 100644 --- a/src/core/tests/frontend/CMakeLists.txt +++ b/src/core/tests/frontend/CMakeLists.txt @@ -12,7 +12,7 @@ target_compile_definitions(${MOCK1_FE_NAME} PRIVATE "-DMOCK_VARIANT=\"1\"") target_include_directories(${MOCK1_FE_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) -target_link_libraries(${MOCK1_FE_NAME} PRIVATE frontend_common) +target_link_libraries(${MOCK1_FE_NAME} PRIVATE openvino::frontend::common) add_dependencies(ov_core_unit_tests ${MOCK1_FE_NAME}) ov_add_clang_format_target(${MOCK1_FE_NAME}_clang FOR_TARGETS ${MOCK1_FE_NAME}) diff --git a/src/core/tests/models/ir/string_parameter.bin b/src/core/tests/models/ir/string_parameter.bin new file mode 100644 index 00000000000000..e69de29bb2d1d6 diff --git a/src/core/tests/models/ir/string_parameter.xml b/src/core/tests/models/ir/string_parameter.xml new file mode 100644 index 00000000000000..bf93f6fc2917cc --- /dev/null +++ b/src/core/tests/models/ir/string_parameter.xml @@ -0,0 +1,26 @@ + + + + + + + + 1 + 3 + + + + + + + 1 + 3 + + + + + + + + + diff --git a/src/core/tests/ov_tensor_test.cpp b/src/core/tests/ov_tensor_test.cpp index 6a7eb090444043..891d26bba8f57d 100644 --- a/src/core/tests/ov_tensor_test.cpp +++ b/src/core/tests/ov_tensor_test.cpp @@ -23,6 +23,8 @@ using OVTensorTest = ::testing::Test; +const size_t string_size = ov::element::string.size(); + inline ov::Strides byteStrides(const ov::Strides& strides, const ov::element::Type& type) { ov::Strides byte_strides(strides.size()); for (size_t i = 0; i < strides.size(); ++i) @@ -45,6 +47,21 @@ TEST_F(OVTensorTest, canCreateTensor) { ASSERT_THROW(t.data(), ov::Exception); } +TEST_F(OVTensorTest, canCreateStringTensor) { + ov::Shape shape = {4, 3, 2}; + ov::Tensor t{ov::element::string, shape}; + const std::size_t totalSize = ov::shape_size(shape); + ASSERT_EQ(totalSize, t.get_size()); + ASSERT_NE(nullptr, t.data()); + ASSERT_EQ(ov::element::string, t.get_element_type()); + ASSERT_EQ(shape, t.get_shape()); + ASSERT_NE(shape, t.get_strides()); + ASSERT_EQ(byteStrides(ov::Strides({6, 2, 1}), t.get_element_type()), t.get_strides()); + ASSERT_EQ(string_size * totalSize, t.get_byte_size()); + ASSERT_THROW(t.data(ov::element::i64), ov::Exception); + ASSERT_THROW(t.data(), ov::Exception); +} + TEST_F(OVTensorTest, createTensorFromPort) { auto parameter1 = std::make_shared(ov::element::f64, ov::Shape{1, 3, 2, 2}); auto parameter2 = std::make_shared(ov::element::f32, ov::Shape{1, 3}); @@ -65,6 +82,27 @@ TEST_F(OVTensorTest, createTensorFromPort) { EXPECT_EQ(t4.get_element_type(), parameter3->get_element_type()); } +TEST_F(OVTensorTest, createStringTensorFromPort) { + auto parameter1 = std::make_shared(ov::element::string, ov::Shape{1, 3, 2, 2}); + auto parameter2 = std::make_shared(ov::element::string, ov::Shape{1, 3}); + auto parameter3 = std::make_shared(ov::element::string, ov::PartialShape::dynamic()); + + std::string data[] = {"one", "two sentence", "three 3 sentence"}; + ov::Tensor t1{parameter1->output(0)}; + ov::Tensor t2{parameter2->output(0), data}; + ov::Tensor t3{parameter3->output(0)}; + ov::Tensor t4{parameter3->output(0), data}; + + EXPECT_EQ(t1.get_shape(), parameter1->get_shape()); + EXPECT_EQ(t1.get_element_type(), parameter1->get_element_type()); + EXPECT_EQ(t2.get_shape(), parameter2->get_shape()); + EXPECT_EQ(t2.get_element_type(), parameter2->get_element_type()); + EXPECT_EQ(t3.get_shape(), ov::Shape{0}); + EXPECT_EQ(t3.get_element_type(), parameter3->get_element_type()); + EXPECT_EQ(t4.get_shape(), ov::Shape{0}); + EXPECT_EQ(t4.get_element_type(), parameter3->get_element_type()); +} + TEST_F(OVTensorTest, canAccessF16Tensor) { ov::Shape shape = {4, 3, 2}; ov::Tensor t{ov::element::f16, shape}; @@ -76,6 +114,24 @@ TEST_F(OVTensorTest, canAccessF16Tensor) { EXPECT_THROW(t.data(), ov::Exception); } +TEST_F(OVTensorTest, canAccessStringTensor) { + ov::Shape shape = {4, 3, 2}; + ov::Tensor t{ov::element::string, shape}; + EXPECT_NE(nullptr, t.data()); + EXPECT_NO_THROW(t.data(ov::element::string)); + EXPECT_NO_THROW(t.data()); + + // check that all elements of string ov::Tensor are empty strings + auto string_elements = t.data(); + auto num_elements = t.get_size(); + for (size_t ind = 0; ind < num_elements; ++ind) { + EXPECT_EQ(string_elements[ind], std::string()); + } + + EXPECT_THROW(t.data(), ov::Exception); + EXPECT_THROW(t.data(), ov::Exception); +} + TEST_F(OVTensorTest, canAccessU8Tensor) { ov::Shape shape = {4, 3, 2}; ov::Tensor t{ov::element::u8, shape}; @@ -96,6 +152,11 @@ TEST_F(OVTensorTest, emptySize) { ASSERT_NE(nullptr, t.data()); } +TEST_F(OVTensorTest, emptySizeStringTensor) { + ov::Tensor t(ov::element::string, {0}); + ASSERT_NE(nullptr, t.data()); +} + TEST_F(OVTensorTest, operators) { ov::Tensor t; ASSERT_FALSE(t); @@ -110,7 +171,6 @@ class OVMockAllocatorImpl : public ov::AllocatorImpl { MOCK_METHOD(bool, is_equal, (const ov::AllocatorImpl&), (const, noexcept)); // NOLINT(readability/casting) }; -OPENVINO_SUPPRESS_DEPRECATED_START TEST_F(OVTensorTest, canCreateTensorUsingMockAllocatorImpl) { ov::Shape shape = {1, 2, 3}; auto allocator = std::make_shared(); @@ -172,6 +232,22 @@ TEST_F(OVTensorTest, canAccessExternalData) { } } +TEST_F(OVTensorTest, canAccessExternalDataStringTensor) { + ov::Shape shape = {1, 1, 3}; + std::string data[] = {"one two three", "123", ""}; + ov::Tensor t{ov::element::string, shape, data}; + { + std::string* ptr = t.data(); + ASSERT_EQ(ptr[2], ""); + ASSERT_EQ(data, t.data(ov::element::string)); + ASSERT_EQ(data, ptr); + ASSERT_THROW(t.data(), ov::Exception); + ASSERT_EQ(byteStrides(ov::row_major_strides(shape), t.get_element_type()), t.get_strides()); + ASSERT_EQ(ov::shape_size(shape), t.get_size()); + ASSERT_EQ(ov::shape_size(shape) * string_size, t.get_byte_size()); + } +} + TEST_F(OVTensorTest, canAccessExternalDataWithStrides) { ov::Shape shape = {2, 3}; float data[] = {5.f, 6.f, 7.f, 0.f, 1.f, 42.f, 3.f, 0.f}; @@ -184,11 +260,29 @@ TEST_F(OVTensorTest, canAccessExternalDataWithStrides) { } } +TEST_F(OVTensorTest, canAccessExternalDataWithStridesStringTensor) { + ov::Shape shape = {2, 3}; + std::string data[] = {"abdcd efg hi", "01234", "xyz ", " ", "$%&%&& (*&&", "", "\n ", "\t "}; + ov::Strides strides = {shape[1] * string_size + string_size, string_size}; + ov::Tensor t{ov::element::string, shape, data, strides}; + ASSERT_EQ(strides, t.get_strides()); + { + ASSERT_EQ((ov::Shape{2, 3}), t.get_shape()); + const std::string* ptr = t.data(); + ASSERT_EQ(ptr[4], "$%&%&& (*&&"); + } +} + TEST_F(OVTensorTest, cannotCreateTensorWithExternalNullptr) { ov::Shape shape = {2, 3}; ASSERT_THROW(ov::Tensor(ov::element::f32, shape, nullptr), ov::Exception); } +TEST_F(OVTensorTest, cannotCreateStringTensorWithExternalNullptr) { + ov::Shape shape = {2, 3}; + ASSERT_THROW(ov::Tensor(ov::element::string, shape, nullptr), ov::Exception); +} + TEST_F(OVTensorTest, cannotCreateTensorWithWrongStrides) { ov::Shape shape = {2, 3}; float data[] = {5.f, 6.f, 7.f, 0.f, 1.f, 42.f, 3.f, 0.f}; @@ -212,6 +306,29 @@ TEST_F(OVTensorTest, cannotCreateTensorWithWrongStrides) { } } +TEST_F(OVTensorTest, cannotCreateStringTensorWithWrongStrides) { + ov::Shape shape = {2, 3}; + std::string data[] = {"abdcd efg hi", "01234", "xyz ", " ", "$%&%&& (*&&", "", "\n ", "\t "}; + const auto el = ov::element::string; + { + // strides.size() != shape.size() + EXPECT_THROW(ov::Tensor(el, shape, data, byteStrides({6, 3, 1}, el)), ov::Exception); + } + { + // strides values are element-wise >= ov::row_major_strides(shape) values + EXPECT_THROW(ov::Tensor(el, shape, data, byteStrides({2, 1}, el)), ov::Exception); + EXPECT_THROW(ov::Tensor(el, shape, data, byteStrides({3, 0}, el)), ov::Exception); + EXPECT_THROW(ov::Tensor(el, shape, data, byteStrides({3, 2}, el)), ov::Exception); + EXPECT_NO_THROW(ov::Tensor(el, shape, data, byteStrides({6, 2}, el))); + } + { + // strides are not divisible by elem_size + EXPECT_THROW(ov::Tensor(el, shape, data, {43, el.size()}), ov::Exception); + EXPECT_THROW(ov::Tensor(el, shape, data, {3, 0}), ov::Exception); + EXPECT_THROW(ov::Tensor(el, shape, data, {el.size(), 61}), ov::Exception); + } +} + TEST_F(OVTensorTest, saveDimsAndSizeAfterMove) { ov::Shape shape = {1, 2, 3}; ov::Tensor t{ov::element::f32, shape}; @@ -232,6 +349,26 @@ TEST_F(OVTensorTest, saveDimsAndSizeAfterMove) { ASSERT_THROW(t.data(), ov::Exception); } +TEST_F(OVTensorTest, saveDimsAndSizeAfterMoveStringTensor) { + ov::Shape shape = {1, 2, 3}; + ov::Tensor t{ov::element::string, shape}; + + ov::Tensor new_tensor(std::move(t)); + + ASSERT_EQ(shape, new_tensor.get_shape()); + ASSERT_EQ(ov::element::string, new_tensor.get_element_type()); + ASSERT_EQ(byteStrides(ov::row_major_strides(shape), new_tensor.get_element_type()), new_tensor.get_strides()); + + ASSERT_THROW(t.get_size(), ov::Exception); + ASSERT_THROW(t.get_element_type(), ov::Exception); + ASSERT_THROW(t.get_byte_size(), ov::Exception); + ASSERT_THROW(t.get_strides(), ov::Exception); + ASSERT_THROW(t.get_shape(), ov::Exception); + ASSERT_THROW(t.set_shape({}), ov::Exception); + ASSERT_THROW(t.data(), ov::Exception); + ASSERT_THROW(t.data(), ov::Exception); +} + // SetShape TEST_F(OVTensorTest, canSetShape) { const ov::Shape origShape({1, 2, 3}); @@ -262,6 +399,36 @@ TEST_F(OVTensorTest, canSetShape) { } } +TEST_F(OVTensorTest, canSetShapeStringTensor) { + const ov::Shape origShape({1, 2, 3}); + ov::Tensor t{ov::element::string, {1, 2, 3}}; + const ov::Shape newShape({4, 5, 6}); + + const void* orig_data = t.data(); + ASSERT_EQ(t.get_shape(), origShape); + ASSERT_NO_THROW(t.set_shape(newShape)); + ASSERT_EQ(newShape, t.get_shape()); + ASSERT_EQ(byteStrides(ov::row_major_strides(newShape), t.get_element_type()), t.get_strides()); + ASSERT_NE(orig_data, t.data()); + const void* new_data = t.data(); + + // check that setShape for copy changes original Tensor + { + ov::Tensor t2 = t; + ASSERT_NO_THROW(t2.set_shape(origShape)); + ASSERT_EQ(origShape, t2.get_shape()); + ASSERT_EQ(origShape, t.get_shape()); + ASSERT_EQ(t2.data(), t.data()); + } + + // set_shape for smaller memory - does not perform reallocation + { + ASSERT_NO_THROW(t.set_shape(origShape)); + ASSERT_EQ(origShape, t.get_shape()); + ASSERT_EQ(new_data, t.data()); + } +} + TEST_F(OVTensorTest, cannotSetShapeOfBiggerSizeOnPreallocatedMemory) { float data[4 * 5 * 6 * 2]; ov::Tensor t{ov::element::f32, {1, 2, 3}, data}; @@ -270,6 +437,14 @@ TEST_F(OVTensorTest, cannotSetShapeOfBiggerSizeOnPreallocatedMemory) { ASSERT_THROW(t.set_shape(newShape), ov::Exception); } +TEST_F(OVTensorTest, cannotSetShapeOfBiggerSizeOnPreallocatedMemoryStringTensor) { + std::string data[4 * 5 * 6]; + ov::Tensor t{ov::element::string, {1, 2, 3}, data}; + const ov::Shape newShape({4, 5, 6}); + + ASSERT_THROW(t.set_shape(newShape), ov::Exception); +} + TEST_F(OVTensorTest, canSetShapeOfSmallerSizeOnPreallocatedMemory) { float data[4 * 5 * 6 * 2]; ov::Tensor t{ov::element::f32, {4, 5, 6}, data}; @@ -278,6 +453,14 @@ TEST_F(OVTensorTest, canSetShapeOfSmallerSizeOnPreallocatedMemory) { ASSERT_NO_THROW(t.set_shape(newShape)); } +TEST_F(OVTensorTest, canSetShapeOfSmallerSizeOnPreallocatedMemoryStringTensor) { + std::string data[4 * 5 * 6]; + ov::Tensor t{ov::element::string, {4, 5, 6}, data}; + const ov::Shape newShape({1, 2, 3}); + + ASSERT_NO_THROW(t.set_shape(newShape)); +} + TEST_F(OVTensorTest, canSetShapeOfSameSizeOnPreallocatedMemory) { float data[4 * 5 * 6 * 2]; ov::Tensor t{ov::element::f32, {4, 5, 6}, data}; @@ -286,6 +469,14 @@ TEST_F(OVTensorTest, canSetShapeOfSameSizeOnPreallocatedMemory) { ASSERT_NO_THROW(t.set_shape(newShape)); } +TEST_F(OVTensorTest, canSetShapeOfSameSizeOnPreallocatedMemoryStringTensor) { + std::string data[4 * 5 * 6]; + ov::Tensor t{ov::element::string, {4, 5, 6}, data}; + const ov::Shape newShape({4, 5, 6}); + + ASSERT_NO_THROW(t.set_shape(newShape)); +} + TEST_F(OVTensorTest, canSetShapeOfOriginalSizeAfterDecreasingOnPreallocatedMemory) { float data[4 * 5 * 6 * 2]; ov::Tensor t{ov::element::f32, {4, 5, 6}, data}; @@ -296,6 +487,16 @@ TEST_F(OVTensorTest, canSetShapeOfOriginalSizeAfterDecreasingOnPreallocatedMemor ASSERT_NO_THROW(t.set_shape(originalShape)); } +TEST_F(OVTensorTest, canSetShapeOfOriginalSizeAfterDecreasingOnPreallocatedMemoryStringTensor) { + std::string data[4 * 5 * 6]; + ov::Tensor t{ov::element::string, {4, 5, 6}, data}; + const ov::Shape smallerShape({1, 2, 3}); + const ov::Shape originalShape({4, 5, 6}); + + ASSERT_NO_THROW(t.set_shape(smallerShape)); + ASSERT_NO_THROW(t.set_shape(originalShape)); +} + TEST_F(OVTensorTest, canChangeShapeOnStridedTensor) { float data[64 * 4]; ov::Tensor t{ov::element::f32, {4, 2, 2}, data, {64, 16, 4}}; @@ -306,6 +507,16 @@ TEST_F(OVTensorTest, canChangeShapeOnStridedTensor) { ASSERT_NO_THROW(t.set_shape(correct_shape)); } +TEST_F(OVTensorTest, canChangeShapeOnStridedTensorStringTensor) { + std::string data[64 * 4]; + ov::Tensor t{ov::element::string, {4, 2, 2}, data, {8 * string_size, 3 * string_size, string_size}}; + const ov::Shape incorrect_shape({2, 2, 4}); + const ov::Shape correct_shape({1, 1, 2}); + + ASSERT_THROW(t.set_shape(incorrect_shape), ov::Exception); + ASSERT_NO_THROW(t.set_shape(correct_shape)); +} + TEST_F(OVTensorTest, makeRangeRoiTensor) { ov::Tensor t{ov::element::i32, {1, 3, 6, 5}}; // RGBp picture of size (WxH) = 5x6 ov::Tensor roi_tensor{t, {0, 0, 1, 2}, {1, 3, 5, 4}}; @@ -321,6 +532,21 @@ TEST_F(OVTensorTest, makeRangeRoiTensor) { ASSERT_EQ(roi_tensor.get_element_type(), t.get_element_type()); } +TEST_F(OVTensorTest, makeRangeRoiStringTensor) { + ov::Tensor t{ov::element::string, {1, 3, 6, 5}}; // RGBp picture of size (WxH) = 5x6 + ov::Tensor roi_tensor{t, {0, 0, 1, 2}, {1, 3, 5, 4}}; + ov::Shape ref_shape = {1, 3, 4, 2}; + ptrdiff_t ref_offset_elems = 7; + ptrdiff_t ref_offset_bytes = ref_offset_elems * string_size; + ov::Strides ref_strides = {90, 30, 5, 1}; + ASSERT_EQ(roi_tensor.get_shape(), ref_shape); + ASSERT_EQ(roi_tensor.data() - t.data(), ref_offset_elems); + ASSERT_EQ(reinterpret_cast(roi_tensor.data()) - reinterpret_cast(t.data()), ref_offset_bytes); + ASSERT_EQ(roi_tensor.get_strides(), t.get_strides()); + ASSERT_EQ(byteStrides(ref_strides, roi_tensor.get_element_type()), roi_tensor.get_strides()); + ASSERT_EQ(roi_tensor.get_element_type(), t.get_element_type()); +} + TEST_F(OVTensorTest, cannotSetShapeOnRoiTensor) { ov::Tensor t{ov::element::i32, {1, 3, 6, 5}}; // RGBp picture of size (WxH) = 5x6 ov::Tensor roi_tensor{t, {0, 0, 1, 2}, {1, 3, 5, 4}}; @@ -329,6 +555,14 @@ TEST_F(OVTensorTest, cannotSetShapeOnRoiTensor) { ASSERT_THROW(roi_tensor.set_shape(newShape), ov::Exception); } +TEST_F(OVTensorTest, cannotSetShapeOnRoiStringTensor) { + ov::Tensor t{ov::element::string, {1, 3, 6, 5}}; // RGBp picture of size (WxH) = 5x6 + ov::Tensor roi_tensor{t, {0, 0, 1, 2}, {1, 3, 5, 4}}; + const ov::Shape newShape({4, 5, 6}); + + ASSERT_THROW(roi_tensor.set_shape(newShape), ov::Exception); +} + TEST_F(OVTensorTest, tensorInt4DataAccess) { ov::Tensor t{ov::element::i4, {1, 6, 5, 3}}; // RGB picture of size (WxH) = 5x6 ASSERT_THROW((ov::Tensor{t, {0, 1, 2, 0}, {1, 5, 4, 3}}), ov::Exception); @@ -368,6 +602,31 @@ TEST_F(OVTensorTest, readRangeRoiBlob) { } } +TEST_F(OVTensorTest, readRangeRoiBlobStringTensor) { + ov::Tensor t{ov::element::string, {1, 3, 4, 8}}; + { + const auto origPtr = t.data(); + ASSERT_NE(nullptr, origPtr); + for (size_t i = 0; i < t.get_size(); ++i) { + origPtr[i] = std::to_string(i); + } + } + ov::Tensor roi_tensor{t, {0, 0, 2, 4}, {1, 3, 4, 8}}; + ASSERT_NE(false, static_cast(roi_tensor)); + { + const std::uint8_t* roi = static_cast(roi_tensor.data()); + ASSERT_NE(nullptr, roi); + auto strides = roi_tensor.get_strides(); + for (auto&& c : ov::CoordinateTransformBasic{roi_tensor.get_shape()}) { + auto actual_addr = roi + c[3] * strides[3] + c[2] * strides[2] + c[1] * strides[1] + c[0] * strides[0]; + auto expected_addr = t.data() + ((c[3] + 4) * strides[3] + (c[2] + 2) * strides[2] + + (c[1] + 0) * strides[1] + (c[0] + 0) * strides[0]) / + t.get_element_type().size(); + ASSERT_EQ(actual_addr, static_cast(static_cast(expected_addr))); + } + } +} + struct TestParams { ov::Shape src_shape; ov::Strides src_strides; @@ -403,7 +662,9 @@ void compare_data(const ov::Tensor& src, const ov::Tensor& dst) { } }; -template +template ::value_type, + typename std::enable_if::type = true> void init_tensor(const ov::Tensor& tensor, bool input) { const auto origPtr = tensor.data(); ASSERT_NE(nullptr, origPtr); @@ -412,43 +673,57 @@ void init_tensor(const ov::Tensor& tensor, bool input) { } } +template ::value_type, + typename std::enable_if::type = true> +void init_tensor(const ov::Tensor& tensor, bool input) { + const auto origPtr = tensor.data(); + ASSERT_NE(nullptr, origPtr); + for (size_t i = 0; i < tensor.get_size(); ++i) { + origPtr[i] = std::to_string(i); + } +} + void init_tensor(const ov::Tensor& tensor, bool input) { switch (tensor.get_element_type()) { case ov::element::bf16: - init_tensor::value_type>(tensor, input); + init_tensor(tensor, input); break; case ov::element::f16: - init_tensor::value_type>(tensor, input); + init_tensor(tensor, input); break; case ov::element::f32: - init_tensor::value_type>(tensor, input); + init_tensor(tensor, input); break; case ov::element::f64: - init_tensor::value_type>(tensor, input); + init_tensor(tensor, input); break; case ov::element::i8: - init_tensor::value_type>(tensor, input); + init_tensor(tensor, input); break; case ov::element::i16: - init_tensor::value_type>(tensor, input); + init_tensor(tensor, input); break; case ov::element::i32: - init_tensor::value_type>(tensor, input); + init_tensor(tensor, input); break; case ov::element::i64: - init_tensor::value_type>(tensor, input); + init_tensor(tensor, input); break; case ov::element::u8: - init_tensor::value_type>(tensor, input); + init_tensor(tensor, input); break; case ov::element::u16: - init_tensor::value_type>(tensor, input); + init_tensor(tensor, input); break; case ov::element::u32: - init_tensor::value_type>(tensor, input); + init_tensor(tensor, input); break; case ov::element::u64: - init_tensor::value_type>(tensor, input); + init_tensor(tensor, input); + break; + case ov::element::string: + init_tensor(tensor, input); break; default: OPENVINO_THROW("Unsupported data type"); @@ -496,6 +771,9 @@ void compare_tensors(const ov::Tensor& src, const ov::Tensor& dst) { case ov::element::u64: compare_data::value_type>(src, dst); break; + case ov::element::string: + compare_data::value_type>(src, dst); + break; default: OPENVINO_THROW("Unsupported data type"); } @@ -578,4 +856,38 @@ INSTANTIATE_TEST_SUITE_P(copy_tests, {1}, {} } ))); + +INSTANTIATE_TEST_SUITE_P(copy_tests_strings, + OVTensorTestCopy, + ::testing::Combine(::testing::Values(ov::element::string), + ::testing::Values( + TestParams { + ov::Shape{1, 3, 4, 8}, {}, + {0}, {} + }, + TestParams { + ov::Shape{3, 2, 2}, {}, + ov::Shape{3, 2, 2}, ov::Strides{16 * string_size, 3 * string_size, string_size} + }, + TestParams { + ov::Shape{3, 2, 2}, ov::Strides{8 * string_size, 2 * string_size, string_size}, + ov::Shape{3, 2, 2}, ov::Strides{} + }, + TestParams { + ov::Shape{3, 2, 2}, ov::Strides{8 * string_size, 2 * string_size, string_size}, + ov::Shape{3, 2, 2}, ov::Strides{16 * string_size, 3 * string_size, string_size} + }, + TestParams { + ov::Shape{}, {}, + {}, {} + }, + TestParams { + ov::Shape{1}, {}, + {}, {} + }, + TestParams { + ov::Shape{}, {}, + {1}, {} + } + ))); // clang-format on diff --git a/src/core/tests/pass/serialization/serialize.cpp b/src/core/tests/pass/serialization/serialize.cpp index 791c46790dda14..d4531b1e029f98 100644 --- a/src/core/tests/pass/serialization/serialize.cpp +++ b/src/core/tests/pass/serialization/serialize.cpp @@ -98,7 +98,8 @@ INSTANTIATE_TEST_SUITE_P( std::make_tuple("loop_2d_add.xml", "loop_2d_add.bin"), std::make_tuple("nms5_dynamism.xml", "nms5_dynamism.bin"), std::make_tuple("if_diff_case.xml", "if_diff_case.bin"), - std::make_tuple("if_body_without_parameters.xml", "if_body_without_parameters.bin"))); + std::make_tuple("if_body_without_parameters.xml", "if_body_without_parameters.bin"), + std::make_tuple("string_parameter.xml", "string_parameter.bin"))); #ifdef ENABLE_OV_ONNX_FRONTEND diff --git a/src/core/tests/tensor.cpp b/src/core/tests/tensor.cpp index 361e45e8a570ce..39b47ad2a86aee 100644 --- a/src/core/tests/tensor.cpp +++ b/src/core/tests/tensor.cpp @@ -14,7 +14,6 @@ #include "openvino/core/model.hpp" #include "openvino/op/parameter.hpp" #include "openvino/op/relu.hpp" -#include "tensor_conversion_util.hpp" using namespace std; using namespace ov; @@ -35,24 +34,6 @@ TEST(tensor, tensor_names) { ASSERT_EQ(f0->get_result()->input_value(0).get_tensor().get_names(), relu->get_output_tensor(0).get_names()); } -TEST(tensor, wrap_tensor_with_unspecified_type) { - auto param = std::make_shared(element::undefined, ov::PartialShape{}); - OPENVINO_SUPPRESS_DEPRECATED_START - auto tensor = ov::util::wrap_tensor(param->output(0)); - OPENVINO_SUPPRESS_DEPRECATED_END - // !tensor means that the tensor is not initialized - EXPECT_EQ(!tensor, true); -} - -TEST(tensor, wrap_tensor_with_unspecified_type_from_host_tensor) { - OPENVINO_SUPPRESS_DEPRECATED_START - auto host_tensor = std::make_shared(element::undefined, ov::PartialShape{}); - auto tensor = ov::util::wrap_tensor(host_tensor); - OPENVINO_SUPPRESS_DEPRECATED_END - // !tensor means that the tensor is not initialized - EXPECT_EQ(!tensor, true); -} - TEST(tensor, create_tensor_with_zero_dims_check_stride) { ov::Shape shape = {0, 0, 0, 0}; auto tensor = ov::Tensor(element::f32, shape); diff --git a/src/core/tests/type_prop/constant.cpp b/src/core/tests/type_prop/constant.cpp index 2a70b44444de3a..061f5c218772e4 100644 --- a/src/core/tests/type_prop/constant.cpp +++ b/src/core/tests/type_prop/constant.cpp @@ -34,6 +34,13 @@ TEST(type_prop, tensor_constant_deduce_bool) { ASSERT_EQ(c->get_shape(), (ov::Shape{2, 2})); } +TEST(type_prop, tensor_constant_deduce_string) { + auto c = + ov::op::v0::Constant::create(ov::element::string, ov::Shape{2, 2}, vector{"1", "2", "3", "4"}); + ASSERT_EQ(c->get_element_type(), ov::element::string); + ASSERT_EQ(c->get_shape(), (ov::Shape{2, 2})); +} + TEST(type_prop, tensor_constant_bad_count) { try { auto c = ov::op::v0::Constant::create(ov::element::boolean, ov::Shape{2, 2}, {1, 1, 1}); @@ -53,3 +60,10 @@ TEST(type_prop, constant_zero_elements_one_string) { ASSERT_EQ(c->get_element_type(), ov::element::i64); ASSERT_EQ(c->get_shape(), (ov::Shape{2, 0, 2, 2})); } + +TEST(type_prop, constant_zero_elements_ov_string) { + auto c = + make_shared(ov::element::string, ov::Shape{2, 0, 2, 2}, std::vector{"42"}); + ASSERT_EQ(c->get_element_type(), ov::element::string); + ASSERT_EQ(c->get_shape(), (ov::Shape{2, 0, 2, 2})); +} diff --git a/src/core/tests/type_prop/equal.cpp b/src/core/tests/type_prop/equal.cpp new file mode 100644 index 00000000000000..d57462dc40e47e --- /dev/null +++ b/src/core/tests/type_prop/equal.cpp @@ -0,0 +1,51 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "openvino/op/equal.hpp" + +#include + +#include "common_test_utils/type_prop.hpp" +#include "openvino/op/broadcast.hpp" +#include "openvino/op/convert.hpp" +#include "openvino/op/shape_of.hpp" + +using ov::op::v0::Convert; +using ov::op::v0::Parameter; +using ov::op::v3::Broadcast; +using ov::op::v3::ShapeOf; + +class TypePropEqualV1Test : public TypePropOpTest { + // Common test for Equal operator are in type_prop/binary_elementwise.cpp +}; + +TEST_F(TypePropEqualV1Test, lhs_upper_bound_within_rhs_bounds) { + constexpr auto et = ov::element::i32; + + const auto lhs = std::make_shared(et, ov::PartialShape{{1, 1}}); + const auto rhs = std::make_shared(et, ov::PartialShape{{0, -1}}); + const auto lhs_shape_of = std::make_shared(lhs, et); + const auto rhs_shape_of = std::make_shared(rhs, et); + const auto op = make_op(lhs_shape_of, rhs_shape_of); + + const auto p = std::make_shared(et, ov::PartialShape{1}); + const auto bc = std::make_shared(p, std::make_shared(op, et)); + + EXPECT_EQ(bc->get_output_partial_shape(0), ov::PartialShape({{0, 1}})); +} + +TEST_F(TypePropEqualV1Test, rhs_upper_bound_within_lhs_bounds) { + constexpr auto et = ov::element::i32; + + const auto lhs = std::make_shared(et, ov::PartialShape{{0, -1}}); + const auto rhs = std::make_shared(et, ov::PartialShape{{1, 1}}); + const auto lhs_shape_of = std::make_shared(lhs, et); + const auto rhs_shape_of = std::make_shared(rhs, et); + const auto op = make_op(lhs_shape_of, rhs_shape_of); + + const auto p = std::make_shared(et, ov::PartialShape{1}); + const auto bc = std::make_shared(p, std::make_shared(op, et)); + + EXPECT_EQ(bc->get_output_partial_shape(0), ov::PartialShape({{0, 1}})); +} diff --git a/src/core/tests/type_prop/multinomial.cpp b/src/core/tests/type_prop/multinomial.cpp index faa6b17b4f790b..e2e80f159ecde6 100644 --- a/src/core/tests/type_prop/multinomial.cpp +++ b/src/core/tests/type_prop/multinomial.cpp @@ -8,17 +8,18 @@ #include "common_test_utils/test_assertions.hpp" #include "common_test_utils/type_prop.hpp" +#include "openvino/op/constant.hpp" using namespace testing; class TypePropMultinomialV13Test : public TypePropOpTest {}; -TEST_F(TypePropMultinomialV13Test, input_probs_f64_num_samples_i32_convert_i32) { - const auto probs = std::make_shared(ov::element::f64, ov::Shape{4}); +TEST_F(TypePropMultinomialV13Test, input_probs_const_f64_num_samples_i32_convert_i32) { + const auto probs = ov::op::v0::Constant::create(ov::element::f64, ov::Shape{2, 2}, {1.0f, 1.0f, 1.0f, 1.0f}); const auto num_samples = std::make_shared(ov::element::i32, ov::Shape{1}); const auto op = make_op(probs, num_samples, ov::element::i32, false, false, 0, 0); EXPECT_EQ(op->get_element_type(), ov::element::i32); - EXPECT_EQ(op->get_output_partial_shape(0), (ov::PartialShape::dynamic(1))); + EXPECT_EQ(op->get_output_partial_shape(0), (ov::PartialShape{2, -1})); } TEST_F(TypePropMultinomialV13Test, input_probs_f32_num_samples_i32_convert_i64) { @@ -29,8 +30,16 @@ TEST_F(TypePropMultinomialV13Test, input_probs_f32_num_samples_i32_convert_i64) EXPECT_EQ(op->get_output_partial_shape(0), (ov::PartialShape{4, -1})); } +TEST_F(TypePropMultinomialV13Test, input_probs_f32_num_samples_const_i32_convert_i64) { + const auto probs = std::make_shared(ov::element::f32, ov::Shape{4, 4}); + const auto num_samples = ov::op::v0::Constant::create(ov::element::i32, ov::Shape{}, {10}); + const auto op = make_op(probs, num_samples, ov::element::i64, false, false, 0, 0); + EXPECT_EQ(op->get_element_type(), ov::element::i64); + EXPECT_EQ(op->get_output_partial_shape(0), (ov::PartialShape{4, 10})); +} + TEST_F(TypePropMultinomialV13Test, probs_incompatibile_data_type) { - const auto probs = std::make_shared(ov::element::i32, ov::Shape{4}); + const auto probs = std::make_shared(ov::element::i32, ov::Shape{4, 4}); const auto num_samples = std::make_shared(ov::element::i32, ov::Shape{}); OV_EXPECT_THROW(std::ignore = make_op(probs, num_samples, ov::element::u64, false, false, 0, 0), ov::NodeValidationFailure, @@ -38,23 +47,31 @@ TEST_F(TypePropMultinomialV13Test, probs_incompatibile_data_type) { } TEST_F(TypePropMultinomialV13Test, num_samples_incompatibile_data_type) { - const auto probs = std::make_shared(ov::element::f32, ov::Shape{4}); + const auto probs = std::make_shared(ov::element::f32, ov::Shape{4, 4}); const auto num_samples = std::make_shared(ov::element::f32, ov::Shape{}); OV_EXPECT_THROW(std::ignore = make_op(probs, num_samples, ov::element::u64, false, false, 0, 0), ov::NodeValidationFailure, HasSubstr("Expected integer type as element type for the 'num_samples' input.")); } -TEST_F(TypePropMultinomialV13Test, probs_incompatibile_rank) { +TEST_F(TypePropMultinomialV13Test, probs_incompatibile_rank_too_big) { const auto probs = std::make_shared(ov::element::f32, ov::Shape{4, 4, 4}); const auto num_samples = std::make_shared(ov::element::i32, ov::Shape{1}); OV_EXPECT_THROW(std::ignore = make_op(probs, num_samples, ov::element::boolean, false, false, 0, 0), ov::NodeValidationFailure, - HasSubstr("The rank of the 'probs' tensor defining output shape must be either 1 or 2.")); + HasSubstr("Input probabilities must be a 2D tensor.")); } -TEST_F(TypePropMultinomialV13Test, num_samples_incompatibile_rank) { +TEST_F(TypePropMultinomialV13Test, probs_incompatibile_rank_too_small) { const auto probs = std::make_shared(ov::element::f32, ov::Shape{4}); + const auto num_samples = std::make_shared(ov::element::i32, ov::Shape{1}); + OV_EXPECT_THROW(std::ignore = make_op(probs, num_samples, ov::element::boolean, false, false, 0, 0), + ov::NodeValidationFailure, + HasSubstr("Input probabilities must be a 2D tensor.")); +} + +TEST_F(TypePropMultinomialV13Test, num_samples_incompatibile_rank) { + const auto probs = std::make_shared(ov::element::f32, ov::Shape{4, 4}); const auto num_samples = std::make_shared(ov::element::i32, ov::Shape{1, 2}); OV_EXPECT_THROW(std::ignore = make_op(probs, num_samples, ov::element::boolean, false, false, 0, 0), ov::NodeValidationFailure, diff --git a/src/core/tests/type_prop/shape_of.cpp b/src/core/tests/type_prop/shape_of.cpp index ac89bb5d747c40..d431ddbff65592 100644 --- a/src/core/tests/type_prop/shape_of.cpp +++ b/src/core/tests/type_prop/shape_of.cpp @@ -137,3 +137,18 @@ TEST(type_prop, shape_of_3_dynamic_value_and_label_propagation) { const auto& output_shape = bc->get_output_partial_shape(0); ASSERT_EQ(ov::DimensionTracker::get_label(output_shape[0]), 10); } + +TEST(type_prop, shape_of_3_dynamic_value_propagation_out_i32) { + constexpr auto i32_max = static_cast(std::numeric_limits::max()); + constexpr auto bound = static_cast(std::numeric_limits::max()) + 10; + + auto param = std::make_shared( + element::f32, + PartialShape{{2, bound}, {3, -1}, {i32_max + 1, bound}, {i32_max, -1}, {1, 1021}}); + auto op = std::make_shared(param, element::i32); + + auto bc_param = std::make_shared(element::f32, Shape{1}); + auto bc = std::make_shared(bc_param, op); + + EXPECT_EQ(bc->get_output_partial_shape(0), PartialShape({-1, -1, -1, -1, {1, 1021}})); +} diff --git a/src/core/tests/visitors/op/constant.cpp b/src/core/tests/visitors/op/constant.cpp index 8577187d678a1d..d47dc0443b42e1 100644 --- a/src/core/tests/visitors/op/constant.cpp +++ b/src/core/tests/visitors/op/constant.cpp @@ -84,3 +84,67 @@ TEST(attributes, constant_op_from_host_tensor_identical_elements) { EXPECT_EQ(data, g_data); ASSERT_TRUE(g_k->get_all_data_elements_bitwise_identical()); } + +// TODO: implement (de)serialization string constants +TEST(attributes, DISABLED_constant_op_string) { + vector data{"abc", "de fc qq", "", "123 abc", "0112 3 ", "&&&"}; + auto k = make_shared(element::string, Shape{2, 3}, data); + NodeBuilder builder(k); + auto g_k = ov::as_type_ptr(builder.create()); + g_k->validate_and_infer_types(); + ASSERT_TRUE(g_k); + EXPECT_EQ(k->get_element_type(), g_k->get_element_type()); + EXPECT_EQ(k->get_shape(), g_k->get_shape()); + vector g_data = g_k->get_vector(); + EXPECT_EQ(data, g_data); + ASSERT_FALSE(g_k->get_all_data_elements_bitwise_identical()); +} + +// TODO: implement (de)serialization string constants +TEST(attributes, DISABLED_constant_op_identical_elements_string) { + vector data{"abc edfg", "abc edfg", "abc edfg", "abc edfg", "abc edfg", "abc edfg"}; + auto k = make_shared(element::string, Shape{2, 3}, data); + NodeBuilder builder(k); + auto g_k = ov::as_type_ptr(builder.create()); + g_k->validate_and_infer_types(); + ASSERT_TRUE(g_k); + EXPECT_EQ(k->get_element_type(), g_k->get_element_type()); + EXPECT_EQ(k->get_shape(), g_k->get_shape()); + vector g_data = g_k->get_vector(); + EXPECT_EQ(data, g_data); + ASSERT_TRUE(g_k->get_all_data_elements_bitwise_identical()); +} + +// TODO: implement (de)serialization string constants +TEST(attributes, DISABLED_constant_op_from_host_tensor_different_elements_string) { + vector data{"abc", "de fc qq", "", "123 abc", "0112 3 ", "&&&"}; + auto tensor = ov::Tensor(element::string, Shape{2, 3}, &data[0]); + auto k = make_shared(tensor); + ASSERT_FALSE(k->get_all_data_elements_bitwise_identical()); + NodeBuilder builder(k); + auto g_k = ov::as_type_ptr(builder.create()); + g_k->validate_and_infer_types(); + ASSERT_TRUE(g_k); + EXPECT_EQ(k->get_element_type(), g_k->get_element_type()); + EXPECT_EQ(k->get_shape(), g_k->get_shape()); + vector g_data = g_k->get_vector(); + EXPECT_EQ(data, g_data); + ASSERT_FALSE(g_k->get_all_data_elements_bitwise_identical()); +} + +// TODO: implement (de)serialization string constants +TEST(attributes, DISABLED_constant_op_from_host_tensor_identical_elements_string) { + vector data{"abc edfg", "abc edfg", "abc edfg", "abc edfg", "abc edfg", "abc edfg"}; + auto tensor = ov::Tensor(element::string, Shape{2, 3}, &data[0]); + auto k = make_shared(tensor); + ASSERT_TRUE(k->get_all_data_elements_bitwise_identical()); + NodeBuilder builder(k); + auto g_k = ov::as_type_ptr(builder.create()); + g_k->validate_and_infer_types(); + ASSERT_TRUE(g_k); + EXPECT_EQ(k->get_element_type(), g_k->get_element_type()); + EXPECT_EQ(k->get_shape(), g_k->get_shape()); + vector g_data = g_k->get_vector(); + EXPECT_EQ(data, g_data); + ASSERT_TRUE(g_k->get_all_data_elements_bitwise_identical()); +} diff --git a/src/frontends/common/CMakeLists.txt b/src/frontends/common/CMakeLists.txt index 4fd41e6f4d3601..9c3d45f949c5bb 100644 --- a/src/frontends/common/CMakeLists.txt +++ b/src/frontends/common/CMakeLists.txt @@ -2,18 +2,33 @@ # SPDX-License-Identifier: Apache-2.0 # -set(TARGET_NAME "frontend_common") +set(TARGET_NAME "openvino_frontend_common") + +set(FRONTEND_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include) +set(FRONTEND_DEV_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/dev_api) file(GLOB_RECURSE LIBRARY_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp) file(GLOB_RECURSE LIBRARY_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/src/*.hpp) file(GLOB_RECURSE LIBRARY_PUBLIC_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/include/*.hpp) -set(FRONTEND_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include) - source_group("src" FILES ${LIBRARY_SRC}) source_group("include" FILES ${LIBRARY_HEADERS}) source_group("public include" FILES ${LIBRARY_PUBLIC_HEADERS}) +# create frontend common library + +add_library(${TARGET_NAME} INTERFACE) + +target_include_directories(${TARGET_NAME} INTERFACE + $ + $) + +target_link_libraries(${TARGET_NAME} INTERFACE openvino::runtime) + +add_library(openvino::frontend::common ALIAS ${TARGET_NAME}) + +ov_install_static_lib(${TARGET_NAME} ${OV_CPACK_COMP_CORE}) + # create library add_library(${TARGET_NAME}_obj OBJECT ${LIBRARY_SRC} ${LIBRARY_HEADERS} ${LIBRARY_PUBLIC_HEADERS}) @@ -23,7 +38,7 @@ target_include_directories(${TARGET_NAME}_obj $ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src - $ + $ # for ov_frontends.hpp in static build ${CMAKE_CURRENT_BINARY_DIR}/src) @@ -60,22 +75,12 @@ ov_ncc_naming_style(FOR_TARGET ${TARGET_NAME}_obj ADDITIONAL_INCLUDE_DIRECTORIES $) -# INTERFACE library for BW compatibility - -add_library(${TARGET_NAME} INTERFACE) -target_link_libraries(${TARGET_NAME} INTERFACE openvino::runtime) -target_include_directories(${TARGET_NAME} INTERFACE $ - $>) - -add_library(ngraph::${TARGET_NAME} ALIAS ${TARGET_NAME}) -add_library(openvino::frontend::common ALIAS ${TARGET_NAME}) -add_library(${TARGET_NAME}::static ALIAS ${TARGET_NAME}) - # Installation rules header files install(DIRECTORY ${FRONTEND_INCLUDE_DIR}/openvino DESTINATION ${FRONTEND_INSTALL_INCLUDE} - COMPONENT ${OV_CPACK_COMP_CORE_DEV}) + COMPONENT ${OV_CPACK_COMP_CORE_DEV} + ${OV_CPACK_COMP_CORE_DEV_EXCLUDE_ALL}) # Shutdown protobuf library if(Protobuf_IN_FRONTEND AND BUILD_SHARED_LIBS) diff --git a/src/frontends/common/dev_api/openvino/frontend/common/random_normal_helper.hpp b/src/frontends/common/dev_api/openvino/frontend/common/random_normal_helper.hpp new file mode 100644 index 00000000000000..e88cf62354a148 --- /dev/null +++ b/src/frontends/common/dev_api/openvino/frontend/common/random_normal_helper.hpp @@ -0,0 +1,42 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include "ngraph/output_vector.hpp" +#include "openvino/frontend/visibility.hpp" +#include "openvino/pass/graph_rewrite.hpp" + +namespace ov { +namespace frontend { + +/// \brief Creates a random normal tensor with the given shape and type. +/// \details Uses Box-Mueller algorithm to generate random numbers from a Gauassian distribution +/// \param sizes Shape of the output tensor +/// \param target_type Type of the output tensor +/// \param mean Mean of the distribution +/// \param scale Standard deviation of the distribution +/// \param seed Seed for the random number generator +FRONTEND_API OutputVector make_random_normal(pass::NodeRegistry& registry, + const Output& sizes, + element::Type target_type, + const Output& mean, + const Output& scale, + float seed); + +/// \brief Creates a random normal tensor with the given shape and type. +/// \details Uses Box-Mueller algorithm to generate random numbers from a Gauassian distribution +/// \param sizes Shape of the output tensor +/// \param target_type Type of the output tensor +/// \param mean Mean of the distribution +/// \param scale Standard deviation of the distribution +/// \param seed Seed for the random number generator +FRONTEND_API std::pair make_random_normal(const Output& sizes, + element::Type target_type, + const Output& mean, + const Output& scale, + float seed); + +} // namespace frontend +} // namespace ov diff --git a/src/frontends/common/include/openvino/frontend/complex_type_mark.hpp b/src/frontends/common/include/openvino/frontend/complex_type_mark.hpp new file mode 100644 index 00000000000000..76d3d2e277b7fa --- /dev/null +++ b/src/frontends/common/include/openvino/frontend/complex_type_mark.hpp @@ -0,0 +1,49 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include "openvino/core/type/element_type.hpp" +#include "openvino/op/util/framework_node.hpp" + +namespace ov { +namespace frontend { + +// ComplexTypeMark serves to mark places that require complex type propagation +// that means to represent native complex type with simulating floating-point tensor +// that has one extra dimension to concatenate real and imaginary parts of complex tensor. +// For example, a tensor of complex type with shape [N1, N2, ..., Nk] will be transformed +// into a floating-point tensor [N1, N2, ..., Nk, 2] +// where a slice with index [..., 0] represents a real part and +// a slice with index [..., 1] represents a imaginary part. +class ComplexTypeMark : public ov::op::util::FrameworkNode { +public: + OPENVINO_OP("ComplexTypeMark", "util", ov::op::util::FrameworkNode); + + ComplexTypeMark(const ov::Output& input, const ov::element::Type& complex_part_type) + : ov::op::util::FrameworkNode(ov::OutputVector{input}, 1), + m_complex_part_type(complex_part_type) { + validate_and_infer_types(); + } + + void validate_and_infer_types() override { + set_output_type(0, ov::element::dynamic, PartialShape::dynamic()); + } + + std::shared_ptr clone_with_new_inputs(const OutputVector& inputs) const override { + auto complex_type_mark = std::make_shared(inputs[0], m_complex_part_type); + complex_type_mark->set_attrs(get_attrs()); + return complex_type_mark; + } + + ov::element::Type get_complex_part_type() const { + return m_complex_part_type; + } + +private: + ov::element::Type m_complex_part_type; +}; + +} // namespace frontend +} // namespace ov diff --git a/src/frontends/common/include/openvino/frontend/visibility.hpp b/src/frontends/common/include/openvino/frontend/visibility.hpp index 4e07f3cedbbc17..ddc2d7eb6898e7 100644 --- a/src/frontends/common/include/openvino/frontend/visibility.hpp +++ b/src/frontends/common/include/openvino/frontend/visibility.hpp @@ -9,7 +9,7 @@ // Increment each time when FrontEnd/InputModel/Place interface is changed #define OV_FRONTEND_API_VERSION 1 -#if defined(USE_STATIC_FRONTEND_COMMON) || defined(OPENVINO_STATIC_LIBRARY) +#if defined(OPENVINO_STATIC_LIBRARY) # define FRONTEND_API # define FRONTEND_C_API #else @@ -20,5 +20,5 @@ # else # define FRONTEND_API OPENVINO_CORE_IMPORTS # define FRONTEND_C_API OPENVINO_EXTERN_C OPENVINO_CORE_IMPORTS -# endif // frontend_common_EXPORTS -#endif // USE_STATIC_FRONTEND_COMMON || OPENVINO_STATIC_LIBRARY +# endif // openvino_frontend_common_EXPORTS +#endif // OPENVINO_STATIC_LIBRARY diff --git a/src/frontends/common/src/random_normal_helper.cpp b/src/frontends/common/src/random_normal_helper.cpp new file mode 100644 index 00000000000000..5e789a9f72f2f5 --- /dev/null +++ b/src/frontends/common/src/random_normal_helper.cpp @@ -0,0 +1,77 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "openvino/frontend/common/random_normal_helper.hpp" + +#include "ngraph/output_vector.hpp" +#include "openvino/op/constant.hpp" +#include "openvino/opsets/opset12.hpp" +#include "openvino/pass/graph_rewrite.hpp" +#include "transformations/rt_info/disable_fp16_compression.hpp" +#define _USE_MATH_DEFINES +#include + +namespace ov { +namespace frontend { + +OutputVector make_random_normal(pass::NodeRegistry& registry, + const Output& sizes, + element::Type target_type, + const Output& mean, + const Output& scale, + float seed) { + // We start by generating two random series from a uniform distribution + const uint64_t global_seed = 0; + + // ONNX specifies the seed as a float, but OpenVINO uses uint64_t + const auto op_seed = static_cast(seed * 1000); + + // We need to use two op_seeds to make sure we get different results for two RandomUniform series + // But we also have to keep original logic and pass "0" (auto-generated seed) to RandomUniform + const uint64_t seed_1 = op_seed; + const uint64_t seed_2 = (op_seed == 0 ? op_seed : op_seed + 10000); + + auto min_val = registry.make(target_type, Shape{1}, std::numeric_limits::min()); + auto max_val = registry.make(target_type, Shape{1}, 1); + + auto uniform_1 = registry.make(sizes, min_val, max_val, target_type, global_seed, seed_1); + auto uniform_2 = registry.make(sizes, min_val, max_val, target_type, global_seed, seed_2); + + // Compute Box–Muller transform + // random_normal = scale * sqrt(-2.0 * log(uniform_1)) * cos(2.0 * pi * uniform_2) + mean + auto pi = registry.make(target_type, Shape{1}, M_PI); + auto minus_two = registry.make(target_type, Shape{1}, -2.0); + auto two = registry.make(target_type, Shape{1}, 2.0); + + auto log = registry.make(uniform_1); + auto multiply_minus_two_log = registry.make(log, minus_two); + auto sqrt = registry.make(multiply_minus_two_log); + + auto multiply_2pi = registry.make(two, pi); + auto multiply_2pi_uniform_2 = registry.make(multiply_2pi, uniform_2); + auto cos = registry.make(multiply_2pi_uniform_2); + + auto sqrt_x_cos = registry.make(sqrt, cos); + auto product = registry.make(scale, sqrt_x_cos); + auto sum = registry.make(product, mean); + + // if we don't disable down-casting then log(float32_min) gives -inf + disable_fp16_compression(uniform_1); + disable_fp16_compression(log); + + return {sum}; +} + +std::pair make_random_normal(const Output& sizes, + element::Type target_type, + const Output& mean, + const Output& scale, + float seed) { + pass::NodeRegistry registry; + OutputVector res = make_random_normal(registry, sizes, target_type, mean, scale, seed); + return std::make_pair(res, registry); +} + +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/frontend/CMakeLists.txt b/src/frontends/onnx/frontend/CMakeLists.txt index d4681b54b08f93..50782959202168 100644 --- a/src/frontends/onnx/frontend/CMakeLists.txt +++ b/src/frontends/onnx/frontend/CMakeLists.txt @@ -16,10 +16,9 @@ target_compile_definitions(${TARGET_NAME} PRIVATE ONNX_OPSET_VERSION=${ONNX_OPSE ov_ncc_naming_style(FOR_TARGET ${TARGET_NAME} SOURCE_DIRECTORIES "${${TARGET_NAME}_INCLUDE_DIR}" DEFINITIONS - $ - ADDITIONAL_INCLUDE_DIRECTORIES - $) + $) install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/onnx_import DESTINATION ${FRONTEND_INSTALL_INCLUDE}/ngraph/frontend - COMPONENT ${OV_CPACK_COMP_CORE_DEV}) + COMPONENT ${OV_CPACK_COMP_CORE_DEV} + ${OV_CPACK_COMP_CORE_DEV_EXCLUDE_ALL}) diff --git a/src/frontends/onnx/frontend/src/op/dequantize_linear.cpp b/src/frontends/onnx/frontend/src/op/dequantize_linear.cpp index 86a19fd4dc8f6c..0647e1f6adb0cc 100644 --- a/src/frontends/onnx/frontend/src/op/dequantize_linear.cpp +++ b/src/frontends/onnx/frontend/src/op/dequantize_linear.cpp @@ -174,10 +174,16 @@ OutputVector dequantize_linear(const Node& node) { const auto& scale = inputs[1]; const auto zero_point = op::detail::get_zero_point(inputs); + const auto& scale_shape = scale.get_partial_shape(); // per-tensor quantization, axis attribute ignored - if (scale.get_partial_shape().rank().is_static() && scale.get_partial_shape().rank().get_length() == 0) { - if (!zero_point || (zero_point->get_output_partial_shape(0).rank().is_static() && - zero_point->get_output_partial_shape(0).rank().get_length() == 0)) { + if ((scale_shape.rank().is_static() && scale_shape.size() == 0) || + (scale_shape.is_static() && shape_size(scale_shape.get_shape()) == 1)) { + if (!zero_point) { + return set_1::dequantize_linear(node); + } + const auto& zero_point_shape = zero_point->get_output_partial_shape(0); + if ((zero_point_shape.rank().is_static() && zero_point_shape.size() == 0) || + (zero_point_shape.is_static() && shape_size(zero_point_shape.get_shape()) == 1)) { return set_1::dequantize_linear(node); } } diff --git a/src/frontends/onnx/frontend/src/op/quantize_linear.cpp b/src/frontends/onnx/frontend/src/op/quantize_linear.cpp index 40ace174738bb3..9468a579e169f1 100644 --- a/src/frontends/onnx/frontend/src/op/quantize_linear.cpp +++ b/src/frontends/onnx/frontend/src/op/quantize_linear.cpp @@ -34,10 +34,12 @@ Output get_zero_point(const OutputVector& inputs) { void validate_zero_point_type(const Node& onnx_node, const Output& y_zero_point) { const auto& y_zero_point_et = y_zero_point.get_element_type(); - CHECK_VALID_NODE(onnx_node, - y_zero_point_et.is_static() && (y_zero_point_et == element::u8 || y_zero_point_et == element::i8), - "\"y_zero_point\" input data type must be static and of 8-bit " - "integer type."); + CHECK_VALID_NODE( + onnx_node, + y_zero_point_et.is_static() && (y_zero_point_et == element::u8 || y_zero_point_et == element::i8 || + y_zero_point_et == element::u16 || y_zero_point_et == element::i16), + "\"y_zero_point\" input data for QuantizeLinear operator must be one of the supported types: u8, i8, u16 or i16" + "integer type."); } Output validate_scale(const Node& onnx_node, const Output& y_scale) { @@ -65,12 +67,28 @@ std::tuple, std::shared_ptr> get_out std::shared_ptr output_low; std::shared_ptr output_high; - if (destination_type == element::i8) { + // These values could be used in a ConvertQuantizeDequantize transformation and + // should be aligned + switch (destination_type) { + case element::i8: output_low = std::make_shared(data_type, Shape{1}, -128); output_high = std::make_shared(data_type, Shape{1}, 127); - } else { + break; + case element::u8: output_low = std::make_shared(data_type, Shape{1}, 0); output_high = std::make_shared(data_type, Shape{1}, 255); + break; + case element::i16: + output_low = std::make_shared(data_type, Shape{1}, -32768); + output_high = std::make_shared(data_type, Shape{1}, 32767); + break; + case element::u16: + output_low = std::make_shared(data_type, Shape{1}, 0); + output_high = std::make_shared(data_type, Shape{1}, 65535); + break; + default: + OPENVINO_THROW("Unsupported element type for QuantizeLinear"); + break; } return std::make_tuple(output_low, output_high); diff --git a/src/frontends/onnx/frontend/src/op/random_normal.cpp b/src/frontends/onnx/frontend/src/op/random_normal.cpp index 35978df4dbf2ad..5b8ccb80e8e380 100644 --- a/src/frontends/onnx/frontend/src/op/random_normal.cpp +++ b/src/frontends/onnx/frontend/src/op/random_normal.cpp @@ -2,10 +2,10 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "utils/random_normal.hpp" - #include "exceptions.hpp" #include "ngraph/shape.hpp" +#include "openvino/frontend/common/random_normal_helper.hpp" +#include "openvino/op/constant.hpp" #include "utils/common.hpp" OPENVINO_SUPPRESS_DEPRECATED_START @@ -23,11 +23,13 @@ OutputVector random_normal(const Node& node) { const auto mean = node.get_attribute_value("mean", 0.0f); const auto scale = node.get_attribute_value("scale", 1.0f); - const auto seed = node.get_attribute_value("seed", 0); + auto scale_node = ov::op::v0::Constant::create(target_type, Shape{1}, {scale}); + auto mean_node = ov::op::v0::Constant::create(target_type, Shape{1}, {mean}); + const auto seed = node.get_attribute_value("seed", 0); const auto shape = node.get_attribute_as_constant>("shape"); - - return detail::make_random_normal(shape, target_type, mean, scale, seed); + auto res = ov::frontend::make_random_normal(shape, target_type, mean_node, scale_node, seed); + return res.first; } } // namespace set_1 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 8d77d8055db16b..0df669b4ada2aa 100644 --- a/src/frontends/onnx/frontend/src/op/random_normal_like.cpp +++ b/src/frontends/onnx/frontend/src/op/random_normal_like.cpp @@ -4,8 +4,8 @@ #include "ngraph/shape.hpp" #include "op/random_uniform_like.hpp" +#include "openvino/frontend/common/random_normal_helper.hpp" #include "utils/common.hpp" -#include "utils/random_normal.hpp" OPENVINO_SUPPRESS_DEPRECATED_START namespace ngraph { @@ -25,11 +25,15 @@ OutputVector random_normal_like(const Node& node) { } const auto shape = std::make_shared(input); + const auto seed = node.get_attribute_value("seed", 0.0f); + const auto mean = node.get_attribute_value("mean", 0.0f); const auto scale = node.get_attribute_value("scale", 1.0f); - const auto seed = node.get_attribute_value("seed", 0.0f); + auto scale_node = ov::op::v0::Constant::create(target_type, Shape{1}, {scale}); + auto mean_node = ov::op::v0::Constant::create(target_type, Shape{1}, {mean}); - return detail::make_random_normal(shape, target_type, mean, scale, seed); + auto res = ov::frontend::make_random_normal(shape, target_type, mean_node, scale_node, seed); + return res.first; } } // namespace set_1 diff --git a/src/frontends/onnx/frontend/src/ops_bridge.cpp b/src/frontends/onnx/frontend/src/ops_bridge.cpp index 88f00c59cdbe1d..b26efd10bf0b84 100644 --- a/src/frontends/onnx/frontend/src/ops_bridge.cpp +++ b/src/frontends/onnx/frontend/src/ops_bridge.cpp @@ -576,6 +576,15 @@ OperatorsBridge::OperatorsBridge() { REGISTER_OPERATOR_WITH_DOMAIN(MICROSOFT_DOMAIN, "SkipLayerNormalization", 1, skip_layer_normalization); REGISTER_OPERATOR_WITH_DOMAIN(MICROSOFT_DOMAIN, "Trilu", 1, trilu); + register_operator_in_custom_domain("DequantizeLinear", + VersionRange::since(1), + op::set_13::dequantize_linear, + "com.microsoft"); + register_operator_in_custom_domain("QuantizeLinear", + VersionRange::since(1), + op::set_13::quantize_linear, + "com.microsoft"); + REGISTER_OPERATOR_WITH_DOMAIN(PYTORCH_ATEN_DOMAIN, "adaptive_avg_pool2d", 1, adaptive_avg_pooling2d); REGISTER_OPERATOR_WITH_DOMAIN(MMDEPLOY_DOMAIN, "NMSRotated", 1, nms_rotated); } diff --git a/src/frontends/onnx/frontend/src/utils/random_normal.cpp b/src/frontends/onnx/frontend/src/utils/random_normal.cpp deleted file mode 100644 index 0905be6ddb1f8b..00000000000000 --- a/src/frontends/onnx/frontend/src/utils/random_normal.cpp +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "random_normal.hpp" - -#include "default_opset.hpp" -#include "ngraph/opsets/opset8.hpp" - -namespace ngraph { -namespace onnx_import { -namespace detail { - -OutputVector make_random_normal(const Output& shape, - element::Type target_type, - float mean, - float scale, - float seed) { - // We start by generating two random series from a uniform distribution - const uint64_t global_seed = 0; - - // ONNX specifies the seed as a float, but OpenVINO uses uint64_t - const auto op_seed = static_cast(seed * 1000); - - // We need to use two op_seeds to make sure we get different results for two RandomUniform series - // But we also have to keep original logic and pass "0" (auto-generated seed) to RandomUniform - const uint64_t seed_1 = op_seed; - const uint64_t seed_2 = (op_seed == 0 ? op_seed : op_seed + 10000); - - const auto min_val = default_opset::Constant::create(target_type, Shape{1}, {0}); - const auto max_val = default_opset::Constant::create(target_type, Shape{1}, {1}); - - const auto uniform_1 = - std::make_shared(shape, min_val, max_val, target_type, global_seed, seed_1); - const auto uniform_2 = - std::make_shared(shape, min_val, max_val, target_type, global_seed, seed_2); - - // Compute Box–Muller transform - // random_normal = scale * ng.sqrt(-2.0 * ng.log(uniform_1)) * ng.cos(2.0 * np.pi * uniform_2) + mean - const auto pi = default_opset::Constant::create(target_type, Shape{1}, {3.141592653589793}); - const auto minus_two = default_opset::Constant::create(target_type, Shape{1}, {-2.0}); - const auto two = default_opset::Constant::create(target_type, Shape{1}, {2.0}); - - const auto log = std::make_shared(uniform_1); - const auto multiply_minus_two_log = std::make_shared(log, minus_two); - const auto sqrt = std::make_shared(multiply_minus_two_log); - - const auto multiply_two_pi = std::make_shared(uniform_2, pi); - const auto multiply_two_pi_uniform_2 = std::make_shared(multiply_two_pi, uniform_2); - auto const cos = std::make_shared(multiply_two_pi_uniform_2); - - auto const scale_const = default_opset::Constant::create(target_type, Shape{1}, {scale}); - auto const mean_const = default_opset::Constant::create(target_type, Shape{1}, {mean}); - auto const product = - std::make_shared(scale_const, std::make_shared(sqrt, cos)); - auto const sum = std::make_shared(product, mean_const); - - return {sum}; -} - -} // namespace detail -} // namespace onnx_import -} // namespace ngraph diff --git a/src/frontends/onnx/frontend/src/utils/random_normal.hpp b/src/frontends/onnx/frontend/src/utils/random_normal.hpp deleted file mode 100644 index f581b2a01b393a..00000000000000 --- a/src/frontends/onnx/frontend/src/utils/random_normal.hpp +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "ngraph/op/reshape.hpp" -#include "ngraph/output_vector.hpp" - -namespace ngraph { -namespace onnx_import { -namespace detail { - -/// \brief Creates a random normal tensor with the given shape and type. -/// \details Uses Box-Mueller algorithm to generate random numbers from a Gauassian distribution -/// \param shape Shape of the output tensor -/// \param type Type of the output tensor -/// \param mean Mean of the distribution -/// \param scale Standard deviation of the distribution -/// \param seed Seed for the random number generator -OutputVector make_random_normal(const Output& shape, - element::Type type, - float mean, - float scale, - float seed); - -} // namespace detail -} // namespace onnx_import -} // namespace ngraph diff --git a/src/frontends/onnx/onnx_common/CMakeLists.txt b/src/frontends/onnx/onnx_common/CMakeLists.txt index 7e27aab9f025a6..d8f2b6d98d11be 100644 --- a/src/frontends/onnx/onnx_common/CMakeLists.txt +++ b/src/frontends/onnx/onnx_common/CMakeLists.txt @@ -28,7 +28,7 @@ target_include_directories(${TARGET_NAME} $ PRIVATE ${ONNX_COMMON_SRC_DIR}) -target_link_libraries(${TARGET_NAME} PRIVATE openvino::runtime) +target_link_libraries(${TARGET_NAME} PRIVATE openvino::runtime openvino::util) ov_link_system_libraries(${TARGET_NAME} PUBLIC onnx_proto onnx) diff --git a/src/frontends/onnx/onnx_common/include/onnx_common/parser.hpp b/src/frontends/onnx/onnx_common/include/onnx_common/parser.hpp index e51e66aff45cf3..081579e74673cd 100644 --- a/src/frontends/onnx/onnx_common/include/onnx_common/parser.hpp +++ b/src/frontends/onnx/onnx_common/include/onnx_common/parser.hpp @@ -3,24 +3,23 @@ // #pragma once +#include + #include #include -/// \ingroup ngraph_cpp_api -namespace ONNX_NAMESPACE { -class ModelProto; -} - -namespace ngraph { +namespace ov { +namespace frontend { namespace onnx_common { +using namespace ::ONNX_NAMESPACE; /// \brief Parses an ONNX model from a file located on a storage device. /// /// \param file_path Path to the file containing an ONNX model. /// /// \return The parsed in-memory representation of the ONNX model -ONNX_NAMESPACE::ModelProto parse_from_file(const std::string& file_path); +ModelProto parse_from_file(const std::string& file_path); #if defined(OPENVINO_ENABLE_UNICODE_PATH_SUPPORT) && defined(_WIN32) -ONNX_NAMESPACE::ModelProto parse_from_file(const std::wstring& file_path); +ModelProto parse_from_file(const std::wstring& file_path); #endif /// \brief Parses an ONNX model from a stream (representing for example a file) @@ -28,7 +27,13 @@ ONNX_NAMESPACE::ModelProto parse_from_file(const std::wstring& file_path); /// \param model_stream Path to the file containing an ONNX model. /// /// \return The parsed in-memory representation of the ONNX model -ONNX_NAMESPACE::ModelProto parse_from_istream(std::istream& model_stream); +ModelProto parse_from_istream(std::istream& model_stream); } // namespace onnx_common +} // namespace frontend +} // namespace ov +namespace ngraph { +namespace onnx_common { +using namespace ov::frontend::onnx_common; +} } // namespace ngraph diff --git a/src/frontends/onnx/onnx_common/src/parser.cpp b/src/frontends/onnx/onnx_common/src/parser.cpp index 9682c35088291a..dd64a13b430de7 100644 --- a/src/frontends/onnx/onnx_common/src/parser.cpp +++ b/src/frontends/onnx/onnx_common/src/parser.cpp @@ -8,11 +8,11 @@ #include #include -#include +#include "openvino/core/except.hpp" +#include "openvino/util/file_util.hpp" -#include "ngraph/except.hpp" - -namespace ngraph { +namespace ov { +namespace frontend { namespace onnx_common { ONNX_NAMESPACE::ModelProto parse_from_file(const std::string& file_path) { std::ifstream file_stream{file_path.c_str(), std::ios::in | std::ios::binary}; @@ -31,9 +31,7 @@ ONNX_NAMESPACE::ModelProto parse_from_file(const std::wstring& file_path) { std::ifstream file_stream{file_path.c_str(), std::ios::in | std::ios::binary}; if (!file_stream.is_open()) { - NGRAPH_SUPPRESS_DEPRECATED_START - OPENVINO_THROW("Could not open the file: " + file_util::wstring_to_string(file_path)); - NGRAPH_SUPPRESS_DEPRECATED_END + OPENVINO_THROW("Could not open the file: " + ov::util::wstring_to_string(file_path)); }; auto model_proto = parse_from_istream(file_stream); @@ -60,4 +58,5 @@ ONNX_NAMESPACE::ModelProto parse_from_istream(std::istream& model_stream) { return model_proto; } } // namespace onnx_common -} // namespace ngraph +} // namespace frontend +} // namespace ov diff --git a/src/frontends/onnx/tests/CMakeLists.txt b/src/frontends/onnx/tests/CMakeLists.txt index 76e7893efef623..2b2d4b0bc95198 100644 --- a/src/frontends/onnx/tests/CMakeLists.txt +++ b/src/frontends/onnx/tests/CMakeLists.txt @@ -68,7 +68,6 @@ set(MULTI_TEST_SRC onnx_import_rnn.in.cpp onnx_import_signal.in.cpp onnx_import_quant.in.cpp - onnx_test_utils.in.cpp onnx_import_with_editor.in.cpp) set(SRC conversion.cpp @@ -83,6 +82,7 @@ set(SRC onnx_importer_test.cpp onnx_tensor_names.cpp onnx_test_util.cpp + onnx_utils.cpp onnx_transformations.cpp op_extension.cpp telemetry.cpp @@ -142,8 +142,13 @@ if(ONNX_TESTS_DEPENDENCIES) add_dependencies(ov_onnx_frontend_tests ${ONNX_TESTS_DEPENDENCIES}) endif() -target_link_libraries(ov_onnx_frontend_tests PRIVATE gtest_main_manifest openvino::runtime::dev - openvino_onnx_frontend openvino_onnx_common func_test_utils) +target_link_libraries(ov_onnx_frontend_tests PRIVATE + gtest_main_manifest + frontend_shared_test_classes + openvino::runtime::dev + openvino_onnx_frontend + openvino_onnx_common + func_test_utils) # It's needed by onnx_import_library.cpp and onnx_import_exceptions.cpp tests to include onnx_pb.h. # Not linking statically to libprotobuf (linked into libonnx) avoids false-failing onnx_editor tests. diff --git a/src/frontends/onnx/tests/__init__.py b/src/frontends/onnx/tests/__init__.py index 452b03dc9b8fb8..48d058df016c01 100644 --- a/src/frontends/onnx/tests/__init__.py +++ b/src/frontends/onnx/tests/__init__.py @@ -164,3 +164,7 @@ def xfail_test(reason="Mark the test as expected to fail", strict=True): xfail_issue_119922 = xfail_test(reason="ai.onnx.ml operators domain isn't supported") xfail_issue_119925 = xfail_test(reason="AveragePool AssertionError: Not equal to tolerance rtol=0.001, atol=1e-07") xfail_issue_119926 = xfail_test(reason="ROIAlign AssertionError: Not equal to tolerance rtol=0.001, atol=1e-07") +xfail_issue_122776 = xfail_test(reason="test_mish_expanded_cpu - " + "Not equal to tolerance") +xfail_issue_122775 = xfail_test(reason="test_resize_downsample_scales_linear_cpu - " + "Not equal to tolerance") diff --git a/src/frontends/onnx/tests/models/dequantize_linear_u16.prototxt b/src/frontends/onnx/tests/models/dequantize_linear_u16.prototxt new file mode 100644 index 00000000000000..c7a5a2b9f80b72 --- /dev/null +++ b/src/frontends/onnx/tests/models/dequantize_linear_u16.prototxt @@ -0,0 +1,62 @@ +ir_version: 3 +producer_name: "ngraph ONNXImporter" +graph { + node { + input: "x" + input: "x_scale" + input: "x_zero_point" + output: "y" + name: "node1" + op_type: "DequantizeLinear" + } + name: "test" + input { + name: "x" + type { + tensor_type { + elem_type: 4 + shape { + dim { + dim_value: 4 + } + } + } + } + } + input { + name: "x_scale" + type { + tensor_type { + elem_type: 1 + shape { + } + } + } + } + input { + name: "x_zero_point" + type { + tensor_type { + elem_type: 4 + shape { + } + } + } + } + output { + name: "y" + type { + tensor_type { + elem_type: 1 + shape { + dim { + dim_value: 4 + } + } + } + } + } +} +opset_import { + version: 21 +} diff --git a/src/frontends/onnx/tests/models/quantize_linear_u16.prototxt b/src/frontends/onnx/tests/models/quantize_linear_u16.prototxt new file mode 100644 index 00000000000000..1595fd9b481199 --- /dev/null +++ b/src/frontends/onnx/tests/models/quantize_linear_u16.prototxt @@ -0,0 +1,73 @@ +ir_version: 3 +producer_name: "ngraph ONNXImporter" +graph { + node { + input: "X" + input: "y_scale" + input: "y_zero_point" + output: "Y" + name: "QuantizeLinear" + op_type: "QuantizeLinear" + } + name: "test_graph" + initializer { + data_type: 4 + name: "y_zero_point" + raw_data: "\000" + } + input { + name: "X" + type { + tensor_type { + elem_type: 1 + shape { + dim { + dim_value: 2 + } + dim { + dim_value: 2 + } + } + } + } + } + input { + name: "y_scale" + type { + tensor_type { + elem_type: 1 + shape { + } + } + } + } + input { + name: "y_zero_point" + type { + tensor_type { + elem_type: 4 + shape { + } + } + } + } + output { + name: "Y" + type { + tensor_type { + elem_type: 4 + shape { + dim { + dim_value: 2 + } + dim { + dim_value: 2 + } + } + } + } + } +} +opset_import { + version: 21 +} diff --git a/src/frontends/onnx/tests/onnx_import.in.cpp b/src/frontends/onnx/tests/onnx_import.in.cpp index 10c8346c3dd833..dc302f500c4124 100644 --- a/src/frontends/onnx/tests/onnx_import.in.cpp +++ b/src/frontends/onnx/tests/onnx_import.in.cpp @@ -5366,7 +5366,7 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_model_random_normal) { file_util::path_join(ov::test::utils::getExecutableDirectory(), SERIALIZED_ZOO, "onnx/random_normal.onnx")); auto test_case = ov::test::TestCase(function, s_device); - test_case.add_expected_output(Shape{2, 2}, {13.459274f, 41.75028f, -19.311913f, 131.79282f}); + test_case.add_expected_output(Shape{2, 2}, {83.052017f, 55.496368f, 119.31188f, -3.6946249f}); test_case.run(); } @@ -5377,7 +5377,7 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_model_random_normal_like) { auto test_case = ov::test::TestCase(function, s_device); test_case.add_input(Shape{2, 2}, {0, 0, 0, 0}); - test_case.add_expected_output(Shape{2, 2}, {13.459274f, 41.75028f, -19.311913f, 131.79282f}); + test_case.add_expected_output(Shape{2, 2}, {83.052017f, 55.496368f, 119.31188f, -3.6946249f}); test_case.run(); } diff --git a/src/frontends/onnx/tests/onnx_import_quant.in.cpp b/src/frontends/onnx/tests/onnx_import_quant.in.cpp index ea13274d1b8804..0be5d99d8ce15b 100644 --- a/src/frontends/onnx/tests/onnx_import_quant.in.cpp +++ b/src/frontends/onnx/tests/onnx_import_quant.in.cpp @@ -59,6 +59,19 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_model_quantize_linear) { test_case.run(); } +OPENVINO_TEST(${BACKEND_NAME}, onnx_model_quantize_linear_u16) { + auto function = onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), + SERIALIZED_ZOO, + "onnx/quantize_linear_u16.onnx")); + + auto test_case = ov::test::TestCase(function, s_device); + test_case.add_input(std::vector{32.25f, 48.34f, 250.f, 22883.f}); + test_case.add_input(std::vector{0.5f}); + + test_case.add_expected_output(std::vector{64, 97, 500, 45766}); + test_case.run(); +} + OPENVINO_TEST(${BACKEND_NAME}, onnx_model_quantize_linear_zero_point) { auto function = onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), SERIALIZED_ZOO, @@ -220,6 +233,20 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_model_dequantize_linear_scalar_zero_scale_ui test_case.run(); } +OPENVINO_TEST(${BACKEND_NAME}, onnx_model_dequantize_linear_scalar_zero_scale_uint16) { + auto function = onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), + SERIALIZED_ZOO, + "onnx/dequantize_linear_u16.onnx")); + + auto test_case = ov::test::TestCase(function, s_device); + test_case.add_input(std::vector{0, 3, 32768, 65535}); // x + test_case.add_input(std::vector{2.0f}); // scale + test_case.add_input(std::vector{32768}); // zero_point + + test_case.add_expected_output({4}, std::vector{-65536.0f, -65530.0f, 0.0f, 65534.0f}); + test_case.run(); +} + OPENVINO_TEST(${BACKEND_NAME}, onnx_model_dequantize_linear_scalar_zero_scale_int8) { auto function = onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), SERIALIZED_ZOO, diff --git a/src/frontends/onnx/tests/onnx_test_util.cpp b/src/frontends/onnx/tests/onnx_test_util.cpp index 668bca583f8f98..2fb733a7f9e8a7 100644 --- a/src/frontends/onnx/tests/onnx_test_util.cpp +++ b/src/frontends/onnx/tests/onnx_test_util.cpp @@ -191,8 +191,10 @@ ComparisonResult compare_onnx_graphs(const ONNX_NAMESPACE::GraphProto& graph, return compare_nodes(graph, ref_graph, comp); } } // namespace -namespace ngraph { -namespace test { +namespace ov { +namespace frontend { +namespace onnx { +namespace tests { bool default_name_comparator(std::string lhs, std::string rhs) { return lhs == rhs; @@ -220,5 +222,7 @@ std::string change_opset_version(const std::string& model, return model_proto.SerializeAsString(); } -} // namespace test -} // namespace ngraph +} // namespace tests +} // namespace onnx +} // namespace frontend +} // namespace ov \ No newline at end of file diff --git a/src/frontends/onnx/tests/onnx_test_util.hpp b/src/frontends/onnx/tests/onnx_test_util.hpp index a61371c03b882a..c5db6f6a0c54fb 100644 --- a/src/frontends/onnx/tests/onnx_test_util.hpp +++ b/src/frontends/onnx/tests/onnx_test_util.hpp @@ -8,8 +8,10 @@ #include #include -namespace ngraph { -namespace test { +namespace ov { +namespace frontend { +namespace onnx { +namespace tests { struct ComparisonResult { ComparisonResult() = default; ComparisonResult(std::string error) : is_ok{false}, error_message{std::move(error)} {} @@ -40,5 +42,13 @@ ComparisonResult compare_onnx_models(const std::string& model, std::string change_opset_version(const std::string& model, const std::vector& new_opset_version, const std::string& domain = "ai.onnx"); +} // namespace tests +} // namespace onnx +} // namespace frontend +} // namespace ov + +namespace ngraph { +namespace test { +using namespace ov::frontend::onnx::tests; } // namespace test } // namespace ngraph diff --git a/src/frontends/onnx/tests/onnx_test_utils.in.cpp b/src/frontends/onnx/tests/onnx_test_utils.in.cpp deleted file mode 100644 index 6290310a7a4a8f..00000000000000 --- a/src/frontends/onnx/tests/onnx_test_utils.in.cpp +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include -#include - -#include "common_test_utils/all_close.hpp" -#include "common_test_utils/file_utils.hpp" -#include "common_test_utils/test_case.hpp" -#include "common_test_utils/test_control.hpp" -#include "common_test_utils/test_tools.hpp" -#include "default_opset.hpp" -#include "editor.hpp" -#include "gtest/gtest.h" -#include "ngraph/file_util.hpp" -#include "ngraph/op/util/op_types.hpp" -#include "onnx_import/onnx.hpp" -#include "onnx_utils.hpp" - -using namespace ngraph; -OPENVINO_SUPPRESS_DEPRECATED_START - -static std::string s_manifest = ngraph::file_util::path_join(ov::test::utils::getExecutableDirectory(), "${MANIFEST}"); -static std::string s_device = backend_name_to_device("${BACKEND_NAME}"); - -// is there any benefit of running below tests on different backends? -// why are these here anyway? - -OPENVINO_TEST(${BACKEND_NAME}, add_abc_from_ir) { - const auto ir_xml = - file_util::path_join(ov::test::utils::getExecutableDirectory(), TEST_MODEL_ZOO, "core/models/ir/add_abc.xml"); - const auto function = function_from_ir(ir_xml); - - auto test_case = ov::test::TestCase(function, s_device); - test_case.add_input({1}); - test_case.add_input({2}); - test_case.add_input({3}); - test_case.add_expected_output(Shape{1}, {6}); - - test_case.run(); -} - -OPENVINO_TEST(${BACKEND_NAME}, add_abc_from_ir_with_bin_path) { - const auto ir_xml = - file_util::path_join(ov::test::utils::getExecutableDirectory(), TEST_MODEL_ZOO, "core/models/ir/add_abc.xml"); - const auto ir_bin = - file_util::path_join(ov::test::utils::getExecutableDirectory(), TEST_MODEL_ZOO, "core/models/ir/add_abc.bin"); - const auto function = function_from_ir(ir_xml, ir_bin); - - auto test_case = ov::test::TestCase(function, s_device); - test_case.add_input({1}); - test_case.add_input({2}); - test_case.add_input({3}); - test_case.add_expected_output(Shape{1}, {6}); - - test_case.run(); -} diff --git a/src/frontends/onnx/tests/onnx_utils.cpp b/src/frontends/onnx/tests/onnx_utils.cpp new file mode 100644 index 00000000000000..9795e1f4e09cc9 --- /dev/null +++ b/src/frontends/onnx/tests/onnx_utils.cpp @@ -0,0 +1,99 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "onnx_utils.hpp" + +#include +#include + +#include "utils.hpp" + +using namespace std; +using namespace ov; +using namespace ov::frontend; + +// For compatibility purposes, need to remove when will be unused +const std::string ONNX_FE = "onnx"; + +namespace ov { +namespace frontend { +namespace onnx { +namespace tests { + +const std::string ONNX_FE = ::ONNX_FE; + +shared_ptr convert_model(const string& model_path, const ov::frontend::ConversionExtensionBase::Ptr& conv_ext) { + auto fem = FrontEndManager(); + FrontEnd::Ptr front_end = fem.load_by_framework(ONNX_FE); + if (!front_end) { + throw "ONNX FrontEnd is not initialized"; + } + + if (conv_ext) { + front_end->add_extension(conv_ext); + } + + auto full_path = FrontEndTestUtils::make_model_path(string(TEST_ONNX_MODELS_DIRNAME) + model_path); + InputModel::Ptr input_model = front_end->load(full_path); + if (!input_model) { + throw "Input Model is not loaded"; + } + + shared_ptr model = front_end->convert(input_model); + if (!model) { + throw "Model is not converted"; + } + + return model; +} + +shared_ptr convert_model(ifstream& model_stream) { + auto fem = FrontEndManager(); + FrontEnd::Ptr front_end = fem.load_by_framework(ONNX_FE); + if (!front_end) { + throw "ONNX FrontEnd is not initialized"; + } + + InputModel::Ptr input_model = front_end->load(dynamic_cast(&model_stream)); + if (!input_model) { + throw "Input Model is not loaded"; + } + + shared_ptr model = front_end->convert(input_model); + if (!model) { + throw "Model is not converted"; + } + + return model; +} + +shared_ptr convert_partially(const string& model_path) { + auto fem = FrontEndManager(); + FrontEnd::Ptr front_end = fem.load_by_framework(ONNX_FE); + if (!front_end) { + throw "ONNX FrontEnd is not initialized"; + } + + auto full_path = FrontEndTestUtils::make_model_path(string(TEST_ONNX_MODELS_DIRNAME) + model_path); + InputModel::Ptr input_model = front_end->load(full_path); + if (!input_model) { + throw "Input Model is not loaded"; + } + + shared_ptr model = front_end->convert_partially(input_model); + if (!model) { + throw "Model is not converted"; + } + + return model; +} + +std::string onnx_backend_manifest(const std::string& manifest) { + return ov::util::path_join({ov::test::utils::getExecutableDirectory(), manifest}); +} + +} // namespace tests +} // namespace onnx +} // namespace frontend +} // namespace ov \ No newline at end of file diff --git a/src/frontends/onnx/tests/onnx_utils.hpp b/src/frontends/onnx/tests/onnx_utils.hpp index 4aa68986fc097e..eea1e10475a764 100644 --- a/src/frontends/onnx/tests/onnx_utils.hpp +++ b/src/frontends/onnx/tests/onnx_utils.hpp @@ -4,13 +4,15 @@ #pragma once +#include + +#include +#include #include -#include "openvino/runtime/core.hpp" #include "common_test_utils/test_constants.hpp" -static const std::string ONNX_FE = "onnx"; - +// Resolves different backend names to an internal device enumeration inline std::string backend_name_to_device(const std::string& backend_name) { if (backend_name == "INTERPRETER") return ov::test::utils::DEVICE_TEMPLATE; @@ -18,10 +20,31 @@ inline std::string backend_name_to_device(const std::string& backend_name) { return ov::test::utils::DEVICE_CPU; if (backend_name == "IE_GPU") return ov::test::utils::DEVICE_GPU; - OPENVINO_THROW("Unsupported backend name"); + throw "Unsupported backend name"; } -inline std::shared_ptr function_from_ir(const std::string& xml_path, const std::string& bin_path = {}) { - ov::Core c; - return c.read_model(xml_path, bin_path); -} +namespace ov { +namespace frontend { +namespace onnx { +namespace tests { + +extern const std::string ONNX_FE; + +// A wrapper to create ONNX Frontend and configure the conversion pipeline +std::shared_ptr convert_model(const std::string& model_path, + const ov::frontend::ConversionExtensionBase::Ptr& conv_ext = nullptr); +// A wrapper to create ONNX Frontend and configure the conversion pipeline +std::shared_ptr convert_model(std::ifstream& model_stream); +// A wrapper to create ONNX Frontend and configure the conversion pipeline to get +// a model with possible Framework Nodes +std::shared_ptr convert_partially(const std::string& model_path); + +// Returns path to a manifest file +std::string onnx_backend_manifest(const std::string& manifest); +} // namespace tests +} // namespace onnx +} // namespace frontend +} // namespace ov + +// For compatibility purposes, need to remove when will be unused +extern const std::string ONNX_FE; diff --git a/src/frontends/onnx/tests/runtime/ie/unit_test.manifest b/src/frontends/onnx/tests/runtime/ie/unit_test.manifest index 6c8a302313f032..dabc8d7bfe95d4 100644 --- a/src/frontends/onnx/tests/runtime/ie/unit_test.manifest +++ b/src/frontends/onnx/tests/runtime/ie/unit_test.manifest @@ -392,3 +392,15 @@ IE_CPU.onnx_model_top_k_repeating_unsorted # Accuracy regression - Ticket 105909 IE_CPU.onnx_model_attention_qkv_hidden_sizes + +# Accuracy issues on ARM CPU - Ticket 122663 +IE_CPU.onnx_model_bias_gelu +IE_CPU.onnx_model_embed_layer_normalization_diff_seq_len_pos_embed_len +IE_CPU.onnx_model_embed_layer_normalization_with_position_ids +IE_CPU.onnx_resize10_down_scales_const_linear +IE_CPU.onnx_resize11_down_scales_linear_asymmetric +IE_CPU.onnx_model_softplus +IE_CPU.onnx_model_instance_normalization +IE_CPU.quant_dequant_pattern_axis +IE_CPU/GRUSequenceOp.onnx_model_gru_reverse_mixed_seq_len_const +IE_CPU/RNNSequenceOp.onnx_model_rnn_fwd_bias_initial_h_const diff --git a/src/frontends/onnx/tests/tests_python/test_backend.py b/src/frontends/onnx/tests/tests_python/test_backend.py index 27fbae1dbd3986..6a9e0fa78969e6 100644 --- a/src/frontends/onnx/tests/tests_python/test_backend.py +++ b/src/frontends/onnx/tests/tests_python/test_backend.py @@ -72,6 +72,8 @@ xfail_issue_119922, xfail_issue_119925, xfail_issue_119926, + xfail_issue_122775, + xfail_issue_122776 ) from tests.tests_python.utils.onnx_backend import OpenVinoTestBackend @@ -685,6 +687,14 @@ def expect_fail(test_case_path, xfail): # type: (str) -> None )] ) +if platform.system() == 'Linux' and platform.machine() in ['arm', 'armv7l', 'aarch64', 'arm64', 'ARM64']: + tests_expected_to_fail.extend( + [ + (xfail_issue_122775, "OnnxBackendNodeModelTest.test_resize_downsample_scales_linear_cpu"), + (xfail_issue_122776, "OnnxBackendNodeModelTest.test_mish_expanded_cpu") + ] + ) + for test_group in tests_expected_to_fail: for test_case in test_group[1:]: expect_fail(f"{test_case}", test_group[0]) diff --git a/src/frontends/paddle/include/openvino/frontend/paddle/decoder.hpp b/src/frontends/paddle/include/openvino/frontend/paddle/decoder.hpp index 1934352e3c01b1..a687f137ca0e03 100644 --- a/src/frontends/paddle/include/openvino/frontend/paddle/decoder.hpp +++ b/src/frontends/paddle/include/openvino/frontend/paddle/decoder.hpp @@ -40,6 +40,9 @@ class DecoderBase { virtual size_t get_output_size() const = 0; virtual size_t get_output_size(const std::string& port_name) const = 0; + /// \brief Get the version + virtual int64_t get_version() const = 0; + /// \brief Get output port type /// /// Current API assumes that output port has only one output type. diff --git a/src/frontends/paddle/include/openvino/frontend/paddle/node_context.hpp b/src/frontends/paddle/include/openvino/frontend/paddle/node_context.hpp index d571af6ddddf44..dde7df0770c2ff 100644 --- a/src/frontends/paddle/include/openvino/frontend/paddle/node_context.hpp +++ b/src/frontends/paddle/include/openvino/frontend/paddle/node_context.hpp @@ -98,6 +98,10 @@ class NodeContext : public ov::frontend::NodeContext { return decoder->get_output_port_infos(port_name); } + int64_t get_version() const { + return decoder->get_version(); + } + private: ov::Any apply_additional_conversion_rules(const ov::Any& any, const std::type_info& type_info) const override { auto res = decoder->convert_attribute(any, type_info); diff --git a/src/frontends/paddle/src/decoder_proto.cpp b/src/frontends/paddle/src/decoder_proto.cpp index f286bfcf1f81fc..41da414db6a23e 100644 --- a/src/frontends/paddle/src/decoder_proto.cpp +++ b/src/frontends/paddle/src/decoder_proto.cpp @@ -75,6 +75,10 @@ ov::Any DecoderProto::get_attribute(const std::string& name) const { } } +int64_t DecoderProto::get_version() const { + return get_place()->get_version(); +} + ov::Any DecoderProto::convert_attribute(const Any& data, const std::type_info& type_info) const { if (data.is() && type_info == typeid(ov::element::Type)) { return get_ov_type(static_cast(data.as())); diff --git a/src/frontends/paddle/src/decoder_proto.hpp b/src/frontends/paddle/src/decoder_proto.hpp index 11627c6fba6ab9..cfad67bbc4ff2d 100644 --- a/src/frontends/paddle/src/decoder_proto.hpp +++ b/src/frontends/paddle/src/decoder_proto.hpp @@ -55,6 +55,8 @@ class DecoderProto : public paddle::DecoderBase { std::map map_for_each_output( const std::function(const std::string&, size_t)>& func) const; + int64_t get_version() const override; + private: std::vector<::paddle::framework::proto::OpDesc_Attr> decode_attribute_helper(const std::string& name) const; std::weak_ptr op_place; diff --git a/src/frontends/paddle/src/input_model.cpp b/src/frontends/paddle/src/input_model.cpp index 287fa5e54ad743..8518db040eea39 100644 --- a/src/frontends/paddle/src/input_model.cpp +++ b/src/frontends/paddle/src/input_model.cpp @@ -34,6 +34,9 @@ class InputModel::InputModelImpl { const std::shared_ptr& telemetry); std::vector get_inputs() const; std::vector get_outputs() const; + int64_t get_version() const { + return m_fw_ptr->version().version(); + } Place::Ptr get_place_by_tensor_name(const std::string& tensorName) const; void override_all_outputs(const std::vector& outputs); void override_all_inputs(const std::vector& inputs); @@ -589,6 +592,10 @@ std::vector InputModel::get_outputs() const { return _impl->get_outputs(); } +int64_t InputModel::get_version() const { + return _impl->get_version(); +} + Place::Ptr InputModel::get_place_by_tensor_name(const std::string& tensorName) const { return _impl->get_place_by_tensor_name(tensorName); } diff --git a/src/frontends/paddle/src/input_model.hpp b/src/frontends/paddle/src/input_model.hpp index 069e7a94c98b34..8607cf30134129 100644 --- a/src/frontends/paddle/src/input_model.hpp +++ b/src/frontends/paddle/src/input_model.hpp @@ -32,6 +32,7 @@ class InputModel : public ov::frontend::InputModel { ov::PartialShape get_partial_shape(const Place::Ptr& place) const override; void set_element_type(const Place::Ptr& place, const ov::element::Type&) override; void set_tensor_value(const Place::Ptr& place, const void* value) override; + int64_t get_version() const; private: friend class ov::frontend::paddle::FrontEnd; diff --git a/src/frontends/paddle/src/op/argmax.cpp b/src/frontends/paddle/src/op/argmax.cpp index 10029a385eb08d..7ec245a8c2ffbe 100644 --- a/src/frontends/paddle/src/op/argmax.cpp +++ b/src/frontends/paddle/src/op/argmax.cpp @@ -28,9 +28,17 @@ NamedOutputs argmax(const NodeContext& node) { const Output reshape_flatten = ov::opset6::Constant::create(ov::element::i64, {1}, {-1}); auto node_reshape = std::make_shared(data, reshape_flatten, true); auto node_topk = std::make_shared(node_reshape, k, axis, "max", "index", index_element_type); - return node.default_single_output_mapping( - {std::make_shared(node_topk->output(1), element::i64)}, - {"Out"}); + const auto output_info = node.get_output_port_infos("Out"); + size_t output_size = output_info[0].second.size(); + if (output_size == 0) { + auto out = std::make_shared(node_topk->output(1)); + return node.default_single_output_mapping({std::make_shared(out, element::i64)}, + {"Out"}); + } else { + return node.default_single_output_mapping( + {std::make_shared(node_topk->output(1), element::i64)}, + {"Out"}); + } } } diff --git a/src/frontends/paddle/src/op/elementwise_ops.cpp b/src/frontends/paddle/src/op/elementwise_ops.cpp index d0c3a12c48b60b..edbe9564883a99 100644 --- a/src/frontends/paddle/src/op/elementwise_ops.cpp +++ b/src/frontends/paddle/src/op/elementwise_ops.cpp @@ -42,15 +42,15 @@ NamedOutputs elementwise_pow(const NodeContext& node_context) { return elementwise_ops(node_context); } -NamedOutputs elementwise_equal(const NodeContext& node_context) { +NamedOutputs equal(const NodeContext& node_context) { return elementwise_ops(node_context); } -NamedOutputs elementwise_greater_equal(const NodeContext& node_context) { +NamedOutputs greater_equal(const NodeContext& node_context) { return elementwise_ops(node_context); } -NamedOutputs elementwise_not_equal(const NodeContext& node_context) { +NamedOutputs not_equal(const NodeContext& node_context) { return elementwise_ops(node_context); } @@ -61,10 +61,17 @@ NamedOutputs elementwise_floordiv(const NodeContext& node_context) { if (node_context.has_attribute("axis")) { axis = node_context.get_attribute("axis"); } + + int64_t pd_version = node_context.get_version(); + + bool python_div = false; + if (pd_version >= 2005000 || pd_version == 0) { + python_div = true; + } return node_context.default_single_output_mapping( {std::make_shared(x, y, - false, + python_div, ov::op::AutoBroadcastSpec(ov::op::AutoBroadcastType::PDPD, axis))}, {"Out"}); } diff --git a/src/frontends/paddle/src/op/fill_constant_batch_size_like.cpp b/src/frontends/paddle/src/op/fill_constant_batch_size_like.cpp index 4f5c3c891c4c4f..cf23a4a2e151b6 100644 --- a/src/frontends/paddle/src/op/fill_constant_batch_size_like.cpp +++ b/src/frontends/paddle/src/op/fill_constant_batch_size_like.cpp @@ -121,4 +121,4 @@ NamedOutputs fill_constant_batch_size_like(const NodeContext& node) { } // namespace op } // namespace paddle } // namespace frontend -} // namespace ov +} // namespace ov \ No newline at end of file diff --git a/src/frontends/paddle/src/op/grid_sampler.cpp b/src/frontends/paddle/src/op/grid_sampler.cpp index 148ad60cfd7d1e..b78c3ea345ad1e 100644 --- a/src/frontends/paddle/src/op/grid_sampler.cpp +++ b/src/frontends/paddle/src/op/grid_sampler.cpp @@ -4,11 +4,15 @@ #include "default_opset.hpp" #include "openvino/frontend/paddle/node_context.hpp" +#include "openvino/op/grid_sample.hpp" namespace ov { namespace frontend { namespace paddle { namespace op { + +using namespace ov::op; + NamedOutputs grid_sampler(const NodeContext& node) { auto data = node.get_input("X"); auto grid = node.get_input("Grid"); diff --git a/src/frontends/paddle/src/op/matmul_v2.cpp b/src/frontends/paddle/src/op/matmul_v2.cpp index 12dc2eee018072..2a096569d0335b 100644 --- a/src/frontends/paddle/src/op/matmul_v2.cpp +++ b/src/frontends/paddle/src/op/matmul_v2.cpp @@ -16,7 +16,9 @@ NamedOutputs matmul_v2(const NodeContext& node) { const auto mm = std::make_shared(x, y, transpose_a, transpose_b); std::shared_ptr result = mm; - if (is_scalar(mm->get_output_partial_shape(0))) { + const auto output_info = node.get_output_port_infos("Out"); + size_t output_size = output_info[0].second.size(); + if (is_scalar(mm->get_output_partial_shape(0)) && output_size) { auto unsqueeze_scalar = default_opset::Constant::create(ov::element::i64, {}, {0}); result = std::make_shared(mm, unsqueeze_scalar); } diff --git a/src/frontends/paddle/src/op/p_norm.cpp b/src/frontends/paddle/src/op/p_norm.cpp index 3023700e5e57ee..645bd9e53c9b11 100644 --- a/src/frontends/paddle/src/op/p_norm.cpp +++ b/src/frontends/paddle/src/op/p_norm.cpp @@ -18,22 +18,20 @@ NamedOutputs p_norm(const NodeContext& node) { const auto absNode = std::make_shared(data); const auto axisNode = default_opset::Constant::create(ov::element::i32, {1}, {axis}); + std::shared_ptr p_norm_node; + const auto input_shape = data.get_partial_shape(); + if (p == std::numeric_limits::infinity()) { - return node.default_single_output_mapping( - {std::make_shared(absNode, axisNode, keepdim)}, - {"Out"}); + p_norm_node = std::make_shared(absNode, axisNode, keepdim); } else if (p == -std::numeric_limits::infinity()) { - return node.default_single_output_mapping( - {std::make_shared(absNode, axisNode, keepdim)}, - {"Out"}); + p_norm_node = std::make_shared(absNode, axisNode, keepdim); } else if (p == 0.0) { const auto input_dtype = data.get_element_type(); const auto zero = default_opset::Constant::create(input_dtype, {1}, {0}); const auto non_zero = std::make_shared(absNode, zero); const auto converted_non_zero = std::make_shared(non_zero, input_dtype); - const auto reduce_sum = std::make_shared(converted_non_zero, axisNode, keepdim); - const auto input_shape = data.get_partial_shape(); + p_norm_node = std::make_shared(converted_non_zero, axisNode, keepdim); // process 1-d input and keepdim=false, output shape is [1], instead of scalar. if (!keepdim) { PADDLE_OP_CHECK(node, @@ -42,19 +40,23 @@ NamedOutputs p_norm(const NodeContext& node) { const auto input_rank = input_shape.rank().get_length(); if (input_rank == 1) { const auto one = default_opset::Constant::create(ov::element::i64, {1}, {1}); - auto out = std::make_shared(reduce_sum, one, false); - return node.default_single_output_mapping({out}, {"Out"}); + p_norm_node = std::make_shared(p_norm_node, one, false); } } - return node.default_single_output_mapping({reduce_sum}, {"Out"}); } else { const auto power_factor = default_opset::Constant::create(ov::element::f32, Shape{1}, {p}); const auto powNode = std::make_shared(absNode, power_factor); const auto reduce_sum = std::make_shared(powNode, axisNode, keepdim); const auto extract_factor = default_opset::Constant::create(ov::element::f32, Shape{1}, {1.0 / p}); - return node.default_single_output_mapping({std::make_shared(reduce_sum, extract_factor)}, - {"Out"}); + p_norm_node = std::make_shared(reduce_sum, extract_factor); + } + + const auto output_info = node.get_output_port_infos("Out"); + size_t output_size = output_info[0].second.size(); + if ((axis == -1 || input_shape.size() == 1) && !keepdim && !output_size) { + p_norm_node = std::make_shared(p_norm_node); } + return node.default_single_output_mapping({p_norm_node}, {"Out"}); } } // namespace op diff --git a/src/frontends/paddle/src/op/reduce_ops.hpp b/src/frontends/paddle/src/op/reduce_ops.hpp index bc700c1ed0327e..0944d1081ff759 100644 --- a/src/frontends/paddle/src/op/reduce_ops.hpp +++ b/src/frontends/paddle/src/op/reduce_ops.hpp @@ -40,6 +40,12 @@ NamedOutputs reduce_ops(const NodeContext& node) { auto unsqueeze_scalar = default_opset::Constant::create(ov::element::i64, {}, {0}); result = std::make_shared(reduceNode, unsqueeze_scalar); } + + const auto output_info = node.get_output_port_infos("Out"); + size_t output_size = output_info[0].second.size(); + if (reduce_all && !output_size) { + result = std::make_shared(reduceNode); + } return node.default_single_output_mapping({result}, {"Out"}); } diff --git a/src/frontends/paddle/src/op/reverse.cpp b/src/frontends/paddle/src/op/reverse.cpp index 097e13b401986b..bf986055dab067 100644 --- a/src/frontends/paddle/src/op/reverse.cpp +++ b/src/frontends/paddle/src/op/reverse.cpp @@ -14,4 +14,4 @@ NamedOutputs reverse(const NodeContext& node) { } // namespace op } // namespace paddle } // namespace frontend -} // namespace ov +} // namespace ov \ No newline at end of file diff --git a/src/frontends/paddle/src/op_table.cpp b/src/frontends/paddle/src/op_table.cpp index f701065569517e..4ed557a4edd13e 100644 --- a/src/frontends/paddle/src/op_table.cpp +++ b/src/frontends/paddle/src/op_table.cpp @@ -29,25 +29,25 @@ OP_CONVERTER(dequantize_linear); OP_CONVERTER(dropout); OP_CONVERTER(elementwise_add); OP_CONVERTER(elementwise_div); -OP_CONVERTER(elementwise_equal); OP_CONVERTER(elementwise_floordiv); -OP_CONVERTER(elementwise_greater_equal); OP_CONVERTER(elementwise_max); OP_CONVERTER(elementwise_min); OP_CONVERTER(elementwise_mod); OP_CONVERTER(elementwise_mul); -OP_CONVERTER(elementwise_not_equal); OP_CONVERTER(elementwise_pow); OP_CONVERTER(elementwise_sub); +OP_CONVERTER(equal); +OP_CONVERTER(greater_equal); +OP_CONVERTER(not_equal); OP_CONVERTER(embedding); OP_CONVERTER(exp); OP_CONVERTER(expand_v2); OP_CONVERTER(flip); -OP_CONVERTER(fill_any_like); -OP_CONVERTER(fill_constant_batch_size_like); -OP_CONVERTER(fill_constant); OP_CONVERTER(flatten_contiguous_range); OP_CONVERTER(floor); +OP_CONVERTER(fill_any_like); +OP_CONVERTER(fill_constant); +OP_CONVERTER(fill_constant_batch_size_like); OP_CONVERTER(gather); OP_CONVERTER(gather_nd); OP_CONVERTER(gelu); @@ -152,22 +152,22 @@ std::map get_supported_ops() { {"depthwise_conv2d", op::conv2d}, {"depthwise_conv2d_transpose", op::conv2d_transpose}, {"dequantize_linear", op::dequantize_linear}, - {"dropout", op::dropout}, {"elementwise_add", op::elementwise_add}, {"elementwise_div", op::elementwise_div}, {"elementwise_floordiv", op::elementwise_floordiv}, - {"elementwise_max", op::elementwise_max}, - {"elementwise_min", op::elementwise_min}, {"elementwise_mod", op::elementwise_mod}, {"elementwise_mul", op::elementwise_mul}, - {"elementwise_pow", op::elementwise_pow}, + {"elementwise_max", op::elementwise_max}, + {"elementwise_min", op::elementwise_min}, {"elementwise_sub", op::elementwise_sub}, - {"equal", op::elementwise_equal}, + {"dropout", op::dropout}, + {"elementwise_pow", op::elementwise_pow}, + {"equal", op::equal}, {"exp", op::exp}, {"expand_v2", op::expand_v2}, {"fill_any_like", op::fill_any_like}, - {"fill_constant_batch_size_like", op::fill_constant_batch_size_like}, {"fill_constant", op::fill_constant}, + {"fill_constant_batch_size_like", op::fill_constant_batch_size_like}, {"flatten_contiguous_range", op::flatten_contiguous_range}, {"flip", op::flip}, {"floor", op::floor}, @@ -175,7 +175,7 @@ std::map get_supported_ops() { {"gather_nd", op::gather_nd}, {"gelu", op::gelu}, {"generate_proposals_v2", op::generate_proposals_v2}, - {"greater_equal", op::elementwise_greater_equal}, + {"greater_equal", op::greater_equal}, {"greater_than", op::greater_than}, {"grid_sampler", op::grid_sampler}, {"group_norm", op::group_norm}, @@ -202,7 +202,7 @@ std::map get_supported_ops() { {"multiclass_nms3", op::multiclass_nms}, {"nearest_interp_v2", op::nearest_interp_v2}, {"nearest_interp", op::nearest_interp_v2}, - {"not_equal", op::elementwise_not_equal}, + {"not_equal", op::not_equal}, {"one_hot_v2", op::one_hot_v2}, {"p_norm", op::p_norm}, {"pad3d", op::pad3d}, @@ -255,8 +255,7 @@ std::map get_supported_ops() { {"while", op::while_}, {"write_to_array", op::write_to_array}, {"where_index", op::where_index}, - {"yolo_box", op::yolo_box}, - {"generate_proposals_v2", op::generate_proposals_v2}}; + {"yolo_box", op::yolo_box}}; }; } // namespace paddle diff --git a/src/frontends/paddle/src/place.hpp b/src/frontends/paddle/src/place.hpp index fc2fe9eb29efe0..583d5191feab81 100644 --- a/src/frontends/paddle/src/place.hpp +++ b/src/frontends/paddle/src/place.hpp @@ -44,6 +44,10 @@ class Place : public ov::frontend::Place { return m_names; } + int64_t get_version() const { + return dynamic_cast(m_input_model).get_version(); + } + private: const ov::frontend::InputModel& m_input_model; std::vector m_names; diff --git a/src/frontends/paddle/src/proto/framework.proto b/src/frontends/paddle/src/proto/framework.proto index 22112cba29667d..cfcc10c6ee692f 100644 --- a/src/frontends/paddle/src/proto/framework.proto +++ b/src/frontends/paddle/src/proto/framework.proto @@ -41,8 +41,31 @@ enum AttrType { VAR = 13; VARS = 14; FLOAT64 = 15; + SCALAR = 16; + SCALARS = 17; } + +message Complex { + required double r = 1; + required double i = 2; +}; + +message Scalar { + enum Type { + BOOLEAN = 1; + LONG = 2; + FLOAT64 = 3; + COMPLEX128 = 4; + } + required Type type = 1; + + optional bool b = 2; + optional int64 i = 3; + optional double r = 4; + optional Complex c = 5; +}; + // OpDesc describes an instance of a C++ framework::OperatorBase // derived class type. message OpDesc { @@ -66,6 +89,8 @@ message OpDesc { optional string var_name = 17; repeated string vars_name = 18; optional double float64 = 19; + optional Scalar scalar = 20; + repeated Scalar scalars = 21; }; message Var { @@ -126,7 +151,7 @@ message VarType { FP16 = 4; FP32 = 5; FP64 = 6; - // Tensor is used in C++. + // phi::DenseTensor is used in C++. SIZE_T = 19; UINT8 = 20; INT8 = 21; diff --git a/src/frontends/paddle/tests/CMakeLists.txt b/src/frontends/paddle/tests/CMakeLists.txt index 6d373e67c0a663..078a133138aa45 100644 --- a/src/frontends/paddle/tests/CMakeLists.txt +++ b/src/frontends/paddle/tests/CMakeLists.txt @@ -21,9 +21,6 @@ else() set(paddlepaddle_FOUND ON) endif() -# PDPD 2.5.1 is not compatible with tests models we use -set(paddlepaddle_FOUND OFF) - if(paddlepaddle_FOUND) set(ctest_labels OV UNIT) endif() diff --git a/src/frontends/paddle/tests/op_fuzzy.cpp b/src/frontends/paddle/tests/op_fuzzy.cpp index 8487bed8827af3..d99862ceb69490 100644 --- a/src/frontends/paddle/tests/op_fuzzy.cpp +++ b/src/frontends/paddle/tests/op_fuzzy.cpp @@ -192,22 +192,21 @@ static const std::vector models{ std::string("flip_5"), std::string("flip_dynamic_1"), std::string("flip_dynamic_2"), - std::string("fill_any_like"), - std::string("fill_any_like_f16"), - std::string("fill_any_like_f32"), - std::string("fill_any_like_f64"), - std::string("fill_any_like_i16"), - std::string("fill_any_like_i32"), - std::string("fill_any_like_i64"), - std::string("fill_any_like_bool"), - std::string("fill_any_like_bool_2"), - std::string("fill_constant"), - std::string("fill_constant_batch_size_like"), - std::string("fill_constant_int32"), - std::string("fill_constant_int64"), - std::string("fill_constant_tensor"), - std::string("fill_constant_shape_tensor"), - std::string("fill_constant_shape_tensor_list"), + std::string("full_like"), + std::string("full_like_f16"), + std::string("full_like_f32"), + std::string("full_like_f64"), + std::string("full_like_i16"), + std::string("full_like_i32"), + std::string("full_like_i64"), + std::string("full_like_bool"), + std::string("full_like_bool_2"), + std::string("full"), + std::string("full_int32"), + std::string("full_int64"), + std::string("full_tensor"), + std::string("full_shape_tensor"), + std::string("full_shape_tensor_list"), std::string("flatten_contiguous_range_test1"), std::string("floor_float32"), std::string("floor_mod1"), @@ -244,7 +243,8 @@ static const std::vector models{ std::string("greater_than_int64"), std::string("grid_sampler_1"), std::string("grid_sampler_2"), - std::string("grid_sampler_dyn"), + // std::string("grid_sampler_3"), + // std::string("grid_sampler_dyn"), std::string("group_norm_1/group_norm_1.pdmodel"), std::string("group_norm_2/group_norm_2.pdmodel"), std::string("group_norm_3/group_norm_3.pdmodel"), @@ -282,15 +282,15 @@ static const std::vector models{ std::string("loop/loop.pdmodel"), std::string("loop_dyn/loop_dyn.pdmodel"), std::string("loop_dyn_x/loop_dyn_x.pdmodel"), - std::string("loop_if/loop_if.pdmodel"), - std::string("loop_if_loop/loop_if_loop.pdmodel"), - std::string("loop_if_loop_if/loop_if_loop_if.pdmodel"), - std::string("loop_if_loop_complex/loop_if_loop_complex.pdmodel"), + // std::string("loop_if/loop_if.pdmodel"), + // std::string("loop_if_loop/loop_if_loop.pdmodel"), + // std::string("loop_if_loop_if/loop_if_loop_if.pdmodel"), + // std::string("loop_if_loop_complex/loop_if_loop_complex.pdmodel"), // disabed due to slice could not produce full dynamic shape // std::string("loop_if_tensor_array/loop_if_tensor_array.pdmodel"), + // std::string("loop_x/loop_x.pdmodel"), std::string("loop_t/loop_t.pdmodel"), std::string("loop_tensor_array/loop_tensor_array.pdmodel"), - std::string("loop_x/loop_x.pdmodel"), std::string("matmul_xt/matmul_xt.pdmodel"), std::string("matmul_xt_yt/matmul_xt_yt.pdmodel"), std::string("matmul_yt/matmul_yt.pdmodel"), @@ -446,14 +446,6 @@ static const std::vector models{ std::string("reshape"), std::string("reshape_tensor"), std::string("reshape_tensor_list"), - std::string("reverse_static_1"), - std::string("reverse_static_2"), - std::string("reverse_static_3"), - std::string("reverse_static_4"), - std::string("reverse_dynamic_1"), - std::string("reverse_dynamic_2"), - std::string("reverse_dynamic_3"), - std::string("reverse_dynamic_4"), std::string("rnn_lstm_layer_1_bidirectional/rnn_lstm_layer_1_bidirectional.pdmodel"), std::string("rnn_lstm_layer_1_forward/rnn_lstm_layer_1_forward.pdmodel"), std::string("rnn_lstm_layer_2_bidirectional/rnn_lstm_layer_2_bidirectional.pdmodel"), diff --git a/src/frontends/paddle/tests/places.cpp b/src/frontends/paddle/tests/places.cpp index 17f0df7e2d7aed..655d3941d69a66 100644 --- a/src/frontends/paddle/tests/places.cpp +++ b/src/frontends/paddle/tests/places.cpp @@ -3,6 +3,8 @@ // #include +#include +#include #include #include "gtest/gtest.h" @@ -10,50 +12,42 @@ using namespace ov::frontend; -const std::string model_file = std::string(TEST_PADDLE_MODELS_DIRNAME) + "place_test_model/place_test_model.pdmodel"; - -/*** -model: - - [input] - | - [const] [const] [transpose] - \ | / - [ RNN (LSTM) ] - / | \ - [transpose] [scale_{1,2}] [relu_{0,1,2}] - | | | - [scale_0] [out_{1,2}] [scale_{3,4,5}] - | | - [out_1] [out_{3,4,5}] - -***/ - -std::vector tensor_names = { - "x", - "const_1.tmp_0", - "const_2.tmp_0", - "transpose_0.tmp_0", - "transpose_0.tmp_1", - "lstm_0.tmp_0", - "lstm_0._generated_var_0", - "lstm_0.tmp_3", - "lstm_0.tmp_1", - "lstm_0.tmp_2", - "transpose_1.tmp_0", - "transpose_1.tmp_1", - "relu_1.tmp_0", - "relu_2.tmp_0", - "relu_3.tmp_0", - "save_infer_model/scale_0.tmp_0", - "save_infer_model/scale_1.tmp_0", - "save_infer_model/scale_2.tmp_0", - "save_infer_model/scale_3.tmp_0", - "save_infer_model/scale_4.tmp_0", - "save_infer_model/scale_5.tmp_0", +const std::string model_file = FrontEndTestUtils::make_model_path(std::string(TEST_PADDLE_MODELS_DIRNAME) + + "place_test_model/place_test_model.pdmodel"); +const std::string vars_name_file = + FrontEndTestUtils::make_model_path(std::string(TEST_PADDLE_MODELS_DIRNAME) + "place_test_model/vars_name.txt"); +const std::string outputs_name_file = + FrontEndTestUtils::make_model_path(std::string(TEST_PADDLE_MODELS_DIRNAME) + "place_test_model/outputs_name.txt"); + +class Paddle_Places : public ::testing::Test { +protected: + void SetUp() override { + std::fstream name_file; + name_file.open(vars_name_file, std::ios::in); + if (name_file.is_open()) { + std::string name; + while (std::getline(name_file, name)) + tensor_names.push_back(name); + name_file.close(); + } else + FRONT_END_THROW("Can not open " + vars_name_file); + + std::fstream output_file; + output_file.open(outputs_name_file, std::ios::in); + if (output_file.is_open()) { + std::string name; + while (std::getline(output_file, name)) + output_names.push_back(name); + output_file.close(); + } else + FRONT_END_THROW("Can not open " + outputs_name_file); + } + + std::vector tensor_names; + std::vector output_names; }; -TEST(Paddle_Places, check_tensor_names) { +TEST_F(Paddle_Places, check_tensor_names) { auto fem = FrontEndManager(); FrontEnd::Ptr frontend; ASSERT_NO_THROW(frontend = fem.load_by_framework(PADDLE_FE)); @@ -66,7 +60,7 @@ TEST(Paddle_Places, check_tensor_names) { } } -TEST(Paddle_Places, check_input_outputs) { +TEST_F(Paddle_Places, check_input_outputs) { auto fem = FrontEndManager(); FrontEnd::Ptr frontend; ASSERT_NO_THROW(frontend = fem.load_by_framework(PADDLE_FE)); @@ -82,13 +76,6 @@ TEST(Paddle_Places, check_input_outputs) { auto tensor_place = input_model->get_place_by_tensor_name("x"); tensor_place->is_equal(inputs[0]); - std::vector output_names = {"save_infer_model/scale_0.tmp_0", - "save_infer_model/scale_1.tmp_0", - "save_infer_model/scale_2.tmp_0", - "save_infer_model/scale_3.tmp_0", - "save_infer_model/scale_4.tmp_0", - "save_infer_model/scale_5.tmp_0"}; - for (const auto& name : output_names) { const auto output_place = input_model->get_place_by_tensor_name(name); auto it = std::find_if(outputs.begin(), outputs.end(), [&output_place](const Place::Ptr& place) { @@ -99,7 +86,7 @@ TEST(Paddle_Places, check_input_outputs) { } // all existed in the model ops have "Out" port -TEST(Paddle_Places, check_out_port_of_all_ops) { +TEST_F(Paddle_Places, check_out_port_of_all_ops) { auto fem = FrontEndManager(); FrontEnd::Ptr frontend; ASSERT_NO_THROW(frontend = fem.load_by_framework(PADDLE_FE)); @@ -121,7 +108,7 @@ TEST(Paddle_Places, check_out_port_of_all_ops) { } } -TEST(Paddle_Places, check_in_out_ports_of_model_outputs) { +TEST_F(Paddle_Places, check_in_out_ports_of_model_outputs) { auto fem = FrontEndManager(); FrontEnd::Ptr frontend; ASSERT_NO_THROW(frontend = fem.load_by_framework(PADDLE_FE)); @@ -155,7 +142,7 @@ TEST(Paddle_Places, check_in_out_ports_of_model_outputs) { } } -TEST(Paddle_Places, check_source_target_tensors_of_model_outputs) { +TEST_F(Paddle_Places, check_source_target_tensors_of_model_outputs) { auto fem = FrontEndManager(); FrontEnd::Ptr frontend; ASSERT_NO_THROW(frontend = fem.load_by_framework(PADDLE_FE)); @@ -189,7 +176,7 @@ TEST(Paddle_Places, check_source_target_tensors_of_model_outputs) { } } -TEST(Paddle_Places, check_producing_consuming_ops_of_model_outputs) { +TEST_F(Paddle_Places, check_producing_consuming_ops_of_model_outputs) { auto fem = FrontEndManager(); FrontEnd::Ptr frontend; ASSERT_NO_THROW(frontend = fem.load_by_framework(PADDLE_FE)); @@ -224,7 +211,7 @@ TEST(Paddle_Places, check_producing_consuming_ops_of_model_outputs) { } // check data flow [ output port -> tensor -> input port ] -TEST(Paddle_Places, check_data_flow) { +TEST_F(Paddle_Places, check_data_flow) { auto fem = FrontEndManager(); FrontEnd::Ptr frontend; ASSERT_NO_THROW(frontend = fem.load_by_framework(PADDLE_FE)); @@ -263,7 +250,7 @@ TEST(Paddle_Places, check_data_flow) { // -> input_port_2 // -> input_port_N] // input_port, input_port_2, ... input_port_N are equal data -TEST(Paddle_Places, check_tensor_to_multiple_ports) { +TEST_F(Paddle_Places, check_tensor_to_multiple_ports) { auto fem = FrontEndManager(); FrontEnd::Ptr frontend; ASSERT_NO_THROW(frontend = fem.load_by_framework(PADDLE_FE)); @@ -289,7 +276,7 @@ TEST(Paddle_Places, check_tensor_to_multiple_ports) { } // consuming ops should be equal for tensor place and producing output port -TEST(Paddle_Places, check_consuming_ops) { +TEST_F(Paddle_Places, check_consuming_ops) { auto fem = FrontEndManager(); FrontEnd::Ptr frontend; ASSERT_NO_THROW(frontend = fem.load_by_framework(PADDLE_FE)); @@ -330,7 +317,7 @@ TEST(Paddle_Places, check_consuming_ops) { } } -TEST(Paddle_Places, check_consuming_ops_2) { +TEST_F(Paddle_Places, check_consuming_ops_2) { auto fem = FrontEndManager(); FrontEnd::Ptr frontend; ASSERT_NO_THROW(frontend = fem.load_by_framework(PADDLE_FE)); @@ -369,7 +356,7 @@ TEST(Paddle_Places, check_consuming_ops_2) { } } -TEST(Paddle_Places, check_producing_ops) { +TEST_F(Paddle_Places, check_producing_ops) { auto fem = FrontEndManager(); FrontEnd::Ptr frontend; ASSERT_NO_THROW(frontend = fem.load_by_framework(PADDLE_FE)); @@ -391,20 +378,13 @@ TEST(Paddle_Places, check_producing_ops) { } } -TEST(Paddle_Places, check_input_output_ports_dy_idx) { +TEST_F(Paddle_Places, check_input_output_ports_dy_idx) { auto fem = FrontEndManager(); FrontEnd::Ptr frontend; ASSERT_NO_THROW(frontend = fem.load_by_framework(PADDLE_FE)); InputModel::Ptr input_model; ASSERT_NO_THROW(input_model = frontend->load(FrontEndTestUtils::make_model_path(model_file))); - std::vector output_names = {"save_infer_model/scale_0.tmp_0", - "save_infer_model/scale_1.tmp_0", - "save_infer_model/scale_2.tmp_0", - "save_infer_model/scale_3.tmp_0", - "save_infer_model/scale_4.tmp_0", - "save_infer_model/scale_5.tmp_0"}; - for (const auto& tensor_name : output_names) { auto tensor_place = input_model->get_place_by_tensor_name(tensor_name); EXPECT_NE(tensor_place, nullptr); @@ -417,20 +397,13 @@ TEST(Paddle_Places, check_input_output_ports_dy_idx) { } } -TEST(Paddle_Places, check_ops_tensors_by_idx) { +TEST_F(Paddle_Places, check_ops_tensors_by_idx) { auto fem = FrontEndManager(); FrontEnd::Ptr frontend; ASSERT_NO_THROW(frontend = fem.load_by_framework(PADDLE_FE)); InputModel::Ptr input_model; ASSERT_NO_THROW(input_model = frontend->load(FrontEndTestUtils::make_model_path(model_file))); - std::vector output_names = {"save_infer_model/scale_0.tmp_0", - "save_infer_model/scale_1.tmp_0", - "save_infer_model/scale_2.tmp_0", - "save_infer_model/scale_3.tmp_0", - "save_infer_model/scale_4.tmp_0", - "save_infer_model/scale_5.tmp_0"}; - for (const auto& tensor_name : output_names) { auto tensor_place = input_model->get_place_by_tensor_name(tensor_name); EXPECT_NE(tensor_place, nullptr); diff --git a/src/frontends/paddle/tests/read_paddle_model_test.cpp b/src/frontends/paddle/tests/read_paddle_model_test.cpp index b362566f52af11..08beac86b67f24 100644 --- a/src/frontends/paddle/tests/read_paddle_model_test.cpp +++ b/src/frontends/paddle/tests/read_paddle_model_test.cpp @@ -20,8 +20,10 @@ #include "openvino/pass/serialize.hpp" TEST(Paddle_Reader_Tests, LoadModelMemoryToCore) { - auto model = std::string(TEST_PADDLE_MODELS_DIRNAME) + "conv2d_relu/conv2d_relu.pdmodel"; - auto param = std::string(TEST_PADDLE_MODELS_DIRNAME) + "conv2d_relu/conv2d_relu.pdiparams"; + auto model = + FrontEndTestUtils::make_model_path(std::string(TEST_PADDLE_MODELS_DIRNAME) + "conv2d_relu/conv2d_relu.pdmodel"); + auto param = FrontEndTestUtils::make_model_path(std::string(TEST_PADDLE_MODELS_DIRNAME) + + "conv2d_relu/conv2d_relu.pdiparams"); ov::Core core; auto read_file = [&](const std::string& file_name, size_t& size) { @@ -73,7 +75,7 @@ TEST(Paddle_Reader_Tests, LoadModelMemoryToCore) { } TEST(Paddle_Reader_Tests, ImportBasicModelToCore) { - auto model = std::string(TEST_PADDLE_MODELS_DIRNAME) + "relu/relu.pdmodel"; + auto model = FrontEndTestUtils::make_model_path(std::string(TEST_PADDLE_MODELS_DIRNAME) + "relu/relu.pdmodel"); ov::Core core; auto function = core.read_model(FrontEndTestUtils::make_model_path(model)); diff --git a/src/frontends/paddle/tests/skip_tests_config.cpp b/src/frontends/paddle/tests/skip_tests_config.cpp index 144e9d001ae276..c5ca1227a9a693 100644 --- a/src/frontends/paddle/tests/skip_tests_config.cpp +++ b/src/frontends/paddle/tests/skip_tests_config.cpp @@ -11,7 +11,8 @@ std::vector disabledTestPatterns() { return { #ifdef OPENVINO_STATIC_LIBRARY // Disable tests for static libraries - ".*FrontendLibCloseTest.*" + ".*FrontendLibCloseTest.*", #endif + ".*testUnloadLibBeforeDeletingDependentObject.*", }; } diff --git a/src/frontends/paddle/tests/test_models/gen_scripts/generate_2in_2out.py b/src/frontends/paddle/tests/test_models/gen_scripts/generate_2in_2out.py index 5d6cd952189692..54911ebdc59443 100644 --- a/src/frontends/paddle/tests/test_models/gen_scripts/generate_2in_2out.py +++ b/src/frontends/paddle/tests/test_models/gen_scripts/generate_2in_2out.py @@ -14,24 +14,45 @@ inp_blob1 = np.random.randn(1, 1, 3, 3).astype(np.float32) inp_blob2 = np.random.randn(1, 2, 3, 3).astype(np.float32) -x1 = fluid.data(name='inputX1', shape=[1, 1, 3, 3], dtype='float32') -x2 = fluid.data(name='inputX2', shape=[1, 2, 3, 3], dtype='float32') +if paddle.__version__ >= '2.0.0': + x1 = paddle.static.data(name='inputX1', shape=[1, 1, 3, 3], dtype='float32') + x2 = paddle.static.data(name='inputX2', shape=[1, 2, 3, 3], dtype='float32') +else: + x1 = fluid.data(name='inputX1', shape=[1, 1, 3, 3], dtype='float32') + x2 = fluid.data(name='inputX2', shape=[1, 2, 3, 3], dtype='float32') -conv2d1 = fluid.layers.conv2d(input=x1, num_filters=1, filter_size=(1, 1), stride=(1, 1), padding=(0, 0), +if paddle.__version__ >= '2.0.0': + conv2d1 = paddle.static.nn.conv2d(input=x1, num_filters=1, filter_size=(1, 1), stride=(1, 1), padding=(0, 0), + dilation=(1, 1), groups=1, bias_attr=False, name="conv2dX1") + + conv2d2 = paddle.static.nn.conv2d(input=x2, num_filters=1, filter_size=(1, 1), stride=(1, 1), padding=(0, 0), + dilation=(1, 1), groups=1, bias_attr=False, name="conv2dX2") + + add1 = paddle.add(conv2d1, conv2d2, name="add1.tmp_0") + + relu2a = paddle.nn.functional.relu(add1, name="relu2a") + relu2b = paddle.nn.functional.relu(add1, name="relu2b") + + add2 = paddle.add(relu2a, relu2b, name="add2.tmp_0") + + relu3a = paddle.nn.functional.relu(add2, name="relu3a") + relu3b = paddle.nn.functional.relu(add2, name="relu3b") +else: + conv2d1 = fluid.layers.conv2d(input=x1, num_filters=1, filter_size=(1, 1), stride=(1, 1), padding=(0, 0), dilation=(1, 1), groups=1, bias_attr=False, name="conv2dX1") -conv2d2 = fluid.layers.conv2d(input=x2, num_filters=1, filter_size=(1, 1), stride=(1, 1), padding=(0, 0), - dilation=(1, 1), groups=1, bias_attr=False, name="conv2dX2") + conv2d2 = fluid.layers.conv2d(input=x2, num_filters=1, filter_size=(1, 1), stride=(1, 1), padding=(0, 0), + dilation=(1, 1), groups=1, bias_attr=False, name="conv2dX2") -add1 = fluid.layers.elementwise_add(conv2d1, conv2d2, name="add1") + add1 = fluid.layers.elementwise_add(conv2d1, conv2d2, name="add1") -relu2a = fluid.layers.relu(add1, name="relu2a") -relu2b = fluid.layers.relu(add1, name="relu2b") + relu2a = fluid.layers.relu(add1, name="relu2a") + relu2b = fluid.layers.relu(add1, name="relu2b") -add2 = fluid.layers.elementwise_add(relu2a, relu2b, name="add2") + add2 = fluid.layers.elementwise_add(relu2a, relu2b, name="add2") -relu3a = fluid.layers.relu(add2, name="relu3a") -relu3b = fluid.layers.relu(add2, name="relu3b") + relu3a = fluid.layers.relu(add2, name="relu3a") + relu3b = fluid.layers.relu(add2, name="relu3b") exe = fluid.Executor(fluid.CPUPlace()) exe.run(fluid.default_startup_program()) diff --git a/src/frontends/paddle/tests/test_models/gen_scripts/generate_2in_2out_dynbatch.py b/src/frontends/paddle/tests/test_models/gen_scripts/generate_2in_2out_dynbatch.py index d3fc8c95207d0f..b49b4ad6e5d182 100644 --- a/src/frontends/paddle/tests/test_models/gen_scripts/generate_2in_2out_dynbatch.py +++ b/src/frontends/paddle/tests/test_models/gen_scripts/generate_2in_2out_dynbatch.py @@ -13,24 +13,44 @@ inp_blob1 = np.random.randn(1, 1, 3, 3).astype(np.float32) inp_blob2 = np.random.randn(1, 2, 3, 3).astype(np.float32) -x1 = fluid.data(name='inputX1', shape=[-1, 1, 3, 3], dtype='float32') -x2 = fluid.data(name='inputX2', shape=[-1, 2, 3, 3], dtype='float32') +if paddle.__version__ >= '2.0.0': + x1 = paddle.static.data(name='inputX1', shape=[-1, 1, 3, 3], dtype='float32') + x2 = paddle.static.data(name='inputX2', shape=[-1, 2, 3, 3], dtype='float32') -conv2d1 = fluid.layers.conv2d(input=x1, num_filters=1, filter_size=(1, 1), stride=(1, 1), padding=(0, 0), - dilation=(1, 1), groups=1, bias_attr=False, name="conv2dX1") + conv2d1 = paddle.static.nn.conv2d(input=x1, num_filters=1, filter_size=(1, 1), stride=(1, 1), padding=(0, 0), + dilation=(1, 1), groups=1, bias_attr=False, name="conv2dX1") -conv2d2 = fluid.layers.conv2d(input=x2, num_filters=1, filter_size=(1, 1), stride=(1, 1), padding=(0, 0), - dilation=(1, 1), groups=1, bias_attr=False, name="conv2dX2") + conv2d2 = paddle.static.nn.conv2d(input=x2, num_filters=1, filter_size=(1, 1), stride=(1, 1), padding=(0, 0), + dilation=(1, 1), groups=1, bias_attr=False, name="conv2dX2") -add1 = fluid.layers.elementwise_add(conv2d1, conv2d2, name="add1") + add1 = paddle.add(conv2d1, conv2d2, name="add1") -relu2a = fluid.layers.relu(add1, name="relu2a") -relu2b = fluid.layers.relu(add1, name="relu2b") + relu2a = paddle.nn.functional.relu(add1, name="relu2a") + relu2b = paddle.nn.functional.relu(add1, name="relu2b") -add2 = fluid.layers.elementwise_add(relu2a, relu2b, name="add2") + add2 = paddle.add(relu2a, relu2b, name="add2") -relu3a = fluid.layers.relu(add2, name="relu3a") -relu3b = fluid.layers.relu(add2, name="relu3b") + relu3a = paddle.nn.functional.relu(add2, name="relu3a") + relu3b = paddle.nn.functional.relu(add2, name="relu3b") +else: + x1 = fluid.data(name='inputX1', shape=[-1, 1, 3, 3], dtype='float32') + x2 = fluid.data(name='inputX2', shape=[-1, 2, 3, 3], dtype='float32') + + conv2d1 = fluid.layers.conv2d(input=x1, num_filters=1, filter_size=(1, 1), stride=(1, 1), padding=(0, 0), + dilation=(1, 1), groups=1, bias_attr=False, name="conv2dX1") + + conv2d2 = fluid.layers.conv2d(input=x2, num_filters=1, filter_size=(1, 1), stride=(1, 1), padding=(0, 0), + dilation=(1, 1), groups=1, bias_attr=False, name="conv2dX2") + + add1 = fluid.layers.elementwise_add(conv2d1, conv2d2, name="add1") + + relu2a = fluid.layers.relu(add1, name="relu2a") + relu2b = fluid.layers.relu(add1, name="relu2b") + + add2 = fluid.layers.elementwise_add(relu2a, relu2b, name="add2") + + relu3a = fluid.layers.relu(add2, name="relu3a") + relu3b = fluid.layers.relu(add2, name="relu3b") exe = fluid.Executor(fluid.CPUPlace()) exe.run(fluid.default_startup_program()) diff --git a/src/frontends/paddle/tests/test_models/gen_scripts/generate_clip.py b/src/frontends/paddle/tests/test_models/gen_scripts/generate_clip.py index 39979ee1d0787f..5fe76bf6a0e0a8 100644 --- a/src/frontends/paddle/tests/test_models/gen_scripts/generate_clip.py +++ b/src/frontends/paddle/tests/test_models/gen_scripts/generate_clip.py @@ -14,7 +14,10 @@ def clip(name: str, x, min, max): with paddle.static.program_guard(paddle.static.Program(), paddle.static.Program()): node_x = paddle.static.data(name='x', shape=x.shape, dtype='float32') - out = paddle.fluid.layers.clip(node_x, min=min, max=max) + if paddle.__version__ >= '2.0.0': + out = paddle.clip(node_x, min=min, max=max) + else: + out = paddle.fluid.layers.clip(node_x, min=min, max=max) cpu = paddle.static.cpu_places(1) exe = paddle.static.Executor(cpu[0]) diff --git a/src/frontends/paddle/tests/test_models/gen_scripts/generate_conv2d_relu.py b/src/frontends/paddle/tests/test_models/gen_scripts/generate_conv2d_relu.py index d28ed1d52fa366..ebd06b34e9002f 100644 --- a/src/frontends/paddle/tests/test_models/gen_scripts/generate_conv2d_relu.py +++ b/src/frontends/paddle/tests/test_models/gen_scripts/generate_conv2d_relu.py @@ -12,17 +12,26 @@ inp_blob = np.random.randn(1, 3, 4, 4).astype(np.float32) -x = fluid.data(name='xxx', shape=[1, 3, 4, 4], dtype='float32') -test_layer = fluid.layers.conv2d(input=x, num_filters=5, filter_size=(1, 1), stride=(1, 1), padding=(1, 1), +if paddle.__version__ >= '2.0.0': + x = paddle.static.data(name='xxx', shape=[1, 3, 4, 4], dtype='float32') + test_layer = paddle.static.nn.conv2d(input=x, num_filters=5, filter_size=(1, 1), stride=(1, 1), padding=(1, 1), + dilation=(1, 1), groups=1, bias_attr=False) +else: + x = fluid.data(name='xxx', shape=[1, 3, 4, 4], dtype='float32') + test_layer = fluid.layers.conv2d(input=x, num_filters=5, filter_size=(1, 1), stride=(1, 1), padding=(1, 1), dilation=(1, 1), groups=1, bias_attr=False) -relu = fluid.layers.relu(test_layer) +if paddle.__version__ >= '2.0.0': + relu = paddle.nn.functional.relu(test_layer) +else: + relu = fluid.layers.relu(test_layer) exe = fluid.Executor(fluid.CPUPlace()) exe.run(fluid.default_startup_program()) inp_dict = {'xxx': inp_blob} var = [relu] -res_paddle = exe.run(fluid.default_main_program(), fetch_list=var, feed=inp_dict) +res_paddle = exe.run(fluid.default_main_program(), + fetch_list=var, feed=inp_dict) -fluid.io.save_inference_model(os.path.join(sys.argv[1], "conv2d_relu"), list(inp_dict.keys()), var, exe, - model_filename="conv2d_relu.pdmodel", params_filename="conv2d_relu.pdiparams") +paddle.fluid.io.save_inference_model(os.path.join(sys.argv[1], "conv2d_relu"), list(inp_dict.keys()), var, exe, + model_filename="conv2d_relu.pdmodel", params_filename="conv2d_relu.pdiparams") diff --git a/src/frontends/paddle/tests/test_models/gen_scripts/generate_conv2d_s.py b/src/frontends/paddle/tests/test_models/gen_scripts/generate_conv2d_s.py index 2568bc6bfe217e..1463cb5a43e88a 100644 --- a/src/frontends/paddle/tests/test_models/gen_scripts/generate_conv2d_s.py +++ b/src/frontends/paddle/tests/test_models/gen_scripts/generate_conv2d_s.py @@ -11,15 +11,21 @@ inp_blob = np.random.randn(1, 3, 4, 4).astype(np.float32) -x = fluid.data(name='x', shape=[1, 3, 4, 4], dtype='float32') -test_layer = fluid.layers.conv2d(input=x, num_filters=5, filter_size=(1, 1), stride=(1, 1), padding=(1, 1), - dilation=(1, 1), groups=1, bias_attr=False) +if paddle.__version__ >= '2.0.0': + x = paddle.static.data(name='x', shape=[1, 3, 4, 4], dtype='float32') + test_layer = paddle.static.nn.conv2d(input=x, num_filters=5, filter_size=(1, 1), stride=(1, 1), padding=(1, 1), + dilation=(1, 1), groups=1, bias_attr=False) +else: + x = fluid.data(name='x', shape=[1, 3, 4, 4], dtype='float32') + test_layer = fluid.layers.conv2d(input=x, num_filters=5, filter_size=(1, 1), stride=(1, 1), padding=(1, 1), + dilation=(1, 1), groups=1, bias_attr=False) exe = fluid.Executor(fluid.CPUPlace()) exe.run(fluid.default_startup_program()) inp_dict = {'x': inp_blob} var = [test_layer] -res_paddle = exe.run(fluid.default_main_program(), fetch_list=var, feed=inp_dict) +res_paddle = exe.run(fluid.default_main_program(), + fetch_list=var, feed=inp_dict) -fluid.io.save_inference_model(os.path.join(sys.argv[1], "conv2d_s"), list(inp_dict.keys()), var, exe, - model_filename="conv2d.pdmodel", params_filename="conv2d.pdiparams") +paddle.fluid.io.save_inference_model(os.path.join(sys.argv[1], "conv2d_s"), list(inp_dict.keys()), var, exe, + model_filename="conv2d.pdmodel", params_filename="conv2d.pdiparams") diff --git a/src/frontends/paddle/tests/test_models/gen_scripts/generate_dynamic_pool2d.py b/src/frontends/paddle/tests/test_models/gen_scripts/generate_dynamic_pool2d.py index 515fec958ec6af..e967cd06d6d716 100644 --- a/src/frontends/paddle/tests/test_models/gen_scripts/generate_dynamic_pool2d.py +++ b/src/frontends/paddle/tests/test_models/gen_scripts/generate_dynamic_pool2d.py @@ -15,13 +15,21 @@ paddle.enable_static() inp_blob1 = np.random.randn(1, 1, 224, 224).astype(np.float32) -x1 = fluid.data(name='inputX1', shape=[1, 1, -1, -1], dtype='float32') - -adative_pool2d = paddle.fluid.layers.adaptive_pool2d( - input=x1, - pool_size=[3,3], - pool_type='avg', - require_index=False) +if paddle.__version__ >= '2.0.0': + x1 = paddle.static.data(name='inputX1', shape=[ + 1, 1, -1, -1], dtype='float32') + + adative_pool2d = paddle.nn.functional.adaptive_avg_pool2d( + x=x1, + output_size=[3, 3]) +else: + x1 = fluid.data(name='inputX1', shape=[1, 1, -1, -1], dtype='float32') + + adative_pool2d = paddle.fluid.layers.adaptive_pool2d( + input=x1, + pool_size=[3, 3], + pool_type='avg', + require_index=False) cpu = paddle.static.cpu_places(1) exe = paddle.static.Executor(cpu[0]) @@ -32,4 +40,5 @@ feed={'inputX1': inp_blob1}, fetch_list=[adative_pool2d]) -saveModel("pool2d_dyn_hw", exe, feedkeys=['inputX1'], fetchlist=adative_pool2d, inputs=[inp_blob1], outputs=outs, target_dir=sys.argv[1]) +saveModel("pool2d_dyn_hw", exe, feedkeys=['inputX1'], fetchlist=adative_pool2d, inputs=[ + inp_blob1], outputs=outs, target_dir=sys.argv[1]) diff --git a/src/frontends/paddle/tests/test_models/gen_scripts/generate_elementwise_ops.py b/src/frontends/paddle/tests/test_models/gen_scripts/generate_elementwise_ops.py index 844ff58b963413..37f556e298b74f 100644 --- a/src/frontends/paddle/tests/test_models/gen_scripts/generate_elementwise_ops.py +++ b/src/frontends/paddle/tests/test_models/gen_scripts/generate_elementwise_ops.py @@ -7,16 +7,21 @@ import numpy as np import sys from save_model import saveModel +import paddle -def elementwise_add(name : str, x, y, axis, in_dtype): +def elementwise_add(name: str, x, y, in_dtype, axis=-1): import paddle paddle.enable_static() with paddle.static.program_guard(paddle.static.Program(), paddle.static.Program()): node_x = paddle.static.data(name='x', shape=x.shape, dtype=in_dtype) node_y = paddle.static.data(name='y', shape=y.shape, dtype=in_dtype) - out = paddle.fluid.layers.nn.elementwise_add(node_x, node_y, axis=axis) + if paddle.__version__ >= '2.0.0': + out = paddle.add(node_x, node_y) + else: + out = paddle.fluid.layers.elementwise_add( + node_x, node_y, axis=axis) cpu = paddle.static.cpu_places(1) exe = paddle.static.Executor(cpu[0]) @@ -24,21 +29,26 @@ def elementwise_add(name : str, x, y, axis, in_dtype): # startup program will call initializer to initialize the parameters. exe.run(paddle.static.default_startup_program()) outs = exe.run( - feed={'x': x, 'y': y}, - fetch_list=[out]) - saveModel(name, exe, feedkeys=['x', 'y'], fetchlist=[out], inputs=[x, y], outputs=[outs[0]], target_dir=sys.argv[1]) + feed={'x': x, 'y': y}, + fetch_list=[out]) + saveModel(name, exe, feedkeys=['x', 'y'], fetchlist=[out], inputs=[ + x, y], outputs=[outs[0]], target_dir=sys.argv[1]) return outs[0] -def elementwise_sub(name : str, x, y, axis, in_dtype): +def elementwise_sub(name: str, x, y, in_dtype, axis=-1): import paddle paddle.enable_static() with paddle.static.program_guard(paddle.static.Program(), paddle.static.Program()): node_x = paddle.static.data(name='x', shape=x.shape, dtype=in_dtype) node_y = paddle.static.data(name='y', shape=y.shape, dtype=in_dtype) - out = paddle.fluid.layers.nn.elementwise_sub(node_x, node_y, axis=axis) + if paddle.__version__ >= '2.0.0': + out = paddle.subtract(node_x, node_y) + else: + out = paddle.fluid.layers.elementwise_sub( + node_x, node_y, axis=axis) cpu = paddle.static.cpu_places(1) exe = paddle.static.Executor(cpu[0]) @@ -46,21 +56,26 @@ def elementwise_sub(name : str, x, y, axis, in_dtype): # startup program will call initializer to initialize the parameters. exe.run(paddle.static.default_startup_program()) outs = exe.run( - feed={'x': x, 'y': y}, - fetch_list=[out]) - saveModel(name, exe, feedkeys=['x', 'y'], fetchlist=[out], inputs=[x, y], outputs=[outs[0]], target_dir=sys.argv[1]) + feed={'x': x, 'y': y}, + fetch_list=[out]) + saveModel(name, exe, feedkeys=['x', 'y'], fetchlist=[out], inputs=[ + x, y], outputs=[outs[0]], target_dir=sys.argv[1]) return outs[0] -def elementwise_div(name : str, x, y, axis, in_dtype): +def elementwise_div(name: str, x, y, in_dtype, axis=-1): import paddle paddle.enable_static() with paddle.static.program_guard(paddle.static.Program(), paddle.static.Program()): - node_x = paddle.static.data(name = 'x', shape = x.shape, dtype = in_dtype) - node_y = paddle.static.data(name = 'y', shape = y.shape, dtype = in_dtype) - out = paddle.fluid.layers.nn.elementwise_div(node_x, node_y, axis=axis) + node_x = paddle.static.data(name='x', shape=x.shape, dtype=in_dtype) + node_y = paddle.static.data(name='y', shape=y.shape, dtype=in_dtype) + if paddle.__version__ >= '2.0.0': + out = paddle.divide(node_x, node_y) + else: + out = paddle.fluid.layers.elementwise_div( + node_x, node_y, axis=axis) cpu = paddle.static.cpu_places(1) exe = paddle.static.Executor(cpu[0]) @@ -68,24 +83,29 @@ def elementwise_div(name : str, x, y, axis, in_dtype): # startup program will call initializer to initialize the parameters. exe.run(paddle.static.default_startup_program()) outs = exe.run( - feed={'x': x, 'y': y}, - fetch_list=[out]) - saveModel(name, exe, feedkeys=['x', 'y'], fetchlist=[out], inputs=[x, y], outputs=[outs[0]], target_dir=sys.argv[1]) + feed={'x': x, 'y': y}, + fetch_list=[out]) + saveModel(name, exe, feedkeys=['x', 'y'], fetchlist=[out], inputs=[ + x, y], outputs=[outs[0]], target_dir=sys.argv[1]) return outs[0] -def elementwise_mod(name : str, x, y, axis, in_dtype, is_api=False): +def elementwise_mod(name: str, x, y, in_dtype, is_api=False, axis=-1): import paddle paddle.enable_static() with paddle.static.program_guard(paddle.static.Program(), paddle.static.Program()): node_x = paddle.static.data(name='x', shape=x.shape, dtype=in_dtype) node_y = paddle.static.data(name='y', shape=y.shape, dtype=in_dtype) - if is_api: + if paddle.__version__ >= '2.0.0': out = paddle.floor_mod(node_x, node_y) else: - out = paddle.fluid.layers.elementwise_mod(node_x, node_y, axis=axis) + if is_api: + out = paddle.floor_mod(node_x, node_y) + else: + out = paddle.fluid.layers.elementwise_mod( + node_x, node_y, axis=axis) cpu = paddle.static.cpu_places(1) exe = paddle.static.Executor(cpu[0]) @@ -93,21 +113,26 @@ def elementwise_mod(name : str, x, y, axis, in_dtype, is_api=False): # startup program will call initializer to initialize the parameters. exe.run(paddle.static.default_startup_program()) outs = exe.run( - feed={'x': x, 'y': y}, - fetch_list=[out]) - saveModel(name, exe, feedkeys=['x', 'y'], fetchlist=[out], inputs=[x, y], outputs=[outs[0]], target_dir=sys.argv[1]) + feed={'x': x, 'y': y}, + fetch_list=[out]) + saveModel(name, exe, feedkeys=['x', 'y'], fetchlist=[out], inputs=[ + x, y], outputs=[outs[0]], target_dir=sys.argv[1]) return outs[0] -def elementwise_mul(name : str, x, y, axis, in_dtype): +def elementwise_mul(name: str, x, y, in_dtype, axis=-1): import paddle paddle.enable_static() with paddle.static.program_guard(paddle.static.Program(), paddle.static.Program()): - node_x = paddle.static.data(name = 'x', shape = x.shape, dtype = in_dtype) - node_y = paddle.static.data(name = 'y', shape = y.shape, dtype = in_dtype) - out = paddle.fluid.layers.nn.elementwise_mul(node_x, node_y, axis=axis) + node_x = paddle.static.data(name='x', shape=x.shape, dtype=in_dtype) + node_y = paddle.static.data(name='y', shape=y.shape, dtype=in_dtype) + if paddle.__version__ >= '2.0.0': + out = paddle.multiply(node_x, node_y) + else: + out = paddle.fluid.layers.elementwise_mul( + node_x, node_y, axis=axis) cpu = paddle.static.cpu_places(1) exe = paddle.static.Executor(cpu[0]) @@ -115,19 +140,21 @@ def elementwise_mul(name : str, x, y, axis, in_dtype): # startup program will call initializer to initialize the parameters. exe.run(paddle.static.default_startup_program()) outs = exe.run( - feed={'x': x, 'y': y}, - fetch_list=[out]) - saveModel(name, exe, feedkeys=['x', 'y'], fetchlist=[out], inputs=[x, y], outputs=[outs[0]], target_dir=sys.argv[1]) + feed={'x': x, 'y': y}, + fetch_list=[out]) + saveModel(name, exe, feedkeys=['x', 'y'], fetchlist=[out], inputs=[ + x, y], outputs=[outs[0]], target_dir=sys.argv[1]) return outs[0] -def elementwise_mul_bool(name : str, x, y, in_dtype='bool'): + +def elementwise_mul_bool(name: str, x, y, in_dtype='bool'): import paddle paddle.enable_static() with paddle.static.program_guard(paddle.static.Program(), paddle.static.Program()): - node_x = paddle.static.data(name = 'x', shape = x.shape, dtype = in_dtype) - node_y = paddle.static.data(name = 'y', shape = y.shape, dtype = in_dtype) + node_x = paddle.static.data(name='x', shape=x.shape, dtype=in_dtype) + node_y = paddle.static.data(name='y', shape=y.shape, dtype=in_dtype) mul = node_x * node_y out = paddle.cast(mul, 'float32') @@ -137,21 +164,26 @@ def elementwise_mul_bool(name : str, x, y, in_dtype='bool'): # startup program will call initializer to initialize the parameters. exe.run(paddle.static.default_startup_program()) outs = exe.run( - feed={'x': x, 'y': y}, - fetch_list=[out]) - saveModel(name, exe, feedkeys=['x', 'y'], fetchlist=[out], inputs=[x, y], outputs=[outs[0]], target_dir=sys.argv[1]) + feed={'x': x, 'y': y}, + fetch_list=[out]) + saveModel(name, exe, feedkeys=['x', 'y'], fetchlist=[out], inputs=[ + x, y], outputs=[outs[0]], target_dir=sys.argv[1]) return outs[0] -def elementwise_min(name : str, x, y, axis, in_dtype): +def elementwise_min(name: str, x, y, in_dtype, axis=-1): import paddle paddle.enable_static() with paddle.static.program_guard(paddle.static.Program(), paddle.static.Program()): - node_x = paddle.static.data(name = 'x', shape = x.shape, dtype = in_dtype) - node_y = paddle.static.data(name = 'y', shape = y.shape, dtype = in_dtype) - out = paddle.fluid.layers.nn.elementwise_min(node_x, node_y, axis=axis) + node_x = paddle.static.data(name='x', shape=x.shape, dtype=in_dtype) + node_y = paddle.static.data(name='y', shape=y.shape, dtype=in_dtype) + if paddle.__version__ >= '2.0.0': + out = paddle.minimum(node_x, node_y) + else: + out = paddle.fluid.layers.elementwise_min( + node_x, node_y, axis=axis) cpu = paddle.static.cpu_places(1) exe = paddle.static.Executor(cpu[0]) @@ -161,19 +193,24 @@ def elementwise_min(name : str, x, y, axis, in_dtype): outs = exe.run( feed={'x': x, 'y': y}, fetch_list=[out]) - saveModel(name, exe, feedkeys=['x', 'y'], fetchlist=[out], inputs=[x, y], outputs=[outs[0]], target_dir=sys.argv[1]) + saveModel(name, exe, feedkeys=['x', 'y'], fetchlist=[out], inputs=[ + x, y], outputs=[outs[0]], target_dir=sys.argv[1]) return outs[0] -def elementwise_max(name : str, x, y, axis, in_dtype): +def elementwise_max(name: str, x, y, in_dtype, axis=-1): import paddle paddle.enable_static() with paddle.static.program_guard(paddle.static.Program(), paddle.static.Program()): - node_x = paddle.static.data(name = 'x', shape = x.shape, dtype = in_dtype) - node_y = paddle.static.data(name = 'y', shape = y.shape, dtype = in_dtype) - out = paddle.fluid.layers.nn.elementwise_max(node_x, node_y, axis=axis) + node_x = paddle.static.data(name='x', shape=x.shape, dtype=in_dtype) + node_y = paddle.static.data(name='y', shape=y.shape, dtype=in_dtype) + if paddle.__version__ >= '2.0.0': + out = paddle.maximum(node_x, node_y) + else: + out = paddle.fluid.layers.elementwise_max( + node_x, node_y, axis=axis) cpu = paddle.static.cpu_places(1) exe = paddle.static.Executor(cpu[0]) @@ -183,19 +220,24 @@ def elementwise_max(name : str, x, y, axis, in_dtype): outs = exe.run( feed={'x': x, 'y': y}, fetch_list=[out]) - saveModel(name, exe, feedkeys=['x', 'y'], fetchlist=[out], inputs=[x, y], outputs=[outs[0]], target_dir=sys.argv[1]) + saveModel(name, exe, feedkeys=['x', 'y'], fetchlist=[out], inputs=[ + x, y], outputs=[outs[0]], target_dir=sys.argv[1]) return outs[0] -def elementwise_pow(name : str, x, y, axis, in_dtype): +def elementwise_pow(name: str, x, y, in_dtype, axis=-1): import paddle paddle.enable_static() with paddle.static.program_guard(paddle.static.Program(), paddle.static.Program()): - node_x = paddle.static.data(name = 'x', shape = x.shape, dtype = in_dtype) - node_y = paddle.static.data(name = 'y', shape = y.shape, dtype = in_dtype) - out = paddle.fluid.layers.nn.elementwise_pow(node_x, node_y, axis=axis) + node_x = paddle.static.data(name='x', shape=x.shape, dtype=in_dtype) + node_y = paddle.static.data(name='y', shape=y.shape, dtype=in_dtype) + if paddle.__version__ >= '2.0.0': + out = paddle.pow(node_x, node_y) + else: + out = paddle.fluid.layers.elementwise_pow( + node_x, node_y, axis=axis) cpu = paddle.static.cpu_places(1) exe = paddle.static.Executor(cpu[0]) @@ -205,24 +247,24 @@ def elementwise_pow(name : str, x, y, axis, in_dtype): outs = exe.run( feed={'x': x, 'y': y}, fetch_list=[out]) - saveModel(name, exe, feedkeys=['x', 'y'], fetchlist=[out], inputs=[x, y], outputs=[outs[0]], target_dir=sys.argv[1]) + saveModel(name, exe, feedkeys=['x', 'y'], fetchlist=[out], inputs=[ + x, y], outputs=[outs[0]], target_dir=sys.argv[1]) return outs[0] -def elementwise_floordiv(name : str, x, y, axis, in_dtype): +def elementwise_floordiv(name: str, x, y, in_dtype, axis=-1): import paddle paddle.enable_static() with paddle.static.program_guard(paddle.static.Program(), paddle.static.Program()): - node_x = paddle.static.data(name = 'x', shape = x.shape, dtype = in_dtype) - node_y = paddle.static.data(name = 'y', shape = y.shape, dtype = in_dtype) - if paddle.__version__ == "1.8": - out = paddle.fluid.layers.nn.elementwise_floordiv(node_x, node_y, axis=axis) - else: - if axis != -1: - pass + node_x = paddle.static.data(name='x', shape=x.shape, dtype=in_dtype) + node_y = paddle.static.data(name='y', shape=y.shape, dtype=in_dtype) + if paddle.__version__ >= '2.0.0': out = paddle.floor_divide(node_x, node_y) + else: + out = paddle.fluid.layers.nn.elementwise_floordiv( + node_x, node_y, axis=axis) cpu = paddle.static.cpu_places(1) exe = paddle.static.Executor(cpu[0]) @@ -232,20 +274,21 @@ def elementwise_floordiv(name : str, x, y, axis, in_dtype): outs = exe.run( feed={'x': x, 'y': y}, fetch_list=[out]) - saveModel(name, exe, feedkeys=['x', 'y'], fetchlist=[out], inputs=[x, y], outputs=[outs[0]], target_dir=sys.argv[1]) + saveModel(name, exe, feedkeys=['x', 'y'], fetchlist=[out], inputs=[ + x, y], outputs=[outs[0]], target_dir=sys.argv[1]) return outs[0] -def elementwise_ops(name : str, data_x, data_y, axis, in_dtype): - elementwise_add("elementwise_add" + name, data_x, data_y, axis, in_dtype) - elementwise_sub("elementwise_sub" + name, data_x, data_y, axis, in_dtype) - elementwise_div("elementwise_div" + name, data_x, data_y, axis, in_dtype) - elementwise_mod("elementwise_mod" + name, data_x, data_y, axis, in_dtype) - elementwise_mul("elementwise_mul" + name, data_x, data_y, axis, in_dtype) - elementwise_min("elementwise_min" + name, data_x, data_y, axis, in_dtype) - elementwise_max("elementwise_max" + name, data_x, data_y, axis, in_dtype) - elementwise_pow("elementwise_pow" + name, data_x, data_y, axis, in_dtype) +def elementwise_ops(name: str, data_x, data_y, in_dtype, axis=-1): + elementwise_add("elementwise_add" + name, data_x, data_y, in_dtype, axis) + elementwise_sub("elementwise_sub" + name, data_x, data_y, in_dtype, axis) + elementwise_div("elementwise_div" + name, data_x, data_y, in_dtype, axis) + elementwise_mod("elementwise_mod" + name, data_x, data_y, in_dtype, axis) + elementwise_mul("elementwise_mul" + name, data_x, data_y, in_dtype, axis) + elementwise_min("elementwise_min" + name, data_x, data_y, in_dtype, axis) + elementwise_max("elementwise_max" + name, data_x, data_y, in_dtype, axis) + elementwise_pow("elementwise_pow" + name, data_x, data_y, in_dtype, axis) def main(): @@ -253,52 +296,56 @@ def main(): in_dtype = 'float32' data_x = np.array([2, 3, 4]).astype(in_dtype) data_y = np.array([1, 5, 2]).astype(in_dtype) - axis = -1 - elementwise_ops("1", data_x, data_y, axis, in_dtype) - elementwise_mod('floor_mod1', data_x, data_y, -1, in_dtype, True) + elementwise_ops("1", data_x, data_y, in_dtype) + elementwise_mod('floor_mod1', data_x, data_y, in_dtype, True) # data_y's shape is the continuous subsequence of data_x's shape data_x = np.random.rand(2, 5, 3, 4).astype(np.float32) data_y = (0.1 + np.random.rand(3, 4).astype(np.float32)) / 1.1 - elementwise_ops("2", data_x, data_y, axis, in_dtype) - elementwise_mod('floor_mod2', data_x, data_y, -1, in_dtype, True) + elementwise_ops("2", data_x, data_y, in_dtype) + elementwise_mod('floor_mod2', data_x, data_y, in_dtype, True) + + data_y = (0.1 + np.random.rand(4).astype(np.float32)) / 1.1 - data_y = (0.1 + np.random.rand(5).astype(np.float32)) / 1.1 - axis = 1 - elementwise_ops("3", data_x, data_y, axis, in_dtype) + if paddle.__version__ >= '2.0.0': + elementwise_ops("3", data_x, data_y, in_dtype) + else: + elementwise_ops("3", data_x, data_y, in_dtype, 1) - data_y = (0.1 + np.random.rand(2, 5, 3).astype(np.float32)) / 1.1 - axis = 0 - elementwise_ops("4", data_x, data_y, axis, in_dtype) + data_y = (0.1 + np.random.rand(5, 3, 4).astype(np.float32)) / 1.1 + if paddle.__version__ >= '2.0.0': + elementwise_ops("4", data_x, data_y, in_dtype) + else: + elementwise_ops("4", data_x, data_y, in_dtype, 0) # test for elementwise_floordiv, support int and int64 # paddle1.8 support axis = [0, x_last_dims] # paddle2.x only support axis = -1 floordiv_support_dtype = ['int64', 'int32'] data_x = np.array([-4, 0, -8]) - + data_y = np.array([3, 5, 3]) - axis = -1 for dtype in floordiv_support_dtype: - elementwise_floordiv("elementwise_floordiv_" + dtype + "_1", - data_x.astype(dtype), data_y.astype(dtype), axis, dtype) + elementwise_floordiv("elementwise_floordiv_" + dtype + "_1", + data_x.astype(dtype), data_y.astype(dtype), dtype) data_x = np.random.randint(-10, 10, [2, 5, 3, 4]) data_y = np.random.randint(1, 5, [3, 4]) for dtype in floordiv_support_dtype: - elementwise_floordiv("elementwise_floordiv_" + dtype + "_2", - data_x.astype(dtype), data_y.astype(dtype), axis, dtype) + elementwise_floordiv("elementwise_floordiv_" + dtype + "_2", + data_x.astype(dtype), data_y.astype(dtype), dtype) data_y = np.random.randint(1, 5, [5, 3, 4]) for dtype in floordiv_support_dtype: - elementwise_floordiv("elementwise_floordiv_" + dtype + "_3", - data_x.astype(dtype), data_y.astype(dtype), axis, dtype) + elementwise_floordiv("elementwise_floordiv_" + dtype + "_3", + data_x.astype(dtype), data_y.astype(dtype), dtype) # test for elementwise_mul with bool data type sample_arr = [True, False] - data_x = np.random.choice(sample_arr, size=(2,3,4)) - data_y = np.random.choice(sample_arr, size=(1,3,4)) + data_x = np.random.choice(sample_arr, size=(2, 3, 4)) + data_y = np.random.choice(sample_arr, size=(1, 3, 4)) elementwise_mul_bool("elementwise_mul_bool1", data_x, data_y) + if __name__ == "__main__": main() diff --git a/src/frontends/paddle/tests/test_models/gen_scripts/generate_embedding.py b/src/frontends/paddle/tests/test_models/gen_scripts/generate_embedding.py index 1808a613f5d142..576c08b2b87a1d 100644 --- a/src/frontends/paddle/tests/test_models/gen_scripts/generate_embedding.py +++ b/src/frontends/paddle/tests/test_models/gen_scripts/generate_embedding.py @@ -6,9 +6,10 @@ # for lookup_table_v2 # https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/nn/Embedding_cn.html#embedding # equal to "gather" -# +# import numpy as np import sys +import paddle from save_model import saveModel @@ -21,21 +22,22 @@ def ov_embedding(ids, vocab_embeddings, vocab_size, embedding_dim, padding_idx, from openvino import Core if vocab_embeddings is None: - # - vocab_embeddings = np.zeros((vocab_size, embedding_dim)).astype("float32") + # + vocab_embeddings = np.zeros( + (vocab_size, embedding_dim)).astype("float32") node_ids = opset8.parameter(shape=ids.shape, name='ids', dtype=ids.dtype) node_w = opset8.parameter(shape=vocab_embeddings.shape, name='w', dtype=vocab_embeddings.dtype) if padding_idx == -1: padding_idx += vocab_size - + if padding_idx is not None: ''' mask W ''' masked_embeddings = np.ones(vocab_embeddings.shape, dtype='int64') - masked_embeddings[padding_idx,:] = 0 # mask + masked_embeddings[padding_idx, :] = 0 # mask node_mask = opset8.constant(masked_embeddings, name='mask', dtype=vocab_embeddings.dtype) node_masked_w = opset8.multiply(node_w, node_mask) @@ -56,21 +58,24 @@ def ov_embedding(ids, vocab_embeddings, vocab_size, embedding_dim, padding_idx, return output -def embedding(name : str, ids, vocab_size, embedding_dim, padding_idx=None, sparse=False, vocab_embeddings=None, compare=False): + +def embedding(name: str, ids, vocab_size, embedding_dim, padding_idx=None, sparse=False, vocab_embeddings=None, compare=False): """ padding_idx (int|long|None) """ - import paddle paddle.enable_static() with paddle.static.program_guard(paddle.static.Program(), paddle.static.Program()): - node_ids = paddle.static.data(name = 'Ids', shape = ids.shape, dtype = ids.dtype) + node_ids = paddle.static.data( + name='Ids', shape=ids.shape, dtype=ids.dtype) pretrained_attr = paddle.ParamAttr(name='W', - initializer=paddle.nn.initializer.Assign(vocab_embeddings), - trainable=False) if vocab_embeddings is not None else None + initializer=paddle.nn.initializer.Assign( + vocab_embeddings), + trainable=False) if vocab_embeddings is not None else None - node_embedding = paddle.nn.Embedding(num_embeddings=vocab_size, embedding_dim=embedding_dim, padding_idx=padding_idx, sparse=sparse, weight_attr=pretrained_attr, name=name) + node_embedding = paddle.nn.Embedding(num_embeddings=vocab_size, embedding_dim=embedding_dim, + padding_idx=padding_idx, sparse=sparse, weight_attr=pretrained_attr, name=name) node_out = node_embedding(node_ids) cpu = paddle.static.cpu_places(1) @@ -78,15 +83,16 @@ def embedding(name : str, ids, vocab_size, embedding_dim, padding_idx=None, spar # startup program will call initializer to initialize the parameters. exe.run(paddle.static.default_startup_program()) - + input_dict = {'Ids': ids} output_vars_list = [node_out] infer_results = exe.run( - feed=input_dict, - fetch_list=output_vars_list ) + feed=input_dict, + fetch_list=output_vars_list) - saveModel(name, exe, feedkeys=[node_ids], fetchlist=output_vars_list, inputs=list(input_dict.values()), outputs=infer_results, target_dir=sys.argv[1], use_static_api=True) + saveModel(name, exe, feedkeys=[node_ids], fetchlist=output_vars_list, inputs=list( + input_dict.values()), outputs=infer_results, target_dir=sys.argv[1], use_static_api=True) # outputs = dict() @@ -98,30 +104,29 @@ def embedding(name : str, ids, vocab_size, embedding_dim, padding_idx=None, spar ng_result = ov_embedding(ids, vocab_embeddings, vocab_size, embedding_dim, padding_idx, sparse) ng_result = list(ng_result.values())[0] paddle_result = list(outputs.values())[0] - + match = np.all(np.isclose( paddle_result, ng_result, rtol=1e-4, atol=1e-5)) prefix_color = '\n\033[92m' if match else '\n\033[91m' - print(prefix_color + - 'TestCase {} Result {} '.format(name, match) + '\033[0m\n') + print(prefix_color + + 'TestCase {} Result {} '.format(name, match) + '\033[0m\n') if not match: np.set_printoptions(precision=2) np.set_printoptions(suppress=True) - print(prefix_color + - 'paddle_result: {}'.format(paddle_result) + '\033[0m\n') - print(prefix_color + - 'ng_result: {}'.format(ng_result) + '\033[0m\n') + print(prefix_color + + 'paddle_result: {}'.format(paddle_result) + '\033[0m\n') + print(prefix_color + + 'ng_result: {}'.format(ng_result) + '\033[0m\n') raise ValueError(name + ': OV result does not match paddle!') return outputs - + if __name__ == "__main__": - import paddle.compat as cpt vocab_size = 17 embedding_dim = 31 @@ -129,42 +134,55 @@ def embedding(name : str, ids, vocab_size, embedding_dim, padding_idx=None, spar # ids = np.random.randint(0, vocab_size, 4).astype("int32") - embedding("embedding_0", ids, vocab_size, embedding_dim, vocab_embeddings=table, compare=False) + embedding("embedding_0", ids, vocab_size, embedding_dim, + vocab_embeddings=table, compare=False) # ids = np.random.randint(0, vocab_size, 4).astype("int32") - embedding("embedding_sparse", ids, vocab_size, embedding_dim, sparse=True, vocab_embeddings=table, compare=False) + embedding("embedding_sparse", ids, vocab_size, embedding_dim, + sparse=True, vocab_embeddings=table, compare=False) # # compare fail ids = np.random.randint(0, vocab_size, 4).astype("int32") - embedding("embedding_none_weight", ids, vocab_size, embedding_dim, compare=False) + embedding("embedding_none_weight", ids, + vocab_size, embedding_dim, compare=False) # ids = np.random.randint(0, vocab_size, 4).astype("int32") ids = np.squeeze(ids) padding_idx = np.random.choice(ids, 1)[0] # print('padding_idx {}, ids {}'.format(padding_idx, ids)) - outputs = embedding("embedding_paddings", ids, vocab_size, embedding_dim, padding_idx=int(padding_idx), vocab_embeddings=table, compare=False) + outputs = embedding("embedding_paddings", ids, vocab_size, embedding_dim, padding_idx=int( + padding_idx), vocab_embeddings=table, compare=False) # print('outputs {}'.format(outputs)) # corner case ids = np.random.randint(0, vocab_size, 4).astype("int32") - pick = np.random.choice(4, 1)[0] # pick randomly to be max vacab_size -1 - ids[pick] = vocab_size-1 + pick = np.random.choice(4, 1)[0] # pick randomly to be max vacab_size -1 + ids[pick] = vocab_size - 1 padding_idx = -1 # print('padding_idx {}, ids {}'.format(padding_idx, ids)) - outputs = embedding("embedding_paddings_neg1", ids, vocab_size, embedding_dim, padding_idx=int(padding_idx), vocab_embeddings=table, compare=False) - # print('outputs {}'.format(outputs)) + outputs = embedding("embedding_paddings_neg1", ids, vocab_size, embedding_dim, + padding_idx=int(padding_idx), vocab_embeddings=table, compare=False) + # print('outputs {}'.format(outputs)) # - ids = np.random.randint(low=0, high=vocab_size, size=(2, 4, 5)).astype("int32") - embedding("embedding_tensorIds", ids, vocab_size, embedding_dim, vocab_embeddings=table, compare=False) - + ids = np.random.randint(low=0, high=vocab_size, + size=(2, 4, 5)).astype("int32") + embedding("embedding_tensorIds", ids, vocab_size, + embedding_dim, vocab_embeddings=table, compare=False) + # - ids = np.random.randint(low=0, high=vocab_size, size=(2, 4, 5)).astype("int32") + ids = np.random.randint(low=0, high=vocab_size, + size=(2, 4, 5)).astype("int32") flatten_idx = ids.flatten() padding_idx = np.random.choice(flatten_idx, 1)[0] # print('padding_idx {}'.format(padding_idx)) - outputs = embedding("embedding_tensorIds_paddings", ids, vocab_size, embedding_dim, padding_idx=cpt.long_type(padding_idx), vocab_embeddings=table, compare=False) - # print('outputs {}'.format(outputs)) - + + if paddle.__version__ >= '2.0.0': + outputs = embedding("embedding_tensorIds_paddings", ids, vocab_size, embedding_dim, + padding_idx=np.compat.long(padding_idx), vocab_embeddings=table, compare=False) + else: + import paddle.compat as cpt + outputs = embedding("embedding_tensorIds_paddings", ids, vocab_size, embedding_dim, + padding_idx=cpt.long_type(padding_idx), vocab_embeddings=table, compare=False) diff --git a/src/frontends/paddle/tests/test_models/gen_scripts/generate_exp.py b/src/frontends/paddle/tests/test_models/gen_scripts/generate_exp.py index 344351c9bc790f..e1bc08053b3be8 100644 --- a/src/frontends/paddle/tests/test_models/gen_scripts/generate_exp.py +++ b/src/frontends/paddle/tests/test_models/gen_scripts/generate_exp.py @@ -4,6 +4,8 @@ # # exp paddle model generator # + +import paddle import numpy as np from save_model import saveModel import sys @@ -15,7 +17,10 @@ def exp(name: str, x): with paddle.static.program_guard(paddle.static.Program(), paddle.static.Program()): node_x = paddle.static.data(name='x', shape=x.shape, dtype=x.dtype) - out = paddle.fluid.layers.exp(x=node_x) + if paddle.__version__ >= '2.0.0': + out = paddle.exp(x=node_x) + else: + out = paddle.fluid.layers.exp(x=node_x) cpu = paddle.static.cpu_places(1) exe = paddle.static.Executor(cpu[0]) # startup program will call initializer to initialize the parameters. diff --git a/src/frontends/paddle/tests/test_models/gen_scripts/generate_fill_constant.py b/src/frontends/paddle/tests/test_models/gen_scripts/generate_fill_constant.py deleted file mode 100644 index f1b2f250dd0345..00000000000000 --- a/src/frontends/paddle/tests/test_models/gen_scripts/generate_fill_constant.py +++ /dev/null @@ -1,100 +0,0 @@ -# Copyright (C) 2018-2023 Intel Corporation -# SPDX-License-Identifier: Apache-2.0 - -# -# fill_const paddle model generator -# -import numpy as np -from save_model import saveModel -import paddle -import sys - - -def fill_constant(name : str, shape : list, dtype, value): - paddle.enable_static() - with paddle.static.program_guard(paddle.static.Program(), paddle.static.Program()): - x1 = paddle.fluid.layers.fill_constant(shape=shape, value=value, dtype=dtype, name='fill_constant') - x2 = paddle.fluid.layers.fill_constant(shape=shape, value=value, dtype=dtype, name='fill_constant') - out = paddle.add(paddle.cast(x1, np.float32), paddle.cast(x2, np.float32)) - cpu = paddle.static.cpu_places(1) - exe = paddle.static.Executor(cpu[0]) - # startup program will call initializer to initialize the parameters. - exe.run(paddle.static.default_startup_program()) - - outs = exe.run( - fetch_list=[out]) - - saveModel(name, exe, feedkeys=[], fetchlist=[out], inputs=[], outputs=[outs[0]], target_dir=sys.argv[1]) - - return outs[0] - - -def fill_constant_tensor(name : str, shape : list, dtype, value): - paddle.enable_static() - with paddle.static.program_guard(paddle.static.Program(), paddle.static.Program()): - node_value = paddle.static.data(name='value', shape=[1], dtype=dtype) - x1 = paddle.fluid.layers.fill_constant(shape=shape, value=node_value, dtype=dtype, name='fill_constant1') - out = paddle.cast(x1, np.float32) - cpu = paddle.static.cpu_places(1) - exe = paddle.static.Executor(cpu[0]) - # startup program will call initializer to initialize the parameters. - exe.run(paddle.static.default_startup_program()) - - outs = exe.run( - feed={"value": value}, - fetch_list=[out]) - - saveModel(name, exe, feedkeys=["value"], fetchlist=[out], inputs=[np.array([value]).astype(dtype)], outputs=[outs[0]], target_dir=sys.argv[1]) - - return outs[0] - - -def fill_constant_shape_tensor(name : str, shape, dtype, value): - paddle.enable_static() - with paddle.static.program_guard(paddle.static.Program(), paddle.static.Program()): - node_shape = paddle.fluid.layers.fill_constant(shape=[2], value=shape, dtype='int32', name='shape') - x1 = paddle.fluid.layers.fill_constant(shape=node_shape, value=value, dtype=dtype, name='fill_constant') - out = paddle.cast(x1, np.float32) - cpu = paddle.static.cpu_places(1) - exe = paddle.static.Executor(cpu[0]) - # startup program will call initializer to initialize the parameters. - exe.run(paddle.static.default_startup_program()) - - outs = exe.run( - fetch_list=[out]) - - saveModel(name, exe, feedkeys=[], fetchlist=[out], inputs=[], outputs=[outs[0]], target_dir=sys.argv[1]) - - return outs[0] - - -def fill_constant_shape_tensor_list(name : str, shape: list, dtype, value): - paddle.enable_static() - with paddle.static.program_guard(paddle.static.Program(), paddle.static.Program()): - node_shape = paddle.fluid.layers.fill_constant(shape=[1], value=shape, dtype='int32', name='shape') - x1 = paddle.fluid.layers.fill_constant(shape=[2, node_shape], value=value, dtype=dtype, name='fill_constant') - out = paddle.cast(x1, np.float32) - cpu = paddle.static.cpu_places(1) - exe = paddle.static.Executor(cpu[0]) - # startup program will call initializer to initialize the parameters. - exe.run(paddle.static.default_startup_program()) - - outs = exe.run( - fetch_list=[out]) - - saveModel(name, exe, feedkeys=[], fetchlist=[out], inputs=[], outputs=[outs[0]], target_dir=sys.argv[1]) - - return outs[0] - - -def main(): - fill_constant("fill_constant", [2, 3, 4], 'float32', 0.03) - fill_constant("fill_constant_int32", [2, 3, 4], "int32", 2) - fill_constant("fill_constant_int64", [2, 3, 4], "int64", 4) - fill_constant_tensor("fill_constant_tensor", [2, 3, 4], 'float32', 0.05) - fill_constant_shape_tensor("fill_constant_shape_tensor", 2, 'float32', 0.05) - fill_constant_shape_tensor_list("fill_constant_shape_tensor_list", 2, 'float32', 0.05) - - -if __name__ == "__main__": - main() diff --git a/src/frontends/paddle/tests/test_models/gen_scripts/generate_fill_constant_batch_size_like.py b/src/frontends/paddle/tests/test_models/gen_scripts/generate_fill_constant_batch_size_like.py deleted file mode 100644 index 7701eba8121395..00000000000000 --- a/src/frontends/paddle/tests/test_models/gen_scripts/generate_fill_constant_batch_size_like.py +++ /dev/null @@ -1,42 +0,0 @@ -# Copyright (C) 2018-2023 Intel Corporation -# SPDX-License-Identifier: Apache-2.0 - -# -# fill_constant_batch_size_like paddle model generator -# -import numpy as np -from save_model import saveModel -import paddle -import sys - -data_type = 'float32' - -def fill_constant_batch_size_like(name : str, x, shape, dtype, value, input_dim_idx=0, output_dim_idx=0): - paddle.enable_static() - - with paddle.static.program_guard(paddle.static.Program(), paddle.static.Program()): - like = paddle.static.data(name='x', shape=x.shape, dtype = data_type) - out = paddle.fluid.layers.fill_constant_batch_size_like(input=like, shape=shape, \ - value=value, dtype=dtype, \ - output_dim_idx=output_dim_idx, input_dim_idx=input_dim_idx) - - cpu = paddle.static.cpu_places(1) - exe = paddle.static.Executor(cpu[0]) - # startup program will call initializer to initialize the parameters. - exe.run(paddle.static.default_startup_program()) - - outs = exe.run( - feed={'x': x}, - fetch_list=[out]) - - saveModel(name, exe, feedkeys=['x'], fetchlist=[out], inputs=[x], outputs=[outs[0]], target_dir=sys.argv[1]) - - return outs[0] - -def main(): - x = np.random.rand(4, 3, 2).astype(data_type) - fill_constant_batch_size_like("fill_constant_batch_size_like", \ - x, [1, -1, 3], data_type, 0.03, 2, 1) - -if __name__ == "__main__": - main() diff --git a/src/frontends/paddle/tests/test_models/gen_scripts/generate_full.py b/src/frontends/paddle/tests/test_models/gen_scripts/generate_full.py new file mode 100644 index 00000000000000..2bbcbaf7836e12 --- /dev/null +++ b/src/frontends/paddle/tests/test_models/gen_scripts/generate_full.py @@ -0,0 +1,118 @@ +# Copyright (C) 2018-2023 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +# +# fill_const paddle model generator +# +import numpy as np +from save_model import saveModel +import paddle +import sys + + +def full(name : str, shape : list, dtype, value): + paddle.enable_static() + with paddle.static.program_guard(paddle.static.Program(), paddle.static.Program()): + if paddle.__version__ >= '2.0.0': + x1 = paddle.full(shape=shape, fill_value=value, dtype=dtype, name='fill') + x2 = paddle.full(shape=shape, fill_value=value, dtype=dtype, name='fill') + else: + x1 = paddle.fluid.layers.fill_constant(shape=shape, value=value, dtype=dtype, name='fill_constant') + x2 = paddle.fluid.layers.fill_constant(shape=shape, value=value, dtype=dtype, name='fill_constant') + out = paddle.add(paddle.cast(x1, np.float32), paddle.cast(x2, np.float32)) + cpu = paddle.static.cpu_places(1) + exe = paddle.static.Executor(cpu[0]) + # startup program will call initializer to initialize the parameters. + exe.run(paddle.static.default_startup_program()) + + outs = exe.run( + fetch_list=[out]) + + saveModel(name, exe, feedkeys=[], fetchlist=[out], inputs=[], outputs=[outs[0]], target_dir=sys.argv[1]) + + return outs[0] + + +def full_tensor(name : str, shape : list, dtype, value): + paddle.enable_static() + with paddle.static.program_guard(paddle.static.Program(), paddle.static.Program()): + if paddle.__version__ >= '2.5.1': + node_value = paddle.static.data(name='value', shape=[], dtype=dtype) + x1 = paddle.full(shape=shape, fill_value=node_value, dtype=dtype, name='full1') + elif paddle.__version__ >= '2.0.0': + node_value = paddle.static.data(name='value', shape=[1], dtype=dtype) + x1 = paddle.full(shape=shape, fill_value=node_value, dtype=dtype, name='full1') + else: + node_value = paddle.static.data(name='value', shape=[1], dtype=dtype) + x1 = paddle.fluid.layers.fill_constant(shape=shape, value=node_value, dtype=dtype, name='fill_constant1') + out = paddle.cast(x1, np.float32) + cpu = paddle.static.cpu_places(1) + exe = paddle.static.Executor(cpu[0]) + # startup program will call initializer to initialize the parameters. + exe.run(paddle.static.default_startup_program()) + + outs = exe.run( + feed={"value": value}, + fetch_list=[out]) + + if paddle.__version__ >= '2.5.1': + saveModel(name, exe, feedkeys=["value"], fetchlist=[out], inputs=[np.array(value).astype(dtype)], outputs=[outs[0]], target_dir=sys.argv[1]) + else: + saveModel(name, exe, feedkeys=["value"], fetchlist=[out], inputs=[np.array([value]).astype(dtype)], outputs=[outs[0]], target_dir=sys.argv[1]) + + return outs[0] + + +def full_shape_tensor(name : str, shape, dtype, value): + paddle.enable_static() + with paddle.static.program_guard(paddle.static.Program(), paddle.static.Program()): + if paddle.__version__ >= '2.0.0': + node_shape = paddle.full(shape=[2], fill_value=shape, dtype='int32', name='shape') + x1 = paddle.full(shape=node_shape, fill_value=value, dtype=dtype, name='full') + else: + node_shape = paddle.fluid.layers.fill_constant(shape=[1], value=shape, dtype='int32', name='shape') + x1 = paddle.fluid.layers.fill_constant(shape=[2, node_shape], value=value, dtype=dtype, name='fill_constant') + out = paddle.cast(x1, np.float32) + cpu = paddle.static.cpu_places(1) + exe = paddle.static.Executor(cpu[0]) + # startup program will call initializer to initialize the parameters. + exe.run(paddle.static.default_startup_program()) + + outs = exe.run( + fetch_list=[out]) + + saveModel(name, exe, feedkeys=[], fetchlist=[out], inputs=[], outputs=[outs[0]], target_dir=sys.argv[1]) + + return outs[0] + + +def full_shape_tensor_list(name : str, shape: list, dtype, value): + paddle.enable_static() + with paddle.static.program_guard(paddle.static.Program(), paddle.static.Program()): + node_shape = paddle.full(shape=[1], fill_value=shape, dtype='int32', name='shape') + x1 = paddle.full(shape=[2, node_shape], fill_value=value, dtype=dtype, name='full') + out = paddle.cast(x1, np.float32) + cpu = paddle.static.cpu_places(1) + exe = paddle.static.Executor(cpu[0]) + # startup program will call initializer to initialize the parameters. + exe.run(paddle.static.default_startup_program()) + + outs = exe.run( + fetch_list=[out]) + + saveModel(name, exe, feedkeys=[], fetchlist=[out], inputs=[], outputs=[outs[0]], target_dir=sys.argv[1]) + + return outs[0] + + +def main(): + full("full", [2, 3, 4], 'float32', 0.03) + full("full_int32", [2, 3, 4], "int32", 2) + full("full_int64", [2, 3, 4], "int64", 4) + full_tensor("full_tensor", [2, 3, 4], 'float32', 0.05) + full_shape_tensor("full_shape_tensor", 2, 'float32', 0.05) + full_shape_tensor_list("full_shape_tensor_list", 2, 'float32', 0.05) + + +if __name__ == "__main__": + main() diff --git a/src/frontends/paddle/tests/test_models/gen_scripts/generate_fill_any_like.py b/src/frontends/paddle/tests/test_models/gen_scripts/generate_full_like.py similarity index 63% rename from src/frontends/paddle/tests/test_models/gen_scripts/generate_fill_any_like.py rename to src/frontends/paddle/tests/test_models/gen_scripts/generate_full_like.py index ab32b20a8e6898..71a2d634ba624a 100644 --- a/src/frontends/paddle/tests/test_models/gen_scripts/generate_fill_any_like.py +++ b/src/frontends/paddle/tests/test_models/gen_scripts/generate_full_like.py @@ -2,7 +2,7 @@ # SPDX-License-Identifier: Apache-2.0 # -# fill_any_like paddle model generator +# full_like paddle model generator # import numpy as np from save_model import saveModel @@ -11,7 +11,7 @@ data_type = 'float32' -def fill_any_like(name:str, x, value, dtype=None): +def full_like(name:str, x, value, dtype=None): paddle.enable_static() with paddle.static.program_guard(paddle.static.Program(), paddle.static.Program()): @@ -35,18 +35,18 @@ def fill_any_like(name:str, x, value, dtype=None): def main(): x = np.random.rand(8, 24, 32).astype(data_type) - fill_any_like("fill_any_like", x, 1.2) - fill_any_like("fill_any_like_f16", x, 1.0, dtype='float16') - fill_any_like("fill_any_like_f32", x, 1.2, dtype='float32') - fill_any_like("fill_any_like_f64", x, 1.2, dtype='float64') - fill_any_like("fill_any_like_i16", x, 3, dtype='int16') - fill_any_like("fill_any_like_i32", x, 2, dtype='int32') - fill_any_like("fill_any_like_i64", x, 10, dtype='int64') - fill_any_like("fill_any_like_bool", x, True, dtype='bool') + full_like("full_like", x, 1.2) + full_like("full_like_f16", x, 1.0, dtype='float16') + full_like("full_like_f32", x, 1.2, dtype='float32') + full_like("full_like_f64", x, 1.2, dtype='float64') + full_like("full_like_i16", x, 3, dtype='int16') + full_like("full_like_i32", x, 2, dtype='int32') + full_like("full_like_i64", x, 10, dtype='int64') + full_like("full_like_bool", x, True, dtype='bool') sample_arr = [True, False] x = np.random.choice(sample_arr, size=(13,17,11)) - fill_any_like("fill_any_like_bool_2", x, False, dtype=None) + full_like("full_like_bool_2", x, False, dtype=None) if __name__ == "__main__": main() diff --git a/src/frontends/paddle/tests/test_models/gen_scripts/generate_gelu.py b/src/frontends/paddle/tests/test_models/gen_scripts/generate_gelu.py index b67959ef0ed439..a17fadc9c10bcb 100644 --- a/src/frontends/paddle/tests/test_models/gen_scripts/generate_gelu.py +++ b/src/frontends/paddle/tests/test_models/gen_scripts/generate_gelu.py @@ -16,7 +16,10 @@ def gelu(name:str, x, approximate=False): with paddle.static.program_guard(paddle.static.Program(), paddle.static.Program()): data = paddle.static.data(name='x', shape=x.shape, dtype = data_type) - out = paddle.fluid.layers.gelu(data, approximate=approximate) + if paddle.__version__ >= '2.0.0': + out = paddle.nn.functional.gelu(data, approximate=approximate) + else: + out = paddle.fluid.layers.gelu(data, approximate=approximate) cpu = paddle.static.cpu_places(1) exe = paddle.static.Executor(cpu[0]) diff --git a/src/frontends/paddle/tests/test_models/gen_scripts/generate_greater_equal.py b/src/frontends/paddle/tests/test_models/gen_scripts/generate_greater_equal.py index c3a82914fc0427..f540c0ea8302ec 100644 --- a/src/frontends/paddle/tests/test_models/gen_scripts/generate_greater_equal.py +++ b/src/frontends/paddle/tests/test_models/gen_scripts/generate_greater_equal.py @@ -16,7 +16,10 @@ def greater_equal(name : str, x, y, data_type, cast_to_fp32=False): with paddle.static.program_guard(paddle.static.Program(), paddle.static.Program()): node_x = paddle.static.data(name='input_x', shape=x.shape, dtype=data_type) node_y = paddle.static.data(name='input_y', shape=y.shape, dtype=data_type) - out = paddle.fluid.layers.greater_equal(x=node_x, y=node_y, name='greater_equal') + if paddle.__version__ >= '2.0.0': + out = paddle.greater_equal(x=node_x, y=node_y, name='greater_equal') + else: + out = paddle.fluid.layers.greater_equal(x=node_x, y=node_y, name='greater_equal') # FuzzyTest framework doesn't support boolean so cast to fp32/int32 if cast_to_fp32: diff --git a/src/frontends/paddle/tests/test_models/gen_scripts/generate_greater_than.py b/src/frontends/paddle/tests/test_models/gen_scripts/generate_greater_than.py index 045f80c341b411..7ca2b6ad95f9a5 100644 --- a/src/frontends/paddle/tests/test_models/gen_scripts/generate_greater_than.py +++ b/src/frontends/paddle/tests/test_models/gen_scripts/generate_greater_than.py @@ -15,8 +15,12 @@ def greater_than(name: str, x, y, data_type, cast_to_fp32=False): name='input_x', shape=x.shape, dtype=data_type) node_y = pdpd.static.data( name='input_y', shape=y.shape, dtype=data_type) - out = pdpd.fluid.layers.greater_than( - x=node_x, y=node_y, name='greater_than') + if pdpd.__version__ >= '2.0.0': + out = pdpd.greater_than( + x=node_x, y=node_y, name='greater_than') + else: + out = pdpd.fluid.layers.greater_than( + x=node_x, y=node_y, name='greater_than') # FuzzyTest framework doesn't support boolean so cast to fp32/int32 if cast_to_fp32: diff --git a/src/frontends/paddle/tests/test_models/gen_scripts/generate_grid_sampler.py b/src/frontends/paddle/tests/test_models/gen_scripts/generate_grid_sampler.py index 4dec54ad32c223..d3c404fb88108b 100644 --- a/src/frontends/paddle/tests/test_models/gen_scripts/generate_grid_sampler.py +++ b/src/frontends/paddle/tests/test_models/gen_scripts/generate_grid_sampler.py @@ -51,6 +51,8 @@ def main(): x = np.random.randn(2, 3, 128, 128).astype(dtype) grid = np.random.uniform(-1, 1, [2, 130, 130, 2]).astype(dtype) padding_mode = "border" + grid_sampler(name='grid_sampler_3', x=x, grid=grid, mode=mode, padding_mode=padding_mode, + align_corners=align_corners) grid_sampler(name='grid_sampler_dyn', x=x, grid=grid, mode=mode, padding_mode=padding_mode, align_corners=align_corners, is_dynamic=True) diff --git a/src/frontends/paddle/tests/test_models/gen_scripts/generate_hard_sigmoid.py b/src/frontends/paddle/tests/test_models/gen_scripts/generate_hard_sigmoid.py index 68c9179421c788..9ccdb623094107 100644 --- a/src/frontends/paddle/tests/test_models/gen_scripts/generate_hard_sigmoid.py +++ b/src/frontends/paddle/tests/test_models/gen_scripts/generate_hard_sigmoid.py @@ -15,7 +15,7 @@ def hard_sigmoid(name: str, x, slope: float = 0.2, offset: float = 0.5, data_typ with paddle.static.program_guard(paddle.static.Program(), paddle.static.Program()): node_x = paddle.static.data(name='x', shape=x.shape, dtype = data_type) - out = paddle.fluid.layers.hard_sigmoid(node_x, slope=slope, offset=offset, name='hard_sigmoid') + out = paddle.nn.functional.hardsigmoid(node_x, slope=slope, offset=offset, name='hard_sigmoid') cpu = paddle.static.cpu_places(1) exe = paddle.static.Executor(cpu[0]) diff --git a/src/frontends/paddle/tests/test_models/gen_scripts/generate_hard_swish.py b/src/frontends/paddle/tests/test_models/gen_scripts/generate_hard_swish.py index 2fdf4a3ee29f66..c86eab1877abe3 100644 --- a/src/frontends/paddle/tests/test_models/gen_scripts/generate_hard_swish.py +++ b/src/frontends/paddle/tests/test_models/gen_scripts/generate_hard_swish.py @@ -15,7 +15,10 @@ def hard_swish(name: str, x, threshold=6.0, scale=6.0, offset=3.0, data_type='fl with paddle.static.program_guard(paddle.static.Program(), paddle.static.Program()): node_x = paddle.static.data(name='x', shape=x.shape, dtype=data_type) - out = paddle.fluid.layers.hard_swish(node_x, threshold=threshold, scale=scale, offset=offset, name='hard_swish') + if paddle.__version__ >= '2.0.0': + out = paddle.nn.functional.hardswish(node_x, name='hard_swish') + else: + out = paddle.fluid.layers.hard_swish(node_x, threshold=threshold, scale=scale, offset=offset, name='hard_swish') cpu = paddle.static.cpu_places(1) exe = paddle.static.Executor(cpu[0]) diff --git a/src/frontends/paddle/tests/test_models/gen_scripts/generate_index_select.py b/src/frontends/paddle/tests/test_models/gen_scripts/generate_index_select.py index f1f2bdcd39e1f8..476471daed2070 100644 --- a/src/frontends/paddle/tests/test_models/gen_scripts/generate_index_select.py +++ b/src/frontends/paddle/tests/test_models/gen_scripts/generate_index_select.py @@ -5,7 +5,6 @@ # index_select paddle model generator # import numpy as np -from paddle.fluid import param_attr from save_model import saveModel import paddle import sys diff --git a/src/frontends/paddle/tests/test_models/gen_scripts/generate_layer_norm.py b/src/frontends/paddle/tests/test_models/gen_scripts/generate_layer_norm.py index 593f019f2fba87..25d90cae8f981b 100644 --- a/src/frontends/paddle/tests/test_models/gen_scripts/generate_layer_norm.py +++ b/src/frontends/paddle/tests/test_models/gen_scripts/generate_layer_norm.py @@ -36,8 +36,12 @@ def layer_norm(name:str, x, begin_norm_axis, scale=True, shift=True, param_attr= def main(): x = np.random.rand(8, 24, 32).astype(data_type) random_data = np.random.rand(24 * 32).astype(data_type) - attr = paddle.ParamAttr( - initializer=paddle.fluid.initializer.NumpyArrayInitializer(random_data)) + if paddle.__version__ >= '2.0.0': + attr = paddle.ParamAttr( + initializer=paddle.nn.initializer.Assign(random_data)) + else: + attr = paddle.ParamAttr( + initializer=paddle.fluid.initializer.NumpyArrayInitializer(random_data)) layer_norm("layer_norm", x, begin_norm_axis=1, param_attr=attr, bias_attr=attr) layer_norm("layer_norm_noscale", x, scale=False, begin_norm_axis=2) layer_norm("layer_norm_noshift", x, shift=False, begin_norm_axis=1) diff --git a/src/frontends/paddle/tests/test_models/gen_scripts/generate_leaky_relu.py b/src/frontends/paddle/tests/test_models/gen_scripts/generate_leaky_relu.py index 580a0a0a7acbb0..71740e7961382e 100644 --- a/src/frontends/paddle/tests/test_models/gen_scripts/generate_leaky_relu.py +++ b/src/frontends/paddle/tests/test_models/gen_scripts/generate_leaky_relu.py @@ -10,12 +10,15 @@ import sys -def leaky_relu(name: str, x, alpha: float = 0.02, data_type='float32'): +def leaky_relu(name: str, x, alpha: float = 0.01, data_type='float32'): paddle.enable_static() with paddle.static.program_guard(paddle.static.Program(), paddle.static.Program()): node_x = paddle.static.data(name='x', shape=x.shape, dtype = data_type) - out = paddle.fluid.layers.leaky_relu(node_x, alpha=alpha, name='leaky_relu') + if paddle.__version__ >= '2.0.0': + out = paddle.nn.functional.leaky_relu(node_x, negative_slope=alpha, name='leaky_relu') + else: + out = paddle.fluid.layers.leaky_relu(node_x, alpha=alpha, name='leaky_relu') cpu = paddle.static.cpu_places(1) exe = paddle.static.Executor(cpu[0]) diff --git a/src/frontends/paddle/tests/test_models/gen_scripts/generate_less_than.py b/src/frontends/paddle/tests/test_models/gen_scripts/generate_less_than.py index 187f920df297c8..91749fffdd3f84 100644 --- a/src/frontends/paddle/tests/test_models/gen_scripts/generate_less_than.py +++ b/src/frontends/paddle/tests/test_models/gen_scripts/generate_less_than.py @@ -3,29 +3,32 @@ # import numpy as np from save_model import saveModel -import paddle as pdpd +import paddle import sys def less_than(name: str, x, y, data_type, cast_to_fp32=False): - pdpd.enable_static() + paddle.enable_static() - with pdpd.static.program_guard(pdpd.static.Program(), pdpd.static.Program()): - node_x = pdpd.static.data( + with paddle.static.program_guard(paddle.static.Program(), paddle.static.Program()): + node_x = paddle.static.data( name='input_x', shape=x.shape, dtype=data_type) - node_y = pdpd.static.data( + node_y = paddle.static.data( name='input_y', shape=y.shape, dtype=data_type) - out = pdpd.fluid.layers.less_than(x=node_x, y=node_y, name='less_than') + if paddle.__version__ >= '2.0.0': + out = paddle.less_than(x=node_x, y=node_y, name='less_than') + else: + out = paddle.fluid.layers.less_than(x=node_x, y=node_y, name='less_than') # FuzzyTest framework doesn't support boolean so cast to fp32/int32 if cast_to_fp32: data_type = "float32" - out = pdpd.cast(out, data_type) - cpu = pdpd.static.cpu_places(1) - exe = pdpd.static.Executor(cpu[0]) + out = paddle.cast(out, data_type) + cpu = paddle.static.cpu_places(1) + exe = paddle.static.Executor(cpu[0]) # startup program will call initializer to initialize the parameters. - exe.run(pdpd.static.default_startup_program()) + exe.run(paddle.static.default_startup_program()) outs = exe.run( feed={'input_x': x, 'input_y': y}, diff --git a/src/frontends/paddle/tests/test_models/gen_scripts/generate_log.py b/src/frontends/paddle/tests/test_models/gen_scripts/generate_log.py index 7cd9196172d551..1fd2cbde20a3f5 100644 --- a/src/frontends/paddle/tests/test_models/gen_scripts/generate_log.py +++ b/src/frontends/paddle/tests/test_models/gen_scripts/generate_log.py @@ -15,7 +15,10 @@ def log(name: str, x, data_type='float32'): with paddle.static.program_guard(paddle.static.Program(), paddle.static.Program()): node_x = paddle.static.data(name='x', shape=x.shape, dtype=data_type) - out = paddle.fluid.layers.log(node_x, name='log') + if paddle.__version__ >= '2.0.0': + out = paddle.log(node_x, name='log') + else: + out = paddle.fluid.layers.log(node_x, name='log') cpu = paddle.static.cpu_places(1) exe = paddle.static.Executor(cpu[0]) diff --git a/src/frontends/paddle/tests/test_models/gen_scripts/generate_loop.py b/src/frontends/paddle/tests/test_models/gen_scripts/generate_loop.py index 2cb59b42e45320..72185ba530cb3d 100644 --- a/src/frontends/paddle/tests/test_models/gen_scripts/generate_loop.py +++ b/src/frontends/paddle/tests/test_models/gen_scripts/generate_loop.py @@ -23,7 +23,10 @@ def body(i, dummy): with paddle.static.program_guard(paddle.static.Program(), paddle.static.Program()): node_x = paddle.static.data(name='x', shape=x.shape, dtype=x.dtype) node_i = paddle.full(shape=[1], fill_value=0, dtype='int64', name='i') - node_i = paddle.fluid.layers.nn.elementwise_add(node_i, node_x) + if paddle.__version__ >= '2.0.0': + node_i = paddle.add(node_i, node_x) + else: + node_i = paddle.fluid.layers.nn.elementwise_add(node_i, node_x) node_ten = paddle.full(shape=[1], fill_value=10, dtype='int64', name='ten') out, dummy = paddle.static.nn.while_loop(cond, body, [node_i, node_ten], name='while_loop') @@ -49,7 +52,10 @@ def body(i, t): with paddle.static.program_guard(paddle.static.Program(), paddle.static.Program()): node_x = paddle.static.data(name='x', shape=x.shape, dtype=x.dtype) node_i = paddle.full(shape=[1], fill_value=0, dtype='int64', name='i') - node_i = paddle.fluid.layers.nn.elementwise_add(node_i, node_x) + if paddle.__version__ >= '2.0.0': + node_i = paddle.add(node_i, node_x) + else: + node_i = paddle.fluid.layers.nn.elementwise_add(node_i, node_x) node_ten = paddle.full(shape=[1], fill_value=10, dtype='int64', name='ten') out, dummy = paddle.static.nn.while_loop(cond, body, [node_i, node_ten], name='while_loop') @@ -76,7 +82,10 @@ def body(i, t): with paddle.static.program_guard(paddle.static.Program(), paddle.static.Program()): node_x = paddle.static.data(name='x', shape=x.shape, dtype=x.dtype) node_i = paddle.full(shape=[1], fill_value=0, dtype='int64', name='i') - node_i = paddle.fluid.layers.nn.elementwise_add(node_i, node_x) + if paddle.__version__ >= '2.0.0': + node_i = paddle.add(node_i, node_x) + else: + paddle.fluid.layers.nn.elementwise_add(node_i, node_x) node_ten = paddle.full(shape=[1], fill_value=10, dtype='int64', name='ten') out_i,out_t = paddle.static.nn.while_loop(cond, body, [node_i, node_ten], name='while_loop') diff --git a/src/frontends/paddle/tests/test_models/gen_scripts/generate_mul.py b/src/frontends/paddle/tests/test_models/gen_scripts/generate_mul.py index dbc8c818d2f8c4..f198178ae4a2c8 100644 --- a/src/frontends/paddle/tests/test_models/gen_scripts/generate_mul.py +++ b/src/frontends/paddle/tests/test_models/gen_scripts/generate_mul.py @@ -12,7 +12,10 @@ def paddle_matmul(name, x1, x2, x_transpose=False, y_transpose=False): with paddle.static.program_guard(paddle.static.Program(), paddle.static.Program()): node_x1 = paddle.static.data(name='x1', shape=x1.shape, dtype=x1.dtype) node_x2 = paddle.static.data(name='x2', shape=x2.shape, dtype=x2.dtype) - mul_node = paddle.fluid.layers.matmul(node_x1, node_x2, x_transpose, y_transpose) + if paddle.__version__ >= '2.0.0': + mul_node = paddle.matmul(node_x1, node_x2, x_transpose, y_transpose) + else: + mul_node = paddle.fluid.layers.matmul(node_x1, node_x2, x_transpose, y_transpose) result = paddle.static.nn.batch_norm(mul_node, use_global_stats=True) cpu = paddle.static.cpu_places(1) diff --git a/src/frontends/paddle/tests/test_models/gen_scripts/generate_multi_tensor_split.py b/src/frontends/paddle/tests/test_models/gen_scripts/generate_multi_tensor_split.py index 8ec25d91c40f17..b98c4a4325810e 100644 --- a/src/frontends/paddle/tests/test_models/gen_scripts/generate_multi_tensor_split.py +++ b/src/frontends/paddle/tests/test_models/gen_scripts/generate_multi_tensor_split.py @@ -15,12 +15,19 @@ def create_multi_output_model(): num_splits = 20 inp_blob_1 = np.random.randn(2, num_splits, 4, 4).astype(np.float32) - x = fluid.data(name='x', shape=[2, num_splits, 4, 4], dtype='float32') - test_layer = fluid.layers.split(x, num_or_sections=num_splits, dim=1) - + if paddle.__version__ >= '2.0.0': + x = paddle.static.data(name='x', shape=[2, num_splits, 4, 4], dtype='float32') + test_layer = paddle.split(x, num_or_sections=num_splits, axis=1) + else: + x = fluid.data(name='x', shape=[2, num_splits, 4, 4], dtype='float32') + test_layer = paddle.split(x, num_or_sections=num_splits, axis=1) + var = [] for i in range(num_splits//2): - add = fluid.layers.elementwise_add(test_layer[2*i], test_layer[2*i+1]) + if paddle.__version__ >= '2.0.0': + add = paddle.add(test_layer[2*i], test_layer[2*i+1]) + else: + add = fluid.layers.elementwise_add(test_layer[2*i], test_layer[2*i+1]) var.append(add) exe = fluid.Executor(fluid.CPUPlace()) @@ -28,7 +35,7 @@ def create_multi_output_model(): inp_dict = {'x': inp_blob_1} res_paddle = exe.run(fluid.default_main_program(), fetch_list=var, feed=inp_dict) - fluid.io.save_inference_model(os.path.join(sys.argv[1], "multi_tensor_split"), + paddle.fluid.io.save_inference_model(os.path.join(sys.argv[1], "multi_tensor_split"), list(inp_dict.keys()), var, exe, model_filename="multi_tensor_split.pdmodel", params_filename="multi_tensor_split.pdiparams") diff --git a/src/frontends/paddle/tests/test_models/gen_scripts/generate_place_test_model.py b/src/frontends/paddle/tests/test_models/gen_scripts/generate_place_test_model.py index da4a7f901d2aef..a7e92ca264a6e8 100644 --- a/src/frontends/paddle/tests/test_models/gen_scripts/generate_place_test_model.py +++ b/src/frontends/paddle/tests/test_models/gen_scripts/generate_place_test_model.py @@ -1,10 +1,11 @@ # Copyright (C) 2018-2023 Intel Corporation # SPDX-License-Identifier: Apache-2.0 +import paddle import numpy as np from save_model import saveModel import sys - +import os def paddle_rnn_lstm(input_size, hidden_size, layers, direction): import paddle @@ -34,11 +35,40 @@ def paddle_rnn_lstm(input_size, hidden_size, layers, direction): feed={'x': np.ones([4, 3, input_size]).astype(np.float32)}, fetch_list=[y, h, c], program=main_program) - saveModel("place_test_model", exe, feedkeys=[data], - fetchlist=[y, h, c, relu_1, relu_2, relu_3], - inputs=[np.ones([4, 3, input_size]).astype(np.float32)], - outputs=[outs[0], outs[1], outs[2]], target_dir=sys.argv[1], - use_static_api=True) + + if paddle.__version__ >= '2.0.0': + feed_vars = [data] + fetch_vars = [y, h, c, relu_1, relu_2, relu_3] + saveModel("place_test_model", exe, feedkeys=feed_vars, + fetchlist=fetch_vars, + inputs=[np.ones([4, 3, input_size]).astype(np.float32)], + outputs=[outs[0], outs[1], outs[2]], target_dir=sys.argv[1], + use_static_api=True) + path_prefix = os.path.join(sys.argv[1], "place_test_model", "place_test_model") + program, feed_target_names, fetch_targets = paddle.static.io.load_inference_model(path_prefix, exe) + + from paddle.fluid import core + condition = lambda v : not v.persistable and v.name != "transpose_1.tmp_1" and v.name != "transpose_0.tmp_1" + vars_ = list(filter(condition, program.list_vars())) + vars_name = [v.name for v in vars_] + vars_name_file = os.path.join(sys.argv[1], "place_test_model", "vars_name.txt") + with open(vars_name_file, 'w') as f: + for name in vars_name: + f.writelines(f"{name}\n") + + fetch_targets_name = [ft.name for ft in fetch_targets] + outputs_name_file = os.path.join(sys.argv[1], "place_test_model", "outputs_name.txt") + with open(outputs_name_file, 'w') as f: + for name in fetch_targets_name: + f.writelines(f"{name}\n") + + else: + saveModel("place_test_model", exe, feedkeys=[data], + fetchlist=[y, h, c, relu_1, relu_2, relu_3], + inputs=[np.ones([4, 3, input_size]).astype(np.float32)], + outputs=[outs[0], outs[1], outs[2]], target_dir=sys.argv[1], + use_static_api=True) + return outs[0] diff --git a/src/frontends/paddle/tests/test_models/gen_scripts/generate_pool2d.py b/src/frontends/paddle/tests/test_models/gen_scripts/generate_pool2d.py index afec1e06243691..45aa60862d1c79 100644 --- a/src/frontends/paddle/tests/test_models/gen_scripts/generate_pool2d.py +++ b/src/frontends/paddle/tests/test_models/gen_scripts/generate_pool2d.py @@ -8,70 +8,102 @@ import sys from save_model import saveModel -data_type = 'float32' +data_type = "float32" -def pool2d(name : str, x, attrs : dict): + +def pool2d(name: str, x, attrs: dict): import paddle + paddle.enable_static() with paddle.static.program_guard(paddle.static.Program(), paddle.static.Program()): - node_x = paddle.static.data(name='x', shape=x.shape, dtype=data_type) - out = paddle.fluid.layers.pool2d(node_x, - pool_size=attrs['pool_size'], - pool_type=attrs['pool_type'], - pool_stride=attrs['pool_stride'], - pool_padding=attrs['pool_padding'], - global_pooling=attrs['global_pooling'], - ceil_mode=attrs['ceil_mode'], - exclusive=attrs['exclusive'], - data_format=attrs['data_format']) + node_x = paddle.static.data(name="x", shape=x.shape, dtype=data_type) + + if attrs["pool_type"] == "max": + out = paddle.nn.functional.max_pool2d( + node_x, + kernel_size=attrs["pool_size"], + stride=attrs["pool_stride"], + padding=attrs["pool_padding"], + ceil_mode=attrs["ceil_mode"], + data_format=attrs["data_format"] + ) + else: + out = paddle.nn.functional.avg_pool2d( + node_x, + kernel_size=attrs["pool_size"], + stride=attrs["pool_stride"], + padding=attrs["pool_padding"], + ceil_mode=attrs["ceil_mode"], + data_format=attrs["data_format"] + ) cpu = paddle.static.cpu_places(1) exe = paddle.static.Executor(cpu[0]) # startup program will call initializer to initialize the parameters. exe.run(paddle.static.default_startup_program()) - outs = exe.run( - feed={'x': x}, - fetch_list=[out]) + outs = exe.run(feed={"x": x}, fetch_list=[out]) - saveModel(name, exe, feedkeys=['x'], fetchlist=[out], inputs=[x], outputs=[outs[0]], target_dir=sys.argv[1]) + saveModel( + name, + exe, + feedkeys=["x"], + fetchlist=[out], + inputs=[x], + outputs=[outs[0]], + target_dir=sys.argv[1], + ) return outs[0] -def adaptive_pool2d(name : str, x, attrs : dict): + +def adaptive_pool2d(name: str, x, attrs: dict): import paddle + paddle.enable_static() with paddle.static.program_guard(paddle.static.Program(), paddle.static.Program()): - node_x = paddle.static.data(name='x', shape=x.shape, dtype=data_type) - out = paddle.fluid.layers.adaptive_pool2d( - input=node_x, - pool_size=attrs['pool_size'], - pool_type=attrs['pool_type'], - require_index=attrs['require_index']) + node_x = paddle.static.data(name="x", shape=x.shape, dtype=data_type) + if attrs["pool_type"] == "max": + out = paddle.nn.functional.adaptive_max_pool2d( + x=node_x, + output_size=attrs["pool_size"] + ) + else: + out = paddle.nn.functional.adaptive_avg_pool2d( + x=node_x, + output_size=attrs["pool_size"] + ) cpu = paddle.static.cpu_places(1) exe = paddle.static.Executor(cpu[0]) # startup program will call initializer to initialize the parameters. exe.run(paddle.static.default_startup_program()) - outs = exe.run( - feed={'x': x}, - fetch_list=[out]) + outs = exe.run(feed={"x": x}, fetch_list=[out]) - saveModel(name, exe, feedkeys=['x'], fetchlist=[out], inputs=[x], outputs=[outs[0]], target_dir=sys.argv[1]) + saveModel( + name, + exe, + feedkeys=["x"], + fetchlist=[out], + inputs=[x], + outputs=[outs[0]], + target_dir=sys.argv[1], + ) return outs[0] + def main(): N, C, H, W = 2, 3, 4, 4 - data = np.arange(N*C*H*W).astype(data_type) + data = np.arange(N * C * H * W).astype(data_type) data_NCHW = data.reshape(N, C, H, W) data_NHWC = data.reshape(N, H, W, C) - #print(data_NCHW, data_NCHW.shape) + # print(data_NCHW, data_NCHW.shape) - pooling_types = ['max', 'avg'] + pooling_types = ["max", "avg"] # pool2d for i, pooling_type in enumerate(pooling_types): @@ -79,185 +111,193 @@ def main(): # ceil_mode = False paddle_attrs = { # input=data_NCHW, # shape: [2, 3, 8, 8] - 'pool_size' : [3,3], - 'pool_type' : pooling_type, - 'pool_stride' : [3,3], - 'pool_padding' : [2,1], # it is same as pool_padding = [2,2,1,1] - 'global_pooling' : False, - 'ceil_mode' : False, - 'exclusive' : True, - 'data_format' : "NCHW" + "pool_size": [3, 3], + "pool_type": pooling_type, + "pool_stride": [3, 3], + "pool_padding": [2, 1], # it is same as pool_padding = [2,2,1,1] + "global_pooling": False, + "ceil_mode": False, + "exclusive": True, + "data_format": "NCHW", } # shape of out_1: [2, 3, 4, 3] - pool2d(pooling_type+'Pool_test1', data_NCHW, paddle_attrs) + pool2d(pooling_type + "Pool_test1", data_NCHW, paddle_attrs) # Cecilia: there is a bug of PaddlePaddle in this case. # example 2: # ceil_mode = True (different from example 1) paddle_attrs = { - #input=data_NCHW, - 'pool_size':[3,3], - 'pool_type' : pooling_type, - 'pool_stride' : [3,3], - 'pool_padding':[[0,0], [0,0], [2,2], [1,1]], # it is same as pool_padding = [2,2,1,1] - 'global_pooling':False, - 'ceil_mode':True, - 'exclusive':True, - 'data_format':"NCHW" + # input=data_NCHW, + "pool_size": [3, 3], + "pool_type": pooling_type, + "pool_stride": [3, 3], + "pool_padding": [ + [0, 0], + [0, 0], + [2, 2], + [1, 1], + ], # it is same as pool_padding = [2,2,1,1] + "global_pooling": False, + "ceil_mode": True, + "exclusive": True, + "data_format": "NCHW", } # shape of out_2: [2, 3, 4, 4] which is different from out_1 - pool2d(pooling_type+'Pool_test2', data_NCHW, paddle_attrs) + pool2d(pooling_type + "Pool_test2", data_NCHW, paddle_attrs) # example 3: # pool_padding = "SAME" (different from example 1) paddle_attrs = { - #input=data_NCHW, - 'pool_size':[3,3], - 'pool_type' : pooling_type, - 'pool_stride' : [3,3], - 'pool_padding':"SAME", - 'global_pooling':False, - 'ceil_mode':False, - 'exclusive':True, - 'data_format':"NCHW" + # input=data_NCHW, + "pool_size": [3, 3], + "pool_type": pooling_type, + "pool_stride": [3, 3], + "pool_padding": "SAME", + "global_pooling": False, + "ceil_mode": False, + "exclusive": True, + "data_format": "NCHW", } # shape of out_3: [2, 3, 3, 3] which is different from out_1 - pool2d(pooling_type+'Pool_test3', data_NCHW, paddle_attrs) + pool2d(pooling_type + "Pool_test3", data_NCHW, paddle_attrs) # example 4: # pool_padding = "VALID" (different from example 1) paddle_attrs = { - #input=data_NCHW, - 'pool_size':[3,3], - 'pool_type' : pooling_type, - 'pool_stride' : [3,3], - 'pool_padding':"VALID", - 'global_pooling':False, - 'ceil_mode':False, - 'exclusive':True, - 'data_format':"NCHW" + # input=data_NCHW, + "pool_size": [3, 3], + "pool_type": pooling_type, + "pool_stride": [3, 3], + "pool_padding": "VALID", + "global_pooling": False, + "ceil_mode": False, + "exclusive": True, + "data_format": "NCHW", } # shape of out_4: [2, 3, 2, 2] which is different from out_1 - pool2d(pooling_type+'Pool_test4', data_NCHW, paddle_attrs) + pool2d(pooling_type + "Pool_test4", data_NCHW, paddle_attrs) # example 5: # global_pooling = True (different from example 1) # It will be set pool_size = [8,8] and pool_padding = [0,0] actually. paddle_attrs = { - #input=data_NCHW, - 'pool_size':[3,3], - 'pool_type' : pooling_type, - 'pool_stride' : [3,3], - 'pool_padding':[2,1], - 'global_pooling':True, - 'ceil_mode':False, - 'exclusive':True, - 'data_format':"NCHW" + # input=data_NCHW, + "pool_size": [3, 3], + "pool_type": pooling_type, + "pool_stride": [3, 3], + "pool_padding": [2, 1], + "global_pooling": True, + "ceil_mode": False, + "exclusive": True, + "data_format": "NCHW", } # shape of out_5: [2, 3, 1, 1] which is different from out_1 - pool2d(pooling_type+'Pool_test5', data_NCHW, paddle_attrs) + pool2d(pooling_type + "Pool_test5", data_NCHW, paddle_attrs) # example 6: # data_format = "NHWC" (different from example 1) paddle_attrs = { - #input=data_NHWC, # shape: [2, 8, 8, 3] - 'pool_size':[3,3], - 'pool_type' : pooling_type, - 'pool_stride' : [3,3], - 'pool_padding':[2,1], - 'global_pooling':False, - 'ceil_mode':False, - 'exclusive':True, - 'data_format':"NHWC" + # input=data_NHWC, # shape: [2, 8, 8, 3] + "pool_size": [3, 3], + "pool_type": pooling_type, + "pool_stride": [3, 3], + "pool_padding": [2, 1], + "global_pooling": False, + "ceil_mode": False, + "exclusive": True, + "data_format": "NHWC", } # shape of out_6: [2, 4, 3, 3] which is different from out_1 - pool2d(pooling_type+'Pool_test6', data_NHWC, paddle_attrs) + pool2d(pooling_type + "Pool_test6", data_NHWC, paddle_attrs) # example 7: # pool_size is [9, 9] paddle_attrs = { - #input=data_NCHW, - 'pool_size':[9,9], - 'pool_type' : pooling_type, - 'pool_stride' : [3,3], - 'pool_padding':[[0,0], [0,0], [2,2], [1,1]], # it is same as pool_padding = [2,2,1,1] - 'global_pooling':False, - 'ceil_mode':True, - 'exclusive':True, - 'data_format':"NCHW" + # input=data_NCHW, + "pool_size": [9, 9], + "pool_type": pooling_type, + "pool_stride": [3, 3], + "pool_padding": [ + [0, 0], + [0, 0], + [2, 2], + [1, 1], + ], # it is same as pool_padding = [2,2,1,1] + "global_pooling": False, + "ceil_mode": True, + "exclusive": True, + "data_format": "NCHW", } - pool2d(pooling_type+'Pool_test7', data_NCHW, paddle_attrs) + pool2d(pooling_type + "Pool_test7", data_NCHW, paddle_attrs) # example 8: # pool_padding size is 1 paddle_attrs = { - 'pool_size':[3,3], - 'pool_type' : pooling_type, - 'pool_stride' : [3,3], - 'pool_padding':2, - 'global_pooling':False, - 'ceil_mode':False, - 'exclusive':True, - 'data_format':"NCHW" + "pool_size": [3, 3], + "pool_type": pooling_type, + "pool_stride": [3, 3], + "pool_padding": 2, + "global_pooling": False, + "ceil_mode": False, + "exclusive": True, + "data_format": "NCHW", } - pool2d(pooling_type+'Pool_test8', data_NCHW, paddle_attrs) + pool2d(pooling_type + "Pool_test8", data_NCHW, paddle_attrs) - #input data for test9 and test10 + # input data for test9 and test10 N_data1, C_data1, H_data1, W_data1 = 2, 3, 8, 8 - data1 = np.arange(N_data1*C_data1*H_data1*W_data1).astype(data_type) + data1 = np.arange(N_data1 * C_data1 * H_data1 * W_data1).astype(data_type) data1_NCHW = data1.reshape(N_data1, C_data1, H_data1, W_data1) # example 9: # pool_padding size is 4: [pad_height_top, pad_height_bottom, pad_width_left, pad_width_right] paddle_attrs = { - 'pool_size':[3,3], - 'pool_type' : pooling_type, - 'pool_stride' : [3,3], - 'pool_padding':[2, 1, 2, 1], - 'global_pooling':False, - 'ceil_mode':False, - 'exclusive':True, - 'data_format':"NCHW" + "pool_size": [3, 3], + "pool_type": pooling_type, + "pool_stride": [3, 3], + "pool_padding": [2, 1, 2, 1], + "global_pooling": False, + "ceil_mode": False, + "exclusive": True, + "data_format": "NCHW", } - pool2d(pooling_type+'Pool_test9', data1_NCHW, paddle_attrs) + pool2d(pooling_type + "Pool_test9", data1_NCHW, paddle_attrs) # example 10: # input=data_NCHW and pool_padding is [[0,0], [0,0], [pad_height_top, pad_height_bottom], [pad_width_left, pad_width_right]] paddle_attrs = { - 'pool_size':[3,3], - 'pool_type' : pooling_type, - 'pool_stride' : [3,3], - 'pool_padding':[[0,0], [0,0], [2, 1], [2, 1]], - 'global_pooling':False, - 'ceil_mode':False, - 'exclusive':True, - 'data_format':"NCHW" + "pool_size": [3, 3], + "pool_type": pooling_type, + "pool_stride": [3, 3], + "pool_padding": [[0, 0], [0, 0], [2, 1], [2, 1]], + "global_pooling": False, + "ceil_mode": False, + "exclusive": True, + "data_format": "NCHW", } - pool2d(pooling_type+'Pool_test10', data1_NCHW, paddle_attrs) + pool2d(pooling_type + "Pool_test10", data1_NCHW, paddle_attrs) # example 11: # input=data_NCHW and poolsize is the multiply by width & height. pool_padding is [[0,0], [0,0], [pad_height_top, pad_height_bottom], [pad_width_left, pad_width_right]] paddle_attrs = { - 'pool_size': 9, - 'pool_type' : pooling_type, - 'pool_stride' : [3,3], - 'pool_padding':[[0,0], [0,0], [2, 1], [2, 1]], - 'global_pooling':False, - 'ceil_mode':False, - 'exclusive':True, - 'data_format':"NCHW" + "pool_size": 9, + "pool_type": pooling_type, + "pool_stride": [3, 3], + "pool_padding": [[0, 0], [0, 0], [2, 1], [2, 1]], + "global_pooling": False, + "ceil_mode": False, + "exclusive": True, + "data_format": "NCHW", } - pool2d(pooling_type+'Pool_test11', data1_NCHW, paddle_attrs) - + pool2d(pooling_type + "Pool_test11", data1_NCHW, paddle_attrs) # adaptive_pool2d for i, pooling_type in enumerate(pooling_types): paddle_attrs = { - 'pool_size': [3,3], - 'pool_type': pooling_type, - 'require_index': False + "pool_size": [3, 3], + "pool_type": pooling_type } - adaptive_pool2d(pooling_type+'AdaptivePool2D_test1', data_NCHW, paddle_attrs) + adaptive_pool2d(pooling_type + "AdaptivePool2D_test1", data_NCHW, paddle_attrs) if __name__ == "__main__": - main() + main() diff --git a/src/frontends/paddle/tests/test_models/gen_scripts/generate_pow.py b/src/frontends/paddle/tests/test_models/gen_scripts/generate_pow.py index c845fac78d3337..c762c8a6506f92 100644 --- a/src/frontends/paddle/tests/test_models/gen_scripts/generate_pow.py +++ b/src/frontends/paddle/tests/test_models/gen_scripts/generate_pow.py @@ -15,7 +15,11 @@ def paddle_pow(name : str, x, y, data_type): with paddle.static.program_guard(paddle.static.Program(), paddle.static.Program()): node_x = paddle.static.data(name='x', shape=x.shape, dtype=data_type) - out = paddle.fluid.layers.pow(node_x, y, name='pow') + if paddle.__version__ >= '2.0.0': + y = paddle.to_tensor(y, dtype=data_type) + out = paddle.pow(node_x, y, name='pow') + else: + out = paddle.fluid.layers.pow(node_x, y, name='pow') #FuzzyTest supports int32 & float32 if data_type == "int64": out = paddle.cast(out, "float32") @@ -40,7 +44,10 @@ def paddle_pow_tensor(name : str, x, y, data_type): with paddle.static.program_guard(paddle.static.Program(), paddle.static.Program()): node_x = paddle.static.data(name='x', shape=x.shape, dtype=data_type) node_y = paddle.static.data(name='y', shape=y.shape, dtype=data_type) - out = paddle.fluid.layers.pow(node_x, node_y, name='pow') + if paddle.__version__ >= '2.0.0': + out = paddle.pow(node_x, node_y, name='pow') + else: + out = paddle.fluid.layers.pow(node_x, node_y, name='pow') out = paddle.cast(out, "float32") cpu = paddle.static.cpu_places(1) diff --git a/src/frontends/paddle/tests/test_models/gen_scripts/generate_prior_box.py b/src/frontends/paddle/tests/test_models/gen_scripts/generate_prior_box.py index 12088009701c0f..b0f1c6b12aacbb 100644 --- a/src/frontends/paddle/tests/test_models/gen_scripts/generate_prior_box.py +++ b/src/frontends/paddle/tests/test_models/gen_scripts/generate_prior_box.py @@ -19,18 +19,32 @@ def prior_box(name: str, input_data, image_data, attrs: dict): Image = paddle.static.data( name='Image', shape=image_data.shape, dtype=image_data.dtype) - box, var = paddle.fluid.layers.prior_box(Input, - Image, - min_sizes=attrs['min_sizes'], - max_sizes=attrs['max_sizes'], - aspect_ratios=attrs['aspect_ratios'], - variance=attrs['variance'], - flip=attrs['flip'], - clip=attrs['clip'], - steps=attrs['steps'], - offset=attrs['offset'], - name=None, - min_max_aspect_ratios_order=attrs['min_max_aspect_ratios_order']) + if paddle.__version__ >= '2.0.0': + box, var = paddle.vision.ops.prior_box(Input, + Image, + min_sizes=attrs['min_sizes'], + max_sizes=attrs['max_sizes'], + aspect_ratios=attrs['aspect_ratios'], + variance=attrs['variance'], + flip=attrs['flip'], + clip=attrs['clip'], + steps=attrs['steps'], + offset=attrs['offset'], + name=None, + min_max_aspect_ratios_order=attrs['min_max_aspect_ratios_order']) + else: + box, var = paddle.fluid.layers.prior_box(Input, + Image, + min_sizes=attrs['min_sizes'], + max_sizes=attrs['max_sizes'], + aspect_ratios=attrs['aspect_ratios'], + variance=attrs['variance'], + flip=attrs['flip'], + clip=attrs['clip'], + steps=attrs['steps'], + offset=attrs['offset'], + name=None, + min_max_aspect_ratios_order=attrs['min_max_aspect_ratios_order']) cpu = paddle.static.cpu_places(1) exe = paddle.static.Executor(cpu[0]) diff --git a/src/frontends/paddle/tests/test_models/gen_scripts/generate_range.py b/src/frontends/paddle/tests/test_models/gen_scripts/generate_range.py index 0b1dde6c1fa8b2..dee96b6874fe27 100644 --- a/src/frontends/paddle/tests/test_models/gen_scripts/generate_range.py +++ b/src/frontends/paddle/tests/test_models/gen_scripts/generate_range.py @@ -16,7 +16,10 @@ def paddle_range(name : str, x, start, end, step, out_type): with paddle.static.program_guard(paddle.static.Program(), paddle.static.Program()): node_x = paddle.static.data(name='x', shape=x.shape, dtype='float32') # Range op only support fill_constant input, since dynamic op is not supported in ov - out = paddle.fluid.layers.range(start, end, step, out_type) + if paddle.__version__ >= '2.0.0': + out = paddle.arange(start, end, step, out_type) + else: + out = paddle.fluid.layers.range(start, end, step, out_type) out = paddle.cast(out, np.float32) out = paddle.add(node_x, out) #out = paddle.cast(out, np.float32) diff --git a/src/frontends/paddle/tests/test_models/gen_scripts/generate_reduce_all.py b/src/frontends/paddle/tests/test_models/gen_scripts/generate_reduce_all.py index c24f9fd3eaef74..6f11265a760bfd 100644 --- a/src/frontends/paddle/tests/test_models/gen_scripts/generate_reduce_all.py +++ b/src/frontends/paddle/tests/test_models/gen_scripts/generate_reduce_all.py @@ -16,7 +16,10 @@ def reduce_all(name : str, x, axis=None, keepdim=False): with paddle.static.program_guard(paddle.static.Program(), paddle.static.Program()): data_x = paddle.static.data(name='x', shape=x.shape, dtype=x.dtype) - reduced = paddle.fluid.layers.reduce_all(data_x, dim=axis, keep_dim=keepdim) + if paddle.__version__ >= '2.0.0': + reduced = paddle.all(data_x, axis=axis, keepdim=keepdim) + else: + reduced = paddle.fluid.layers.reduce_all(data_x, dim=axis, keep_dim=keepdim) out = paddle.cast(reduced, 'int32') cpu = paddle.static.cpu_places(1) diff --git a/src/frontends/paddle/tests/test_models/gen_scripts/generate_relu6.py b/src/frontends/paddle/tests/test_models/gen_scripts/generate_relu6.py index 2c79c0332a7698..0af6c04ea2d5af 100644 --- a/src/frontends/paddle/tests/test_models/gen_scripts/generate_relu6.py +++ b/src/frontends/paddle/tests/test_models/gen_scripts/generate_relu6.py @@ -15,8 +15,11 @@ def relu6(name: str, x, threshold: float = 6.0, data_type='float32'): with paddle.static.program_guard(paddle.static.Program(), paddle.static.Program()): node_x = paddle.static.data(name='x', shape=x.shape, dtype=data_type) - out = paddle.fluid.layers.relu6(node_x, threshold=threshold, name='relu6') - + + if paddle.__version__ >= '2.0.0': + out = paddle.nn.functional.relu6(node_x, name='relu6') + else: + out = paddle.fluid.layers.relu6(node_x, name='relu6') cpu = paddle.static.cpu_places(1) exe = paddle.static.Executor(cpu[0]) # startup program will call initializer to initialize the parameters. diff --git a/src/frontends/paddle/tests/test_models/gen_scripts/generate_reshape.py b/src/frontends/paddle/tests/test_models/gen_scripts/generate_reshape.py index 289c2128a0d972..24fbc3f3af351a 100644 --- a/src/frontends/paddle/tests/test_models/gen_scripts/generate_reshape.py +++ b/src/frontends/paddle/tests/test_models/gen_scripts/generate_reshape.py @@ -17,7 +17,10 @@ def reshape(name : str, x, out_shape): with paddle.static.program_guard(paddle.static.Program(), paddle.static.Program()): node_x = paddle.static.data(name='x', shape=x.shape, dtype=data_type) - out = paddle.fluid.layers.reshape(x=node_x, shape=out_shape) + if paddle.__version__ >= '2.0.0': + out = paddle.reshape(x=node_x, shape=out_shape) + else: + out = paddle.fluid.layers.reshape(x=node_x, shape=out_shape) cpu = paddle.static.cpu_places(1) exe = paddle.static.Executor(cpu[0]) @@ -42,11 +45,14 @@ def reshape_tensor(name : str, x, out_shape, use_tensor_in_list): node_x = paddle.static.data(name='x', shape=x.shape, dtype=data_type) if use_tensor_in_list: out_shape[0] = paddle.assign(np.array((out_shape[0],)).astype('int32')) - out = paddle.fluid.layers.reshape(x=node_x, shape=out_shape) + if paddle.__version__ >= '2.0.0': + out = paddle.reshape(x=node_x, shape=out_shape) + else: + out = paddle.fluid.layers.reshape(x=node_x, shape=out_shape) else: out_shape = np.array(out_shape).astype('int32') node_shape = paddle.assign(out_shape) - out = paddle.fluid.layers.reshape(x=node_x, shape=node_shape) + out = paddle.reshape(x=node_x, shape=node_shape) out = paddle.pow(out, 1) cpu = paddle.static.cpu_places(1) diff --git a/src/frontends/paddle/tests/test_models/gen_scripts/generate_reverse.py b/src/frontends/paddle/tests/test_models/gen_scripts/generate_reverse.py deleted file mode 100644 index e993057df8389d..00000000000000 --- a/src/frontends/paddle/tests/test_models/gen_scripts/generate_reverse.py +++ /dev/null @@ -1,61 +0,0 @@ -# Copyright (C) 2018-2023 Intel Corporation -# SPDX-License-Identifier: Apache-2.0 - -# -# reverse paddle model generator -# -import numpy as np -from save_model import saveModel -import sys -import paddle - -def reverse(name: str, x, axis, use_static=True, dtype="float32"): - paddle.enable_static() - - with paddle.static.program_guard(paddle.static.Program(), paddle.static.Program()): - if use_static: - node_x = paddle.static.data(name='x', shape=x.shape, dtype=dtype) - else: - node_x = paddle.fluid.data(name='x', shape=[1, 1, -1, -1], dtype=dtype) - out = paddle.fluid.layers.reverse(node_x, axis) - - cpu = paddle.static.cpu_places(1) - exe = paddle.static.Executor(cpu[0]) - # startup program will call initializer to initialize the parameters. - exe.run(paddle.static.default_startup_program()) - - outs = exe.run( - feed={'x': x}, - fetch_list=[out]) - - saveModel(name, exe, feedkeys=['x'], fetchlist=[out], inputs=[x], outputs=[outs[0]], target_dir=sys.argv[1]) - - return outs[0] - -def main(): - data1 = np.array([0,2], dtype='int64') - reverse("reverse_static_1", data1, 0, True, 'int64') - - data2 = np.array([[0,1,2], [3,4,5], [6,7,8]], dtype='float32') - reverse("reverse_static_2", data2, 1, True, 'float32') - - data3 = np.array([[0,1,2], [3,4,5], [6,7,8]], dtype='float32') - reverse("reverse_static_3", data3, [0, 1], True, 'float32') - - data4 = np.array([[0,1,2], [3,4,5], [6,7,8]], dtype='int32') - reverse("reverse_static_4", data4, -1, True, 'int32') - - data5 = np.random.randn(1, 1, 32, 32).astype('int32') - reverse("reverse_dynamic_1", data5, [2], False, dtype='int32') - - data6 = np.random.randn(1, 1, 64, 64).astype('float32') - reverse("reverse_dynamic_2", data6, [3], False, dtype='float32') - - data7 = np.random.randn(1, 1, 112, 112).astype('float32') - reverse("reverse_dynamic_3", data7, [2,3], False, dtype='float32') - - data8 = np.random.randn(1, 1, 224, 224).astype('int32') - reverse("reverse_dynamic_4", data8, [-2, -1], False, dtype='int32') - -if __name__ == "__main__": - main() diff --git a/src/frontends/paddle/tests/test_models/gen_scripts/generate_scale.py b/src/frontends/paddle/tests/test_models/gen_scripts/generate_scale.py index 2cea7f87e15a12..cacd230574e1d5 100644 --- a/src/frontends/paddle/tests/test_models/gen_scripts/generate_scale.py +++ b/src/frontends/paddle/tests/test_models/gen_scripts/generate_scale.py @@ -34,12 +34,15 @@ def paddle_scale(name : str, x, scale, bias, attrs : dict, data_type): def paddle_scale_tensor(name : str, x, scale, bias, attrs : dict, data_type): - import paddle as paddle + import paddle paddle.enable_static() with paddle.static.program_guard(paddle.static.Program(), paddle.static.Program()): node_x = paddle.static.data(name='x', shape=x.shape, dtype=data_type) - node_scale = paddle.static.data(name='scale', shape=[1], dtype='float32') + if paddle.__version__ >= '2.5.1': + node_scale = paddle.static.data(name='scale', shape=[], dtype='float32') + else: + node_scale = paddle.static.data(name='scale', shape=[1], dtype='float32') out = paddle.scale(x=node_x, scale=node_scale, bias=bias, bias_after_scale=attrs['bias_after_scale']) #FuzzyTest only support FP32 now, so cast result to fp32 @@ -53,7 +56,10 @@ def paddle_scale_tensor(name : str, x, scale, bias, attrs : dict, data_type): feed={'x': x, 'scale': scale}, fetch_list=[out]) - saveModel(name, exe, feedkeys=['x', 'scale'], fetchlist=[out], inputs=[x, np.array([scale]).astype('float32')], outputs=[outs[0]], target_dir=sys.argv[1]) + if paddle.__version__ >= '2.5.1': + saveModel(name, exe, feedkeys=['x', 'scale'], fetchlist=[out], inputs=[x, np.array(scale).astype('float32')], outputs=[outs[0]], target_dir=sys.argv[1]) + else: + saveModel(name, exe, feedkeys=['x', 'scale'], fetchlist=[out], inputs=[x, np.array([scale]).astype('float32')], outputs=[outs[0]], target_dir=sys.argv[1]) return outs[0] diff --git a/src/frontends/paddle/tests/test_models/gen_scripts/generate_set_value.py b/src/frontends/paddle/tests/test_models/gen_scripts/generate_set_value.py index a3266684a7dcfa..876eb03825bbf1 100644 --- a/src/frontends/paddle/tests/test_models/gen_scripts/generate_set_value.py +++ b/src/frontends/paddle/tests/test_models/gen_scripts/generate_set_value.py @@ -167,4 +167,4 @@ def set_value7(x, value, *slice): paddle_set_value("set_value_dynamic2", data, value, set_value7, dtype, starts, ends, steps, is_dynamic=True) if __name__ == "__main__": - main() + main() \ No newline at end of file diff --git a/src/frontends/paddle/tests/test_models/gen_scripts/generate_sigmoid.py b/src/frontends/paddle/tests/test_models/gen_scripts/generate_sigmoid.py index 7b6bc715e6a54f..09c8327f277350 100644 --- a/src/frontends/paddle/tests/test_models/gen_scripts/generate_sigmoid.py +++ b/src/frontends/paddle/tests/test_models/gen_scripts/generate_sigmoid.py @@ -15,7 +15,10 @@ def sigmoid(name: str, x, data_type): with paddle.static.program_guard(paddle.static.Program(), paddle.static.Program()): node_x = paddle.static.data(name='x', shape=x.shape, dtype=data_type) - out = paddle.fluid.layers.sigmoid(node_x, name='sigmoid') + if paddle.__version__ >= '2.0.0': + out = paddle.nn.functional.sigmoid(node_x, name='sigmoid') + else: + out = paddle.fluid.layers.sigmoid(node_x, name='sigmoid') cpu = paddle.static.cpu_places(1) exe = paddle.static.Executor(cpu[0]) diff --git a/src/frontends/paddle/tests/test_models/gen_scripts/generate_split.py b/src/frontends/paddle/tests/test_models/gen_scripts/generate_split.py index 639ab5b51d14c1..d92d286ec6c57b 100644 --- a/src/frontends/paddle/tests/test_models/gen_scripts/generate_split.py +++ b/src/frontends/paddle/tests/test_models/gen_scripts/generate_split.py @@ -15,8 +15,11 @@ def split(name : str, x, attrs : dict): with paddle.static.program_guard(paddle.static.Program(), paddle.static.Program()): node_x = paddle.static.data(name='x', shape=x.shape, dtype=x.dtype) - out = paddle.fluid.layers.split(node_x, num_or_sections=attrs['num_or_sections'], dim=attrs['axis']) - + + if paddle.__version__ >= '2.0.0': + out = paddle.split(node_x, num_or_sections=attrs['num_or_sections'], axis=attrs['axis']) + else: + out = paddle.fluid.layers.split(node_x, num_or_sections=attrs['num_or_sections'], dim=attrs['axis']) cpu = paddle.static.cpu_places(1) exe = paddle.static.Executor(cpu[0]) # startup program will call initializer to initialize the parameters. @@ -40,7 +43,10 @@ def split_dim_tensor(name : str, x, attrs : dict, dim): with paddle.static.program_guard(paddle.static.Program(), paddle.static.Program()): node_x = paddle.static.data(name='x', shape=x.shape, dtype=x.dtype) dim_node = paddle.assign(dim) - out = paddle.fluid.layers.split(node_x, num_or_sections=attrs['num_or_sections'], dim=dim_node) + if paddle.__version__ >= '2.0.0': + out = paddle.split(node_x, num_or_sections=attrs['num_or_sections'], axis=dim_node) + else: + out = paddle.fluid.layers.split(node_x, num_or_sections=attrs['num_or_sections'], dim=dim_node) cpu = paddle.static.cpu_places(1) exe = paddle.static.Executor(cpu[0]) @@ -66,8 +72,10 @@ def split_test_list_tensor(name : str, x, attrs : dict): node_x = paddle.static.data(name='x', shape=x.shape, dtype=x.dtype) section = attrs['num_or_sections'] section[0] = paddle.assign(np.array((section[0],)).astype('int32')) - out = paddle.fluid.layers.split(node_x, num_or_sections=section, dim=attrs['axis']) - + if paddle.__version__ >= '2.0.0': + out = paddle.split(node_x, num_or_sections=section, axis=attrs['axis']) + else: + out = paddle.fluid.layers.split(node_x, num_or_sections=section, dim=attrs['axis']) cpu = paddle.static.cpu_places(1) exe = paddle.static.Executor(cpu[0]) # startup program will call initializer to initialize the parameters. diff --git a/src/frontends/paddle/tests/test_models/gen_scripts/generate_squeeze.py b/src/frontends/paddle/tests/test_models/gen_scripts/generate_squeeze.py index 08f99ddc3dcdd3..855646d795372d 100644 --- a/src/frontends/paddle/tests/test_models/gen_scripts/generate_squeeze.py +++ b/src/frontends/paddle/tests/test_models/gen_scripts/generate_squeeze.py @@ -16,8 +16,10 @@ def squeeze(name : str, x, axes : list): with paddle.static.program_guard(paddle.static.Program(), paddle.static.Program()): node_x = paddle.static.data(name='x', shape=x.shape, dtype = data_type) - out = paddle.fluid.layers.squeeze(node_x, axes=axes, name='squeeze') - + if paddle.__version__ >= '2.0.0': + out = paddle.squeeze(node_x, axis=axes, name='squeeze') + else: + out = paddle.fluid.layers.squeeze(node_x, axes=axes, name='squeeze') cpu = paddle.static.cpu_places(1) exe = paddle.static.Executor(cpu[0]) # startup program will call initializer to initialize the parameters. diff --git a/src/frontends/paddle/tests/test_models/gen_scripts/generate_strided_slice.py b/src/frontends/paddle/tests/test_models/gen_scripts/generate_strided_slice.py index b9517b6add48c4..d651da8dfb0774 100644 --- a/src/frontends/paddle/tests/test_models/gen_scripts/generate_strided_slice.py +++ b/src/frontends/paddle/tests/test_models/gen_scripts/generate_strided_slice.py @@ -11,124 +11,145 @@ def strided_slice(name: str, input_data, attrs: dict): import paddle + paddle.enable_static() with paddle.static.program_guard(paddle.static.Program(), paddle.static.Program()): Input = paddle.static.data( - name='x', shape=input_data.shape, dtype=input_data.dtype) - - out = paddle.fluid.layers.strided_slice(Input, axes=attrs['axes'], - starts=attrs['starts'], - ends=attrs['ends'], - strides=attrs['strides']) + name="x", shape=input_data.shape, dtype=input_data.dtype + ) + + if paddle.__version__ >= '2.0.0': + out = paddle.strided_slice( + Input, + axes=attrs["axes"], + starts=attrs["starts"], + ends=attrs["ends"], + strides=attrs["strides"], + ) + else: + out = paddle.fluid.layers.strided_slice(Input, axes=attrs['axes'], + starts=attrs['starts'], + ends=attrs['ends'], + strides=attrs['strides']) cpu = paddle.static.cpu_places(1) exe = paddle.static.Executor(cpu[0]) # startup program will call initializer to initialize the parameters. exe.run(paddle.static.default_startup_program()) - outs = exe.run( - feed={'x': input_data}, - fetch_list=[out]) + outs = exe.run(feed={"x": input_data}, fetch_list=[out]) # Save inputs in order of OpenVINO model, to facilite Fuzzy test, # which accepts inputs and outputs in this order as well. - saveModel(name, exe, feedkeys=['x'], fetchlist=[out], - inputs=[input_data], outputs=[outs[0]], target_dir=sys.argv[1]) + saveModel( + name, + exe, + feedkeys=["x"], + fetchlist=[out], + inputs=[input_data], + outputs=[outs[0]], + target_dir=sys.argv[1], + ) return outs if __name__ == "__main__": - strided_slice_input1_1 = { - 'name': "strided_slice_input1_1", - 'axes': np.array([0]).astype('int32').tolist(), - 'starts': np.array([-4]).astype('int32').tolist(), - 'ends': np.array([-3]).astype('int32').tolist(), - 'strides': np.array([1]).astype('int32').tolist() + "name": "strided_slice_input1_1", + "axes": np.array([0]).astype("int32").tolist(), + "starts": np.array([-4]).astype("int32").tolist(), + "ends": np.array([-3]).astype("int32").tolist(), + "strides": np.array([1]).astype("int32").tolist(), } strided_slice_input1_2 = { - 'name': "strided_slice_input1_2", - 'axes': np.array([0]).astype('int32').tolist(), - 'starts': np.array([3]).astype('int32').tolist(), - 'ends': np.array([8]).astype('int32').tolist(), - 'strides': np.array([1]).astype('int32').tolist() + "name": "strided_slice_input1_2", + "axes": np.array([0]).astype("int32").tolist(), + "starts": np.array([3]).astype("int32").tolist(), + "ends": np.array([8]).astype("int32").tolist(), + "strides": np.array([1]).astype("int32").tolist(), } strided_slice_input1_3 = { - 'name': "strided_slice_input1_3", - 'axes': np.array([0]).astype('int32').tolist(), - 'starts': np.array([5]).astype('int32').tolist(), - 'ends': np.array([0]).astype('int32').tolist(), - 'strides': np.array([-1]).astype('int32').tolist() + "name": "strided_slice_input1_3", + "axes": np.array([0]).astype("int32").tolist(), + "starts": np.array([5]).astype("int32").tolist(), + "ends": np.array([0]).astype("int32").tolist(), + "strides": np.array([-1]).astype("int32").tolist(), } strided_slice_input1_4 = { - 'name': "strided_slice_input1_4", - 'axes': np.array([0]).astype('int32').tolist(), - 'starts': np.array([-1]).astype('int32').tolist(), - 'ends': np.array([-3]).astype('int32').tolist(), - 'strides': np.array([-1]).astype('int32').tolist() + "name": "strided_slice_input1_4", + "axes": np.array([0]).astype("int32").tolist(), + "starts": np.array([-1]).astype("int32").tolist(), + "ends": np.array([-3]).astype("int32").tolist(), + "strides": np.array([-1]).astype("int32").tolist(), } strided_slice_input2_1 = { - 'name': "strided_slice_input2_1", - 'axes': np.array([0, 1, 2]).astype('int32').tolist(), - 'starts': np.array([1, 0, 0]).astype('int32').tolist(), - 'ends': np.array([2, 1, 3]).astype('int32').tolist(), - 'strides': np.array([1, 1, 1]).astype('int32').tolist() + "name": "strided_slice_input2_1", + "axes": np.array([0, 1, 2]).astype("int32").tolist(), + "starts": np.array([1, 0, 0]).astype("int32").tolist(), + "ends": np.array([2, 1, 3]).astype("int32").tolist(), + "strides": np.array([1, 1, 1]).astype("int32").tolist(), } strided_slice_input2_2 = { - 'name': "strided_slice_input2_2", - 'axes': np.array([0, 1, 2]).astype('int32').tolist(), - 'starts': np.array([1, -1, 0]).astype('int32').tolist(), - 'ends': np.array([2, -3, 3]).astype('int32').tolist(), - 'strides': np.array([1, -1, 1]).astype('int32').tolist() + "name": "strided_slice_input2_2", + "axes": np.array([0, 1, 2]).astype("int32").tolist(), + "starts": np.array([1, -1, 0]).astype("int32").tolist(), + "ends": np.array([2, -3, 3]).astype("int32").tolist(), + "strides": np.array([1, -1, 1]).astype("int32").tolist(), } strided_slice_input2_3 = { - 'name': "strided_slice_input2_3", - 'axes': np.array([0, 1, 2]).astype('int32').tolist(), - 'starts': np.array([1, 0, 0]).astype('int32').tolist(), - 'ends': np.array([2, 2, 3]).astype('int32').tolist(), - 'strides': np.array([1, 1, 1]).astype('int32').tolist() + "name": "strided_slice_input2_3", + "axes": np.array([0, 1, 2]).astype("int32").tolist(), + "starts": np.array([1, 0, 0]).astype("int32").tolist(), + "ends": np.array([2, 2, 3]).astype("int32").tolist(), + "strides": np.array([1, 1, 1]).astype("int32").tolist(), } strided_slice_input3_1 = { - 'name': "strided_slice_input3_1", - 'axes': np.array([1]).astype('int32').tolist(), - 'starts': np.array([1]).astype('int32').tolist(), - 'ends': np.array([2]).astype('int32').tolist(), - 'strides': np.array([1]).astype('int32').tolist() + "name": "strided_slice_input3_1", + "axes": np.array([1]).astype("int32").tolist(), + "starts": np.array([1]).astype("int32").tolist(), + "ends": np.array([2]).astype("int32").tolist(), + "strides": np.array([1]).astype("int32").tolist(), } strided_slice_input3_2 = { - 'name': "strided_slice_input3_2", - 'axes': np.array([1]).astype('int32').tolist(), - 'starts': np.array([-1]).astype('int32').tolist(), - 'ends': np.array([-2]).astype('int32').tolist(), - 'strides': np.array([-1]).astype('int32').tolist() + "name": "strided_slice_input3_2", + "axes": np.array([1]).astype("int32").tolist(), + "starts": np.array([-1]).astype("int32").tolist(), + "ends": np.array([-2]).astype("int32").tolist(), + "strides": np.array([-1]).astype("int32").tolist(), } - strided_slice_input1_list = [strided_slice_input1_1, - strided_slice_input1_2, strided_slice_input1_3, strided_slice_input1_4] + strided_slice_input1_list = [ + strided_slice_input1_1, + strided_slice_input1_2, + strided_slice_input1_3, + strided_slice_input1_4, + ] - strided_slice_input2_list = [strided_slice_input2_1, - strided_slice_input2_2, strided_slice_input2_3] + strided_slice_input2_list = [ + strided_slice_input2_1, + strided_slice_input2_2, + strided_slice_input2_3, + ] - strided_slice_input3_list = [ - strided_slice_input3_1, strided_slice_input3_2] + strided_slice_input3_list = [strided_slice_input3_1, strided_slice_input3_2] - input1 = np.random.rand(100).astype('float32') + input1 = np.random.rand(100).astype("float32") for item in strided_slice_input1_list: - pred_paddle = strided_slice(item['name'], input1, item) + pred_paddle = strided_slice(item["name"], input1, item) - input2 = np.random.rand(5, 5, 5).astype('int32') + input2 = np.random.rand(5, 5, 5).astype("int32") for item in strided_slice_input2_list: - pred_paddle = strided_slice(item['name'], input2, item) + pred_paddle = strided_slice(item["name"], input2, item) - input3 = np.random.rand(1, 100, 1).astype('float32') + input3 = np.random.rand(1, 100, 1).astype("float32") for item in strided_slice_input3_list: - pred_paddle = strided_slice(item['name'], input3, item) + pred_paddle = strided_slice(item["name"], input3, item) diff --git a/src/frontends/paddle/tests/test_models/gen_scripts/generate_swish.py b/src/frontends/paddle/tests/test_models/gen_scripts/generate_swish.py index 9d7d68ae0ec8ed..cd83bc22a16652 100644 --- a/src/frontends/paddle/tests/test_models/gen_scripts/generate_swish.py +++ b/src/frontends/paddle/tests/test_models/gen_scripts/generate_swish.py @@ -3,22 +3,25 @@ # import numpy as np from save_model import saveModel -import paddle as pdpd +import paddle import sys -def swish(name: str, x, data_type, input_beta): - pdpd.enable_static() +def swish(name: str, x, data_type): + paddle.enable_static() - with pdpd.static.program_guard(pdpd.static.Program(), pdpd.static.Program()): - node_x = pdpd.static.data( + with paddle.static.program_guard(paddle.static.Program(), paddle.static.Program()): + node_x = paddle.static.data( name='input_x', shape=x.shape, dtype=data_type) - out = pdpd.fluid.layers.swish(x=node_x, beta=input_beta, name='swish') + if paddle.__version__ >= '2.0.0': + out = paddle.nn.functional.swish(x=node_x, name='swish') + else: + out = paddle.fluid.layers.swish(x=node_x, name='swish') - cpu = pdpd.static.cpu_places(1) - exe = pdpd.static.Executor(cpu[0]) + cpu = paddle.static.cpu_places(1) + exe = paddle.static.Executor(cpu[0]) # startup program will call initializer to initialize the parameters. - exe.run(pdpd.static.default_startup_program()) + exe.run(paddle.static.default_startup_program()) outs = exe.run( feed={'input_x': x}, @@ -34,11 +37,11 @@ def main(): data_type = 'float32' input_beta = 1.0 x = np.random.randn(2, 3).astype(data_type) - swish("swish_default_params", x, data_type, input_beta) + swish("swish_default_params", x, data_type) input_beta = 2.0 x = np.random.randn(2, 3).astype(data_type) - swish("swish_beta", x, data_type, input_beta) + swish("swish_beta", x, data_type) if __name__ == "__main__": diff --git a/src/frontends/paddle/tests/test_models/gen_scripts/generate_tile.py b/src/frontends/paddle/tests/test_models/gen_scripts/generate_tile.py index bf9089d5c710fb..84174906b39609 100644 --- a/src/frontends/paddle/tests/test_models/gen_scripts/generate_tile.py +++ b/src/frontends/paddle/tests/test_models/gen_scripts/generate_tile.py @@ -8,7 +8,6 @@ from save_model import saveModel import paddle import sys -from paddle.fluid.layers.tensor import fill_constant def paddle_tile(name: str, x, repeat_times, to_tensor=False, tensor_list=False): @@ -24,7 +23,11 @@ def paddle_tile(name: str, x, repeat_times, to_tensor=False, tensor_list=False): repeat_times_list = [] if tensor_list: for i in repeat_times: - temp_out = fill_constant([1], "int32", i, force_cpu=True) + if paddle.__version__ >= '2.0.0': + temp_out = paddle.full([1], i, "int32").cpu() + else: + temp_out = paddle.fluid.layers.tensor.fill_constant([1], "int32", i, force_cpu=True) + repeat_times_list.append(temp_out) else: repeat_times_list = repeat_times diff --git a/src/frontends/paddle/tests/test_models/gen_scripts/generate_unsqueeze.py b/src/frontends/paddle/tests/test_models/gen_scripts/generate_unsqueeze.py index 1260e2cb2040ca..50ef4693635514 100644 --- a/src/frontends/paddle/tests/test_models/gen_scripts/generate_unsqueeze.py +++ b/src/frontends/paddle/tests/test_models/gen_scripts/generate_unsqueeze.py @@ -16,7 +16,10 @@ def unsqueeze(name : str, x, axes : list): with paddle.static.program_guard(paddle.static.Program(), paddle.static.Program()): node_x = paddle.static.data(name='x', shape=x.shape, dtype = data_type) - out = paddle.fluid.layers.unsqueeze(node_x, axes = axes, name = 'unsqueeze') + if paddle.__version__ >= '2.0.0': + out = paddle.unsqueeze(node_x, axis=axes, name='unsqueeze') + else: + out = paddle.fluid.layers.unsqueeze(node_x, axes=axes, name='unsqueeze') cpu = paddle.static.cpu_places(1) exe = paddle.static.Executor(cpu[0]) diff --git a/src/frontends/paddle/tests/test_models/gen_scripts/generate_where.py b/src/frontends/paddle/tests/test_models/gen_scripts/generate_where.py index 3f6a8d89903917..3dbde8def410d3 100644 --- a/src/frontends/paddle/tests/test_models/gen_scripts/generate_where.py +++ b/src/frontends/paddle/tests/test_models/gen_scripts/generate_where.py @@ -22,7 +22,10 @@ def where(name, test_x, test_y, test_cond): Cond_Node = paddle.static.data( name='cond', shape=test_cond.shape, dtype=test_cond.dtype) - Cond_Node_bl = paddle.fluid.layers.cast(Cond_Node, "bool") + if paddle.__version__ >= '2.0.0': + Cond_Node_bl = paddle.cast(Cond_Node, "bool") + else: + Cond_Node_bl = paddle.fluid.layers.cast(Cond_Node, "bool") out = paddle.where(Cond_Node_bl, X_Node, Y_Node) cpu = paddle.static.cpu_places(1) diff --git a/src/frontends/paddle/tests/test_models/gen_scripts/generate_where_index.py b/src/frontends/paddle/tests/test_models/gen_scripts/generate_where_index.py index 369162cbdba38e..b7c1ee8258f294 100644 --- a/src/frontends/paddle/tests/test_models/gen_scripts/generate_where_index.py +++ b/src/frontends/paddle/tests/test_models/gen_scripts/generate_where_index.py @@ -16,7 +16,10 @@ def where_index(name: str, x, force_boolean=False): with paddle.static.program_guard(paddle.static.Program(), paddle.static.Program()): node_x = paddle.static.data(name='x', shape=x.shape, dtype=x.dtype) if force_boolean: - node_x_bl = paddle.fluid.layers.cast(node_x, "bool") + if paddle.__version__ >= '2.0.0': + node_x_bl = paddle.cast(node_x, "bool") + else: + node_x_bl = paddle.fluid.layers.cast(node_x, "bool") out = paddle.nonzero(node_x_bl) else: out = paddle.nonzero(node_x) diff --git a/src/frontends/paddle/tests/test_models/gen_scripts/nms.py b/src/frontends/paddle/tests/test_models/gen_scripts/nms.py index d4123e239f6f3d..fc74071799814d 100644 --- a/src/frontends/paddle/tests/test_models/gen_scripts/nms.py +++ b/src/frontends/paddle/tests/test_models/gen_scripts/nms.py @@ -9,30 +9,32 @@ import sys from save_model import saveModel, exportModel, print_alike +from paddle.fluid import data_feeder + # bboxes shape (N, M, 4) if shared else (M, C, 4) # scores shape (N, C, M) if shared else (M, C) def NMS(name: str, bboxes, scores, attrs: dict, rois_num=None, verbose=False): - import paddle as pdpd + import paddle from ops import multiclass_nms as multiclass_nms from ops import matrix_nms as matrix_nms - pdpd.enable_static() + paddle.enable_static() - with pdpd.static.program_guard(pdpd.static.Program(), - pdpd.static.Program()): + with paddle.static.program_guard(paddle.static.Program(), + paddle.static.Program()): # make model with inputs of dynamic shape - node_boxes = pdpd.static.data(name='bboxes', + node_boxes = paddle.static.data(name='bboxes', shape=[-1, -1, 4], dtype=bboxes.dtype, lod_level=1) - node_scores = pdpd.static.data(name='scores', + node_scores = paddle.static.data(name='scores', shape=[-1] * len(scores.shape), dtype=scores.dtype, lod_level=1) node_rois_num = None if rois_num is not None: - node_rois_num = pdpd.static.data(name='rois_num', + node_rois_num = paddle.static.data(name='rois_num', shape=rois_num.shape, dtype=rois_num.dtype, lod_level=1) @@ -67,14 +69,14 @@ def NMS(name: str, bboxes, scores, attrs: dict, rois_num=None, verbose=False): output = [] for x in nms_outputs: if x is not None: - if x.dtype==pdpd.int32 or x.dtype==pdpd.int64: - x = pdpd.cast(x, "float32") + if x.dtype==paddle.int32 or x.dtype==paddle.int64: + x = paddle.cast(x, "float32") output.append(x) - cpu = pdpd.static.cpu_places(1) - exe = pdpd.static.Executor(cpu[0]) + cpu = paddle.static.cpu_places(1) + exe = paddle.static.Executor(cpu[0]) # startup program will call initializer to initialize the parameters. - exe.run(pdpd.static.default_startup_program()) + exe.run(paddle.static.default_startup_program()) fetch_vars = [x for x in output if x is not None] feed_dict = {'bboxes': bboxes, 'scores': scores} @@ -92,9 +94,12 @@ def NMS(name: str, bboxes, scores, attrs: dict, rois_num=None, verbose=False): out = np.array(output_lod.pop(0)) nms_rois_num = np.array( output_lod.pop(0)) if output[1] is not None else None - index = np.array(output_lod.pop(0)).astype(pdpd.fluid.data_feeder.convert_dtype( - output[2].dtype)) if output[2] is not None else None - + if paddle.__version__ >= '2.0.0': + index = np.array(output_lod.pop(0)).astype(data_feeder.convert_dtype( + output[2].dtype)) if output[2] is not None else None + else: + index = np.array(output_lod.pop(0)).astype(paddle.fluid.data_feeder.convert_dtype( + output[2].dtype)) if output[2] is not None else None # Save inputs in order of OpenVINO model, to facilite Fuzzy test, # which accepts inputs and outputs in this order as well. output_np = [out, nms_rois_num, index] diff --git a/src/frontends/pytorch/src/CMakeLists.txt b/src/frontends/pytorch/src/CMakeLists.txt index f51dee59b761db..814d820b5c17aa 100644 --- a/src/frontends/pytorch/src/CMakeLists.txt +++ b/src/frontends/pytorch/src/CMakeLists.txt @@ -6,4 +6,4 @@ ov_add_frontend(NAME pytorch LINKABLE_FRONTEND SHUTDOWN_PROTOBUF FILEDESCRIPTION "FrontEnd to load and convert TorchScript models from PyTorch" - LINK_LIBRARIES openvino::util openvino::core::dev) \ No newline at end of file + LINK_LIBRARIES openvino::util openvino::core::dev) diff --git a/src/frontends/pytorch/src/frontend.cpp b/src/frontends/pytorch/src/frontend.cpp index 1f021dfba441f5..15d9be8dafc6ce 100644 --- a/src/frontends/pytorch/src/frontend.cpp +++ b/src/frontends/pytorch/src/frontend.cpp @@ -36,7 +36,7 @@ #include "transforms/prim_list_construct_pad.hpp" #include "transforms/prim_list_tuple_construct_replacer.hpp" #include "transforms/prim_list_unpack_replacer.hpp" -#include "transforms/prim_tuple_unpack_parameter_replacer.hpp" +#include "transforms/prim_unpack_parameter_replacer.hpp" #include "transforms/quantized_node_remover.hpp" #include "transforms/reverseprop_resolver.hpp" #include "transforms/rfftn_complex_replacer.hpp" @@ -195,7 +195,7 @@ 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(); manager.register_pass(); diff --git a/src/frontends/pytorch/src/op/copy.cpp b/src/frontends/pytorch/src/op/copy.cpp index 271d06ffd92a88..f4cb61f83cb7d9 100644 --- a/src/frontends/pytorch/src/op/copy.cpp +++ b/src/frontends/pytorch/src/op/copy.cpp @@ -29,6 +29,17 @@ OutputVector translate_copy_(const NodeContext& context) { return {res}; }; +OutputVector translate_alias_copy(const NodeContext& context) { + // aten::alias_copy(Tensor self) -> Tensor + // aten::alias_copy.out(Tensor self, *, Tensor(a!) out) -> Tensor(a!) + num_inputs_check(context, 1, 2); + auto self = context.get_input(0); + if (!context.input_is_none(1)) { + context.mutate_input(1, self); + } + return {self}; +} + } // namespace op } // namespace pytorch } // namespace frontend diff --git a/src/frontends/pytorch/src/op/cross.cpp b/src/frontends/pytorch/src/op/cross.cpp new file mode 100644 index 00000000000000..06392a14e0e3c7 --- /dev/null +++ b/src/frontends/pytorch/src/op/cross.cpp @@ -0,0 +1,101 @@ +// 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/multiply.hpp" +#include "openvino/op/roll.hpp" +#include "openvino/op/subtract.hpp" +#include "openvino/op/unsqueeze.hpp" +#include "utils.hpp" + +namespace ov { +namespace frontend { +namespace pytorch { +namespace op { + +using namespace ov::op; + +namespace { +Output translate_cross_base(const NodeContext& context, Output self, Output other, Output dim) { + auto const_1 = context.mark_node(v0::Constant::create(element::i32, Shape{1}, {1})); + auto const_2 = context.mark_node(v0::Constant::create(element::i32, Shape{1}, {2})); + auto x_roll_1 = context.mark_node(std::make_shared(self, const_2, dim)); + auto x_roll_2 = context.mark_node(std::make_shared(self, const_1, dim)); + auto y_roll_1 = context.mark_node(std::make_shared(other, const_1, dim)); + auto y_roll_2 = context.mark_node(std::make_shared(other, const_2, dim)); + auto mul_1 = context.mark_node(std::make_shared(x_roll_1, y_roll_1)); + auto mul_2 = context.mark_node(std::make_shared(x_roll_2, y_roll_2)); + return context.mark_node(std::make_shared(mul_1, mul_2)); +} + +} // namespace +OutputVector translate_linalg_cross(const NodeContext& context) { + // aten::linalg_cross(Tensor self, Tensor other, int? dim=-1) -> Tensor + // aten::linalg_cross.out(Tensor self, Tensor other, int? dim=-1, *, Tensor(a!) out) -> Tensor(a!) + num_inputs_check(context, 3, 4); + auto self = context.get_input(0); + auto other = context.get_input(1); + align_eltwise_input_types(context, self, other, true); + auto const_minus_1 = context.mark_node(v0::Constant::create(element::i32, Shape{1}, {-1})); + Output dim; + if (context.input_is_none(2)) { + dim = const_minus_1; + } else { + dim = context.get_input(2); + auto const_0 = context.mark_node(v0::Constant::create(element::i32, Shape{1}, {0})); + dim = context.mark_node(std::make_shared(dim, const_0)); + } + auto res = translate_cross_base(context, self, other, dim); + if (!context.input_is_none(3)) { + context.mutate_input(3, res); + } + + return {res}; +}; + +OutputVector translate_cross(const NodeContext& context) { + // aten::cross(Tensor self, Tensor other, int? dim=None) -> Tensor + // aten::cross.out(Tensor self, Tensor other, int? dim=None, *, Tensor(a!) out) -> Tensor(a!) + num_inputs_check(context, 3, 4); + auto self = context.get_input(0); + auto other = context.get_input(1); + align_eltwise_input_types(context, self, other, true); + Output dim; + if (context.input_is_none(2)) { + // If dim is not given, it defaults to the first dimension found with the size 3 + auto pshape = self.get_partial_shape(); + if (pshape.rank().is_dynamic()) { + FRONT_END_GENERAL_CHECK(false, "Rank should be known for aten::cross without explicit dim"); + } + size_t dim_id = static_cast(pshape.rank().get_length()); + size_t rank = static_cast(pshape.rank().get_length()); + for (size_t i = 0; i < rank; i++) { + if (pshape[i].is_static() && pshape[i] == ov::Dimension(3)) { + dim_id = i; + break; + } + } + if (dim_id == rank) { + FRONT_END_GENERAL_CHECK(false, "Suitable dim for aten::cross not found"); + } + dim = context.mark_node(v0::Constant::create(element::i32, Shape{1}, {dim_id})); + + } else { + dim = context.get_input(2); + auto const_0 = context.mark_node(v0::Constant::create(element::i32, Shape{1}, {0})); + dim = context.mark_node(std::make_shared(dim, const_0)); + } + auto res = translate_cross_base(context, self, other, dim); + if (!context.input_is_none(3)) { + context.mutate_input(3, res); + } + + return {res}; +}; + +} // namespace op +} // namespace pytorch +} // namespace frontend +} // namespace ov \ No newline at end of file diff --git a/src/frontends/pytorch/src/op/rand.cpp b/src/frontends/pytorch/src/op/rand.cpp index 677a3e86a52ac0..d04b3bbd2780b7 100644 --- a/src/frontends/pytorch/src/op/rand.cpp +++ b/src/frontends/pytorch/src/op/rand.cpp @@ -3,6 +3,7 @@ // #include +#include "openvino/frontend/common/random_normal_helper.hpp" #include "openvino/frontend/pytorch/node_context.hpp" #include "openvino/op/add.hpp" #include "openvino/op/constant.hpp" @@ -15,6 +16,7 @@ #include "openvino/op/shape_of.hpp" #include "openvino/op/sqrt.hpp" #include "pt_framework_node.hpp" +#include "transformations/rt_info/disable_fp16_compression.hpp" #include "utils.hpp" namespace ov { @@ -32,40 +34,13 @@ OutputVector make_random_normal(const NodeContext& context, const Output& mean_const) { std::random_device rd; std::mt19937 gen(rd()); - std::uniform_int_distribution distrib(0, 9999); + std::uniform_real_distribution distrib(0.0f, 9999.0f); + float seed = distrib(gen); - const uint64_t global_seed = 0; - - const uint64_t seed_1 = distrib(gen); - const uint64_t seed_2 = distrib(gen); - - auto min_val = context.mark_node(v0::Constant::create(target_type, Shape{1}, {std::numeric_limits::min()})); - auto max_val = context.mark_node(v0::Constant::create(target_type, Shape{1}, {1})); - - auto uniform_1 = context.mark_node( - std::make_shared(sizes, min_val, max_val, target_type, global_seed, seed_1)); - auto uniform_2 = context.mark_node( - std::make_shared(sizes, min_val, max_val, target_type, global_seed, seed_2)); - - // Compute Box–Muller transform - // random_normal = scale * ng.sqrt(-2.0 * ng.log(uniform_1)) * ng.cos(2.0 * np.pi * uniform_2) + mean - auto pi = context.mark_node(v0::Constant::create(target_type, Shape{1}, {3.141592653589793})); - auto minus_two = context.mark_node(v0::Constant::create(target_type, Shape{1}, {-2.0})); - auto two = context.mark_node(v0::Constant::create(target_type, Shape{1}, {2.0})); - - auto log = context.mark_node(std::make_shared(uniform_1)); - auto multiply_minus_two_log = context.mark_node(std::make_shared(log, minus_two)); - auto sqrt = context.mark_node(std::make_shared(multiply_minus_two_log)); - - auto multiply_two_pi = context.mark_node(std::make_shared(uniform_2, pi)); - auto multiply_two_pi_uniform_2 = context.mark_node(std::make_shared(multiply_two_pi, uniform_2)); - auto cos = context.mark_node(std::make_shared(multiply_two_pi_uniform_2)); - - auto sqrt_x_cos = context.mark_node(std::make_shared(sqrt, cos)); - auto product = context.mark_node(std::make_shared(scale_const, sqrt_x_cos)); - auto sum = context.mark_node(std::make_shared(product, mean_const)); - - return {sum}; + pass::NodeRegistry registry; + auto res = ov::frontend::make_random_normal(registry, sizes, target_type, mean_const, scale_const, seed); + context.mark_nodes(registry.get()); + return res; } }; // namespace diff --git a/src/frontends/pytorch/src/op_table.cpp b/src/frontends/pytorch/src/op_table.cpp index 45c61f84424281..230b2b4d06c7c8 100644 --- a/src/frontends/pytorch/src/op_table.cpp +++ b/src/frontends/pytorch/src/op_table.cpp @@ -26,6 +26,7 @@ OP_CONVERTER(translate_add); OP_CONVERTER(translate_add_); OP_CONVERTER(translate_addcmul); OP_CONVERTER(translate_addmm); +OP_CONVERTER(translate_alias_copy); OP_CONVERTER(translate_all); OP_CONVERTER(translate_amax); OP_CONVERTER(translate_amin); @@ -54,6 +55,7 @@ OP_CONVERTER(translate_convnd); OP_CONVERTER(translate_convolution); OP_CONVERTER(translate_convolution_mode); OP_CONVERTER(translate_copy_); +OP_CONVERTER(translate_cross); OP_CONVERTER(translate_cumsum); OP_CONVERTER(translate_deform_conv); OP_CONVERTER(translate_derive_index); @@ -97,6 +99,7 @@ OP_CONVERTER(translate_int); OP_CONVERTER(translate_is_nonzero); OP_CONVERTER(translate_layer_norm); OP_CONVERTER(translate_len); +OP_CONVERTER(translate_linalg_cross); OP_CONVERTER(translate_linalg_norm); OP_CONVERTER(translate_linalg_matrix_norm); OP_CONVERTER(translate_linalg_vector_norm); @@ -266,6 +269,8 @@ const std::map get_supported_ops_ts() { {"aten::add_", op::translate_add_}, {"aten::addcmul", op::translate_addcmul}, {"aten::addmm", op::translate_addmm}, + {"aten::alias", op::skip_node}, + {"aten::alias_copy", op::translate_alias_copy}, {"aten::all", op::translate_all}, {"aten::amax", op::translate_amax}, {"aten::amin", op::translate_amin}, @@ -323,6 +328,7 @@ const std::map get_supported_ops_ts() { {"aten::cos_", op::inplace_op>}, {"aten::cosh", op::translate_1to1_match_1_inputs_with_fp32_type_alignment}, {"aten::cosh_", op::inplace_op>}, + {"aten::cross", op::translate_cross}, {"aten::cumsum", op::translate_cumsum}, {"aten::detach", op::skip_node}, {"aten::dequantize", op::skip_node}, // we convert model to fp32 using FQ, so dequantization is not needed @@ -390,6 +396,7 @@ const std::map get_supported_ops_ts() { {"aten::lift", op::skip_node}, {"aten::lift_fresh", op::skip_node}, {"aten::lift_fresh_copy", op::skip_node}, + {"aten::linalg_cross", op::translate_linalg_cross}, {"aten::linalg_norm", op::translate_linalg_norm}, {"aten::linalg_matrix_norm", op::translate_linalg_matrix_norm}, {"aten::linalg_vector_norm", op::translate_linalg_vector_norm}, diff --git a/src/frontends/pytorch/src/transforms/prim_tuple_unpack_parameter_replacer.cpp b/src/frontends/pytorch/src/transforms/prim_unpack_parameter_replacer.cpp similarity index 88% rename from src/frontends/pytorch/src/transforms/prim_tuple_unpack_parameter_replacer.cpp rename to src/frontends/pytorch/src/transforms/prim_unpack_parameter_replacer.cpp index f18befab77927f..e8183815f849d1 100644 --- a/src/frontends/pytorch/src/transforms/prim_tuple_unpack_parameter_replacer.cpp +++ b/src/frontends/pytorch/src/transforms/prim_unpack_parameter_replacer.cpp @@ -1,7 +1,7 @@ // Copyright (C) 2018-2023 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // -#include "prim_tuple_unpack_parameter_replacer.hpp" +#include "prim_unpack_parameter_replacer.hpp" #include #include @@ -16,7 +16,7 @@ namespace frontend { namespace pytorch { namespace pass { -bool DecomposeTupleParameters::run_on_model(const std::shared_ptr& model) { +bool DecomposeUnpackParameters::run_on_model(const std::shared_ptr& model) { bool at_least_one_decomposed = false; const auto& orig_parameters = model->get_parameters(); std::deque> parameters(orig_parameters.begin(), orig_parameters.end()); @@ -29,7 +29,7 @@ bool DecomposeTupleParameters::run_on_model(const std::shared_ptr& model) size_t num_outputs = 0; // number of outputs in each unpack consumer should match bool all_unpacks = true; - // collects all outputs per each consumer operation for this tuple Parameter + // collects all outputs per each consumer operation for this tuple/list Parameter std::vector consumer_outputs; // The following vector track consumer nodes having prim::TupleUnpack type to form a detailed @@ -38,8 +38,11 @@ bool DecomposeTupleParameters::run_on_model(const std::shared_ptr& model) for (const auto& consumer : consumers) { auto node = consumer.get_node()->shared_from_this(); - auto tuple_unpack = cast_fw_node(node, "prim::TupleUnpack"); - if (!tuple_unpack) { + std::shared_ptr unpack = cast_fw_node(node, "prim::TupleUnpack"); + if (!unpack) { + unpack = cast_fw_node(node, "prim::ListUnpack"); + } + if (!unpack) { all_unpacks = false; continue; // need to look at all consumers to form good diagnostics } @@ -49,7 +52,7 @@ bool DecomposeTupleParameters::run_on_model(const std::shared_ptr& model) } else if (num_outputs != node->get_output_size()) { std::stringstream message; message << "Unpack node " << node - << " as one of the consumers of a tuple, which is introduced by parameter " + << " as one of the consumers of a tuple/list, which is introduced by parameter " << parameter->output(0) << ", has number of outputs " << node->get_output_size() << " not matching number of outputs " << num_outputs << " for other consumer(s) found earlier."; add_exception_to_fw_node(node, message.str()); @@ -64,11 +67,11 @@ bool DecomposeTupleParameters::run_on_model(const std::shared_ptr& model) // we cannot replace other unpacks even if they exist, leaving Unpack-op(s) in the graph for this Parameter updated_parameters.push_back(parameter); - // In case if at least one Unpack exists there is an opportinity to attach diagnostics + // In case if at least one Unpack exists there is an opportunity to attach diagnostics for (const auto& consumer : consumer_unpacks) { std::stringstream message; - message << "Not prim::TupleUnpack operations exist except this one: " << consumer - << " found as one of the consumers of a tuple, which is introduced by parameter " + message << "Not unpack operations exist except this one: " << consumer + << " found as one of the consumers of a tuple/list, which is introduced by parameter " << parameter->output(0) << "."; add_exception_to_fw_node(consumer, message.str()); } diff --git a/src/frontends/pytorch/src/transforms/prim_tuple_unpack_parameter_replacer.hpp b/src/frontends/pytorch/src/transforms/prim_unpack_parameter_replacer.hpp similarity index 63% rename from src/frontends/pytorch/src/transforms/prim_tuple_unpack_parameter_replacer.hpp rename to src/frontends/pytorch/src/transforms/prim_unpack_parameter_replacer.hpp index 46007a5c12a775..1f93da74dfafc4 100644 --- a/src/frontends/pytorch/src/transforms/prim_tuple_unpack_parameter_replacer.hpp +++ b/src/frontends/pytorch/src/transforms/prim_unpack_parameter_replacer.hpp @@ -12,12 +12,12 @@ namespace frontend { namespace pytorch { namespace pass { -// This transformation replaces all prim::TupleUnpack operations coming after Parameters with -// more Parameters -- one new parameter for each prim::TupleUnpack output. The original Parameter +// This transformation replaces all prim::TupleUnpack/prim::ListUnpack operations coming after Parameters +// with more Parameters -- one new parameter for each unpacked output. The original Parameter // is replaced with these new Parameters preserving the order relative to other Parameters in a model. -// Order of new parameters is the same as the order of prim::TupleUnpack outputs. -// If prim::TupleUnpack has a consumer that is also prim::TupleUnpack, the transformation applies -// the replacement recursively until all prim::TupleUnpacks that take a Parameter output are eliminated. +// Order of new parameters is the same as the order of unpacked outputs. +// If unpack operation has a consumer that is also unpack operation, the transformation applies +// the replacement recursively until all unpack operations that take a Parameter output are eliminated. // // For example, if a model has the following signature: a, (b, (c, d)), e, where a, b, c, d, and e are // tensors, and (x1, x2) means tuple consisting two elements x1 and x2, then the resulting model @@ -25,9 +25,9 @@ namespace pass { // Note, that there is no special 'tuple' type of an input, tuple structure is restored by // following prim::TupleUnpack operations in the graph only assuming that they can be applied on // tuples only and the most nested objects in those tuples are tensors. -class DecomposeTupleParameters : public ov::pass::ModelPass { +class DecomposeUnpackParameters : public ov::pass::ModelPass { public: - OPENVINO_RTTI("ov::frontend::pytorch::pass::DecomposeTupleParameters"); + OPENVINO_RTTI("ov::frontend::pytorch::pass::DecomposeUnpackParameters"); bool run_on_model(const std::shared_ptr& model) override; }; diff --git a/src/frontends/tensorflow/src/frontend.cpp b/src/frontends/tensorflow/src/frontend.cpp index ad9b5b76bdfbda..020e8cd3ecf4db 100644 --- a/src/frontends/tensorflow/src/frontend.cpp +++ b/src/frontends/tensorflow/src/frontend.cpp @@ -20,6 +20,7 @@ #include "openvino/core/so_extension.hpp" #include "openvino/frontend/graph_iterator.hpp" #include "openvino/frontend/tensorflow/extension/conversion.hpp" +#include "openvino/op/util/framework_node.hpp" #include "openvino/op/util/multi_subgraph_base.hpp" #include "openvino/pass/manager.hpp" #include "openvino/util/common_util.hpp" @@ -39,6 +40,24 @@ using namespace ov; using namespace ov::frontend::tensorflow; namespace { +void update_failures_unsupported_ops(const std::string& op_type, + const ov::op::util::FrameworkNodeAttrs& fw_node_attrs, + std::set& unsupported_operations, + std::unordered_map& failures) { + // if this operation is encountered among unsupported operations + // or conversion failures, skip it + if (failures.count(op_type) > 0 || unsupported_operations.count(op_type) > 0) { + return; + } + if (fw_node_attrs.find(FrameworkNode::failed_conversion_key) != fw_node_attrs.end()) { + // save only the first encountered failure that is more improtant for developer + // that means the translator is found but the conversion is failed + failures[op_type] = fw_node_attrs.at(FrameworkNode::failed_conversion_key); + } else { + // found new unsupported operation + unsupported_operations.insert(op_type); + } +} void get_unsupported_operations_and_failures(const std::shared_ptr& model, std::set& unsupported_operations, @@ -55,20 +74,13 @@ void get_unsupported_operations_and_failures(const std::shared_ptr& model unsupported_operations.insert(op_type); } else if (const auto& fw_node = ov::as_type_ptr(node)) { auto op_type = fw_node->get_decoder()->get_op_type(); - // if this operation is encountered among unsupported operations - // or conversion failures, skip it - if (failures.count(op_type) > 0 || unsupported_operations.count(op_type) > 0) { - continue; - } auto fw_node_attrs = fw_node->get_attrs(); - if (fw_node_attrs.find(FrameworkNode::failed_conversion_key) != fw_node_attrs.end()) { - // save only the first encountered failure that is more improtant for developer - // that means the translator is found but the conversion is failed - failures[op_type] = fw_node_attrs.at(FrameworkNode::failed_conversion_key); - } else { - // found new unsupported operation - unsupported_operations.insert(op_type); - } + update_failures_unsupported_ops(op_type, fw_node_attrs, unsupported_operations, failures); + } else if (const auto& fw_node = ov::as_type_ptr(node)) { + // handle auxiliary operations from common frontend like ComplexTypeMark + auto op_type = std::string(fw_node->get_type_name()); + auto fw_node_attrs = fw_node->get_attrs(); + update_failures_unsupported_ops(op_type, fw_node_attrs, unsupported_operations, failures); } if (const auto& fw_node = ov::as_type_ptr(node)) { int subgraphs_size = static_cast(fw_node->get_internal_subgraphs_size()); @@ -117,14 +129,14 @@ bool FrontEnd::supported_impl(const std::vector& variants) const { // avoid parsing of checkpoints here if (variants[0].is()) { std::string model_path = variants[0].as(); - if (ov::util::ends_with(model_path, ".pb") && GraphIteratorProto::is_supported(model_path)) { + if (GraphIteratorProto::is_supported(model_path)) { // handle binary protobuf format // for automatic deduction of the frontend to convert the model // we have more strict rule that is to have `.pb` extension in the path return true; } else if (GraphIteratorSavedModel::is_supported(model_path)) { return true; - } else if (ov::util::ends_with(model_path, ".meta") && GraphIteratorMeta::is_supported(model_path)) { + } else if (GraphIteratorMeta::is_supported(model_path)) { return true; } else if (GraphIteratorProtoTxt::is_supported(model_path)) { // handle text protobuf format @@ -149,15 +161,14 @@ bool FrontEnd::supported_impl(const std::vector& variants) const { #if defined(OPENVINO_ENABLE_UNICODE_PATH_SUPPORT) && defined(_WIN32) else if (variants[0].is()) { std::wstring model_path = variants[0].as(); - if (ov::util::ends_with(model_path, std::wstring(L".pb")) && GraphIteratorProto::is_supported(model_path)) { + if (GraphIteratorProto::is_supported(model_path)) { // handle binary protobuf format with a path in Unicode // for automatic deduction of the frontend to convert the model // we have more strict rule that is to have `.pb` extension in the path return true; } else if (GraphIteratorSavedModel::is_supported(model_path)) { return true; - } else if (ov::util::ends_with(model_path, std::wstring(L".meta")) && - GraphIteratorMeta::is_supported(model_path)) { + } else if (GraphIteratorMeta::is_supported(model_path)) { return true; } else if (GraphIteratorProtoTxt::is_supported(model_path)) { // handle text protobuf format diff --git a/src/frontends/tensorflow/src/graph_iterator_meta.cpp b/src/frontends/tensorflow/src/graph_iterator_meta.cpp index 06f2d31f389a27..499a5478d4ff1b 100644 --- a/src/frontends/tensorflow/src/graph_iterator_meta.cpp +++ b/src/frontends/tensorflow/src/graph_iterator_meta.cpp @@ -18,25 +18,12 @@ namespace frontend { namespace tensorflow { bool GraphIteratorMeta::is_valid_signature(const ::tensorflow::SignatureDef& signature) const { - const std::map<::tensorflow::DataType, ov::element::Type> types{ - {::tensorflow::DataType::DT_BOOL, ov::element::boolean}, - {::tensorflow::DataType::DT_INT16, ov::element::i16}, - {::tensorflow::DataType::DT_INT32, ov::element::i32}, - {::tensorflow::DataType::DT_INT64, ov::element::i64}, - {::tensorflow::DataType::DT_HALF, ov::element::f16}, - {::tensorflow::DataType::DT_FLOAT, ov::element::f32}, - {::tensorflow::DataType::DT_DOUBLE, ov::element::f64}, - {::tensorflow::DataType::DT_UINT8, ov::element::u8}, - {::tensorflow::DataType::DT_INT8, ov::element::i8}, - {::tensorflow::DataType::DT_BFLOAT16, ov::element::bf16}, - {::tensorflow::DataType::DT_STRING, ov::element::dynamic}}; - for (const auto& it : signature.inputs()) { - if (it.second.name().empty() || types.find(it.second.dtype()) == types.end()) + if (it.second.name().empty()) return false; } for (const auto& it : signature.outputs()) { - if (it.second.name().empty() || types.find(it.second.dtype()) == types.end()) + if (it.second.name().empty()) return false; } return true; diff --git a/src/frontends/tensorflow/src/graph_iterator_saved_model.cpp b/src/frontends/tensorflow/src/graph_iterator_saved_model.cpp index 803e7d694bc69a..8f31bef0de7af3 100644 --- a/src/frontends/tensorflow/src/graph_iterator_saved_model.cpp +++ b/src/frontends/tensorflow/src/graph_iterator_saved_model.cpp @@ -18,25 +18,12 @@ namespace frontend { namespace tensorflow { bool GraphIteratorSavedModel::is_valid_signature(const ::tensorflow::SignatureDef& signature) const { - const std::map<::tensorflow::DataType, ov::element::Type> types{ - {::tensorflow::DataType::DT_BOOL, ov::element::boolean}, - {::tensorflow::DataType::DT_INT16, ov::element::i16}, - {::tensorflow::DataType::DT_INT32, ov::element::i32}, - {::tensorflow::DataType::DT_INT64, ov::element::i64}, - {::tensorflow::DataType::DT_HALF, ov::element::f16}, - {::tensorflow::DataType::DT_FLOAT, ov::element::f32}, - {::tensorflow::DataType::DT_DOUBLE, ov::element::f64}, - {::tensorflow::DataType::DT_UINT8, ov::element::u8}, - {::tensorflow::DataType::DT_INT8, ov::element::i8}, - {::tensorflow::DataType::DT_BFLOAT16, ov::element::bf16}, - {::tensorflow::DataType::DT_STRING, ov::element::dynamic}}; - for (const auto& it : signature.inputs()) { - if (it.second.name().empty() || types.find(it.second.dtype()) == types.end()) + if (it.second.name().empty()) return false; } for (const auto& it : signature.outputs()) { - if (it.second.name().empty() || types.find(it.second.dtype()) == types.end()) + if (it.second.name().empty()) return false; } return true; diff --git a/src/frontends/tensorflow/src/op/placeholder.cpp b/src/frontends/tensorflow/src/op/placeholder.cpp index 62babcf826f0a9..9b4d54b07df33f 100644 --- a/src/frontends/tensorflow/src/op/placeholder.cpp +++ b/src/frontends/tensorflow/src/op/placeholder.cpp @@ -4,10 +4,11 @@ #include "common_op_table.hpp" #include "input_model.hpp" -#include "openvino/opsets/opset8.hpp" +#include "openvino/op/parameter.hpp" +#include "utils.hpp" using namespace std; -using namespace ov::opset8; +using namespace ov::op; using namespace ov; namespace ov { @@ -16,40 +17,10 @@ namespace tensorflow { namespace op { OutputVector translate_placeholder_linked_op(const NodeContext& node) { - auto dtype = node.get_attribute("dtype"); - auto shape = node.get_attribute("shape", ov::PartialShape::dynamic()); - auto translate_session = node.get_translate_session(); - TENSORFLOW_OP_VALIDATION(node, - translate_session, - "[TensorFlow Frontend] Internal error: Translate session is nullptr."); - auto model = reinterpret_cast(translate_session->get_input_model().get()); - auto tensor_places = model->get_tensor_places(); - auto saved_model_input_names = model->get_saved_model_input_names(); - - if (saved_model_input_names.get() && saved_model_input_names->size() > 0) { - auto input_name = saved_model_input_names->find(node.get_name()); - if (input_name == saved_model_input_names->end()) { - input_name = saved_model_input_names->find(node.get_name() + ":0"); - } - if (input_name != saved_model_input_names->end()) { - auto tensor_place = tensor_places.find(input_name->second); - if (tensor_place != tensor_places.end()) { - shape = tensor_place->second->get_partial_shape(); - } - } - } - - if (shape.rank().is_static() && shape.rank().get_length() == 0 && node.has_attribute("_output_shapes")) { - // we know some cases when Placeholder operation has empty scalar `shape` attribute value - // and non-empty `_output_shapes` attribute value. - // `_output_shapes` attribute value turns to be correct in this case - auto output_shapes = node.get_attribute>("_output_shapes"); - if (output_shapes.size() == 1 && output_shapes[0].rank().is_static()) { - shape = output_shapes[0]; - } - } - - auto res = std::make_shared(dtype, shape); + default_op_checks(node, 0, {"Placeholder"}); + auto dtype = node.get_attribute("dtype"); + auto shape = node.get_attribute("shape", PartialShape::dynamic()); + auto res = std::make_shared(dtype, shape); set_node_name(node.get_name(), res); return res->outputs(); } diff --git a/src/frontends/tensorflow/src/op/var_handle.cpp b/src/frontends/tensorflow/src/op/var_handle.cpp index e9eb0eaa1816e9..7aed518c5dcc5c 100644 --- a/src/frontends/tensorflow/src/op/var_handle.cpp +++ b/src/frontends/tensorflow/src/op/var_handle.cpp @@ -69,7 +69,11 @@ OutputVector translate_varhandle_op(const NodeContext& node) { TENSORFLOW_OP_VALIDATION(node, translate_session, "[TensorFlow Frontend] Internal error: Translate session is nullptr."); - auto model = reinterpret_cast(translate_session->get_input_model().get()); + auto model = dynamic_cast(translate_session->get_input_model().get()); + TENSORFLOW_OP_VALIDATION( + node, + model, + "[TensorFlow Frontend] internal error: cannot cast a pointer to ov::frontend::tensorflow::InputModel*"); auto var_index = model->get_variables_index(); auto ov_type = node.get_attribute("dtype"); std::shared_ptr const_node; @@ -188,10 +192,24 @@ OutputVector translate_restorev2_op(const NodeContext& node) { TENSORFLOW_OP_VALIDATION(node, translate_session, "[TensorFlow Frontend] Internal error: Translate session is nullptr."); - auto model = reinterpret_cast(translate_session->get_input_model().get()); + auto model = dynamic_cast(translate_session->get_input_model().get()); + TENSORFLOW_OP_VALIDATION( + node, + model, + "[TensorFlow Frontend] internal error: cannot cast a pointer to ov::frontend::tensorflow::InputModel*"); auto var_index = model->get_variables_index(); - auto tensor_names = - reinterpret_cast(node.get_input(1).get_node())->get_data().as>(); + + auto string_constant_node = dynamic_pointer_cast(node.get_input(1).get_node_shared_ptr()); + TENSORFLOW_OP_VALIDATION( + node, + string_constant_node, + "[TensorFlow Frontend] internal error: cannot cast a node pointer to StringConstant pointer"); + TENSORFLOW_OP_VALIDATION( + node, + string_constant_node->get_data().is>(), + "[TensorFlow Frontend] internal error: cannot cast data of StringConstant into std::vector"); + auto tensor_names = string_constant_node->get_data().as>(); + auto tensor_types = node.get_attribute>("dtypes"); OutputVector outs = {}; diff --git a/src/frontends/tensorflow/src/op_table.cpp b/src/frontends/tensorflow/src/op_table.cpp index 176525fa7ef643..df9dd2ac737197 100644 --- a/src/frontends/tensorflow/src/op_table.cpp +++ b/src/frontends/tensorflow/src/op_table.cpp @@ -102,6 +102,7 @@ const std::map get_supported_ops() { // note: BinaryOp translator declaration for each op must to be added in binary_op.cpp file {"Add", CreatorFunction(translate_binary_op)}, {"AddV2", CreatorFunction(translate_binary_op)}, + {"Atan2", CreatorFunction(translate_atan2_op)}, {"BitwiseAnd", CreatorFunction(translate_binary_op)}, {"BitwiseOr", CreatorFunction(translate_binary_op)}, {"BitwiseXor", CreatorFunction(translate_binary_op)}, @@ -231,6 +232,7 @@ const std::map get_supported_ops() { {"MaxPoolWithArgmax", CreatorFunction(translate_max_pool_with_argmax)}, {"Merge", CreatorFunction(translate_merge_op)}, {"MirrorPad", CreatorFunction(translate_mirror_pad_op)}, + {"MulNoNan", CreatorFunction(translate_mul_no_nan_op)}, {"MutableHashTable", CreatorFunction(translate_hash_table_op)}, {"MutableHashTableV2", CreatorFunction(translate_hash_table_op)}, {"NonMaxSuppression", CreatorFunction(translate_non_max_suppression_op)}, diff --git a/src/frontends/tensorflow/src/tf_utils.cpp b/src/frontends/tensorflow/src/tf_utils.cpp index 68ddf3677a6189..c3f1c7cf0d13dd 100644 --- a/src/frontends/tensorflow/src/tf_utils.cpp +++ b/src/frontends/tensorflow/src/tf_utils.cpp @@ -63,7 +63,7 @@ void copy_conditional_flow_markers_for_producer( } template -void extract_tensor_content(const string& tensor_content, Tensor* values) { +void extract_tensor_content(const std::string& tensor_content, Tensor* values) { const auto tensor_content_size = tensor_content.size(); FRONT_END_GENERAL_CHECK(tensor_content_size % sizeof(T) == 0, "Size of tensor_content (", @@ -82,17 +82,17 @@ void extract_tensor_content(const string& tensor_content, Tensor* values) { # pragma warning(disable : 4244) // possible loss of data # pragma warning(disable : 4267) // possible loss of data #endif -template +template void extract_compressed_tensor_content(const ::tensorflow::TensorProto& tensor_proto, int64_t val_size, Tensor* values) { - auto val_lastsaved = static_cast(0); - auto values_data = values->data(); + auto val_lastsaved = static_cast(0); + auto values_data = values->data(); for (size_t i = 0; i < values->get_size(); i++) { if (val_size == 0) { - values_data[i] = static_cast(0); + values_data[i] = static_cast(0); } else if (static_cast(i) < val_size) { - auto val_i = static_cast(0); + auto val_i = static_cast(0); switch (values->get_element_type()) { // TODO: there are more element types to support here case boolean: @@ -113,13 +113,34 @@ void extract_compressed_tensor_content(const ::tensorflow::TensorProto& tensor_p case f64: val_i = tensor_proto.double_val()[i]; break; + case u8: + val_i = tensor_proto.int_val()[i]; + break; + case u16: + val_i = tensor_proto.int_val()[i]; + break; + case u64: + val_i = tensor_proto.uint64_val()[i]; + break; + case i8: + val_i = tensor_proto.int_val()[i]; + break; + case bf16: + val_i = bfloat16::from_bits(tensor_proto.half_val()[i]); + break; + case u32: + val_i = tensor_proto.uint32_val()[i]; + break; + case i16: + val_i = tensor_proto.int_val()[i]; + break; default: FRONT_END_THROW("Encountered unknown element type " + values->get_element_type().get_type_name()); } - values_data[i] = val_i; + values_data[i] = static_cast(val_i); val_lastsaved = val_i; } else { - values_data[i] = val_lastsaved; + values_data[i] = static_cast(val_lastsaved); } } } @@ -150,16 +171,18 @@ bool CfMarkerType::is_copyable() const { } Type get_ov_type(const ::tensorflow::DataType& type) { - static const map<::tensorflow::DataType, Type> type_map{{::tensorflow::DataType::DT_BOOL, boolean}, - {::tensorflow::DataType::DT_INT16, i16}, - {::tensorflow::DataType::DT_INT32, i32}, - {::tensorflow::DataType::DT_INT64, i64}, - {::tensorflow::DataType::DT_HALF, f16}, - {::tensorflow::DataType::DT_FLOAT, f32}, - {::tensorflow::DataType::DT_DOUBLE, f64}, - {::tensorflow::DataType::DT_UINT8, u8}, - {::tensorflow::DataType::DT_INT8, i8}, - {::tensorflow::DataType::DT_BFLOAT16, bf16}}; + using ::tensorflow::DataType; + + static map type_map{ + {DataType::DT_FLOAT, f32}, {DataType::DT_DOUBLE, f64}, {DataType::DT_INT32, i32}, + {DataType::DT_UINT8, u8}, {DataType::DT_INT16, i16}, {DataType::DT_INT8, i8}, + {DataType::DT_INT64, i64}, {DataType::DT_BOOL, boolean}, {DataType::DT_BFLOAT16, bf16}, + {DataType::DT_UINT16, u16}, {DataType::DT_HALF, f16}, {DataType::DT_UINT32, u32}, + {DataType::DT_UINT64, u64}, {DataType::DT_FLOAT_REF, f32}, {DataType::DT_DOUBLE_REF, f64}, + {DataType::DT_INT32_REF, i32}, {DataType::DT_UINT8_REF, u8}, {DataType::DT_INT16_REF, i16}, + {DataType::DT_INT8_REF, i8}, {DataType::DT_INT64_REF, i64}, {DataType::DT_BOOL_REF, boolean}, + {DataType::DT_BFLOAT16_REF, bf16}, {DataType::DT_UINT16_REF, u16}, {DataType::DT_HALF_REF, f16}, + {DataType::DT_UINT32_REF, u32}, {DataType::DT_UINT64_REF, u64}}; auto it = type_map.find(type); // for all unsupported types return dynamic type @@ -185,42 +208,55 @@ Any unpack_tensor_proto(const ::tensorflow::TensorProto& tensor_proto, ov_type.is_static(), "Encountered unknown element type " + DataType_Name(tensor_type) + " on an empty tensor_proto"); } else { - auto data = vector(); + auto data = vector(); for (const auto& item : tensor_proto.string_val()) { data.push_back(item); } return data; } + Tensor res(ov_type, pshape.get_shape()); auto tensor_content = tensor_proto.tensor_content(); if (!tensor_content.empty() && tensor_proto.has_tensor_shape()) { switch (ov_type) { + case f32: + extract_tensor_content(tensor_content, &res); + break; case u8: extract_tensor_content(tensor_content, &res); break; - case i8: - extract_tensor_content(tensor_content, &res); + case i64: + extract_tensor_content(tensor_content, &res); break; - case i16: - extract_tensor_content(tensor_content, &res); + case u16: + extract_tensor_content(tensor_content, &res); + break; + case u64: + extract_tensor_content(tensor_content, &res); break; case i32: extract_tensor_content(tensor_content, &res); break; - case i64: - extract_tensor_content(tensor_content, &res); + case i8: + extract_tensor_content(tensor_content, &res); break; - case f16: - extract_tensor_content(tensor_content, &res); + case bf16: + extract_tensor_content(tensor_content, &res); break; - case f32: - extract_tensor_content(tensor_content, &res); + case u32: + extract_tensor_content(tensor_content, &res); break; case f64: extract_tensor_content(tensor_content, &res); break; - case bf16: - extract_tensor_content(tensor_content, &res); + case i16: + extract_tensor_content(tensor_content, &res); + break; + case boolean: + extract_tensor_content(tensor_content, &res); + break; + case f16: + extract_tensor_content(tensor_content, &res); break; default: FRONT_END_THROW("Encountered unknown element type " + ov_type.get_type_name()); @@ -228,30 +264,58 @@ Any unpack_tensor_proto(const ::tensorflow::TensorProto& tensor_proto, } else { int64_t val_size = 0; switch (ov_type) { - case boolean: - val_size = tensor_proto.bool_val_size(); - extract_compressed_tensor_content(tensor_proto, val_size, &res); + case f32: + val_size = tensor_proto.float_val_size(); + extract_compressed_tensor_content(tensor_proto, val_size, &res); break; - case i32: + case u8: val_size = tensor_proto.int_val_size(); - extract_compressed_tensor_content(tensor_proto, val_size, &res); + extract_compressed_tensor_content(tensor_proto, val_size, &res); break; case i64: val_size = tensor_proto.int64_val_size(); extract_compressed_tensor_content(tensor_proto, val_size, &res); break; - case f16: + case u16: + val_size = tensor_proto.int_val_size(); + extract_compressed_tensor_content(tensor_proto, val_size, &res); + break; + case u64: + val_size = tensor_proto.uint64_val_size(); + extract_compressed_tensor_content(tensor_proto, val_size, &res); + break; + case i32: + val_size = tensor_proto.int_val_size(); + extract_compressed_tensor_content(tensor_proto, val_size, &res); + break; + case i8: + val_size = tensor_proto.int_val_size(); + extract_compressed_tensor_content(tensor_proto, val_size, &res); + break; + case bf16: val_size = tensor_proto.half_val_size(); - extract_compressed_tensor_content(tensor_proto, val_size, &res); + extract_compressed_tensor_content(tensor_proto, val_size, &res); break; - case f32: - val_size = tensor_proto.float_val_size(); - extract_compressed_tensor_content(tensor_proto, val_size, &res); + case u32: + val_size = tensor_proto.uint32_val_size(); + extract_compressed_tensor_content(tensor_proto, val_size, &res); break; case f64: val_size = tensor_proto.double_val_size(); extract_compressed_tensor_content(tensor_proto, val_size, &res); break; + case i16: + val_size = tensor_proto.int_val_size(); + extract_compressed_tensor_content(tensor_proto, val_size, &res); + break; + case boolean: + val_size = tensor_proto.bool_val_size(); + extract_compressed_tensor_content(tensor_proto, val_size, &res); + break; + case f16: + val_size = tensor_proto.half_val_size(); + extract_compressed_tensor_content(tensor_proto, val_size, &res); + break; default: FRONT_END_THROW("Encountered unknown element type " + ov_type.get_type_name()); } diff --git a/src/frontends/tensorflow/tests/compilation.cpp b/src/frontends/tensorflow/tests/compilation.cpp index 73a22ceed92644..dc3ef5187b987e 100644 --- a/src/frontends/tensorflow/tests/compilation.cpp +++ b/src/frontends/tensorflow/tests/compilation.cpp @@ -14,6 +14,20 @@ using namespace ov::frontend::tensorflow::tests; class CompileModelsTests : public ::testing::Test {}; +#ifdef OPENVINO_ARCH_ARM64 +// Ticket: 122666 +TEST_F(CompileModelsTests, DISABLED_NgramCompilation) { + ov::Core core; + auto model = convert_model("model_ngram/model_ngram.pbtxt"); + ov::CompiledModel compiled_model = core.compile_model(model, "CPU"); + const auto runtime_model = compiled_model.get_runtime_model(); + + // A convert node will be inserted for CPU plugin API 2.0 + EXPECT_EQ(runtime_model->get_ordered_ops().size(), 5); + EXPECT_EQ(runtime_model->get_parameters().size(), 2); + EXPECT_EQ(runtime_model->get_results().size(), 1); +} +#else TEST_F(CompileModelsTests, NgramCompilation) { ov::Core core; auto model = convert_model("model_ngram/model_ngram.pbtxt"); @@ -25,8 +39,15 @@ TEST_F(CompileModelsTests, NgramCompilation) { EXPECT_EQ(runtime_model->get_parameters().size(), 2); EXPECT_EQ(runtime_model->get_results().size(), 1); } +#endif -TEST_F(CompileModelsTests, ModelWithSplitConvConcat) { +#ifdef OPENVINO_ARCH_ARM64 +// Ticket: CVS-122396 +TEST_F(CompileModelsTests, DISABLED_ModelWithSplitConvConcat) +#else +TEST_F(CompileModelsTests, ModelWithSplitConvConcat) +#endif +{ { auto model = convert_model("split_conv_concat/split_conv_concat.pbtxt"); ov::Core core; diff --git a/src/frontends/tensorflow/tests/convert_model.cpp b/src/frontends/tensorflow/tests/convert_model.cpp index f6ec18cf9cc12c..5419b2c4f77c6d 100644 --- a/src/frontends/tensorflow/tests/convert_model.cpp +++ b/src/frontends/tensorflow/tests/convert_model.cpp @@ -13,6 +13,8 @@ using TFConvertModelTest = FrontEndConvertModelTest; static const std::vector models{ std::string("2in_2out/2in_2out.pb"), + std::string("2in_2out/2in_2out.pb.frozen"), + std::string("2in_2out/2in_2out.pb.frozen_text"), std::string("forward_edge_model/forward_edge_model.pbtxt"), std::string("forward_edge_model2/forward_edge_model2.pbtxt"), std::string("concat_with_non_constant_axis/concat_with_non_constant_axis.pbtxt"), diff --git a/src/frontends/tensorflow/tests/convert_saved_model.cpp b/src/frontends/tensorflow/tests/convert_saved_model.cpp index 76a5caf1fe54b1..2c9a8a6362d16f 100644 --- a/src/frontends/tensorflow/tests/convert_saved_model.cpp +++ b/src/frontends/tensorflow/tests/convert_saved_model.cpp @@ -19,8 +19,8 @@ TEST_F(FrontEndConversionWithReferenceTestsF, SavedModelProgramOnly) { model = convert_model("saved_model_program-only"); // check tensor names in the resulted model - unordered_set input_tensor_names = {"y"}; - unordered_set output_tensor_names = {"z"}; + unordered_set input_tensor_names = {"y"}; + unordered_set output_tensor_names = {"z"}; ASSERT_EQ(model->get_results().size(), 1); ASSERT_TRUE(model->get_results()[0]->input_value(0).get_names() == output_tensor_names); ASSERT_EQ(model->get_parameters().size(), 1); @@ -61,9 +61,9 @@ TEST_F(FrontEndConversionWithReferenceTestsF, SavedModelWithInputIntegerType) { {PartialShape{10, 5}, PartialShape{3}}); // check tensor names in the resulted model - unordered_set input_tensor_name1 = {"params"}; - unordered_set input_tensor_name2 = {"indices"}; - unordered_set output_tensor_names = {"test_output_name"}; + unordered_set input_tensor_name1 = {"params"}; + unordered_set input_tensor_name2 = {"indices"}; + unordered_set output_tensor_names = {"test_output_name"}; ASSERT_EQ(model->get_results().size(), 1); ASSERT_TRUE(model->get_results()[0]->input_value(0).get_names() == output_tensor_names); ASSERT_EQ(model->get_parameters().size(), 2); @@ -97,7 +97,7 @@ TEST_F(FrontEndConversionWithReferenceTestsF, SavedModelMultipleTensorNames) { model = convert_model("saved_model_parameter_result"); // check tensor names in the resulted model - unordered_set tensor_names = {"params", "test_output_name"}; + unordered_set tensor_names = {"params", "test_output_name"}; ASSERT_EQ(model->get_results().size(), 1); ASSERT_TRUE(model->get_results()[0]->input_value(0).get_names() == tensor_names); ASSERT_EQ(model->get_parameters().size(), 1); diff --git a/src/frontends/tensorflow/tests/convert_unsupported.cpp b/src/frontends/tensorflow/tests/convert_unsupported.cpp index 7d9a83045b5606..4b648dcf2d757d 100644 --- a/src/frontends/tensorflow/tests/convert_unsupported.cpp +++ b/src/frontends/tensorflow/tests/convert_unsupported.cpp @@ -55,13 +55,13 @@ class TestDecoder : public ov::frontend::DecoderBase { const std::string m_op_type; }; -shared_ptr convert_model_partially(const string& model_path) { +shared_ptr convert_model_partially(const std::string& model_path) { FrontEndManager fem; auto front_end = fem.load_by_framework(TF_FE); if (!front_end) { throw "TensorFlow Frontend is not initialized"; } - auto model_filename = FrontEndTestUtils::make_model_path(string(TEST_TENSORFLOW_MODELS_DIRNAME) + model_path); + auto model_filename = FrontEndTestUtils::make_model_path(std::string(TEST_TENSORFLOW_MODELS_DIRNAME) + model_path); auto input_model = front_end->load(model_filename); if (!input_model) { throw "Input model is not read"; @@ -95,8 +95,8 @@ TEST(FrontEndConvertModelTest, test_unsupported_op) { InputModel::Ptr inputModel; ASSERT_NO_THROW(frontEnd = fem.load_by_framework(TF_FE)); ASSERT_NE(frontEnd, nullptr); - auto model_filename = FrontEndTestUtils::make_model_path(string(TEST_TENSORFLOW_MODELS_DIRNAME) + - string("relu_unsupported/relu_unsupported.pb")); + auto model_filename = FrontEndTestUtils::make_model_path(std::string(TEST_TENSORFLOW_MODELS_DIRNAME) + + std::string("relu_unsupported/relu_unsupported.pb")); ASSERT_NO_THROW(inputModel = frontEnd->load(model_filename)); ASSERT_NE(inputModel, nullptr); shared_ptr model; @@ -141,13 +141,13 @@ TEST(FrontEndConvertModelTest, test_unsupported_tf1_while_and_incorrect_less_tra "passed without errors. " "OpConversionFailure is expected."; } catch (const OpConversionFailure& error) { - string error_message = error.what(); - string ref_message = "Less expects ten inputs.\n"; - string not_found_message = + std::string error_message = error.what(); + std::string ref_message = "Less expects ten inputs.\n"; + std::string not_found_message = "[TensorFlow Frontend] Internal error, no translator found for operation(s): Enter, Exit, " "LoopCond, Merge, NextIteration, Switch"; - ASSERT_TRUE(error_message.find(ref_message) != string::npos); - ASSERT_TRUE(error_message.find(not_found_message) == string::npos); + ASSERT_TRUE(error_message.find(ref_message) != std::string::npos); + ASSERT_TRUE(error_message.find(not_found_message) == std::string::npos); ASSERT_EQ(model, nullptr); } catch (...) { FAIL() << "Conversion of TensorFlow 1 While failed by wrong reason."; @@ -164,13 +164,13 @@ TEST(FrontEndConvertModelTest, conversion_with_unknown_exception) { "passed without errors. " "OpConversionFailure is expected."; } catch (const OpConversionFailure& error) { - string error_message = error.what(); - string ref_message = "Unknown exception type\n"; - string doc_message = + std::string error_message = error.what(); + std::string ref_message = "Unknown exception type\n"; + std::string doc_message = "To facilitate the conversion of unsupported operations, refer to Frontend Extension documentation: " "https://docs.openvino.ai/latest/openvino_docs_Extensibility_UG_Frontend_Extensions.html"; - ASSERT_TRUE(error_message.find(ref_message) != string::npos); - ASSERT_TRUE(error_message.find(doc_message) == string::npos); + ASSERT_TRUE(error_message.find(ref_message) != std::string::npos); + ASSERT_TRUE(error_message.find(doc_message) == std::string::npos); ASSERT_EQ(model, nullptr); } catch (...) { FAIL() << "Conversion of TensorFlow 1 While failed by wrong reason."; @@ -187,11 +187,11 @@ TEST(FrontEndConvertModelTest, test_unsupported_resource_gather_translator) { "ResourceGather translator. " "OpConversionFailure is expected."; } catch (const OpConversionFailure& error) { - string error_message = error.what(); - string ref_message = "Less expects ten inputs.\n"; - string no_ref_message = "[TensorFlow Frontend] Internal error: No translator found for"; - ASSERT_TRUE(error_message.find(ref_message) != string::npos); - ASSERT_TRUE(error_message.find(no_ref_message) == string::npos); + std::string error_message = error.what(); + std::string ref_message = "Less expects ten inputs.\n"; + std::string no_ref_message = "[TensorFlow Frontend] Internal error: No translator found for"; + ASSERT_TRUE(error_message.find(ref_message) != std::string::npos); + ASSERT_TRUE(error_message.find(no_ref_message) == std::string::npos); ASSERT_EQ(model, nullptr); } catch (...) { FAIL() << "Conversion of the model with ResourceGather failed by wrong reason."; @@ -204,10 +204,10 @@ TEST(FrontEndConvertModelTest, test_unsupported_operation_conversion_with_reason model = convert_model("gather_with_string_table/gather_with_string_table.pb"); FAIL() << "The model with Const of string type must not be converted."; } catch (const OpConversionFailure& error) { - string error_message = error.what(); - string ref_message = + std::string error_message = error.what(); + std::string ref_message = "[TensorFlow Frontend] Internal error, no translator found for operation(s): Const of string type"; - ASSERT_TRUE(error_message.find(ref_message) != string::npos); + ASSERT_TRUE(error_message.find(ref_message) != std::string::npos); ASSERT_EQ(model, nullptr); } catch (...) { FAIL() << "Conversion of the model with Const of string type failed by wrong reason."; diff --git a/src/frontends/tensorflow/tests/telemetry.cpp b/src/frontends/tensorflow/tests/telemetry.cpp index 5f9b433a92a4c9..aae6b84d38ed58 100644 --- a/src/frontends/tensorflow/tests/telemetry.cpp +++ b/src/frontends/tensorflow/tests/telemetry.cpp @@ -75,8 +75,8 @@ TEST(TFTelemetryTest, test_nonexistent_add) { m_test_telemetry.clear(); EXPECT_NO_THROW(frontEnd->add_extension(telemetry_extension)); - auto model_filename = FrontEndTestUtils::make_model_path(string(TEST_TENSORFLOW_MODELS_DIRNAME) + - string("nonexistent_add/nonexistent_add.pb")); + auto model_filename = FrontEndTestUtils::make_model_path(std::string(TEST_TENSORFLOW_MODELS_DIRNAME) + + std::string("nonexistent_add/nonexistent_add.pb")); ASSERT_NO_THROW(inputModel = frontEnd->load(model_filename)); ASSERT_NE(inputModel, nullptr); shared_ptr model; @@ -85,9 +85,9 @@ TEST(TFTelemetryTest, test_nonexistent_add) { model = frontEnd->convert(inputModel); FAIL() << "Non-existent operation Adddd must not be supported by TF FE."; } catch (const OpConversionFailure& error) { - string error_message = error.what(); - string ref_message = "Internal error, no translator found for operation(s): Adddd"; - ASSERT_TRUE(error_message.find(ref_message) != string::npos); + std::string error_message = error.what(); + std::string ref_message = "Internal error, no translator found for operation(s): Adddd"; + ASSERT_TRUE(error_message.find(ref_message) != std::string::npos); ASSERT_EQ(model, nullptr); // check telemetry data diff --git a/src/frontends/tensorflow/tests/test_models/gen_scripts/generate_2in_2out.py b/src/frontends/tensorflow/tests/test_models/gen_scripts/generate_2in_2out.py index 33264d2c6c749b..42f022c001c262 100644 --- a/src/frontends/tensorflow/tests/test_models/gen_scripts/generate_2in_2out.py +++ b/src/frontends/tensorflow/tests/test_models/gen_scripts/generate_2in_2out.py @@ -1,9 +1,10 @@ # Copyright (C) 2018-2023 Intel Corporation # SPDX-License-Identifier: Apache-2.0 -import numpy as np import os import sys + +import numpy as np import tensorflow as tf tf.compat.v1.reset_default_graph() @@ -33,3 +34,5 @@ tf_net = sess.graph_def tf.io.write_graph(tf_net, os.path.join(sys.argv[1], "2in_2out"), '2in_2out.pb', False) +tf.io.write_graph(tf_net, os.path.join(sys.argv[1], "2in_2out"), '2in_2out.pb.frozen', False) +tf.io.write_graph(tf_net, os.path.join(sys.argv[1], "2in_2out"), '2in_2out.pb.frozen_text', True) diff --git a/src/frontends/tensorflow/tests/tf_utils.cpp b/src/frontends/tensorflow/tests/tf_utils.cpp index d742b53dcf8704..11625e4250b99b 100644 --- a/src/frontends/tensorflow/tests/tf_utils.cpp +++ b/src/frontends/tensorflow/tests/tf_utils.cpp @@ -18,9 +18,9 @@ namespace tests { const std::string TF_FE = "tf"; -shared_ptr convert_model(const string& model_path, +shared_ptr convert_model(const std::string& model_path, const ConversionExtension::Ptr& conv_ext, - const vector& input_names, + const vector& input_names, const vector& input_types, const vector& input_shapes, const std::vector& input_names_to_freeze, @@ -34,7 +34,7 @@ shared_ptr convert_model(const string& model_path, if (conv_ext) { front_end->add_extension(conv_ext); } - auto model_filename = FrontEndTestUtils::make_model_path(string(TEST_TENSORFLOW_MODELS_DIRNAME) + model_path); + auto model_filename = FrontEndTestUtils::make_model_path(std::string(TEST_TENSORFLOW_MODELS_DIRNAME) + model_path); ov::frontend::InputModel::Ptr input_model; if (!disable_mmap) { input_model = front_end->load(model_filename); diff --git a/src/frontends/tensorflow_common/include/common_op_table.hpp b/src/frontends/tensorflow_common/include/common_op_table.hpp index 6b5d83d4c2bb84..d11b91049b8ba6 100644 --- a/src/frontends/tensorflow_common/include/common_op_table.hpp +++ b/src/frontends/tensorflow_common/include/common_op_table.hpp @@ -36,6 +36,7 @@ OP_CONVERTER(translate_add_n_op); OP_CONVERTER(translate_adjust_contrast_op); OP_CONVERTER(translate_arg_max_op); OP_CONVERTER(translate_arg_min_op); +OP_CONVERTER(translate_atan2_op); OP_CONVERTER(translate_avg_pool_op); OP_CONVERTER(translate_batch_mat_mul_op); OP_CONVERTER(translate_batch_mat_mul_with_type_op); @@ -100,6 +101,7 @@ OP_CONVERTER(translate_matrix_diag_op); OP_CONVERTER(translate_max_pool_op); OP_CONVERTER_NAMED(translate_max_pool_with_argmax); OP_CONVERTER(translate_mirror_pad_op); +OP_CONVERTER(translate_mul_no_nan_op); OP_CONVERTER_NAMED(translate_non_max_suppression_op); OP_CONVERTER(translate_parallel_dynamic_stitch_op); OP_CONVERTER(translate_placeholder_op); @@ -173,4 +175,4 @@ OP_CONVERTER_NAMED(translate_unique_op); } // namespace op } // namespace tensorflow } // namespace frontend -} // namespace ov \ No newline at end of file +} // namespace ov diff --git a/src/frontends/tensorflow_common/include/helper_ops/complex_type_mark.hpp b/src/frontends/tensorflow_common/include/helper_ops/complex_type_mark.hpp index 5d0e2d5eb2d140..f9f2d287295bed 100644 --- a/src/frontends/tensorflow_common/include/helper_ops/complex_type_mark.hpp +++ b/src/frontends/tensorflow_common/include/helper_ops/complex_type_mark.hpp @@ -4,47 +4,13 @@ #pragma once -#include "openvino/core/type/element_type.hpp" -#include "openvino/op/util/framework_node.hpp" +#include "openvino/frontend/complex_type_mark.hpp" namespace ov { namespace frontend { namespace tensorflow { -// ComplexTypeMark serves to mark places that require complex type propagation -// that means to represent native complex type with simulating floating-point tensor -// that has one extra dimension to concatenate real and imaginary parts of complex tensor. -// For example, a tensor of complex type with shape [N1, N2, ..., Nk] will be transformed -// into a floating-point tensor [N1, N2, ..., Nk, 2] -// where a slice with index [..., 0] represents a real part and -// a slice with index [..., 1] represents a imaginary part. -class ComplexTypeMark : public ov::op::util::FrameworkNode { -public: - OPENVINO_OP("ComplexTypeMark", "util", ov::op::util::FrameworkNode); - - ComplexTypeMark(const ov::Output& input, const ov::element::Type& complex_part_type) - : ov::op::util::FrameworkNode(ov::OutputVector{input}, 1), - m_complex_part_type(complex_part_type) { - validate_and_infer_types(); - } - - void validate_and_infer_types() override { - set_output_type(0, ov::element::dynamic, PartialShape::dynamic()); - } - - std::shared_ptr clone_with_new_inputs(const OutputVector& inputs) const override { - auto complex_type_mark = std::make_shared(inputs[0], m_complex_part_type); - complex_type_mark->set_attrs(get_attrs()); - return complex_type_mark; - } - - ov::element::Type get_complex_part_type() const { - return m_complex_part_type; - } - -private: - ov::element::Type m_complex_part_type; -}; +using ov::frontend::ComplexTypeMark; } // namespace tensorflow } // namespace frontend diff --git a/src/frontends/tensorflow_common/include/tf_framework_node.hpp b/src/frontends/tensorflow_common/include/tf_framework_node.hpp index fa2e949706dad0..10b9382f708a66 100644 --- a/src/frontends/tensorflow_common/include/tf_framework_node.hpp +++ b/src/frontends/tensorflow_common/include/tf_framework_node.hpp @@ -16,7 +16,7 @@ namespace tensorflow { class FrameworkNode : public ov::op::util::FrameworkNode { public: static constexpr const char* failed_conversion_key = "tensorflow::FrameworkNode::failed_conversion_key"; - OPENVINO_OP("FrameworkNode", "util", ::ov::op::util::FrameworkNode); + OPENVINO_OP("TFFrameworkNode", "util", ::ov::op::util::FrameworkNode); FrameworkNode(const std::shared_ptr& decoder, const OutputVector& inputs, size_t num_outputs) : ov::op::util::FrameworkNode(inputs, std::max(num_outputs, size_t(1))), diff --git a/src/frontends/tensorflow_common/src/op/atan2.cpp b/src/frontends/tensorflow_common/src/op/atan2.cpp new file mode 100644 index 00000000000000..35a7dbf40ae979 --- /dev/null +++ b/src/frontends/tensorflow_common/src/op/atan2.cpp @@ -0,0 +1,72 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 + +#include "common_op_table.hpp" +#include "openvino/op/add.hpp" +#include "openvino/op/atan.hpp" +#include "openvino/op/constant.hpp" +#include "openvino/op/convert_like.hpp" +#include "openvino/op/divide.hpp" +#include "openvino/op/equal.hpp" +#include "openvino/op/greater.hpp" +#include "openvino/op/greater_eq.hpp" +#include "openvino/op/less.hpp" +#include "openvino/op/logical_and.hpp" +#include "openvino/op/multiply.hpp" +#include "openvino/op/select.hpp" +#include "openvino/op/subtract.hpp" + +using namespace std; +using namespace ov::op; + +namespace ov { +namespace frontend { +namespace tensorflow { +namespace op { + +OutputVector translate_atan2_op(const NodeContext& node) { + default_op_checks(node, 2, {"Atan2"}); + auto y = node.get_input(0); + auto x = node.get_input(1); + + // handle the first condition : x>0 + auto div_y_x = make_shared(y, x); + auto atan = make_shared(div_y_x); + auto const_zero = create_same_type_const_scalar(x, 0); + auto result = atan->output(0); + + // handle the second condition : x<0 && y>=0 + auto const_pi = create_same_type_const_scalar(x, std::atan(1.0) * 4); + auto is_x_negative = make_shared(x, const_zero); + auto y_non_negative = make_shared(y, const_zero); + auto cond1 = make_shared(is_x_negative, y_non_negative); + auto atan_y_x_plus_pi = make_shared(atan, const_pi); + result = make_shared(cond1, atan_y_x_plus_pi, result); + + // handle the third condition : x<0 && y<0 + auto is_y_negative = make_shared(y, const_zero); + auto cond2 = make_shared(is_x_negative, is_y_negative); + auto atan_y_x_minus_pi = make_shared(atan, const_pi); + result = make_shared(cond2, atan_y_x_minus_pi, result); + + // handle the fourth condition : x=0 && y>0 + auto is_x_zero = make_shared(x, const_zero); + auto is_y_positive = make_shared(y, const_zero); + auto cond3 = make_shared(is_x_zero, is_y_positive); + auto const_two = create_same_type_const_scalar(x, 2); + auto pi_div_two = make_shared(const_pi, const_two); + result = make_shared(cond3, pi_div_two, result); + + // handle the fifth condition : x=0 && y<0 + auto cond4 = make_shared(is_x_zero, is_y_negative); + auto const_minus_two = create_same_type_const_scalar(x, -2); + auto pi_div_minus_two = make_shared(const_pi, const_minus_two); + result = make_shared(cond4, pi_div_two, result); + + set_node_name(node.get_name(), result.get_node_shared_ptr()); + return {result}; +} +} // namespace op +} // namespace tensorflow +} // namespace frontend +} // namespace ov diff --git a/src/frontends/tensorflow_common/src/op/mul_no_nan.cpp b/src/frontends/tensorflow_common/src/op/mul_no_nan.cpp new file mode 100644 index 00000000000000..513507207d2635 --- /dev/null +++ b/src/frontends/tensorflow_common/src/op/mul_no_nan.cpp @@ -0,0 +1,43 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "common_op_table.hpp" +#include "openvino/op/equal.hpp" +#include "openvino/op/multiply.hpp" +#include "openvino/op/select.hpp" +#include "utils.hpp" + +using namespace std; +using namespace ov::op; + +namespace ov { +namespace frontend { +namespace tensorflow { +namespace op { +OutputVector translate_mul_no_nan_op(const NodeContext& node) { + default_op_checks(node, 2, {"MulNoNan"}); + + // first = x, second = y + auto x = node.get_input(0); + auto y = node.get_input(1); + + // prepare zero constant of the same type as the inputs + auto const_zero = create_same_type_const_scalar(x, 0); + + // get mask where y equals 0 + auto is_zero = make_shared(y, const_zero); + + // replace all values in x at is_zero mask with zeros + auto x_zeros = make_shared(is_zero, const_zero, x); + + // multiply y with the updated x + auto mul_no_nan = make_shared(x_zeros, y); + + set_node_name(node.get_name(), mul_no_nan); + return mul_no_nan->outputs(); +} +} // namespace op +} // namespace tensorflow +} // namespace frontend +} // namespace ov \ No newline at end of file diff --git a/src/frontends/tensorflow_common/src/op/pad.cpp b/src/frontends/tensorflow_common/src/op/pad.cpp index 6f31d34ce7ebe0..43310f767b7d80 100644 --- a/src/frontends/tensorflow_common/src/op/pad.cpp +++ b/src/frontends/tensorflow_common/src/op/pad.cpp @@ -5,6 +5,8 @@ #include "openvino/op/pad.hpp" #include "common_op_table.hpp" +#include "helper_ops/complex_type_mark.hpp" +#include "openvino/op/concat.hpp" #include "openvino/op/constant.hpp" #include "openvino/op/convert.hpp" #include "openvino/op/gather.hpp" @@ -20,7 +22,8 @@ namespace tensorflow { namespace op { static void slice_pads_begin_end(const Output& paddings, shared_ptr& pads_begin, - shared_ptr& pads_end) { + shared_ptr& pads_end, + bool is_complex = false) { // TODO: fix IR reader to accept padding of i32 type auto paddings_i64 = make_shared(paddings, element::i64); auto axis = make_shared(element::i32, Shape{}, 1); @@ -28,28 +31,52 @@ static void slice_pads_begin_end(const Output& paddings, auto index_one = make_shared(element::i32, Shape{}, 1); pads_begin = make_shared(paddings_i64, index_zero, axis); pads_end = make_shared(paddings_i64, index_one, axis); + + if (is_complex) { + // the last dimension is auxiliary and needs no padding + auto const_zero = make_shared(element::i64, Shape{1}, 0); + pads_begin = make_shared(OutputVector{pads_begin, const_zero}, 0); + pads_end = make_shared(OutputVector{pads_end, const_zero}, 0); + } } static OutputVector translate_pad_base_op(const NodeContext& node, - const Output& input, + Output& input, const Output& paddings, const Output& constant_value) { + bool is_complex = false; + element::Type complex_part_type = element::f32; + if (auto complex_type_mark = as_type_ptr(input.get_node_shared_ptr())) { + is_complex = true; + complex_part_type = complex_type_mark->get_complex_part_type(); + input = complex_type_mark->input_value(0); + } auto pad_mode = ov::op::PadMode::CONSTANT; // prepare pads_begin and pads_end for OpenVINO Pad shared_ptr pads_begin, pads_end; - slice_pads_begin_end(paddings, pads_begin, pads_end); + slice_pads_begin_end(paddings, pads_begin, pads_end, is_complex); auto pad = make_shared(input, pads_begin, pads_end, constant_value, pad_mode); set_node_name(node.get_name(), pad); + + if (is_complex) { + // need to propagate ComplexTypeMark after Pad operation + auto complex_type_mark = make_shared(pad, complex_part_type); + return {complex_type_mark}; + } return {pad}; } OutputVector translate_pad_op(const NodeContext& node) { - default_op_checks(node, 2, {"Pad"}); + default_op_checks(node, 2, {"Pad"}, true); auto input = node.get_input(0); auto paddings = node.get_input(1); + auto constant_value = create_same_type_const_scalar(input, 0); + if (auto complex_type_mark = as_type_ptr(input.get_node_shared_ptr())) { + constant_value = create_same_type_const_scalar(complex_type_mark->input_value(0), 0); + } return translate_pad_base_op(node, input, paddings, constant_value); } diff --git a/src/frontends/tests/frontend/shared/src/op_fuzzy.cpp b/src/frontends/tests/frontend/shared/src/op_fuzzy.cpp index 8a911e6544f094..90826a6e164e2b 100644 --- a/src/frontends/tests/frontend/shared/src/op_fuzzy.cpp +++ b/src/frontends/tests/frontend/shared/src/op_fuzzy.cpp @@ -107,7 +107,12 @@ void FrontEndFuzzyOpTest::runConvertedModel(const std::shared_ptr mod } } +#ifdef OPENVINO_ARCH_ARM64 +// Ticket: 126830 +TEST_P(FrontEndFuzzyOpTest, DISABLED_testOpFuzzy) { +#else TEST_P(FrontEndFuzzyOpTest, testOpFuzzy) { +#endif // load ASSERT_NO_THROW(doLoadFromFile()); diff --git a/src/frontends/tests/frontend/shared/test_builtin_extensions/CMakeLists.txt b/src/frontends/tests/frontend/shared/test_builtin_extensions/CMakeLists.txt index 959834bbe0d15c..cc541e17b9017a 100644 --- a/src/frontends/tests/frontend/shared/test_builtin_extensions/CMakeLists.txt +++ b/src/frontends/tests/frontend/shared/test_builtin_extensions/CMakeLists.txt @@ -13,7 +13,7 @@ endif() file(GLOB LIBRARY_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) file(GLOB LIBRARY_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/*.hpp) -set(DEPENDENCIES openvino::runtime::dev openvino::frontend::common) +set(DEPENDENCIES openvino::runtime::dev) if (ENABLE_OV_ONNX_FRONTEND) list(APPEND DEPENDENCIES openvino::frontend::onnx) diff --git a/src/inference/CMakeLists.txt b/src/inference/CMakeLists.txt index 11ad85b3740d6a..768e7cf1185b7f 100644 --- a/src/inference/CMakeLists.txt +++ b/src/inference/CMakeLists.txt @@ -137,13 +137,11 @@ target_compile_definitions(${TARGET_NAME}_obj PRIVATE IMPLEMENT_INFERENCE_ENGINE_API $<$:PROXY_PLUGIN_ENABLED> $ - $ $) target_include_directories(${TARGET_NAME}_obj SYSTEM PRIVATE $ $ - $ $<$:$> $<$:$>) @@ -224,7 +222,8 @@ ov_install_static_lib(${TARGET_NAME}_plugin_api ${OV_CPACK_COMP_CORE}) install(DIRECTORY "${PUBLIC_HEADERS_DIR}/" DESTINATION ${OV_CPACK_INCLUDEDIR} - COMPONENT ${OV_CPACK_COMP_CORE_DEV}) + COMPONENT ${OV_CPACK_COMP_CORE_DEV} + ${OV_CPACK_COMP_CORE_DEV_EXCLUDE_ALL}) if(ENABLE_TESTS) add_subdirectory(tests) diff --git a/src/inference/dev_api/blob_factory.hpp b/src/inference/dev_api/blob_factory.hpp index 02401bbc5b2d55..3ba23868b92159 100644 --- a/src/inference/dev_api/blob_factory.hpp +++ b/src/inference/dev_api/blob_factory.hpp @@ -127,6 +127,7 @@ InferenceEngine::Blob::Ptr make_blob_with_precision(InferenceEngine::Precision p USE_FACTORY(BIN); USE_FACTORY(BF16); USE_FACTORY(BOOL); + USE_FACTORY(STRING); default: IE_THROW() << "cannot locate blob for precision: " << precision; } diff --git a/src/inference/dev_api/ie_ngraph_utils.hpp b/src/inference/dev_api/ie_ngraph_utils.hpp index 2786fc4abf4198..0dad11f80bedbd 100644 --- a/src/inference/dev_api/ie_ngraph_utils.hpp +++ b/src/inference/dev_api/ie_ngraph_utils.hpp @@ -55,6 +55,8 @@ INFERENCE_ENGINE_1_0_DEPRECATED inline ::ngraph::element::Type convertPrecision( return ::ngraph::element::Type(::ngraph::element::Type_t::u1); case Precision::NF4: return ::ngraph::element::Type(::ngraph::element::Type_t::nf4); + case Precision::STRING: + return ::ngraph::element::Type(::ngraph::element::Type_t::string); case Precision::Q78: case Precision::MIXED: case Precision::CUSTOM: @@ -105,6 +107,8 @@ INFERENCE_ENGINE_1_0_DEPRECATED inline Precision convertPrecision(const ::ngraph return Precision(Precision::BOOL); case ::ngraph::element::Type_t::nf4: return Precision(Precision::NF4); + case ::ngraph::element::Type_t::string: + return Precision(Precision::STRING); case ::ngraph::element::Type_t::dynamic: return Precision(Precision::UNSPECIFIED); default: diff --git a/src/inference/dev_api/openvino/runtime/system_conf.hpp b/src/inference/dev_api/openvino/runtime/system_conf.hpp index c2e0cc37fd942c..c4525265c2349a 100644 --- a/src/inference/dev_api/openvino/runtime/system_conf.hpp +++ b/src/inference/dev_api/openvino/runtime/system_conf.hpp @@ -260,6 +260,24 @@ OPENVINO_RUNTIME_API void set_cpu_used(const std::vector& cpu_ids, const in */ OPENVINO_RUNTIME_API int get_socket_by_numa_node(int numa_node_id); +/** + * @brief Get original socket id by current socket id, the input socket id is recalculated after filtering (like + * numactl), while the original socket id is the original id before filtering + * @ingroup ie_dev_api_system_conf + * @param[in] socket_id socket id + * @return socket id + */ +OPENVINO_RUNTIME_API int get_org_socket_id(int socket_id); + +/** + * @brief Get original numa node id by current numa node id, the input numa node id is recalculated after filtering + * (like numactl), while the original numa node id is the original id before filtering + * @ingroup ie_dev_api_system_conf + * @param[in] numa_node_id numa node id + * @return numa node id + */ +OPENVINO_RUNTIME_API int get_org_numa_id(int numa_node_id); + /** * @enum ColumnOfCPUMappingTable * @brief This enum contains definition of each columns in CPU mapping table which use processor id as index. 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 66f34be0bd69c5..363b7a912b15f0 100644 --- a/src/inference/dev_api/openvino/runtime/threading/istreams_executor.hpp +++ b/src/inference/dev_api/openvino/runtime/threading/istreams_executor.hpp @@ -194,6 +194,11 @@ class OPENVINO_RUNTIME_API IStreamsExecutor : virtual public ITaskExecutor { int threads_per_stream, PreferredCoreType core_type, bool cpu_pinning); + /** + * @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(); }; /** diff --git a/src/inference/dev_api/openvino/runtime/threading/thread_local.hpp b/src/inference/dev_api/openvino/runtime/threading/thread_local.hpp index 679d9518baa4ab..a92c312ee7273c 100644 --- a/src/inference/dev_api/openvino/runtime/threading/thread_local.hpp +++ b/src/inference/dev_api/openvino/runtime/threading/thread_local.hpp @@ -116,6 +116,20 @@ struct ThreadLocal { auto end() const -> Iterator const { return {_map.end()}; } + + // CombineFunc has signature T(T,T) or T(const T&, const T&) + template + T combine(CombineFunc f_combine) { + if (begin() != end()) { + auto ci = begin(); + T my_result = *ci; + while (++ci != end()) + my_result = f_combine(my_result, *ci); + return my_result; + } else { + return _create(); + } + } }; #endif diff --git a/src/inference/include/ie/ie_blob.h b/src/inference/include/ie/ie_blob.h index 0a40427f316541..f8e116ddfc5b3d 100644 --- a/src/inference/include/ie/ie_blob.h +++ b/src/inference/include/ie/ie_blob.h @@ -872,6 +872,7 @@ extern template class INFERENCE_ENGINE_API_CLASS(InferenceEngine::TBlob); extern template class INFERENCE_ENGINE_API_CLASS(InferenceEngine::TBlob); extern template class INFERENCE_ENGINE_API_CLASS(InferenceEngine::TBlob); +extern template class INFERENCE_ENGINE_API_CLASS(InferenceEngine::TBlob); #endif /** diff --git a/src/inference/include/ie/ie_precision.hpp b/src/inference/include/ie/ie_precision.hpp index 17b995244e253b..f967e2dd645c58 100644 --- a/src/inference/include/ie/ie_precision.hpp +++ b/src/inference/include/ie/ie_precision.hpp @@ -55,6 +55,7 @@ class INFERENCE_ENGINE_1_0_DEPRECATED Precision { U64 = 73, /**< 64bit unsigned integer value */ BIN = 71, /**< 1bit integer value */ BOOL = 41, /**< 8bit bool type */ + STRING = 79, /**< string type, std::string in C++ */ CUSTOM = 80 /**< custom precision has it's own name and size of elements */ }; @@ -146,6 +147,7 @@ class INFERENCE_ENGINE_1_0_DEPRECATED Precision { CASE(BOOL, uint8_t); CASE2(Q78, int16_t, uint16_t); CASE2(BIN, int8_t, uint8_t); + CASE(STRING, std::string); default: return areSameStrings(name(), typeName == nullptr ? typeid(T).name() : typeName); #undef CASE @@ -251,11 +253,11 @@ class INFERENCE_ENGINE_1_0_DEPRECATED Precision { static Precision FromStr(const std::string& str) { static const std::unordered_map names = { #define PRECISION_NAME(s) {#s, s} - PRECISION_NAME(Q78), PRECISION_NAME(BOOL), PRECISION_NAME(BF16), PRECISION_NAME(I4), - PRECISION_NAME(I8), PRECISION_NAME(I16), PRECISION_NAME(I32), PRECISION_NAME(I64), - PRECISION_NAME(U4), PRECISION_NAME(U8), PRECISION_NAME(U16), PRECISION_NAME(U32), - PRECISION_NAME(U64), PRECISION_NAME(FP32), PRECISION_NAME(FP64), PRECISION_NAME(FP16), - PRECISION_NAME(MIXED), PRECISION_NAME(NF4), PRECISION_NAME(BIN), + PRECISION_NAME(Q78), PRECISION_NAME(BOOL), PRECISION_NAME(BF16), PRECISION_NAME(I4), + PRECISION_NAME(I8), PRECISION_NAME(I16), PRECISION_NAME(I32), PRECISION_NAME(I64), + PRECISION_NAME(U4), PRECISION_NAME(U8), PRECISION_NAME(U16), PRECISION_NAME(U32), + PRECISION_NAME(U64), PRECISION_NAME(FP32), PRECISION_NAME(FP64), PRECISION_NAME(FP16), + PRECISION_NAME(MIXED), PRECISION_NAME(NF4), PRECISION_NAME(STRING), PRECISION_NAME(BIN), #undef PRECISION_NAME }; auto i = names.find(str); @@ -364,6 +366,7 @@ class INFERENCE_ENGINE_1_0_DEPRECATED Precision { CASE(MIXED); CASE(BIN); CASE(BOOL); + CASE(STRING); default: return makePrecisionInfo("UNSPECIFIED"); #undef CASE @@ -472,6 +475,12 @@ struct INFERENCE_ENGINE_1_0_DEPRECATED PrecisionTrait { enum { is_float = false }; }; +template <> +struct PrecisionTrait { + using value_type = std::string; + enum { is_float = false }; +}; + template INFERENCE_ENGINE_1_0_DEPRECATED inline uint8_t type_size_or_zero() { return sizeof(T); diff --git a/src/inference/include/openvino/runtime/auto/properties.hpp b/src/inference/include/openvino/runtime/auto/properties.hpp index 9cdfee865bd95d..090d9620550626 100644 --- a/src/inference/include/openvino/runtime/auto/properties.hpp +++ b/src/inference/include/openvino/runtime/auto/properties.hpp @@ -28,5 +28,51 @@ static constexpr Property enable_startup_fallback{"ENABLE_STARTUP_FALLBACK * selected device */ static constexpr Property enable_runtime_fallback{"ENABLE_RUNTIME_FALLBACK"}; + +/** + * @brief Enum to define the policy of scheduling inference request to target device in cumulative throughput mode on + * AUTO + * @ingroup ov_runtime_cpp_prop_api + */ +enum class SchedulePolicy { + ROUND_ROBIN = 0, // will schedule the infer request using round robin policy + DEVICE_PRIORITY = 1, // will schedule the infer request based on the device priority + DEFAULT = DEVICE_PRIORITY, //!< Default schedule policy is DEVICE_PRIORITY +}; + +/** @cond INTERNAL */ +inline std::ostream& operator<<(std::ostream& os, const SchedulePolicy& policy) { + switch (policy) { + case SchedulePolicy::ROUND_ROBIN: + return os << "ROUND_ROBIN"; + case SchedulePolicy::DEVICE_PRIORITY: + return os << "DEVICE_PRIORITY"; + default: + OPENVINO_THROW("Unsupported schedule policy value"); + } +} + +inline std::istream& operator>>(std::istream& is, SchedulePolicy& policy) { + std::string str; + is >> str; + if (str == "ROUND_ROBIN") { + policy = SchedulePolicy::ROUND_ROBIN; + } else if (str == "DEVICE_PRIORITY") { + policy = SchedulePolicy::DEVICE_PRIORITY; + } else if (str == "DEFAULT") { + policy = SchedulePolicy::DEFAULT; + } else { + OPENVINO_THROW("Unsupported schedule policy: ", str); + } + return is; +} +/** @endcond */ + +/** + * @brief High-level OpenVINO model policy hint + * Defines what scheduling policy should be used in AUTO CUMULATIVE_THROUGHPUT or MULTI case + * @ingroup ov_runtime_cpp_prop_api + */ +static constexpr Property schedule_policy{"SCHEDULE_POLICY"}; } // namespace intel_auto } // namespace ov \ No newline at end of file diff --git a/src/inference/src/core.cpp b/src/inference/src/core.cpp index fd05fbaec54a78..9ee07f6246afe5 100644 --- a/src/inference/src/core.cpp +++ b/src/inference/src/core.cpp @@ -13,20 +13,6 @@ #include "openvino/runtime/iremote_context.hpp" #include "openvino/util/file_util.hpp" -namespace { -std::string resolve_extension_path(const std::string& path) { - std::string retvalue; - try { - const std::string absolute_path = ov::util::get_absolute_file_path(path); - retvalue = ov::util::file_exists(absolute_path) ? absolute_path : path; - } catch (const std::runtime_error&) { - retvalue = path; - } - return retvalue; -} - -} // namespace - namespace ov { std::string find_plugins_xml(const std::string& xml_file) { @@ -166,8 +152,7 @@ void Core::add_extension(const InferenceEngine::IExtensionPtr& extension) { void Core::add_extension(const std::string& library_path) { try { - const std::string path = resolve_extension_path(library_path); - add_extension(ov::detail::load_extensions(path)); + add_extension(ov::detail::load_extensions(library_path)); } catch (const std::runtime_error&) { try { // Try to load legacy extension @@ -186,8 +171,7 @@ void Core::add_extension(const std::string& library_path) { #ifdef OPENVINO_ENABLE_UNICODE_PATH_SUPPORT void Core::add_extension(const std::wstring& library_path) { try { - const std::string path = resolve_extension_path(ov::util::wstring_to_string(library_path)); - add_extension(ov::detail::load_extensions(ov::util::string_to_wstring(path))); + add_extension(ov::detail::load_extensions(library_path)); } catch (const std::runtime_error&) { try { // Try to load legacy extension diff --git a/src/inference/src/dev/core_impl.cpp b/src/inference/src/dev/core_impl.cpp index 458563633ed0b3..8d8db9bbab9936 100644 --- a/src/inference/src/dev/core_impl.cpp +++ b/src/inference/src/dev/core_impl.cpp @@ -837,7 +837,7 @@ ov::SoPtr ov::CoreImpl::compile_model(const std::string& mod return compile_model_and_cache(model, plugin, parsed._config, {}, cacheContent); }); } else if (cacheManager) { - // this code path is enabled for AUTO / MULTI / BATCH devices which don't support + // this code path is enabled for AUTO / MULTI / BATCH / PROXY devices which don't support // import / export explicitly, but can redirect this functionality to actual HW plugin compiled_model = plugin.compile_model(model_path, parsed._config); } else { diff --git a/src/inference/src/dev/make_tensor.cpp b/src/inference/src/dev/make_tensor.cpp index a61095bc1cba97..2c5340b046247b 100644 --- a/src/inference/src/dev/make_tensor.cpp +++ b/src/inference/src/dev/make_tensor.cpp @@ -37,7 +37,9 @@ class ViewTensor : public ITensor { void* data(const element::Type& element_type) const override { if (element_type != element::undefined && element_type != element::dynamic && (element_type.bitwidth() != get_element_type().bitwidth() || - element_type.is_real() != get_element_type().is_real())) { + element_type.is_real() != get_element_type().is_real() || + (element_type == element::string && get_element_type() != element::string) || + (element_type != element::string && get_element_type() == element::string))) { OPENVINO_THROW("Tensor data with element type ", get_element_type(), ", is not representable as pointer to ", @@ -178,28 +180,63 @@ class AllocatedTensor : public ViewTensor { shape, [&] { OPENVINO_ASSERT(allocator, "Allocator was not initialized"); - return const_cast(allocator).allocate(element_type.size() * shape_size(shape)); + auto num_elements = shape_size(shape); + auto data = const_cast(allocator).allocate(element_type.size() * num_elements); + init(data, element_type, shape); + return data; }()}, m_allocator{allocator} {} ~AllocatedTensor() { + auto num_elements = get_size(); + destroy(0, num_elements); m_allocator.deallocate(m_ptr, get_byte_size()); } void set_shape(ov::Shape new_shape) override { if (m_shape == new_shape) return; + + auto old_num_elements = get_size(); auto old_byte_size = get_byte_size(); m_shape = std::move(new_shape); + auto new_num_elements = get_size(); + if (get_byte_size() > old_byte_size) { + // allocate buffer and initialize objects from scratch + destroy(0, old_num_elements); m_allocator.deallocate(m_ptr, old_byte_size); m_ptr = m_allocator.allocate(get_byte_size()); + init(m_ptr, m_element_type, m_shape); + } else { + // destroy only not needed objects + destroy(new_num_elements, old_num_elements); } + m_strides.clear(); update_strides(); } private: + void destroy(size_t begin_ind, size_t end_ind) { + // it removes elements from tail + if (get_element_type() == element::Type_t::string) { + auto strings = static_cast(m_ptr); + for (size_t ind = begin_ind; ind < end_ind; ++ind) { + using std::string; + strings[ind].~string(); + } + } + } + + void init(void* data, const element::Type& element_type, const Shape& shape) { + if (element_type == element::Type_t::string) { + auto num_elements = shape_size(shape); + auto string_ptr = static_cast(data); + std::uninitialized_fill_n(string_ptr, num_elements, std::string()); + } + } + Allocator m_allocator; }; diff --git a/src/inference/src/dev/threading/cpu_streams_executor.cpp b/src/inference/src/dev/threading/cpu_streams_executor.cpp index 8068359ad935ce..eb706a37192143 100644 --- a/src/inference/src/dev/threading/cpu_streams_executor.cpp +++ b/src/inference/src/dev/threading/cpu_streams_executor.cpp @@ -144,7 +144,7 @@ struct CPUStreamsExecutor::Impl { .set_max_threads_per_core(max_threads_per_core)}); } else if (stream_type == STREAM_WITH_NUMA_ID) { _taskArena.reset(new custom::task_arena{custom::task_arena::constraints{} - .set_numa_id(_numaNodeId) + .set_numa_id(get_org_numa_id(_numaNodeId)) .set_max_concurrency(concurrency) .set_max_threads_per_core(max_threads_per_core)}); } else if (stream_type == STREAM_WITH_CORE_TYPE) { @@ -186,7 +186,10 @@ 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 = _streamId >= _impl->_config._streams ? _impl->_config._streams - 1 : _streamId; + const auto stream_id = + _impl->_config._streams == 0 + ? 0 + : (_streamId >= _impl->_config._streams ? _impl->_config._streams - 1 : _streamId); get_cur_stream_info(stream_id, _impl->_config._cpu_reservation, diff --git a/src/inference/src/dev/threading/istreams_executor.cpp b/src/inference/src/dev/threading/istreams_executor.cpp index 4c7dc2c2ede546..891de30aba695d 100644 --- a/src/inference/src/dev/threading/istreams_executor.cpp +++ b/src/inference/src/dev/threading/istreams_executor.cpp @@ -563,6 +563,10 @@ void IStreamsExecutor::Config::update_executor_config(int stream_nums, return; } + if (proc_type_table.size() > 1) { + core_type = ov::threading::IStreamsExecutor::Config::ANY; + } + // 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]; @@ -659,5 +663,22 @@ void IStreamsExecutor::Config::update_executor_config(int stream_nums, } } +void IStreamsExecutor::Config::set_config_zero_stream() { + std::vector> proc_type_table = get_proc_type_table(); + int core_type = MAIN_CORE_PROC; + int numa_id = 0; + int socket_id = 0; + + if (proc_type_table.size() > 0) { + core_type = proc_type_table[0][MAIN_CORE_PROC] > 0 + ? MAIN_CORE_PROC + : (proc_type_table[0][EFFICIENT_CORE_PROC] > 0 ? EFFICIENT_CORE_PROC : HYPER_THREADING_PROC); + numa_id = std::max(0, proc_type_table[0][PROC_NUMA_NODE_ID]); + socket_id = std::max(0, proc_type_table[0][PROC_SOCKET_ID]); + } + _streams_info_table.push_back({1, core_type, 1, numa_id, socket_id}); + _cpu_reservation = false; +} + } // namespace threading } // namespace ov diff --git a/src/inference/src/ie_blob_common.cpp b/src/inference/src/ie_blob_common.cpp index 40347650838930..e7e0d0ab040178 100644 --- a/src/inference/src/ie_blob_common.cpp +++ b/src/inference/src/ie_blob_common.cpp @@ -118,6 +118,7 @@ template class TBlob; template class TBlob; template class TBlob; template class TBlob; +template class TBlob; #endif } // namespace InferenceEngine diff --git a/src/inference/src/os/cpu_map_info.hpp b/src/inference/src/os/cpu_map_info.hpp index 88606a846c3cb6..9121b706f7d620 100644 --- a/src/inference/src/os/cpu_map_info.hpp +++ b/src/inference/src/os/cpu_map_info.hpp @@ -27,6 +27,8 @@ class CPU { std::vector> _org_proc_type_table; std::vector> _proc_type_table; std::vector> _cpu_mapping_table; + std::map _socketid_mapping_table; + std::map _numaid_mapping_table; std::mutex _cpu_mutex; int _socket_idx = 0; }; @@ -155,14 +157,13 @@ void parse_processor_info_win(const char* base_ptr, * @param[out] _sockets total number for sockets in system * @param[out] _cores total number for physical CPU cores in system * @param[out] _proc_type_table summary table of number of processors per type - * @return */ -int parse_processor_info_macos(const std::vector>& system_info_table, - int& _processors, - int& _numa_nodes, - int& _sockets, - int& _cores, - std::vector>& _proc_type_table); +void parse_processor_info_macos(const std::vector>& system_info_table, + int& _processors, + int& _numa_nodes, + int& _sockets, + int& _cores, + std::vector>& _proc_type_table); #endif } // namespace ov diff --git a/src/inference/src/os/lin/lin_system_conf.cpp b/src/inference/src/os/lin/lin_system_conf.cpp index 2cfb12a7826b33..99ded17f0f1597 100644 --- a/src/inference/src/os/lin/lin_system_conf.cpp +++ b/src/inference/src/os/lin/lin_system_conf.cpp @@ -169,10 +169,16 @@ CPU::CPU() { } } for (size_t i = 0; i < valid_cpu_mapping_table.size(); i++) { - valid_cpu_mapping_table[i][CPU_MAP_NUMA_NODE_ID] = - numa_node_map.at(valid_cpu_mapping_table[i][CPU_MAP_NUMA_NODE_ID]); - valid_cpu_mapping_table[i][CPU_MAP_SOCKET_ID] = - sockets_map.at(valid_cpu_mapping_table[i][CPU_MAP_SOCKET_ID]); + auto new_numa_id = numa_node_map.at(valid_cpu_mapping_table[i][CPU_MAP_NUMA_NODE_ID]); + auto new_socket_id = sockets_map.at(valid_cpu_mapping_table[i][CPU_MAP_SOCKET_ID]); + if (_numaid_mapping_table.find(new_numa_id) == _numaid_mapping_table.end()) { + _numaid_mapping_table.insert({new_numa_id, valid_cpu_mapping_table[i][CPU_MAP_NUMA_NODE_ID]}); + } + if (_socketid_mapping_table.find(new_socket_id) == _socketid_mapping_table.end()) { + _socketid_mapping_table.insert({new_socket_id, valid_cpu_mapping_table[i][CPU_MAP_SOCKET_ID]}); + } + valid_cpu_mapping_table[i][CPU_MAP_NUMA_NODE_ID] = new_numa_id; + valid_cpu_mapping_table[i][CPU_MAP_SOCKET_ID] = new_socket_id; } } @@ -265,12 +271,13 @@ CPU::CPU() { _cores); } } - _org_proc_type_table = _proc_type_table; std::vector>().swap(system_info_table); if (check_valid_cpu() < 0) { OPENVINO_THROW("CPU affinity check failed. No CPU is eligible to run inference."); }; + + _org_proc_type_table = _proc_type_table; } void parse_node_info_linux(const std::vector node_info_table, @@ -601,6 +608,16 @@ void parse_freq_info_linux(const std::vector> system_in std::vector line_value_0(PROC_TYPE_TABLE_SIZE, 0); + auto clean_up_output = [&]() { + _processors = 0; + _cores = 0; + _numa_nodes = 0; + _sockets = 0; + _cpu_mapping_table.clear(); + _proc_type_table.clear(); + return; + }; + for (int n = 0; n < _processors; n++) { if (-1 == _cpu_mapping_table[n][CPU_MAP_SOCKET_ID]) { std::string::size_type pos = 0; @@ -618,6 +635,10 @@ void parse_freq_info_linux(const std::vector> system_in core_1 = std::stoi(sub_str); sub_str = system_info_table[n][0].substr(endpos1 + 1); core_2 = std::stoi(sub_str); + if ((core_1 != n) && (core_2 != n)) { + clean_up_output(); + return; + } _cpu_mapping_table[core_1][CPU_MAP_PROCESSOR_ID] = core_1; _cpu_mapping_table[core_1][CPU_MAP_SOCKET_ID] = std::stoi(system_info_table[core_1][1]); diff --git a/src/inference/src/os/mac/mac_system_conf.cpp b/src/inference/src/os/mac/mac_system_conf.cpp index 04b9a77c7d61da..092cd0f33cddef 100644 --- a/src/inference/src/os/mac/mac_system_conf.cpp +++ b/src/inference/src/os/mac/mac_system_conf.cpp @@ -7,6 +7,7 @@ #include #include "dev/threading/parallel_custom_arena.hpp" +#include "openvino/core/except.hpp" #include "openvino/runtime/system_conf.hpp" #include "os/cpu_map_info.hpp" @@ -28,17 +29,16 @@ CPU::CPU() { } } - if (!parse_processor_info_macos(system_info_table, _processors, _numa_nodes, _sockets, _cores, _proc_type_table)) { - _org_proc_type_table = _proc_type_table; - } + parse_processor_info_macos(system_info_table, _processors, _numa_nodes, _sockets, _cores, _proc_type_table); + _org_proc_type_table = _proc_type_table; } -int parse_processor_info_macos(const std::vector>& system_info_table, - int& _processors, - int& _numa_nodes, - int& _sockets, - int& _cores, - std::vector>& _proc_type_table) { +void parse_processor_info_macos(const std::vector>& system_info_table, + int& _processors, + int& _numa_nodes, + int& _sockets, + int& _cores, + std::vector>& _proc_type_table) { _processors = 0; _numa_nodes = 0; _sockets = 0; @@ -51,7 +51,7 @@ int parse_processor_info_macos(const std::vector(it->second); } @@ -63,63 +63,50 @@ int parse_processor_info_macos(const std::vector(it->second); } + _proc_type_table.resize(1, std::vector(PROC_TYPE_TABLE_SIZE, 0)); + _numa_nodes = 1; _sockets = 1; + _proc_type_table[0][ALL_PROC] = _processors; + _proc_type_table[0][MAIN_CORE_PROC] = _cores; + _proc_type_table[0][HYPER_THREADING_PROC] = _processors - _cores; + it = std::find_if(system_info_table.begin(), system_info_table.end(), [&](const std::pair& item) { return item.first == "hw.optional.arm64"; }); - if (it == system_info_table.end()) { - _proc_type_table.resize(1, std::vector(PROC_TYPE_TABLE_SIZE, 0)); - _proc_type_table[0][ALL_PROC] = _processors; - _proc_type_table[0][MAIN_CORE_PROC] = _cores; - _proc_type_table[0][HYPER_THREADING_PROC] = _processors - _cores; - _proc_type_table[0][PROC_NUMA_NODE_ID] = 0; - _proc_type_table[0][PROC_SOCKET_ID] = 0; - } else { + if (it != system_info_table.end()) { it = std::find_if(system_info_table.begin(), system_info_table.end(), [&](const std::pair& item) { return item.first == "hw.perflevel0.physicalcpu"; }); - if (it == system_info_table.end()) { - _processors = 0; - _cores = 0; - _numa_nodes = 0; - _sockets = 0; - return -1; - } else { - _proc_type_table.resize(1, std::vector(PROC_TYPE_TABLE_SIZE, 0)); - _proc_type_table[0][ALL_PROC] = _processors; + if (it != system_info_table.end()) { _proc_type_table[0][MAIN_CORE_PROC] = it->second; - _proc_type_table[0][PROC_NUMA_NODE_ID] = 0; - _proc_type_table[0][PROC_SOCKET_ID] = 0; - } - it = std::find_if(system_info_table.begin(), - system_info_table.end(), - [&](const std::pair& item) { - return item.first == "hw.perflevel1.physicalcpu"; - }); + it = std::find_if(system_info_table.begin(), + system_info_table.end(), + [&](const std::pair& item) { + return item.first == "hw.perflevel1.physicalcpu"; + }); - if (it == system_info_table.end()) { - return 0; + if (it != system_info_table.end()) { + _proc_type_table[0][EFFICIENT_CORE_PROC] = it->second; + } } else { - _proc_type_table[0][EFFICIENT_CORE_PROC] = it->second; + _proc_type_table[0][EFFICIENT_CORE_PROC] = _cores / 2; + _proc_type_table[0][MAIN_CORE_PROC] = _cores - _proc_type_table[0][EFFICIENT_CORE_PROC]; } } - - return 0; } } // namespace ov diff --git a/src/inference/src/system_conf.cpp b/src/inference/src/system_conf.cpp index b4fded633ffdb0..7b048accbaf4b7 100644 --- a/src/inference/src/system_conf.cpp +++ b/src/inference/src/system_conf.cpp @@ -215,6 +215,14 @@ int get_socket_by_numa_node(int numa_node_id) { return -1; }; +int get_org_socket_id(int socket_id) { + return -1; +} + +int get_org_numa_id(int numa_node_id) { + return -1; +} + #elif defined(__APPLE__) // for Linux and Windows the getNumberOfCPUCores (that accounts only for physical cores) implementation is OS-specific // (see cpp files in corresponding folders), for __APPLE__ it is default : @@ -267,6 +275,24 @@ int get_socket_by_numa_node(int numa_node_id) { return -1; }; +int get_org_socket_id(int socket_id) { + CPU& cpu = cpu_info(); + auto iter = cpu._socketid_mapping_table.find(socket_id); + if (iter != cpu._socketid_mapping_table.end()) { + return iter->second; + } + return -1; +} + +int get_org_numa_id(int numa_node_id) { + CPU& cpu = cpu_info(); + auto iter = cpu._numaid_mapping_table.find(numa_node_id); + if (iter != cpu._numaid_mapping_table.end()) { + return iter->second; + } + return -1; +} + #else # ifndef _WIN32 @@ -417,6 +443,25 @@ int get_number_of_logical_cpu_cores(bool bigCoresOnly) { # endif return logical_cores; } + +int get_org_socket_id(int socket_id) { + CPU& cpu = cpu_info(); + auto iter = cpu._socketid_mapping_table.find(socket_id); + if (iter != cpu._socketid_mapping_table.end()) { + return iter->second; + } + return -1; +} + +int get_org_numa_id(int numa_node_id) { + CPU& cpu = cpu_info(); + auto iter = cpu._numaid_mapping_table.find(numa_node_id); + if (iter != cpu._numaid_mapping_table.end()) { + return iter->second; + } + return -1; +} + #endif #if ((OV_THREAD == OV_THREAD_TBB) || (OV_THREAD == OV_THREAD_TBB_AUTO)) diff --git a/src/inference/tests/functional/CMakeLists.txt b/src/inference/tests/functional/CMakeLists.txt index 4a42e9eb5bd5b4..187f48599746e5 100644 --- a/src/inference/tests/functional/CMakeLists.txt +++ b/src/inference/tests/functional/CMakeLists.txt @@ -36,6 +36,10 @@ if(ENABLE_AUTO_BATCH) list(APPEND COMPILE_DEFINITIONS ENABLE_AUTO_BATCH) endif() +if(ENABLE_PROXY) + list(APPEND COMPILE_DEFINITIONS PROXY_PLUGIN_ENABLED) +endif() + ov_add_test_target( NAME ${TARGET_NAME} ROOT ${CMAKE_CURRENT_SOURCE_DIR} @@ -48,6 +52,7 @@ ov_add_test_target( ${COMPILE_DEFINITIONS} INCLUDES $/src + $<$:$> ${CMAKE_CURRENT_SOURCE_DIR} ADD_CLANG_FORMAT LABELS diff --git a/src/inference/tests/functional/caching_test.cpp b/src/inference/tests/functional/caching_test.cpp index 2668eafc44a34e..06569f7bdfcfec 100644 --- a/src/inference/tests/functional/caching_test.cpp +++ b/src/inference/tests/functional/caching_test.cpp @@ -22,6 +22,9 @@ #include "openvino/op/parameter.hpp" #include "openvino/pass/manager.hpp" #include "openvino/pass/serialize.hpp" +#ifdef PROXY_PLUGIN_ENABLED +# include "openvino/proxy/properties.hpp" +#endif #include "openvino/runtime/common.hpp" #include "openvino/runtime/compiled_model.hpp" #include "openvino/runtime/core.hpp" @@ -2341,3 +2344,58 @@ INSTANTIATE_TEST_SUITE_P(CachingTest, ::testing::Combine(::testing::ValuesIn(loadVariants), ::testing::ValuesIn(cacheFolders)), getTestCaseName); #endif // defined(ENABLE_OV_IR_FRONTEND) + +class CacheTestWithProxyEnabled : public CachingTest { +protected: + void testLoadProxy(const std::function& func) { + ov::Core core; + injectPlugin(mockPlugin.get()); + core.register_plugin(ov::util::make_plugin_library_name(ov::test::utils::getExecutableDirectory(), + std::string("mock_engine") + OV_BUILD_POSTFIX), + deviceName, + {{ov::proxy::configuration::alias.name(), "mock"}, + {ov::proxy::configuration::internal_name.name(), "internal_mock"}}); + ON_CALL(*mockPlugin, get_default_context(_)).WillByDefault(Invoke([&](const ov::AnyMap&) { + return std::make_shared("internal_mock"); + })); + func(core); + core.unload_plugin(deviceName); + } +}; + +#ifdef PROXY_PLUGIN_ENABLED +TEST_P(CacheTestWithProxyEnabled, TestLoad) { + ON_CALL(*mockPlugin, get_property(ov::available_devices.name(), _)) + .WillByDefault(Invoke([&](const std::string&, const ov::AnyMap&) { + std::vector available_devices = {}; + available_devices.push_back("mock"); + return decltype(ov::available_devices)::value_type(available_devices); + })); + EXPECT_CALL(*mockPlugin, get_default_context(_)).Times(AnyNumber()); + EXPECT_CALL(*mockPlugin, get_property(ov::supported_properties.name(), _)).Times(AnyNumber()); + EXPECT_CALL(*mockPlugin, get_property(ov::device::architecture.name(), _)).Times(AnyNumber()); + EXPECT_CALL(*mockPlugin, get_property(ov::internal::supported_properties.name(), _)).Times(AnyNumber()); + EXPECT_CALL(*mockPlugin, get_property(ov::internal::caching_properties.name(), _)).Times(AnyNumber()); + EXPECT_CALL(*mockPlugin, get_property(ov::available_devices.name(), _)).Times(AnyNumber()); + EXPECT_CALL(*mockPlugin, get_property(ov::device::capabilities.name(), _)) + .Times(AnyNumber()) + .WillRepeatedly(Return(decltype(ov::device::capabilities)::value_type{})); + // proxy should direct the compile from file to hardware plugin + EXPECT_CALL(*mockPlugin, OnCompileModelFromFile()).Times(m_type == TestLoadType::EModelName ? 1 : 0); + + { + EXPECT_CALL(*mockPlugin, compile_model(_, _, _)).Times(m_remoteContext ? 1 : 0); + EXPECT_CALL(*mockPlugin, compile_model(A&>(), _)) + .Times(!m_remoteContext ? 1 : 0); + testLoadProxy([&](ov::Core& core) { + core.set_property(ov::cache_dir(m_cacheDir)); + m_testFunction(core); + }); + } +} + +INSTANTIATE_TEST_SUITE_P(CacheTestWithProxyEnabled, + CacheTestWithProxyEnabled, + ::testing::Combine(::testing::ValuesIn(loadVariants), ::testing::ValuesIn(cacheFolders)), + getTestCaseName); +#endif \ No newline at end of file diff --git a/src/inference/tests/unit/cpu_map_parser/freq_parser_linux.cpp b/src/inference/tests/unit/cpu_map_parser/freq_parser_linux.cpp index 118c32218ed7b2..0609798e9669a4 100644 --- a/src/inference/tests/unit/cpu_map_parser/freq_parser_linux.cpp +++ b/src/inference/tests/unit/cpu_map_parser/freq_parser_linux.cpp @@ -967,6 +967,22 @@ LinuxCpuMapTestCase freq_1sockets_4cores = { {}, }; +LinuxCpuMapTestCase freq_1sockets_4cores_2 = { + 0, + 0, + 0, + 0, + {}, + {}, + { + {"0-3", "-1", "1848000"}, + {"0-3", "-1", "1848000"}, + {"0-3", "-1", "1848000"}, + {"0-3", "-1", "1848000"}, + }, + {}, +}; + TEST_P(LinuxCpuMapFreqParserTests, LinuxFreq) {} INSTANTIATE_TEST_SUITE_P(CPUMap, @@ -986,7 +1002,8 @@ INSTANTIATE_TEST_SUITE_P(CPUMap, freq_1sockets_12cores_hyperthreading, freq_1sockets_8cores_hyperthreading, freq_1sockets_8cores_hyperthreading_1, - freq_1sockets_4cores)); + freq_1sockets_4cores, + freq_1sockets_4cores_2)); #endif } // namespace \ No newline at end of file diff --git a/src/inference/tests/unit/cpu_map_parser/parser_macos.cpp b/src/inference/tests/unit/cpu_map_parser/parser_macos.cpp index 59fe8aef0ac543..9b550ee9a04f97 100644 --- a/src/inference/tests/unit/cpu_map_parser/parser_macos.cpp +++ b/src/inference/tests/unit/cpu_map_parser/parser_macos.cpp @@ -52,7 +52,7 @@ class MacOSCpuMapParserTests : public ov::test::TestsCommon, } }; -MacOSCpuMapTestCase test_case_arm = { +MacOSCpuMapTestCase test_case_arm_1 = { 8, // param[expected out]: total 8 logcial processors on this simulated platform 1, // param[expected out]: total 1 numa nodes on this simulated platform 1, // param[expected out]: total 1 sockets on this simulated platform @@ -67,7 +67,32 @@ MacOSCpuMapTestCase test_case_arm = { }, // param[in]: The system information table of this simulated platform }; -MacOSCpuMapTestCase test_case_x86 = { +MacOSCpuMapTestCase test_case_arm_2 = { + 8, + 1, + 1, + 8, + {{8, 4, 4, 0, 0, 0}}, + { + {"hw.ncpu", 8}, + {"hw.physicalcpu", 8}, + {"hw.optional.arm64", 1}, + }, +}; + +MacOSCpuMapTestCase test_case_arm_3 = { + 8, + 1, + 1, + 8, + {{8, 4, 4, 0, 0, 0}}, + { + {"hw.ncpu", 8}, + {"hw.optional.arm64", 1}, + }, +}; + +MacOSCpuMapTestCase test_case_x86_1 = { 12, 1, 1, @@ -76,9 +101,21 @@ MacOSCpuMapTestCase test_case_x86 = { {{"hw.ncpu", 12}, {"hw.physicalcpu", 6}}, }; +MacOSCpuMapTestCase test_case_x86_2 = { + 12, + 1, + 1, + 12, + {{12, 12, 0, 0, 0, 0}}, + {{"hw.ncpu", 12}}, +}; + TEST_P(MacOSCpuMapParserTests, MacOS) {} -INSTANTIATE_TEST_SUITE_P(CPUMap, MacOSCpuMapParserTests, testing::Values(test_case_arm, test_case_x86)); +INSTANTIATE_TEST_SUITE_P( + CPUMap, + MacOSCpuMapParserTests, + testing::Values(test_case_arm_1, test_case_arm_2, test_case_arm_3, test_case_x86_1, test_case_x86_2)); #endif } // namespace diff --git a/src/plugins/auto/CMakeLists.txt b/src/plugins/auto/CMakeLists.txt index b3b60de0ab5d1b..5afb0173667db1 100644 --- a/src/plugins/auto/CMakeLists.txt +++ b/src/plugins/auto/CMakeLists.txt @@ -35,9 +35,8 @@ elseif(ENABLE_MULTI) VERSION_DEFINES_FOR src/plugin.cpp) endif() -if(ENABLE_TESTS) - add_subdirectory(tests) -endif() +find_package(Threads REQUIRED) +target_link_libraries(${TARGET_NAME} PRIVATE Threads::Threads) ov_set_threading_interface_for(${TARGET_NAME}) @@ -45,3 +44,7 @@ ov_set_threading_interface_for(${TARGET_NAME}) ov_add_api_validator_post_build_step(TARGET ${TARGET_NAME}) set_target_properties(${TARGET_NAME} PROPERTIES INTERPROCEDURAL_OPTIMIZATION_RELEASE ${ENABLE_LTO}) + +if(ENABLE_TESTS) + add_subdirectory(tests) +endif() diff --git a/src/plugins/auto/src/common.hpp b/src/plugins/auto/src/common.hpp index 8fac7e0e5e2444..317d6844c5af4c 100644 --- a/src/plugins/auto/src/common.hpp +++ b/src/plugins/auto/src/common.hpp @@ -219,6 +219,7 @@ class ScheduleContext : public std::enable_shared_from_this { std::string m_str_devices; unsigned int m_model_priority = 0; ov::Any m_performance_hint; + ov::Any m_schedule_policy = ov::intel_auto::SchedulePolicy::DEFAULT; std::mutex m_mutex; std::mutex m_fallback_mutex; SoCompiledModel m_hw_compiled_model; diff --git a/src/plugins/auto/src/cumulative_compiled_model.cpp b/src/plugins/auto/src/cumulative_compiled_model.cpp index 0f23b9fdc249f6..21339b653333c1 100644 --- a/src/plugins/auto/src/cumulative_compiled_model.cpp +++ b/src/plugins/auto/src/cumulative_compiled_model.cpp @@ -47,7 +47,8 @@ ov::Any AutoCumuCompiledModel::get_property(const std::string& name) const { ov::optimal_number_of_infer_requests, ov::device::properties, ov::hint::model_priority, - ov::loaded_from_cache}; + ov::loaded_from_cache, + ov::intel_auto::schedule_policy}; return ro_properties; }; const auto& default_rw_properties = []() { @@ -72,6 +73,8 @@ ov::Any AutoCumuCompiledModel::get_property(const std::string& name) const { return decltype(ov::supported_properties)::value_type(supported_properties); } else if (name == ov::hint::performance_mode) { return m_context->m_performance_hint; + } else if (name == ov::intel_auto::schedule_policy) { + return m_context->m_schedule_policy; } else if (name == ov::device::priorities) { // device priority does not support change on-the-fly return decltype(ov::device::priorities)::value_type(m_context->m_str_devices); diff --git a/src/plugins/auto/src/cumulative_schedule.cpp b/src/plugins/auto/src/cumulative_schedule.cpp index bf321e1aa58ebd..476c923bfedf58 100644 --- a/src/plugins/auto/src/cumulative_schedule.cpp +++ b/src/plugins/auto/src/cumulative_schedule.cpp @@ -10,6 +10,25 @@ // ------------------------------CumuSchedule---------------------------- namespace ov { namespace auto_plugin { +std::string CumuSchedule::schedule_to_next_device(const std::vector& devices, + std::size_t current_device_index) { + std::string selected_device_name = ""; + { + std::lock_guard lock(m_context->m_mutex); + m_n_ctput_schedule_next_device = + m_n_ctput_schedule_next_device >= devices.size() ? 0 : m_n_ctput_schedule_next_device; + selected_device_name = devices[m_n_ctput_schedule_next_device].device_name; + } + auto schedule_policy = m_context->m_schedule_policy; + if (schedule_policy == ov::intel_auto::SchedulePolicy::ROUND_ROBIN) { + std::lock_guard lock(m_context->m_mutex); + m_n_ctput_schedule_next_device++; + } else if (schedule_policy == ov::intel_auto::SchedulePolicy::DEVICE_PRIORITY) { + selected_device_name = devices[current_device_index].device_name; + } + return selected_device_name; +} + bool CumuSchedule::select_other_device(const std::string& cur_dev_name) { { std::lock_guard lock(m_context->m_fallback_mutex); @@ -209,7 +228,7 @@ bool CumuSchedule::schedule_to_worker_infer_request(ov::threading::Task pipeline std::unique_lock lock(m_context->m_fallback_mutex); if (!preferred_device.empty()) { devices = m_context->m_device_priorities; - if (!deviceChecker().check_if_device_in_list(preferred_device, devices)) { + if (!deviceChecker().check_if_device_in_list(preferred_device, devices)) { lock.unlock(); OPENVINO_THROW("The preferred device should be the selected device"); } @@ -217,14 +236,22 @@ bool CumuSchedule::schedule_to_worker_infer_request(ov::threading::Task pipeline devices = m_context->m_device_priorities; } lock.unlock(); - for (auto&& device : devices) { - if (!preferred_device.empty() && (device.device_name != preferred_device)) { + + std::size_t current_device_index = 0; + while (current_device_index < devices.size()) { + if (!preferred_device.empty() && (devices[current_device_index].device_name != preferred_device)) { + current_device_index++; continue; } - if (run_pipeline_task(pipeline_task, m_idle_worker_requests[device.device_name], preferred_device)) { + auto selected_device_name = + preferred_device.empty() ? schedule_to_next_device(devices, current_device_index) : preferred_device; + if (run_pipeline_task(pipeline_task, m_idle_worker_requests[selected_device_name], preferred_device)) { return true; + } else { + current_device_index++; } } + // no vacant requests this time, storing the task to the respective queue if (!preferred_device.empty()) { m_infer_pipeline_tasks_device_specific[preferred_device]->push(std::move(pipeline_task)); diff --git a/src/plugins/auto/src/cumulative_schedule.hpp b/src/plugins/auto/src/cumulative_schedule.hpp index b8b5defd218cbb..fdbb7be965af0f 100644 --- a/src/plugins/auto/src/cumulative_schedule.hpp +++ b/src/plugins/auto/src/cumulative_schedule.hpp @@ -17,7 +17,9 @@ class CumuSchedule : public Schedule { virtual ~CumuSchedule(); std::unique_ptr m_p_ctput_loadcontext = nullptr; size_t m_n_ctput_devicenums = 0; - + size_t m_n_ctput_schedule_next_device = 0; + std::string schedule_to_next_device(const std::vector& devices, + std::size_t current_device_index); private: void init() override; SoCompiledModel wait_first_compiled_model_ready() override; diff --git a/src/plugins/auto/src/plugin.cpp b/src/plugins/auto/src/plugin.cpp index 59e79222540f94..5b27a5f9f683ed 100644 --- a/src/plugins/auto/src/plugin.cpp +++ b/src/plugins/auto/src/plugin.cpp @@ -464,7 +464,7 @@ std::shared_ptr Plugin::compile_model_impl(const std::string std::list devices_with_priority(support_devices.begin(), support_devices.end()); std::shared_ptr cloned_model, ppp_model; if (model_path.empty()) { - support_devices = filter_device_by_model(support_devices_by_property, model); + support_devices = filter_device_by_model(support_devices_by_property, model, load_config); cloned_model = model->clone(); ppp_model = cloned_model->clone(); @@ -555,6 +555,7 @@ std::shared_ptr Plugin::compile_model_impl(const std::string auto_s_context->m_startup_fallback = load_config.get_property(ov::intel_auto::enable_startup_fallback); auto_s_context->m_runtime_fallback = load_config.get_property(ov::intel_auto::enable_runtime_fallback); auto_s_context->m_bind_buffer = load_config.get_property(ov::intel_auto::device_bind_buffer); + auto_s_context->m_schedule_policy = load_config.get_property(ov::intel_auto::schedule_policy); std::shared_ptr impl; std::shared_ptr scheduler = is_cumulative ? std::static_pointer_cast(std::make_shared()) : std::static_pointer_cast(std::make_shared()); @@ -910,39 +911,83 @@ std::vector Plugin::filter_device(const std::vector Plugin::filter_device_by_model(const std::vector& meta_devices, - const std::shared_ptr& model) const { + const std::shared_ptr& model, + PluginConfig& load_config) const { if (meta_devices.empty()) { OPENVINO_THROW("No available device to filter ", get_device_name(), " plugin"); } - std::vector filter_device; - auto is_stateful = [&]() { - for (auto& op : model->get_ops()) { - if (std::dynamic_pointer_cast(op) || - std::dynamic_pointer_cast(op)) { - LOG_INFO_TAG("stateful mode, try deployed to CPU"); - return true; - } + auto disable_startup_runtime_fallback = [&]() { + if (load_config.get_property(ov::intel_auto::enable_startup_fallback)) { + LOG_WARNING_TAG("Setting property ov::intel_auto::enable_startup_fallback to false for stateful model."); + load_config.set_property(ov::intel_auto::enable_startup_fallback(false)); + } + if (load_config.get_property(ov::intel_auto::enable_runtime_fallback)) { + LOG_WARNING_TAG("Setting property ov::intel_auto::enable_running_fallback to false for stateful model."); + load_config.set_property(ov::intel_auto::enable_runtime_fallback(false)); } - return false; }; + if (meta_devices.size() == 1) { + return meta_devices; + } + + std::vector filter_device; + std::vector stateful_node_names; + // Check if CPU is in candidate list auto cpuiter = std::find_if(meta_devices.begin(), meta_devices.end(), [](const DeviceInformation& device_info) { return device_info.device_name.find("CPU") != std::string::npos; }); - // If CPU is in candidate list, load dynamic model to CPU first // For MULTI do not only load stateful model to CPU // For AUTO CTPUT only load stateful model to CPU - if (((model->is_dynamic()) || (is_stateful() && get_device_name() != "MULTI")) && cpuiter != meta_devices.end()) { + if (model->is_dynamic() && cpuiter != meta_devices.end()) { filter_device.push_back(*cpuiter); return filter_device; } - // If CPU is not in candidate list, continue to run selection logic regardless of whether the input model is a // dynamic model or not - return meta_devices; + + for (auto& op : model->get_ops()) { + if (std::dynamic_pointer_cast(op) || + std::dynamic_pointer_cast(op)) { + stateful_node_names.push_back(op->get_friendly_name()); + } + } + if (stateful_node_names.empty()) { + // not stateful model + return meta_devices; + } + + // disable CPU_HELP and runtime fallback if model is stateful + disable_startup_runtime_fallback(); + + auto is_supported_stateful = [&](const std::string& device_name, const ov::AnyMap& config) { + auto device_qm = get_core()->query_model(model, device_name, config); + for (auto&& node_name : stateful_node_names) { + if (device_qm.find(node_name) == device_qm.end()) + return false; + } + return true; + }; + + for (auto& item : meta_devices) { + if (is_supported_stateful(item.device_name, item.config)) + filter_device.push_back(item); + } + bool isCumulative = (get_device_name() == "MULTI") || (load_config.get_property(ov::hint::performance_mode) == + ov::hint::PerformanceMode::CUMULATIVE_THROUGHPUT); + if (isCumulative) { + if (filter_device.empty() || filter_device.size() > 1) + OPENVINO_THROW("AUTO cumulative model doesn't support stateful model."); + else + return filter_device; + } + if (filter_device.empty()) { + return meta_devices; + } + return filter_device; } std::string Plugin::get_log_tag() const noexcept { diff --git a/src/plugins/auto/src/plugin.hpp b/src/plugins/auto/src/plugin.hpp index a41b11130843f0..47e7e85a9df571 100644 --- a/src/plugins/auto/src/plugin.hpp +++ b/src/plugins/auto/src/plugin.hpp @@ -78,7 +78,8 @@ class Plugin : public ov::IPlugin { std::vector filter_device(const std::vector& meta_devices, const ov::AnyMap& properties) const; std::vector filter_device_by_model(const std::vector& meta_devices, - const std::shared_ptr& model) const; + const std::shared_ptr& model, + PluginConfig& load_config) const; std::string get_log_tag() const noexcept; static std::mutex m_mtx; static std::map> m_priority_map; diff --git a/src/plugins/auto/src/plugin_config.cpp b/src/plugins/auto/src/plugin_config.cpp index 0f49680856d1a4..c8e32fc68c2f0c 100644 --- a/src/plugins/auto/src/plugin_config.cpp +++ b/src/plugins/auto/src/plugin_config.cpp @@ -21,6 +21,7 @@ void PluginConfig::set_default() { std::make_tuple(ov::hint::model_priority, ov::hint::Priority::MEDIUM), std::make_tuple(ov::log::level, ov::log::Level::NO), std::make_tuple(ov::intel_auto::device_bind_buffer, false), + std::make_tuple(ov::intel_auto::schedule_policy, ov::intel_auto::SchedulePolicy::DEVICE_PRIORITY), std::make_tuple(ov::hint::performance_mode, ov::hint::PerformanceMode::LATENCY), std::make_tuple(ov::hint::execution_mode, ov::hint::ExecutionMode::PERFORMANCE), std::make_tuple(ov::hint::num_requests, 0, UnsignedTypeValidator()), diff --git a/src/plugins/auto/tests/functional/CMakeLists.txt b/src/plugins/auto/tests/functional/CMakeLists.txt index b15afe68b96660..f905c1b61b327e 100644 --- a/src/plugins/auto/tests/functional/CMakeLists.txt +++ b/src/plugins/auto/tests/functional/CMakeLists.txt @@ -10,7 +10,7 @@ if(ENABLE_AUTO_BATCH) endif() if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") - ie_add_compiler_flags(/wd4305) + ov_add_compiler_flags(/wd4305) endif() ov_add_test_target( diff --git a/src/plugins/auto/tests/functional/behavior/infer_schedule_test.cpp b/src/plugins/auto/tests/functional/behavior/infer_schedule_test.cpp new file mode 100644 index 00000000000000..53004953d7f749 --- /dev/null +++ b/src/plugins/auto/tests/functional/behavior/infer_schedule_test.cpp @@ -0,0 +1,96 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "auto_func_test.hpp" + +namespace ov { +namespace auto_plugin { +namespace tests { +using schedule_policy_param = std::tuple; + +class InferSchedulePolicyTest : public AutoFuncTests, public testing::WithParamInterface { +public: + void SetUp() override { + AutoFuncTests::SetUp(); + std::tie(property, niters) = this->GetParam(); + } + static std::string getTestCaseName(const testing::TestParamInfo& obj) { + ov::AnyMap property; + int niters; + std::tie(property, niters) = obj.param; + std::ostringstream result; + result << "numberOfInfer=" << niters << "_"; + if (!property.empty()) { + for (auto& iter : property) { + result << "priority=" << iter.first << "_" << iter.second.as(); + } + } + return result.str(); + } + +public: + ov::AnyMap property; + int niters; +}; + +TEST_P(InferSchedulePolicyTest, can_run_async_requests_with_different_schedule_policy) { + ov::CompiledModel compiled_model; + property.emplace(ov::hint::performance_mode(ov::hint::PerformanceMode::CUMULATIVE_THROUGHPUT)); + ASSERT_NO_THROW(compiled_model = core.compile_model(model_cannot_batch, "AUTO", property)); + std::vector inferReqsQueue; + int count = niters; + while (count--) { + ov::InferRequest req; + ASSERT_NO_THROW(req = compiled_model.create_infer_request()); + inferReqsQueue.push_back(req); + } + for (auto& req : inferReqsQueue) { + ASSERT_NO_THROW(req.start_async()); + } + for (auto& req : inferReqsQueue) { + ASSERT_NO_THROW(req.wait()); + } +} + +TEST_P(InferSchedulePolicyTest, can_run_sync_requests_with_different_schedule_policy) { + ov::CompiledModel compiled_model; + property.emplace(ov::hint::performance_mode(ov::hint::PerformanceMode::CUMULATIVE_THROUGHPUT)); + ASSERT_NO_THROW(compiled_model = core.compile_model(model_cannot_batch, "AUTO", property)); + std::vector inferReqsQueue; + int count = niters; + while (count--) { + ov::InferRequest req; + ASSERT_NO_THROW(req = compiled_model.create_infer_request()); + inferReqsQueue.push_back(req); + } + for (auto& req : inferReqsQueue) { + ASSERT_NO_THROW(req.infer()); + ASSERT_NO_THROW(req.wait()); + } +} + +auto properties = std::vector{ + {ov::device::priorities("MOCK_GPU"), ov::intel_auto::schedule_policy(ov::intel_auto::SchedulePolicy::ROUND_ROBIN)}, + {ov::device::priorities("MOCK_GPU"), + ov::intel_auto::schedule_policy(ov::intel_auto::SchedulePolicy::DEVICE_PRIORITY)}, + {ov::device::priorities("MOCK_CPU"), ov::intel_auto::schedule_policy(ov::intel_auto::SchedulePolicy::ROUND_ROBIN)}, + {ov::device::priorities("MOCK_CPU"), + ov::intel_auto::schedule_policy(ov::intel_auto::SchedulePolicy::DEVICE_PRIORITY)}, + {ov::device::priorities("MOCK_GPU", "MOCK_CPU"), + ov::intel_auto::schedule_policy(ov::intel_auto::SchedulePolicy::ROUND_ROBIN)}, + {ov::device::priorities("MOCK_GPU", "MOCK_CPU"), + ov::intel_auto::schedule_policy(ov::intel_auto::SchedulePolicy::DEVICE_PRIORITY)}, + {ov::device::priorities("MOCK_CPU", "MOCK_GPU"), + ov::intel_auto::schedule_policy(ov::intel_auto::SchedulePolicy::ROUND_ROBIN)}}; +auto niters = std::vector{10, 20, 30}; + +INSTANTIATE_TEST_SUITE_P(AutoFuncTests, + InferSchedulePolicyTest, + ::testing::Combine(::testing::ValuesIn(properties), ::testing::ValuesIn(niters)), + InferSchedulePolicyTest::getTestCaseName); +} // namespace tests +} // namespace auto_plugin +} // namespace ov 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 39756244e9fdad..90cfa56407ca6f 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 @@ -80,13 +80,15 @@ INSTANTIATE_TEST_SUITE_P(smoke_AutoCompileModelBehaviorTests, ::testing::ValuesIn(auto_compileModel_properties)), OVSetPropComplieModleGetPropTests::getTestCaseName); -const std::vector default_properties = {{ov::enable_profiling(false)}, - {ov::log::level("LOG_NONE")}, - {ov::hint::model_priority(ov::hint::Priority::MEDIUM)}, - {ov::hint::execution_mode(ov::hint::ExecutionMode::PERFORMANCE)}, - {ov::intel_auto::device_bind_buffer(false)}, - {ov::intel_auto::enable_startup_fallback(true)}, - {ov::device::priorities("")}}; +const std::vector default_properties = { + {ov::enable_profiling(false)}, + {ov::log::level("LOG_NONE")}, + {ov::hint::model_priority(ov::hint::Priority::MEDIUM)}, + {ov::hint::execution_mode(ov::hint::ExecutionMode::PERFORMANCE)}, + {ov::intel_auto::device_bind_buffer(false)}, + {ov::intel_auto::enable_startup_fallback(true)}, + {ov::intel_auto::schedule_policy(ov::intel_auto::SchedulePolicy::DEVICE_PRIORITY)}, + {ov::device::priorities("")}}; INSTANTIATE_TEST_SUITE_P(smoke_AutoBehaviorTests, OVPropertiesDefaultTests, ::testing::Combine(::testing::Values(ov::test::utils::DEVICE_AUTO), diff --git a/src/plugins/auto/tests/unit/infer_request_schedule_policy_test.cpp b/src/plugins/auto/tests/unit/infer_request_schedule_policy_test.cpp new file mode 100644 index 00000000000000..70dc61ed9aff95 --- /dev/null +++ b/src/plugins/auto/tests/unit/infer_request_schedule_policy_test.cpp @@ -0,0 +1,142 @@ +// Copyright (C) 2018-2022 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// +#include +#include + +#include + +#include "async_infer_request.hpp" +#include "common.hpp" +#include "cumulative_schedule.hpp" +#include "openvino/runtime/auto/properties.hpp" +#include "plugin.hpp" +using ConfigParams = std::tuple, // device candidate list + ov::intel_auto::SchedulePolicy, // schedule policy + std::map, // number of infer request for each device + std::vector // the expected device where each of infer request comes from + >; +class MockCumuSchedule : public ov::auto_plugin::CumuSchedule, public ::testing::TestWithParam { +protected: + std::vector devicesInfo; + ov::intel_auto::SchedulePolicy schedulePolicy; + std::map numOfInferRequests; + std::vector expectedScheDevs; + +public: + static std::string getTestCaseName(testing::TestParamInfo obj) { + std::vector devicesInfo; + ov::intel_auto::SchedulePolicy schedulePolicy; + std::map numOfInferRequests; + std::vector expectedScheDevs; + std::tie(devicesInfo, schedulePolicy, numOfInferRequests, expectedScheDevs) = obj.param; + std::ostringstream result; + std::string candidateDevList; + result << "candaidateDeviceList_"; + for (auto dev : devicesInfo) + result << dev.device_name << "_"; + result << "schedulePolicy_" << schedulePolicy << "_"; + result << "inferRequestNumberOnEachDevice_"; + for (auto ninfer : numOfInferRequests) + result << ninfer.first << "_" << ninfer.second << "_"; + result << "expectedDeviceSelection_"; + for (auto dev : expectedScheDevs) + result << dev << "_"; + return result.str(); + } + + void TearDown() override { + devicesInfo.clear(); + numOfInferRequests.clear(); + expectedScheDevs.clear(); + m_context.reset(); + } + + void SetUp() override { + std::tie(devicesInfo, schedulePolicy, numOfInferRequests, expectedScheDevs) = GetParam(); + m_context = std::make_shared(); + m_context->m_schedule_policy = schedulePolicy; + } +}; + +TEST_P(MockCumuSchedule, scheduleInferRequestBasedOnSchedulePolicy) { + std::size_t deviceIndexWithInferReq = 0; + int expectedDevIndex = 0; + while (true) { + std::string actualSelectedDev; + ASSERT_NO_THROW(actualSelectedDev = schedule_to_next_device(devicesInfo, deviceIndexWithInferReq)); + if (numOfInferRequests[actualSelectedDev] > 0) { + EXPECT_EQ(actualSelectedDev, expectedScheDevs[expectedDevIndex++]); + // consume an available infer request on selected device + numOfInferRequests[actualSelectedDev]--; + } else { + // schecdule to next priority device + deviceIndexWithInferReq++; + if (deviceIndexWithInferReq >= devicesInfo.size()) { + // no available infer request on all of the devices + break; + } + } + } +} + +const std::vector metaDevicesWithSingleDev = { + {"DEVICE_0", {}, -1, "01", "DEVICE_0_01", 0}}; +const std::vector metaDevicesWithTwoDevs = { + {"DEVICE_0", {}, -1, "01", "DEVICE_0_01", 0}, + {"DEVICE_1", {}, -1, "01", "DEVICE_1_01", 1}}; +const std::vector metaDevices = {{"DEVICE_0", {}, -1, "01", "DEVICE_0_01", 0}, + {"DEVICE_1", {}, -1, "01", "DEVICE_1_01", 1}, + {"DEVICE_2", {}, -1, "01", "DEVICE_2_01", 2}}; +const std::vector configs = { + ConfigParams{ + metaDevicesWithSingleDev, // param[in]: device candidate list for AUTO plugin + ov::intel_auto::SchedulePolicy::ROUND_ROBIN, // param[in]: specified schedule policy + {{"DEVICE_0", 6}}, // param[in]: a map recorded the count of infer request on each hw device + {"DEVICE_0", + "DEVICE_0", + "DEVICE_0", + "DEVICE_0", + "DEVICE_0", + "DEVICE_0"}}, // param[output]: the expected device list where the next available infer request comes from + ConfigParams{metaDevicesWithSingleDev, + ov::intel_auto::SchedulePolicy::DEVICE_PRIORITY, + {{"DEVICE_0", 6}}, + {"DEVICE_0", "DEVICE_0", "DEVICE_0", "DEVICE_0", "DEVICE_0", "DEVICE_0"}}, + ConfigParams{metaDevicesWithTwoDevs, + ov::intel_auto::SchedulePolicy::ROUND_ROBIN, + {{"DEVICE_0", 3}, {"DEVICE_1", 2}}, + {"DEVICE_0", "DEVICE_1", "DEVICE_0", "DEVICE_1", "DEVICE_0"}}, + ConfigParams{metaDevicesWithTwoDevs, + ov::intel_auto::SchedulePolicy::DEVICE_PRIORITY, + {{"DEVICE_0", 3}, {"DEVICE_1", 2}}, + {"DEVICE_0", "DEVICE_0", "DEVICE_0", "DEVICE_1", "DEVICE_1"}}, + ConfigParams{metaDevicesWithTwoDevs, + ov::intel_auto::SchedulePolicy::DEVICE_PRIORITY, + {{"DEVICE_0", 2}, {"DEVICE_1", 3}}, + {"DEVICE_0", "DEVICE_0", "DEVICE_1", "DEVICE_1", "DEVICE_1"}}, + ConfigParams{metaDevices, + ov::intel_auto::SchedulePolicy::ROUND_ROBIN, + {{"DEVICE_0", 3}, {"DEVICE_1", 2}, {"DEVICE_2", 1}}, + {"DEVICE_0", "DEVICE_1", "DEVICE_2", "DEVICE_0", "DEVICE_1", "DEVICE_0"}}, + ConfigParams{metaDevices, + ov::intel_auto::SchedulePolicy::ROUND_ROBIN, + {{"DEVICE_0", 1}, {"DEVICE_1", 2}, {"DEVICE_2", 3}}, + {"DEVICE_0", "DEVICE_1", "DEVICE_2", "DEVICE_1", "DEVICE_2", "DEVICE_2"}}, + ConfigParams{metaDevices, + ov::intel_auto::SchedulePolicy::ROUND_ROBIN, + {{"DEVICE_0", 1}, {"DEVICE_1", 3}, {"DEVICE_2", 2}}, + {"DEVICE_0", "DEVICE_1", "DEVICE_2", "DEVICE_1", "DEVICE_2", "DEVICE_1"}}, + ConfigParams{metaDevices, + ov::intel_auto::SchedulePolicy::DEVICE_PRIORITY, + {{"DEVICE_0", 1}, {"DEVICE_1", 3}, {"DEVICE_2", 2}}, + {"DEVICE_0", "DEVICE_1", "DEVICE_1", "DEVICE_1", "DEVICE_2", "DEVICE_2"}}, + ConfigParams{metaDevices, + ov::intel_auto::SchedulePolicy::DEVICE_PRIORITY, + {{"DEVICE_0", 3}, {"DEVICE_1", 2}, {"DEVICE_2", 1}}, + {"DEVICE_0", "DEVICE_0", "DEVICE_0", "DEVICE_1", "DEVICE_1", "DEVICE_2"}}}; + +INSTANTIATE_TEST_SUITE_P(smoke_Auto_BehaviorTests, + MockCumuSchedule, + ::testing::ValuesIn(configs), + MockCumuSchedule::getTestCaseName); \ No newline at end of file diff --git a/src/plugins/auto/tests/unit/stateful_model_test.cpp b/src/plugins/auto/tests/unit/stateful_model_test.cpp new file mode 100644 index 00000000000000..8c4e8206b1c2e4 --- /dev/null +++ b/src/plugins/auto/tests/unit/stateful_model_test.cpp @@ -0,0 +1,415 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include +#include + +#include "include/auto_unit_test.hpp" +#include "openvino/opsets/opset11.hpp" + +using StatefulModelConfigParams = + std::tuple, // device and the flag if device supports stateful + bool, // is cumulative mode + std::vector> // expected compiling model times on each device + >; + +class StatefulModelSupportedTest : public tests::AutoTest, public ::testing::TestWithParam { +public: + std::shared_ptr create_dynamic_output_model(); + std::shared_ptr create_stateful_model(); + static std::string getTestCaseName(testing::TestParamInfo obj); + void SetUp() override; + +protected: + bool isDynamicModel; + bool isStatefulModel; + std::map isDevSupportStatefulMap; + std::vector> expectedCalledTimes; + bool isCumulative; + std::string devicesList; +}; + +std::string StatefulModelSupportedTest::getTestCaseName(testing::TestParamInfo obj) { + bool isDynamicModel; + bool isStatefulModel; + std::map isDevSupportStatefulMap; + std::vector> expectedCalledTimes; + bool isCumulative; + std::string devicesList; + + std::tie(devicesList, isDynamicModel, isStatefulModel, isDevSupportStatefulMap, isCumulative, expectedCalledTimes) = + obj.param; + std::ostringstream result; + result << "_devicesList_" << devicesList; + result << "_isDynamic_" << isDynamicModel; + result << "_isStatefulModel_" << isStatefulModel; + for (auto& item : isDevSupportStatefulMap) { + result << "_" << item.first << "_" << item.second; + } + result << "_isCumulative_" << isCumulative; + for (auto& item : expectedCalledTimes) { + result << "_calling_on_" << item.first << "_expected_times_" << item.second; + } + auto string = result.str(); + return string; +} + +std::shared_ptr StatefulModelSupportedTest::create_dynamic_output_model() { + auto boxes = std::make_shared(ov::element::f32, ov::Shape{1, 2, 4}); + boxes->set_friendly_name("param_1"); + boxes->get_output_tensor(0).set_names({"input_tensor_1"}); + auto scores = std::make_shared(ov::element::f32, ov::Shape{1, 1, 2}); + scores->set_friendly_name("param_2"); + scores->get_output_tensor(0).set_names({"input_tensor_2"}); + auto max_output_boxes_per_class = ov::op::v0::Constant::create(ov::element::i64, ov::Shape{}, {10}); + auto iou_threshold = ov::op::v0::Constant::create(ov::element::f32, ov::Shape{}, {0.75}); + auto score_threshold = ov::op::v0::Constant::create(ov::element::f32, ov::Shape{}, {0.7}); + auto nms = std::make_shared(boxes, + scores, + max_output_boxes_per_class, + iou_threshold, + score_threshold); + auto res = std::make_shared(nms); + res->set_friendly_name("output_dynamic"); + return std::make_shared(ov::NodeVector{nms}, ov::ParameterVector{boxes, scores}); +} + +std::shared_ptr StatefulModelSupportedTest::create_stateful_model() { + auto arg = std::make_shared(ov::element::f32, ov::Shape{1, 1}); + auto init_const = ov::opset11::Constant::create(ov::element::f32, ov::Shape{1, 1}, {0}); + // The ReadValue/Assign operations must be used in pairs in the model. + // For each such a pair, its own variable object must be created. + const std::string variable_name("variable0"); + // auto variable = std::make_shared( + // ov::op::util::VariableInfo{ov::PartialShape::dynamic(), ov::element::dynamic, variable_name}); + auto variable = std::make_shared( + ov::op::util::VariableInfo{init_const->get_shape(), ov::element::f32, variable_name}); + // Creating ov::Model + auto read = std::make_shared(init_const, variable); + std::vector> args = {arg, read}; + auto add = std::make_shared(arg, read); + add->set_friendly_name("add_sum"); + auto assign = std::make_shared(add, variable); + assign->set_friendly_name("save"); + auto res = std::make_shared(add); + res->set_friendly_name("res"); + + auto model = + std::make_shared(ov::ResultVector({res}), ov::SinkVector({assign}), ov::ParameterVector({arg})); + + return model; +} + +void StatefulModelSupportedTest::SetUp() { + std::tie(devicesList, isDynamicModel, isStatefulModel, isDevSupportStatefulMap, isCumulative, expectedCalledTimes) = + GetParam(); + if (isDynamicModel) { + model = create_dynamic_output_model(); + } else if (isStatefulModel) { + model = create_stateful_model(); + } + + std::map devicesSupportedLayers; + for (auto& item : isDevSupportStatefulMap) { + ov::SupportedOpsMap res; + auto deviceName = item.first; + auto isSupportStateful = item.second; + std::unordered_set device_supported_layers; + for (auto& op : model->get_ops()) { + if (!std::dynamic_pointer_cast(op) && + !std::dynamic_pointer_cast(op)) { + res[op->get_friendly_name()] = deviceName; + continue; + } + if (isSupportStateful) { + res[op->get_friendly_name()] = deviceName; + } + } + devicesSupportedLayers[deviceName] = res; + } + + for (auto& item : devicesSupportedLayers) { + ON_CALL(*core, + query_model(::testing::Matcher&>(_), + ::testing::Matcher(StrEq(item.first)), + _)) + .WillByDefault(Return(item.second)); + } + + ON_CALL(*core, + compile_model(::testing::Matcher&>(_), + ::testing::Matcher(StrEq(ov::test::utils::DEVICE_CPU)), + (_))) + .WillByDefault(Return(mockExeNetwork)); + + ON_CALL(*core, + compile_model(::testing::Matcher&>(_), + ::testing::Matcher(StrEq(ov::test::utils::DEVICE_GPU)), + (_))) + .WillByDefault(Return(mockExeNetworkActual)); + if (isCumulative) + plugin->set_device_name("MULTI"); + else + plugin->set_device_name("AUTO"); +} + +TEST_P(StatefulModelSupportedTest, CanFilterOutCorrectTargetDeviceWithStatefulModel) { + metaDevices.clear(); + int priority = 0; + for (auto& item : expectedCalledTimes) { + auto deviceName = item.first; + auto times = item.second; + DeviceInformation devInfo(deviceName, {}, -1, {}, deviceName, priority++); + metaDevices.push_back(devInfo); + if (times >= 0) { + EXPECT_CALL(*core, + compile_model(::testing::Matcher&>(_), + ::testing::Matcher(StrEq(deviceName)), + ::testing::Matcher(_))) + .Times(times); + } + } + int expectedTimes = expectedCalledTimes.begin()->second; + ov::AnyMap config = {}; + + if (!devicesList.empty()) + config.insert(ov::device::priorities(devicesList)); + + ON_CALL(*plugin, parse_meta_devices(_, _)).WillByDefault(Return(metaDevices)); + ON_CALL(*plugin, get_valid_device) + .WillByDefault([](const std::vector& metaDevices, const std::string& netPrecision) { + std::list devices(metaDevices.begin(), metaDevices.end()); + return devices; + }); + + config.insert(ov::intel_auto::enable_runtime_fallback(false)); + if (isCumulative) { + config.insert(ov::hint::performance_mode(ov::hint::PerformanceMode::CUMULATIVE_THROUGHPUT)); + } + if (expectedTimes < 0) { + ASSERT_THROW(plugin->compile_model(model, config), ov::Exception); + } else { + ASSERT_NO_THROW(plugin->compile_model(model, config)); + } +} + +const std::vector testConfigs = { + // test cases for dynamic model + StatefulModelConfigParams{ + "CPU", // device candidate list is CPU + true, // model is dynamic model + true, // model is stateful model + std::map{{"CPU", true}}, // device CPU supports stateful model + true, // performance mode is cumulative mode + std::vector>{{"CPU", 1}}}, // expected compiling model count is 1 on device CPU + StatefulModelConfigParams{"CPU", + true, + false, + std::map{{"CPU", true}}, + true, + std::vector>{{"CPU", 1}}}, + StatefulModelConfigParams{"CPU", + true, + true, + std::map{{"CPU", false}}, + true, + std::vector>{{"CPU", 1}}}, + StatefulModelConfigParams{"CPU", + true, + true, + std::map{{"CPU", true}}, + false, + std::vector>{{"CPU", 1}}}, + StatefulModelConfigParams{"CPU", + true, + true, + std::map{{"CPU", false}}, + false, + std::vector>{{"CPU", 1}}}, + + StatefulModelConfigParams{"GPU", + true, + false, + std::map{{"GPU", true}}, + true, + std::vector>{{"GPU", 1}}}, + StatefulModelConfigParams{"GPU", + true, + false, + std::map{{"GPU", false}}, + true, + std::vector>{{"GPU", 1}}}, + StatefulModelConfigParams{"GPU", + true, + false, + std::map{{"GPU", true}}, + false, + std::vector>{{"GPU", 1}}}, + + StatefulModelConfigParams{"CPU,GPU", + true, + true, + std::map{{"CPU", true}, {"GPU", true}}, + true, + std::vector>{{"CPU", 1}, {"GPU", 0}}}, + StatefulModelConfigParams{"GPU,CPU", + true, + true, + std::map{{"CPU", true}, {"GPU", true}}, + true, + std::vector>{{"GPU", 0}, {"CPU", 1}}}, + StatefulModelConfigParams{"CPU,GPU", + true, + false, + std::map{{"CPU", true}, {"GPU", true}}, + true, + std::vector>{{"CPU", 1}, {"GPU", 0}}}, + StatefulModelConfigParams{"GPU,CPU", + true, + false, + std::map{{"CPU", true}, {"GPU", true}}, + true, + std::vector>{{"GPU", 0}, {"CPU", 1}}}, + StatefulModelConfigParams{"CPU", + false, + false, + std::map{{"CPU", true}, {"GPU", true}}, + true, + std::vector>{{"CPU", 1}}}, + StatefulModelConfigParams{"CPU", + false, + false, + std::map{{"CPU", false}, {"GPU", true}}, + false, + std::vector>{{"CPU", 1}}}, + StatefulModelConfigParams{"GPU", + false, + false, + std::map{{"CPU", true}, {"GPU", true}}, + true, + std::vector>{{"GPU", 1}}}, + StatefulModelConfigParams{"GPU", + false, + false, + std::map{{"CPU", false}, {"GPU", true}}, + false, + std::vector>{{"GPU", 1}}}, + StatefulModelConfigParams{"CPU,GPU", + false, + false, + std::map{{"CPU", false}, {"GPU", true}}, + false, + std::vector>{{"CPU", 1}, {"GPU", 0}}}, + StatefulModelConfigParams{"CPU,GPU", + false, + false, + std::map{{"CPU", false}, {"GPU", true}}, + true, + std::vector>{{"CPU", 1}, {"GPU", 1}}}, + StatefulModelConfigParams{"GPU,CPU", + false, + false, + std::map{{"CPU", false}, {"GPU", true}}, + false, + std::vector>{{"GPU", 1}, {"CPU", 1}}}, + StatefulModelConfigParams{"GPU,CPU", + false, + false, + std::map{{"CPU", false}, {"GPU", true}}, + true, + std::vector>{{"GPU", 1}, {"CPU", 1}}}, + StatefulModelConfigParams{"CPU", + false, + true, + std::map{{"CPU", false}, {"GPU", true}}, + true, + std::vector>{{"CPU", 1}}}, + StatefulModelConfigParams{"CPU", + false, + true, + std::map{{"CPU", false}, {"GPU", true}}, + false, + std::vector>{{"CPU", 1}}}, + StatefulModelConfigParams{"CPU", + false, + true, + std::map{{"CPU", true}, {"GPU", false}}, + false, + std::vector>{{"CPU", 1}}}, + StatefulModelConfigParams{"GPU", + false, + true, + std::map{{"CPU", true}, {"GPU", false}}, + true, + std::vector>{{"GPU", 1}}}, + StatefulModelConfigParams{"GPU", + false, + true, + std::map{{"CPU", false}, {"GPU", true}}, + true, + std::vector>{{"GPU", 1}}}, + StatefulModelConfigParams{"GPU", + false, + true, + std::map{{"CPU", false}, {"GPU", true}}, + false, + std::vector>{{"GPU", 1}}}, + StatefulModelConfigParams{"CPU,GPU", + false, + true, + std::map{{"CPU", true}, {"GPU", false}}, + false, + std::vector>{{"CPU", 1}, {"GPU", 0}}}, + StatefulModelConfigParams{"CPU,GPU", + false, + true, + std::map{{"CPU", false}, {"GPU", true}}, + false, + std::vector>{{"GPU", 1}, {"CPU", 0}}}, + StatefulModelConfigParams{"CPU,GPU", + false, + true, + std::map{{"CPU", true}, {"GPU", true}}, + false, + std::vector>{{"GPU", 1}, {"CPU", 0}}}, + StatefulModelConfigParams{"CPU,GPU", + false, + true, + std::map{{"CPU", false}, {"GPU", false}}, + false, + std::vector>{{"GPU", 1}, {"CPU", 0}}}, + + StatefulModelConfigParams{"CPU,GPU", + false, + true, + std::map{{"CPU", true}, {"GPU", false}}, + true, + std::vector>{{"GPU", 0}, {"CPU", 1}}}, + StatefulModelConfigParams{"CPU,GPU", + false, + true, + std::map{{"CPU", false}, {"GPU", true}}, + true, + std::vector>{{"GPU", 1}, {"CPU", 0}}}, + StatefulModelConfigParams{"CPU,GPU", + false, + true, + std::map{{"CPU", true}, {"GPU", true}}, + true, + std::vector>{{"GPU", -1}, {"CPU", -1}}}, + StatefulModelConfigParams{"CPU,GPU", + false, + true, + std::map{{"CPU", false}, {"GPU", false}}, + true, + std::vector>{{"GPU", -1}, {"CPU", -1}}}, +}; + +INSTANTIATE_TEST_SUITE_P(smoke_Auto_BehaviorTests, + StatefulModelSupportedTest, + ::testing::ValuesIn(testConfigs), + StatefulModelSupportedTest::getTestCaseName); diff --git a/src/plugins/auto_batch/CMakeLists.txt b/src/plugins/auto_batch/CMakeLists.txt index 9ff585740abc98..a8419940ff4c6c 100644 --- a/src/plugins/auto_batch/CMakeLists.txt +++ b/src/plugins/auto_batch/CMakeLists.txt @@ -9,7 +9,6 @@ endif() set(TARGET_NAME "openvino_auto_batch_plugin") file(GLOB SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp) - file(GLOB HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/src/*.hpp) ov_add_plugin(NAME ${TARGET_NAME} @@ -18,6 +17,9 @@ ov_add_plugin(NAME ${TARGET_NAME} SOURCES ${SOURCES} ${HEADERS} VERSION_DEFINES_FOR src/plugin.cpp ADD_CLANG_FORMAT) +find_package(Threads REQUIRED) +target_link_libraries(${TARGET_NAME} PRIVATE Threads::Threads) + ov_set_threading_interface_for(${TARGET_NAME}) # must be called after all target_link_libraries diff --git a/src/plugins/intel_cpu/CMakeLists.txt b/src/plugins/intel_cpu/CMakeLists.txt index d65c8661fcef0d..efa25c321f9b1c 100644 --- a/src/plugins/intel_cpu/CMakeLists.txt +++ b/src/plugins/intel_cpu/CMakeLists.txt @@ -161,23 +161,16 @@ cross_compiled_file(${TARGET_NAME} ) cross_compiled_file(${TARGET_NAME} ARCH AVX512F AVX2 ANY - src/nodes/kernels/scaled_attn/dot_product.cpp - API src/nodes/kernels/scaled_attn/dot_product.hpp - NAME attn_dot_products + src/nodes/kernels/scaled_attn/mha_single_token.cpp + API src/nodes/kernels/scaled_attn/mha_single_token.hpp + NAME mha_single_token NAMESPACE InferenceEngine::Extensions::Cpu::XARCH ) cross_compiled_file(${TARGET_NAME} ARCH AVX512F AVX2 ANY - src/nodes/kernels/scaled_attn/acc_value.cpp - API src/nodes/kernels/scaled_attn/acc_value.hpp - NAME attn_acc_values - NAMESPACE InferenceEngine::Extensions::Cpu::XARCH -) -cross_compiled_file(${TARGET_NAME} - ARCH AVX512F AVX2 ANY - src/nodes/kernels/scaled_attn/reduce.cpp - API src/nodes/kernels/scaled_attn/reduce.hpp - NAME attn_reduce + src/nodes/kernels/scaled_attn/attn_memcpy.cpp + API src/nodes/kernels/scaled_attn/attn_memcpy.hpp + NAME attn_memcpy NAMESPACE InferenceEngine::Extensions::Cpu::XARCH ) # system dependencies must go last diff --git a/src/plugins/intel_cpu/src/compiled_model.cpp b/src/plugins/intel_cpu/src/compiled_model.cpp index 8b33f6ca75faef..c19bee36c5d354 100644 --- a/src/plugins/intel_cpu/src/compiled_model.cpp +++ b/src/plugins/intel_cpu/src/compiled_model.cpp @@ -247,7 +247,7 @@ ov::Any CompiledModel::get_property(const std::string& name) const { } else if (name == ov::optimal_number_of_infer_requests) { const auto streams = config.streamExecutorConfig._streams; return decltype(ov::optimal_number_of_infer_requests)::value_type( - streams); // ov::optimal_number_of_infer_requests has no negative values + 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; return decltype(ov::num_streams)::value_type( diff --git a/src/plugins/intel_cpu/src/config.cpp b/src/plugins/intel_cpu/src/config.cpp index df2304c50e8583..53b2779936b7b3 100644 --- a/src/plugins/intel_cpu/src/config.cpp +++ b/src/plugins/intel_cpu/src/config.cpp @@ -378,8 +378,6 @@ void Config::updateProperties() { _config.insert({ov::device::id.name(), device_id}); - _config.insert({ov::num_streams.name(), std::to_string(streamExecutorConfig._streams)}); - _config.insert({ov::inference_num_threads.name(), std::to_string(streamExecutorConfig._threads)}); _config.insert({ov::hint::performance_mode.name(), ov::util::to_string(hintPerfMode)}); _config.insert({ov::hint::num_requests.name(), std::to_string(hintNumRequests)}); diff --git a/src/plugins/intel_cpu/src/cpu_streams_calculation.cpp b/src/plugins/intel_cpu/src/cpu_streams_calculation.cpp index 0d22db1546118e..ea8ba981dc1992 100644 --- a/src/plugins/intel_cpu/src/cpu_streams_calculation.cpp +++ b/src/plugins/intel_cpu/src/cpu_streams_calculation.cpp @@ -146,68 +146,62 @@ 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)) && - ((latencyThreadingMode == Config::LatencyThreadingMode::PER_PLATFORM) || (proc_type_table.size() == 1))) || + (input_perf_hint == ov::util::to_string(ov::hint::PerformanceMode::LATENCY))) || ((input_streams_changed == true) && (input_streams == 1))) { - n_streams = 1; - if ((proc_type_table.size() == 1) && (input_threads == 0) && (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; - n_threads_per_stream = proc_type_table[0][MAIN_CORE_PROC] + proc_type_table[0][HYPER_THREADING_PROC]; - stream_info[THREADS_PER_STREAM] = n_threads_per_stream; - update_ids_method(proc_type_table[0]); - } else if (proc_type_table[0][MAIN_CORE_PROC] == 0) { - stream_info[PROC_TYPE] = EFFICIENT_CORE_PROC; - n_threads_per_stream = proc_type_table[0][EFFICIENT_CORE_PROC]; - stream_info[THREADS_PER_STREAM] = n_threads_per_stream; - update_ids_method(proc_type_table[0]); + 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 if (((input_streams_changed == false) && + (latencyThreadingMode == Config::LatencyThreadingMode::PER_PLATFORM)) || + (proc_type_table.size() == 1) || ((input_streams_changed == true) && (input_streams == 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; + n_threads_per_stream = + proc_type_table[0][MAIN_CORE_PROC] + proc_type_table[0][HYPER_THREADING_PROC]; + stream_info[THREADS_PER_STREAM] = n_threads_per_stream; + update_ids_method(proc_type_table[0]); + } else if (proc_type_table[0][MAIN_CORE_PROC] == 0) { + stream_info[PROC_TYPE] = EFFICIENT_CORE_PROC; + n_threads_per_stream = proc_type_table[0][EFFICIENT_CORE_PROC]; + stream_info[THREADS_PER_STREAM] = n_threads_per_stream; + update_ids_method(proc_type_table[0]); + } else { + stream_info[PROC_TYPE] = ALL_PROC; + n_threads_per_stream = proc_type_table[0][ALL_PROC]; + } } else { - stream_info[PROC_TYPE] = ALL_PROC; n_threads_per_stream = proc_type_table[0][ALL_PROC]; } - } else { - n_threads_per_stream = input_threads > 0 ? std::min(input_threads, proc_type_table[0][ALL_PROC]) - : proc_type_table[0][ALL_PROC]; - if ((proc_type_table.size() == 1) && (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 if ((input_streams_changed == false) && + (latencyThreadingMode == Config::LatencyThreadingMode::PER_SOCKET)) { + for (auto& row : proc_socket_table) { + n_threads_per_stream = std::max(n_threads_per_stream, row[ALL_PROC]); } - } - } else if ((input_streams_changed == false) && - (input_perf_hint == ov::util::to_string(ov::hint::PerformanceMode::LATENCY)) && - (latencyThreadingMode == Config::LatencyThreadingMode::PER_SOCKET)) { - for (auto& row : proc_socket_table) { - n_threads_per_stream = std::max(n_threads_per_stream, row[ALL_PROC]); - } - n_threads_per_stream = input_threads > 0 ? std::min(input_threads, n_threads_per_stream) : n_threads_per_stream; - for (auto& row : proc_socket_table) { - if (n_threads_per_stream <= row[ALL_PROC]) { - n_streams++; + for (auto& row : proc_socket_table) { + if (n_threads_per_stream <= row[ALL_PROC]) { + n_streams++; + } } - } - n_streams = input_threads > 0 ? static_cast(input_threads / n_threads_per_stream) : n_streams; - n_streams = input_infer_requests > 0 ? std::min(input_infer_requests, n_streams) : n_streams; - } else if ((input_streams_changed == false) && - (input_perf_hint == ov::util::to_string(ov::hint::PerformanceMode::LATENCY)) && - (latencyThreadingMode == Config::LatencyThreadingMode::PER_NUMA_NODE)) { - if (proc_type_table.size() == 1) { - n_streams = 1; - n_threads_per_stream = input_threads > 0 ? std::min(input_threads, proc_type_table[0][ALL_PROC]) - : proc_type_table[0][ALL_PROC]; + n_streams = input_infer_requests > 0 ? std::min(input_infer_requests, n_streams) : n_streams; } else { 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]); } - n_threads_per_stream = - input_threads > 0 ? std::min(input_threads, n_threads_per_stream) : n_threads_per_stream; for (size_t i = 1; i < proc_type_table.size(); i++) { if (n_threads_per_stream <= proc_type_table[i][ALL_PROC]) { n_streams++; } } - n_streams = input_threads > 0 ? static_cast(input_threads / n_threads_per_stream) : n_streams; n_streams = input_infer_requests > 0 ? std::min(input_infer_requests, n_streams) : n_streams; } } else { @@ -305,35 +299,20 @@ std::vector> get_streams_info_table(const int input_streams, } } - if (total_streams == n_streams) { + if ((total_streams == n_streams) && (input_threads == 0)) { 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); n_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][ALL_PROC] >= stream_info[THREADS_PER_STREAM]) { - update_mix_stream_info(proc_type_table[n_node], proc_type_table); + 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); n_streams--; } } } - 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); - n_streams--; - } - } - } - - if (total_streams == n_streams) { - 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); - n_streams--; - } - } } if (total_streams == n_streams) { @@ -389,7 +368,7 @@ std::vector> get_streams_info_table(const int input_streams, } } else { if (stream_info[PROC_TYPE] == ALL_PROC) { - update_mix_stream_info(proc_socket_table[0], proc_type_table); + update_mix_stream_info(proc_type_table[0], proc_type_table); } 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); diff --git a/src/plugins/intel_cpu/src/cpu_types.cpp b/src/plugins/intel_cpu/src/cpu_types.cpp index f897ca808c1d1f..0175519b87a8e3 100644 --- a/src/plugins/intel_cpu/src/cpu_types.cpp +++ b/src/plugins/intel_cpu/src/cpu_types.cpp @@ -205,6 +205,7 @@ static const TypeToNameMap& get_type_to_name_tbl() { { "MatrixNms", Type::MatrixNms}, { "MulticlassNms", Type::MulticlassNms}, { "MulticlassNmsIEInternal", Type::MulticlassNms}, + { "Multinomial", Type::Multinomial}, { "Reference", Type::Reference}, { "Subgraph", Type::Subgraph}, { "PriorBox", Type::PriorBox}, @@ -214,7 +215,7 @@ static const TypeToNameMap& get_type_to_name_tbl() { { "Unique", Type::Unique}, { "Ngram", Type::Ngram}, { "ScaledDotProductAttention", Type::ScaledDotProductAttention}, - { "ScaledDotProductAttentionStub", Type::ScaledDotProductAttention}, + { "ScaledDotProductAttentionWithKVCache", Type::ScaledDotProductAttention}, { "RoPE", Type::RoPE}, }; return type_to_name_tbl; @@ -321,6 +322,7 @@ std::string NameFromType(const Type type) { CASE(NonMaxSuppression); CASE(MatrixNms); CASE(MulticlassNms); + CASE(Multinomial); CASE(Reference); CASE(Subgraph); CASE(PriorBox); diff --git a/src/plugins/intel_cpu/src/cpu_types.h b/src/plugins/intel_cpu/src/cpu_types.h index cf214542b1b604..6348f03b74ccd0 100644 --- a/src/plugins/intel_cpu/src/cpu_types.h +++ b/src/plugins/intel_cpu/src/cpu_types.h @@ -4,10 +4,10 @@ #pragma once -#include "caseless.hpp" - -#include #include +#include + +#include "caseless.hpp" namespace ov { namespace intel_cpu { @@ -105,6 +105,7 @@ enum class Type { NonMaxSuppression, MatrixNms, MulticlassNms, + Multinomial, Subgraph, PriorBox, PriorBoxClustered, @@ -262,5 +263,5 @@ std::string NameFromType(const Type type); std::string algToString(const Algorithm alg); -} // namespace intel_cpu -} // namespace ov +} // namespace intel_cpu +} // namespace ov diff --git a/src/plugins/intel_cpu/src/dnnl_extension_utils.cpp b/src/plugins/intel_cpu/src/dnnl_extension_utils.cpp index 5e8536f8acc31c..04238e7eb5fd58 100644 --- a/src/plugins/intel_cpu/src/dnnl_extension_utils.cpp +++ b/src/plugins/intel_cpu/src/dnnl_extension_utils.cpp @@ -68,7 +68,7 @@ dnnl::memory::data_type DnnlExtensionUtils::ElementTypeToDataType(const ov::elem case ov::element::undefined: return memory::data_type::undef; default: { - OPENVINO_THROW("The plugin does not support ", elementType.to_string(), " for use with oneDNN"); + OPENVINO_THROW("CPU plugin does not support ", elementType.to_string(), " for use with oneDNN."); } } } diff --git a/src/plugins/intel_cpu/src/emitters/x64/cpu_generator.cpp b/src/plugins/intel_cpu/src/emitters/x64/cpu_generator.cpp index c1d3e9d1bd1cff..7596c8117ab19a 100644 --- a/src/plugins/intel_cpu/src/emitters/x64/cpu_generator.cpp +++ b/src/plugins/intel_cpu/src/emitters/x64/cpu_generator.cpp @@ -14,12 +14,15 @@ #include "jit_dnnl_emitters.hpp" #include "jit_dnnl_ext_emitters.hpp" #include "jit_conversion_emitters.hpp" +#include "jit_perf_count_chrono_emitters.hpp" +#include "jit_perf_count_rdtsc_emitters.hpp" #include "transformations/snippets/x64/op/load_convert.hpp" #include "transformations/snippets/x64/op/store_convert.hpp" #include "transformations/snippets/x64/op/fused_mul_add.hpp" #include "transformations/snippets/x64/op/brgemm_copy_b.hpp" #include "transformations/snippets/x64/op/brgemm_cpu.hpp" +#include "transformations/snippets/x64/op/perf_count_rdtsc.hpp" #include "transformations/cpu_opset/common/op/swish_cpu.hpp" #include "transformations/snippets/x64/pass/lowered/fuse_load_store_and_convert.hpp" @@ -63,7 +66,8 @@ intel_cpu::CPUTargetMachine::CPUTargetMachine(dnnl::impl::cpu::x64::cpu_isa_t ho // data movement jitters[op::v0::Parameter::get_type_info_static()] = CREATE_SNIPPETS_EMITTER(NopEmitter); jitters[op::v0::Result::get_type_info_static()] = CREATE_SNIPPETS_EMITTER(NopEmitter); - jitters[snippets::op::Buffer::get_type_info_static()] = CREATE_SNIPPETS_EMITTER(NopEmitter); + jitters[snippets::op::IntermediateMemoryBuffer::get_type_info_static()] = CREATE_SNIPPETS_EMITTER(NopEmitter); + jitters[snippets::op::NewMemoryBuffer::get_type_info_static()] = CREATE_SNIPPETS_EMITTER(NopEmitter); jitters[snippets::op::VectorBuffer::get_type_info_static()] = CREATE_SNIPPETS_EMITTER(NopEmitter); jitters[snippets::op::RankNormalization::get_type_info_static()] = CREATE_SNIPPETS_EMITTER(NopEmitter); // jitters[op::v1::Constant::get_type_info_static()] = CREATE_CPU_EMITTER(); // Not supported @@ -157,6 +161,11 @@ intel_cpu::CPUTargetMachine::CPUTargetMachine(dnnl::impl::cpu::x64::cpu_isa_t ho jitters[snippets::op::LoopEnd::get_type_info_static()] = CREATE_SNIPPETS_EMITTER(LoopEndEmitter); jitters[intel_cpu::BrgemmCPU::get_type_info_static()] = CREATE_SNIPPETS_EMITTER(BrgemmEmitter); jitters[intel_cpu::BrgemmCopyB::get_type_info_static()] = CREATE_SNIPPETS_EMITTER(BrgemmCopyBEmitter); + + jitters[snippets::op::PerfCountBegin::get_type_info_static()] = CREATE_CPU_EMITTER(ov::intel_cpu::jit_perf_count_chrono_start_emitter); + jitters[snippets::op::PerfCountEnd::get_type_info_static()] = CREATE_CPU_EMITTER(ov::intel_cpu::jit_perf_count_chrono_end_emitter); + jitters[ov::intel_cpu::PerfCountRdtscBegin::get_type_info_static()] = CREATE_CPU_EMITTER(ov::intel_cpu::jit_perf_count_rdtsc_start_emitter); + jitters[ov::intel_cpu::PerfCountRdtscEnd::get_type_info_static()] = CREATE_CPU_EMITTER(ov::intel_cpu::jit_perf_count_rdtsc_end_emitter); } size_t intel_cpu::CPUTargetMachine::get_lanes() const { @@ -224,6 +233,10 @@ snippets::Generator::opRegType intel_cpu::CPUGenerator::get_specific_op_reg_type } bool intel_cpu::CPUGenerator::uses_precompiled_kernel(const std::shared_ptr& e) const { return std::dynamic_pointer_cast(e) || - std::dynamic_pointer_cast(e); + std::dynamic_pointer_cast(e) || + std::dynamic_pointer_cast(e) || + std::dynamic_pointer_cast(e) || + std::dynamic_pointer_cast(e) || + std::dynamic_pointer_cast(e); } -} // namespace ov \ No newline at end of file +} // namespace ov diff --git a/src/plugins/intel_cpu/src/emitters/x64/jit_emitter.cpp b/src/plugins/intel_cpu/src/emitters/x64/jit_emitter.cpp index f9885daa0f6dc0..dbaafdde8124cc 100644 --- a/src/plugins/intel_cpu/src/emitters/x64/jit_emitter.cpp +++ b/src/plugins/intel_cpu/src/emitters/x64/jit_emitter.cpp @@ -213,5 +213,73 @@ void jit_emitter::emit_code(const std::vector &in_idxs, const std::vecto emitter_postamble(); } +void jit_emitter::internal_call_preamble() const { + // gprs + Xbyak::Operand gprs_to_save[] = {h->r8, h->r9, h->r10, h->r11, h->r12, h->r13, h->r14, h->r15, + h->rax, h->rbx, h->rcx, h->rdx, h->rdi, h->rsi, h->rbp}; + size_t n_gprs_to_save = sizeof(gprs_to_save) / sizeof(gprs_to_save[0]); + + h->sub(h->rsp, n_gprs_to_save * gpr_size); + for (size_t i = 0; i < n_gprs_to_save; ++i) + h->mov(h->ptr[h->rsp + i * gpr_size], gprs_to_save[i]); + + // mask regs + // need preserve based on cpu capability, instead of host isa. + // in case there are possibilty that different isa emitters exist in one subgraph KernelEmitter from perf standpoint in the future. + // e.g. other emitters isa is avx512, while this emitter isa is avx2, and internal call is used. Internal call may use avx512 and spoil k-reg. + // do not care about platform w/ avx512_common but w/o avx512_core(knight landing), which is obsoleted. + if (dnnl::impl::cpu::x64::mayiuse(dnnl::impl::cpu::x64::avx512_core)) { + h->sub(h->rsp, k_mask_num * k_mask_size); + for (size_t i = 0; i < k_mask_num; ++i) { + h->kmovq(h->ptr[h->rsp + i * k_mask_size], Xbyak::Opmask(static_cast(i))); + } + } + + // vector regs + // 1. Caller obligation to save vector registers as callee may use them. + // 2. There is an implicit assumption that the host code uses the same + // `isa` as the injector. Once the assumption is wrong, `vecs_count` and + // `vlen` should be replaced with `host_isa::vlen` and + // `host_isa::vecs_count`. + h->sub(h->rsp, get_max_vecs_count() * get_vec_length()); + for (size_t i = 0; i < get_max_vecs_count(); ++i) { + push_vec(h->ptr[h->rsp + i * get_vec_length()], i); + } +} + +void jit_emitter::internal_call_postamble() const { + // restore vector registers + for (int i = static_cast(get_max_vecs_count()) - 1; i >= 0; --i) { + pop_vec(static_cast(i), h->ptr[h->rsp + i * get_vec_length()]); + } + h->add(h->rsp, (get_max_vecs_count()) * get_vec_length()); + + // restore k reg + if (dnnl::impl::cpu::x64::mayiuse(dnnl::impl::cpu::x64::avx512_core)) { + for (int i = k_mask_num - 1; i >= 0; --i) { + h->kmovq(Xbyak::Opmask(i), h->ptr[h->rsp + i * k_mask_size]); + } + h->add(h->rsp, k_mask_num * k_mask_size); + } + + // restore gpr registers + Xbyak::Operand gprs_to_save[] = {h->r8, h->r9, h->r10, h->r11, h->r12, h->r13, h->r14, h->r15, + h->rax, h->rbx, h->rcx, h->rdx, h->rdi, h->rsi, h->rbp}; + size_t n_gprs_to_save = sizeof(gprs_to_save) / sizeof(gprs_to_save[0]); + for (int i = n_gprs_to_save - 1; i >= 0; --i) + h->mov(gprs_to_save[i], h->ptr[h->rsp + i * gpr_size]); + h->add(h->rsp, n_gprs_to_save * gpr_size); +} + +void jit_emitter::internal_call_rsp_align() const { + h->mov(h->rbx, h->rsp); + h->and_(h->rbx, 0xf); + h->sub(h->rsp, h->rbx); +} + +void jit_emitter::internal_call_rsp_restore() const { + h->add(h->rsp, h->rbx); +} + } // namespace intel_cpu } // namespace ov diff --git a/src/plugins/intel_cpu/src/emitters/x64/jit_emitter.hpp b/src/plugins/intel_cpu/src/emitters/x64/jit_emitter.hpp index c10adb19f9ee58..66f681265b9fd9 100644 --- a/src/plugins/intel_cpu/src/emitters/x64/jit_emitter.hpp +++ b/src/plugins/intel_cpu/src/emitters/x64/jit_emitter.hpp @@ -106,6 +106,8 @@ class jit_emitter : public ov::snippets::Emitter { mutable std::vector aux_gpr_idxs; static constexpr int k_mask_size = 8; + static constexpr int k_mask_num = 8; + static constexpr int gpr_size = 8; Xbyak::Address table_val(std::string key, size_t key_off_val_shift = 0) const { auto off = table_off(key, key_off_val_shift); @@ -130,6 +132,13 @@ class jit_emitter : public ov::snippets::Emitter { } } + void internal_call_preamble() const; + void internal_call_postamble() const; + // align stack on 16-byte as ABI reqiures + // callee is responsible to save and restore rbx. rbx must not be changed after call callee. + void internal_call_rsp_align() const; + void internal_call_rsp_restore() const; + private: mutable std::vector preserved_vec_idxs; mutable std::vector preserved_gpr_idxs; diff --git a/src/plugins/intel_cpu/src/emitters/x64/jit_perf_count_chrono_emitters.cpp b/src/plugins/intel_cpu/src/emitters/x64/jit_perf_count_chrono_emitters.cpp new file mode 100644 index 00000000000000..a94535dfbcbd55 --- /dev/null +++ b/src/plugins/intel_cpu/src/emitters/x64/jit_perf_count_chrono_emitters.cpp @@ -0,0 +1,73 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "jit_emitter.hpp" +#include "jit_perf_count_chrono_emitters.hpp" +#include + +using namespace dnnl::impl; +using namespace dnnl::impl::utils; +using namespace dnnl::impl::cpu; +using namespace dnnl::impl::cpu::x64; +using namespace Xbyak; +using namespace Xbyak::util; + +namespace ov { +namespace intel_cpu { + +jit_perf_count_chrono_start_emitter::jit_perf_count_chrono_start_emitter(dnnl::impl::cpu::x64::jit_generator *host, dnnl::impl::cpu::x64::cpu_isa_t host_isa, + const std::shared_ptr& n) : jit_emitter(host, host_isa) { + m_start_node = ov::as_type_ptr(n); +} + +size_t jit_perf_count_chrono_start_emitter::get_inputs_num() const { + return 0; +} + +void jit_perf_count_chrono_start_emitter::set_start_time(snippets::op::PerfCountBegin* start_node) { + start_node->set_start_time(); +} + +void jit_perf_count_chrono_start_emitter::emit_impl(const std::vector &in_idxs, const std::vector &out_idxs) const { + internal_call_preamble(); + + const auto &set_start_time_overload = static_cast(set_start_time); + h->mov(h->rax, reinterpret_cast(set_start_time_overload)); + h->mov(abi_param1, reinterpret_cast(m_start_node.get())); + internal_call_rsp_align(); + h->call(h->rax); + internal_call_rsp_restore(); + + internal_call_postamble(); +} + +///////////////////jit_perf_count_chrono_end_emitter//////////////////////////////////// +jit_perf_count_chrono_end_emitter::jit_perf_count_chrono_end_emitter(dnnl::impl::cpu::x64::jit_generator *host, dnnl::impl::cpu::x64::cpu_isa_t host_isa, + const std::shared_ptr& n) : jit_emitter(host, host_isa) { + m_end_node = ov::as_type_ptr(n); +} + +size_t jit_perf_count_chrono_end_emitter::get_inputs_num() const { + return 0; +} + +void jit_perf_count_chrono_end_emitter::set_accumulated_time(snippets::op::PerfCountEnd* end_node) { + end_node->set_accumulated_time(); +} + +void jit_perf_count_chrono_end_emitter::emit_impl(const std::vector &in_idxs, const std::vector &out_idxs) const { + internal_call_preamble(); + + const auto &set_accumulated_time_overload = static_cast(set_accumulated_time); + h->mov(h->rax, reinterpret_cast(set_accumulated_time_overload)); + h->mov(abi_param1, reinterpret_cast(m_end_node.get())); + internal_call_rsp_align(); + h->call(h->rax); + internal_call_rsp_restore(); + + internal_call_postamble(); +} + +} // namespace intel_cpu +} // namespace ov diff --git a/src/plugins/intel_cpu/src/emitters/x64/jit_perf_count_chrono_emitters.hpp b/src/plugins/intel_cpu/src/emitters/x64/jit_perf_count_chrono_emitters.hpp new file mode 100644 index 00000000000000..763ac995ffe3e3 --- /dev/null +++ b/src/plugins/intel_cpu/src/emitters/x64/jit_perf_count_chrono_emitters.hpp @@ -0,0 +1,40 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include "jit_emitter.hpp" +#include + +#include "snippets/op/perf_count.hpp" + +namespace ov { +namespace intel_cpu { + +class jit_perf_count_chrono_start_emitter : public jit_emitter { +public: + jit_perf_count_chrono_start_emitter(dnnl::impl::cpu::x64::jit_generator *host, dnnl::impl::cpu::x64::cpu_isa_t host_isa, + const std::shared_ptr& n); + size_t get_inputs_num() const override; + +private: + void emit_impl(const std::vector &in_idxs, const std::vector &out_idxs) const override; + static void set_start_time(snippets::op::PerfCountBegin* start_node); + std::shared_ptr m_start_node = nullptr; +}; + +class jit_perf_count_chrono_end_emitter : public jit_emitter { +public: + jit_perf_count_chrono_end_emitter(dnnl::impl::cpu::x64::jit_generator *host, dnnl::impl::cpu::x64::cpu_isa_t host_isa, + const std::shared_ptr& n); + size_t get_inputs_num() const override; + +private: + void emit_impl(const std::vector &in_idxs, const std::vector &out_idxs) const override; + static void set_accumulated_time(snippets::op::PerfCountEnd* end_node); + std::shared_ptr m_end_node = nullptr; +}; + +} // namespace intel_cpu +} // namespace ov diff --git a/src/plugins/intel_cpu/src/emitters/x64/jit_perf_count_rdtsc_emitters.cpp b/src/plugins/intel_cpu/src/emitters/x64/jit_perf_count_rdtsc_emitters.cpp new file mode 100644 index 00000000000000..7f1ccda3aca62b --- /dev/null +++ b/src/plugins/intel_cpu/src/emitters/x64/jit_perf_count_rdtsc_emitters.cpp @@ -0,0 +1,86 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "jit_emitter.hpp" +#include "jit_perf_count_rdtsc_emitters.hpp" +#include + +using namespace dnnl::impl; +using namespace dnnl::impl::utils; +using namespace dnnl::impl::cpu; +using namespace dnnl::impl::cpu::x64; +using namespace Xbyak; +using namespace Xbyak::util; + +namespace ov { +namespace intel_cpu { + +jit_perf_count_rdtsc_start_emitter::jit_perf_count_rdtsc_start_emitter(dnnl::impl::cpu::x64::jit_generator *host, dnnl::impl::cpu::x64::cpu_isa_t host_isa, + const std::shared_ptr& n) : jit_emitter(host, host_isa) { + m_start_node = ov::as_type_ptr(n); +} + +size_t jit_perf_count_rdtsc_start_emitter::get_inputs_num() const { + return 0; +} + +void jit_perf_count_rdtsc_start_emitter::emit_impl(const std::vector &in_idxs, const std::vector &out_idxs) const { + h->push(h->rax); + h->push(h->rdx); + + // The EDX register is loaded with the high-order 32 bits of the MSR and the EAX register is loaded with the low-order 32 bits. + h->lfence(); + h->rdtsc(); + h->lfence(); + h->shl(h->rdx, 0x20); // shift to higher half of rdx 0x20(32) + h->or_(h->rdx, h->rax); // rdx has current tsc + + h->mov(h->rax, reinterpret_cast(&m_start_node->start_count)); + h->mov(qword[h->rax], h->rdx); + + h->pop(h->rdx); + h->pop(h->rax); +} + +///////////////////jit_perf_count_rdtsc_end_emitter//////////////////////////////////// +jit_perf_count_rdtsc_end_emitter::jit_perf_count_rdtsc_end_emitter(dnnl::impl::cpu::x64::jit_generator *host, dnnl::impl::cpu::x64::cpu_isa_t host_isa, + const std::shared_ptr& n) : jit_emitter(host, host_isa) { + m_end_node = ov::as_type_ptr(n); +} + +size_t jit_perf_count_rdtsc_end_emitter::get_inputs_num() const { + return 0; +} + +void jit_perf_count_rdtsc_end_emitter::emit_impl(const std::vector &in_idxs, const std::vector &out_idxs) const { + h->push(h->rax); + h->push(h->rdx); + + h->lfence(); + h->rdtsc(); + h->lfence(); + h->shl(h->rdx, 0x20); + h->or_(h->rdx, h->rax); // rdx has current tsc + + // tsc duration + h->mov(h->rax, reinterpret_cast(&m_end_node->get_pc_begin()->start_count)); + h->sub(h->rdx, qword[h->rax]); // rdx has tsc duration + + // accumulation = accumulation + tsc duration + h->mov(h->rax, reinterpret_cast(&m_end_node->accumulation)); + h->add(h->rdx, qword[h->rax]); + h->mov(qword[h->rax], h->rdx); + + // iteration++ + h->mov(h->rax, reinterpret_cast(&m_end_node->iteration)); + h->mov(h->rdx, qword[h->rax]); + h->add(h->rdx, 0x01); + h->mov(qword[h->rax], h->rdx); + + h->pop(h->rdx); + h->pop(h->rax); +} + +} // namespace intel_cpu +} // namespace ov diff --git a/src/plugins/intel_cpu/src/emitters/x64/jit_perf_count_rdtsc_emitters.hpp b/src/plugins/intel_cpu/src/emitters/x64/jit_perf_count_rdtsc_emitters.hpp new file mode 100644 index 00000000000000..c6314adc72a084 --- /dev/null +++ b/src/plugins/intel_cpu/src/emitters/x64/jit_perf_count_rdtsc_emitters.hpp @@ -0,0 +1,37 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include "jit_emitter.hpp" +#include +#include "transformations/snippets/x64/op/perf_count_rdtsc.hpp" + +namespace ov { +namespace intel_cpu { + +class jit_perf_count_rdtsc_start_emitter : public jit_emitter { +public: + jit_perf_count_rdtsc_start_emitter(dnnl::impl::cpu::x64::jit_generator *host, dnnl::impl::cpu::x64::cpu_isa_t host_isa, + const std::shared_ptr& n); + size_t get_inputs_num() const override; + +private: + void emit_impl(const std::vector &in_idxs, const std::vector &out_idxs) const override; + std::shared_ptr m_start_node = nullptr; +}; + +class jit_perf_count_rdtsc_end_emitter : public jit_emitter { +public: + jit_perf_count_rdtsc_end_emitter(dnnl::impl::cpu::x64::jit_generator *host, dnnl::impl::cpu::x64::cpu_isa_t host_isa, + const std::shared_ptr& n); + size_t get_inputs_num() const override; + +private: + void emit_impl(const std::vector &in_idxs, const std::vector &out_idxs) const override; + std::shared_ptr m_end_node = nullptr; +}; + +} // namespace intel_cpu +} // namespace ov diff --git a/src/plugins/intel_cpu/src/emitters/x64/jit_snippets_emitters.cpp b/src/plugins/intel_cpu/src/emitters/x64/jit_snippets_emitters.cpp index 40e49a7b158b6f..c54b031db04645 100644 --- a/src/plugins/intel_cpu/src/emitters/x64/jit_snippets_emitters.cpp +++ b/src/plugins/intel_cpu/src/emitters/x64/jit_snippets_emitters.cpp @@ -26,10 +26,6 @@ using jit_generator = dnnl::impl::cpu::x64::jit_generator; using cpu_isa_t = dnnl::impl::cpu::x64::cpu_isa_t; using ExpressionPtr = ov::snippets::lowered::ExpressionPtr; -namespace { -constexpr size_t gpr_size = 8; -} // namespace - inline static void transform_idxs_to_regs(const std::vector& idxs, std::vector& regs) { regs.resize(idxs.size()); std::transform(idxs.begin(), idxs.end(), regs.begin(), [](size_t idx){return Reg64(static_cast(idx));}); @@ -733,9 +729,6 @@ void StoreConvertEmitter::emit_isa(const std::vector &in, const std::vec void StoreConvertEmitter::emit_data() const { store_emitter->emit_data(); } -size_t BrgemmEmitter::getBrgIdx(size_t kIdx, size_t nIdx) { - return kIdx * BRGEMM_N_KERNEL_NUM + nIdx; -} size_t BrgemmEmitter::get_in_leading_dim(const VectorDims& shape, const std::vector& layout) { // Input shape is original, so we need to correctly read this data by order @@ -765,17 +758,11 @@ size_t BrgemmEmitter::get_out_leading_dim(const VectorDims& shape, const std::ve } BrgemmEmitter::BrgemmEmitter(jit_generator* h, cpu_isa_t isa, const ExpressionPtr& expr) : jit_emitter(h, isa) { - m_brgCtxs.fill(brgemmCtx()); - std::generate(m_brgKernels.begin(), m_brgKernels.end(), [](){ return nullptr; }); in_out_type_ = emitter_in_out_map::gpr_to_gpr; const auto& brgemm_node = as_type_ptr(expr->get_node()); - if (brgemm_node->is_dynamic()) - OPENVINO_THROW("Snippets don't support code generation for dynamic Brgemm"); - const auto brgemm_copy = brgemm_node->is_with_data_repacking() ? brgemm_node->get_brgemm_copy() : nullptr; + OPENVINO_ASSERT(!brgemm_node->is_dynamic(), "Snippets don't support code generation for dynamic Brgemm"); std::vector leading_dimensions; - std::vector> io_layouts; - auto get_layout = [](const std::vector& layout, const snippets::VectorDims& io_shape) { if (!layout.empty()) return layout; std::vector default_layout(io_shape.size()); @@ -784,45 +771,30 @@ BrgemmEmitter::BrgemmEmitter(jit_generator* h, cpu_isa_t isa, const ExpressionPt }; auto init_in_scheduling_params = [&](const snippets::lowered::PortDescriptorPtr& input) { - io_layouts.push_back(get_layout(input->get_layout(), input->get_shape())); - leading_dimensions.push_back(get_in_leading_dim(input->get_shape(), io_layouts.back())); + const auto& layout = get_layout(input->get_layout(), input->get_shape()); + leading_dimensions.push_back(get_in_leading_dim(input->get_shape(), layout)); }; auto init_out_scheduling_params = [&](const snippets::lowered::PortDescriptorPtr& output) { - io_layouts.push_back(get_layout(output->get_layout(), output->get_shape())); - leading_dimensions.push_back(get_out_leading_dim(output->get_shape(), io_layouts.back())); + const auto& layout = get_layout(output->get_layout(), output->get_shape()); + leading_dimensions.push_back(get_out_leading_dim(output->get_shape(), layout)); }; - init_in_scheduling_params(expr->get_input_port_descriptor(0)); + + const auto& input_0_desc = expr->get_input_port_descriptor(0); + const auto& input_1_desc = expr->get_input_port_descriptor(1); + const auto& output_desc = expr->get_output_port_descriptor(0); + + init_in_scheduling_params(input_0_desc); if (brgemm_node->is_with_data_repacking()) { - io_layouts.push_back(std::vector{}); - leading_dimensions.push_back(0); + const auto& brgemm_copy = brgemm_node->get_brgemm_copy(); + const auto& allocated_shape = brgemm_copy->get_data_repacking_shape(input_1_desc->get_shape()); + leading_dimensions.push_back(*allocated_shape.rbegin()); } else { - init_in_scheduling_params(expr->get_input_port_descriptor(1)); + init_in_scheduling_params(input_1_desc); } - init_out_scheduling_params(expr->get_output_port_descriptor(0)); - - const auto& A_shape = expr->get_input_port_descriptor(0)->get_shape(); - const auto& A_layout = io_layouts[0]; - const auto& C_shape = expr->get_output_port_descriptor(0)->get_shape(); - const auto& C_layout = io_layouts[2]; - - // We need find original M,N,K having layouts and ordered shapes - // Layout: 0, 1, 2, 3 => New layout: 0, 2, 1, 3 - // Shape: 1, 3, 5, 9 => New Shape: 1, 5, 3, 9 - // To find original 2nd dimension, we should find index of position value `2` in new layout - // and get dimension from new shape by this index - auto get_ordered_idx = [](const std::vector& layout, size_t idx) { - return std::distance(layout.begin(), std::find(layout.begin(), layout.end(), idx)); - }; + init_out_scheduling_params(output_desc); - m_K = A_shape[get_ordered_idx(A_layout, A_layout.size() - 1)]; - m_M = brgemm_node->get_input_count(0); - m_N = C_shape[get_ordered_idx(C_layout, C_layout.size() - 1)]; - - if (brgemm_node->is_with_data_repacking()) - leading_dimensions[1] = rnd_up(m_N, brgemm_copy->get_n_block_size()); - auto brg0Prc = brgemm_node->get_input_element_type(0); - auto brg1Prc = brgemm_node->get_input_element_type(1); - m_brg0VnniFactor = 4 / brg0Prc.size(); + const auto& brg0Prc = brgemm_node->get_input_element_type(0); + const auto& brg1Prc = brgemm_node->get_input_element_type(1); bool brgWithAMX = brgemm_node->is_amx(); io_data_size = {brg0Prc.size(), brg1Prc.size()}; @@ -833,59 +805,28 @@ BrgemmEmitter::BrgemmEmitter(jit_generator* h, cpu_isa_t isa, const ExpressionPt m_with_comp = brgemm_node->is_with_compensations(); m_with_scratch = brgemm_node->is_with_scratchpad(); - m_N_blk = brgemm_node->get_n_block_size(); - m_K_blk = brgemm_node->get_k_block_size(); - m_N_tail = m_N % m_N_blk; - m_K_tail = m_K % m_K_blk; - - m_N_blk_loop = m_N >= 2 * m_N_blk; - m_K_blk_loop = m_K >= 3 * m_K_blk; - OPENVINO_ASSERT((!brgemm_node->is_with_data_repacking()) || (!m_N_blk_loop && !m_K_blk_loop), - "BrgemmEmitter doesn't support blocking by K, N dimensions when data repacking is needed!"); - - auto N = [&](size_t n) { - switch (n) { - case 0: return m_N_blk; - case 1: return m_N_tail; - default: OPENVINO_THROW("BrgemmEmitter detected unsupported N value"); - } - }; - auto K = [&](size_t k) { - switch (k) { - case 0: return m_K_blk; - case 1: return m_K >= 2 * m_K_blk ? m_K_blk : 0; - case 2: return m_K_tail; - default: OPENVINO_THROW("BrgemmEmitter detected unsupported K value"); - } - }; - - bool has_K_kernel = false; - for (size_t k = 0; k < BRGEMM_K_KERNEL_NUM; k++) { - bool has_N_kernel = false; - for (size_t n = 0; n < BRGEMM_N_KERNEL_NUM; n++) { - const size_t kernel_idx = getBrgIdx(k, n); - auto& brgemmCtx = m_brgCtxs[kernel_idx]; - - brgemmCtx.M = m_M; - brgemmCtx.N = N(n); - brgemmCtx.K = K(k); - brgemmCtx.LDA = leading_dimensions[0]; - brgemmCtx.LDB = leading_dimensions[1]; - brgemmCtx.LDC = leading_dimensions[2]; - brgemmCtx.dt_in0 = static_cast(DnnlExtensionUtils::ElementTypeToDataType(brg0Prc)); - brgemmCtx.dt_in1 = static_cast(DnnlExtensionUtils::ElementTypeToDataType(brg1Prc)); - brgemmCtx.beta = has_K_kernel ? 1 : 0; - - if (brgemmCtx.N == 0 || brgemmCtx.N > m_N || - brgemmCtx.K == 0 || brgemmCtx.K > m_K) - continue; - - initBrgemm(brgemmCtx, m_brgKernels[kernel_idx], brgWithAMX); - has_N_kernel = true; - } - if (has_N_kernel) - has_K_kernel = true; - } + const auto& output_subtensor = output_desc->get_subtensor(); + const auto& input_0_subtensor = input_0_desc->get_subtensor(); + const auto& input_1_subtensor = input_1_desc->get_subtensor(); + + OPENVINO_ASSERT(*(output_subtensor.rbegin() + 1) == *(input_0_subtensor.rbegin() + 1), + "Brgemm has different M dimension subtensors on input0 and output"); + OPENVINO_ASSERT(*output_subtensor.rbegin() == *input_1_subtensor.rbegin(), + "Brgemm has different N dimension subtensors on input1 and output"); + OPENVINO_ASSERT(*input_0_subtensor.rbegin() == *(input_1_subtensor.rbegin() + 1), + "Brgemm has different K dimension subtensors on input0 and input1"); + + m_brgCtx.M = *(output_subtensor.rbegin() + 1); + m_brgCtx.N = *output_subtensor.rbegin(); + m_brgCtx.K = *input_0_subtensor.rbegin(); + m_brgCtx.LDA = leading_dimensions[0]; + m_brgCtx.LDB = leading_dimensions[1]; + m_brgCtx.LDC = leading_dimensions[2]; + m_brgCtx.dt_in0 = static_cast(DnnlExtensionUtils::ElementTypeToDataType(brg0Prc)); + m_brgCtx.dt_in1 = static_cast(DnnlExtensionUtils::ElementTypeToDataType(brg1Prc)); + m_brgCtx.beta = brgemm_node->get_beta(); + + initBrgemm(m_brgCtx, m_brgKernel, brgWithAMX); m_load_offset_a = brgemm_node->get_offset_a(); m_load_offset_b = brgemm_node->get_offset_b(); @@ -915,28 +856,8 @@ std::set> BrgemmEmitter::get_supported_precisions(con } void BrgemmEmitter::validate_arguments(const std::vector &in, const std::vector &out) const { - std::set unique_ids{in[0], in[1], out[0]}; - size_t unique_ids_count = 3; - auto add_reg_to_unique_ids = [&](const size_t reg_number) { - unique_ids.insert(reg_number); - unique_ids_count++; - }; - - if (m_N_blk_loop || m_K_blk_loop) { - if (aux_gpr_idxs.size() < static_cast(m_N_blk_loop) + static_cast(m_K_blk_loop)) - OPENVINO_THROW("BRGEMM Emitter requires extra gpr which was not allocated"); - if (m_N_blk_loop) - add_reg_to_unique_ids(aux_gpr_idxs[0]); - if (m_K_blk_loop) - add_reg_to_unique_ids(aux_gpr_idxs[m_N_blk_loop]); - } - if (m_with_scratch) { - if (in.size() != 3) - OPENVINO_THROW("BRGEMM Emitter expects 3 inputs if there are compensations/wsp"); - add_reg_to_unique_ids(in[2]); - } - if (unique_ids.size() != unique_ids_count) { - OPENVINO_THROW("BRGEMM Emitter expects that all input/output registers are unique"); + if (m_with_scratch && in.size() != 3) { + IE_THROW() << "BRGEMM Emitter expects 3 inputs if there are compensations/wsp"; } } @@ -964,118 +885,24 @@ void BrgemmEmitter::initBrgemm(brgemmCtx& ctx, std::unique_ptr& brgKernel.reset(brgKernel_); } -size_t BrgemmEmitter::aux_gprs_count() const { - return m_N_blk_loop + m_K_blk_loop; -} - -void BrgemmEmitter::emit_N_blocking_loops(size_t k_kernel_id, - const Xbyak::Reg64& input_0, const Xbyak::Reg64& input_1, - const Xbyak::Reg64& input_2, const Xbyak::Reg64& output_0, - const Xbyak::Reg64& work_amount_N) const { - // Blocked N loop - size_t kernel_idx = getBrgIdx(k_kernel_id, 0); - if (m_brgKernels[kernel_idx]) { - const auto& brgemmCtx = m_brgCtxs[kernel_idx]; - Label N_loop_begin; - if (m_N_blk_loop) { - h->mov(work_amount_N, m_N); - h->L(N_loop_begin); - } - - emit_brgemm_kernel_call(m_brgKernels[kernel_idx].get(), brgemmCtx, input_0, input_1, input_2, output_0); - // We don't need to increment pointers if we cover full N dimension in one kernel call - if (m_N_blk_loop || m_N_tail != 0) { - h->add(output_0, brgemmCtx.N * io_data_size.back()); - h->add(input_1, brgemmCtx.N * io_data_size[1]); - if (m_with_scratch && m_with_comp) - h->add(input_2, brgemmCtx.N * io_data_size[2]); - } - - if (m_N_blk_loop) { - h->sub(work_amount_N, brgemmCtx.N); - h->cmp(work_amount_N, brgemmCtx.N); - h->jge(N_loop_begin); - } - } - // N loop tail - kernel_idx = getBrgIdx(k_kernel_id, 1); - if (m_brgKernels[kernel_idx]) - emit_brgemm_kernel_call(m_brgKernels[kernel_idx].get(), m_brgCtxs[kernel_idx], input_0, input_1, input_2, output_0); - - if (m_N_blk_loop || m_N_tail != 0) { - h->sub(input_1, (m_N - m_N_tail) * io_data_size[1]); - h->sub(output_0, (m_N - m_N_tail) * io_data_size.back()); - if (m_with_scratch && m_with_comp) - h->sub(input_2, (m_N - m_N_tail) * io_data_size[2]); - } -} - void BrgemmEmitter::emit_impl(const std::vector& in, const std::vector& out) const { validate_arguments(in, out); if (host_isa_ == cpu::x64::avx512_core) { Xbyak::Reg64 input_0(static_cast(in[0])); Xbyak::Reg64 input_1(static_cast(in[1])); - Xbyak::Reg64 input_2(static_cast(0)); // scratch. Default reg index is 0 if there isn't scratch + Xbyak::Reg64 input_2(static_cast(m_with_scratch ? in[2] : 0)); // scratch. Default reg index is 0 if there isn't scratch Xbyak::Reg64 output_0(static_cast(out[0])); - Xbyak::Reg64 work_amount_N(m_N_blk_loop ? static_cast(aux_gpr_idxs[0]) : 0); - Xbyak::Reg64 work_amount_K(m_K_blk_loop ? static_cast(aux_gpr_idxs[m_N_blk_loop]) : 0); - h->add(input_0, m_load_offset_a); - h->add(input_1, m_load_offset_b); - h->add(output_0, m_store_offset_c); - if (m_with_scratch) { - input_2 = Xbyak::Reg64(static_cast(in[2])); - h->add(input_2, m_load_offset_scratch); - } - - // fills kernel_idx with the first idx of non-empty K kernel or returns false - auto get_K_kernel_idx = [&](size_t k_kernel_id, size_t& kernel_idx) { - for (size_t n = 0; n < BRGEMM_N_KERNEL_NUM; n++) { - const auto idx = getBrgIdx(k_kernel_id, n); - if (m_brgKernels[idx]) { - kernel_idx = idx; - return true; - } - } - return false; - }; - // Blocked K loop - const auto k_tail_id = BRGEMM_K_KERNEL_NUM - 1; - size_t total_K_work_amount = m_K; - size_t kernel_idx = SIZE_MAX; - for (size_t k_blocked_id = 0; k_blocked_id < k_tail_id; k_blocked_id++) { - if (get_K_kernel_idx(k_blocked_id, kernel_idx)) { - const auto& brgemmCtx = m_brgCtxs[kernel_idx]; - Label K_loop_begin; - // Note: we never emit loop for the first blocked kernel, since it always executed only once. - // The purpose of the first blocked K kernel is to initializes output, because it has beta = 0 - if (k_blocked_id == 0) { - total_K_work_amount -= brgemmCtx.K; - } else if (m_K_blk_loop) { - h->mov(work_amount_K, total_K_work_amount); - h->L(K_loop_begin); - } - - emit_N_blocking_loops(k_blocked_id, input_0, input_1, input_2, output_0, work_amount_N); - h->add(input_0, brgemmCtx.K * io_data_size[0]); - h->add(input_1, (brgemmCtx.K * brgemmCtx.LDB) * io_data_size[1]); - if (m_K_blk_loop && k_blocked_id) { - h->sub(work_amount_K, brgemmCtx.K); - h->cmp(work_amount_K, brgemmCtx.K); - h->jge(K_loop_begin); - } - } - } - // K loop tail - if (get_K_kernel_idx(k_tail_id, kernel_idx)) { - emit_N_blocking_loops(k_tail_id, input_0, input_1, input_2, output_0, work_amount_N); - } - - h->sub(input_0, m_load_offset_a + (m_K - m_K_tail) * io_data_size[0]); - h->sub(input_1, m_load_offset_b + (m_K - m_K_tail) * m_brgCtxs[0].LDB * io_data_size[1]); - if (m_with_scratch) - h->sub(input_2, m_load_offset_scratch); - h->sub(output_0, m_store_offset_c); + emit_brgemm_kernel_call(m_brgKernel.get(), + m_brgCtx, + input_0, + input_1, + input_2, + output_0, + m_load_offset_a, + m_load_offset_b, + m_load_offset_scratch, + m_store_offset_c); } else { OPENVINO_THROW("BrgemmEmitter requires at least avx512_core instruction set"); } @@ -1114,32 +941,7 @@ void BrgemmEmitter::emit_brgemm_kernel_call(const brgemm_kernel_t *brg_kernel, c h->add(h->rsp, n_gprs_to_save * gpr_size); } - Xbyak::Operand gprs_to_save[] = {h->r8, h->r9, h->r10, h->r11, h->r12, h->r13, h->r14, h->r15, - h->rax, h->rcx, h->rdx, h->rdi, h->rsi, h->rbp, h->rbx}; - size_t n_gprs_to_save = sizeof(gprs_to_save) / sizeof(gprs_to_save[0]); - - h->sub(h->rsp, n_gprs_to_save * gpr_size); - for (size_t i = 0; i < n_gprs_to_save; ++i) - h->mov(h->ptr[h->rsp + i * gpr_size], gprs_to_save[i]); - - // caller obligation to save k-regs as callee may use them - size_t n_k_regs_to_save = 8; - h->sub(h->rsp, n_k_regs_to_save * k_mask_size); - for (size_t i = 0; i < n_k_regs_to_save; ++i) { - if (mayiuse(avx512_core)) - h->kmovq(h->ptr[h->rsp + i * k_mask_size], Opmask(static_cast(i))); - else - h->kmovw(h->ptr[h->rsp + i * k_mask_size], Opmask(static_cast(i))); - } - - // 1. Caller obligation to save vector registers as callee may use them. - // 2. There is an implicit assumption that the host code uses the same - // `isa` as the injector. Once the assumption is wrong, `vecs_count` and - // `vlen` should be replaced with `host_isa::vlen` and - // `host_isa::vecs_count`. - h->sub(h->rsp, get_max_vecs_count() * get_vec_length()); - for (size_t i = 0; i < get_max_vecs_count(); ++i) - h->uni_vmovups(h->ptr[h->rsp + i * get_vec_length()], Zmm(i)); + internal_call_preamble(); // save function address in gpr to pass in call instruction const auto& brgemm_kernel_overload = static_castmov(abi_param6, static_cast(m_with_comp)); #endif - // align stack on 16-byte as ABI requires - // note that RBX must not be changed by the callee - h->mov(h->rbx, h->rsp); - h->and_(h->rbx, 0xf); - h->sub(h->rsp, h->rbx); - + internal_call_rsp_align(); h->call(h->rbp); - - h->add(h->rsp, h->rbx); + internal_call_rsp_restore(); #ifdef _WIN32 h->add(h->rsp, num_args_passed_on_stack * gpr_size); #endif - // restore vector registers - for (int i = static_cast(get_max_vecs_count()) - 1; i >= 0; --i) { - h->uni_vmovups(Zmm(i), h->ptr[h->rsp + i * get_vec_length()]); - } - h->add(h->rsp, (get_max_vecs_count()) * get_vec_length()); - - // restore k registers - for (int i = n_k_regs_to_save - 1; i >= 0; --i) { - if (mayiuse(avx512_core)) - h->kmovq(Opmask(i), h->ptr[h->rsp + i * k_mask_size]); - else - h->kmovw(Opmask(i), h->ptr[h->rsp + i * k_mask_size]); - } - h->add(h->rsp, n_k_regs_to_save * k_mask_size); - // restore gpr registers - for (int i = n_gprs_to_save - 1; i >= 0; --i) - h->mov(gprs_to_save[i], h->ptr[h->rsp + i * gpr_size]); - h->add(h->rsp, n_gprs_to_save * gpr_size); + internal_call_postamble(); } void BrgemmEmitter::kernel_execute(const brgemm_kernel_t *brg_kernel, @@ -1358,32 +1137,7 @@ void BrgemmCopyBEmitter::emit_impl(const std::vector& in, void BrgemmCopyBEmitter::emit_kernel_call(const matmul::jit_brgemm_matmul_copy_b_t* kernel, Reg64 src, Reg64 dst, Reg64 comp, size_t N, size_t K, size_t offset_in, size_t offset_out, size_t offset_comp) const { - Xbyak::Operand gprs_to_save[] = {h->r8, h->r9, h->r10, h->r11, h->r12, h->r13, h->r14, h->r15, - h->rax, h->rcx, h->rdx, h->rdi, h->rsi, h->rbp, h->rbx}; - size_t n_gprs_to_save = sizeof(gprs_to_save) / sizeof(gprs_to_save[0]); - - h->sub(h->rsp, n_gprs_to_save * gpr_size); - for (size_t i = 0; i < n_gprs_to_save; ++i) - h->mov(h->ptr[h->rsp + i * gpr_size], gprs_to_save[i]); - - // caller obligation to save k-regs as callee may use them - size_t n_k_regs_to_save = 8; - h->sub(h->rsp, n_k_regs_to_save * k_mask_size); - for (size_t i = 0; i < n_k_regs_to_save; ++i) { - if (mayiuse(avx512_core)) - h->kmovq(h->ptr[h->rsp + i * k_mask_size], Opmask(static_cast(i))); - else - h->kmovw(h->ptr[h->rsp + i * k_mask_size], Opmask(static_cast(i))); - } - - // 1. Caller obligation to save vector registers as callee may use them. - // 2. There is an implicit assumption that the host code uses the same - // `isa` as the injector. Once the assumption is wrong, `vecs_count` and - // `vlen` should be replaced with `host_isa::vlen` and - // `host_isa::vecs_count`. - h->sub(h->rsp, get_max_vecs_count() * get_vec_length()); - for (size_t i = 0; i < get_max_vecs_count(); ++i) - h->uni_vmovups(h->ptr[h->rsp + i * get_vec_length()], Zmm(i)); + internal_call_preamble(); const auto data_ptr = [&](Xmm xmm, Xbyak::Reg64 reg, size_t bytes_offset) { h->uni_vmovq(reg, xmm); @@ -1437,38 +1191,16 @@ void BrgemmCopyBEmitter::emit_kernel_call(const matmul::jit_brgemm_matmul_copy_b h->mov(abi_param5, N); h->mov(abi_param6, K); #endif - // align stack on 16-byte as ABI requires - // note that RBX must not be changed by the callee - h->mov(h->rbx, h->rsp); - h->and_(h->rbx, 0xf); - h->sub(h->rsp, h->rbx); + internal_call_rsp_align(); h->call(h->rbp); - - h->add(h->rsp, h->rbx); + internal_call_rsp_restore(); #ifdef _WIN32 h->add(h->rsp, gpr_size * num_args_passed_on_stack); #endif - // restore vector registers - for (int i = static_cast(get_max_vecs_count()) - 1; i >= 0; --i) { - h->uni_vmovups(Zmm(i), h->ptr[h->rsp + i * get_vec_length()]); - } - h->add(h->rsp, (get_max_vecs_count()) * get_vec_length()); - - // restore k registers - for (int i = n_k_regs_to_save - 1; i >= 0; --i) { - if (mayiuse(avx512_core)) - h->kmovq(Opmask(i), h->ptr[h->rsp + i * k_mask_size]); - else - h->kmovw(Opmask(i), h->ptr[h->rsp + i * k_mask_size]); - } - h->add(h->rsp, n_k_regs_to_save * k_mask_size); - // restore gpr registers - for (int i = n_gprs_to_save - 1; i >= 0; --i) - h->mov(gprs_to_save[i], h->ptr[h->rsp + i * gpr_size]); - h->add(h->rsp, n_gprs_to_save * gpr_size); + internal_call_postamble(); } void BrgemmCopyBEmitter::execute(matmul::jit_brgemm_matmul_copy_b_t *kernel, const void *src, diff --git a/src/plugins/intel_cpu/src/emitters/x64/jit_snippets_emitters.hpp b/src/plugins/intel_cpu/src/emitters/x64/jit_snippets_emitters.hpp index c2e3a07cfa108a..2ee34f34fef8d8 100644 --- a/src/plugins/intel_cpu/src/emitters/x64/jit_snippets_emitters.hpp +++ b/src/plugins/intel_cpu/src/emitters/x64/jit_snippets_emitters.hpp @@ -365,7 +365,6 @@ class BrgemmEmitter : public jit_emitter { size_t get_inputs_num() const override { return m_with_scratch ? 3 : 2; } static std::set> get_supported_precisions(const std::shared_ptr& node = nullptr); - size_t aux_gprs_count() const override; static size_t get_in_leading_dim(const VectorDims& shape, const std::vector& layout); static size_t get_out_leading_dim(const VectorDims& shape, const std::vector& layout); @@ -387,30 +386,15 @@ class BrgemmEmitter : public jit_emitter { float beta; }; static void initBrgemm(brgemmCtx& ctx, std::unique_ptr& brgKernel, bool use_amx); - static size_t getBrgIdx(size_t kIdx, size_t nIdx); void emit_brgemm_kernel_call(const dnnl::impl::cpu::x64::brgemm_kernel_t* brg_kernel, const brgemmCtx& ctx, Xbyak::Reg64 addr_A, Xbyak::Reg64 addr_B, Xbyak::Reg64 scratch, Xbyak::Reg64 addr_C, size_t in0_kernel_offset = 0, size_t in1_kernel_offset = 0, size_t in2_kernel_offset = 0, size_t out0_kernel_offset = 0) const; static void kernel_execute(const dnnl::impl::cpu::x64::brgemm_kernel_t *brg_kernel, const void *A, const void *B, void *C, void *scratch, int with_comp); - void emit_N_blocking_loops(size_t k_kernel_id, - const Xbyak::Reg64& input_0, const Xbyak::Reg64& input_1, - const Xbyak::Reg64& input_2, const Xbyak::Reg64& output_0, - const Xbyak::Reg64& work_amount_N) const; - - // Note: K dimension is covered by TWO blocked kernels (with beta = 0 and 1) + 1 for tail - static constexpr size_t BRGEMM_K_KERNEL_NUM = 3; - static constexpr size_t BRGEMM_N_KERNEL_NUM = 2; - std::array m_brgCtxs; - std::array, BRGEMM_K_KERNEL_NUM * BRGEMM_N_KERNEL_NUM> m_brgKernels; - - size_t m_M; - size_t m_K, m_K_blk, m_K_tail; - size_t m_N, m_N_blk, m_N_tail; - size_t m_brg0VnniFactor; - bool m_N_blk_loop = false; - bool m_K_blk_loop = false; + + brgemmCtx m_brgCtx; + std::unique_ptr m_brgKernel = nullptr; bool m_with_scratch = false; bool m_with_comp = false; diff --git a/src/plugins/intel_cpu/src/extension.cpp b/src/plugins/intel_cpu/src/extension.cpp index 8110a4c2fff2ea..faa3368f39c163 100644 --- a/src/plugins/intel_cpu/src/extension.cpp +++ b/src/plugins/intel_cpu/src/extension.cpp @@ -6,7 +6,7 @@ #include "transformations/cpu_opset/common/op/fully_connected.hpp" #include "transformations/cpu_opset/common/op/leaky_relu.hpp" #include "transformations/cpu_opset/common/op/power_static.hpp" -#include "transformations/cpu_opset/common/op/sdp.hpp" +#include "transformations/cpu_opset/common/op/sdpa.hpp" #include "transformations/cpu_opset/common/op/swish_cpu.hpp" #include "transformations/cpu_opset/common/op/ngram.hpp" #include "transformations/cpu_opset/x64/op/mha.hpp" @@ -15,6 +15,7 @@ #include "transformations/snippets/x64/op/store_convert.hpp" #include "transformations/snippets/x64/op/brgemm_cpu.hpp" #include "transformations/snippets/x64/op/brgemm_copy_b.hpp" +#include "transformations/snippets/x64/op/perf_count_rdtsc.hpp" #include #include @@ -60,7 +61,7 @@ std::map Extension::getOpSets() { NGRAPH_OP(NgramNode, ov::intel_cpu) NGRAPH_OP_X64(MHANode, ov::intel_cpu) NGRAPH_OP_X64(InteractionNode, ov::intel_cpu) - NGRAPH_OP_X64(ScaledDotProductAttentionStub, ov::intel_cpu) + NGRAPH_OP_X64(ScaledDotProductAttentionWithKVCache, ov::intel_cpu) #undef NGRAPH_OP return opset; @@ -139,7 +140,6 @@ std::map Extension::getOpSets() { #define NGRAPH_OP(NAME, NAMESPACE) opset.insert(); NGRAPH_OP(Brgemm, ov::snippets::op) - NGRAPH_OP(Buffer, ov::snippets::op) NGRAPH_OP(BroadcastLoad, ov::snippets::op) NGRAPH_OP(BroadcastMove, ov::snippets::op) NGRAPH_OP(ConvertSaturation, ov::snippets::op) @@ -148,10 +148,12 @@ std::map Extension::getOpSets() { NGRAPH_OP(HorizonMax, ov::snippets::op) NGRAPH_OP(HorizonSum, ov::snippets::op) NGRAPH_OP(Kernel, ov::snippets::op) + NGRAPH_OP(IntermediateMemoryBuffer, ov::snippets::op) NGRAPH_OP(Load, ov::snippets::op) NGRAPH_OP(LoadReshape, ov::snippets::op) NGRAPH_OP(LoopBegin, ov::snippets::op) NGRAPH_OP(LoopEnd, ov::snippets::op) + NGRAPH_OP(NewMemoryBuffer, ov::snippets::op) NGRAPH_OP(Nop, ov::snippets::op) NGRAPH_OP(PowerStatic, ov::snippets::op) NGRAPH_OP(Scalar, ov::snippets::op) @@ -159,12 +161,16 @@ std::map Extension::getOpSets() { NGRAPH_OP(Subgraph, ov::snippets::op) NGRAPH_OP(VectorBuffer, ov::snippets::op) NGRAPH_OP(RankNormalization, ov::snippets::op) + NGRAPH_OP(PerfCountBegin, ov::snippets::op) + NGRAPH_OP(PerfCountEnd, ov::snippets::op) NGRAPH_OP_X64(LoadConvertSaturation, ov::intel_cpu) NGRAPH_OP_X64(LoadConvertTruncation, ov::intel_cpu) NGRAPH_OP_X64(StoreConvertSaturation, ov::intel_cpu) NGRAPH_OP_X64(StoreConvertTruncation, ov::intel_cpu) NGRAPH_OP_X64(BrgemmCPU, ov::intel_cpu) NGRAPH_OP_X64(BrgemmCopyB, ov::intel_cpu) + NGRAPH_OP_X64(PerfCountRdtscBegin, ov::intel_cpu) + NGRAPH_OP_X64(PerfCountRdtscEnd, ov::intel_cpu) #undef NGRAPH_OP return opset; diff --git a/src/plugins/intel_cpu/src/graph.cpp b/src/plugins/intel_cpu/src/graph.cpp index ed6921ed88f19d..932c40e8c5cb0f 100644 --- a/src/plugins/intel_cpu/src/graph.cpp +++ b/src/plugins/intel_cpu/src/graph.cpp @@ -47,7 +47,6 @@ #include "utils/ngraph_utils.hpp" #include "utils/node_dumper.h" #include "utils/verbose.h" -#include "memory_desc/cpu_memory_desc_utils.h" #include "openvino/runtime/memory_solver.hpp" @@ -894,63 +893,17 @@ void Graph::PushInputData(const std::string& name, const ov::SoPtr& inp if (!IsReady()) OPENVINO_THROW("Wrong state. Topology not ready."); auto input_itr = inputNodesMap.find(name); if (input_itr != inputNodesMap.end()) { - auto create_mem_desc = [&](const ov::SoPtr& tensor) -> CpuBlockedMemoryDesc { - auto element_type = tensor->get_element_type(); - auto shape = tensor->get_shape(); - if (shape.empty()) - shape = {tensor->get_size()}; - std::vector blk_order(shape.size()); - std::iota(blk_order.begin(), blk_order.end(), 0); - std::vector dim_offset(shape.size(), 0); - std::vector blk_strides; - auto byte_strides = element_type.bitwidth() >= 8 ? tensor->get_strides() : Strides{}; - if (byte_strides.empty()) { - blk_strides = ov::row_major_strides(shape); - } else { - // ROI tensor need figure out correct blk_strides - blk_strides.resize(byte_strides.size()); - std::transform(byte_strides.begin(), - byte_strides.end(), - blk_strides.begin(), - [&element_type](size_t byte_stride) { - OPENVINO_ASSERT(byte_stride % element_type.size() == 0, - "Limitation: Stride in bytes ", - byte_stride, - " should be divisible by size of element ", - element_type.size()); - return byte_stride / element_type.size(); - }); - } - InferenceEngine::TensorDesc tensorDesc( - InferenceEngine::details::convertPrecision(tensor->get_element_type()), - shape, - InferenceEngine::BlockingDesc{shape, blk_order, 0, dim_offset, blk_strides}); - return MemoryDescUtils::convertToCpuBlockedMemoryDesc(tensorDesc); - }; - auto node = input_itr->second; auto childEdge = node->getChildEdgeAt(0); - const auto& outDims = node->getOutputShapeAtPort(0); const void* ext_data_ptr = input->data(); void* inter_data_ptr = childEdge->getMemory().getData(); if (ext_data_ptr != inter_data_ptr) { - auto ext_tensor_desc = create_mem_desc(input); + auto ext_tensor_desc = MemoryDescUtils::generateCpuBlockedMemoryDesc(input); Memory ext_mem(getEngine(), ext_tensor_desc, ext_data_ptr, false); childEdge->getMemory().load(ext_mem, false); } - - // todo: make sure 'name' exists in this map... - if (_normalizePreprocMap.find(name) != _normalizePreprocMap.end()) { - if (input->get_element_type() == ov::element::f32) { - _normalizePreprocMap[name].NormalizeImage(outDims, - reinterpret_cast(inter_data_ptr), - TensorDesc::getLayoutByDims(input->get_shape())); - } else { - OPENVINO_THROW("Mean image of type ", input->get_element_type().get_type_name(), " is unsupported"); - } - } } else { OPENVINO_THROW("Input blob for infer '", name, "' doesn't correspond to input in network"); } @@ -973,44 +926,32 @@ void Graph::PullOutputData(std::unordered_map>& OPENVINO_THROW("The CPU plugin graph doesn't contain output node with name: ", name.c_str()); } - InferenceEngine::TensorDesc expectedDesc( - InferenceEngine::details::convertPrecision(ext_blob->get_element_type()), - ext_blob->get_shape(), - InferenceEngine::TensorDesc::getLayoutByRank(ext_blob->get_shape().size())); - DEBUG_LOG(name, ", tensor data addr ", static_cast(output[name]->data())); + auto expected_desc_ptr = MemoryDescUtils::generateCpuBlockedMemoryDesc(ext_blob); + const auto actualDesc = intr_blob.getDescWithType(); - const auto actualDesc = MemoryDescUtils::convertToTensorDesc(intr_blob.getDesc()); + DEBUG_LOG(name, ", tensor data addr ", static_cast(output[name]->data())); // TODO [NM]: need to create universal reorder which will be detect cases when we really need to use it // WA: for cases when output shape after transformation will be 1x1x1x1 but model output is scalar bool isScalarOutput = false; - if (actualDesc.getLayout() == SCALAR) { - isScalarOutput = expectedDesc.getLayout() == SCALAR || - (!expectedDesc.getDims().empty() && - std::accumulate(expectedDesc.getDims().begin(), expectedDesc.getDims().end(), (size_t)1, std::multiplies()) == 1); - } else if (expectedDesc.getLayout() == SCALAR) { - isScalarOutput = actualDesc.getLayout() == SCALAR || - (!actualDesc.getDims().empty() && - std::accumulate(actualDesc.getDims().begin(), actualDesc.getDims().end(), (size_t)1, std::multiplies()) == 1); + if (ext_blob->get_shape().empty() && ext_blob->get_size() == 1) { + const auto& actualDims = expected_desc_ptr->getShape().getStaticDims(); + isScalarOutput = + !actualDims.empty() && + std::accumulate(actualDims.begin(), actualDims.end(), (size_t)1, std::multiplies()) == 1; } auto outDims = intr_blob.getStaticDims(); if (ext_blob->get_shape() != outDims && !isScalarOutput) { // WA: because input/output info initially contains non empty dims, order etc. // and setDims (called inside setShape) can't correct modify blocked desc for desc with blocked layout - if (expectedDesc.getLayout() == InferenceEngine::Layout::BLOCKED) { - expectedDesc = TensorDesc(expectedDesc.getPrecision(), expectedDesc.getLayout()); - } DEBUG_LOG(name, ", tensor data addr ", static_cast(output[name]->data()), " dims ", PartialShape(output[name]->get_shape()), " -> ", PartialShape(outDims), ", intr ptr ", intr_blob.getData(), " , parentedge's memory object ", parentEdge->getMemoryPtr().get()); ext_blob->set_shape(outDims); DEBUG_LOG(name, ", tensor data addr ", static_cast(output[name]->data()), " dims ", PartialShape(output[name]->get_shape()), ", intr ptr ", intr_blob.getData()); - expectedDesc = - InferenceEngine::TensorDesc(InferenceEngine::details::convertPrecision(ext_blob->get_element_type()), - ext_blob->get_shape(), - InferenceEngine::TensorDesc::getLayoutByRank(ext_blob->get_shape().size())); + expected_desc_ptr = MemoryDescUtils::generateCpuBlockedMemoryDesc(ext_blob); } // check for empty output blob @@ -1018,8 +959,8 @@ void Graph::PullOutputData(std::unordered_map>& continue; } - auto srcPrec = actualDesc.getPrecision(); - auto dstPrec = expectedDesc.getPrecision(); + auto srcPrec = actualDesc->getPrecision(); + auto dstPrec = expected_desc_ptr->getPrecision(); if (!getConfig().isLegacyApi && srcPrec == dstPrec && ext_blob->get_byte_size() != intr_blob.getSize()) OPENVINO_THROW("Output blob byte size is not equal network output byte size (", ext_blob->get_byte_size(), @@ -1034,24 +975,13 @@ void Graph::PullOutputData(std::unordered_map>& // That is the same memory. No need to copy if (ext_blob_ptr == intr_blob_ptr) continue; - if (actualDesc.getBlockingDesc() != expectedDesc.getBlockingDesc() && !isScalarOutput) { - // User can initialize output via SetOutput API using tensorDesc with ANY layout. - // For these cases we create planar memory descriptor. - auto outBlobDesc = - expectedDesc.getLayout() == InferenceEngine::Layout::ANY - ? DnnlBlockedMemoryDesc(InferenceEngine::details::convertPrecision(expectedDesc.getPrecision()), - Shape(expectedDesc.getDims())) - : MemoryDescUtils::convertToDnnlBlockedMemoryDesc(expectedDesc); - Memory outBloMem(getEngine(), outBlobDesc, ext_blob_ptr, false); + if (actualDesc->isCompatible(*expected_desc_ptr) && !isScalarOutput) { + Memory outBloMem(getEngine(), expected_desc_ptr, ext_blob_ptr, false); outBloMem.load(intr_blob, false); } else { size_t size_to_copy = intr_blob.getDescWithType()->getPaddedElementsCount(); DEBUG_LOG("pull_output: convert ", srcPrec, " to ", dstPrec); - cpu_convert(intr_blob_ptr, - ext_blob_ptr, - InferenceEngine::details::convertPrecision(srcPrec), - InferenceEngine::details::convertPrecision(dstPrec), - size_to_copy); + cpu_convert(intr_blob_ptr, ext_blob_ptr, srcPrec, dstPrec, size_to_copy); } } } diff --git a/src/plugins/intel_cpu/src/graph.h b/src/plugins/intel_cpu/src/graph.h index 890b9de8bcf604..955cbe014fd7a4 100644 --- a/src/plugins/intel_cpu/src/graph.h +++ b/src/plugins/intel_cpu/src/graph.h @@ -11,7 +11,6 @@ #include "edge.h" #include "graph_context.h" #include "node.h" -#include "normalize_preprocess.h" #include "openvino/runtime/make_tensor.hpp" #include "openvino/runtime/profiling_info.hpp" @@ -60,10 +59,6 @@ class Graph { const GraphContext::CPtr ctx, std::string name); - bool hasMeanImageFor(const std::string& name) { - return _normalizePreprocMap.find(name) != _normalizePreprocMap.end(); - } - void PushInputData(const std::string& name, const ov::SoPtr& input); void PullOutputData(std::unordered_map>& output); @@ -212,7 +207,6 @@ class Graph { outputNodesMap.clear(); graphNodes.clear(); graphEdges.clear(); - _normalizePreprocMap.clear(); syncNodesInds.clear(); } Status status { Status::NotReady }; @@ -228,7 +222,6 @@ class Graph { std::vector graphNodes; std::vector graphEdges; - std::map _normalizePreprocMap; std::string _name; bool graphHasDynamicInput = false; diff --git a/src/plugins/intel_cpu/src/infer_request.cpp b/src/plugins/intel_cpu/src/infer_request.cpp index 2ca2913b7ccdc6..b3620b37623cbc 100644 --- a/src/plugins/intel_cpu/src/infer_request.cpp +++ b/src/plugins/intel_cpu/src/infer_request.cpp @@ -332,37 +332,6 @@ void SyncInferRequest::throw_if_canceled() const { } } -static InferenceEngine::TensorDesc create_tensor_desc(const ov::SoPtr& tensor) { - auto element_type = tensor->get_element_type(); - auto shape = tensor->get_shape(); - std::vector blk_order(shape.size()); - std::iota(blk_order.begin(), blk_order.end(), 0); - std::vector dim_offset(shape.size(), 0); - std::vector blk_strides; - auto byte_strides = element_type.bitwidth() >= 8 ? tensor->get_strides() : Strides{}; - if (byte_strides.empty()) { - blk_strides = ov::row_major_strides(shape); - } else { - blk_strides.resize(byte_strides.size()); - std::transform(byte_strides.begin(), - byte_strides.end(), - blk_strides.begin(), - [&element_type](size_t byte_stride) { - OPENVINO_ASSERT(byte_stride % element_type.size() == 0, - "Limitation: Stride in bytes ", - byte_stride, - " should be divisible by size of element ", - element_type.size()); - return byte_stride / element_type.size(); - }); - } - OPENVINO_SUPPRESS_DEPRECATED_START - return InferenceEngine::TensorDesc{InferenceEngine::details::convertPrecision(element_type), - shape, - InferenceEngine::BlockingDesc{shape, blk_order, 0, dim_offset, blk_strides}}; - OPENVINO_SUPPRESS_DEPRECATED_END -} - ov::SoPtr SyncInferRequest::get_tensor(const ov::Output& in_port) const { auto port = get_internal_port(in_port); return ov::ISyncInferRequest::get_tensor(port); @@ -398,7 +367,7 @@ void SyncInferRequest::set_tensor(const ov::Output& in_port, con tensor = ov::make_tensor(in_tensor->get_element_type(), in_port.get_shape(), in_tensor->data()); } auto name = get_port_name(in_port, m_is_legacy_api); - auto tensor_desc = create_tensor_desc(tensor); + auto mem_desc_ptr = MemoryDescUtils::generateCpuBlockedMemoryDesc(tensor); bool is_input = ov::op::util::is_parameter(port.get_node()); if (is_input) { const auto netInPrc = port.get_element_type(); @@ -436,14 +405,11 @@ void SyncInferRequest::set_tensor(const ov::Output& in_port, con // we must define desc for dynamic case // otherwise we got incorrect check on shape compatibility inside isCompatible // because lower and upper bound will be compared - OPENVINO_SUPPRESS_DEPRECATED_START - actualDesc = actualDesc->cloneWithNewDims(tensor_desc.getLayout() == InferenceEngine::Layout::SCALAR - ? InferenceEngine::SizeVector{1} - : tensor_desc.getDims()); - OPENVINO_SUPPRESS_DEPRECATED_END + actualDesc = actualDesc->cloneWithNewDims( + ov::is_scalar(tensor->get_shape()) ? VectorDims{1} : VectorDims{tensor->get_shape()}); } - if (actualDesc->isCompatible(MemoryDescUtils::convertToCpuBlockedMemoryDesc(tensor_desc)) && - m_graph->_normalizePreprocMap.find(name) == m_graph->_normalizePreprocMap.end()) { + + if (actualDesc->isCompatible(*mem_desc_ptr)) { m_external_ptr[name] = tensor; } else if (m_external_ptr.find(name) != m_external_ptr.end()) { m_external_ptr.erase(name); @@ -481,7 +447,7 @@ void SyncInferRequest::set_tensor(const ov::Output& in_port, con } const auto& desc = m_graph->getOutputNodeByName(name)->getParentEdgesAtPort(0)[0]->getMemory().getDesc(); - if (!isDynamic && tensor_desc == MemoryDescUtils::convertToTensorDesc(desc)) { + if (!isDynamic && mem_desc_ptr->isCompatible(desc)) { m_external_ptr[name] = tensor; } else if (m_external_ptr.find(name) != m_external_ptr.end()) { m_external_ptr.erase(name); @@ -538,12 +504,12 @@ void SyncInferRequest::init_tensor(const std::string& name) { tensor = ov::make_tensor(port.get_element_type(), tensor_shape); ov::ISyncInferRequest::set_tensor(port, tensor); - auto desc = create_tensor_desc(tensor); - if (!isDynamic && - desc == MemoryDescUtils::convertToTensorDesc( - m_graph->getInputNodeByName(name)->getChildEdgesAtPort(0)[0]->getMemory().getDesc()) && - m_graph->_normalizePreprocMap.find(name) == m_graph->_normalizePreprocMap.end()) { - m_external_ptr[name] = tensor; + if (!isDynamic) { + auto mem_desc_ptr = MemoryDescUtils::generateCpuBlockedMemoryDesc(tensor); + if (mem_desc_ptr->isCompatible( + m_graph->getInputNodeByName(name)->getChildEdgesAtPort(0)[0]->getMemory().getDesc())) { + m_external_ptr[name] = tensor; + } } } } @@ -626,11 +592,11 @@ void SyncInferRequest::init_tensor(const std::string& name) { } } m_outputs[name] = tensor; - auto desc = create_tensor_desc(tensor); - if (!port_shape.is_dynamic() && !m_external_ptr.count(name) && - desc == MemoryDescUtils::convertToTensorDesc( - output->second->getParentEdgesAtPort(0)[0]->getMemory().getDesc())) { - m_external_ptr[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())) { + m_external_ptr[name] = tensor; + } } // update tensors in case of multiple output ports with the same name for (const auto& out : get_outputs()) { 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 b7a3ac26a18b1f..2f39090ac40837 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 @@ -5,15 +5,18 @@ #include #include "cpu_memory_desc.h" #include "memory_desc/cpu_memory_desc_utils.h" -#include #include "memory_desc/dnnl_blocked_memory_desc.h" -#include "utils/general_utils.h" +#include "openvino/runtime/itensor.hpp" +#include "openvino/runtime/so_ptr.hpp" #include "utils/cpu_utils.hpp" -#include -#include -#include +#include "utils/general_utils.h" + #include +#include #include +#include +#include +#include using namespace dnnl; using namespace InferenceEngine; @@ -46,27 +49,12 @@ DnnlBlockedMemoryDesc MemoryDescUtils::convertToDnnlBlockedMemoryDesc(const Memo } } -CpuBlockedMemoryDesc MemoryDescUtils::convertToCpuBlockedMemoryDesc(const InferenceEngine::TensorDesc& desc) { - if (desc.getLayout() == InferenceEngine::Layout::ANY) - OPENVINO_THROW("Cannot convert InferenceEngine::TensorDesc with ANY layout to CpuBlockedMemoryDesc"); - - const auto& blkDesc = desc.getBlockingDesc(); - const auto& dims = desc.getDims(); - - auto strides = blkDesc.getStrides(); - // for empty tensor case InferenceEngine::TensorDesc fill strides with non zero values before first 0 dims - // i.e. dims[1, 0, 2, 3] -> strides [0, 6, 3, 1] - if (std::any_of(dims.begin(), dims.end(), [](size_t dim){ return dim == 0; })) { - std::fill(strides.begin(), strides.end(), 0); +BlockedMemoryDescPtr MemoryDescUtils::convertToBlockedMemoryDesc(const MemoryDescPtr &desc) { + if (desc->getType() & MemoryDescType::Blocked) { + return std::dynamic_pointer_cast(desc); + } else { + OPENVINO_THROW("Can not convert unsupported memory descriptor"); } - - return CpuBlockedMemoryDesc(InferenceEngine::details::convertPrecision(desc.getPrecision()), - Shape(dims), - blkDesc.getBlockDims(), - blkDesc.getOrder(), - blkDesc.getOffsetPadding(), - blkDesc.getOffsetPaddingToData(), - strides); } CpuBlockedMemoryDescPtr MemoryDescUtils::generateCpuBlockedMemoryDesc(const ov::SoPtr& tensor) { @@ -82,6 +70,8 @@ CpuBlockedMemoryDescPtr MemoryDescUtils::generateCpuBlockedMemoryDesc(const ov:: if (byte_strides.empty()) { blk_strides = ov::row_major_strides(shape); + } else if (tensor->get_size() == 0) { + blk_strides.resize(shape.size()); } else { // ROI tensor need figure out correct blk_strides blk_strides.resize(byte_strides.size()); @@ -108,6 +98,7 @@ CpuBlockedMemoryDescPtr MemoryDescUtils::generateCpuBlockedMemoryDesc(const ov:: blk_strides); } +OPENVINO_SUPPRESS_DEPRECATED_START DnnlBlockedMemoryDesc MemoryDescUtils::convertToDnnlBlockedMemoryDesc(const InferenceEngine::TensorDesc& desc) { if (desc.getLayout() == InferenceEngine::Layout::ANY) OPENVINO_THROW("Cannot convert InferenceEngine::TensorDesc with ANY layout to DnnlBlockedMemoryDesc"); @@ -131,15 +122,7 @@ DnnlBlockedMemoryDesc MemoryDescUtils::convertToDnnlBlockedMemoryDesc(const Infe strides); } -BlockedMemoryDescPtr MemoryDescUtils::convertToBlockedMemoryDesc(const MemoryDescPtr &desc) { - if (desc->getType() & MemoryDescType::Blocked) { - return std::dynamic_pointer_cast(desc); - } else { - OPENVINO_THROW("Can not convert unsupported memory descriptor"); - } -} - -InferenceEngine::Blob::Ptr MemoryDescUtils::interpretAsBlob(const IMemory &mem) { +InferenceEngine::Blob::Ptr MemoryDescUtils::interpretAsBlob(const IMemory& mem) { // TODO [DS]: Rewrite when IE is moved to the new TensorDescriptor auto& memDesc = mem.getDesc(); InferenceEngine::TensorDesc desc = convertToTensorDesc(memDesc); @@ -148,7 +131,7 @@ InferenceEngine::Blob::Ptr MemoryDescUtils::interpretAsBlob(const IMemory &mem) return make_blob_with_precision(desc, mem.getData()); } -InferenceEngine::TensorDesc MemoryDescUtils::interpretAsBlobDesc(const IMemory &mem) { +InferenceEngine::TensorDesc MemoryDescUtils::interpretAsBlobDesc(const IMemory& mem) { auto& memDesc = mem.getDesc(); InferenceEngine::TensorDesc desc = convertToTensorDesc(memDesc); @@ -174,6 +157,7 @@ InferenceEngine::TensorDesc MemoryDescUtils::convertToTensorDesc(const MemoryDes OPENVINO_THROW("Cannot convert MemoryDesc to InferenceEngine::TensorDesc"); } } +OPENVINO_SUPPRESS_DEPRECATED_END std::string MemoryDescUtils::dim2str(Dim dim) { return dim == Shape::UNDEFINED_DIM ? "?" : std::to_string(dim); diff --git a/src/plugins/intel_cpu/src/memory_desc/cpu_memory_desc_utils.h b/src/plugins/intel_cpu/src/memory_desc/cpu_memory_desc_utils.h index 43c1d2a2d410ef..d930612ac0a173 100644 --- a/src/plugins/intel_cpu/src/memory_desc/cpu_memory_desc_utils.h +++ b/src/plugins/intel_cpu/src/memory_desc/cpu_memory_desc_utils.h @@ -7,7 +7,8 @@ #include #include "cpu_types.h" #include "cpu_shape.h" - +#include "openvino/runtime/itensor.hpp" +#include "openvino/runtime/so_ptr.hpp" #include #include #include @@ -42,11 +43,11 @@ class MemoryDescUtils { static DnnlBlockedMemoryDesc convertToDnnlBlockedMemoryDesc(const MemoryDesc& desc); /** - * @brief Converts InferenceEngine::TensorDesc to CpuBlockedMemoryDesc - * @param desc InferenceEngine::TensorDesc to be converted - * @return converted CpuBlockedMemoryDesc + * @brief Converts MemoryDesc to BlockedMemoryDesc + * @param desc MemoryDesc to be converted + * @return converted BlockedMemoryDesc */ - static CpuBlockedMemoryDesc convertToCpuBlockedMemoryDesc(const InferenceEngine::TensorDesc& desc); + static std::shared_ptr convertToBlockedMemoryDesc(const std::shared_ptr &desc); /** * @brief Builds CpuBlockedMemoryDesc for given ov::ITensor @@ -55,6 +56,7 @@ class MemoryDescUtils { */ static std::shared_ptr generateCpuBlockedMemoryDesc(const ov::SoPtr& tensor); + OPENVINO_SUPPRESS_DEPRECATED_START /** * @brief Converts InferenceEngine::TensorDesc to DnnlBlockedMemoryDesc * @param desc InferenceEngine::TensorDesc to be converted @@ -62,13 +64,6 @@ class MemoryDescUtils { */ static DnnlBlockedMemoryDesc convertToDnnlBlockedMemoryDesc(const InferenceEngine::TensorDesc& desc); - /** - * @brief Converts MemoryDesc to BlockedMemoryDesc - * @param desc MemoryDesc to be converted - * @return converted BlockedMemoryDesc - */ - static std::shared_ptr convertToBlockedMemoryDesc(const std::shared_ptr &desc); - /** * @brief Creates InferenceEngine::Blob from Memory with the memory reuse * @param desc Memory from which will be created InferenceEngine::Blob @@ -89,6 +84,7 @@ class MemoryDescUtils { * @return converted InferenceEngine::TensorDesc */ static InferenceEngine::TensorDesc convertToTensorDesc(const MemoryDesc& desc); + OPENVINO_SUPPRESS_DEPRECATED_END static constexpr Dim DEFAULT_DUMMY_VAL = 64; diff --git a/src/plugins/intel_cpu/src/node.cpp b/src/plugins/intel_cpu/src/node.cpp index f6dc2284200961..2c3749f2b08dda 100644 --- a/src/plugins/intel_cpu/src/node.cpp +++ b/src/plugins/intel_cpu/src/node.cpp @@ -23,7 +23,6 @@ #include "nodes/eltwise.h" #include "nodes/matmul.h" #include "nodes/fullyconnected.h" -#include "nodes/generic.h" #include "nodes/if.h" #include "nodes/input.h" #include "nodes/lrn.h" @@ -855,13 +854,11 @@ void Node::prepareMemory(const DnnlMemoryDescPtr& intDesc, size_t indx) { internalBlobs.size()); } - const auto &internalBlob = internalBlobs[indx]; + const auto& internalBlob = internalBlobs[indx]; - auto create = [&] () { - // TODO [DS]: internal blobs should be removed or rewritten using Memory object - auto newDesc = MemoryDescUtils::convertToDnnlBlockedMemoryDesc(internalBlob->getTensorDesc()); - - Memory memory{engine, newDesc, internalBlob->buffer()}; + auto create = [&]() { + auto newDesc = internalBlob->getDescPtr(); + Memory memory{engine, newDesc, internalBlob->getData()}; MemoryPtr _ptr = std::make_shared(engine, intDesc); node::Reorder::reorderData(memory, *_ptr, context->getParamsCache()); @@ -872,12 +869,13 @@ void Node::prepareMemory(const DnnlMemoryDescPtr& intDesc, size_t indx) { auto weightCache = context->getWeightsCache(); if (weightCache != nullptr && memory::format_kind::blocked == intDesc->getDnnlDesc().get_format_kind()) { const auto& format = intDesc->serializeFormat(); - const uint64_t data_hash = weightCache->GetHashFunc().hash( - internalBlob->buffer(), internalBlob->byteSize()); + const uint64_t data_hash = + weightCache->GetHashFunc().hash(static_cast(internalBlob->getData()), + internalBlob->getSize()); const std::string string_hash = name + "_" + std::to_string(indx) + "_" + format - + "_" + std::to_string(internalBlob->byteSize()) + + "_" + std::to_string(internalBlob->getSize()) + "_" + std::to_string(data_hash); ptr = *weightCache->findOrCreate(string_hash, create); @@ -1254,24 +1252,22 @@ bool Node::isFusedWith(Type fusedNodeType) const { return false; } -InferenceEngine::Layout Node::getWeightsLayoutByDims(SizeVector dims, bool isGrouped) { +dnnl::memory::format_tag Node::getWeightsFormatTagByDims(const SizeVector& dims) const { switch (dims.size()) { - case 0: - return InferenceEngine::Layout::SCALAR; - case 1: - return InferenceEngine::Layout::C; - case 2: - return InferenceEngine::Layout::NC; - case 3: - return InferenceEngine::Layout::CHW; - case 4: - return InferenceEngine::Layout::OIHW; - case 5: - return isGrouped ? InferenceEngine::Layout::GOIHW : InferenceEngine::Layout::OIDHW; - case 6: - return isGrouped ? InferenceEngine::Layout::GOIDHW : InferenceEngine::Layout::BLOCKED; - default: - return InferenceEngine::Layout::BLOCKED; + case 1: + return dnnl::memory::format_tag::a; + case 2: + return dnnl::memory::format_tag::ab; + case 3: + return dnnl::memory::format_tag::abc; + case 4: + return dnnl::memory::format_tag::abcd; + case 5: + return dnnl::memory::format_tag::abcde; + case 6: + return dnnl::memory::format_tag::abcdef; + default: + OPENVINO_THROW("getWeightsFormatTagByDims doesn't support dims.size() = ", dims.size()); } } diff --git a/src/plugins/intel_cpu/src/node.h b/src/plugins/intel_cpu/src/node.h index 0e56f0632aa9fb..0d998c39d889a1 100644 --- a/src/plugins/intel_cpu/src/node.h +++ b/src/plugins/intel_cpu/src/node.h @@ -526,7 +526,7 @@ class Node { return outputShapes[port]; } - const std::vector& getInternalBlobs() const { + const std::vector& getInternalBlobs() const { return internalBlobs; } @@ -606,7 +606,7 @@ class Node { }; mutable InPlaceType inplace = InPlaceType::Unknown; ConstantType constant = ConstantType::Unknown; - std::vector internalBlobs; + std::vector internalBlobs; std::vector internalBlobMemory; std::vector supportedPrimitiveDescriptors; std::unordered_map primArgs; @@ -633,7 +633,7 @@ class Node { virtual std::vector getAvailableFormatsForDims(const Shape& dims) const; - InferenceEngine::Layout getWeightsLayoutByDims(InferenceEngine::SizeVector dims, bool isGrouped); + dnnl::memory::format_tag getWeightsFormatTagByDims(const InferenceEngine::SizeVector& dims) const; /** * @brief Auxiliary function to get node input precisions diff --git a/src/plugins/intel_cpu/src/nodes/adaptive_pooling.cpp b/src/plugins/intel_cpu/src/nodes/adaptive_pooling.cpp index 9c836c7a16c6aa..f235688f533c57 100644 --- a/src/plugins/intel_cpu/src/nodes/adaptive_pooling.cpp +++ b/src/plugins/intel_cpu/src/nodes/adaptive_pooling.cpp @@ -105,10 +105,6 @@ void AdaptivePooling::initSupportedPrimitiveDescriptors() { // we supports only fp32 currently precision = ov::element::f32; - InferenceEngine::LayerConfig config; - config.inConfs.resize(2); - config.outConfs.resize((algorithm == Algorithm::AdaptivePoolingAvg ? 1 : 2)); - std::vector dataFormats{ LayoutType::ncsp }; const auto &inDims = getInputShapeAtPort(0).getDims(); if (inDims[1] != Shape::UNDEFINED_DIM && inDims[1] != 1) { diff --git a/src/plugins/intel_cpu/src/nodes/conv.cpp b/src/plugins/intel_cpu/src/nodes/conv.cpp index d605f5271da6e6..705c825b31b282 100644 --- a/src/plugins/intel_cpu/src/nodes/conv.cpp +++ b/src/plugins/intel_cpu/src/nodes/conv.cpp @@ -1193,35 +1193,6 @@ bool Convolution::isNspcAvailable() const { return true; } -InferenceEngine::Blob::Ptr Convolution::createInternalBlob(InferenceEngine::SizeVector dims, size_t edgeNum, bool isGrouped) { - const auto constNode = std::dynamic_pointer_cast(getParentEdgeAt(edgeNum)->getParent()); - if (!constNode) { - OPENVINO_THROW("Cannot cast ", edgeNum, " input to Input node for ", getName(), "."); - } - auto blb = constNode->getMemoryPtr(); - if (blb == nullptr) - OPENVINO_THROW("Cannot get const blob for node ", getName(), "."); - - auto const elementsCount = blb->getDescWithType()->getPaddedElementsCount(); - - InferenceEngine::TensorDesc desc(InferenceEngine::details::convertPrecision(ov::element::f32), dims, getWeightsLayoutByDims(dims, isGrouped)); - - Blob::Ptr internalBlob = InferenceEngine::make_shared_blob(desc); - internalBlob->allocate(); - - if (internalBlob->size() != elementsCount) { - OPENVINO_THROW("Created internal blob and const blob has different size for node: ", getName(), "."); - } - - cpu_convert(blb->getData(), - internalBlob->buffer(), - DnnlExtensionUtils::DataTypeToElementType(blb->getDataType()), - InferenceEngine::details::convertPrecision(internalBlob->getTensorDesc().getPrecision()), - elementsCount); - - return internalBlob; -} - void Convolution::prepareParams() { auto srcMemPtr = getParentEdgesAtPort(0)[0]->getMemoryPtr(); auto wghMemPtr = getParentEdgesAtPort(1)[0]->getMemoryPtr(); diff --git a/src/plugins/intel_cpu/src/nodes/conv.h b/src/plugins/intel_cpu/src/nodes/conv.h index 2279e2fc80ef67..5d7e89aa7fc009 100644 --- a/src/plugins/intel_cpu/src/nodes/conv.h +++ b/src/plugins/intel_cpu/src/nodes/conv.h @@ -116,7 +116,6 @@ class Convolution : public Node { void SetPostOpsAndZeroPoints(std::vector &attrs); void filterSupportedDescriptors(); bool isNspcAvailable() const; - InferenceEngine::Blob::Ptr createInternalBlob(InferenceEngine::SizeVector dims, size_t edgeNum, bool isGrouped = false); void updatePadding(); MemoryDescPtr getSumMemDesc(const dnnl::primitive_desc &primitive_desc_it); diff --git a/src/plugins/intel_cpu/src/nodes/deconv.cpp b/src/plugins/intel_cpu/src/nodes/deconv.cpp index a3d141ff28be98..cc1731ca596ebf 100644 --- a/src/plugins/intel_cpu/src/nodes/deconv.cpp +++ b/src/plugins/intel_cpu/src/nodes/deconv.cpp @@ -233,7 +233,7 @@ Deconvolution::Deconvolution(const std::shared_ptr& op, attr = std::make_shared(); } -InferenceEngine::Blob::Ptr Deconvolution::createWeiBlobAsIO(InferenceEngine::SizeVector dims) { +MemoryPtr Deconvolution::createWeiBlobAsIO(const VectorDims& dims) { auto constNode = std::dynamic_pointer_cast(getParentEdgeAt(1)->getParent()); if (!constNode) OPENVINO_THROW("Cannot cast const input node for node ", getName(), "."); @@ -244,7 +244,7 @@ InferenceEngine::Blob::Ptr Deconvolution::createWeiBlobAsIO(InferenceEngine::Siz auto const blbSize = blb->getSize(); // WA: In int8 case, we are processing weights using internal blob. - InferenceEngine::SizeVector dimsForBlockedDesc{dims}; + VectorDims dimsForBlockedDesc{dims}; std::swap(dimsForBlockedDesc[withGroups + 0], dimsForBlockedDesc[withGroups + 1]); VectorDims orderForBlockedDesc; @@ -256,18 +256,15 @@ InferenceEngine::Blob::Ptr Deconvolution::createWeiBlobAsIO(InferenceEngine::Siz for (size_t i = 2 + withGroups; i < dimsForBlockedDesc.size(); i++) orderForBlockedDesc.push_back(i); - BlockingDesc blkDesc(dimsForBlockedDesc, orderForBlockedDesc); - InferenceEngine::TensorDesc tensorDesc( - InferenceEngine::details::convertPrecision(DnnlExtensionUtils::DataTypeToElementType(blb->getDataType())), - dims, - blkDesc); - - Blob::Ptr internalBlob = InferenceEngine::make_shared_blob(tensorDesc); - internalBlob->allocate(); - char *data = internalBlob->buffer(); - if (data == nullptr) - OPENVINO_THROW("NotAllocated: Internal blob was not allocated for node ", getName(), "."); - size_t intBuffSize = internalBlob->byteSize(); + auto desc = CpuBlockedMemoryDesc(DnnlExtensionUtils::DataTypeToElementType(blb->getDataType()), + Shape(dims), + dimsForBlockedDesc, + orderForBlockedDesc); + MemoryPtr mem_ptr = std::make_shared(getEngine(), desc); + if (!mem_ptr->isAllocated()) + OPENVINO_THROW("NotAllocated: Internal tensor was not allocated for node ", getName(), "."); + char* data = static_cast(mem_ptr->getData()); + size_t intBuffSize = mem_ptr->getSize(); size_t offset = blbSize; if (intBuffSize < offset) { @@ -275,7 +272,7 @@ InferenceEngine::Blob::Ptr Deconvolution::createWeiBlobAsIO(InferenceEngine::Siz } cpu_memcpy_s(data, intBuffSize, blb->getData(), blbSize); - return internalBlob; + return mem_ptr; } bool Deconvolution::canBeExecutedInInt8() const { @@ -846,8 +843,7 @@ void Deconvolution::createPrimitive() { if (found) { prepareMemory({DnnlExtensionUtils::makeDescriptor(prim_desc.weights_desc(0))}); } else { - prepareMemory({std::make_shared( - MemoryDescUtils::convertToDnnlBlockedMemoryDesc(internalBlobs.front()->getTensorDesc()))}); + prepareMemory({internalBlobs.front()->getDescWithType()}); } } diff --git a/src/plugins/intel_cpu/src/nodes/deconv.h b/src/plugins/intel_cpu/src/nodes/deconv.h index 5477feadc4ffc6..8043705d7e4152 100644 --- a/src/plugins/intel_cpu/src/nodes/deconv.h +++ b/src/plugins/intel_cpu/src/nodes/deconv.h @@ -118,7 +118,7 @@ class Deconvolution : public Node { std::string errorPrefix; - InferenceEngine::Blob::Ptr createWeiBlobAsIO(InferenceEngine::SizeVector dims); + MemoryPtr createWeiBlobAsIO(const VectorDims& dims); }; } // namespace node 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 ac42cf20871359..9c5f1471c6e7bf 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 @@ -51,7 +51,7 @@ void EmbeddingBagOffsetSum::initSupportedPrimitiveDescriptors() { {ov::element::f32, ov::element::i8, ov::element::u8, ov::element::i32}; auto inDataPrecision = getOriginalInputPrecisionAtPort(EMB_TABLE_IDX); - if (inDataPrecision == ov::element::bf16) + if (one_of(inDataPrecision, ov::element::bf16, ov::element::f16)) inDataPrecision = ov::element::f32; if (!supportedPrecisions.empty()) { if (supportedPrecisions.find(inDataPrecision) == supportedPrecisions.end()) 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 88039109e3af49..ca9c4067faaa3b 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 @@ -48,7 +48,7 @@ void EmbeddingBagPackedSum::initSupportedPrimitiveDescriptors() { {ov::element::f32, ov::element::i8, ov::element::u8, ov::element::i32}; auto inDataPrecision = getOriginalInputPrecisionAtPort(EMB_TABLE_IDX); - if (inDataPrecision == ov::element::bf16) + if (one_of(inDataPrecision, ov::element::bf16, ov::element::f16)) inDataPrecision = ov::element::f32; if (!supportedPrecisions.empty()) { if (supportedPrecisions.find(inDataPrecision) == supportedPrecisions.end()) 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 bee500e9e27572..3d233660edc316 100644 --- a/src/plugins/intel_cpu/src/nodes/embedding_segments_sum.cpp +++ b/src/plugins/intel_cpu/src/nodes/embedding_segments_sum.cpp @@ -52,7 +52,7 @@ void EmbeddingSegmentsSum::initSupportedPrimitiveDescriptors() { {ov::element::f32, ov::element::i8, ov::element::u8, ov::element::i32}; auto inDataPrecision = getOriginalInputPrecisionAtPort(EMB_TABLE_IDX); - if (inDataPrecision == ov::element::bf16) + if (one_of(inDataPrecision, ov::element::bf16, ov::element::f16)) inDataPrecision = ov::element::f32; if (!supportedPrecisions.empty()) { if (supportedPrecisions.find(inDataPrecision) == supportedPrecisions.end()) diff --git a/src/plugins/intel_cpu/src/nodes/generic.cpp b/src/plugins/intel_cpu/src/nodes/generic.cpp index 36b8ba8fc609d5..689d6a1f60a4f8 100644 --- a/src/plugins/intel_cpu/src/nodes/generic.cpp +++ b/src/plugins/intel_cpu/src/nodes/generic.cpp @@ -195,6 +195,7 @@ void Generic::initDescriptor(const NodeConfig &config) { } for (auto &outConf : rightConfig.outConfs) { if (outConf.inPlace() < static_cast(getParentEdges().size()) && + outConf.inPlace() >= 0 && getParentEdgeAt(static_cast(outConf.inPlace()))->getParent()->getChildEdges().size() > 1) { outConf.inPlace(-1); } diff --git a/src/plugins/intel_cpu/src/nodes/generic.h b/src/plugins/intel_cpu/src/nodes/generic.h index dd78515b2922b3..43408d826cd8b1 100644 --- a/src/plugins/intel_cpu/src/nodes/generic.h +++ b/src/plugins/intel_cpu/src/nodes/generic.h @@ -18,7 +18,7 @@ namespace node { class Generic : public Node { public: - Generic(const std::shared_ptr& op, const GraphContext::CPtr context); + Generic(const std::shared_ptr& op, const GraphContext::CPtr context); ~Generic() = default; void getSupportedDescriptors() override; diff --git a/src/plugins/intel_cpu/src/nodes/kernels/scaled_attn/acc_value.cpp b/src/plugins/intel_cpu/src/nodes/kernels/scaled_attn/acc_value.cpp deleted file mode 100644 index 994fb55e971525..00000000000000 --- a/src/plugins/intel_cpu/src/nodes/kernels/scaled_attn/acc_value.cpp +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include - -#include -#include -#include -#include -#include - -#if defined(HAVE_AVX2) || defined(HAVE_AVX512F) -# include -#endif - -#include "openvino/core/type/bfloat16.hpp" -#include "common.hpp" -#include "acc_value.hpp" - -namespace InferenceEngine { -namespace Extensions { -namespace Cpu { -namespace XARCH { - -template -void attn_acc_value_inner(float* out, float weight, T* v, size_t S) { - size_t i = 0; -#if defined(HAVE_AVX512F) - auto attn_w_vec_fp32 = _mm512_set1_ps(weight); - for (; i + vec_len_f32_avx512 <= S; i += vec_len_f32_avx512) { - auto v_value = mm512_uni_loadu_ps(v + i); - auto v_out = mm512_uni_loadu_ps(out + i); - v_out = _mm512_fmadd_ps(attn_w_vec_fp32, v_value, v_out); - _mm512_storeu_ps(out + i, v_out); - } -#elif defined(HAVE_AVX2) - auto attn_w_vec_fp32 = _mm256_set1_ps(weight); - for (; i + vec_len_f32_avx2 <= S; i += vec_len_f32_avx2) { - auto v_value = mm256_uni_loadu_ps(v + i); - auto v_out = mm256_uni_loadu_ps(out + i); - v_out = _mm256_fmadd_ps(attn_w_vec_fp32, v_value, v_out); - mm256_uni_storeu_ps(out + i, v_out); - } -#endif - for (; i < S; i++) { - out[i] += weight * v[i]; - } -} - -void attn_acc_values(float** outs, float* weights, void** vs, size_t vec_num, size_t vec_len, ov::element::Type input_precision) { - if (input_precision == ov::element::f32) { - for (size_t i = 0; i < vec_num; i++) { - auto out_ptr = outs[i]; - auto v_ptr = static_cast(vs[i]); - attn_acc_value_inner(out_ptr, weights[i], v_ptr, vec_len); - } - } else { - assert(input_precision == ov::element::bf16); - for (size_t i = 0; i < vec_num; i++) { - auto out_ptr = outs[i]; - auto v_ptr = static_cast(vs[i]); - attn_acc_value_inner(out_ptr, weights[i], v_ptr, vec_len); - } - } -} - -} // namespace XARCH -} // namespace Cpu -} // namespace Extensions -} // namespace InferenceEngine \ No newline at end of file diff --git a/src/plugins/intel_cpu/src/nodes/kernels/scaled_attn/attn_memcpy.cpp b/src/plugins/intel_cpu/src/nodes/kernels/scaled_attn/attn_memcpy.cpp new file mode 100644 index 00000000000000..6c2b35b94f49ed --- /dev/null +++ b/src/plugins/intel_cpu/src/nodes/kernels/scaled_attn/attn_memcpy.cpp @@ -0,0 +1,100 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// +#include + +#include +#include +#include +#include +#include + +#if defined(HAVE_AVX2) || defined(HAVE_AVX512F) +# include +#endif + +#include "openvino/core/type/bfloat16.hpp" +#include "openvino/core/parallel.hpp" +#include "common.hpp" +#include "attn_memcpy.hpp" + +namespace InferenceEngine { +namespace Extensions { +namespace Cpu { +namespace XARCH { + +using namespace ov; + +// float16 <- float +template +void attn_copy(TA* a, TB* b, size_t n) { + size_t i = 0; +#if defined(HAVE_AVX512F) + for (; i + vec_len_f32_avx512 <= n; i += vec_len_f32_avx512) { + auto vb = mm512_uni_loadu_ps(b + i); + mm512_uni_storeu_ps(a + i, vb); + } +#elif defined(HAVE_AVX2) + for (; i + vec_len_f32_avx2 <= n; i += vec_len_f32_avx2) { + auto vb = mm256_uni_loadu_ps(b + i); + mm256_uni_storeu_ps(a + i, vb); + } +#endif + for (; i < n; i++) { + a[i] = b[i]; + } +} + +template +void attn_memcpy_kernel(const ov::intel_cpu::PlainTensor& k_input, + const ov::intel_cpu::PlainTensor& v_input, + const ov::intel_cpu::PlainTensor& past_k_output, + const ov::intel_cpu::PlainTensor& past_v_output) { + size_t B = k_input.m_dims[0], H = k_input.m_dims[1], L1 = k_input.m_dims[2], S = k_input.m_dims[3]; + parallel_for3d(B, H, L1, [&](size_t b, size_t h, size_t m) { + attn_copy(&past_k_output.at({b, h, m, 0}), + &k_input.at({b, h, m, 0}), + S); + attn_copy(&past_v_output.at({b, h, m, 0}), + &v_input.at({b, h, m, 0}), + S); + }); +} + +template +void attn_memcpy_kernel(const ov::intel_cpu::PlainTensor& k_input, + const ov::intel_cpu::PlainTensor& v_input, + const ov::intel_cpu::PlainTensor& past_k_output, + const ov::intel_cpu::PlainTensor& past_v_output) { + size_t B = k_input.m_dims[0], H = k_input.m_dims[1], L1 = k_input.m_dims[2], S = k_input.m_dims[3]; + parallel_for3d(B, H, L1, [&](size_t b, size_t h, size_t m) { + memcpy(&past_k_output.at({b, h, m, 0}), + &k_input.at({b, h, m, 0}), + S * sizeof(T)); + memcpy(&past_v_output.at({b, h, m, 0}), + &v_input.at({b, h, m, 0}), + S * sizeof(T)); + }); +} + +void attn_memcpy(const ov::intel_cpu::PlainTensor& k_input, + const ov::intel_cpu::PlainTensor& v_input, + const ov::intel_cpu::PlainTensor& past_k_output, + const ov::intel_cpu::PlainTensor& past_v_output) { + if (past_k_output.get_precision() == k_input.get_precision()) { + if (past_k_output.get_precision() == ov::element::bf16) { + attn_memcpy_kernel(k_input, v_input, past_k_output, past_v_output); + } else { + assert(past_k_output.get_precision() == ov::element::f16); + attn_memcpy_kernel(k_input, v_input, past_k_output, past_v_output); + } + } else if (past_k_output.get_precision() == ov::element::f16) { + attn_memcpy_kernel(k_input, v_input, past_k_output, past_v_output); + } else { + attn_memcpy_kernel(k_input, v_input, past_k_output, past_v_output); + } +} +} // namespace XARCH +} // namespace Cpu +} // namespace Extensions +} // namespace InferenceEngine \ No newline at end of file diff --git a/src/plugins/intel_cpu/src/nodes/kernels/scaled_attn/acc_value.hpp b/src/plugins/intel_cpu/src/nodes/kernels/scaled_attn/attn_memcpy.hpp similarity index 57% rename from src/plugins/intel_cpu/src/nodes/kernels/scaled_attn/acc_value.hpp rename to src/plugins/intel_cpu/src/nodes/kernels/scaled_attn/attn_memcpy.hpp index c4ef60b3028ae0..ad1c5c69db098c 100644 --- a/src/plugins/intel_cpu/src/nodes/kernels/scaled_attn/acc_value.hpp +++ b/src/plugins/intel_cpu/src/nodes/kernels/scaled_attn/attn_memcpy.hpp @@ -1,19 +1,24 @@ // Copyright (C) 2018-2023 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // +#pragma once #include #include #include #include #include +#include "utils/plain_tensor.hpp" namespace InferenceEngine { namespace Extensions { namespace Cpu { namespace XARCH { -void attn_acc_values(float** outs, float* weights, void** vs, size_t vec_num, size_t vec_len, ov::element::Type input_precision); +void attn_memcpy(const ov::intel_cpu::PlainTensor& k_input, + const ov::intel_cpu::PlainTensor& v_input, + const ov::intel_cpu::PlainTensor& past_k_output, + const ov::intel_cpu::PlainTensor& past_v_output); } // namespace XARCH } // namespace Cpu 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 b9d4ecbba2bf8c..7b729b274c3be6 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 @@ -1,12 +1,16 @@ // Copyright (C) 2018-2023 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // +#pragma once #include #include #include #include +#include "openvino/core/type/bfloat16.hpp" +#include "openvino/core/type/float16.hpp" + namespace InferenceEngine { namespace Extensions { namespace Cpu { @@ -55,6 +59,15 @@ static constexpr size_t vec_len_f32_avx2 = vec_len_avx2 / sizeof(float); x = _mm512_mask_blend_epi32(mask, nan, x); // Check NaN before converting back to bf16 _mm512_mask_cvtepi32_storeu_epi16(addr, mask_addr, x); } + + inline __m512 mm512_uni_loadu_ps(ov::float16* a) { + auto vec_f16 = _mm256_loadu_si256(reinterpret_cast<__m256i*>(a)); + return _mm512_cvtph_ps(vec_f16); + } + inline void mm512_uni_storeu_ps(ov::float16* addr, __m512 v) { + __m256i vec_f16 = _mm512_cvtps_ph(v, 0); + _mm256_storeu_si256(reinterpret_cast<__m256i *>(addr), vec_f16); + } #endif #ifdef HAVE_AVX2 @@ -87,6 +100,16 @@ static constexpr size_t vec_len_f32_avx2 = vec_len_avx2 / sizeof(float); _mm_storeu_si128(reinterpret_cast<__m128i *>(addr), bf16_o); } + inline __m256 mm256_uni_loadu_ps(ov::float16* a) { + auto vec_f16 = _mm_loadu_si128(reinterpret_cast<__m128i*>(a)); + auto o = _mm256_cvtph_ps(vec_f16); + return o; + } + inline void mm256_uni_storeu_ps(ov::float16* a, __m256 v) { + __m128i vec_f16 = _mm256_cvtps_ph(v, 0); + _mm_storeu_si128(reinterpret_cast<__m128i *>(a), vec_f16); + } + inline void hsum(__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 diff --git a/src/plugins/intel_cpu/src/nodes/kernels/scaled_attn/dot_product.cpp b/src/plugins/intel_cpu/src/nodes/kernels/scaled_attn/dot_product.cpp deleted file mode 100644 index 3a963b68842d16..00000000000000 --- a/src/plugins/intel_cpu/src/nodes/kernels/scaled_attn/dot_product.cpp +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include - -#include -#include -#include -#include -#include - -#if defined(HAVE_AVX2) || defined(HAVE_AVX512F) -# include -#endif - -#include "openvino/core/type/bfloat16.hpp" -#include "common.hpp" -#include "dot_product.hpp" - -namespace InferenceEngine { -namespace Extensions { -namespace Cpu { -namespace XARCH { - -template -float dot_product_inner(T* a, T* b, size_t n) { - size_t i = 0; - float sum = 0.0f; -#if defined(HAVE_AVX512F) - auto vsum = _mm512_setzero_ps(); - for (; i + vec_len_f32_avx512 <= n; i += vec_len_f32_avx512) { - auto va = mm512_uni_loadu_ps(a + i); - auto vb = mm512_uni_loadu_ps(b + i); - vsum = _mm512_fmadd_ps(va, vb, vsum); - } - sum = _mm512_reduce_add_ps(vsum); -#elif defined(HAVE_AVX2) - auto vsum = _mm256_set1_ps(0.0f); - for (; i + vec_len_f32_avx2 <= n; i += vec_len_f32_avx2) { - auto va = mm256_uni_loadu_ps(a + i); - auto vb = mm256_uni_loadu_ps(b + i); - vsum = _mm256_fmadd_ps(va, vb, vsum); - } - hsum(vsum); - sum = _mm256_cvtss_f32(vsum); -#endif - for (; i < n; i++) { - sum += a[i] * b[i]; - } - return sum; -} - -void attn_dot_products(void** a, void** b, void**c, size_t vec_num, size_t vec_len, ov::element::Type input_precision) { - if (input_precision == ov::element::f32) { - for (size_t i = 0; i < vec_num; i++) { - auto a_ptr = static_cast(a[i]); - auto b_ptr = static_cast(b[i]); - auto c_ptr = static_cast(c[i]); - c_ptr[0] = dot_product_inner(a_ptr, b_ptr, vec_len); - } - } else { - for (size_t i = 0; i < vec_num; i++) { - auto a_ptr = static_cast(a[i]); - auto b_ptr = static_cast(b[i]); - auto c_ptr = static_cast(c[i]); - c_ptr[0] = dot_product_inner(a_ptr, b_ptr, vec_len); - } - } -} - -} // namespace XARCH -} // namespace Cpu -} // namespace Extensions -} // namespace InferenceEngine \ No newline at end of file diff --git a/src/plugins/intel_cpu/src/nodes/kernels/scaled_attn/dot_product.hpp b/src/plugins/intel_cpu/src/nodes/kernels/scaled_attn/dot_product.hpp deleted file mode 100644 index 161fd9b890cda2..00000000000000 --- a/src/plugins/intel_cpu/src/nodes/kernels/scaled_attn/dot_product.hpp +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include -#include -#include -#include -#include - -namespace InferenceEngine { -namespace Extensions { -namespace Cpu { -namespace XARCH { - -void attn_dot_products(void** a, void** b, void**c, size_t vec_num, size_t vec_len, ov::element::Type input_precision); - -} // namespace XARCH -} // namespace Cpu -} // namespace Extensions -} // namespace InferenceEngine \ No newline at end of file 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 new file mode 100644 index 00000000000000..8ac1aca6c1467e --- /dev/null +++ b/src/plugins/intel_cpu/src/nodes/kernels/scaled_attn/mha_single_token.cpp @@ -0,0 +1,288 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// +#include + +#include +#include +#include +#include +#include + +#if defined(HAVE_AVX2) || defined(HAVE_AVX512F) +# include +#endif + +#include "openvino/core/type/bfloat16.hpp" +#include "openvino/core/parallel.hpp" +#include "mha_single_token.hpp" +#include "common.hpp" +#include "softmax_kernel.hpp" + +namespace InferenceEngine { +namespace Extensions { +namespace Cpu { +namespace XARCH { + +using namespace ov; + +template +void attn_acc_value(float* out, float weight, T* v, size_t S) { + size_t i = 0; +#if defined(HAVE_AVX512F) + auto attn_w_vec_fp32 = _mm512_set1_ps(weight); + for (; i + vec_len_f32_avx512 <= S; i += vec_len_f32_avx512) { + auto v_value = mm512_uni_loadu_ps(v + i); + auto v_out = mm512_uni_loadu_ps(out + i); + v_out = _mm512_fmadd_ps(attn_w_vec_fp32, v_value, v_out); + _mm512_storeu_ps(out + i, v_out); + } +#elif defined(HAVE_AVX2) + auto attn_w_vec_fp32 = _mm256_set1_ps(weight); + for (; i + vec_len_f32_avx2 <= S; i += vec_len_f32_avx2) { + auto v_value = mm256_uni_loadu_ps(v + i); + auto v_out = mm256_uni_loadu_ps(out + i); + v_out = _mm256_fmadd_ps(attn_w_vec_fp32, v_value, v_out); + mm256_uni_storeu_ps(out + i, v_out); + } +#endif + for (; i < S; i++) { + out[i] += weight * v[i]; + } +} + +template +float dot_product(TA* a, TB* b, size_t n) { + size_t i = 0; + float sum = 0.0f; +#if defined(HAVE_AVX512F) + auto vsum = _mm512_setzero_ps(); + for (; i + vec_len_f32_avx512 <= n; i += vec_len_f32_avx512) { + auto va = mm512_uni_loadu_ps(a + i); + auto vb = mm512_uni_loadu_ps(b + i); + vsum = _mm512_fmadd_ps(va, vb, vsum); + } + sum = _mm512_reduce_add_ps(vsum); +#elif defined(HAVE_AVX2) + auto vsum = _mm256_set1_ps(0.0f); + for (; i + vec_len_f32_avx2 <= n; i += vec_len_f32_avx2) { + auto va = mm256_uni_loadu_ps(a + i); + auto vb = mm256_uni_loadu_ps(b + i); + vsum = _mm256_fmadd_ps(va, vb, vsum); + } + hsum(vsum); + sum = _mm256_cvtss_f32(vsum); +#endif + for (; i < n; i++) { + sum += a[i] * b[i]; + } + return sum; +} + +template +void attn_reduce(T* dst, float* temp, size_t M, size_t S, size_t temp_stride) { + size_t i = 0; +#if defined(HAVE_AVX512F) + for (; i + vec_len_f32_avx512 <= S; i+= vec_len_f32_avx512) { + auto* src = temp + i; + auto result_vec_fp32 = _mm512_setzero_ps(); + for (size_t m = 0; m < M; m++) { + //auto* temp = &m_temp.at({ithr, b, pq, h, 0}); + auto o_vec_fp32 = _mm512_loadu_ps(src); + result_vec_fp32 = _mm512_add_ps(result_vec_fp32, o_vec_fp32); + src += temp_stride; + } + // save to bf16 + mm512_uni_storeu_ps(dst + i, result_vec_fp32); + } +#elif defined(HAVE_AVX2) + for (; i + vec_len_f32_avx2 <= S; i += vec_len_f32_avx2) { + auto* src = temp + i; + auto result_vec_fp32 = _mm256_set1_ps(0.0f); + for (size_t m = 0; m < M; m++) { + auto o_vec_fp32 = mm256_uni_loadu_ps(src); + result_vec_fp32 = _mm256_add_ps(result_vec_fp32, o_vec_fp32); + src += temp_stride; + } + mm256_uni_storeu_ps(dst + i, result_vec_fp32); + } +#endif + for (; i < S; i++) { + auto* src = temp + i; + float sum = 0.0f; + // sum result from all threads partition + for (size_t m = 0; m < M; m++) { + sum += src[0]; + src += temp_stride; + } + dst[i] = sum; + } +} + +template +void mha_single_token_kernel(const ov::intel_cpu::PlainTensor& query, + const ov::intel_cpu::PlainTensor& present_key, + const ov::intel_cpu::PlainTensor& present_value, + const ov::intel_cpu::PlainTensor& alibi_mask, + const ov::intel_cpu::PlainTensor& attention_mask, + const ov::intel_cpu::PlainTensor& beams, + ov::intel_cpu::PlainTensor& output_emb, + ov::intel_cpu::PlainTensor& buf_attn_w, + ov::intel_cpu::PlainTensor& buf_attn_score, + bool has_out_transpose, + bool auto_causal, + float d_scale) { + ov::intel_cpu::PlainTensor causal_mask; + bool select_nfltmax_at_0 = false; + auto B = query.size(0); + auto H = query.size(1); + auto q_len = query.size(2); + auto S = query.size(3); + auto kv_len = present_key.size(2); + + if (d_scale == 0.0f) + d_scale = 1.0f / sqrt(S); + + // use per-token kernel, for each k,v token + // attn mask is a matrix of q_len(kv_len) + buf_attn_w.resize({B, H, q_len, kv_len}); + + bool is_abcd = present_key.stride(1) >= present_key.stride(2); + size_t dim0 = is_abcd ? B : kv_len; + size_t dim1 = is_abcd ? H : B; + size_t dim2 = is_abcd ? kv_len : H; + + parallel_for3d(dim0, dim1, dim2, [&](size_t d0, size_t d1, size_t d2) { + size_t b = is_abcd ? d0 : d1; + size_t h = is_abcd ? d1 : d2; + size_t pk = is_abcd ? d2 : d0; + + // which batch item should be used at postion pk? + auto b_kv = beams ? beams.at({b, pk}) : b; + for (size_t pq = 0; pq < q_len; pq++) { + buf_attn_w.at({b, h, pq, pk}) = dot_product(&query.at({b, h, pq, 0}), + &present_key.at({b_kv, h, pk, 0}, true), + S); + } + }); + + parallel_for3d(B, H, q_len, [&](size_t b, size_t h, size_t pq) { + // 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* 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}), + d_scale, + alibi_ptr, + attn_mask_ptr, + cmask_ptr, + select_nfltmax_at_0, + ncausal, + kv_len, + ov::element::f32); + }); + + // attn_w * V + auto nthr = parallel_get_max_threads(); + buf_attn_score.resize({static_cast(nthr), B, q_len, H, S}); + // buf_attn_w {B, H, q_len, kv_len} + parallel_nt_static(nthr, [&](const size_t ithr, const size_t nthr) { + size_t start{0}, end{0}; + splitter(B * H * kv_len, nthr, ithr, start, end); + + memset(&buf_attn_score.at({ithr, 0, 0, 0, 0}), 0, buf_attn_score.stride(0) * sizeof(float)); + + size_t b, h, pv; + if (start < end) { + if (is_abcd) + parallel_it_init(start, b, B, h, H, pv, kv_len); + else + parallel_it_init(start, pv, kv_len, b, B, h, H); + for (size_t iwork = start; iwork < end; ++iwork) { + auto b_kv = beams ? beams.at({b, pv}) : b; + auto* v = &present_value.at({b_kv, h, pv, 0}, true); + for (size_t pq = 0; pq < q_len; pq++) { + attn_acc_value(&buf_attn_score.at({ithr, b, pq, h, 0}), + buf_attn_w.at({b, h, pq, pv}), + v, + S); + } + if (is_abcd) + parallel_it_step(b, B, h, H, pv, kv_len); + else + parallel_it_step(pv, kv_len, b, B, h, H); + } + } + }); + + parallel_for3d(B, H, q_len, [&](size_t b, size_t h, size_t pq) { + auto* temp = &buf_attn_score.at({0, b, pq, h, 0}); + size_t temp_stride = buf_attn_score.stride(0); + auto* dst = has_out_transpose ? &output_emb.at({b, pq, h * S}) : &output_emb.at({b, h, pq}); + attn_reduce(dst, temp, nthr, S, temp_stride); + }); +} + +void mha_single_token(const ov::intel_cpu::PlainTensor& query, + const ov::intel_cpu::PlainTensor& present_key, + const ov::intel_cpu::PlainTensor& present_value, + const ov::intel_cpu::PlainTensor& alibi_mask, + const ov::intel_cpu::PlainTensor& attention_mask, + const ov::intel_cpu::PlainTensor& beams, + ov::intel_cpu::PlainTensor& output_emb, + ov::intel_cpu::PlainTensor& buf_attn_w, + ov::intel_cpu::PlainTensor& buf_attn_score, + bool has_out_transpose, + bool auto_causal, + float d_scale) { + if (query.get_precision() == ov::element::bf16) { + mha_single_token_kernel(query, + present_key, + present_value, + alibi_mask, + attention_mask, + beams, + output_emb, + buf_attn_w, + buf_attn_score, + has_out_transpose, + auto_causal, + d_scale); + } else if (query.get_precision() == ov::element::f32) { + if (present_key.get_precision() == ov::element::f16) { + mha_single_token_kernel(query, + present_key, + present_value, + alibi_mask, + attention_mask, + beams, + output_emb, + buf_attn_w, + buf_attn_score, + has_out_transpose, + auto_causal, + d_scale); + } else { + mha_single_token_kernel(query, + present_key, + present_value, + alibi_mask, + attention_mask, + beams, + output_emb, + buf_attn_w, + buf_attn_score, + has_out_transpose, + auto_causal, + d_scale); + } + } else { + OPENVINO_THROW("Unsupported precision: ", query.get_precision()); + } +} +} // namespace XARCH +} // namespace Cpu +} // namespace Extensions +} // namespace InferenceEngine \ No newline at end of file diff --git a/src/plugins/intel_cpu/src/nodes/kernels/scaled_attn/mha_single_token.hpp b/src/plugins/intel_cpu/src/nodes/kernels/scaled_attn/mha_single_token.hpp new file mode 100644 index 00000000000000..543f7f1d9217a0 --- /dev/null +++ b/src/plugins/intel_cpu/src/nodes/kernels/scaled_attn/mha_single_token.hpp @@ -0,0 +1,34 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// +#pragma once + +#include +#include +#include +#include +#include +#include "utils/plain_tensor.hpp" + +namespace InferenceEngine { +namespace Extensions { +namespace Cpu { +namespace XARCH { + +void mha_single_token(const ov::intel_cpu::PlainTensor& query, + const ov::intel_cpu::PlainTensor& present_key, + const ov::intel_cpu::PlainTensor& present_value, + const ov::intel_cpu::PlainTensor& alibi_mask, + const ov::intel_cpu::PlainTensor& attention_mask, + const ov::intel_cpu::PlainTensor& beams, + ov::intel_cpu::PlainTensor& output_emb, + ov::intel_cpu::PlainTensor& buf_attn_w, + ov::intel_cpu::PlainTensor& buf_attn_score, + bool has_out_transpose, + bool auto_causal, + float d_scale); + +} // namespace XARCH +} // namespace Cpu +} // namespace Extensions +} // namespace InferenceEngine \ No newline at end of file diff --git a/src/plugins/intel_cpu/src/nodes/kernels/scaled_attn/reduce.cpp b/src/plugins/intel_cpu/src/nodes/kernels/scaled_attn/reduce.cpp deleted file mode 100644 index ad5e502dfa8907..00000000000000 --- a/src/plugins/intel_cpu/src/nodes/kernels/scaled_attn/reduce.cpp +++ /dev/null @@ -1,80 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include - -#include -#include -#include -#include -#include - -#if defined(HAVE_AVX2) || defined(HAVE_AVX512F) - #include -#endif - -#include "openvino/core/type/bfloat16.hpp" -#include "common.hpp" -#include "reduce.hpp" - -namespace InferenceEngine { -namespace Extensions { -namespace Cpu { -namespace XARCH { - -template -void attn_reduce_inner(T* dst, float* temp, size_t M, size_t S, size_t temp_stride) { - size_t i = 0; -#if defined(HAVE_AVX512F) - for (; i + vec_len_f32_avx512 <= S; i+= vec_len_f32_avx512) { - auto* src = temp + i; - auto result_vec_fp32 = _mm512_setzero_ps(); - for (size_t m = 0; m < M; m++) { - //auto* temp = &m_temp.at({ithr, b, pq, h, 0}); - auto o_vec_fp32 = _mm512_loadu_ps(src); - result_vec_fp32 = _mm512_add_ps(result_vec_fp32, o_vec_fp32); - src += temp_stride; - } - // save to bf16 - mm512_uni_storeu_ps(dst + i, result_vec_fp32); - } -#elif defined(HAVE_AVX2) - for (; i + vec_len_f32_avx2 <= S; i += vec_len_f32_avx2) { - auto* src = temp + i; - auto result_vec_fp32 = _mm256_set1_ps(0.0f); - for (size_t m = 0; m < M; m++) { - auto o_vec_fp32 = mm256_uni_loadu_ps(src); - result_vec_fp32 = _mm256_add_ps(result_vec_fp32, o_vec_fp32); - src += temp_stride; - } - mm256_uni_storeu_ps(dst + i, result_vec_fp32); - } -#endif - for (; i < S; i++) { - auto* src = temp + i; - float sum = 0.0f; - // sum result from all threads partition - for (size_t m = 0; m < M; m++) { - sum += src[0]; - src += temp_stride; - } - dst[i] = sum; - } -} - -void attn_reduce(void* dst, float* temp, size_t M, size_t S, size_t temp_stride, ov::element::Type input_precision) { - if (input_precision == ov::element::f32) { - auto dst_ptr = static_cast(dst); - attn_reduce_inner(dst_ptr, temp, M, S, temp_stride); - } else { - assert(input_precision == ov::element::bf16); - auto dst_ptr = static_cast(dst); - attn_reduce_inner(dst_ptr, temp, M, S, temp_stride); - } -} - -} // namespace XARCH -} // namespace Cpu -} // namespace Extensions -} // namespace InferenceEngine \ No newline at end of file diff --git a/src/plugins/intel_cpu/src/nodes/kernels/scaled_attn/reduce.hpp b/src/plugins/intel_cpu/src/nodes/kernels/scaled_attn/reduce.hpp deleted file mode 100644 index baa9b6d1835f1d..00000000000000 --- a/src/plugins/intel_cpu/src/nodes/kernels/scaled_attn/reduce.hpp +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include -#include -#include -#include -#include - -namespace InferenceEngine { -namespace Extensions { -namespace Cpu { -namespace XARCH { - -void attn_reduce(void* dst, float* temp, size_t M, size_t S, size_t temp_stride, ov::element::Type input_precision); - -} // namespace XARCH -} // namespace Cpu -} // namespace Extensions -} // namespace InferenceEngine \ No newline at end of file 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 5c2bea26b71556..7ebec7f9bae3ef 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 @@ -15,522 +15,13 @@ #include "openvino/core/type/bfloat16.hpp" #include "softmax.hpp" +#include "softmax_kernel.hpp" #include "common.hpp" namespace InferenceEngine { namespace Extensions { 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 - x = _mm256_max_ps(x, y); // X: 01 12 23 30 45 56 67 74 - y = _mm256_permute_ps(x, 0x4e); // y: 23 30 01 12 67 74 45 56 - x = _mm256_max_ps(x, y); // x: 0123 x x x 4567 x x x - y = _mm256_permute2f128_ps(x, x, 1); // y: 4567 x x x 0123 x x x - x = _mm256_max_ps(x, y); // x: 01234567 x x x x x x x -} - -inline void exp_ps_avx2(__m256& src) { - static __m256 exp_ln_flt_min_f = _mm256_castsi256_ps(_mm256_set1_epi32(0xc2aeac50)); // log(FLT_MIN) - static __m256 exp_ln_flt_max_f = _mm256_castsi256_ps(_mm256_set1_epi32(0x42b17218)); // log(FLT_MAX) - static __m256 exp_log2ef = _mm256_castsi256_ps(_mm256_set1_epi32(0x3fb8aa3b)); // log2(e) - static __m256 half = _mm256_castsi256_ps(_mm256_set1_epi32(0x3f000000)); // 0.5f - static __m256 ln2f = _mm256_castsi256_ps(_mm256_set1_epi32(0x3f317218)); // ln(2) - static __m256 one = _mm256_castsi256_ps(_mm256_set1_epi32(0x3f800000)); // 1.0f - static __m256i exponent_bias = _mm256_set1_epi32(0x0000007f); // 127 - static constexpr int n_mantissa_bits = 23; - static __m256 exp_pol1 = _mm256_castsi256_ps(_mm256_set1_epi32(0x3f7ffffb)); // p1 = 0.999999701f - static __m256 exp_pol2 = _mm256_castsi256_ps(_mm256_set1_epi32(0x3efffee3)); // p2 = 0.499991506f - static __m256 exp_pol3 = _mm256_castsi256_ps(_mm256_set1_epi32(0x3e2aad40)); // p3 = 0.166676521f - static __m256 exp_pol4 = _mm256_castsi256_ps(_mm256_set1_epi32(0x3d2b9d0d)); // p4 = 0.0418978221f - static __m256 exp_pol5 = _mm256_castsi256_ps(_mm256_set1_epi32(0x3c07cfce)); // p5 = 0.00828929059f - static __m256 two = _mm256_castsi256_ps(_mm256_set1_epi32(0x40000000)); // 2 - // exp(x) = - // = exp(n * ln(2) + r) // divide x by ln(2) and get quot and rem - // = 2^n * exp(r) // simplify the exp(n*ln(2)) expression - - // get mask of values lower than log(FLT_MIN) to zero them in the output - auto zero_mask = _mm256_cmp_ps(src, exp_ln_flt_min_f, _CMP_LT_OS); - - // clip src - src = _mm256_min_ps(src, exp_ln_flt_max_f); - src = _mm256_max_ps(src, exp_ln_flt_min_f); - - // aux1 : r - auto aux1 = src; - - // calculate exp(x) - // fx = x * log2(e) + 0.5 - src = _mm256_mul_ps(src, exp_log2ef); - src = _mm256_add_ps(src, half); - - // tmp = floorf(fx) - src = _mm256_floor_ps(src); - - // aux1 = x - fx * ln2 - aux1 = _mm256_fnmadd_ps(src, ln2f, aux1); - - // We do not count 2^n here, because n can reach 128 and 2^128 is not - // representable by fp32, so to get around this problem, instead of computing - // 2^n * exp(r) will be counted 2*2^(n-1)*exp(r), because 2^127 - // and 2 are numbers representable in fp32. - - // compute 2^(n-1) - src = _mm256_sub_ps(src, one); - auto aux2_i = _mm256_cvtps_epi32(src); - aux2_i = _mm256_add_epi32(aux2_i, exponent_bias); - aux2_i = _mm256_slli_epi32(aux2_i, n_mantissa_bits); - - // set zeroes at those points which were < log(FLT_MIN) - auto zero = _mm256_setzero_ps(); - auto aux2 = _mm256_blendv_ps(_mm256_castsi256_ps(aux2_i), zero, zero_mask); - - // compute polynomial - src = exp_pol5; - src = _mm256_fmadd_ps(src, aux1, exp_pol4); - src = _mm256_fmadd_ps(src, aux1, exp_pol3); - src = _mm256_fmadd_ps(src, aux1, exp_pol2); - src = _mm256_fmadd_ps(src, aux1, exp_pol1); - src = _mm256_fmadd_ps(src, aux1, one); - - // y = y * 2^n - src = _mm256_mul_ps(src, aux2); - src = _mm256_mul_ps(src, two); -} -#endif - -inline void scale_add_reduce_max(float* a, const float scale, const float* b, const size_t size, float& max) { -#if defined(HAVE_AVX512F) - auto v_max = _mm512_set1_ps(std::numeric_limits::lowest()); - auto v_scale = _mm512_set1_ps(scale); - auto v_a = v_max; - auto v_b = v_max; - size_t i = 0; - // process vector body - while (i + vec_len_f32_avx512 <= size) { - v_a = _mm512_loadu_ps(a + i); - v_b = _mm512_loadu_ps(b + i); - v_a = _mm512_fmadd_ps(v_a, v_scale, v_b); - v_max = _mm512_max_ps(v_max, v_a); - _mm512_storeu_ps(a + i, v_a); - i += vec_len_f32_avx512; - } - - // process tails - if (i < size) { - __mmask16 mask = (1 << (size - i)) - 1; - v_a = _mm512_maskz_loadu_ps(mask, a + i); - v_b = _mm512_maskz_loadu_ps(mask, b + i); - v_a = _mm512_fmadd_ps(v_a, v_scale, v_b); - v_max = _mm512_mask_max_ps(v_max, mask, v_a, v_max); - _mm512_mask_storeu_ps(a + i, mask, v_a); - } - - max = _mm512_reduce_max_ps(v_max); -#elif defined(HAVE_AVX2) - auto v_max = _mm256_set1_ps(std::numeric_limits::lowest()); - auto v_scale = _mm256_set1_ps(scale); - auto v_a = v_max; - auto v_b = v_max; - size_t i = 0; - // process vector body - while (i + vec_len_f32_avx2 <= size) { - v_a = _mm256_loadu_ps(a + i); - v_b = _mm256_loadu_ps(b + i); - v_a = _mm256_fmadd_ps(v_a, v_scale, v_b); - v_max = _mm256_max_ps(v_max, v_a); - _mm256_storeu_ps(a + i, v_a); - i += vec_len_f32_avx2; - } - - // process tails - if (i < size) { - auto mask = get_mask(size - i); - v_a = _mm256_maskload_ps(a + i, mask); - v_b = _mm256_maskload_ps(b + i, mask); - v_a = _mm256_fmadd_ps(v_a, v_scale, v_b); - v_a = _mm256_blendv_ps(v_max, v_a, _mm256_castsi256_ps(mask)); - v_max = _mm256_max_ps(v_max, v_a); - _mm256_maskstore_ps(a + i, mask, v_a); - } - hmax(v_max); - max = _mm256_cvtss_f32(v_max); -#else - for (size_t i = 0; i < size; i++) { - a[i] *= scale; - a[i] += b[i]; - max = a[i] > max ? a[i] : max; - } -#endif -} -template -inline void scale_add2_reduce_max(float* a, - float scale, - const float* alibi, - const float* attn_mask, - const uint8_t* causal_mask, - bool select_nfltmax_at_0, // true: 0 in mask set -FLT_MAX - size_t size, - float& max) { -#if defined(HAVE_AVX512F) - auto v_max = _mm512_set1_ps(std::numeric_limits::lowest()); - auto v_scale = _mm512_set1_ps(scale); - auto v_a = v_max; - size_t i = 0; - auto v_zeroi32 = _mm512_setzero_epi32(); - auto v_nfltmax = _mm512_set1_ps(-FLT_MAX); - auto kmask_xor = _cvtu32_mask16(select_nfltmax_at_0 ? 0xFFFF : 0); - // process vector body - while (i + vec_len_f32_avx512 <= size) { - v_a = _mm512_loadu_ps(a + i); - v_a = _mm512_mul_ps(v_a, v_scale); - - if (has_alibi) { - auto v_mask = _mm512_loadu_ps(alibi + i); - v_a = _mm512_add_ps(v_a, v_mask); - } - - if (has_attn_mask) { - auto v_mask = _mm512_loadu_ps(attn_mask + i); - v_a = _mm512_add_ps(v_a, v_mask); - } - - if (has_causal_mask) { - auto v_maski8 = _mm_loadu_si128(reinterpret_cast<__m128i const*>(causal_mask + i)); - auto v_maski32 = _mm512_cvtepi8_epi32(v_maski8); - auto kmask = _mm512_cmp_epi32_mask(v_maski32, v_zeroi32, _MM_CMPINT_NE); // !=0 - kmask = _kxor_mask16(kmask, kmask_xor); // reverse, mask at ==0 - v_a = _mm512_mask_blend_ps(kmask, v_a, v_nfltmax); // mask => -FLT_MAX - } - v_max = _mm512_max_ps(v_max, v_a); - _mm512_storeu_ps(a + i, v_a); - i += vec_len_f32_avx512; - } - - // process tails - if (i < size) { - __mmask16 mask = (1 << (size - i)) - 1; - v_a = _mm512_maskz_loadu_ps(mask, a + i); - v_a = _mm512_mul_ps(v_a, v_scale); - - if (has_alibi) { - auto v_mask = _mm512_maskz_loadu_ps(mask, alibi + i); - v_a = _mm512_add_ps(v_a, v_mask); - } - - if (has_attn_mask) { - auto v_mask = _mm512_maskz_loadu_ps(mask, attn_mask + i); - v_a = _mm512_add_ps(v_a, v_mask); - } - - if (has_causal_mask) { - auto v_maski8 = _mm_loadu_si128(reinterpret_cast<__m128i const*>(causal_mask + i)); - auto v_maski32 = _mm512_cvtepi8_epi32(v_maski8); - auto kmask = _mm512_cmp_epi32_mask(v_maski32, v_zeroi32, _MM_CMPINT_NE); // !=0 - kmask = _kxor_mask16(kmask, kmask_xor); // reverse, mask at ==0 - v_a = _mm512_mask_blend_ps(kmask, v_a, v_nfltmax); // mask => -FLT_MAX - } - v_max = _mm512_mask_max_ps(v_max, mask, v_a, v_max); - _mm512_mask_storeu_ps(a + i, mask, v_a); - } - - max = _mm512_reduce_max_ps(v_max); -#elif defined(HAVE_AVX2) - auto v_max = _mm256_set1_ps(std::numeric_limits::lowest()); - auto v_scale = _mm256_set1_ps(scale); - auto v_a = v_max; - auto v_zeroi32 = _mm256_setzero_si256(); - auto v_mask_xor = _mm256_set1_epi32(select_nfltmax_at_0 ? -1 : 0); - auto v_nfltmax = _mm256_set1_ps(-FLT_MAX); - size_t i = 0; - // process vector body - while (i + vec_len_f32_avx2 <= size) { - v_a = _mm256_loadu_ps(a + i); - v_a = _mm256_mul_ps(v_a, v_scale); - - if (has_alibi) { - auto v_mask = _mm256_loadu_ps(alibi + i); - v_a = _mm256_add_ps(v_a, v_mask); - } - - if (has_attn_mask) { - auto v_mask = _mm256_loadu_ps(attn_mask + i); - v_a = _mm256_add_ps(v_a, v_mask); - } - - if (has_causal_mask) { - auto v_maski8 = _mm_loadu_si128(reinterpret_cast<__m128i const*>(causal_mask + i)); - auto v_maski32 = _mm256_cvtepi8_epi32(v_maski8); - v_maski32 = _mm256_cmpeq_epi32(v_maski32, v_zeroi32); // ==0 - v_maski32 = _mm256_xor_si256(v_maski32, v_mask_xor); // reverse, mask at ==0 - v_a = _mm256_blendv_ps(v_nfltmax, v_a, _mm256_castsi256_ps(v_maski32)); // mask => -FLT_MAX - } - - v_max = _mm256_max_ps(v_max, v_a); - _mm256_storeu_ps(a + i, v_a); - i += vec_len_f32_avx2; - } - - // process tails - if (i < size) { - auto mask = get_mask(size - i); - v_a = _mm256_maskload_ps(a + i, mask); - v_a = _mm256_mul_ps(v_a, v_scale); - - if (has_alibi) { - auto v_mask = _mm256_maskload_ps(alibi + i, mask); - v_a = _mm256_add_ps(v_a, v_mask); - } - - if (has_attn_mask) { - auto v_mask = _mm256_maskload_ps(attn_mask + i, mask); - v_a = _mm256_add_ps(v_a, v_mask); - } - - if (has_causal_mask) { - auto v_maski8 = _mm_loadu_si128(reinterpret_cast<__m128i const*>(causal_mask + i)); - auto v_maski32 = _mm256_cvtepi8_epi32(v_maski8); - v_maski32 = _mm256_cmpeq_epi32(v_maski32, v_zeroi32); // ==0 - v_maski32 = _mm256_xor_si256(v_maski32, v_mask_xor); // reverse, mask at ==0 - v_a = _mm256_blendv_ps(v_nfltmax, v_a, _mm256_castsi256_ps(v_maski32)); // mask => -FLT_MAX - } - - v_a = _mm256_blendv_ps(v_max, v_a, _mm256_castsi256_ps(mask)); - v_max = _mm256_max_ps(v_max, v_a); - _mm256_maskstore_ps(a + i, mask, v_a); - } - hmax(v_max); - max = _mm256_cvtss_f32(v_max); -#else - for (size_t i = 0; i < size; i++) { - a[i] *= scale; - if (has_alibi) - a[i] += alibi[i]; - - if (has_attn_mask) - a[i] += attn_mask[i]; - - if (has_causal_mask) { - if (select_nfltmax_at_0) { - if (causal_mask[i] == 0) - a[i] = -FLT_MAX; - } else { - if (causal_mask[i] != 0) - a[i] = -FLT_MAX; - } - } - - max = a[i] > max ? a[i] : max; - } -#endif -} - -#if defined(HAVE_AVX512F) -inline void exp_ps_avx512(__m512& src) { - static __m512 exp_ln_flt_min_f = _mm512_castsi512_ps(_mm512_set1_epi32(0xc2aeac50)); // log(FLT_MIN) - static __m512 exp_ln_flt_max_f = _mm512_castsi512_ps(_mm512_set1_epi32(0x42b17218)); // log(FLT_MAX) - static __m512 exp_log2ef = _mm512_castsi512_ps(_mm512_set1_epi32(0x3fb8aa3b)); // log2(e) - static __m512 half = _mm512_castsi512_ps(_mm512_set1_epi32(0x3f000000)); // 0.5f - static __m512 ln2f = _mm512_castsi512_ps(_mm512_set1_epi32(0x3f317218)); // ln(2) - static __m512 one = _mm512_castsi512_ps(_mm512_set1_epi32(0x3f800000)); // 1.0f - static __m512i exponent_bias = _mm512_set1_epi32(0x0000007f); // 127 - static constexpr int n_mantissa_bits = 23; - static __m512 exp_pol1 = _mm512_castsi512_ps(_mm512_set1_epi32(0x3f7ffffb)); // p1 = 0.999999701f - static __m512 exp_pol2 = _mm512_castsi512_ps(_mm512_set1_epi32(0x3efffee3)); // p2 = 0.499991506f - static __m512 exp_pol3 = _mm512_castsi512_ps(_mm512_set1_epi32(0x3e2aad40)); // p3 = 0.166676521f - static __m512 exp_pol4 = _mm512_castsi512_ps(_mm512_set1_epi32(0x3d2b9d0d)); // p4 = 0.0418978221f - static __m512 exp_pol5 = _mm512_castsi512_ps(_mm512_set1_epi32(0x3c07cfce)); // p5 = 0.00828929059f - static __m512 two = _mm512_castsi512_ps(_mm512_set1_epi32(0x40000000)); // 2 - // exp(x) = - // = exp(n * ln(2) + r) // divide x by ln(2) and get quot and rem - // = 2^n * exp(r) // simplify the exp(n*ln(2)) expression - - // get mask of values lower than log(FLT_MIN) to zero them in the output - auto zero_mask = _mm512_cmp_ps_mask(src, exp_ln_flt_min_f, _CMP_LT_OS); - - // clip src - src = _mm512_min_ps(src, exp_ln_flt_max_f); - src = _mm512_max_ps(src, exp_ln_flt_min_f); - - // aux1 : r - auto aux1 = src; - - // calculate exp(x) - // fx = x * log2(e) + 0.5 - src = _mm512_mul_ps(src, exp_log2ef); - src = _mm512_add_ps(src, half); - - // tmp = floorf(fx) - src = _mm512_floor_ps(src); - - // aux1 = x - fx * ln2 - aux1 = _mm512_fnmadd_ps(src, ln2f, aux1); - // We do not count 2^n here, because n can reach 128 and 2^128 is not - // representable by fp32, so to get around this problem, instead of computing - // 2^n * exp(r) will be counted 2*2^(n-1)*exp(r), because 2^127 - // and 2 are numbers representable in fp32. - - // compute 2^(n-1) - src = _mm512_sub_ps(src, one); - auto aux2_i = _mm512_cvtps_epi32(src); - aux2_i = _mm512_add_epi32(aux2_i, exponent_bias); - aux2_i = _mm512_slli_epi32(aux2_i, n_mantissa_bits); - - // set zeroes at those points which were < log(FLT_MIN) - auto zero = _mm512_setzero_ps(); - auto aux2 = _mm512_mask_blend_ps(zero_mask, _mm512_castsi512_ps(aux2_i), zero); - - // compute polynomial - src = exp_pol5; - src = _mm512_fmadd_ps(src, aux1, exp_pol4); - src = _mm512_fmadd_ps(src, aux1, exp_pol3); - src = _mm512_fmadd_ps(src, aux1, exp_pol2); - src = _mm512_fmadd_ps(src, aux1, exp_pol1); - src = _mm512_fmadd_ps(src, aux1, one); - - // y = y * 2^n - src = _mm512_mul_ps(src, aux2); - src = _mm512_mul_ps(src, two); -} -#endif - -inline void exp_reduce_sum(float* a, const float max, const size_t size, float& sum) { -#if defined(HAVE_AVX512F) - size_t i = 0; - __m512 v_a; - auto v_max = _mm512_set1_ps(max); - auto v_sum = _mm512_set1_ps(0.0f); - while (i + vec_len_f32_avx512 <= size) { - v_a = _mm512_loadu_ps(a + i); - v_a = _mm512_sub_ps(v_a, v_max); - exp_ps_avx512(v_a); - v_sum = _mm512_add_ps(v_sum, v_a); - _mm512_storeu_ps(a + i, v_a); - i += vec_len_f32_avx512; - } - - if (i < size) { - __mmask16 mask = (1 << (size - i)) - 1; - v_a = _mm512_maskz_loadu_ps(mask, a + i); - v_a = _mm512_sub_ps(v_a, v_max); - exp_ps_avx512(v_a); - v_sum = _mm512_mask_add_ps(v_sum, mask, v_a, v_sum); - _mm512_mask_storeu_ps(a + i, mask, v_a); - } - sum = _mm512_reduce_add_ps(v_sum); -#elif defined(HAVE_AVX2) - size_t i = 0; - __m256 v_a; - auto v_max = _mm256_set1_ps(max); - auto v_sum = _mm256_set1_ps(0.0f); - while (i + vec_len_f32_avx2 <= size) { - v_a = _mm256_loadu_ps(a + i); - v_a = _mm256_sub_ps(v_a, v_max); - exp_ps_avx2(v_a); - v_sum = _mm256_add_ps(v_sum, v_a); - _mm256_storeu_ps(a + i, v_a); - i += vec_len_f32_avx2; - } - - if (i < size) { - auto mask = get_mask(size - i); - v_a = _mm256_maskload_ps(a + i, mask); - v_a = _mm256_sub_ps(v_a, v_max); - exp_ps_avx2(v_a); - v_a = _mm256_blendv_ps(_mm256_setzero_ps(), v_a, _mm256_castsi256_ps(mask)); - v_sum = _mm256_add_ps(v_a, v_sum); - _mm256_maskstore_ps(a + i, mask, v_a); - } - hsum(v_sum); - sum = _mm256_cvtss_f32(v_sum); -#else - for (size_t i = 0; i < size; i++) { - a[i] = exp(a[i] - max); - sum += a[i]; - } -#endif -} - -inline void multiply_scalar(float* a, float* a_dst, const float val, const size_t size) { -#if defined(HAVE_AVX512F) - auto v_scale = _mm512_set1_ps(val); - __m512 v_a = {0}; - size_t i = 0; - while (i + vec_len_f32_avx512 <= size) { - v_a = _mm512_loadu_ps(a + i); - v_a = _mm512_mul_ps(v_a, v_scale); - _mm512_storeu_ps(a_dst + i, v_a); - i += vec_len_f32_avx512; - } - if (i < size) { - __mmask16 mask = (1 << (size - i)) - 1; - v_a = _mm512_maskz_loadu_ps(mask, a + i); - v_a = _mm512_mul_ps(v_a, v_scale); - _mm512_mask_storeu_ps(a_dst + i, mask, v_a); - } -#elif defined(HAVE_AVX2) - auto v_scale = _mm256_set1_ps(val); - __m256 v_a = {0}; - size_t i = 0; - while (i + vec_len_f32_avx2 <= size) { - v_a = _mm256_loadu_ps(a + i); - v_a = _mm256_mul_ps(v_a, v_scale); - _mm256_storeu_ps(a_dst + i, v_a); - i += vec_len_f32_avx2; - } - if (i < size) { - auto mask = get_mask(size - i); - v_a = _mm256_maskload_ps(a + i, mask); - v_a = _mm256_mul_ps(v_a, v_scale); - _mm256_maskstore_ps(a_dst + i, mask, v_a); - } -#else - for (size_t i = 0; i < size; i++) { - a_dst[i] = a[i] * val; - } -#endif -} - -inline void multiply_scalar(float* a, ov::bfloat16* a_dst, const float val, const size_t size) { -#if defined(HAVE_AVX512F) - auto v_scale = _mm512_set1_ps(val); - __m512 v_a = {0}; - size_t i = 0; - while (i + vec_len_f32_avx512 <= size) { - v_a = _mm512_loadu_ps(a + i); - v_a = _mm512_mul_ps(v_a, v_scale); - mm512_uni_storeu_ps(a_dst + i, v_a); - i += vec_len_f32_avx512; - } - if (i < size) { - __mmask16 mask = (1 << (size - i)) - 1; - v_a = _mm512_maskz_loadu_ps(mask, a + i); - v_a = _mm512_mul_ps(v_a, v_scale); - mm512_uni_mask_storeu_ps(a_dst + i, mask, v_a); - } -#else - for (size_t i = 0; i < size; i++) { - a_dst[i] = a[i] * val; - } -#endif -} void attn_softmax(float* a, void* a_dst, @@ -542,38 +33,9 @@ void attn_softmax(float* a, size_t len, size_t total_size, 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[] = { - 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 - }; - 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); - - float sum = 0.0f; - // exp sum - exp_reduce_sum(a, max, len, sum); - // divide sum - float scalar = 1.0f / sum; - if (dst_precision == ov::element::f32) { - multiply_scalar(a, static_cast(a_dst), scalar, len); - // apply causual mask to final result instead of attn_score - if (total_size > len) - memset(static_cast(a_dst) + len, 0, sizeof(float) * (total_size - len)); - } else { - multiply_scalar(a, static_cast(a_dst), scalar, len); - // apply causual mask to final result instead of attn_score - if (total_size > len) - memset(static_cast(a_dst) + len, 0, sizeof(ov::bfloat16) * (total_size - len)); - } + attn_softmax_kernel(a, a_dst, scale, alibi, attn_mask, causal_mask, select_nfltmax_at_0, len, total_size, dst_precision); } + } // namespace XARCH } // namespace Cpu } // namespace Extensions 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 46fedd048c32d2..0cfd1591e1e641 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 @@ -1,6 +1,7 @@ // Copyright (C) 2018-2023 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // +#pragma once #include #include 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 new file mode 100644 index 00000000000000..e698b199872b72 --- /dev/null +++ b/src/plugins/intel_cpu/src/nodes/kernels/scaled_attn/softmax_kernel.hpp @@ -0,0 +1,576 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// +#pragma once + +#include +#include +#include +#include +#include + +#include "common.hpp" + +namespace InferenceEngine { +namespace Extensions { +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 + x = _mm256_max_ps(x, y); // X: 01 12 23 30 45 56 67 74 + y = _mm256_permute_ps(x, 0x4e); // y: 23 30 01 12 67 74 45 56 + x = _mm256_max_ps(x, y); // x: 0123 x x x 4567 x x x + y = _mm256_permute2f128_ps(x, x, 1); // y: 4567 x x x 0123 x x x + x = _mm256_max_ps(x, y); // x: 01234567 x x x x x x x +} + +inline void exp_ps_avx2(__m256& src) { + static __m256 exp_ln_flt_min_f = _mm256_castsi256_ps(_mm256_set1_epi32(0xc2aeac50)); // log(FLT_MIN) + static __m256 exp_ln_flt_max_f = _mm256_castsi256_ps(_mm256_set1_epi32(0x42b17218)); // log(FLT_MAX) + static __m256 exp_log2ef = _mm256_castsi256_ps(_mm256_set1_epi32(0x3fb8aa3b)); // log2(e) + static __m256 half = _mm256_castsi256_ps(_mm256_set1_epi32(0x3f000000)); // 0.5f + static __m256 ln2f = _mm256_castsi256_ps(_mm256_set1_epi32(0x3f317218)); // ln(2) + static __m256 one = _mm256_castsi256_ps(_mm256_set1_epi32(0x3f800000)); // 1.0f + static __m256i exponent_bias = _mm256_set1_epi32(0x0000007f); // 127 + static constexpr int n_mantissa_bits = 23; + static __m256 exp_pol1 = _mm256_castsi256_ps(_mm256_set1_epi32(0x3f7ffffb)); // p1 = 0.999999701f + static __m256 exp_pol2 = _mm256_castsi256_ps(_mm256_set1_epi32(0x3efffee3)); // p2 = 0.499991506f + static __m256 exp_pol3 = _mm256_castsi256_ps(_mm256_set1_epi32(0x3e2aad40)); // p3 = 0.166676521f + static __m256 exp_pol4 = _mm256_castsi256_ps(_mm256_set1_epi32(0x3d2b9d0d)); // p4 = 0.0418978221f + static __m256 exp_pol5 = _mm256_castsi256_ps(_mm256_set1_epi32(0x3c07cfce)); // p5 = 0.00828929059f + static __m256 two = _mm256_castsi256_ps(_mm256_set1_epi32(0x40000000)); // 2 + // exp(x) = + // = exp(n * ln(2) + r) // divide x by ln(2) and get quot and rem + // = 2^n * exp(r) // simplify the exp(n*ln(2)) expression + + // get mask of values lower than log(FLT_MIN) to zero them in the output + auto zero_mask = _mm256_cmp_ps(src, exp_ln_flt_min_f, _CMP_LT_OS); + + // clip src + src = _mm256_min_ps(src, exp_ln_flt_max_f); + src = _mm256_max_ps(src, exp_ln_flt_min_f); + + // aux1 : r + auto aux1 = src; + + // calculate exp(x) + // fx = x * log2(e) + 0.5 + src = _mm256_mul_ps(src, exp_log2ef); + src = _mm256_add_ps(src, half); + + // tmp = floorf(fx) + src = _mm256_floor_ps(src); + + // aux1 = x - fx * ln2 + aux1 = _mm256_fnmadd_ps(src, ln2f, aux1); + + // We do not count 2^n here, because n can reach 128 and 2^128 is not + // representable by fp32, so to get around this problem, instead of computing + // 2^n * exp(r) will be counted 2*2^(n-1)*exp(r), because 2^127 + // and 2 are numbers representable in fp32. + + // compute 2^(n-1) + src = _mm256_sub_ps(src, one); + auto aux2_i = _mm256_cvtps_epi32(src); + aux2_i = _mm256_add_epi32(aux2_i, exponent_bias); + aux2_i = _mm256_slli_epi32(aux2_i, n_mantissa_bits); + + // set zeroes at those points which were < log(FLT_MIN) + auto zero = _mm256_setzero_ps(); + auto aux2 = _mm256_blendv_ps(_mm256_castsi256_ps(aux2_i), zero, zero_mask); + + // compute polynomial + src = exp_pol5; + src = _mm256_fmadd_ps(src, aux1, exp_pol4); + src = _mm256_fmadd_ps(src, aux1, exp_pol3); + src = _mm256_fmadd_ps(src, aux1, exp_pol2); + src = _mm256_fmadd_ps(src, aux1, exp_pol1); + src = _mm256_fmadd_ps(src, aux1, one); + + // y = y * 2^n + src = _mm256_mul_ps(src, aux2); + src = _mm256_mul_ps(src, two); +} +#endif + +inline void scale_add_reduce_max(float* a, const float scale, const float* b, const size_t size, float& max) { +#if defined(HAVE_AVX512F) + auto v_max = _mm512_set1_ps(std::numeric_limits::lowest()); + auto v_scale = _mm512_set1_ps(scale); + auto v_a = v_max; + auto v_b = v_max; + size_t i = 0; + // process vector body + while (i + vec_len_f32_avx512 <= size) { + v_a = _mm512_loadu_ps(a + i); + v_b = _mm512_loadu_ps(b + i); + v_a = _mm512_fmadd_ps(v_a, v_scale, v_b); + v_max = _mm512_max_ps(v_max, v_a); + _mm512_storeu_ps(a + i, v_a); + i += vec_len_f32_avx512; + } + + // process tails + if (i < size) { + __mmask16 mask = (1 << (size - i)) - 1; + v_a = _mm512_maskz_loadu_ps(mask, a + i); + v_b = _mm512_maskz_loadu_ps(mask, b + i); + v_a = _mm512_fmadd_ps(v_a, v_scale, v_b); + v_max = _mm512_mask_max_ps(v_max, mask, v_a, v_max); + _mm512_mask_storeu_ps(a + i, mask, v_a); + } + + max = _mm512_reduce_max_ps(v_max); +#elif defined(HAVE_AVX2) + auto v_max = _mm256_set1_ps(std::numeric_limits::lowest()); + auto v_scale = _mm256_set1_ps(scale); + auto v_a = v_max; + auto v_b = v_max; + size_t i = 0; + // process vector body + while (i + vec_len_f32_avx2 <= size) { + v_a = _mm256_loadu_ps(a + i); + v_b = _mm256_loadu_ps(b + i); + v_a = _mm256_fmadd_ps(v_a, v_scale, v_b); + v_max = _mm256_max_ps(v_max, v_a); + _mm256_storeu_ps(a + i, v_a); + i += vec_len_f32_avx2; + } + + // process tails + if (i < size) { + auto mask = get_mask(size - i); + v_a = _mm256_maskload_ps(a + i, mask); + v_b = _mm256_maskload_ps(b + i, mask); + v_a = _mm256_fmadd_ps(v_a, v_scale, v_b); + v_a = _mm256_blendv_ps(v_max, v_a, _mm256_castsi256_ps(mask)); + v_max = _mm256_max_ps(v_max, v_a); + _mm256_maskstore_ps(a + i, mask, v_a); + } + hmax(v_max); + max = _mm256_cvtss_f32(v_max); +#else + for (size_t i = 0; i < size; i++) { + a[i] *= scale; + a[i] += b[i]; + max = a[i] > max ? a[i] : max; + } +#endif +} +template +inline void scale_add2_reduce_max(float* a, + float scale, + const float* alibi, + const float* attn_mask, + const uint8_t* causal_mask, + bool select_nfltmax_at_0, // true: 0 in mask set -FLT_MAX + size_t size, + float& max) { +#if defined(HAVE_AVX512F) + auto v_max = _mm512_set1_ps(std::numeric_limits::lowest()); + auto v_scale = _mm512_set1_ps(scale); + auto v_a = v_max; + size_t i = 0; + auto v_zeroi32 = _mm512_setzero_epi32(); + auto v_nfltmax = _mm512_set1_ps(-FLT_MAX); + auto kmask_xor = _cvtu32_mask16(select_nfltmax_at_0 ? 0xFFFF : 0); + // process vector body + while (i + vec_len_f32_avx512 <= size) { + v_a = _mm512_loadu_ps(a + i); + v_a = _mm512_mul_ps(v_a, v_scale); + + if (has_alibi) { + auto v_mask = _mm512_loadu_ps(alibi + i); + v_a = _mm512_add_ps(v_a, v_mask); + } + + if (has_attn_mask) { + auto v_mask = _mm512_loadu_ps(attn_mask + i); + v_a = _mm512_add_ps(v_a, v_mask); + } + + if (has_causal_mask) { + auto v_maski8 = _mm_loadu_si128(reinterpret_cast<__m128i const*>(causal_mask + i)); + auto v_maski32 = _mm512_cvtepi8_epi32(v_maski8); + auto kmask = _mm512_cmp_epi32_mask(v_maski32, v_zeroi32, _MM_CMPINT_NE); // !=0 + kmask = _kxor_mask16(kmask, kmask_xor); // reverse, mask at ==0 + v_a = _mm512_mask_blend_ps(kmask, v_a, v_nfltmax); // mask => -FLT_MAX + } + v_max = _mm512_max_ps(v_max, v_a); + _mm512_storeu_ps(a + i, v_a); + i += vec_len_f32_avx512; + } + + // process tails + if (i < size) { + __mmask16 mask = (1 << (size - i)) - 1; + v_a = _mm512_maskz_loadu_ps(mask, a + i); + v_a = _mm512_mul_ps(v_a, v_scale); + + if (has_alibi) { + auto v_mask = _mm512_maskz_loadu_ps(mask, alibi + i); + v_a = _mm512_add_ps(v_a, v_mask); + } + + if (has_attn_mask) { + auto v_mask = _mm512_maskz_loadu_ps(mask, attn_mask + i); + v_a = _mm512_add_ps(v_a, v_mask); + } + + if (has_causal_mask) { + auto v_maski8 = _mm_loadu_si128(reinterpret_cast<__m128i const*>(causal_mask + i)); + auto v_maski32 = _mm512_cvtepi8_epi32(v_maski8); + auto kmask = _mm512_cmp_epi32_mask(v_maski32, v_zeroi32, _MM_CMPINT_NE); // !=0 + kmask = _kxor_mask16(kmask, kmask_xor); // reverse, mask at ==0 + v_a = _mm512_mask_blend_ps(kmask, v_a, v_nfltmax); // mask => -FLT_MAX + } + v_max = _mm512_mask_max_ps(v_max, mask, v_a, v_max); + _mm512_mask_storeu_ps(a + i, mask, v_a); + } + + max = _mm512_reduce_max_ps(v_max); +#elif defined(HAVE_AVX2) + auto v_max = _mm256_set1_ps(std::numeric_limits::lowest()); + auto v_scale = _mm256_set1_ps(scale); + auto v_a = v_max; + auto v_zeroi32 = _mm256_setzero_si256(); + auto v_mask_xor = _mm256_set1_epi32(select_nfltmax_at_0 ? -1 : 0); + auto v_nfltmax = _mm256_set1_ps(-FLT_MAX); + size_t i = 0; + // process vector body + while (i + vec_len_f32_avx2 <= size) { + v_a = _mm256_loadu_ps(a + i); + v_a = _mm256_mul_ps(v_a, v_scale); + + if (has_alibi) { + auto v_mask = _mm256_loadu_ps(alibi + i); + v_a = _mm256_add_ps(v_a, v_mask); + } + + if (has_attn_mask) { + auto v_mask = _mm256_loadu_ps(attn_mask + i); + v_a = _mm256_add_ps(v_a, v_mask); + } + + if (has_causal_mask) { + auto v_maski8 = _mm_loadu_si128(reinterpret_cast<__m128i const*>(causal_mask + i)); + auto v_maski32 = _mm256_cvtepi8_epi32(v_maski8); + v_maski32 = _mm256_cmpeq_epi32(v_maski32, v_zeroi32); // ==0 + v_maski32 = _mm256_xor_si256(v_maski32, v_mask_xor); // reverse, mask at ==0 + v_a = _mm256_blendv_ps(v_nfltmax, v_a, _mm256_castsi256_ps(v_maski32)); // mask => -FLT_MAX + } + + v_max = _mm256_max_ps(v_max, v_a); + _mm256_storeu_ps(a + i, v_a); + i += vec_len_f32_avx2; + } + + // process tails + if (i < size) { + auto mask = get_mask(size - i); + v_a = _mm256_maskload_ps(a + i, mask); + v_a = _mm256_mul_ps(v_a, v_scale); + + if (has_alibi) { + auto v_mask = _mm256_maskload_ps(alibi + i, mask); + v_a = _mm256_add_ps(v_a, v_mask); + } + + if (has_attn_mask) { + auto v_mask = _mm256_maskload_ps(attn_mask + i, mask); + v_a = _mm256_add_ps(v_a, v_mask); + } + + if (has_causal_mask) { + auto v_maski8 = _mm_loadu_si128(reinterpret_cast<__m128i const*>(causal_mask + i)); + auto v_maski32 = _mm256_cvtepi8_epi32(v_maski8); + v_maski32 = _mm256_cmpeq_epi32(v_maski32, v_zeroi32); // ==0 + v_maski32 = _mm256_xor_si256(v_maski32, v_mask_xor); // reverse, mask at ==0 + v_a = _mm256_blendv_ps(v_nfltmax, v_a, _mm256_castsi256_ps(v_maski32)); // mask => -FLT_MAX + } + + v_a = _mm256_blendv_ps(v_max, v_a, _mm256_castsi256_ps(mask)); + v_max = _mm256_max_ps(v_max, v_a); + _mm256_maskstore_ps(a + i, mask, v_a); + } + hmax(v_max); + max = _mm256_cvtss_f32(v_max); +#else + for (size_t i = 0; i < size; i++) { + a[i] *= scale; + if (has_alibi) + a[i] += alibi[i]; + + if (has_attn_mask) + a[i] += attn_mask[i]; + + if (has_causal_mask) { + if (select_nfltmax_at_0) { + if (causal_mask[i] == 0) + a[i] = -FLT_MAX; + } else { + if (causal_mask[i] != 0) + a[i] = -FLT_MAX; + } + } + + max = a[i] > max ? a[i] : max; + } +#endif +} + +#if defined(HAVE_AVX512F) +inline void exp_ps_avx512(__m512& src) { + static __m512 exp_ln_flt_min_f = _mm512_castsi512_ps(_mm512_set1_epi32(0xc2aeac50)); // log(FLT_MIN) + static __m512 exp_ln_flt_max_f = _mm512_castsi512_ps(_mm512_set1_epi32(0x42b17218)); // log(FLT_MAX) + static __m512 exp_log2ef = _mm512_castsi512_ps(_mm512_set1_epi32(0x3fb8aa3b)); // log2(e) + static __m512 half = _mm512_castsi512_ps(_mm512_set1_epi32(0x3f000000)); // 0.5f + static __m512 ln2f = _mm512_castsi512_ps(_mm512_set1_epi32(0x3f317218)); // ln(2) + static __m512 one = _mm512_castsi512_ps(_mm512_set1_epi32(0x3f800000)); // 1.0f + static __m512i exponent_bias = _mm512_set1_epi32(0x0000007f); // 127 + static constexpr int n_mantissa_bits = 23; + static __m512 exp_pol1 = _mm512_castsi512_ps(_mm512_set1_epi32(0x3f7ffffb)); // p1 = 0.999999701f + static __m512 exp_pol2 = _mm512_castsi512_ps(_mm512_set1_epi32(0x3efffee3)); // p2 = 0.499991506f + static __m512 exp_pol3 = _mm512_castsi512_ps(_mm512_set1_epi32(0x3e2aad40)); // p3 = 0.166676521f + static __m512 exp_pol4 = _mm512_castsi512_ps(_mm512_set1_epi32(0x3d2b9d0d)); // p4 = 0.0418978221f + static __m512 exp_pol5 = _mm512_castsi512_ps(_mm512_set1_epi32(0x3c07cfce)); // p5 = 0.00828929059f + static __m512 two = _mm512_castsi512_ps(_mm512_set1_epi32(0x40000000)); // 2 + // exp(x) = + // = exp(n * ln(2) + r) // divide x by ln(2) and get quot and rem + // = 2^n * exp(r) // simplify the exp(n*ln(2)) expression + + // get mask of values lower than log(FLT_MIN) to zero them in the output + auto zero_mask = _mm512_cmp_ps_mask(src, exp_ln_flt_min_f, _CMP_LT_OS); + + // clip src + src = _mm512_min_ps(src, exp_ln_flt_max_f); + src = _mm512_max_ps(src, exp_ln_flt_min_f); + + // aux1 : r + auto aux1 = src; + + // calculate exp(x) + // fx = x * log2(e) + 0.5 + src = _mm512_mul_ps(src, exp_log2ef); + src = _mm512_add_ps(src, half); + + // tmp = floorf(fx) + src = _mm512_floor_ps(src); + + // aux1 = x - fx * ln2 + aux1 = _mm512_fnmadd_ps(src, ln2f, aux1); + // We do not count 2^n here, because n can reach 128 and 2^128 is not + // representable by fp32, so to get around this problem, instead of computing + // 2^n * exp(r) will be counted 2*2^(n-1)*exp(r), because 2^127 + // and 2 are numbers representable in fp32. + + // compute 2^(n-1) + src = _mm512_sub_ps(src, one); + auto aux2_i = _mm512_cvtps_epi32(src); + aux2_i = _mm512_add_epi32(aux2_i, exponent_bias); + aux2_i = _mm512_slli_epi32(aux2_i, n_mantissa_bits); + + // set zeroes at those points which were < log(FLT_MIN) + auto zero = _mm512_setzero_ps(); + auto aux2 = _mm512_mask_blend_ps(zero_mask, _mm512_castsi512_ps(aux2_i), zero); + + // compute polynomial + src = exp_pol5; + src = _mm512_fmadd_ps(src, aux1, exp_pol4); + src = _mm512_fmadd_ps(src, aux1, exp_pol3); + src = _mm512_fmadd_ps(src, aux1, exp_pol2); + src = _mm512_fmadd_ps(src, aux1, exp_pol1); + src = _mm512_fmadd_ps(src, aux1, one); + + // y = y * 2^n + src = _mm512_mul_ps(src, aux2); + src = _mm512_mul_ps(src, two); +} +#endif + +inline void exp_reduce_sum(float* a, const float max, const size_t size, float& sum) { +#if defined(HAVE_AVX512F) + size_t i = 0; + __m512 v_a; + auto v_max = _mm512_set1_ps(max); + auto v_sum = _mm512_set1_ps(0.0f); + while (i + vec_len_f32_avx512 <= size) { + v_a = _mm512_loadu_ps(a + i); + v_a = _mm512_sub_ps(v_a, v_max); + exp_ps_avx512(v_a); + v_sum = _mm512_add_ps(v_sum, v_a); + _mm512_storeu_ps(a + i, v_a); + i += vec_len_f32_avx512; + } + + if (i < size) { + __mmask16 mask = (1 << (size - i)) - 1; + v_a = _mm512_maskz_loadu_ps(mask, a + i); + v_a = _mm512_sub_ps(v_a, v_max); + exp_ps_avx512(v_a); + v_sum = _mm512_mask_add_ps(v_sum, mask, v_a, v_sum); + _mm512_mask_storeu_ps(a + i, mask, v_a); + } + sum = _mm512_reduce_add_ps(v_sum); +#elif defined(HAVE_AVX2) + size_t i = 0; + __m256 v_a; + auto v_max = _mm256_set1_ps(max); + auto v_sum = _mm256_set1_ps(0.0f); + while (i + vec_len_f32_avx2 <= size) { + v_a = _mm256_loadu_ps(a + i); + v_a = _mm256_sub_ps(v_a, v_max); + exp_ps_avx2(v_a); + v_sum = _mm256_add_ps(v_sum, v_a); + _mm256_storeu_ps(a + i, v_a); + i += vec_len_f32_avx2; + } + + if (i < size) { + auto mask = get_mask(size - i); + v_a = _mm256_maskload_ps(a + i, mask); + v_a = _mm256_sub_ps(v_a, v_max); + exp_ps_avx2(v_a); + v_a = _mm256_blendv_ps(_mm256_setzero_ps(), v_a, _mm256_castsi256_ps(mask)); + v_sum = _mm256_add_ps(v_a, v_sum); + _mm256_maskstore_ps(a + i, mask, v_a); + } + hsum(v_sum); + sum = _mm256_cvtss_f32(v_sum); +#else + for (size_t i = 0; i < size; i++) { + a[i] = exp(a[i] - max); + sum += a[i]; + } +#endif +} + +inline void multiply_scalar(float* a, float* a_dst, const float val, const size_t size) { +#if defined(HAVE_AVX512F) + auto v_scale = _mm512_set1_ps(val); + __m512 v_a = {0}; + size_t i = 0; + while (i + vec_len_f32_avx512 <= size) { + v_a = _mm512_loadu_ps(a + i); + v_a = _mm512_mul_ps(v_a, v_scale); + _mm512_storeu_ps(a_dst + i, v_a); + i += vec_len_f32_avx512; + } + if (i < size) { + __mmask16 mask = (1 << (size - i)) - 1; + v_a = _mm512_maskz_loadu_ps(mask, a + i); + v_a = _mm512_mul_ps(v_a, v_scale); + _mm512_mask_storeu_ps(a_dst + i, mask, v_a); + } +#elif defined(HAVE_AVX2) + auto v_scale = _mm256_set1_ps(val); + __m256 v_a = {0}; + size_t i = 0; + while (i + vec_len_f32_avx2 <= size) { + v_a = _mm256_loadu_ps(a + i); + v_a = _mm256_mul_ps(v_a, v_scale); + _mm256_storeu_ps(a_dst + i, v_a); + i += vec_len_f32_avx2; + } + if (i < size) { + auto mask = get_mask(size - i); + v_a = _mm256_maskload_ps(a + i, mask); + v_a = _mm256_mul_ps(v_a, v_scale); + _mm256_maskstore_ps(a_dst + i, mask, v_a); + } +#else + for (size_t i = 0; i < size; i++) { + a_dst[i] = a[i] * val; + } +#endif +} + +inline void multiply_scalar(float* a, ov::bfloat16* a_dst, const float val, const size_t size) { +#if defined(HAVE_AVX512F) + auto v_scale = _mm512_set1_ps(val); + __m512 v_a = {0}; + size_t i = 0; + while (i + vec_len_f32_avx512 <= size) { + v_a = _mm512_loadu_ps(a + i); + v_a = _mm512_mul_ps(v_a, v_scale); + mm512_uni_storeu_ps(a_dst + i, v_a); + i += vec_len_f32_avx512; + } + if (i < size) { + __mmask16 mask = (1 << (size - i)) - 1; + v_a = _mm512_maskz_loadu_ps(mask, a + i); + v_a = _mm512_mul_ps(v_a, v_scale); + mm512_uni_mask_storeu_ps(a_dst + i, mask, v_a); + } +#else + for (size_t i = 0; i < size; i++) { + a_dst[i] = a[i] * val; + } +#endif +} + +inline void attn_softmax_kernel(float* a, + void* a_dst, + float scale, + float* alibi, + float* attn_mask, + uint8_t* causal_mask, + bool select_nfltmax_at_0, + size_t len, + size_t total_size, + 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[] = { + 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 + }; + 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); + + float sum = 0.0f; + // exp sum + exp_reduce_sum(a, max, len, sum); + // divide sum + float scalar = 1.0f / sum; + if (dst_precision == ov::element::f32) { + multiply_scalar(a, static_cast(a_dst), scalar, len); + // apply causual mask to final result instead of attn_score + if (total_size > len) + memset(static_cast(a_dst) + len, 0, sizeof(float) * (total_size - len)); + } else { + multiply_scalar(a, static_cast(a_dst), scalar, len); + // apply causual mask to final result instead of attn_score + if (total_size > len) + memset(static_cast(a_dst) + len, 0, sizeof(ov::bfloat16) * (total_size - len)); + } +} + +} // namespace XARCH +} // namespace Cpu +} // namespace Extensions +} // namespace InferenceEngine \ No newline at end of file diff --git a/src/plugins/intel_cpu/src/nodes/multinomial.cpp b/src/plugins/intel_cpu/src/nodes/multinomial.cpp new file mode 100644 index 00000000000000..54f481d4f0e7e8 --- /dev/null +++ b/src/plugins/intel_cpu/src/nodes/multinomial.cpp @@ -0,0 +1,287 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "multinomial.hpp" + +#include "ie_ngraph_utils.hpp" +#include "openvino/op/multinomial.hpp" +#include "utils/bfloat16.hpp" + +namespace ov { +namespace intel_cpu { +namespace node { + +Multinomial::Multinomial(const std::shared_ptr& op, const GraphContext::CPtr& context) + : Node(op, context, NgraphShapeInferFactory(op, PortMask(NUM_SAMPLES_PORT))) { + std::string errorMessage; + if (!isSupportedOperation(op, errorMessage)) { + THROW_CPU_NODE_ERR(errorMessage); + } + + auto multinomial_op = as_type_ptr(op); + m_with_replacement = multinomial_op->get_with_replacement(); + m_global_seed = multinomial_op->get_global_seed(); + m_log_probs = multinomial_op->get_log_probs(); + m_op_seed = multinomial_op->get_op_seed(); + + m_num_samples_precision = ov::element::i32; + m_output_precision = multinomial_op->get_convert_type(); + + constant = ConstantType::NoConst; + + m_const_batch = op->get_input_partial_shape(PROBS_PORT)[0].is_static(); + m_const_inputs[PROBS_PORT] = is_type(op->get_input_node_ptr(PROBS_PORT)); + m_const_inputs[NUM_SAMPLES_PORT] = is_type(op->get_input_node_ptr(NUM_SAMPLES_PORT)); +} + +bool Multinomial::isSupportedOperation(const std::shared_ptr& op, std::string& errorMessage) noexcept { + try { + if (op->get_type_info() != op::v13::Multinomial::get_type_info_static()) { + errorMessage = "Only Multinomial operation from the opset13 is supported by the CPU plugin."; + return false; + } + } catch (...) { + return false; + } + return true; +} + +void Multinomial::getSupportedDescriptors() { + if (getParentEdges().size() != 2) { + THROW_CPU_NODE_ERR("has incorrect number of input edges."); + } + if (getChildEdges().size() != 1) { + THROW_CPU_NODE_ERR("has incorrect number of output edges."); + } +} + +void Multinomial::initSupportedPrimitiveDescriptors() { + m_probs_precision = getOriginalInputPrecisionAtPort(PROBS_PORT); + if (!one_of(m_probs_precision, ov::element::f32, ov::element::f16, ov::element::bf16)) { + m_probs_precision = ov::element::f32; + } + + addSupportedPrimDesc({{LayoutType::ncsp, m_probs_precision, m_const_inputs[PROBS_PORT]}, + {LayoutType::ncsp, m_num_samples_precision, m_const_inputs[NUM_SAMPLES_PORT]}}, + {{LayoutType::ncsp, m_output_precision}}, + ref_any); +} + +std::string Multinomial::getPrimitiveDescriptorType() const { + std::string str_type; + auto selectedPrimitiveDesc = getSelectedPrimitiveDescriptor(); + + impl_desc_type type = impl_desc_type::undef; + if (selectedPrimitiveDesc) { + type = selectedPrimitiveDesc->getImplementationType(); + } + + if (type == impl_desc_type::unknown) + str_type += "unknown_"; + if ((type & impl_desc_type::jit) == impl_desc_type::jit) + str_type += "jit_"; + if ((type & impl_desc_type::ref) == impl_desc_type::ref) + str_type += "ref_"; + if ((type & impl_desc_type::avx512) == impl_desc_type::avx512) + str_type += "avx512_"; + if ((type & impl_desc_type::avx2) == impl_desc_type::avx2) + str_type += "avx2_"; + if ((type & impl_desc_type::sse42) == impl_desc_type::sse42) + str_type += "sse42_"; + if ((type & impl_desc_type::any) == impl_desc_type::any) + str_type += "any_"; + + if (str_type.empty()) + str_type += "undef_"; + + if (selectedPrimitiveDesc) { + str_type += m_output_precision.get_type_name(); + } else { + str_type.pop_back(); + } + + return str_type; +} + +bool Multinomial::needShapeInfer() const { + return !(m_const_inputs[NUM_SAMPLES_PORT] && m_const_batch); +} + +bool Multinomial::needPrepareParams() const { + return true; +} + +void Multinomial::prepareParams() { + const auto& probs_shape = getParentEdgeAt(PROBS_PORT)->getMemory().getStaticDims(); + const auto& num_samples_shape = getParentEdgeAt(NUM_SAMPLES_PORT)->getMemory().getStaticDims(); + + if (probs_shape.size() != 2) { + THROW_CPU_NODE_ERR("has incompatible 'probs' shape ", + PartialShape(probs_shape), + ". Only 2D tensors are allowed."); + } + + if (num_samples_shape.size() != 1) { + THROW_CPU_NODE_ERR("has incompatible 'num_samples' shape ", + PartialShape(num_samples_shape), + ". Only scalar and 1D single element tensors are allowed."); + } + + if (m_num_samples_precision == ov::element::i32) { + m_samples_count = + reinterpret_cast(getParentEdgeAt(NUM_SAMPLES_PORT)->getMemoryPtr()->getData())[0]; + } else { + m_samples_count = + reinterpret_cast(getParentEdgeAt(NUM_SAMPLES_PORT)->getMemoryPtr()->getData())[0]; + } + + m_batches_count = probs_shape[0]; + m_probs_count = probs_shape[1]; + m_samples_probs_count = m_samples_count * m_probs_count; + m_input_elements_count = m_batches_count * m_probs_count; + m_output_elements_count = m_batches_count * m_samples_count; + m_batches_samples_probs_count = m_output_elements_count * m_probs_count; +} + +bool Multinomial::isExecutable() const { + return !isInputTensorAtPortEmpty(PROBS_PORT) && !isInputTensorAtPortEmpty(NUM_SAMPLES_PORT); +} + +bool Multinomial::created() const { + return getType() == Type::Multinomial; +} + +void Multinomial::execute(dnnl::stream strm) { + switch (m_probs_precision) { + case ov::element::f32: + return execute_probs_type(); + case ov::element::f16: + return execute_probs_type(); + case ov::element::bf16: + return execute_probs_type(); + default: + THROW_CPU_NODE_ERR("Multinomial CPU implementation does not support probs element type: ", m_probs_precision); + } +} + +void Multinomial::executeDynamicImpl(dnnl::stream strm) { + execute(strm); +} + +template +void Multinomial::execute_probs_type() { + switch (m_output_precision) { + case ov::element::i32: + return execute_convert_type(); + default: + THROW_CPU_NODE_ERR("Multinomial CPU implementation does not support output convert type: ", m_output_precision); + } +} + +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()); + + std::vector

m_cdf(m_input_elements_count); + std::vector

m_max_per_batch(m_batches_count); + std::vector

m_random_samples(m_output_elements_count); + + // exp & cumsum + if (m_log_probs) { + parallel_for(m_batches_count, [&](size_t idx) { + const auto start_idx = idx * m_probs_count; + m_cdf[start_idx] = std::exp(probs[start_idx]); + for (size_t prev = start_idx, curr = prev + 1; curr < (start_idx + m_probs_count); ++prev, ++curr) { + m_cdf[curr] = std::exp(probs[curr]) + m_cdf[prev]; + } + }); + } else { + parallel_for(m_batches_count, [&](size_t idx_batch) { + const auto start_idx = idx_batch * m_probs_count; + const auto* probs_start_idx = probs + start_idx; + std::partial_sum(probs_start_idx, probs_start_idx + m_probs_count, m_cdf.begin() + start_idx); + }); + } + + // TODO RandomUniform - should use RandomUniform kernel to match other frameworks' seed results + std::mt19937 gen; + if (m_global_seed == 0 && m_op_seed == 0) { + gen.seed(std::time(NULL)); + } else { + std::seed_seq seed{m_global_seed, m_op_seed}; + gen.seed(seed); + } + + const auto gen_max = static_cast(gen.max()); + std::generate(m_random_samples.begin(), m_random_samples.end(), [&]() { + return static_cast

(static_cast(gen()) / gen_max); + }); + + // max & divide + const auto min_value_of_max = std::numeric_limits

::min(); + parallel_for(m_batches_count, [&](size_t idx) { + m_max_per_batch[idx] = std::max(m_cdf[(idx + 1) * m_probs_count - 1], min_value_of_max); + }); + + parallel_for(m_input_elements_count, [&](size_t idx) { + size_t idx_max_elem = idx / m_probs_count; + m_cdf[idx] = m_cdf[idx] / m_max_per_batch[idx_max_elem]; + }); + + if (m_with_replacement) { + parallel_for(m_batches_samples_probs_count, [&](size_t idx) { + size_t idx_batch = idx / m_samples_probs_count; + size_t idx_num_samples_probs = idx % m_samples_probs_count; + size_t idx_prob = idx_num_samples_probs % m_probs_count; + size_t idx_sample = idx_num_samples_probs / m_probs_count; + + size_t idx_input = idx_batch * m_probs_count + idx_prob; + size_t idx_output = idx_batch * m_samples_count + idx_sample; + if (m_random_samples[idx_output] <= m_cdf[idx_input] && + (!idx_prob || m_random_samples[idx_output] > m_cdf[idx_input - 1])) { + output[idx_output] = static_cast(idx_prob); + } + }); + } else { // without replacement - adjust cdf after each sample drawn from batch, sequentially + parallel_for(m_batches_count, [&](size_t idx_batch) { + for (size_t idx_sample = 0LU; idx_sample < m_samples_count; ++idx_sample) { + size_t idx_input = idx_batch * m_probs_count; + size_t idx_output = idx_batch * m_samples_count + idx_sample; + + bool class_selected = false; + size_t selected_class = m_probs_count; + P sample_value = m_random_samples[idx_output]; + for (size_t idx_prob = 0LU; idx_prob < m_probs_count; ++idx_prob) { + if (sample_value <= m_cdf[idx_input + idx_prob]) { + output[idx_output] = static_cast(idx_prob); + selected_class = idx_prob; + class_selected = true; + break; + } + } + + if (class_selected) { + P class_probability; + if (selected_class) { + class_probability = m_cdf[idx_input + selected_class] - m_cdf[idx_input + selected_class - 1]; + } else { + class_probability = m_cdf[idx_input]; + } + P divisor = 1 - class_probability; + for (size_t idx_prob = 0LU; idx_prob < m_probs_count; ++idx_prob) { + if (idx_prob >= selected_class) { + m_cdf[idx_input + idx_prob] = m_cdf[idx_input + idx_prob] - class_probability; + } + m_cdf[idx_input + idx_prob] = m_cdf[idx_input + idx_prob] / divisor; + } + } + } + }); + } +} + +} // namespace node +} // namespace intel_cpu +} // namespace ov diff --git a/src/plugins/intel_cpu/src/nodes/multinomial.hpp b/src/plugins/intel_cpu/src/nodes/multinomial.hpp new file mode 100644 index 00000000000000..f492814633c7e0 --- /dev/null +++ b/src/plugins/intel_cpu/src/nodes/multinomial.hpp @@ -0,0 +1,80 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include +#include + +#include "ie_common.h" +#include "ie_parallel.hpp" +#include "node.h" + +namespace ov { +namespace intel_cpu { +namespace node { + +class Multinomial : public Node { +public: + Multinomial(const std::shared_ptr& op, const GraphContext::CPtr& context); + + void getSupportedDescriptors() override; + void initSupportedPrimitiveDescriptors() override; + std::string getPrimitiveDescriptorType() const override; + + bool created() const override; + + static bool isSupportedOperation(const std::shared_ptr& op, std::string& errorMessage) noexcept; + + bool needPrepareParams() const override; + void prepareParams() override; + + bool isExecutable() const override; + void execute(dnnl::stream strm) override; + void executeDynamicImpl(dnnl::stream strm) override; + bool canBeInPlace() const override { + return false; + } + +protected: + bool needShapeInfer() const override; + +private: + /// Multinomial params + bool m_with_replacement = false; + bool m_log_probs = false; + uint64_t m_global_seed = 0; + uint64_t m_op_seed = 0; + + /// Shape inference + static constexpr size_t PROBS_PORT = 0lu; + static constexpr size_t NUM_SAMPLES_PORT = 1lu; + static constexpr size_t OUTPUT_PORT = 0lu; + bool m_const_inputs[2] = {false, false}; + bool m_const_batch = false; + VectorDims m_output_shape = {}; + + /// General algorithm variables + ov::element::Type m_probs_precision; + ov::element::Type m_num_samples_precision; + ov::element::Type m_output_precision; + + size_t m_probs_count = 0; + size_t m_batches_count = 0; + size_t m_samples_count = 0; + size_t m_samples_probs_count = 0; + size_t m_input_elements_count = 0; + size_t m_output_elements_count = 0; + size_t m_batches_samples_probs_count = 0; + + template + void execute_probs_type(); + + template + void execute_convert_type(); +}; + +} // namespace node +} // namespace intel_cpu +} // namespace ov diff --git a/src/plugins/intel_cpu/src/nodes/reference.cpp b/src/plugins/intel_cpu/src/nodes/reference.cpp index b7e79de41fcd4a..b7774985dac231 100644 --- a/src/plugins/intel_cpu/src/nodes/reference.cpp +++ b/src/plugins/intel_cpu/src/nodes/reference.cpp @@ -72,7 +72,7 @@ void Reference::executeDynamicImpl(dnnl::stream strm) { if (mem_desc->isDefined()) { outputs.emplace_back(ovCoreNode->get_output_element_type(i), mem_desc->getShape().getStaticDims()); } else { - outputs.emplace_back(ovCoreNode->get_output_element_type(i), ov::util::make_dynamic_shape()); + outputs.emplace_back(ovCoreNode->get_output_element_type(i), ov::Shape{0}); } } } else { diff --git a/src/plugins/intel_cpu/src/nodes/reshape.cpp b/src/plugins/intel_cpu/src/nodes/reshape.cpp index d399b5bb5b58aa..4b9aea6967b132 100644 --- a/src/plugins/intel_cpu/src/nodes/reshape.cpp +++ b/src/plugins/intel_cpu/src/nodes/reshape.cpp @@ -65,9 +65,6 @@ Reshape::Reshape(const std::shared_ptr& op, const GraphContext::CPtr c } bool Reshape::needShapeInfer() const { - if (inputShapesModified()) { - return true; - } const auto& mem = getParentEdgesAtPort(1)[0]->getMemory(); if (lastSecondInputValues.empty()) { lastSecondInputValues.resize(mem.getStaticDims()[0], 0); @@ -81,6 +78,9 @@ bool Reshape::needShapeInfer() const { return true; } } + if (inputShapesModified()) { + return true; + } return false; } diff --git a/src/plugins/intel_cpu/src/nodes/rnn.cpp b/src/plugins/intel_cpu/src/nodes/rnn.cpp index 44fba765ceffc7..d7e4d204e64354 100644 --- a/src/plugins/intel_cpu/src/nodes/rnn.cpp +++ b/src/plugins/intel_cpu/src/nodes/rnn.cpp @@ -746,24 +746,23 @@ void RNN::fillSequenceDesc() { template void RNN::fillWeights(const int *gate_map, const size_t wIdx, const size_t rIdx) { - const auto& weightPrec = DnnlExtensionUtils::DataTypeToElementType(inDataTypes[wIdx]); - const auto& targetWeightPrec = DnnlExtensionUtils::DataTypeToElementType(weightsByinputDataType.at(inDataTypes[xIdx])); + const auto& weightPrec = DnnlExtensionUtils::DataTypeToElementType(inDataTypes[wIdx]); + const auto& targetWeightDataType = weightsByinputDataType.at(inDataTypes[xIdx]); + const auto& targetWeightPrec = DnnlExtensionUtils::DataTypeToElementType(targetWeightDataType); // create weight blobs (data and state part) - const VectorDims dims_w = { L, D, DC, G, SC }; - TensorDesc w_data_desc(InferenceEngine::details::convertPrecision(targetWeightPrec), dims_w, getWeightsLayoutByDims(dims_w, false)); + const VectorDims dims_w = {L, D, DC, G, SC}; + auto w_data_desc = DnnlBlockedMemoryDesc(Shape(dims_w), targetWeightDataType, getWeightsFormatTagByDims(dims_w)); + MemoryPtr w_data_mem = std::make_shared(getEngine(), w_data_desc); + auto w_ptr = static_cast(w_data_mem->getData()); - Blob::Ptr w_data_mem = make_shared_blob(w_data_desc); - w_data_mem->allocate(); - auto w_ptr = static_cast(w_data_mem->buffer()); if (w_ptr == nullptr) OPENVINO_THROW("NotAllocated: Internal blob was not allocated for node ", getName(), "."); - const VectorDims dims_s = { L, D, SC, G, SC }; - TensorDesc w_state_desc(InferenceEngine::details::convertPrecision(targetWeightPrec), dims_s, getWeightsLayoutByDims(dims_s, false)); - Blob::Ptr w_state_mem = make_shared_blob(w_state_desc); - w_state_mem->allocate(); - auto r_ptr = static_cast(w_state_mem->buffer()); + const VectorDims dims_s = {L, D, SC, G, SC}; + auto w_state_desc = DnnlBlockedMemoryDesc(Shape(dims_s), targetWeightDataType, getWeightsFormatTagByDims(dims_s)); + MemoryPtr w_state_mem = std::make_shared(getEngine(), w_state_desc); + auto r_ptr = static_cast(w_state_mem->getData()); if (r_ptr == nullptr) OPENVINO_THROW("NotAllocated: Internal blob was not allocated for node ", getName(), "."); @@ -803,7 +802,6 @@ void RNN::fillWeights(const int *gate_map, const size_t wIdx, const size_t rIdx) } } } - internalBlobs.push_back(w_data_mem); internalBlobs.push_back(w_state_mem); } @@ -817,10 +815,11 @@ void RNN::fillBiases(const int *gate_map) { } VectorDims dims_b = { L, D, Gb, SC }; - TensorDesc w_bias_data_desc(InferenceEngine::details::convertPrecision(Prec), dims_b, getWeightsLayoutByDims(dims_b, false)); - Blob::Ptr w_bias_data_mem = make_shared_blob(w_bias_data_desc); - w_bias_data_mem->allocate(); - auto b_ptr = static_cast(w_bias_data_mem->buffer()); + + auto _data_type = DnnlExtensionUtils::ElementTypeToDataType(Prec); + auto w_bias_data_desc = DnnlBlockedMemoryDesc(Shape(dims_b), _data_type, getWeightsFormatTagByDims(dims_b)); + MemoryPtr w_bias_data_mem = std::make_shared(getEngine(), w_bias_data_desc); + auto b_ptr = static_cast(w_bias_data_mem->getData()); if (b_ptr == nullptr) OPENVINO_THROW("NotAllocated: Internal blob was not allocated for node ", getName(), "."); diff --git a/src/plugins/intel_cpu/src/nodes/rope.cpp b/src/plugins/intel_cpu/src/nodes/rope.cpp index 5ec1aaa2183104..189b9a05023706 100644 --- a/src/plugins/intel_cpu/src/nodes/rope.cpp +++ b/src/plugins/intel_cpu/src/nodes/rope.cpp @@ -38,11 +38,11 @@ struct RoPE::RoPEExecutorRotateHalf : public RoPE::Executor { const RoPENode::Config& config, const std::vector& inputs, const std::vector& outputs) override { - ov::intel_cpu::PlainTensor t_src(inputs[0]); - ov::intel_cpu::PlainTensor t_cos(inputs[1]); - ov::intel_cpu::PlainTensor t_sin(inputs[2]); - ov::intel_cpu::PlainTensor t_dst(outputs[0]); - ov::intel_cpu::PlainTensor gather; + ov::intel_cpu::PlainTensor t_src(inputs[0]); + ov::intel_cpu::PlainTensor t_cos(inputs[1]); + ov::intel_cpu::PlainTensor t_sin(inputs[2]); + ov::intel_cpu::PlainTensor t_dst(outputs[0]); + ov::intel_cpu::PlainTensor gather; if (config.slice_stop - config.slice_start > 0) { t_src = t_src.slice(3, config.slice_start, config.slice_stop); @@ -54,6 +54,13 @@ struct RoPE::RoPEExecutorRotateHalf : public RoPE::Executor { gather.reset(inputs[config.gather_position_arg_id]); } + if (t_cos.m_rank == 2) { + t_cos = t_cos.reshape({1, 1, t_cos.size(0), t_cos.size(1)}); + } + if (t_sin.m_rank == 2) { + t_sin = t_sin.reshape({1, 1, t_sin.size(0), t_sin.size(1)}); + } + auto batch_size = t_src.size(0); auto head_cnt = t_src.size(1); auto seq_len = t_src.size(2); @@ -66,14 +73,14 @@ struct RoPE::RoPEExecutorRotateHalf : public RoPE::Executor { auto cos_pos = p; if (gather) { if (gather.m_rank == 4) - cos_pos = gather.at({b, h, p, 0}, true); + cos_pos = gather.at({b, h, p, 0}, true); else - cos_pos = gather.at({b, p}, true); + cos_pos = gather.at({b, p}, true); } - auto* src = &t_src.at({b, h, p, 0}); - auto* cos = &t_cos.at({b, h, cos_pos, 0}, true); - auto* sin = &t_sin.at({b, h, cos_pos, 0}, true); - auto* dst = &t_dst.at({b, h, p, 0}); + auto* src = &t_src.at({b, h, p, 0}); + auto* cos = &t_cos.at({b, h, cos_pos, 0}, true); + auto* sin = &t_sin.at({b, h, cos_pos, 0}, true); + auto* dst = &t_dst.at({b, h, p, 0}); size_t i = 0; for (; i < half_rotary_dims; i++) { @@ -95,9 +102,9 @@ struct RoPE::RoPEExecutorInterleaved : public RoPE::Executor { const RoPENode::Config& config, const std::vector& inputs, const std::vector& outputs) override { - ov::intel_cpu::PlainTensor t_src(inputs[0]); - ov::intel_cpu::PlainTensor t_sin_cos(inputs[1]); - ov::intel_cpu::PlainTensor t_dst(outputs[0]); + ov::intel_cpu::PlainTensor t_src(inputs[0]); + ov::intel_cpu::PlainTensor t_sin_cos(inputs[1]); + ov::intel_cpu::PlainTensor t_dst(outputs[0]); auto batch_size = t_src.size(0); auto seq_len = t_src.size(1); @@ -107,10 +114,10 @@ struct RoPE::RoPEExecutorInterleaved : public RoPE::Executor { auto rotary_dims = config.rotary_ndims; auto half_rotary_dims = rotary_dims / 2; parallel_for3d(batch_size, seq_len, head_cnt, [&](size_t b, size_t p, size_t h) { - auto* x = &t_src.at({b, p, h, 0}); - float* sin = &t_sin_cos.at({b, p, 0}, true); - float* cos = &t_sin_cos.at({b, p, half_rotary_dims}, true); - auto* dst = &t_dst.at({b, h, p, 0}); + auto* x = &t_src.at({b, p, h, 0}); + float* sin = &t_sin_cos.at({b, p, 0}, true); + float* cos = &t_sin_cos.at({b, p, half_rotary_dims}, true); + auto* dst = &t_dst.at({b, h, p, 0}); size_t i = 0; for (size_t j = 0; i < rotary_dims; i += 2, j++) { @@ -124,6 +131,48 @@ struct RoPE::RoPEExecutorInterleaved : public RoPE::Executor { } }; +template +struct RoPE::RoPEExecutorChatGLM : public RoPE::Executor { + void execute(dnnl::stream strm, + const RoPENode::Config& config, + const std::vector& inputs, + const std::vector& outputs) override { + ov::intel_cpu::PlainTensor t_src(inputs[0]); + ov::intel_cpu::PlainTensor t_cos_sin(inputs[1]); + ov::intel_cpu::PlainTensor t_dst(outputs[0]); + + // [seq_len, batch_size, (hidden_states_q + hidden_states_k + hidden_states_v)] + if (config.slice_stop - config.slice_start > 0) { + t_src = t_src.slice(2, config.slice_start, config.slice_stop); + } + auto seq_len = t_src.size(0); + auto batch_size = t_src.size(1); + + auto head_cnt = config.head_cnt; + auto head_size = config.head_size; + + auto rotary_dims = config.rotary_ndims; + + parallel_for3d(seq_len, batch_size, head_cnt, [&](size_t p, size_t b, size_t h) { + auto* src = &t_src.at({p, b, h * head_size}); + // [length, batch_size, ndims//2, 2] + auto* cos_sin = &t_cos_sin.at({p, b, 0, 0}, true); + auto* dst = &t_dst.at({p, b, h, 0}); + + size_t i = 0; + for (; i < rotary_dims; i += 2) { + auto cosv = cos_sin[i]; + auto sinv = cos_sin[i + 1]; + dst[i] = cosv * src[i] - sinv * src[i + 1]; + dst[i + 1] = sinv * src[i] + cosv * src[i + 1]; + } + for (; i < head_size; i++) { + dst[i] = src[i]; + } + }); + } +}; + void RoPE::initSupportedPrimitiveDescriptors() { if (!supportedPrimitiveDescriptors.empty()) return; @@ -132,7 +181,14 @@ void RoPE::initSupportedPrimitiveDescriptors() { auto rtPrecision = srcPrecision; auto CosSinPrecision = ov::element::f32; - if (m_config.is_interleaved) { + if (m_config.is_chatglm) { + if (rtPrecision == ov::element::bf16) { + m_executor = std::make_shared>(); + } else { + m_executor = std::make_shared>(); + rtPrecision = ov::element::f32; + } + } else if (m_config.is_interleaved) { OPENVINO_ASSERT(m_config.input_trans0213 == false); OPENVINO_ASSERT(m_config.slice_start == 0); OPENVINO_ASSERT(m_config.slice_stop == 0); diff --git a/src/plugins/intel_cpu/src/nodes/rope.h b/src/plugins/intel_cpu/src/nodes/rope.h index c1b2bbda3b3c0f..1f81ddf214322e 100644 --- a/src/plugins/intel_cpu/src/nodes/rope.h +++ b/src/plugins/intel_cpu/src/nodes/rope.h @@ -45,6 +45,8 @@ class RoPE : public Node { struct RoPEExecutorRotateHalf; template struct RoPEExecutorInterleaved; + template + struct RoPEExecutorChatGLM; RoPENode::Config m_config; std::shared_ptr m_executor; }; diff --git a/src/plugins/intel_cpu/src/nodes/scaled_attn.cpp b/src/plugins/intel_cpu/src/nodes/scaled_attn.cpp index 2ba51286e79bd2..c2d1ef17143337 100644 --- a/src/plugins/intel_cpu/src/nodes/scaled_attn.cpp +++ b/src/plugins/intel_cpu/src/nodes/scaled_attn.cpp @@ -28,12 +28,12 @@ #include "utils/plain_tensor.hpp" #include "kernels/scaled_attn/softmax.hpp" -#include "kernels/scaled_attn/dot_product.hpp" -#include "kernels/scaled_attn/acc_value.hpp" -#include "kernels/scaled_attn/reduce.hpp" +#include "kernels/scaled_attn/mha_single_token.hpp" +#include "kernels/scaled_attn/attn_memcpy.hpp" using namespace InferenceEngine; using namespace InferenceEngine::Extensions::Cpu::XARCH; +using namespace dnnl::impl::cpu::x64; namespace ov { namespace intel_cpu { @@ -77,9 +77,9 @@ struct MHAKernel { } } - PlainTensor causal_mask; + PlainTensor causal_mask; bool select_nfltmax_at_0; // set attn_score to -FLT_MAX when causal_mask[...] equal to this - void set_causal_mask(PlainTensor mask, bool _select_nfltmax_at_0) { + void set_causal_mask(PlainTensor mask, bool _select_nfltmax_at_0) { causal_mask = mask; select_nfltmax_at_0 = _select_nfltmax_at_0; } @@ -91,12 +91,12 @@ struct MHAKernel { // attention_mask [B, 1, q_len, kv_len] // output_emb [B, q_len, H*S] void operator()(dnnl::stream strm, - PlainTensor& query, - PlainTensor& present_key, - PlainTensor& present_value, - const PlainTensor& alibi_mask, - const PlainTensor& attention_mask, - PlainTensor& output_emb, + 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) { @@ -117,27 +117,27 @@ struct MHAKernel { for (size_t m = 0; m < q_len; m++) { // dot-product to get attention scores - auto* q = &query.at({b, h, m, 0}); + auto* q = &query.at({b, h, m, 0}); // how many key/values can be accessed causally auto ncausal = kv_len; // no causall mask is set and it's not fused into attention_mask if (auto_causal) ncausal = kv_len - q_len + m + 1; for (size_t n = 0; n < ncausal; n++) { - auto* k = &present_key.at({b, h, n, 0}, true); + auto* k = &present_key.at({b, h, n, 0}, true); attn_score[n] = dot_product(q, k, head_size, k_stride_s) * d_scale; // apply alibi tensor if (alibi_mask) - attn_score[n] += alibi_mask.at({b, h, m, n}, true); + attn_score[n] += alibi_mask.at({b, h, m, n}, true); // apply attention mask (maybe combined with causal_mask) if (attention_mask) - attn_score[n] += attention_mask.at({b, h, m, n}, true); + attn_score[n] += attention_mask.at({b, h, m, n}, true); // apply causal_mask if (causal_mask) { - bool is_zero = causal_mask.at({b, h, m, n}, true) == 0; + bool is_zero = causal_mask.at({b, h, m, n}, true) == 0; if (select_nfltmax_at_0) { if (is_zero) attn_score[n] = -FLT_MAX; @@ -155,12 +155,12 @@ struct MHAKernel { // linearly combine value word_vec.assign(head_size, 0.0f); for (size_t n = 0; n < ncausal; n++) { - auto* v = &present_value.at({b, h, n, 0}, true); + auto* v = &present_value.at({b, h, n, 0}, true); accumulate(word_vec.data(), v, head_size, attn_score[n]); } // output [B, L1, H*head_size] - auto* out = has_out_transpose ? &output_emb.at({b, m, h * head_size}) : &output_emb.at({b, h, m}); + auto* out = has_out_transpose ? &output_emb.at({b, m, h * head_size}) : &output_emb.at({b, h, m}); std::copy(word_vec.begin(), word_vec.end(), out); } }); @@ -218,23 +218,23 @@ struct MHAKernel { } } - 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()); + 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()); qk_prim.execute(strm, {{DNNL_ARG_SRC, q}, {DNNL_ARG_WEIGHTS, k}, {DNNL_ARG_DST, attn_score}}); } - void exec_kv(dnnl::stream strm, PlainTensor& present_value, PlainTensor& output_emb) { - dnnl::memory v(v_md, strm.get_engine(), present_value.data()); - dnnl::memory out(out_md, strm.get_engine(), output_emb.data()); + void exec_kv(dnnl::stream strm, PlainTensor& present_value, PlainTensor& output_emb) { + dnnl::memory v(v_md, strm.get_engine(), present_value.data()); + dnnl::memory out(out_md, strm.get_engine(), output_emb.data()); wv_prim.execute(strm, {{DNNL_ARG_SRC, attn_weight}, {DNNL_ARG_WEIGHTS, v}, {DNNL_ARG_DST, out}}); } - PlainTensor causal_mask; + PlainTensor causal_mask; bool select_nfltmax_at_0 = false; // set attn_score to -FLT_MAX when causal_mask[...] equal to this - void set_causal_mask(PlainTensor mask, bool _select_nfltmax_at_0) { + void set_causal_mask(PlainTensor mask, bool _select_nfltmax_at_0) { causal_mask = mask; select_nfltmax_at_0 = _select_nfltmax_at_0; } @@ -247,12 +247,12 @@ struct MHAKernel { // alibi [B, H, q_len, kv_len] // output_emb [B, L1, H*S] void operator()(dnnl::stream strm, - PlainTensor& query, - PlainTensor& present_key, - PlainTensor& present_value, - const PlainTensor& alibi_mask, - const PlainTensor& attention_mask, - PlainTensor& output_emb, + 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) { @@ -269,20 +269,20 @@ struct MHAKernel { prepare_prim(strm, B, H, Hk, q_len, kv_len, head_size, has_out_transpose); exec_qk(strm, query, present_key); - PlainTensor score; + PlainTensor score; score.resize({B, H, q_len, kv_len}, static_cast(attn_score.get_data_handle())); - PlainTensor weight; + PlainTensor weight; weight.resize({B, H, q_len, kv_len}, static_cast(attn_weight.get_data_handle())); // softmax 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; - attn_softmax(&score.at({b, h, m, 0}), - &weight.at({b, h, m, 0}), + 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, - causal_mask ? &causal_mask.at({b, h, m, 0}, true) : nullptr, + alibi_mask ? &alibi_mask.at({b, h, m, 0}, true) : nullptr, + attention_mask ? &attention_mask.at({b, h, m, 0}, true) : nullptr, + causal_mask ? &causal_mask.at({b, h, m, 0}, true) : nullptr, select_nfltmax_at_0, ncausal, kv_len, @@ -297,17 +297,17 @@ template <> struct MHAKernel { size_t m_block_size; // buffer to hold qk temp - std::vector> qk_buffers; + std::vector qk_buffers; MHAKernel() { m_block_size = 4; select_nfltmax_at_0 = false; - qk_buffers.resize(parallel_get_max_threads(), PlainTensor(true)); + qk_buffers.resize(parallel_get_max_threads(), PlainTensor(true)); } - PlainTensor causal_mask; + PlainTensor causal_mask; bool select_nfltmax_at_0; // set attn_score to -FLT_MAX when causal_mask[...] equal to this - void set_causal_mask(PlainTensor mask, bool _select_nfltmax_at_0) { + void set_causal_mask(PlainTensor mask, bool _select_nfltmax_at_0) { causal_mask = mask; select_nfltmax_at_0 = _select_nfltmax_at_0; } @@ -320,12 +320,12 @@ struct MHAKernel { // alibi // output_emb [B, L1, H*S] void operator()(dnnl::stream strm, - PlainTensor& query, - PlainTensor& present_key, - PlainTensor& present_value, - const PlainTensor& alibi_mask, - const PlainTensor& attention_mask, - PlainTensor& output_emb, + 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) { @@ -354,34 +354,34 @@ struct MHAKernel { auto m_cnt = m_end - m_start; auto kv_len_cache_align = (((kv_len * sizeof(float)) + 63) / 64 * 64) / sizeof(float); - qk_buf.resize({m_block_size, kv_len_cache_align}); - const float* q_ptr = &query.at({b, h, m_start, 0}); - const float* k_ptr = &present_key.at({b, h / h_each_group_len, 0, 0}); - const float* v_ptr = &present_value.at({b, h / h_each_group_len, 0, 0}); + qk_buf.resize({m_block_size, kv_len_cache_align}); + const float* q_ptr = &query.at({b, h, m_start, 0}); + const float* k_ptr = &present_key.at({b, h / h_each_group_len, 0, 0}); + const float* v_ptr = &present_value.at({b, h / h_each_group_len, 0, 0}); float* alibi_ptr = nullptr; auto alibi_stride = 0; if (alibi_mask) { - alibi_ptr = &alibi_mask.at({b, h, 0, 0}, true); + alibi_ptr = &alibi_mask.at({b, h, 0, 0}, true); if (alibi_mask.size(2) > 1) alibi_stride = alibi_mask.stride(2); } float* 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 = &attention_mask.at({b, h, 0, 0}, true); if (attention_mask.size(2) > 1) attn_mask_stride = attention_mask.stride(2); } uint8_t* cmask_ptr = nullptr; auto cmask_stride = 0; if (causal_mask) { - cmask_ptr = &causal_mask.at({b, h, 0, 0}, true); + cmask_ptr = &causal_mask.at({b, h, 0, 0}, true); if (causal_mask.size(2) > 1) cmask_stride = causal_mask.stride(2); } - float* qk = &(qk_buf.at({0, 0})); + float* qk = &(qk_buf.at({0, 0})); auto qk_m_stride = qk_buf.stride(0); if (k_stride_s == 1) @@ -440,7 +440,7 @@ struct MHAKernel { v_ptr, present_value.stride(2), 0.f, - has_out_transpose ? &output_emb.at({b, m_start, h * head_size}) : &output_emb.at({b, h, m_start}), + has_out_transpose ? &output_emb.at({b, m_start, h * head_size}) : &output_emb.at({b, h, m_start}), has_out_transpose ? output_emb.stride(1) : output_emb.stride(2), 1); }); @@ -449,143 +449,45 @@ struct MHAKernel { #endif // 2nd token case : only 1 token in query -template struct MHASingleToken { - PlainTensor m_attn_w; - PlainTensor m_temp; + PlainTensor m_attn_w; + PlainTensor m_temp; - MHASingleToken() : m_attn_w(true), m_temp(true), select_nfltmax_at_0(false) {} - - PlainTensor causal_mask; - bool select_nfltmax_at_0; // set attn_score to -FLT_MAX when causal_mask[...] equal to this - void set_causal_mask(PlainTensor mask, bool _select_nfltmax_at_0) { - causal_mask = mask; - select_nfltmax_at_0 = _select_nfltmax_at_0; - } + MHASingleToken() : m_attn_w(true), m_temp(true) {} // Q, K, V is ready, do attention // query [B, H, q_len, S] // present_key [B, H, kv_len, S] stride of last dim maybe > 1 // present_value [B, H, kv_len, S] - // attention_mask [B, 1, q_len, kv_len] // alibi - // output_emb [B, L1, H*S] - void operator()(PlainTensor& query, - PlainTensor& present_key, - PlainTensor& present_value, - const PlainTensor& alibi_mask, - const PlainTensor& attention_mask, - PlainTensor& output_emb, - const PlainTensor& beams, + // attention_mask [B, 1, q_len, kv_len] + // output_emb [B, L1, H, S] + void operator()(PlainTensor& query, + PlainTensor& present_key, + PlainTensor& present_value, + const PlainTensor& alibi_mask, + const PlainTensor& attention_mask, + PlainTensor& output_emb, + const PlainTensor& beams, bool has_out_transpose, bool auto_causal, float d_scale = 0.0f) { - auto B = query.size(0); - auto H = query.size(1); - auto q_len = query.size(2); - auto S = query.size(3); - auto kv_len = present_key.size(2); - - if (d_scale == 0.0f) - d_scale = 1.0f / sqrt(S); - - // use per-token kernel, for each k,v token - // attn mask is a matrix of q_len(kv_len) - m_attn_w.resize({B, H, q_len, kv_len}); - - parallel_for3d(B, H, kv_len, [&](size_t b, size_t h, size_t pk) { - // which batch item should be used at postion pk? - auto b_kv = beams ? beams.at({b, pk}) : b; - std::vector as(q_len), bs(q_len); - std::vector cs(q_len); - for (size_t pq = 0; pq < q_len; pq++) { - as[pq] = &query.at({b, h, pq, 0}); - bs[pq] = &present_key.at({b_kv, h, pk, 0}, true); - cs[pq] = &m_attn_w.at({b, h, pq, pk}); - } - attn_dot_products(reinterpret_cast(as.data()), - reinterpret_cast(bs.data()), - reinterpret_cast(cs.data()), - q_len, - S, - precision_of::value); - }); - - parallel_for3d(B, H, q_len, [&](size_t b, size_t h, size_t pq) { - // 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* cmask_ptr = causal_mask ? &causal_mask.at({b, h, pq, 0}, true) : nullptr; - attn_softmax(&m_attn_w.at({b, h, pq, 0}), - &m_attn_w.at({b, h, pq, 0}), - d_scale, - alibi_ptr, - attn_mask_ptr, - cmask_ptr, - select_nfltmax_at_0, - ncausal, - kv_len, - ov::element::f32); - }); - - // attn_w * V - auto nthr = parallel_get_max_threads(); - m_temp.resize({static_cast(nthr), B, q_len, H, S}); - // m_attn_w {B, H, q_len, kv_len} - parallel_nt_static(nthr, [&](const size_t ithr, const size_t nthr) { - size_t start{0}, end{0}; - splitter(B * H * kv_len, nthr, ithr, start, end); - - memset(&m_temp.at({ithr, 0, 0, 0, 0}), 0, m_temp.stride(0) * sizeof(float)); - - size_t b, h, pv; - if (start < end) { - parallel_it_init(start, b, B, h, H, pv, kv_len); - std::vector vs(q_len * (end - start)); - std::vector weights(q_len * (end - start)); - std::vector outs(q_len * (end - start)); - size_t idx = 0; - for (size_t iwork = start; iwork < end; ++iwork) { - auto b_kv = beams ? beams.at({b, pv}) : b; - auto* v = &present_value.at({b_kv, h, pv, 0}, true); - for (size_t pq = 0; pq < q_len; pq++) { - outs[idx] = &m_temp.at({ithr, b, pq, h, 0}); - weights[idx] = m_attn_w.at({b, h, pq, pv}); - vs[idx] = v; - idx++; - } - parallel_it_step(b, B, h, H, pv, kv_len); - } - attn_acc_values(outs.data(), - weights.data(), - reinterpret_cast(vs.data()), - q_len * (end - start), - S, - precision_of::value); - } - }); - - parallel_for3d(B, H, q_len, [&](size_t b, size_t h, size_t pq) { - auto* temp = &m_temp.at({0, b, pq, h, 0}); - size_t temp_stride = m_temp.stride(0); - auto* dst = has_out_transpose ? &output_emb.at({b, pq, h*S}) : &output_emb.at({b, h, pq}); - attn_reduce(dst, temp, nthr, S, temp_stride, precision_of::value); - }); + mha_single_token(query, present_key, present_value, alibi_mask, attention_mask, beams, output_emb, + m_attn_w, m_temp, has_out_transpose, auto_causal, d_scale); } }; template struct ScaledDotProductAttention::AttentionExecutor : public ScaledDotProductAttention::Executor { - PlainTensor q_input; // f32[B, H, L1, S] - PlainTensor k_input; // f32[B, H|1, L1, S] / [B, H|1, L0+L1, S] - PlainTensor v_input; // f32[B, H|1, L1, S] / [B, H|1, L0+L1, S] - PlainTensor beam_table; // i32[B, max_kvLen] - PlainTensor attn_buf; // f32[[B|1],[H|1], L1|1, L0+L1] + PlainTensor q_input; // f32[B, H, L1, S] + PlainTensor k_input; // f32[B, H|1, L1, S] / [B, H|1, L0+L1, S] + PlainTensor v_input; // f32[B, H|1, L1, S] / [B, H|1, L0+L1, S] + PlainTensor beam_table; // i32[B, max_kvLen] + PlainTensor attn_buf; // f32[[B|1],[H|1], L1|1, L0+L1] float scale_input = 0.0f; MHAKernel kernel; - MHASingleToken kernel_single_token; + MHASingleToken kernel_single_token; size_t B, H, L1, L0, S; @@ -593,49 +495,33 @@ struct ScaledDotProductAttention::AttentionExecutor : public ScaledDotProductAtt AttentionExecutor(const Config& _config) : attn_buf(true), config(_config) {} void prepare_attn_mask(MemoryPtr attn_input) { - attn_buf.resize(attn_input->getStaticDims()); + attn_buf.resize(attn_input->getStaticDims()); auto p = reinterpret_cast(attn_input->getData()); for (size_t i = 0; i < attn_input->getSize(); i++) - attn_buf.data()[i] = p[i] ? 0.0f : -FLT_MAX; + attn_buf.data()[i] = p[i] ? 0.0f : -FLT_MAX; } void concat_pastkv(const std::vector& inputs, const std::vector& outputs, - const PlainTensor& k_input, - const PlainTensor& v_input, - PlainTensor& past_k_output, - PlainTensor& past_v_output) { + const PlainTensor& k_input, + const PlainTensor& v_input, + PlainTensor& past_k_output, + PlainTensor& past_v_output) { if (config.config.fuse_concat) { k_input.assert_dims({B, 0, L1, S}, true); v_input.assert_dims({B, 0, L1, S}, true); auto past_k_idx = inputs.size() - 2; auto past_k_mem = inputs[past_k_idx + 0]; L0 = past_k_mem->getStaticDims()[2]; - // k,v may support multiquery - auto Hk = past_k_mem->getStaticDims()[1]; // [B, H, L0, S] past_k_output.reset(outputs[1]); past_v_output.reset(outputs[2]); - parallel_for3d(B, Hk, L1, [&](size_t b, size_t h, size_t m) { - std::memcpy(&past_k_output.at({b, h, m + L0, 0}), - &k_input.at({b, h, m, 0}), - S * sizeof(T)); - std::memcpy(&past_v_output.at({b, h, m + L0, 0}), - &v_input.at({b, h, m, 0}), - S * sizeof(T)); - }); + attn_memcpy(k_input, v_input, past_k_output.slice(2, L0, L0 + L1), past_v_output.slice(2, L0, L0 + L1)); if (!config.is_concat_inplaced) { - PlainTensor past_k_input, past_v_input; + PlainTensor past_k_input, past_v_input; past_k_input.reset(past_k_mem); past_v_input.reset(inputs[past_k_idx + 1]); - parallel_for3d(B, Hk, L0, [&](size_t b, size_t h, size_t m) { - std::memcpy(&past_k_output.at({b, h, m, 0}), - &past_k_input.at({b, h, m, 0}), - S * sizeof(T)); - std::memcpy(&past_v_output.at({b, h, m, 0}), - &past_v_input.at({b, h, m, 0}), - S * sizeof(T)); - }); + attn_memcpy(past_k_input, past_v_input, past_k_output, past_v_output); } } else { // k,v inputs are already concatenated @@ -657,7 +543,7 @@ struct ScaledDotProductAttention::AttentionExecutor : public ScaledDotProductAtt q_input.reset(inputs[0]); k_input.reset(inputs[1]); v_input.reset(inputs[2]); - PlainTensor attn_mask; + PlainTensor attn_mask; if (input_num > 3) { // attn_mask if (inputs[3]->getDesc().getPrecision() == ov::element::u8) { @@ -679,10 +565,10 @@ struct ScaledDotProductAttention::AttentionExecutor : public ScaledDotProductAtt L1 = q_input.size(2); S = q_input.size(-1); - PlainTensor present_key, present_value; + PlainTensor present_key, present_value; concat_pastkv(inputs, outputs, k_input, v_input, present_key, present_value); - ov::intel_cpu::PlainTensor output_emb(outputs[0]); + ov::intel_cpu::PlainTensor output_emb(outputs[0]); bool auto_causal; bool use_attn_mask; @@ -715,7 +601,7 @@ struct ScaledDotProductAttention::AttentionExecutor : public ScaledDotProductAtt if (L1 > 1) { // multi-token version - kernel(strm, q_input, k_input, v_input, {}, use_attn_mask ? attn_mask : PlainTensor(), + kernel(strm, q_input, k_input, v_input, {}, use_attn_mask ? attn_mask : PlainTensor(), output_emb, has_out_transpose, auto_causal, scale_input); } else { // 1-token version @@ -723,7 +609,7 @@ struct ScaledDotProductAttention::AttentionExecutor : public ScaledDotProductAtt // 1, in matrix mutiply, using AMX is not efficency because the M dimension of A will alway be 1 // 2, using float will save the repack cost which typically is required for bf16/int8 opt // 3, using dot product can leverage the SIMD while easily adapt to indirect kv cache - kernel_single_token(q_input, present_key, present_value, {}, use_attn_mask ? attn_mask : PlainTensor(), + kernel_single_token(q_input, present_key, present_value, {}, use_attn_mask ? attn_mask : PlainTensor(), output_emb, beam_table, has_out_transpose, auto_causal, scale_input); } } @@ -740,7 +626,7 @@ ScaledDotProductAttention::ScaledDotProductAttention(const std::shared_ptrget_causal(); } else { - const auto node = std::dynamic_pointer_cast(op); + const auto node = std::dynamic_pointer_cast(op); m_config.config = node->get_config(); } } @@ -749,10 +635,14 @@ void ScaledDotProductAttention::initSupportedPrimitiveDescriptors() { if (!supportedPrimitiveDescriptors.empty()) return; auto rtPrecision = getOriginalInputPrecisionAtPort(0); + auto orginSDPInputNumber = getOriginalInputsNumber() - (m_config.config.fuse_concat ? 2 : 0); + + bool enableKVCacheFP16 = m_config.config.fuse_concat && mayiuse(cpu_isa_t::avx2) && rtPrecision != ov::element::bf16; + + auto kvCachePrecision = enableKVCacheFP16 ? ov::element::f16 : rtPrecision; NodeConfig config; auto& creatorsMap = BlockedDescCreator::getCommonCreators(); - auto orginSDPInputNumber = getOriginalInputsNumber() - (m_config.config.fuse_concat ? 2 : 0); config.inConfs.resize(getOriginalInputsNumber()); config.outConfs.resize(getOriginalOutputsNumber()); config.inConfs[0].setMemDesc(creatorsMap.at(LayoutType::ncsp)->createSharedDesc( @@ -782,15 +672,15 @@ void ScaledDotProductAttention::initSupportedPrimitiveDescriptors() { ArbitraryOrderDescCreator cabdDescCreator({2, 0, 1, 3}); config.inConfs[orginSDPInputNumber + 0].setMemDesc(cabdDescCreator.createSharedDesc( - rtPrecision, getInputShapeAtPort(orginSDPInputNumber + 0))); + kvCachePrecision, getInputShapeAtPort(orginSDPInputNumber + 0))); config.inConfs[orginSDPInputNumber + 1].setMemDesc(cabdDescCreator.createSharedDesc( - rtPrecision, getInputShapeAtPort(orginSDPInputNumber + 1))); + kvCachePrecision, getInputShapeAtPort(orginSDPInputNumber + 1))); config.outConfs[1].setMemDesc(cabdDescCreator.createSharedDesc( - rtPrecision, getOutputShapeAtPort(1))); + kvCachePrecision, getOutputShapeAtPort(1))); config.outConfs[1].inPlace(orginSDPInputNumber + 0); config.outConfs[2].setMemDesc(cabdDescCreator.createSharedDesc( - rtPrecision, getOutputShapeAtPort(2))); + kvCachePrecision, getOutputShapeAtPort(2))); config.outConfs[2].inPlace(orginSDPInputNumber + 1); } @@ -801,14 +691,14 @@ void ScaledDotProductAttention::initSupportedPrimitiveDescriptors() { // may fallback to abcd without inplace if (m_config.config.fuse_concat) { config.inConfs[orginSDPInputNumber + 0].setMemDesc(creatorsMap.at(LayoutType::ncsp)->createSharedDesc( - rtPrecision, getInputShapeAtPort(orginSDPInputNumber + 0))); + kvCachePrecision, getInputShapeAtPort(orginSDPInputNumber + 0))); config.inConfs[orginSDPInputNumber + 1].setMemDesc(creatorsMap.at(LayoutType::ncsp)->createSharedDesc( - rtPrecision, getInputShapeAtPort(orginSDPInputNumber + 1))); + kvCachePrecision, getInputShapeAtPort(orginSDPInputNumber + 1))); config.outConfs[1].setMemDesc(creatorsMap.at(LayoutType::ncsp)->createSharedDesc( - rtPrecision, getOutputShapeAtPort(1))); + kvCachePrecision, getOutputShapeAtPort(1))); config.outConfs[1].inPlace(-1); config.outConfs[2].setMemDesc(creatorsMap.at(LayoutType::ncsp)->createSharedDesc( - rtPrecision, getOutputShapeAtPort(2))); + kvCachePrecision, getOutputShapeAtPort(2))); config.outConfs[2].inPlace(-1); supportedPrimitiveDescriptors.emplace_back(config, impl_desc_type::ref_any); } @@ -851,8 +741,8 @@ void ScaledDotProductAttention::execute(dnnl::stream strm) { bool ScaledDotProductAttention::isSupportedOperation(const std::shared_ptr& op, std::string& errorMessage) noexcept { try { if (!std::dynamic_pointer_cast(op) && - !std::dynamic_pointer_cast(op)) { - errorMessage = "Only ScaledDotProductAttention or ScaledDotProductAttentionStub operation are supported"; + !std::dynamic_pointer_cast(op)) { + errorMessage = "Only ScaledDotProductAttention or ScaledDotProductAttentionWithKVCache operation are supported"; return false; } // expect shape of q: [B, H, L, S] @@ -862,7 +752,7 @@ bool ScaledDotProductAttention::isSupportedOperation(const std::shared_ptr(op->get_input_size()); - const auto node = std::dynamic_pointer_cast(op); + const auto node = std::dynamic_pointer_cast(op); if (node) { if (node->get_config().fuse_concat) { orgSDPAInput -= 2; diff --git a/src/plugins/intel_cpu/src/nodes/scaled_attn.h b/src/plugins/intel_cpu/src/nodes/scaled_attn.h index 7c08ef99faf1d4..78bc9d4231478f 100644 --- a/src/plugins/intel_cpu/src/nodes/scaled_attn.h +++ b/src/plugins/intel_cpu/src/nodes/scaled_attn.h @@ -10,7 +10,7 @@ #include #include -#include "transformations/cpu_opset/common/op/sdp.hpp" +#include "transformations/cpu_opset/common/op/sdpa.hpp" namespace ov { namespace intel_cpu { @@ -26,7 +26,7 @@ class ScaledDotProductAttention : public Node { } // pastkv may have zero dimension bool isExecutable() const override { - return true; + return !isInputTensorAtPortEmpty(0) && !isInputTensorAtPortEmpty(1) && !isInputTensorAtPortEmpty(2); } bool needPrepareParams() const override { return false; @@ -47,7 +47,7 @@ class ScaledDotProductAttention : public Node { }; struct Config { - ScaledDotProductAttentionStub::Config config; + ScaledDotProductAttentionWithKVCache::Config config; bool is_concat_inplaced = false; }; diff --git a/src/plugins/intel_cpu/src/nodes_factory.cpp b/src/plugins/intel_cpu/src/nodes_factory.cpp index bead297d033e79..5b91412f03fe9c 100644 --- a/src/plugins/intel_cpu/src/nodes_factory.cpp +++ b/src/plugins/intel_cpu/src/nodes_factory.cpp @@ -2,108 +2,107 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "nodes/reference.h" -#include "nodes/shapeof.h" -#include "nodes/batch_to_space.h" -#include "nodes/multiclass_nms.hpp" #include "nodes/adaptive_pooling.h" +#include "nodes/batch_to_space.h" +#include "nodes/bin_conv.h" +#include "nodes/broadcast.h" +#include "nodes/bucketize.h" +#include "nodes/color_convert.h" +#include "nodes/concat.h" #include "nodes/conv.h" -#include "nodes/roi_align.h" -#include "nodes/lrn.h" -#include "nodes/generic.h" -#include "nodes/experimental_detectron_roifeatureextractor.h" +#include "nodes/convert.h" +#include "nodes/ctc_greedy_decoder.h" +#include "nodes/ctc_greedy_decoder_seq_len.h" +#include "nodes/ctc_loss.h" +#include "nodes/cum_sum.h" +#include "nodes/deconv.h" +#include "nodes/def_conv.h" +#include "nodes/depth_to_space.h" +#include "nodes/detection_output.h" +#include "nodes/dft.h" #include "nodes/eltwise.h" -#include "nodes/reorg_yolo.h" -#include "nodes/pooling.h" -#include "nodes/transpose.h" -#include "nodes/grn.h" -#include "nodes/interpolate.h" +#include "nodes/embedding_bag_offset_sum.h" +#include "nodes/embedding_bag_packed_sum.h" +#include "nodes/embedding_segments_sum.h" #include "nodes/experimental_detectron_detection_output.h" -#include "nodes/roll.h" +#include "nodes/experimental_detectron_generate_proposals_single_image.h" +#include "nodes/experimental_detectron_priorgridgenerator.h" +#include "nodes/experimental_detectron_roifeatureextractor.h" +#include "nodes/experimental_detectron_topkrois.h" +#include "nodes/extract_image_patches.h" +#include "nodes/eye.h" #include "nodes/fake_quantize.h" -#include "nodes/embedding_segments_sum.h" -#include "nodes/region_yolo.h" -#include "nodes/matmul.h" -#include "nodes/detection_output.h" -#include "nodes/reverse_sequence.h" -#include "nodes/pad.h" -#include "nodes/ctc_greedy_decoder_seq_len.h" -#include "nodes/reshape.h" -#include "nodes/psroi_pooling.h" -#include "nodes/memory.hpp" -#include "nodes/bin_conv.h" +#include "nodes/fullyconnected.h" +#include "nodes/gather.h" #include "nodes/gather_elements.h" -#include "nodes/experimental_detectron_priorgridgenerator.h" -#include "nodes/tile.h" +#include "nodes/gather_nd.h" +#include "nodes/gather_tree.h" +#include "nodes/generate_proposals.h" +#include "nodes/generic.h" +#include "nodes/grid_sample.hpp" +#include "nodes/grn.h" +#include "nodes/if.h" +#include "nodes/input.h" +#include "nodes/interaction.h" +#include "nodes/interpolate.h" +#include "nodes/log_softmax.h" +#include "nodes/lrn.h" #include "nodes/mathematics.h" +#include "nodes/matmul.h" +#include "nodes/matrix_nms.h" +#include "nodes/memory.hpp" +#include "nodes/mha.h" +#include "nodes/multiclass_nms.hpp" +#include "nodes/multinomial.hpp" +#include "nodes/mvn.h" +#include "nodes/ngram.h" +#include "nodes/non_max_suppression.h" +#include "nodes/non_zero.h" #include "nodes/normalize.h" +#include "nodes/one_hot.h" +#include "nodes/pad.h" +#include "nodes/pooling.h" +#include "nodes/priorbox.h" +#include "nodes/priorbox_clustered.h" #include "nodes/proposal.h" -#include "nodes/tensoriterator.h" -#include "nodes/fullyconnected.h" -#include "nodes/extract_image_patches.h" -#include "nodes/ctc_loss.h" +#include "nodes/psroi_pooling.h" +#include "nodes/random_uniform.hpp" +#include "nodes/range.h" +#include "nodes/rdft.h" +#include "nodes/reduce.h" +#include "nodes/reference.h" +#include "nodes/region_yolo.h" #include "nodes/reorder.h" -#include "nodes/gather_nd.h" +#include "nodes/reorg_yolo.h" +#include "nodes/reshape.h" +#include "nodes/reverse_sequence.h" +#include "nodes/rnn.h" +#include "nodes/roi_align.h" +#include "nodes/roi_pooling.h" +#include "nodes/roll.h" +#include "nodes/rope.h" +#include "nodes/scaled_attn.h" +#include "nodes/scatter_update.h" +#include "nodes/shapeof.h" #include "nodes/shuffle_channels.h" -#include "nodes/bucketize.h" -#include "nodes/space_to_depth.h" -#include "nodes/concat.h" #include "nodes/softmax.h" #include "nodes/space_to_batch.h" -#include "nodes/topk.h" -#include "nodes/broadcast.h" -#include "nodes/matrix_nms.h" -#include "nodes/mvn.h" -#include "nodes/gather.h" -#include "nodes/grid_sample.hpp" -#include "nodes/scatter_update.h" -#include "nodes/gather_tree.h" -#include "nodes/def_conv.h" -#include "nodes/embedding_bag_offset_sum.h" -#include "nodes/deconv.h" -#include "nodes/roi_pooling.h" -#include "nodes/range.h" +#include "nodes/space_to_depth.h" #include "nodes/split.h" -#include "nodes/one_hot.h" -#include "nodes/log_softmax.h" #include "nodes/strided_slice.h" -#include "nodes/dft.h" -#include "nodes/rdft.h" -#include "nodes/non_max_suppression.h" -#include "nodes/convert.h" -#include "nodes/rnn.h" -#include "nodes/experimental_detectron_topkrois.h" -#include "nodes/cum_sum.h" -#include "nodes/depth_to_space.h" -#include "nodes/input.h" -#include "nodes/experimental_detectron_generate_proposals_single_image.h" -#include "nodes/generate_proposals.h" -#include "nodes/embedding_bag_packed_sum.h" -#include "nodes/random_uniform.hpp" -#include "nodes/reduce.h" -#include "nodes/if.h" -#include "nodes/ctc_greedy_decoder.h" -#include "nodes/non_zero.h" -#include "nodes/color_convert.h" #include "nodes/subgraph.h" -#include "nodes/priorbox.h" -#include "nodes/priorbox_clustered.h" -#include "nodes/eye.h" -#include "nodes/interaction.h" -#include "nodes/mha.h" +#include "nodes/tensoriterator.h" +#include "nodes/tile.h" +#include "nodes/topk.h" +#include "nodes/transpose.h" #include "nodes/unique.hpp" -#include "nodes/ngram.h" -#include "nodes/scaled_attn.h" -#include "nodes/rope.h" namespace ov { namespace intel_cpu { -#define INTEL_CPU_NODE(__prim, __type) \ - registerNodeIfRequired(intel_cpu, __prim, __type, NodeImpl<__prim>) +#define INTEL_CPU_NODE(__prim, __type) registerNodeIfRequired(intel_cpu, __prim, __type, NodeImpl<__prim>) -Node::NodesFactory::NodesFactory() - : Factory("NodesFactory") { +Node::NodesFactory::NodesFactory() : Factory("NodesFactory") { using namespace node; INTEL_CPU_NODE(Generic, Type::Generic); INTEL_CPU_NODE(CumSum, Type::CumSum); @@ -136,7 +135,8 @@ Node::NodesFactory::NodesFactory() INTEL_CPU_NODE(ReorgYolo, Type::ReorgYolo); INTEL_CPU_NODE(EmbeddingSegmentsSum, Type::EmbeddingSegmentsSum); INTEL_CPU_NODE(ShapeOf, Type::ShapeOf); - INTEL_CPU_NODE(ExperimentalDetectronGenerateProposalsSingleImage, Type::ExperimentalDetectronGenerateProposalsSingleImage); + INTEL_CPU_NODE(ExperimentalDetectronGenerateProposalsSingleImage, + Type::ExperimentalDetectronGenerateProposalsSingleImage); INTEL_CPU_NODE(GenerateProposals, Type::GenerateProposals); INTEL_CPU_NODE(ReverseSequence, Type::ReverseSequence); INTEL_CPU_NODE(ExperimentalDetectronPriorGridGenerator, Type::ExperimentalDetectronPriorGridGenerator); @@ -162,6 +162,7 @@ Node::NodesFactory::NodesFactory() INTEL_CPU_NODE(Reshape, Type::Reshape); INTEL_CPU_NODE(MVN, Type::MVN); INTEL_CPU_NODE(MatMul, Type::MatMul); + INTEL_CPU_NODE(Multinomial, Type::Multinomial); INTEL_CPU_NODE(ScatterUpdate, Type::ScatterUpdate); INTEL_CPU_NODE(ScatterUpdate, Type::ScatterElementsUpdate); INTEL_CPU_NODE(ScatterUpdate, Type::ScatterNDUpdate); @@ -208,5 +209,5 @@ Node::NodesFactory::NodesFactory() #undef INTEL_CPU_NODE -} // namespace intel_cpu -} // namespace ov +} // namespace intel_cpu +} // namespace ov diff --git a/src/plugins/intel_cpu/src/normalize_preprocess.cpp b/src/plugins/intel_cpu/src/normalize_preprocess.cpp deleted file mode 100644 index 4d1bf74484f693..00000000000000 --- a/src/plugins/intel_cpu/src/normalize_preprocess.cpp +++ /dev/null @@ -1,130 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "normalize_preprocess.h" -#include "ie_parallel.hpp" -#include "nodes/common/cpu_memcpy.h" -#include "utils/general_utils.h" -#include "ie_ngraph_utils.hpp" - -using namespace InferenceEngine; - -namespace ov { -namespace intel_cpu { - -NormalizePreprocess::NormalizePreprocess() : meanBuffer(nullptr) { -} - -void NormalizePreprocess::Load(const Shape& inputShape, InputInfo::Ptr inputInfo) { - PreProcessInfo &pp = inputInfo->getPreProcess(); - size_t inChannels = pp.getNumberOfChannels(); - if (inChannels == 0) { - meanBuffer = nullptr; - return; - } - - if (!dimsEqualStrong(inChannels, inputShape.getDims()[1])) { - OPENVINO_THROW("channels mismatch between mean and input"); - } - - switch (pp.getMeanVariant()) { - case MEAN_VALUE: { - // mean and standard deviation image common value per channel (1x1xC) - meanValues.resize(inChannels); - stdScales.resize(inChannels); - - for (unsigned channel = 0; channel < inChannels; channel++) { - if (pp[channel]->stdScale == 0) { - OPENVINO_THROW("Preprocessing error: stdScale cannot be equal zero"); - } - meanValues[channel] = pp[channel]->meanValue; - stdScales[channel] = pp[channel]->stdScale; - } - } - break; - case MEAN_IMAGE: { - // since oneDNN expects all channels in the same buffer - we copy it here as it comes from different channels... - auto meanWidth = pp[0]->meanData->getTensorDesc().getDims()[pp[0]->meanData->getTensorDesc().getDims().size() - 1]; - auto meanHeight = pp[0]->meanData->getTensorDesc().getDims()[pp[0]->meanData->getTensorDesc().getDims().size() - 2]; - - TensorDesc desc(InferenceEngine::details::convertPrecision(ov::element::f32), {inChannels, meanHeight, meanWidth}, InferenceEngine::Layout::CHW); - - meanBuffer = make_shared_blob(desc); - - meanBuffer->allocate(); - - for (unsigned channel = 0; channel < inChannels; channel++) { - Blob::Ptr meanBlob = pp[channel]->meanData; - if (!meanBlob || InferenceEngine::details::convertPrecision(meanBlob->getTensorDesc().getPrecision()) != ov::element::f32) - OPENVINO_THROW("mean image not provided or not in Float 32"); - if (meanBlob->size() != meanHeight*meanWidth) { - OPENVINO_THROW("mean image size does not match expected network input, expecting ", - meanWidth, - " x ", - meanHeight); - } - // todo: cast to TBlob and make sure it is floats - cpu_memcpy_s(meanBuffer->data() + channel*meanBlob->size(), meanBuffer->byteSize() - channel*meanBlob->byteSize(), - meanBlob->buffer(), meanBlob->byteSize()); - } - } - break; - - case NONE: { - // there is no mean image. So disable mean image step - meanBuffer = nullptr; - } - break; - - default: { - OPENVINO_THROW("Unsupported mean variant: ", pp.getMeanVariant()); - } - } -} - -void NormalizePreprocess::NormalizeImage(const Shape &inputShape, float *input, InferenceEngine::Layout layout) { - OPENVINO_ASSERT(input != nullptr); - - const auto inputDims = inputShape.getStaticDims(); - if (inputDims.size() != 4) { - OPENVINO_THROW("Expecting input as 4 dimension blob with format NxCxHxW."); - } - - if (layout != NCHW && layout != NHWC) { - OPENVINO_THROW("Expecting input layout NCHW or NHWC."); - } - - int MB = inputDims[0]; - int srcSize = inputShape.getElementsCount() / MB; - - if (meanBuffer && meanBuffer->size()) { - const float * meanBufferValues = meanBuffer->readOnly(); - - parallel_for2d(MB, srcSize, [&](int mb, int i) { - input[srcSize * mb + i] -= meanBufferValues[i]; - }); - } else if (!meanValues.empty() && !stdScales.empty()) { - int C = inputDims[1]; - srcSize /= inputDims[1]; - - if (layout == NCHW) { - parallel_for3d(MB, C, srcSize, [&](int mb, int c, int i) { - input[mb * C * srcSize + c * srcSize + i] -= meanValues[c]; - input[mb * C * srcSize + c * srcSize + i] /= stdScales[c]; - }); - } else if (layout == NHWC) { - parallel_for2d(MB, srcSize, [&](int mb, int i) { - for (int c = 0; c < C; c++) { - input[mb * srcSize * C + i * C + c] -= meanValues[c]; - input[mb * srcSize * C + i * C + c] /= stdScales[c]; - } - }); - } - } else { - OPENVINO_THROW("Preprocessing error: meanValues and stdScales arrays are inconsistent."); - } -} - -} // namespace intel_cpu -} // namespace ov diff --git a/src/plugins/intel_cpu/src/normalize_preprocess.h b/src/plugins/intel_cpu/src/normalize_preprocess.h deleted file mode 100644 index a6d03cfcad5297..00000000000000 --- a/src/plugins/intel_cpu/src/normalize_preprocess.h +++ /dev/null @@ -1,93 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "ie_input_info.hpp" - -#include "cpu_shape.h" -#include "ie_parallel.hpp" -#include -#include - -namespace ov { -namespace intel_cpu { - -class NormalizePreprocess { -public: - NormalizePreprocess(); - -public: - void Load(const Shape& inputShape, InferenceEngine::InputInfo::Ptr inputInfo); - void NormalizeImage(const Shape &inputShape, float *input, InferenceEngine::Layout layout); - - template::value>::type* = nullptr> - void NormalizeImage(const Shape &inputShape, T *input, InferenceEngine::Layout layout) { - OPENVINO_ASSERT(input != nullptr); - - const auto inputDims = inputShape.getStaticDims(); - if (inputDims.size() != 4) { - OPENVINO_THROW("Expecting input as 4 dimension blob with format NxCxHxW."); - } - - if (layout != InferenceEngine::NCHW && layout != InferenceEngine::NHWC) { - OPENVINO_THROW("Expecting input layout NCHW or NHWC."); - } - - int MB = inputDims[0]; - int srcSize = inputShape.getElementsCount() / MB; - - if (meanBuffer && meanBuffer->size()) { - const float * meanBufferValues = meanBuffer->readOnly(); - - InferenceEngine::parallel_for2d(MB, srcSize, [&](int mb, int i) { - int buf = input[srcSize * mb + i]; - buf -= meanBufferValues[i]; - if (buf < (std::numeric_limits::min)()) buf = (std::numeric_limits::min)(); - if (buf > (std::numeric_limits::max)()) buf = (std::numeric_limits::max)(); - input[srcSize * mb + i] = buf; - }); - } else if (!meanValues.empty() && !stdScales.empty()) { - int C = inputDims[1]; - srcSize /= inputDims[1]; - - for (int c = 0; c < C; c++) { - if (stdScales[c] != 1) - OPENVINO_THROW("Preprocessing error: fractional normalization is not supported for integer data. "); - } - - if (layout == InferenceEngine::NCHW) { - InferenceEngine::parallel_for3d(MB, C, srcSize, [&](int mb, int c, int i) { - int buf = input[srcSize * mb * C + c * srcSize + i]; - buf -= meanValues[c]; - if (buf < (std::numeric_limits::min)()) buf = (std::numeric_limits::min)(); - if (buf > (std::numeric_limits::max)()) buf = (std::numeric_limits::max)(); - input[srcSize * mb * C + c * srcSize + i] = buf; - }); - } else if (layout == InferenceEngine::NHWC) { - InferenceEngine::parallel_for2d(MB, srcSize, [&](int mb, int i) { - for (int c = 0; c < C; c++) { - int buf = input[mb * srcSize * C + i * C + c]; - buf -= meanValues[c]; - if (buf < (std::numeric_limits::min)()) buf = (std::numeric_limits::min)(); - if (buf > (std::numeric_limits::max)()) buf = (std::numeric_limits::max)(); - input[mb * srcSize * C + i * C + c] = buf; - } - }); - } - } else { - OPENVINO_THROW("Preprocessing error: meanValues and stdScales arrays are inconsistent."); - } - } - -private: - std::vector meanValues; - - std::vector stdScales; - - InferenceEngine::TBlob::Ptr meanBuffer; -}; - -} // namespace intel_cpu -} // namespace ov diff --git a/src/plugins/intel_cpu/src/plugin.cpp b/src/plugins/intel_cpu/src/plugin.cpp index bf58d77a25eb02..394db23ef5894d 100644 --- a/src/plugins/intel_cpu/src/plugin.cpp +++ b/src/plugins/intel_cpu/src/plugin.cpp @@ -59,9 +59,10 @@ static std::string getDeviceFullName() { #else __cpuid(regs[0], regs[0], regs[1], regs[2], regs[3]); #endif - char *ch = reinterpret_cast(®s[0]); + char* ch = reinterpret_cast(®s[0]); for (size_t j = 0; j < sizeof(regs); j++) - brand_string += ch[j]; + if (ch[j] != '\0') + brand_string += ch[j]; } #else # error "Unkown CPU architecture. Please, add support to openvino/core/visibility.hpp" @@ -136,7 +137,7 @@ std::mutex Engine::SchedulerGuard::mutex; std::weak_ptr Engine::SchedulerGuard::ptr; Engine::SchedulerGuard::SchedulerGuard() { -#if IE_THREAD == IE_THREAD_SEQ +#if OV_THREAD == OV_THREAD_SEQ // To save state for ACL cores in single-thread mode arm_compute::Scheduler::set(arm_compute::Scheduler::Type::ST); #else @@ -330,6 +331,8 @@ void Engine::get_performance_streams(Config& config, const std::shared_ptr #include #include @@ -69,6 +71,7 @@ #include "matmul_shape_inference.hpp" #include "matrix_nms_shape_inference.hpp" #include "max_pool_shape_inference.hpp" +#include "multinomial_shape_inference.hpp" #include "nms_shape_inference.hpp" #include "nv12_shape_inference.hpp" #include "one_hot_shape_inference.hpp" @@ -95,7 +98,6 @@ #include "scatter_elements_update_shape_inference.hpp" #include "scatter_nd_base_shape_inference.hpp" #include "select_shape_inference.hpp" -#include "shape_inference.hpp" #include "shape_nodes.hpp" #include "shuffle_channels_shape_inference.hpp" #include "slice_shape_inference.hpp" @@ -396,6 +398,7 @@ using IStaticShapeInferFactory = template <> const IStaticShapeInferFactory::TRegistry IStaticShapeInferFactory::registry{ // opset13 + _OV_OP_SHAPE_INFER_MASK_REG(opset13::Multinomial, ShapeInferTA, util::bit::mask(1)), _OV_OP_SHAPE_INFER_MASK_REG(opset13::ScaledDotProductAttention, ShapeInferTA, util::bit::mask(3, 5)), // opset12 _OV_OP_SHAPE_INFER_MASK_REG(opset12::Pad, ShapeInferTA, util::bit::mask(1, 2)), diff --git a/src/plugins/intel_cpu/src/transformations/cpu_opset/common/op/rope.cpp b/src/plugins/intel_cpu/src/transformations/cpu_opset/common/op/rope.cpp index 8b4461b479ee7b..fd78f4f3bffafd 100644 --- a/src/plugins/intel_cpu/src/transformations/cpu_opset/common/op/rope.cpp +++ b/src/plugins/intel_cpu/src/transformations/cpu_opset/common/op/rope.cpp @@ -22,6 +22,18 @@ void ov::intel_cpu::RoPENode::validate_and_infer_types() { INTERNAL_OP_SCOPE(RoPENode_validate_and_infer_types); auto input_pshape = get_input_partial_shape(0); auto input_slice_size = m_config.slice_stop - m_config.slice_start; + + if (m_config.is_chatglm) { + // chatGLM specific RoPE + // input [length, batch_size, (hidden_states_q + hidden_states_k + hidden_states_v)] + // output [length, batch_size, head_cnt, hidden_states_k] + set_output_type( + 0, + get_input_element_type(0), + {input_pshape[0], input_pshape[1], ov::Dimension(m_config.head_cnt), ov::Dimension(m_config.head_size)}); + return; + } + if (input_slice_size > 0) { input_pshape[3] = input_slice_size; } @@ -44,6 +56,9 @@ bool ov::intel_cpu::RoPENode::visit_attributes(ngraph::AttributeVisitor& visitor visitor.on_attribute("input_trans0213", m_config.input_trans0213); visitor.on_attribute("is_interleaved", m_config.is_interleaved); visitor.on_attribute("rotary_ndims", m_config.rotary_ndims); + visitor.on_attribute("is_chatglm", m_config.is_chatglm); + visitor.on_attribute("head_cnt", m_config.head_cnt); + visitor.on_attribute("head_size", m_config.head_size); visitor.on_attribute("gather_position_arg_id", m_config.gather_position_arg_id); visitor.finish_structure(); return true; diff --git a/src/plugins/intel_cpu/src/transformations/cpu_opset/common/op/rope.hpp b/src/plugins/intel_cpu/src/transformations/cpu_opset/common/op/rope.hpp index cc6df7ec2b107f..61f93ad787ad0d 100644 --- a/src/plugins/intel_cpu/src/transformations/cpu_opset/common/op/rope.hpp +++ b/src/plugins/intel_cpu/src/transformations/cpu_opset/common/op/rope.hpp @@ -70,6 +70,9 @@ class RoPENode : public ngraph::op::Op { bool input_trans0213 = false; // transpose input dim 1&2 bool is_interleaved = false; // interleaved mode, implies trans0213 happens after RoPE size_t rotary_ndims = 0; // dimensions to be embedded (d in the description) + bool is_chatglm = false; // chatglm is special which overrides other setting + size_t head_cnt = 0; + size_t head_size = 0; int gather_position_arg_id = 0; // arg id of position tensor, ==3 when gather from sin/cos inputs according to position is required }; diff --git a/src/plugins/intel_cpu/src/transformations/cpu_opset/common/op/sdp.cpp b/src/plugins/intel_cpu/src/transformations/cpu_opset/common/op/sdpa.cpp similarity index 71% rename from src/plugins/intel_cpu/src/transformations/cpu_opset/common/op/sdp.cpp rename to src/plugins/intel_cpu/src/transformations/cpu_opset/common/op/sdpa.cpp index e433d5ad34fb5a..4dc5ba799dd4eb 100644 --- a/src/plugins/intel_cpu/src/transformations/cpu_opset/common/op/sdp.cpp +++ b/src/plugins/intel_cpu/src/transformations/cpu_opset/common/op/sdpa.cpp @@ -2,27 +2,27 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "sdp.hpp" +#include "sdpa.hpp" #include #include "transformations/itt.hpp" -ov::intel_cpu::ScaledDotProductAttentionStub::ScaledDotProductAttentionStub(const OutputVector& args, const Config& cfg) +ov::intel_cpu::ScaledDotProductAttentionWithKVCache::ScaledDotProductAttentionWithKVCache(const OutputVector& args, const Config& cfg) : Op(args), m_config(cfg) { constructor_validate_and_infer_types(); } -std::shared_ptr ov::intel_cpu::ScaledDotProductAttentionStub::clone_with_new_inputs( +std::shared_ptr ov::intel_cpu::ScaledDotProductAttentionWithKVCache::clone_with_new_inputs( const ov::OutputVector& new_args) const { - INTERNAL_OP_SCOPE(ScaledDotProductAttentionStub_with_new_inputs); + INTERNAL_OP_SCOPE(ScaledDotProductAttentionWithKVCache_with_new_inputs); check_new_args_count(this, new_args); - return std::make_shared(new_args, m_config); + return std::make_shared(new_args, m_config); } -void ov::intel_cpu::ScaledDotProductAttentionStub::validate_and_infer_types() { - INTERNAL_OP_SCOPE(ScaledDotProductAttentionStub_validate_and_infer_types); +void ov::intel_cpu::ScaledDotProductAttentionWithKVCache::validate_and_infer_types() { + INTERNAL_OP_SCOPE(ScaledDotProductAttentionWithKVCache_validate_and_infer_types); auto input_num = get_input_size(); // [B, H, L1, S] auto q_ps = get_input_partial_shape(0); @@ -45,8 +45,8 @@ void ov::intel_cpu::ScaledDotProductAttentionStub::validate_and_infer_types() { set_output_type(2, get_input_element_type(input_num - 1), past_kv_ps); } -bool ov::intel_cpu::ScaledDotProductAttentionStub::visit_attributes(ov::AttributeVisitor& visitor) { - INTERNAL_OP_SCOPE(ScaledDotProductAttentionStub_visit_attributes); +bool ov::intel_cpu::ScaledDotProductAttentionWithKVCache::visit_attributes(ov::AttributeVisitor& visitor) { + INTERNAL_OP_SCOPE(ScaledDotProductAttentionWithKVCache_visit_attributes); visitor.start_structure("config"); visitor.on_attribute("output_BLHxS", m_config.output_BLHxS); visitor.on_attribute("fuse_causal_attn", m_config.fuse_causal_attn); diff --git a/src/plugins/intel_cpu/src/transformations/cpu_opset/common/op/sdp.hpp b/src/plugins/intel_cpu/src/transformations/cpu_opset/common/op/sdpa.hpp similarity index 78% rename from src/plugins/intel_cpu/src/transformations/cpu_opset/common/op/sdp.hpp rename to src/plugins/intel_cpu/src/transformations/cpu_opset/common/op/sdpa.hpp index 7cf45b24bd7368..94406caeab016e 100644 --- a/src/plugins/intel_cpu/src/transformations/cpu_opset/common/op/sdp.hpp +++ b/src/plugins/intel_cpu/src/transformations/cpu_opset/common/op/sdpa.hpp @@ -14,11 +14,11 @@ namespace intel_cpu { /// /// \ingroup ov_ops_cpp_api -class ScaledDotProductAttentionStub : public ov::op::Op { +class ScaledDotProductAttentionWithKVCache : public ov::op::Op { public: - OPENVINO_OP("ScaledDotProductAttentionStub", "cpu_plugin_opset"); + OPENVINO_OP("ScaledDotProductAttentionWithKVCache", "cpu_plugin_opset"); - ScaledDotProductAttentionStub() = default; + ScaledDotProductAttentionWithKVCache() = default; struct Config { bool output_BLHxS = false; // true implies that output is [B,L,H*S] @@ -28,7 +28,7 @@ class ScaledDotProductAttentionStub : public ov::op::Op { bool fuse_concat = false; // fuse (concat->sdp) ==> sdp }; - ScaledDotProductAttentionStub(const OutputVector& args, const Config& cfg); + ScaledDotProductAttentionWithKVCache(const OutputVector& args, const Config& cfg); std::shared_ptr clone_with_new_inputs(const OutputVector& new_args) const override; bool visit_attributes(AttributeVisitor& visitor) override; 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 fca105c07a475b..07cd8076d52040 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 @@ -132,7 +132,17 @@ ov::intel_cpu::RoPEFusionCosSinPreprocess::RoPEFusionCosSinPreprocess() { {"ellipsis_mask", {}}}); auto squeeze = makePattern({slice_Slice, {-1, head_dims}}); auto index_Gather = makePattern({squeeze, gather_positions_2d, 0}, {{"batch_dims", 0}}); - auto unsqueeze = makePattern({index_Gather, {1, 1, -1, head_dims}}); + + // another simplified pattern for gathering at position_ids + auto slice_Slice2 = makePattern({const_tab, {0}, seq_len, {1}}, + {{"begin_mask", {0}}, + {"end_mask", {0}}, + {"new_axis_mask", {}}, + {"shrink_axis_mask", {}}, + {"ellipsis_mask", {}}}); + auto index_Gather2 = makePattern({slice_Slice2, gather_positions_2d, 0}, {{"batch_dims", 0}}); + + auto unsqueeze = makePattern({index_Gather | index_Gather2, {1, 1, -1, head_dims}}); return unsqueeze; }; @@ -439,6 +449,131 @@ ov::intel_cpu::RoPEFusionGPTJ::RoPEFusionGPTJ() { return true; }; + auto m = std::make_shared(result, matcher_name); + this->register_matcher(m, callback); +} + +ov::intel_cpu::RoPEFusionChatGLM::RoPEFusionChatGLM(int split_output_id) { + MATCHER_SCOPE(RoPEFusionChatGLM); + + auto qkv_linear = makePattern("f32[?,?,?]"); // f32[seq_length, batch_size, 4608] + auto seq_length = makePattern("i32[1]"); + auto cos_sin_cache = makePattern("f32[?,?,?,?]"); // [max_pos_embeddings, batch_size, 32, 2] + + auto ndims = Symbol("ndims"); + auto head_cnt = Symbol("head_cnt"); + auto head_size = Symbol("head_size"); + auto total_size_q = Symbol("total_size_q"); + auto total_size_k = Symbol("total_size_k"); + auto total_size_v = Symbol("total_size_v"); + + auto qkv_proj = makePattern({qkv_linear, -1, {total_size_q, total_size_k, total_size_v}}); + qkv_proj->set_output_size(3); + + // get key [L, B, Hkv, S] + auto cur_key = makePattern({qkv_proj->output(split_output_id), {0, 0, head_cnt, head_size}}, + {{"special_zero", true}}); + + auto slice_Slice_437 = makePattern({cur_key, {0, 0, 0, 0}, {0, 0, 0, ndims}, {1, 1, 1, 1}}, + {{"begin_mask", {1, 1, 1, 0}}, + {"end_mask", {1, 1, 1, 0}}, + {"new_axis_mask", {}}, + {"shrink_axis_mask", {}}, + {"ellipsis_mask", {}}}); + + // rotate half + auto ListConstruct_452_Concat = + makePattern({seq_length, {-1}, {head_cnt}, {ndims / 2}, {2}}, {{"axis", 0}}); + auto ListConstruct_379_Concat = + makePattern({seq_length, {-1}, {1}, {ndims / 2}, {2}}, {{"axis", 0}}); + + auto reshape_Reshape_453 = + makePattern({slice_Slice_437, ListConstruct_452_Concat}, {{"special_zero", false}}); + auto x_even = makePattern({reshape_Reshape_453, 0, -1}, {{"batch_dims", 0}}); + auto slice_Slice_449 = makePattern({cos_sin_cache, {0}, seq_length, {1}}, + {{"begin_mask", {0}}, + {"end_mask", {0}}, + {"new_axis_mask", {}}, + {"shrink_axis_mask", {}}, + {"ellipsis_mask", {}}}); + auto view_Reshape_460 = + makePattern({slice_Slice_449, ListConstruct_379_Concat}, {{"special_zero", false}}); + auto cos_tab = makePattern({view_Reshape_460, 0, -1}, {{"batch_dims", 0}}); + auto x_even_cos = makePattern({x_even, cos_tab}, {{"auto_broadcast", "numpy"}}); + auto x_odd = makePattern({reshape_Reshape_453, 1, -1}, {{"batch_dims", 0}}); + auto sin_tab = makePattern({view_Reshape_460, 1, -1}, {{"batch_dims", 0}}); + auto x_odd_sin = makePattern({x_odd, sin_tab}, {{"auto_broadcast", "numpy"}}); + auto neg_x_odd_sin = makePattern({x_odd_sin, -1.000000f}, {{"auto_broadcast", "numpy"}}); + auto sub_Subtract_469 = makePattern({x_even_cos, neg_x_odd_sin}, {{"auto_broadcast", "numpy"}}); + + auto y_even = makePattern({sub_Subtract_469, -1}); + auto x_odd_cos = makePattern({x_odd, cos_tab}, {{"auto_broadcast", "numpy"}}); + auto x_even_sin = makePattern({x_even, sin_tab}, {{"auto_broadcast", "numpy"}}); + auto add_Add_476 = makePattern({x_odd_cos, x_even_sin}, {{"auto_broadcast", "numpy"}}); + auto y_odd = makePattern({add_Add_476, -1}); + + auto stack_481 = makePattern({y_even, y_odd}, {{"axis", -1}}); + + auto ShapeOf_135133 = makePattern({stack_481}); + auto flatten_Slice_497 = makePattern({ShapeOf_135133, {0}, {3}, {1}}, + {{"begin_mask", {0}}, + {"end_mask", {0}}, + {"new_axis_mask", {}}, + {"shrink_axis_mask", {}}, + {"ellipsis_mask", {}}}); + auto flatten_Concat_500 = makePattern({flatten_Slice_497, {-1}}, {{"axis", 0}}); + auto const_target_shape = makeConst({0, 0, head_cnt, ndims}); + // [length, batch, head_cnt, half_rotary_dims, 2] + auto flatten_Reshape_501 = + makePattern({stack_481, flatten_Concat_500 | const_target_shape}, {{"special_zero", true}}); + auto slice_Slice_443 = + makePattern({cur_key, {0, 0, 0, ndims}, {0, 0, 0, INT_MAX}, {1, 1, 1, 1}}, + {{"begin_mask", {1, 1, 1, 0}}, + {"end_mask", {1, 1, 1, 0}}, + {"new_axis_mask", {}}, + {"shrink_axis_mask", {}}, + {"ellipsis_mask", {}}}); + auto cat_Concat_505 = makePattern({flatten_Reshape_501, slice_Slice_443}, {{"axis", -1}}); + + auto result = cat_Concat_505; + + matcher_pass_callback callback = [=](ngraph::pattern::Matcher& m) { + const auto& pattern_map = m.get_pattern_value_map(); + auto root = m.get_match_root(); + PatternValidator validator(m); + if (!validator) { + return false; + } + + RoPENode::Config config; + OutputVector new_args; + config.rotary_ndims = validator["ndims"]; + config.is_chatglm = true; + config.head_cnt = validator["head_cnt"]; + config.head_size = validator["head_size"]; + + if (split_output_id == 0) { + // query : split_output_id == 0 + config.slice_start = 0; + config.slice_stop = validator["total_size_q"]; + } else { + // key : split_output_id == 1 + config.slice_start = validator["total_size_q"]; + config.slice_stop = config.slice_start + validator["total_size_k"]; + } + + new_args.push_back(pattern_map.at(qkv_linear)); + new_args.push_back(pattern_map.at(cos_sin_cache)); + new_args.push_back(pattern_map.at(cos_sin_cache)); + + auto old_node = root; + + auto new_node = std::make_shared(new_args, config); + new_node->set_friendly_name(old_node->get_friendly_name()); + ov::replace_node(old_node, new_node); + return true; + }; + auto m = std::make_shared(result, matcher_name); this->register_matcher(m, callback); } \ No newline at end of file diff --git a/src/plugins/intel_cpu/src/transformations/cpu_opset/common/pass/rope_fusion.hpp b/src/plugins/intel_cpu/src/transformations/cpu_opset/common/pass/rope_fusion.hpp index 58bab527504096..666366e02c0a47 100644 --- a/src/plugins/intel_cpu/src/transformations/cpu_opset/common/pass/rope_fusion.hpp +++ b/src/plugins/intel_cpu/src/transformations/cpu_opset/common/pass/rope_fusion.hpp @@ -20,7 +20,11 @@ class RoPEFusionGPTJ : public ngraph::pass::MatcherPass { OPENVINO_RTTI("RoPEFusionGPTJ", "0"); RoPEFusionGPTJ(); }; - +class RoPEFusionChatGLM : public ngraph::pass::MatcherPass { +public: + OPENVINO_RTTI("RoPEFusionChatGLM", "0"); + RoPEFusionChatGLM(int split_output_id); +}; class RoPEFusionIOSlicing : public ngraph::pass::MatcherPass { public: OPENVINO_RTTI("RoPEFusionIOSlicing", "0"); @@ -56,6 +60,9 @@ class RoPEFusion : public ngraph::pass::GraphRewrite { add_matcher(); add_matcher(); add_matcher(); + + add_matcher(0); + add_matcher(1); } }; diff --git a/src/plugins/intel_cpu/src/transformations/cpu_opset/common/pass/stateful_sdp_fusion.cpp b/src/plugins/intel_cpu/src/transformations/cpu_opset/common/pass/stateful_sdpa_fusion.cpp similarity index 94% rename from src/plugins/intel_cpu/src/transformations/cpu_opset/common/pass/stateful_sdp_fusion.cpp rename to src/plugins/intel_cpu/src/transformations/cpu_opset/common/pass/stateful_sdpa_fusion.cpp index a1f9dd24ddcb81..683609e968c900 100644 --- a/src/plugins/intel_cpu/src/transformations/cpu_opset/common/pass/stateful_sdp_fusion.cpp +++ b/src/plugins/intel_cpu/src/transformations/cpu_opset/common/pass/stateful_sdpa_fusion.cpp @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "stateful_sdp_fusion.hpp" +#include "stateful_sdpa_fusion.hpp" #include #include @@ -17,13 +17,13 @@ #include "itt.hpp" #include "ov_ops/type_relaxed.hpp" -#include "transformations/cpu_opset/common/op/sdp.hpp" +#include "transformations/cpu_opset/common/op/sdpa.hpp" namespace ov { namespace intel_cpu { -StatefulSDPFusion::StatefulSDPFusion() { - MATCHER_SCOPE(StatefulSDPFusion); +StatefulSDPAFusion::StatefulSDPAFusion() { + MATCHER_SCOPE(StatefulSDPAFusion); using namespace ov::pass::pattern; auto past_k = wrap_type(); @@ -91,13 +91,13 @@ StatefulSDPFusion::StatefulSDPFusion() { args[2] = concat_v_node->input_value(1); args.push_back(read_cvt_k_node ? read_cvt_k_node->output(0) : past_k_node->output(0)); args.push_back(read_cvt_v_node ? read_cvt_v_node->output(0) : past_v_node->output(0)); - ov::intel_cpu::ScaledDotProductAttentionStub::Config config; + ov::intel_cpu::ScaledDotProductAttentionWithKVCache::Config config; config.is_causal = sdp_node->get_causal(); config.fuse_concat = true; auto old_node = sdp_node; - auto new_node = std::make_shared(args, config); + auto new_node = std::make_shared(args, config); new_node->set_friendly_name(old_node->get_friendly_name()); ov::replace_node(old_node, {new_node->output(0)}); if (assign_cvt_k_node) diff --git a/src/plugins/intel_cpu/src/transformations/cpu_opset/common/pass/stateful_sdp_fusion.hpp b/src/plugins/intel_cpu/src/transformations/cpu_opset/common/pass/stateful_sdpa_fusion.hpp similarity index 64% rename from src/plugins/intel_cpu/src/transformations/cpu_opset/common/pass/stateful_sdp_fusion.hpp rename to src/plugins/intel_cpu/src/transformations/cpu_opset/common/pass/stateful_sdpa_fusion.hpp index 21f5250868164e..7de7e018036baa 100644 --- a/src/plugins/intel_cpu/src/transformations/cpu_opset/common/pass/stateful_sdp_fusion.hpp +++ b/src/plugins/intel_cpu/src/transformations/cpu_opset/common/pass/stateful_sdpa_fusion.hpp @@ -8,10 +8,10 @@ namespace ov { namespace intel_cpu { -class StatefulSDPFusion : public ov::pass::MatcherPass { +class StatefulSDPAFusion : public ov::pass::MatcherPass { public: - OPENVINO_RTTI("StatefulSDPFusion", "0"); - StatefulSDPFusion(); + OPENVINO_RTTI("StatefulSDPAFusion", "0"); + StatefulSDPAFusion(); }; } // namespace intel_cpu diff --git a/src/plugins/intel_cpu/src/transformations/snippets/x64/op/brgemm_copy_b.cpp b/src/plugins/intel_cpu/src/transformations/snippets/x64/op/brgemm_copy_b.cpp index 643b5d74fc963b..193d2ce808f002 100644 --- a/src/plugins/intel_cpu/src/transformations/snippets/x64/op/brgemm_copy_b.cpp +++ b/src/plugins/intel_cpu/src/transformations/snippets/x64/op/brgemm_copy_b.cpp @@ -57,32 +57,31 @@ void BrgemmCopyB::custom_constructor_validate_and_infer_types(std::vectorget_shape()); - const auto& element_type = get_input_element_type(0); const auto& planar_pshape = snippets::utils::get_planar_pshape(shape, port->get_layout()); set_output_type(0, element_type, planar_pshape); if (is_with_compensations()) { set_output_type(1, ov::element::f32, planar_pshape); } - validate(planar_pshape, element_type); } -void BrgemmCopyB::validate(const ov::PartialShape& planar_pshape, const ov::element::Type& element_type) { +void BrgemmCopyB::validate_element_type(const ov::element::Type& element_type) { OPENVINO_ASSERT(one_of(element_type, element::bf16, element::i8), "BrgemmCopyB doesn't support element type" + element_type.get_type_name()); } diff --git a/src/plugins/intel_cpu/src/transformations/snippets/x64/op/brgemm_copy_b.hpp b/src/plugins/intel_cpu/src/transformations/snippets/x64/op/brgemm_copy_b.hpp index 9274ad026e5f01..f803e5d55fcb8d 100644 --- a/src/plugins/intel_cpu/src/transformations/snippets/x64/op/brgemm_copy_b.hpp +++ b/src/plugins/intel_cpu/src/transformations/snippets/x64/op/brgemm_copy_b.hpp @@ -67,7 +67,7 @@ class BrgemmCopyB : public snippets::op::MemoryAccess { private: void custom_constructor_validate_and_infer_types(std::vector layout_input = {}); - void validate(const ov::PartialShape& planar_pshape, const ov::element::Type& element_type); + void validate_element_type(const ov::element::Type& element_type); void compute_block_size_values(const size_t blk_size_k, const size_t blk_size_n); Type m_type = Type::OnlyRepacking; diff --git a/src/plugins/intel_cpu/src/transformations/snippets/x64/op/brgemm_cpu.cpp b/src/plugins/intel_cpu/src/transformations/snippets/x64/op/brgemm_cpu.cpp index 20f7fccafe311a..3dd23a04acdd55 100644 --- a/src/plugins/intel_cpu/src/transformations/snippets/x64/op/brgemm_cpu.cpp +++ b/src/plugins/intel_cpu/src/transformations/snippets/x64/op/brgemm_cpu.cpp @@ -16,8 +16,8 @@ namespace intel_cpu { BrgemmCPU::BrgemmCPU(const Output& A, const Output& B, const Type type, const size_t offset_a, const size_t offset_b, const size_t offset_c, std::vector layout_a, std::vector layout_b, std::vector layout_c, - const size_t blk_size_m, const size_t blk_size_k, const size_t blk_size_n) - : Brgemm(), m_type(type) { + const size_t blk_size_m, const size_t blk_size_k, const size_t blk_size_n, const float beta) + : Brgemm(), m_type(type), m_beta(beta) { // We call default ctor of Brgemm class to avoid incorrect shape infer in constructor_validate_and_type_infer() call set_arguments({A, B}); set_output_size(1); @@ -32,8 +32,8 @@ BrgemmCPU::BrgemmCPU(const Output& A, const Output& B, const Type ty BrgemmCPU::BrgemmCPU(const Output& A, const Output& B, const Output& scratch, const Type type, const size_t offset_a, const size_t offset_b, const size_t offset_scratch, const size_t offset_c, std::vector layout_a, std::vector layout_b, std::vector layout_c, - const size_t blk_size_m, const size_t blk_size_k, const size_t blk_size_n) - : Brgemm(), m_type(type) { + const size_t blk_size_m, const size_t blk_size_k, const size_t blk_size_n, const float beta) + : Brgemm(), m_type(type), m_beta(beta) { set_arguments({A, B, scratch}); set_output_size(1); ctor_initialize(std::set{0, 1, 2}, std::set{0}); @@ -48,8 +48,8 @@ BrgemmCPU::BrgemmCPU(const Output& A, const Output& B, const Output< BrgemmCPU::BrgemmCPU(const Output& A, const Output& B, const Type type, const PortDescriptor& desc_a, const PortDescriptor& desc_b, const PortDescriptor& desc_c, std::vector layout_a, std::vector layout_b, std::vector layout_c, - const size_t blk_size_m, const size_t blk_size_k, const size_t blk_size_n) - : Brgemm(), m_type(type) { + const size_t blk_size_m, const size_t blk_size_k, const size_t blk_size_n, const float beta) + : Brgemm(), m_type(type), m_beta(beta) { set_arguments({A, B}); set_output_size(1); m_input_ports = {{0, desc_a}, {1, desc_b}}; @@ -61,8 +61,8 @@ BrgemmCPU::BrgemmCPU(const Output& A, const Output& B, const Type ty BrgemmCPU::BrgemmCPU(const Output& A, const Output& B, const Output& scratch, const Type type, const PortDescriptor& desc_a, const PortDescriptor& desc_b, const PortDescriptor& desc_scratch, const PortDescriptor& desc_c, std::vector layout_a, std::vector layout_b, std::vector layout_c, - const size_t blk_size_m, const size_t blk_size_k, const size_t blk_size_n) - : Brgemm(), m_type(type) { + const size_t blk_size_m, const size_t blk_size_k, const size_t blk_size_n, const float beta) + : Brgemm(), m_type(type), m_beta(beta) { set_arguments({A, B, scratch}); set_output_size(1); m_input_ports = {{0, desc_a}, {1, desc_b}, {2, desc_scratch}}; @@ -134,20 +134,22 @@ void BrgemmCPU::validate_inputs() const { std::shared_ptr BrgemmCPU::clone_with_new_inputs(const OutputVector& new_args) const { INTERNAL_OP_SCOPE(BrgemmCPU_clone_with_new_inputs); check_new_args_count(this, new_args); + std::shared_ptr brgemm; if (!is_with_scratchpad()) { return std::make_shared(new_args.at(0), new_args.at(1), m_type, get_input_port_descriptor(0), get_input_port_descriptor(1), get_output_port_descriptor(0), snippets::lowered::PortDescriptorUtils::get_port_descriptor_ptr(input(0))->get_layout(), snippets::lowered::PortDescriptorUtils::get_port_descriptor_ptr(input(1))->get_layout(), snippets::lowered::PortDescriptorUtils::get_port_descriptor_ptr(output(0))->get_layout(), - m_M_blk, m_K_blk, m_N_blk); + m_M_blk, m_K_blk, m_N_blk, m_beta); + } else { + return std::make_shared(new_args.at(0), new_args.at(1), new_args.at(2), m_type, + get_input_port_descriptor(0), get_input_port_descriptor(1), get_input_port_descriptor(2), get_output_port_descriptor(0), + snippets::lowered::PortDescriptorUtils::get_port_descriptor_ptr(input(0))->get_layout(), + snippets::lowered::PortDescriptorUtils::get_port_descriptor_ptr(input(1))->get_layout(), + snippets::lowered::PortDescriptorUtils::get_port_descriptor_ptr(output(0))->get_layout(), + m_M_blk, m_K_blk, m_N_blk, m_beta); } - return std::make_shared(new_args.at(0), new_args.at(1), new_args.at(2), m_type, - get_input_port_descriptor(0), get_input_port_descriptor(1), get_input_port_descriptor(2), get_output_port_descriptor(0), - snippets::lowered::PortDescriptorUtils::get_port_descriptor_ptr(input(0))->get_layout(), - snippets::lowered::PortDescriptorUtils::get_port_descriptor_ptr(input(1))->get_layout(), - snippets::lowered::PortDescriptorUtils::get_port_descriptor_ptr(output(0))->get_layout(), - m_M_blk, m_K_blk, m_N_blk); } std::shared_ptr BrgemmCPU::get_brgemm_copy() const { @@ -156,7 +158,7 @@ std::shared_ptr BrgemmCPU::get_brgemm_copy() const { if (const auto brgemm_copy_b = ov::as_type_ptr(b_input_node)) { return brgemm_copy_b; } - if (ov::is_type(b_input_node)) { + if (ov::is_type(b_input_node)) { if (const auto brgemm_copy_b = ov::as_type_ptr(b_input_node->get_input_node_shared_ptr(0))) { return brgemm_copy_b; } @@ -169,5 +171,14 @@ size_t BrgemmCPU::get_offset_scratch() const { return get_input_offset(2); } +bool BrgemmCPU::visit_attributes(AttributeVisitor& visitor) { + Brgemm::visit_attributes(visitor); + visitor.on_attribute("blk_M", m_M_blk); + visitor.on_attribute("blk_K", m_K_blk); + visitor.on_attribute("blk_N", m_N_blk); + visitor.on_attribute("beta", m_beta); + return true; +} + } // namespace intel_cpu } // namespace ov diff --git a/src/plugins/intel_cpu/src/transformations/snippets/x64/op/brgemm_cpu.hpp b/src/plugins/intel_cpu/src/transformations/snippets/x64/op/brgemm_cpu.hpp index bf07b7a8546eac..1ea2418f995463 100644 --- a/src/plugins/intel_cpu/src/transformations/snippets/x64/op/brgemm_cpu.hpp +++ b/src/plugins/intel_cpu/src/transformations/snippets/x64/op/brgemm_cpu.hpp @@ -32,19 +32,19 @@ class BrgemmCPU : public snippets::op::Brgemm { BrgemmCPU(const Output& A, const Output& B, const Type type, const size_t offset_a = 0, const size_t offset_b = 0, const size_t offset_c = 0, std::vector layout_a = {}, std::vector layout_b = {}, std::vector layout_c = {}, - const size_t blk_size_m = 0, const size_t blk_size_k = 0, const size_t blk_size_n = 0); + const size_t blk_size_m = 0, const size_t blk_size_k = 0, const size_t blk_size_n = 0, const float beta = 0.f); BrgemmCPU(const Output& A, const Output& B, const Output& scratch, const Type type, const size_t offset_a = 0, const size_t offset_b = 0, const size_t offset_scratch = 0, const size_t offset_c = 0, std::vector layout_a = {}, std::vector layout_b = {}, std::vector layout_c = {}, - const size_t blk_size_m = 0, const size_t blk_size_k = 0, const size_t blk_size_n = 0); + const size_t blk_size_m = 0, const size_t blk_size_k = 0, const size_t blk_size_n = 0, const float beta = 0.f); BrgemmCPU(const Output& A, const Output& B, const Type type, const PortDescriptor& desc_a, const PortDescriptor& desc_b, const PortDescriptor& desc_c, std::vector layout_a = {}, std::vector layout_b = {}, std::vector layout_c = {}, - const size_t blk_size_m = 0, const size_t blk_size_k = 0, const size_t blk_size_n = 0); + const size_t blk_size_m = 0, const size_t blk_size_k = 0, const size_t blk_size_n = 0, const float beta = 0.f); BrgemmCPU(const Output& A, const Output& B, const Output& scratch, const Type type, const PortDescriptor& desc_a, const PortDescriptor& desc_b, const PortDescriptor& desc_scratch, const PortDescriptor& desc_c, std::vector layout_a = {}, std::vector layout_b = {}, std::vector layout_c = {}, - const size_t blk_size_m = 0, const size_t blk_size_k = 0, const size_t blk_size_n = 0); + const size_t blk_size_m = 0, const size_t blk_size_k = 0, const size_t blk_size_n = 0, const float beta = 0.f); BrgemmCPU() = default; void validate_and_infer_types() override; @@ -54,10 +54,12 @@ class BrgemmCPU : public snippets::op::Brgemm { size_t get_m_block_size() const { return m_M_blk; } size_t get_k_block_size() const { return m_K_blk; } size_t get_n_block_size() const { return m_N_blk; } + float get_beta() const { return m_beta; } void set_m_block_size(size_t block_size) { m_M_blk = block_size; } void set_k_block_size(size_t block_size) { m_K_blk = block_size; } void set_n_block_size(size_t block_size) { m_N_blk = block_size; } + void set_beta(float beta) { m_beta = beta; } bool is_with_compensations() const { return m_type == Type::WithCompensations; } bool is_with_data_repacking() const { return m_type != Type::Floating; } @@ -67,6 +69,8 @@ class BrgemmCPU : public snippets::op::Brgemm { size_t get_offset_scratch() const; std::shared_ptr get_brgemm_copy() const; + bool visit_attributes(AttributeVisitor& visitor) override; + constexpr static size_t SCRATCH_BYTE_SIZE = 32 * 1024; private: @@ -79,6 +83,7 @@ class BrgemmCPU : public snippets::op::Brgemm { size_t m_M_blk = 0; size_t m_K_blk = 0; size_t m_N_blk = 0; + float m_beta = 0.f; }; } // namespace intel_cpu diff --git a/src/plugins/intel_cpu/src/transformations/snippets/x64/op/perf_count_rdtsc.cpp b/src/plugins/intel_cpu/src/transformations/snippets/x64/op/perf_count_rdtsc.cpp new file mode 100644 index 00000000000000..a3343d5ab74e8c --- /dev/null +++ b/src/plugins/intel_cpu/src/transformations/snippets/x64/op/perf_count_rdtsc.cpp @@ -0,0 +1,32 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "perf_count_rdtsc.hpp" + +using namespace ov; +using namespace ov::intel_cpu; + +/////////////////////////PerfCountRdtscBegin////////////////////// +PerfCountRdtscBegin::PerfCountRdtscBegin() : PerfCountBeginBase() { + validate_and_infer_types_except_PerfCountEnd(); +} + +std::shared_ptr PerfCountRdtscBegin::clone_with_new_inputs(const OutputVector& inputs) const { + return std::make_shared(); +} + +/////////////////////////PerfCountRdtscEnd////////////////////// +PerfCountRdtscEnd::PerfCountRdtscEnd(const Output& pc_begin) : ov::snippets::op::PerfCountEndBase({pc_begin}), accumulation(0ul), iteration(0u) { + constructor_validate_and_infer_types(); +} + +std::shared_ptr PerfCountRdtscEnd::clone_with_new_inputs(const OutputVector& inputs) const { + return std::make_shared(inputs.at(0)); +} + +std::shared_ptr PerfCountRdtscEnd::get_pc_begin() { + const auto& pc_begin = ov::as_type_ptr(get_input_source_output(get_input_size() - 1).get_node_shared_ptr()); + OPENVINO_ASSERT(pc_begin != nullptr, "PerfCountRdtscEnd last input is not connected to PerfCountRdtscBegin"); + return pc_begin; +} diff --git a/src/plugins/intel_cpu/src/transformations/snippets/x64/op/perf_count_rdtsc.hpp b/src/plugins/intel_cpu/src/transformations/snippets/x64/op/perf_count_rdtsc.hpp new file mode 100644 index 00000000000000..91f8b82fed5055 --- /dev/null +++ b/src/plugins/intel_cpu/src/transformations/snippets/x64/op/perf_count_rdtsc.hpp @@ -0,0 +1,55 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include "openvino/op/op.hpp" +#include "snippets/op/perf_count.hpp" + +using namespace ov::snippets::op; + +namespace ov { +namespace intel_cpu { + +/** + * @interface PerfCountRdtscBegin + * @brief Performance count start time via read rdtsc register + * @ingroup snippets + */ +class PerfCountRdtscBegin : public PerfCountBeginBase { +public: + OPENVINO_OP("PerfCountRdtscBegin", "SnippetsOpset", PerfCountBeginBase); + PerfCountRdtscBegin(); + std::shared_ptr clone_with_new_inputs(const OutputVector& inputs) const override; + + uint64_t start_count = 0ul; +}; + +/** + * @interface PerfCountRdtscEnd + * @brief Performance count end time and duration + * @ingroup snippets + */ +class PerfCountRdtscEnd : public PerfCountEndBase { +public: + OPENVINO_OP("PerfCountRdtscEnd", "SnippetsOpset", PerfCountEndBase); + PerfCountRdtscEnd(const Output& pc_begin); + PerfCountRdtscEnd() = default; + ~PerfCountRdtscEnd() { + uint64_t avg = iteration == 0 ? 0 : accumulation / iteration; + std::cout << "accumulation:" << accumulation << " iteration:" << iteration << " avg:" << avg << std::endl; + } + std::shared_ptr clone_with_new_inputs(const OutputVector& inputs) const override; + + std::shared_ptr get_pc_begin(); + // in each call, PerfCountRdtscBegin get start_count. + // in each call, PerfCountRdtscEnd get end_count, then total_duration += end_count - start_count, and iteration++. + // in destructor of PerfCountRdtscEnd, output the perf info + // accumulation is cycle count + uint64_t accumulation = 0ul; + uint32_t iteration = 0u; +}; + +} // namespace intel_cpu +} // namespace ov diff --git a/src/plugins/intel_cpu/src/transformations/snippets/x64/pass/brgemm_to_brgemm_cpu.cpp b/src/plugins/intel_cpu/src/transformations/snippets/x64/pass/brgemm_to_brgemm_cpu.cpp index 9a08eda8b781eb..ff19f05d591d2d 100644 --- a/src/plugins/intel_cpu/src/transformations/snippets/x64/pass/brgemm_to_brgemm_cpu.cpp +++ b/src/plugins/intel_cpu/src/transformations/snippets/x64/pass/brgemm_to_brgemm_cpu.cpp @@ -92,7 +92,7 @@ pass::BrgemmToBrgemmCPU::BrgemmToBrgemmCPU() { set_full_port_desc(brgemm_repacking->output(0)); if (with_amx) { - const auto scratch = std::make_shared(ov::Shape{BrgemmCPU::SCRATCH_BYTE_SIZE}); + const auto scratch = std::make_shared(ov::Shape{BrgemmCPU::SCRATCH_BYTE_SIZE}); brgemm_cpu = std::make_shared(brgemm->input_value(0), brgemm_repacking->output(0), scratch, BrgemmCPU::Type::AMX, offset_a, offset_b, 0, offset_c, brgemm_in0_desc->get_layout(), std::vector{}, brgemm_out_desc->get_layout()); diff --git a/src/plugins/intel_cpu/src/transformations/snippets/x64/pass/lowered/brgemm_blocking.cpp b/src/plugins/intel_cpu/src/transformations/snippets/x64/pass/lowered/brgemm_blocking.cpp index 5fffd007b93676..fc9aeeac10ee92 100644 --- a/src/plugins/intel_cpu/src/transformations/snippets/x64/pass/lowered/brgemm_blocking.cpp +++ b/src/plugins/intel_cpu/src/transformations/snippets/x64/pass/lowered/brgemm_blocking.cpp @@ -7,8 +7,10 @@ #include "openvino/pass/pattern/matcher.hpp" #include "openvino/pass/pattern/op/wrap_type.hpp" #include "snippets/itt.hpp" +#include "snippets/utils.hpp" #include "snippets/lowered/linear_ir.hpp" #include "snippets/lowered/loop_manager.hpp" +#include "snippets/lowered/pass/insert_tail_loop.hpp" #include "snippets/snippets_isa.hpp" #include "transformations/snippets/x64/op/brgemm_cpu.hpp" @@ -16,19 +18,17 @@ namespace ov { namespace intel_cpu { namespace pass { -using LoopManager = snippets::lowered::LinearIR::LoopManager; -using LoopInfoPtr = LoopManager::LoopInfoPtr; -using LoopPort = LoopManager::LoopPort; +using LinearIR = snippets::lowered::LinearIR; +using LoopPort = LinearIR::LoopManager::LoopPort; +using ExpressionPtr = ov::snippets::lowered::ExpressionPtr; BrgemmBlocking::BrgemmBlocking() : Pass() {} void BrgemmBlocking::move_new_memory_buffer(snippets::lowered::LinearIR& linear_ir, const snippets::lowered::LinearIR::constExprIt& brgemm_it) { const auto& brgemm_expr = brgemm_it->get(); const auto wsp_expr = brgemm_expr->get_input_port_connector(2)->get_source().get_expr(); - const auto wsp_buffer = ov::as_type_ptr(wsp_expr->get_node()); - OPENVINO_ASSERT(wsp_buffer && wsp_buffer->is_new_memory(), "Incorrect Scratchpad buffer for Brgemm AMX"); - // [115164] Should be fully supported by explicit loops of blocking by K, N - OPENVINO_ASSERT(brgemm_expr->get_loop_ids().empty() && wsp_expr->get_loop_ids().empty(), "Incorrect blocking loop marking for Brgemm AMX"); + const auto wsp_buffer = ov::as_type_ptr(wsp_expr->get_node()); + OPENVINO_ASSERT(wsp_buffer, "Incorrect Scratchpad buffer for Brgemm AMX"); // If scratchpad with temp memory is not explicitly before Brgemm, need to move to there. if (wsp_expr != *std::prev(brgemm_it)) { const auto wsp_it = linear_ir.find(wsp_expr); @@ -36,24 +36,22 @@ void BrgemmBlocking::move_new_memory_buffer(snippets::lowered::LinearIR& linear_ } } -bool BrgemmBlocking::run(snippets::lowered::LinearIR& linear_ir) { +bool BrgemmBlocking::run(LinearIR& linear_ir) { OV_ITT_SCOPED_TASK(ov::pass::itt::domains::SnippetsTransform, "Snippets::BrgemmBlocking") if (linear_ir.empty()) return false; - const auto& loop_manager = linear_ir.get_loop_manager(); - const size_t dim_idx = 1; + auto blocking_loop_exists = [&](const ExpressionPtr& brgemm_expr, const std::shared_ptr& brgemm) { + auto check_port = [&](const LoopPort& p) { + return p.expr_port->get_expr() == brgemm_expr && ov::snippets::utils::one_of(p.dim_idx, 0ul, 1ul); + }; - auto blocking_loop_exists = [&](const ov::snippets::lowered::ExpressionPtr& expr, - const std::shared_ptr& brgemm) { - const auto& loop_ids = expr->get_loop_ids(); + const auto& loop_ids = brgemm_expr->get_loop_ids(); for (const auto& id : loop_ids) { const auto loop = loop_manager->get_loop_info(id); - if (loop->dim_idx == dim_idx) { - OPENVINO_ASSERT(brgemm->get_input_count(0) == loop->increment, - "Brgemm ", brgemm, " has input count (", brgemm->get_input_count(0), - ") which doesn't match the increment(", loop->increment, ") of loop by M"); + if (std::any_of(loop->get_entry_points().begin(), loop->get_entry_points().end(), check_port) || + std::any_of(loop->get_exit_points().begin(), loop->get_exit_points().end(), check_port)) { return true; } } @@ -62,34 +60,141 @@ bool BrgemmBlocking::run(snippets::lowered::LinearIR& linear_ir) { bool modified = false; for (auto expr_it = linear_ir.begin(); expr_it != linear_ir.end(); expr_it++) { - const auto& expr = *expr_it; - const auto brgemm = ov::as_type_ptr(expr->get_node()); - if (!brgemm || blocking_loop_exists(expr, brgemm)) + const auto& brgemm_expr = *expr_it; + const auto brgemm = ov::as_type_ptr(brgemm_expr->get_node()); + if (!brgemm || blocking_loop_exists(brgemm_expr, brgemm)) continue; - const auto& input_shape_0 = expr->get_input_port_descriptor(0)->get_shape(); - const auto& input_layout_0 = expr->get_input_port_descriptor(0)->get_layout(); - const auto& dim = *(input_layout_0.rbegin() + dim_idx); - const auto& m = input_shape_0[dim]; - - const auto block_size = brgemm->get_m_block_size(); - brgemm->set_input_count(block_size); - - const auto work_amount = m; - const auto increment = block_size; - - auto loop_begin_it = expr_it, loop_end_it = std::next(expr_it); - std::vector entries{LoopPort(expr->get_input_port(0), true), LoopPort(expr->get_input_port(1), false)}; - // Scratchpad for AMX scenario is needed only as temporary buffer for each M block - it means that the Buffer should be in this loop. - // Other scratchpads (that after BrgemmCopyB) should be the loop outside. - if (brgemm->is_with_compensations()) { - entries.emplace_back(expr->get_input_port(2), false); - } else if (brgemm->is_amx()) { - move_new_memory_buffer(linear_ir, expr_it); - loop_begin_it = std::prev(expr_it); - } - std::vector exits{LoopPort(expr->get_output_port(0), true)}; - loop_manager->mark_loop(loop_begin_it, loop_end_it, work_amount, increment, dim_idx, entries, exits); + const auto& in_0_desc = brgemm_expr->get_input_port_descriptor(0); + const auto& in_1_desc = brgemm_expr->get_input_port_descriptor(1); + const auto& out_desc = brgemm_expr->get_output_port_descriptor(0); + + const auto& in_0_planar_dims = ov::snippets::utils::get_planar_vdims(in_0_desc->get_shape(), in_0_desc->get_layout()); + const auto& in_1_planar_dims = ov::snippets::utils::get_planar_vdims(in_1_desc->get_shape(), in_1_desc->get_layout()); + const auto& out_preordered_dims = ov::snippets::utils::get_preordered_vdims(out_desc->get_shape(), out_desc->get_layout()); + + auto in_0_subtensor = in_0_desc->get_subtensor(); + auto in_1_subtensor = in_1_desc->get_subtensor(); + auto out_subtensor = out_desc->get_subtensor(); + + auto apply_m_blocking = [&]() { + const auto& m = *(out_preordered_dims.rbegin() + 1); + const auto block_size_m = brgemm->get_m_block_size(); + if (block_size_m >= m) { + *(in_0_subtensor.rbegin() + 1) = m; + *(out_subtensor.rbegin() + 1) = m; + } else { + *(in_0_subtensor.rbegin() + 1) = block_size_m; + *(out_subtensor.rbegin() + 1) = block_size_m; + + auto loop_begin_it = expr_it, loop_end_it = std::next(expr_it); + std::vector entries{LoopPort(brgemm_expr->get_input_port(0), true), + LoopPort(brgemm_expr->get_input_port(1), false)}; + if (brgemm->is_with_compensations()) { + entries.emplace_back(brgemm_expr->get_input_port(2), false); + } else if (brgemm->is_amx()) { + move_new_memory_buffer(linear_ir, expr_it); + loop_begin_it = std::prev(expr_it); + } + std::vector exits{LoopPort(brgemm_expr->get_output_port(0), true)}; + loop_manager->mark_loop(loop_begin_it, loop_end_it, m, block_size_m, 1, entries, exits); + } + }; + + auto apply_n_blocking = [&]() { + const auto& n = *out_preordered_dims.rbegin(); + const auto block_size_n = brgemm->get_n_block_size(); + if (block_size_n >= n) { + *in_1_subtensor.rbegin() = n; + *out_subtensor.rbegin() = n; + } else { + *in_1_subtensor.rbegin() = block_size_n; + *out_subtensor.rbegin() = block_size_n; + + auto loop_begin_it = expr_it, loop_end_it = std::next(expr_it); + std::vector entries{LoopPort(brgemm_expr->get_input_port(0), false), + LoopPort(brgemm_expr->get_input_port(1), true)}; + if (brgemm->is_with_compensations()) { + entries.emplace_back(brgemm_expr->get_input_port(2), true); + } else if (brgemm->is_amx()) { + move_new_memory_buffer(linear_ir, expr_it); + loop_begin_it = std::prev(expr_it); + } + std::vector exits{LoopPort(brgemm_expr->get_output_port(0), true)}; + loop_manager->mark_loop(loop_begin_it, loop_end_it, n, block_size_n, 0, entries, exits); + } + }; + + auto apply_k_blocking = [&]() { + const auto& k = *in_0_planar_dims.rbegin(); + OPENVINO_ASSERT(k == *(in_1_planar_dims.rbegin() + 1), "Brgemm input descriptors have different K dimension value."); + const auto block_size_k = brgemm->get_k_block_size(); + if (block_size_k >= k) { + *in_0_subtensor.rbegin() = k; + *(in_1_subtensor.rbegin() + 1) = k; + } else { + *in_0_subtensor.rbegin() = block_size_k; + *(in_1_subtensor.rbegin() + 1) = block_size_k; + + auto loop_begin_it = expr_it, loop_end_it = std::next(expr_it); + std::vector entries{LoopPort(brgemm_expr->get_input_port(0), true, 0), + LoopPort(brgemm_expr->get_input_port(1), true, 1)}; + if (brgemm->is_with_compensations()) { + entries.emplace_back(brgemm_expr->get_input_port(2), false, 1); + } else if (brgemm->is_amx()) { + move_new_memory_buffer(linear_ir, expr_it); + loop_begin_it = std::prev(expr_it); + } + std::vector exits{LoopPort(brgemm_expr->get_output_port(0), false)}; + auto loop_id = loop_manager->mark_loop(loop_begin_it, loop_end_it, k, block_size_k, entries, exits); + const auto loop_info = loop_manager->get_loop_info(loop_id); + + auto first_iter_handler = [](LinearIR& linear_ir, LinearIR::constExprIt loop_end_it) { + const auto loop_end = ov::as_type_ptr(loop_end_it->get()->get_node()); + OPENVINO_ASSERT(loop_end, "First loop iteraton handler must be called on LoopEnd expression"); + const auto loop_id = loop_end->get_id(); + const auto& loop_manager = linear_ir.get_loop_manager(); + const auto& loop_info = loop_manager->get_loop_info(loop_id); + const auto work_amount = loop_info->get_work_amount(); + const auto increment = loop_info->get_increment(); + if (work_amount <= increment) + return false; + + auto new_loop_range = snippets::lowered::pass::InsertTailLoop::copy_loop(linear_ir, loop_id); + const auto firt_iter_loop_end = ov::as_type_ptr(std::prev(new_loop_range.end())->get()->get_node()); + auto first_iter_loop_info = loop_manager->get_loop_info(firt_iter_loop_end->get_id()); + firt_iter_loop_end->set_work_amount(increment); + first_iter_loop_info->set_work_amount(increment); + firt_iter_loop_end->set_finalization_offsets(std::vector(loop_end->get_finalization_offsets().size(), 0)); + + const auto loop_begin_it = linear_ir.find(linear_ir.get_expr_by_node(loop_end->get_loop_begin())); + linear_ir.insert(loop_begin_it, new_loop_range.begin(), new_loop_range.end()); + + const auto new_work_amount = work_amount - increment; + loop_info->set_work_amount(new_work_amount); + loop_end->set_work_amount(new_work_amount); + + // Update original body's Brgemms with new beta parameter + for (auto expr_it = loop_begin_it; expr_it != loop_end_it; ++expr_it) { + const auto& expr_node = expr_it->get()->get_node(); + if (const auto brgemm = ov::as_type_ptr(expr_node)) { + brgemm->set_beta(1.f); + } + } + return true; + }; + loop_info->set_first_iter_handler(first_iter_handler); + } + }; + + apply_k_blocking(); + apply_n_blocking(); + apply_m_blocking(); + + brgemm_expr->get_input_port_descriptor(0)->set_subtensor(in_0_subtensor); + brgemm_expr->get_input_port_descriptor(1)->set_subtensor(in_1_subtensor); + brgemm_expr->get_output_port_descriptor(0)->set_subtensor(out_subtensor); + modified = true; } return modified; diff --git a/src/plugins/intel_cpu/src/transformations/snippets/x64/pass/lowered/brgemm_blocking.hpp b/src/plugins/intel_cpu/src/transformations/snippets/x64/pass/lowered/brgemm_blocking.hpp index 585cd2ad0ae23e..81ae47aa3c6948 100644 --- a/src/plugins/intel_cpu/src/transformations/snippets/x64/pass/lowered/brgemm_blocking.hpp +++ b/src/plugins/intel_cpu/src/transformations/snippets/x64/pass/lowered/brgemm_blocking.hpp @@ -12,7 +12,7 @@ namespace pass { /** * @interface BrgemmBlocking - * @brief Covers BrgemmCPU with blocking loop by M + * @brief Covers BrgemmCPU with blocking loops * @ingroup snippets */ diff --git a/src/plugins/intel_cpu/src/transformations/snippets/x64/pass/lowered/fuse_load_store_and_convert.cpp b/src/plugins/intel_cpu/src/transformations/snippets/x64/pass/lowered/fuse_load_store_and_convert.cpp index fff9182883df2d..319b17d3e6cb07 100644 --- a/src/plugins/intel_cpu/src/transformations/snippets/x64/pass/lowered/fuse_load_store_and_convert.cpp +++ b/src/plugins/intel_cpu/src/transformations/snippets/x64/pass/lowered/fuse_load_store_and_convert.cpp @@ -6,6 +6,7 @@ #include "fuse_load_store_and_convert.hpp" #include "snippets/snippets_isa.hpp" +#include "snippets/lowered/loop_manager.hpp" #include "transformations/snippets/x64/op/load_convert.hpp" #include "transformations/snippets/x64/op/store_convert.hpp" @@ -32,13 +33,13 @@ bool ov::intel_cpu::pass::FuseLoadStoreConvert::fuse_load_convert(snippets::lowe return false; std::shared_ptr load_convert = nullptr; - if (const auto convert_saturation = ov::as_type_ptr(convert)) { + if (ov::is_type(convert)) { load_convert = std::make_shared(load->input_value(0), - convert_saturation->get_destination_type(), + convert->get_destination_type(), load->get_count(), load->get_offset()); - } else if (const auto convert_truncation = ov::as_type_ptr(convert)) { + } else if (ov::is_type(convert)) { load_convert = std::make_shared(load->input_value(0), - convert_truncation->get_destination_type(), + convert->get_destination_type(), load->get_count(), load->get_offset()); } else { OPENVINO_THROW("Type of Convert op is undefined. Supports only fusing Load and ConvertTruncation or ConvertSaturation ops"); @@ -51,6 +52,13 @@ bool ov::intel_cpu::pass::FuseLoadStoreConvert::fuse_load_convert(snippets::lowe const auto convert_expr_it = convert_it; const auto insertion_pos = std::next(convert_it); convert_it = linear_ir.insert(insertion_pos, load_convert_expr); + + const auto& load_loop_ids = load_expr->get_loop_ids(); + load_convert_expr->set_loop_ids(load_loop_ids); + const auto& loop_manager = linear_ir.get_loop_manager(); + loop_manager->update_loops_port(load_loop_ids, load_expr->get_input_port(0), {load_convert_expr->get_input_port(0)}, true); + loop_manager->update_loops_port(load_loop_ids, convert_expr->get_output_port(0), {load_convert_expr->get_output_port(0)}, false); + linear_ir.erase(std::find(linear_ir.cbegin(), convert_expr_it, load_expr)); linear_ir.erase(convert_expr_it); linear_ir.replace_input(convert_consumers, load_convert_expr->get_output_port_connector(0)); @@ -60,7 +68,7 @@ bool ov::intel_cpu::pass::FuseLoadStoreConvert::fuse_load_convert(snippets::lowe bool ov::intel_cpu::pass::FuseLoadStoreConvert::fuse_store_convert(snippets::lowered::LinearIR& linear_ir, snippets::lowered::LinearIR::constExprIt& convert_it) { const auto& convert_expr = *convert_it; - const auto& convert = convert_expr->get_node(); + const auto& convert = ov::as_type_ptr(convert_expr->get_node()); const auto& input_connector = convert_expr->get_input_port_connector(0); const auto& output_connector = convert_expr->get_output_port_connector(0); if (convert->get_input_element_type(0) != ov::element::f32 && convert->get_input_element_type(0) != ov::element::i32) @@ -77,13 +85,13 @@ bool ov::intel_cpu::pass::FuseLoadStoreConvert::fuse_store_convert(snippets::low return false; std::shared_ptr store_convert = nullptr; - if (const auto convert_saturation = ov::as_type_ptr(convert)) { + if (ov::is_type(convert)) { store_convert = std::make_shared(convert->input_value(0), - convert_saturation->get_destination_type(), + convert->get_destination_type(), store->get_count(), store->get_offset()); - } else if (const auto convert_truncation = ov::as_type_ptr(convert)) { + } else if (ov::is_type(convert)) { store_convert = std::make_shared(convert->input_value(0), - convert_truncation->get_destination_type(), + convert->get_destination_type(), store->get_count(), store->get_offset()); } else { OPENVINO_THROW("Type of Convert op is undefined. Supports only fusing Store and ConvertTruncation or ConvertSaturation ops"); @@ -96,6 +104,13 @@ bool ov::intel_cpu::pass::FuseLoadStoreConvert::fuse_store_convert(snippets::low const auto convert_expr_it = convert_it; const auto insertion_pos = std::next(convert_it); convert_it = linear_ir.insert(insertion_pos, store_convert_expr); + + const auto& convert_loop_ids = convert_expr->get_loop_ids(); + store_convert_expr->set_loop_ids(convert_loop_ids); + const auto& loop_manager = linear_ir.get_loop_manager(); + loop_manager->update_loops_port(convert_loop_ids, convert_expr->get_input_port(0), {store_convert_expr->get_input_port(0)}, true); + loop_manager->update_loops_port(convert_loop_ids, store_expr->get_output_port(0), {store_convert_expr->get_output_port(0)}, false); + linear_ir.erase(std::find(convert_expr_it, linear_ir.cend(), store_expr)); linear_ir.erase(convert_expr_it); linear_ir.replace_input(store_consumers, store_convert_expr->get_output_port_connector(0)); diff --git a/src/plugins/intel_cpu/src/transformations/snippets/x64/pass/lowered/set_brgemm_copy_b_buffers_shape.cpp b/src/plugins/intel_cpu/src/transformations/snippets/x64/pass/lowered/set_brgemm_copy_b_buffers_shape.cpp index 91bec8aee60d4a..0f14f9a7dc5d8a 100644 --- a/src/plugins/intel_cpu/src/transformations/snippets/x64/pass/lowered/set_brgemm_copy_b_buffers_shape.cpp +++ b/src/plugins/intel_cpu/src/transformations/snippets/x64/pass/lowered/set_brgemm_copy_b_buffers_shape.cpp @@ -16,7 +16,7 @@ bool ov::intel_cpu::pass::SetBrgemmCopyBBuffersShape::run(snippets::lowered::Lin auto get_buffer_from_output = [](const snippets::lowered::ExpressionPtr& expr, const size_t out_idx) { const auto& consumers = expr->get_output_port_connector(out_idx)->get_consumers(); OPENVINO_ASSERT(consumers.size() == 1, "BrgemmCopyB must have only 1 consumer"); - const auto buffer = ov::as_type_ptr(consumers.begin()->get_expr()->get_node()); + const auto buffer = ov::as_type_ptr(consumers.begin()->get_expr()->get_node()); OPENVINO_ASSERT(buffer, "BrgemmCopyB consumer must be Buffer"); return buffer; }; diff --git a/src/plugins/intel_cpu/src/transformations/snippets/x64/pass/lowered/set_brgemm_copy_b_buffers_shape.hpp b/src/plugins/intel_cpu/src/transformations/snippets/x64/pass/lowered/set_brgemm_copy_b_buffers_shape.hpp index fcac51286e00a6..c7eec92700a16a 100644 --- a/src/plugins/intel_cpu/src/transformations/snippets/x64/pass/lowered/set_brgemm_copy_b_buffers_shape.hpp +++ b/src/plugins/intel_cpu/src/transformations/snippets/x64/pass/lowered/set_brgemm_copy_b_buffers_shape.hpp @@ -13,6 +13,8 @@ namespace pass { /** * @interface SetBrgemmCopyBBuffersShape * @brief Sets the allocation shape for the Buffers after BrgemmCopyB node using BrgemmCopyB parameters + * This pass may be deprecated when a more generic memory management approach is introduced. + * Ticket: 113744 * @ingroup snippets */ class SetBrgemmCopyBBuffersShape: public snippets::lowered::pass::Pass { diff --git a/src/plugins/intel_cpu/src/transformations/snippets/x64/pass/set_brgemm_cpu_blocking_params.cpp b/src/plugins/intel_cpu/src/transformations/snippets/x64/pass/set_brgemm_cpu_blocking_params.cpp index 939998c08bd79e..bd87737ed2c96e 100644 --- a/src/plugins/intel_cpu/src/transformations/snippets/x64/pass/set_brgemm_cpu_blocking_params.cpp +++ b/src/plugins/intel_cpu/src/transformations/snippets/x64/pass/set_brgemm_cpu_blocking_params.cpp @@ -19,7 +19,6 @@ #include "cpu_shape.h" #include "utils/general_utils.h" - namespace ov { namespace intel_cpu { pass::SetBrgemmCPUBlockingParams::SetBrgemmCPUBlockingParams() { @@ -35,42 +34,43 @@ pass::SetBrgemmCPUBlockingParams::SetBrgemmCPUBlockingParams() { return false; } - const auto dimsMatMulIn0 = snippets::utils::get_planar_pshape(brgemm->input(0)).get_shape(); - const auto dimsMatMulIn1 = snippets::utils::get_planar_pshape(brgemm->input(1)).get_shape(); - const auto K = *dimsMatMulIn0.rbegin(); - const auto N = *dimsMatMulIn1.rbegin(); - const auto& input_1_precision = brgemm->get_input_element_type(1); - // Ticket: 113745 // TODO: extend block size selection heuristics - const size_t brgemm_block_size_m = 32; - const size_t brgemm_block_size_k = [&]() { + auto get_block_size_m = [&](const size_t M) { + return 32; + }; + auto get_block_size_k = [&](const size_t K) { if (input_1_precision != ov::element::f32) return K; return K > 1024 ? 1024 : K > 512 ? 512 : K; - }(); - const size_t brgemm_block_size_n = input_1_precision != ov::element::f32 ? N : 64; - - brgemm->set_m_block_size(brgemm_block_size_m); - brgemm->set_k_block_size(brgemm_block_size_k); - brgemm->set_n_block_size(brgemm_block_size_n); - + }; + auto get_block_size_n = [&](const size_t N) { + return input_1_precision != ov::element::f32 ? N : 64; + }; + + const auto brgemm_in0_dims = snippets::utils::get_planar_pshape(brgemm->input(0)).get_shape(); + const auto M = *(brgemm_in0_dims.rbegin() + 1); + const auto K = *brgemm_in0_dims.rbegin(); + const auto brgemm_in1_dims = snippets::utils::get_planar_pshape(brgemm->input(1)).get_shape(); + const auto N = *brgemm_in1_dims.rbegin(); if (brgemm->is_with_data_repacking()) { const auto brgemm_copy_b = brgemm->get_brgemm_copy(); - const bool isAMXSupported = dnnl::impl::cpu::x64::mayiuse(dnnl::impl::cpu::x64::avx512_core_amx); const auto precision = brgemm_copy_b->get_src_element_type(); const auto brgemmVNNIFactor = brgemm_copy_b->get_brgemm_vnni_factor(); const bool use_amx = isAMXSupported && precision != ov::element::f32 && (K % brgemmVNNIFactor == 0) && (N % brgemmVNNIFactor == 0); - const size_t copy_b_block_size_k = use_amx ? brgemm_block_size_k : K; + const size_t copy_b_block_size_k = use_amx ? get_block_size_k(K) : K; const size_t copy_b_block_size_n = 64; brgemm_copy_b->set_k_block_size(copy_b_block_size_k); brgemm_copy_b->set_n_block_size(copy_b_block_size_n); } + brgemm->set_m_block_size(get_block_size_m(M)); + brgemm->set_k_block_size(get_block_size_k(K)); + brgemm->set_n_block_size(get_block_size_n(N)); return false; }; @@ -78,4 +78,4 @@ pass::SetBrgemmCPUBlockingParams::SetBrgemmCPUBlockingParams() { register_matcher(m, callback); } } // namespace intel_cpu -} // namespace ov +} // namespace ov \ No newline at end of file diff --git a/src/plugins/intel_cpu/src/transformations/snippets/x64/shape_inference.cpp b/src/plugins/intel_cpu/src/transformations/snippets/x64/shape_inference.cpp index 6bb833262a516c..a9674cc00daa1f 100644 --- a/src/plugins/intel_cpu/src/transformations/snippets/x64/shape_inference.cpp +++ b/src/plugins/intel_cpu/src/transformations/snippets/x64/shape_inference.cpp @@ -9,6 +9,7 @@ #include "op/fused_mul_add.hpp" #include "op/load_convert.hpp" #include "op/store_convert.hpp" +#include "op/perf_count_rdtsc.hpp" #include "transformations/cpu_opset/common/op/swish_cpu.hpp" namespace ov { @@ -38,6 +39,8 @@ const CPUShapeInferSnippetsFactory::TRegistry CPUShapeInferSnippetsFactory::spec SHAPE_INFER_PREDEFINED(ov::intel_cpu::LoadConvertTruncation, PassThroughShapeInfer), SHAPE_INFER_PREDEFINED(ov::intel_cpu::StoreConvertSaturation, PassThroughShapeInfer), SHAPE_INFER_PREDEFINED(ov::intel_cpu::StoreConvertTruncation, PassThroughShapeInfer), + SHAPE_INFER_PREDEFINED(ov::intel_cpu::PerfCountRdtscBegin, EmptyShapeInfer), + SHAPE_INFER_PREDEFINED(ov::intel_cpu::PerfCountRdtscEnd, EmptyShapeInfer), SHAPE_INFER_OP_SPECIFIC_EXTERNAL(ov::intel_cpu::BrgemmCPU, BrgemmShapeInfer), // SHAPE_INFER_OP_SPECIFIC(ov::intel_cpu::BrgemmCopyB), diff --git a/src/plugins/intel_cpu/src/transformations/transformation_pipeline.cpp b/src/plugins/intel_cpu/src/transformations/transformation_pipeline.cpp index ebc3bc61bffd24..d593a520ee0562 100644 --- a/src/plugins/intel_cpu/src/transformations/transformation_pipeline.cpp +++ b/src/plugins/intel_cpu/src/transformations/transformation_pipeline.cpp @@ -30,6 +30,7 @@ #include "transformations/common_optimizations/common_optimizations.hpp" #include "transformations/common_optimizations/wrap_interpolate_into_transposes.hpp" #include "transformations/common_optimizations/matmul_const_transposes_extraction.hpp" +#include "transformations/common_optimizations/fuse_rotary_positional_embeddings.hpp" #include "transformations/control_flow/unroll_tensor_iterator.hpp" #include "transformations/fp16_compression/mark_decompression_convert_constant_folding.hpp" #include "transformations/op_conversions/convert_batch_to_space.hpp" @@ -112,7 +113,7 @@ #include "transformations/cpu_opset/common/pass/move_eltwise_up_data_movement.hpp" #include "transformations/cpu_opset/common/pass/swap_convert_transpose.hpp" #include "transformations/cpu_opset/common/pass/rope_fusion.hpp" -#include "transformations/cpu_opset/common/pass/stateful_sdp_fusion.hpp" +#include "transformations/cpu_opset/common/pass/stateful_sdpa_fusion.hpp" // Snippets #include "snippets/pass/tokenization.hpp" @@ -326,6 +327,7 @@ void Transformations::PreLpt(const std::vector& defaultPrecis CPU_REGISTER_PASS_COMMON(manager, ov::pass::AUGRUCellFusion); CPU_REGISTER_PASS_COMMON(manager, ov::pass::CommonOptimizations); + CPU_REGISTER_PASS_COMMON(manager, ov::pass::RPE_Fusion); CPU_REGISTER_PASS_COMMON(manager, ov::pass::WrapInterpolateIntoTransposes); CPU_REGISTER_PASS_COMMON(manager, ov::pass::TransposeSinking); CPU_REGISTER_PASS_COMMON(manager, ov::pass::ConvertSequenceToTensorIterator); @@ -473,6 +475,8 @@ void Transformations::PreLpt(const std::vector& defaultPrecis CPU_DISABLE_PASS_COMMON(manager, ov::pass::ConvertTopK11ToTopK3); CPU_DISABLE_PASS_COMMON(manager, ov::pass::HSwishDecomposition); CPU_DISABLE_PASS_COMMON(manager, ov::pass::MatMulConstTransposesExtraction); + // CVS-126827: should be disabled until CPU supports this internal op + CPU_DISABLE_PASS_COMMON(manager, ov::pass::RPE_Fusion); CPU_DISABLE_PASS_X64(manager, ov::pass::HSigmoidDecomposition); CPU_DISABLE_PASS_X64(manager, ov::pass::ReduceL1Decomposition); @@ -661,7 +665,7 @@ void Transformations::PostLpt() { CPU_REGISTER_PASS_X64(postLPTPassManager, EliminateStridedSlice); CPU_REGISTER_PASS_X64(postLPTPassManager, RoPEFusion); - CPU_REGISTER_PASS_X64(postLPTPassManager, StatefulSDPFusion); + CPU_REGISTER_PASS_X64(postLPTPassManager, StatefulSDPAFusion); postLPTPassManager.run_passes(model); } diff --git a/src/plugins/intel_cpu/src/utils/cpu_utils.hpp b/src/plugins/intel_cpu/src/utils/cpu_utils.hpp index 1c607d6c805c90..c2f7e867956382 100644 --- a/src/plugins/intel_cpu/src/utils/cpu_utils.hpp +++ b/src/plugins/intel_cpu/src/utils/cpu_utils.hpp @@ -86,11 +86,6 @@ inline bool isPerTensorOrPerChannelBroadcastable(const VectorDims &firstInputDim return true; } -inline bool isEmptyTensorDesc(const InferenceEngine::TensorDesc &td) { - const auto dims = td.getDims(); - return std::any_of(dims.begin(), dims.end(), [](size_t dim) { return dim == 0; } ); -} - /** * @brief Return precision to which given precision must be converted to be supported in plug-in * @param precision diff --git a/src/plugins/intel_cpu/src/utils/gen_pattern.hpp b/src/plugins/intel_cpu/src/utils/gen_pattern.hpp index c562190494ed4e..a7b29c7f6c78e1 100644 --- a/src/plugins/intel_cpu/src/utils/gen_pattern.hpp +++ b/src/plugins/intel_cpu/src/utils/gen_pattern.hpp @@ -357,7 +357,7 @@ struct AttrAny { return any.as>(); } - template + template std::vector as_T_vector() { if (any.empty()) return {}; @@ -574,6 +574,10 @@ class GenericPattern : public ov::pass::pattern::op::Pattern { bool match_value(ov::pass::pattern::Matcher* matcher, const Output& pattern_value, const Output& graph_value) override { + // strictly requires pattern & graph value to come from output port with same index, + // this is absolute necessary when pattern contains split node connections. + if (pattern_value.get_index() != graph_value.get_index()) + return false; if (m_predicate(graph_value)) { auto& pattern_map = matcher->get_pattern_value_map(); pattern_map[shared_from_this()] = graph_value; @@ -858,7 +862,7 @@ class AttrMatcher : public ov::AttributeVisitor { } else if (auto a = ov::as_type>(&adapter)) { is_matched = m_attr_map[name].equal_to(a->get()); } else { - OPENVINO_THROW("AttrSetter met unsupported AttributeAdapter"); + OPENVINO_THROW("AttrMatcher met unsupported AttributeAdapter ", name); } add_match_result(name, is_matched); } @@ -919,6 +923,13 @@ std::shared_ptr makeConst(const ov::element::Type& type, return std::make_shared(type, shape, std::vector(values)); } +inline std::shared_ptr makeConst(const std::vector& v) { + auto node = ov::pass::pattern::wrap_type(); + auto& rt_info = node->get_rt_info(); + rt_info["symbolic_const_value"] = v; + return node; +} + template std::shared_ptr makeConst(const ov::element::Type& type, const ov::Shape& shape, const std::vector& values) { return std::make_shared(type, shape, values); @@ -1198,7 +1209,7 @@ class PatternValidator { auto byte_size = shape_size(vconst_node->get_output_shape(0)) * vconst_node->get_output_element_type(0).size(); if (std::memcmp(pconst_node->get_data_ptr(), vconst_node->get_data_ptr(), byte_size) != 0) { - _VERBOSE_LOG("Constant value mismatch."); + _VERBOSE_LOG("Constant value mismatch on ", pconst_node, " vs ", vconst_node); return false; } continue; diff --git a/src/plugins/intel_cpu/src/utils/node_dumper.cpp b/src/plugins/intel_cpu/src/utils/node_dumper.cpp index ed4793ab2e88da..24d7a6d403081e 100644 --- a/src/plugins/intel_cpu/src/utils/node_dumper.cpp +++ b/src/plugins/intel_cpu/src/utils/node_dumper.cpp @@ -107,12 +107,10 @@ static void dumpInternalBlobs(const NodePtr& node, const DebugCapsConfig& config std::string file_name = NameFromType(node->getType()) + "_" + nodeName + "_blb" + std::to_string(i) + ".ieb"; auto dump_file = config.blobDumpDir + "/#" + std::to_string(node->getExecIndex()) + "_" + file_name; - TensorDesc desc = blb->getTensorDesc(); - if (InferenceEngine::details::convertPrecision(desc.getPrecision()) == ov::element::u1) + if (blb->getDesc().getPrecision() == ov::element::u1) continue; - MemoryPtr memory = std::make_shared(node->getEngine(), MemoryDescUtils::convertToDnnlBlockedMemoryDesc(desc), blb->buffer()); - BlobDumper dumper(memory); + BlobDumper dumper(blb); dump(dumper, dump_file, config); } } diff --git a/src/plugins/intel_cpu/src/utils/plain_tensor.hpp b/src/plugins/intel_cpu/src/utils/plain_tensor.hpp index f6441e18a68f47..945e872dedf5cf 100644 --- a/src/plugins/intel_cpu/src/utils/plain_tensor.hpp +++ b/src/plugins/intel_cpu/src/utils/plain_tensor.hpp @@ -4,7 +4,6 @@ #pragma once -#include #include #include @@ -58,26 +57,6 @@ inline void assert_dt(ov::element::Type dt) { OPENVINO_ASSERT(dt == ov::element::f16); } -template -struct data_type_name { - static constexpr const char* value = "?"; -}; - -template <> -struct data_type_name { - static constexpr const char* value = "float"; -}; - -template <> -struct data_type_name { - static constexpr const char* value = "bfloat16"; -}; - -template <> -struct data_type_name { - static constexpr const char* value = "uint8_t"; -}; - template struct precision_of { static constexpr ov::element::Type_t value = ov::element::Type_t::undefined; @@ -110,7 +89,6 @@ struct precision_of { #define PLAINTENSOR_RANK_MAX 8 -template struct PlainTensor { size_t m_strides[PLAINTENSOR_RANK_MAX]; size_t m_dims[PLAINTENSOR_RANK_MAX]; @@ -118,6 +96,8 @@ struct PlainTensor { void* m_ptr = nullptr; size_t m_capacity = 0; bool with_storage = false; + size_t m_element_size = 0; + ov::element::Type_t m_dt = ov::element::Type_t::undefined; MemoryPtr m_mem; // hold memory ptr reference operator bool() const { @@ -149,12 +129,14 @@ struct PlainTensor { } // copy construct (always not take ownership) - PlainTensor

operator=(const PlainTensor
& other) { + PlainTensor operator=(const PlainTensor& other) { OPENVINO_ASSERT(!with_storage); memcpy(&m_strides, &other.m_strides, sizeof(m_strides)); memcpy(&m_dims, &other.m_dims, sizeof(m_dims)); m_rank = other.m_rank; m_ptr = other.m_ptr; + m_dt = other.m_dt; + m_element_size = other.m_element_size; return *this; } @@ -169,23 +151,21 @@ struct PlainTensor { } void reset(MemoryPtr mem) { - const auto& mem_desc = mem->getDesc(); - assert_dt
(mem_desc.getPrecision()); - const auto* desc_ptr = mem_desc.as(); + auto mem_desc = mem->getDescWithType(); // not support block layout - OPENVINO_ASSERT(desc_ptr && desc_ptr->getOrder().size() == mem->getStaticDims().size()); + OPENVINO_ASSERT(mem_desc && mem_desc->getOrder().size() == mem->getStaticDims().size()); m_mem = mem; - VectorDims strides(desc_ptr->getStrides().size()); - const auto& orders = desc_ptr->getOrder(); + VectorDims strides(mem_desc->getStrides().size()); + const auto& orders = mem_desc->getOrder(); for (size_t i = 0; i < orders.size(); i++) { - strides[orders[i]] = desc_ptr->getStrides()[i]; + strides[orders[i]] = mem_desc->getStrides()[i]; } // this reshape_to() can do reshape w/o additional cost - resize(mem->getStaticDims(), reinterpret_cast(mem->getData()), &strides); + resize(mem->getStaticDims(), mem_desc->getPrecision().size(), mem_desc->getPrecision(), mem->getData(), strides.data()); } - ov::element::Type get_precision(void) { - return precision_of
::value; + ov::element::Type get_precision() const { + return m_dt; } struct tensor_index { @@ -223,8 +203,8 @@ struct PlainTensor { } }; - PlainTensor
index(const std::initializer_list& indices) { - PlainTensor
sub_tensor; + PlainTensor index(const std::initializer_list& indices) { + PlainTensor sub_tensor; assert(indices.size() <= m_rank); int i_src = 0; int i_dst = 0; @@ -246,13 +226,15 @@ struct PlainTensor { i_src++; } sub_tensor.m_rank = i_dst; // index may imply squeeze - sub_tensor.m_ptr = reinterpret_cast(reinterpret_cast(m_ptr) + off); + sub_tensor.m_ptr = reinterpret_cast(reinterpret_cast(m_ptr) + off * m_element_size); + sub_tensor.m_dt = m_dt; + sub_tensor.m_element_size = m_element_size; return sub_tensor; } // slice: return a sub-view (w/o ownership/refcount to original data) - PlainTensor
slice(int axis, int start, int end, int step = 1) const { - PlainTensor
sub_tensor; + PlainTensor slice(int axis, int start, int end, int step = 1) const { + PlainTensor sub_tensor; assert(axis >= 0 && static_cast::type>(axis) < m_rank); sub_tensor.m_capacity = 0; @@ -277,8 +259,10 @@ struct PlainTensor { } auto off = start * m_strides[axis]; - auto* data = reinterpret_cast(m_ptr) + off; + auto* data = reinterpret_cast(m_ptr) + off * m_element_size; sub_tensor.m_ptr = reinterpret_cast(data); + sub_tensor.m_dt = m_dt; + sub_tensor.m_element_size = m_element_size; return sub_tensor; } @@ -310,21 +294,22 @@ struct PlainTensor { simplified form is when whole tensor is dense */ - PlainTensor
reshape(const std::vector& target_shape) const { + PlainTensor reshape(const std::vector& target_shape) const { // only valid for dense memory - PlainTensor
new_tensor_view; + PlainTensor new_tensor_view; assert(is_dense()); - //assert(shape_size(target_shape) == shape_size(m_dims)); - new_tensor_view.resize(VectorDims(target_shape), reinterpret_cast(m_ptr)); + new_tensor_view.resize(target_shape, m_element_size, m_dt, m_ptr); return new_tensor_view; } - PlainTensor
permute(const std::vector& order) const { - PlainTensor
new_tensor_view; + PlainTensor permute(const std::vector& order) const { + PlainTensor new_tensor_view; assert(order.size() == m_rank); new_tensor_view.m_capacity = 0; new_tensor_view.m_ptr = m_ptr; new_tensor_view.m_rank = m_rank; + new_tensor_view.m_dt = m_dt; + new_tensor_view.m_element_size = m_element_size; auto it_order = order.begin(); // also should check order has no repeat element for (size_t i = 0; i < m_rank; i++) { @@ -336,19 +321,21 @@ struct PlainTensor { return new_tensor_view; } - void resize(const VectorDims& new_dims, DT* data = nullptr, const VectorDims* strides = nullptr) { + void resize(const VectorDims& new_dims, size_t element_size, ov::element::Type_t dt, void* data = nullptr, const size_t* strides = nullptr) { + m_element_size = element_size; + m_dt = dt; // initialize strides for compact/dense tensor m_rank = new_dims.size(); assert(m_rank <= PLAINTENSOR_RANK_MAX); size_t stride = 1; for (int i = m_rank - 1; i >= 0; i--) { m_dims[i] = new_dims[i]; - m_strides[i] = strides ? (*strides)[i] : stride; + m_strides[i] = strides ? strides[i] : stride; stride *= new_dims[i]; } if (!data) { - auto capacity_new = m_strides[0] * m_dims[0] * sizeof(DT); + auto capacity_new = m_strides[0] * m_dims[0] * m_element_size; if (capacity_new > m_capacity) { if (!with_storage) { throw std::bad_alloc(); @@ -368,11 +355,18 @@ struct PlainTensor { } } + template + void resize(const VectorDims& new_dims, DT* data = nullptr, const size_t* strides = nullptr) { + resize(new_dims, sizeof(DT), precision_of
::value, data, strides); + } + + template DT* data() const { return reinterpret_cast(m_ptr); } // when allow_broadcast is true, index to size-1 dim will always access 0. + template DT& at(const std::initializer_list& index, bool allow_broadcast = false) const { size_t off = 0; auto it = index.begin(); @@ -389,7 +383,8 @@ struct PlainTensor { return reinterpret_cast(m_ptr)[off]; } - PlainTensor
& operator=(const DT& value) { + template + PlainTensor& operator=(const DT& value) { // assign every element to value std::vector index(m_rank, 0); auto* dst = reinterpret_cast(m_ptr); @@ -412,8 +407,9 @@ struct PlainTensor { return *this; } + template DT& operator()(const std::initializer_list& index, bool allow_broadcast = false) const { - return at(index, allow_broadcast); + return at
(index, allow_broadcast); } void assert_dims(const std::initializer_list& expect_dims, bool special_zero = false) const { @@ -452,7 +448,7 @@ struct PlainTensor { return "{empty}"; } std::stringstream ss; - ss << data_type_name
::value << " shape=["; + ss << m_dt << " shape=["; const char* sep = ""; size_t sz = 1; for (size_t i = 0; i < m_rank; i++) { @@ -475,7 +471,6 @@ struct PlainTensor { size_t cur_line_elecnt = 0; size_t cur_row_elecnt = 0; size_t i; - auto* p = reinterpret_cast(m_ptr); for (i = 0; i < sz && max_total_lines > 0; i++) { if ((i % last_dim_size) == 0) { ss << row_id << ":\t\t"; @@ -485,10 +480,20 @@ struct PlainTensor { // display current element if we still have buget if (cur_row_lines_left > 0) { - if (std::is_integral
::value) - ss << static_cast(p[i]) << ","; + if (m_dt == ov::element::Type_t::f32) + ss << reinterpret_cast(m_ptr)[i] << ","; + else if (m_dt == ov::element::Type_t::bf16) + ss << reinterpret_cast(m_ptr)[i] << ","; + else if (m_dt == ov::element::Type_t::f16) + ss << reinterpret_cast(m_ptr)[i] << ","; + else if (m_dt == ov::element::Type_t::i32) + ss << reinterpret_cast(m_ptr)[i] << ","; + else if (m_dt == ov::element::Type_t::i8) + ss << static_cast(reinterpret_cast(m_ptr)[i]) << ","; + else if (m_dt == ov::element::Type_t::u8) + ss << static_cast(reinterpret_cast(m_ptr)[i]) << ","; else - ss << p[i] << ","; + ss << "?,"; cur_line_elecnt++; cur_row_elecnt++; if ((cur_line_elecnt % 16) == 15 || (cur_row_elecnt == last_dim_size)) { @@ -514,12 +519,10 @@ struct PlainTensor { return ss.str(); } - template - friend std::ostream& operator<<(std::ostream& os, const PlainTensor& dt); + friend std::ostream& operator<<(std::ostream& os, const PlainTensor& dt); }; -template -std::ostream& operator<<(std::ostream& os, const PlainTensor& dt) { +inline std::ostream& operator<<(std::ostream& os, const PlainTensor& dt) { os << dt.repr(); return os; } diff --git a/src/plugins/intel_cpu/src/utils/print_model.hpp b/src/plugins/intel_cpu/src/utils/print_model.hpp index 6b4eb01180a264..2b4eb31d5671e2 100644 --- a/src/plugins/intel_cpu/src/utils/print_model.hpp +++ b/src/plugins/intel_cpu/src/utils/print_model.hpp @@ -319,6 +319,10 @@ void dump_cpp_style(std::ostream& os, const std::shared_ptr& model) { const auto& type_info = op->get_type_info(); auto version_info = std::string(type_info.get_version()); auto type = version_info + "::" + type_info.name; + auto& rt_info = op->get_rt_info(); + if (rt_info.count("opset") && rt_info["opset"] == "type_relaxed_opset") { + type = std::string("ov::op::TypeRelaxed<") + type + ">"; + } auto name = opname[op.get()]; os << prefix << " "; diff --git a/src/plugins/intel_cpu/tests/functional/extension/extension.cpp b/src/plugins/intel_cpu/tests/functional/extension/extension.cpp index b2f9c1c59ac0c1..1b9c0158e51bd3 100644 --- a/src/plugins/intel_cpu/tests/functional/extension/extension.cpp +++ b/src/plugins/intel_cpu/tests/functional/extension/extension.cpp @@ -205,7 +205,7 @@ static std::string get_extension_path() { } -TEST(Extension, XmlModelWithExtensionFromDSO) { +TEST(Extension, smoke_XmlModelWithExtensionFromDSO) { std::string model = R"V0G0N( @@ -260,6 +260,7 @@ TEST(Extension, XmlModelWithExtensionFromDSO) { std::vector input_values{1, 2, 3, 4, 5, 6, 7, 8}; std::vector expected{12, 13, 14, 15, 16, 17, 18, 19}; InferenceEngine::Core ie; + ie.SetConfig({ { ov::hint::inference_precision.name(), ov::element::f32.get_type_name() } }, "CPU"); ie.AddExtension(std::make_shared(get_extension_path())); InferenceEngine::Blob::CPtr weights; auto network = ie.ReadNetwork(model, weights); 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 fee91b5c5a38d3..20c996333e661b 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 @@ -34,8 +34,9 @@ void core_configuration(ov::test::SubgraphBaseTest* test) { test->configuration.insert({ov::hint::inference_precision.name(), ov::element::f32.to_string()}); } #endif - // todo: issue: 123320 - test->convert_precisions = {{ ov::element::bf16, ov::element::f32 }, { ov::element::f16, ov::element::f32 }}; + // todo: issue: 123320 + test->convert_precisions.insert({ov::element::bf16, ov::element::f32}); + test->convert_precisions.insert({ov::element::f16, ov::element::f32}); } } // namespace test diff --git a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/binary_convolution.cpp b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/binary_convolution.cpp index da2df80eb7dda0..31c13e56b02baa 100644 --- a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/binary_convolution.cpp +++ b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/binary_convolution.cpp @@ -36,7 +36,7 @@ const auto binConv2DParams_ExplicitPadding = ::testing::Combine( ::testing::ValuesIn(padsEnd), ::testing::ValuesIn(dilations), ::testing::ValuesIn(numOutChannels), - ::testing::Values(ngraph::op::PadType::EXPLICIT), + ::testing::Values(ov::op::PadType::EXPLICIT), ::testing::ValuesIn(padValues)); const auto binConv2DParams_ValidPadding = ::testing::Combine( @@ -46,7 +46,7 @@ const auto binConv2DParams_ValidPadding = ::testing::Combine( ::testing::Values(std::vector({0, 0})), ::testing::ValuesIn(dilations), ::testing::ValuesIn(numOutChannels), - ::testing::Values(ngraph::op::PadType::VALID), + ::testing::Values(ov::op::PadType::VALID), ::testing::ValuesIn(padValues)); INSTANTIATE_TEST_SUITE_P( diff --git a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/comparison.cpp b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/comparison.cpp index 0b68b33e2074a9..22a4d9a9740d89 100644 --- a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/comparison.cpp +++ b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/comparison.cpp @@ -37,18 +37,18 @@ std::vector model_type = { ov::element::boolean, }; -std::vector comparisonOpTypes = { - ngraph::helpers::ComparisonTypes::EQUAL, - ngraph::helpers::ComparisonTypes::NOT_EQUAL, - ngraph::helpers::ComparisonTypes::GREATER, - ngraph::helpers::ComparisonTypes::GREATER_EQUAL, - ngraph::helpers::ComparisonTypes::LESS, - ngraph::helpers::ComparisonTypes::LESS_EQUAL, +std::vector comparisonOpTypes = { + ov::test::utils::ComparisonTypes::EQUAL, + ov::test::utils::ComparisonTypes::NOT_EQUAL, + ov::test::utils::ComparisonTypes::GREATER, + ov::test::utils::ComparisonTypes::GREATER_EQUAL, + ov::test::utils::ComparisonTypes::LESS, + ov::test::utils::ComparisonTypes::LESS_EQUAL, }; -std::vector secondInputTypes = { - ngraph::helpers::InputLayerType::CONSTANT, - ngraph::helpers::InputLayerType::PARAMETER, +std::vector secondInputTypes = { + ov::test::utils::InputLayerType::CONSTANT, + ov::test::utils::InputLayerType::PARAMETER, }; std::map additional_config = {}; @@ -81,15 +81,15 @@ std::vector> input_shapes_is_ops_static = { {{2, 17, 3, 4}, {1}} }; -std::vector comparisonOpTypesIs = { - ngraph::helpers::ComparisonTypes::IS_FINITE, - ngraph::helpers::ComparisonTypes::IS_NAN +std::vector comparisonOpTypesIs = { + ov::test::utils::ComparisonTypes::IS_FINITE, + ov::test::utils::ComparisonTypes::IS_NAN }; const auto ComparisonTestParamsIs = ::testing::Combine( ::testing::ValuesIn(ov::test::static_shapes_to_test_representation(input_shapes_is_ops_static)), ::testing::ValuesIn(comparisonOpTypesIs), - ::testing::Values(ngraph::helpers::InputLayerType::CONSTANT), + ::testing::Values(ov::test::utils::InputLayerType::CONSTANT), ::testing::Values(ov::element::f32), ::testing::Values(ov::test::utils::DEVICE_CPU), ::testing::Values(additional_config)); diff --git a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/convolution.cpp b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/convolution.cpp index 3bfe2fb06b814d..3a885a08f8d459 100644 --- a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/convolution.cpp +++ b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/convolution.cpp @@ -64,13 +64,13 @@ const auto conv2DParams_ExplicitPadding = ::testing::Combine( ::testing::ValuesIn(kernels), ::testing::ValuesIn(strides), ::testing::ValuesIn(padBegins), ::testing::ValuesIn(padEnds), ::testing::ValuesIn(dilations), ::testing::ValuesIn(numOutChannels), - ::testing::Values(ngraph::op::PadType::EXPLICIT)); + ::testing::Values(ov::op::PadType::EXPLICIT)); const auto conv2DParams_AutoPadValid = ::testing::Combine( ::testing::ValuesIn(kernels), ::testing::ValuesIn(strides), ::testing::Values(std::vector({0, 0})), ::testing::Values(std::vector({0, 0})), ::testing::ValuesIn(dilations), ::testing::ValuesIn(numOutChannels), - ::testing::Values(ngraph::op::PadType::VALID)); + ::testing::Values(ov::op::PadType::VALID)); INSTANTIATE_TEST_SUITE_P( smoke_Convolution2D_ExplicitPadding, ConvolutionLayerTest, @@ -103,7 +103,7 @@ const auto conv2DParams_WeightLayout = ::testing::Combine(::testing::Values(kern ::testing::Values(padEnds), ::testing::Values(dilations), ::testing::Values(numOutChannels), - ::testing::Values(ngraph::op::PadType::EXPLICIT)); + ::testing::Values(ov::op::PadType::EXPLICIT)); INSTANTIATE_TEST_SUITE_P(smoke_Convolution2D_SpecificWeightLayout, ConvolutionLayerTest, ::testing::Combine(conv2DParams_WeightLayout, @@ -124,13 +124,13 @@ const auto conv3DParams_ExplicitPadding = ::testing::Combine( ::testing::ValuesIn(kernels3d), ::testing::ValuesIn(strides3d), ::testing::ValuesIn(paddings3d), ::testing::ValuesIn(paddings3d), ::testing::ValuesIn(dilations3d), ::testing::ValuesIn(numOutChannels3D), - ::testing::Values(ngraph::op::PadType::EXPLICIT)); + ::testing::Values(ov::op::PadType::EXPLICIT)); const auto conv3DParams_AutoPadValid = ::testing::Combine( ::testing::ValuesIn(kernels3d), ::testing::ValuesIn(strides3d), ::testing::Values(std::vector({0, 0, 0})), ::testing::Values(std::vector({0, 0, 0})), ::testing::ValuesIn(dilations3d), ::testing::ValuesIn(numOutChannels3D), - ::testing::Values(ngraph::op::PadType::VALID)); + ::testing::Values(ov::op::PadType::VALID)); INSTANTIATE_TEST_SUITE_P( smoke_Convolution3D_ExplicitPadding, ConvolutionLayerTest, diff --git a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/deformable_convolution.cpp b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/deformable_convolution.cpp index 8192ab595e5fc7..89b793f8bf7551 100644 --- a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/deformable_convolution.cpp +++ b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/deformable_convolution.cpp @@ -166,7 +166,7 @@ const auto deformableConv2DParams_SingleTestCase = ::testing::Combine( ::testing::ValuesIn(groups), ::testing::ValuesIn(single_deform_groups), ::testing::ValuesIn(numOutChannels), - ::testing::Values(ngraph::op::PadType::EXPLICIT), + ::testing::Values(ov::op::PadType::EXPLICIT), ::testing::ValuesIn(with_bilinear_interpolation_pad)); INSTANTIATE_TEST_SUITE_P( @@ -215,7 +215,7 @@ INSTANTIATE_TEST_SUITE_P( ::testing::ValuesIn(std::vector {2}), // gr. ::testing::ValuesIn(std::vector {2}), // def. gr. ::testing::ValuesIn(numOutChannels), - ::testing::Values(ngraph::op::PadType::EXPLICIT), + ::testing::Values(ov::op::PadType::EXPLICIT), ::testing::ValuesIn(with_bilinear_interpolation_pad)), ::testing::Values(false), ::testing::ValuesIn(netPrecisions), @@ -234,7 +234,7 @@ INSTANTIATE_TEST_SUITE_P( ::testing::ValuesIn(std::vector {2}), // gr. ::testing::ValuesIn(std::vector {2}), // def. gr. ::testing::ValuesIn(numOutChannels), - ::testing::Values(ngraph::op::PadType::EXPLICIT), + ::testing::Values(ov::op::PadType::EXPLICIT), ::testing::ValuesIn(with_bilinear_interpolation_pad)), ::testing::Values(true), ::testing::ValuesIn(netPrecisions), @@ -266,7 +266,7 @@ INSTANTIATE_TEST_SUITE_P( ::testing::ValuesIn(std::vector {4}), // gr. ::testing::ValuesIn(std::vector {1}), // def. gr. ::testing::ValuesIn(numOutChannels), - ::testing::Values(ngraph::op::PadType::EXPLICIT), + ::testing::Values(ov::op::PadType::EXPLICIT), ::testing::ValuesIn(with_bilinear_interpolation_pad)), ::testing::Values(false), ::testing::ValuesIn(netPrecisions), @@ -285,7 +285,7 @@ INSTANTIATE_TEST_SUITE_P( ::testing::ValuesIn(std::vector {4}), // gr. ::testing::ValuesIn(std::vector {1}), // def. gr. ::testing::ValuesIn(numOutChannels), - ::testing::Values(ngraph::op::PadType::EXPLICIT), + ::testing::Values(ov::op::PadType::EXPLICIT), ::testing::ValuesIn(with_bilinear_interpolation_pad)), ::testing::Values(true), ::testing::ValuesIn(netPrecisions), 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 f8a80efe1f6223..ff7e75adf0f264 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 @@ -40,12 +40,12 @@ std::vector> in_shapes_static_check_collapse = { }; std::vector> in_shapes_dynamic = { - {{{ngraph::Dimension(1, 10), 200}, {{2, 200}, {1, 200}}}, - {{ngraph::Dimension(1, 10), 200}, {{2, 200}, {5, 200}}}}, + {{{ov::Dimension(1, 10), 200}, {{2, 200}, {1, 200}}}, + {{ov::Dimension(1, 10), 200}, {{2, 200}, {5, 200}}}}, }; std::vector> in_shapes_dynamic_large_upper_bound = { - {{{ngraph::Dimension(1, 1000000000000), 200}, {{2, 200}, {5, 200}}}}, + {{{ov::Dimension(1, 1000000000000), 200}, {{2, 200}, {5, 200}}}}, }; std::vector model_types = { diff --git a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/gru_sequence.cpp b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/gru_sequence.cpp index 36a35d7bffd819..3745268569552d 100644 --- a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/gru_sequence.cpp +++ b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/gru_sequence.cpp @@ -3,7 +3,6 @@ // #include -#include #include "single_op_tests/gru_sequence.hpp" #include "common_test_utils/test_constants.hpp" #include "common_test_utils/test_enums.hpp" 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 74bec47ba16896..ce45353ab90e50 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 @@ -28,7 +28,7 @@ std::vector> input_shapes_static = { }; std::vector> input_shapes_dynamic = { - {{{ngraph::Dimension(1, 10), 200}, {{2, 200}, {1, 200}}}} + {{{ov::Dimension(1, 10), 200}, {{2, 200}, {1, 200}}}} }; std::vector model_types = { diff --git a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/matrix_nms.cpp b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/matrix_nms.cpp index 9dff6869e3272f..90fadce0861ae9 100644 --- a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/matrix_nms.cpp +++ b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/matrix_nms.cpp @@ -18,14 +18,14 @@ const std::vector> inStaticShapeParams = { const std::vector> inDynamicShapeParams = { // num_batches, num_boxes, 4 - {{{ngraph::Dimension::dynamic(), ngraph::Dimension::dynamic(), 4}, + {{{ov::Dimension::dynamic(), ov::Dimension::dynamic(), 4}, {{1, 10, 4}, {2, 100, 4}}}, // num_batches, num_classes, num_boxes - {{ngraph::Dimension::dynamic(), ngraph::Dimension::dynamic(), ngraph::Dimension::dynamic()}, + {{ov::Dimension::dynamic(), ov::Dimension::dynamic(), ov::Dimension::dynamic()}, {{1, 3, 10}, {2, 5, 100}}}}, - {{{ngraph::Dimension(1, 10), ngraph::Dimension(1, 100), 4}, + {{{ov::Dimension(1, 10), ov::Dimension(1, 100), 4}, {{1, 10, 4}, {2, 100, 4}}}, - {{{ngraph::Dimension(1, 10), ngraph::Dimension(1, 100), ngraph::Dimension(1, 100)}}, + {{{ov::Dimension(1, 10), ov::Dimension(1, 100), ov::Dimension(1, 100)}}, {{1, 3, 10}, {2, 5, 100}}}} }; diff --git a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/mvn.cpp b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/mvn.cpp index 9daa95881ec134..8da9c1249f823e 100644 --- a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/mvn.cpp +++ b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/mvn.cpp @@ -12,7 +12,7 @@ using ov::test::Mvn1LayerTest; using ov::test::Mvn6LayerTest; const std::vector empty_across_channels = {{}}; -const std::vector empty_reduction_axes = {{}}; +const std::vector empty_reduction_axes = {{}}; const std::vector> input_shapes_static = { {{8}}, @@ -69,7 +69,7 @@ const std::vector> input_shapes_reduction_axes_static = { const auto MvnReductionAxes = ::testing::Combine( ::testing::ValuesIn(ov::test::static_shapes_to_test_representation(input_shapes_reduction_axes_static)), ::testing::Values(ov::element::f32), - ::testing::ValuesIn(std::vector{{1, 2, 3}, {2, 3}}), + ::testing::ValuesIn(std::vector{{1, 2, 3}, {2, 3}}), ::testing::ValuesIn(empty_across_channels), ::testing::ValuesIn(normalize_variance), ::testing::ValuesIn(epsilon), 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 5838096b20eed0..ff058cecf6fc35 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 @@ -22,10 +22,10 @@ const std::vector inputStaticShape2D = { }; const std::vector inputDynamicShape2D = { - {{ngraph::Dimension::dynamic(), 10}, {{1, 10}, {2, 10}, {10, 10}}}, - {{ngraph::Dimension(1, 10), 10}, {{1, 10}, {2, 10}, {10, 10}}}, - {{10, ngraph::Dimension::dynamic()}, {{10, 1}, {10, 5}, {10, 10}}}, - {{ngraph::Dimension::dynamic(), ngraph::Dimension::dynamic()}, {{1, 10}, {2, 10}, {10, 10}}} + {{ov::Dimension::dynamic(), 10}, {{1, 10}, {2, 10}, {10, 10}}}, + {{ov::Dimension(1, 10), 10}, {{1, 10}, {2, 10}, {10, 10}}}, + {{10, ov::Dimension::dynamic()}, {{10, 1}, {10, 5}, {10, 10}}}, + {{ov::Dimension::dynamic(), ov::Dimension::dynamic()}, {{1, 10}, {2, 10}, {10, 10}}} }; const std::vector axis2D = { @@ -73,8 +73,8 @@ const std::vector inputStaticShape4D = { }; const std::vector inputDynamicShape4D = { - {{ngraph::Dimension::dynamic(), 100, ngraph::Dimension(1, 10), 1}, {{1, 100, 1, 1}, {100, 100, 5, 1}}}, - {{ngraph::Dimension::dynamic(), ngraph::Dimension::dynamic(), ngraph::Dimension::dynamic(), ngraph::Dimension::dynamic()}, + {{ov::Dimension::dynamic(), 100, ov::Dimension(1, 10), 1}, {{1, 100, 1, 1}, {100, 100, 5, 1}}}, + {{ov::Dimension::dynamic(), ov::Dimension::dynamic(), ov::Dimension::dynamic(), ov::Dimension::dynamic()}, {{1, 100, 1, 1}, {50, 100, 4, 1}, {2, 100, 10, 1}}}, }; 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 dc6745422baedc..92e5777a94755c 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 @@ -3,14 +3,11 @@ // #include "functional_test_utils/skip_tests_config.hpp" - -#include +#include "openvino/runtime/system_conf.hpp" #include #include -#include "ie_parallel.hpp" - std::vector disabledTestPatterns() { std::vector retVector{ // TODO: Issue 31841 @@ -146,11 +143,15 @@ std::vector disabledTestPatterns() { // Issue: 95607 R"(.*CachingSupportCase.*LoadNetworkCacheTestBase.*(TIwithLSTMcell1|MatMulBias|2InputSubtract)_(i|u).*)", R"(.*CachingSupportCase.*ReadConcatSplitAssign.*)", - // 94982. FP32->I32 conversion issue in the reference implementation. There can be some garbage in the rest of float values like 0.333333745. - // The kernel does not have such garbage. The diff 0.000000745 is taken into account in calculations and affects further type conversion. - // Reorder->GridSample->Reorder also does not work here. Potential fix is to use nearest conversion instead of truncation. + // 94982. FP32->I32 conversion issue in the reference implementation. There can be some garbage in the rest of + // float values like 0.333333745. + // The kernel does not have such garbage. The diff 0.000000745 is taken into account in calculations and affects + // further type conversion. + // Reorder->GridSample->Reorder also does not work here. Potential fix is to use nearest conversion instead of + // truncation. R"(.*GridSampleLayerTestCPU.*(BILINEAR|BICUBIC).*(i32|i8).*)", - // AdaptiveAvgPool is converted into Reduce op for suitable parameters. CPU Reduce impl doesn't support non planar layout for 3D case + // AdaptiveAvgPool is converted into Reduce op for suitable parameters. CPU Reduce impl doesn't support non + // planar layout for 3D case R"(.*StaticAdaPoolAvg3DLayoutTest.*OS=\(1\).*_inFmts=(nwc|nCw16c|nCw8c).*)", // Issue: 111404 R"(.*smoke_set1/GatherElementsCPUTest.*)", @@ -217,6 +218,8 @@ std::vector disabledTestPatterns() { R"(.*smoke_Snippets_MHA_.?D_SplitDimensionM.*)", // Issue: 122356 R"(.*NmsRotatedOpTest.*(SortDesc=True|Clockwise=False).*)", + // Issue: 126095 + R"(^smoke_Multinomial(?:Static|Dynamic)+(?:Log)*.*seed_g=0_seed_o=0.*device=CPU.*)", #ifdef OPENVINO_ARCH_32_BIT // Issue: 126177 R"(.*smoke_CompareWithRefs_4D_Bitwise.*/EltwiseLayerCPUTest.CompareWithRefs/.*_eltwiseOpType=Bitwise.*_NetType=i32_.*)" @@ -231,29 +234,46 @@ std::vector disabledTestPatterns() { #elif defined(OPENVINO_ARCH_ARM64) || defined(OPENVINO_ARCH_ARM) { // Issue: 121709 - retVector.emplace_back(R"(smoke_ConversionLayerTest/ConversionLayerTest.Inference/conversionOpType=Convert_IS.*_inputPRC=f16_targetPRC=(u|i)8_trgDev=CPU.*)"); + retVector.emplace_back( + R"(smoke_ConversionLayerTest/ConversionLayerTest.Inference/conversionOpType=Convert_IS.*_inputPRC=f16_targetPRC=(u|i)8_trgDev=CPU.*)"); // Issue: 121710 - retVector.emplace_back(R"(smoke_GRUCellCommon/GRUCellTest.Inference/decomposition0_batch=5_.*WType=CONSTANT_RType=CONSTANT_BType=CONSTANT_netPRC=f16_targetDevice=CPU_.*)"); + retVector.emplace_back( + R"(smoke_GRUCellCommon/GRUCellTest.Inference/decomposition0_batch=5_.*WType=CONSTANT_RType=CONSTANT_BType=CONSTANT_netPRC=f16_targetDevice=CPU_.*)"); // Issue: 121715 - retVector.emplace_back(R"(smoke_CompareWithRefs_static/EltwiseLayerTest.Inference/IS.*_eltwise_op_type=Div_secondary_input_type=PARAMETER_opType=VECTOR_model_type=i32_InType=undefined_OutType=undefined_trgDev=CPU.*)"); - retVector.emplace_back(R"(smoke_CompareWithRefs_static_check_collapsing/EltwiseLayerTest.Inference/IS.*_eltwise_op_type=Div_secondary_input_type=PARAMETER_opType=VECTOR_model_type=i32_InType=undefined_OutType=undefined_trgDev=CPU.*)"); + retVector.emplace_back( + R"(smoke_CompareWithRefs_static/EltwiseLayerTest.Inference/IS.*_eltwise_op_type=Div_secondary_input_type=PARAMETER_opType=VECTOR_model_type=i32_InType=undefined_OutType=undefined_trgDev=CPU.*)"); + retVector.emplace_back( + R"(smoke_CompareWithRefs_static_check_collapsing/EltwiseLayerTest.Inference/IS.*_eltwise_op_type=Div_secondary_input_type=PARAMETER_opType=VECTOR_model_type=i32_InType=undefined_OutType=undefined_trgDev=CPU.*)"); // TODO: enable once streams / tput mode is supported - retVector.emplace_back(R"(OVClassConfigTestCPU.smoke_CpuExecNetworkCheck(Model|Core)StreamsHasHigherPriorityThanLatencyHint.*)"); - retVector.emplace_back(R"(smoke_BehaviorTests/CorrectConfigCheck.canSetConfigAndCheckGetConfig.*CPU_THROUGHPUT_STREAMS=8.*)"); - retVector.emplace_back(R"(smoke_BehaviorTests/CorrectConfigCheck.canSetConfigTwiceAndCheckGetConfig.*CPU_THROUGHPUT_STREAMS=8.*)"); - retVector.emplace_back(R"(smoke_CPU_OVClassLoadNetworkAndCheckWithSecondaryPropertiesTest/OVClassLoadNetworkAndCheckSecondaryPropertiesTest.LoadNetworkAndCheckSecondaryPropertiesTest.*)"); - retVector.emplace_back(R"(smoke_CPU_OVClassLoadNetworkAndCheckWithSecondaryPropertiesDoubleTest/OVClassLoadNetworkAndCheckSecondaryPropertiesTest.LoadNetworkAndCheckSecondaryPropertiesTest.*)"); + retVector.emplace_back( + R"(OVClassConfigTestCPU.smoke_CpuExecNetworkCheck(Model|Core)StreamsHasHigherPriorityThanLatencyHint.*)"); + retVector.emplace_back( + R"(smoke_BehaviorTests/CorrectConfigCheck.canSetConfigAndCheckGetConfig.*CPU_THROUGHPUT_STREAMS=8.*)"); + retVector.emplace_back( + R"(smoke_BehaviorTests/CorrectConfigCheck.canSetConfigTwiceAndCheckGetConfig.*CPU_THROUGHPUT_STREAMS=8.*)"); + retVector.emplace_back( + R"(smoke_CPU_OVClassLoadNetworkAndCheckWithSecondaryPropertiesTest/OVClassLoadNetworkAndCheckSecondaryPropertiesTest.LoadNetworkAndCheckSecondaryPropertiesTest.*)"); + retVector.emplace_back( + R"(smoke_CPU_OVClassLoadNetworkAndCheckWithSecondaryPropertiesDoubleTest/OVClassLoadNetworkAndCheckSecondaryPropertiesTest.LoadNetworkAndCheckSecondaryPropertiesTest.*)"); retVector.emplace_back(R"(smoke_CPU_OVClassCompileModelAndCheckSecondaryPropertiesTest.*)"); retVector.emplace_back(R"(smoke_CPU_OVClassCompileModelAndCheckWithSecondaryPropertiesDoubleTest.*)"); // Issue: 123321 - retVector.emplace_back(R"(.*smoke_RNNSequenceCommonZeroClip/RNNSequenceTest.Inference.*hidden_size=1.*relu.*direction=reverse.*)"); + retVector.emplace_back( + R"(.*smoke_RNNSequenceCommonZeroClip/RNNSequenceTest.Inference.*hidden_size=1.*relu.*direction=reverse.*)"); + // Ticket: 122769 + retVector.emplace_back(R"(.*smoke_nonzero/NonZeroLayerTest.Inference/IS.*)"); + retVector.emplace_back(R"(.*smoke_NormalizeL2_.*)"); + retVector.emplace_back(R"(.*Extension.XmlModelWithExtensionFromDSO.*)"); + retVector.emplace_back(R"(.*Extension.OnnxModelWithExtensionFromDSO.*)"); + retVector.emplace_back(R"(.*ONNXQuantizedModels/QuantizedModelsTests.MaxPool.*)"); + retVector.emplace_back(R"(.*ONNXQuantizedModels/QuantizedModelsTests.Convolution.*)"); } // invalid test: checks u8 precision for runtime graph, while it should be f32 retVector.emplace_back(R"(smoke_NegativeQuantizedMatMulMultiplyFusion.*)"); // int8 specific retVector.emplace_back(R"(smoke_Quantized.*)"); -#if defined(OV_CPU_ARM_ENABLE_FP16) +# if defined(OV_CPU_ARM_ENABLE_FP16) // Issue: 123019 retVector.emplace_back(R"(smoke_CompareWithRefs_Mvn.*INFERENCE_PRECISION_HINT=f16.*)"); retVector.emplace_back(R"(smoke_staticShapes4D.*INFERENCE_PRECISION_HINT=f16.*)"); @@ -264,10 +284,11 @@ std::vector disabledTestPatterns() { retVector.emplace_back(R"(.*smoke_BehaviorTests/InferRequestPerfCountersTest.CheckOperationInPerfMap.*)"); retVector.emplace_back(R"(smoke_BehaviorTests/ExecutableNetworkBaseTest.CheckExecGraphInfo.*)"); retVector.emplace_back(R"(smoke_BehaviorTests/OVCompiledModelBaseTestOptional.CheckExecGraphInfo.*)"); - retVector.emplace_back(R"(smoke_ExecGraph/ExecGraphRuntimePrecision.CheckRuntimePrecision/Function=FakeQuantizeBinaryConvolution.*)"); + retVector.emplace_back( + R"(smoke_ExecGraph/ExecGraphRuntimePrecision.CheckRuntimePrecision/Function=FakeQuantizeBinaryConvolution.*)"); // Issue: 124395 retVector.emplace_back(R"(smoke_VariableStateBasic/InferRequestVariableStateTest.*)"); -#endif +# endif #endif @@ -281,7 +302,8 @@ std::vector disabledTestPatterns() { retVector.emplace_back(R"(.*OVInferConsistencyTest.*)"); // TODO: generate new 'expected' runtime graph for non-x64 CPU retVector.emplace_back(R"(smoke_serialization/ExecGraphSerializationTest.ExecutionGraph.*)"); - retVector.emplace_back(R"(smoke_ExecGraph/ExecGraphRuntimePrecision.CheckRuntimePrecision/Function=(EltwiseWithTwoDynamicInputs|FakeQuantizeRelu).*)"); + retVector.emplace_back( + R"(smoke_ExecGraph/ExecGraphRuntimePrecision.CheckRuntimePrecision/Function=(EltwiseWithTwoDynamicInputs|FakeQuantizeRelu).*)"); // Issue 108803: bug in CPU scalar implementation retVector.emplace_back(R"(smoke_TestsDFT_(1|2|3|4)d/DFTLayerTest.CompareWithRefs.*)"); retVector.emplace_back(R"(smoke_TestsDFT_(1|2|3|4)d/DFTLayerTest.Inference.*)"); @@ -296,7 +318,7 @@ std::vector disabledTestPatterns() { retVector.emplace_back(R"(.*LoadNetworkCompiledKernelsCacheTest.*CanCreateCacheDirAndDumpBinariesUnicodePath.*)"); #endif - if (!InferenceEngine::with_cpu_x86_avx512_core()) { + if (!ov::with_cpu_x86_avx512_core()) { // on platforms which do not support bfloat16, we are disabling bf16 tests since there are no bf16 primitives, // tests are useless on such platforms retVector.emplace_back(R"(.*(BF|bf)16.*)"); @@ -307,20 +329,21 @@ std::vector disabledTestPatterns() { retVector.emplace_back(R"(.*Snippets.*(MatMul|Matmul).*)"); } #if defined(OPENVINO_ARCH_X86) || defined(OPENVINO_ARCH_X86_64) - if (!InferenceEngine::with_cpu_x86_avx512_core_fp16()) { + if (!ov::with_cpu_x86_avx512_core_fp16()) { // Skip fp16 tests for paltforms that don't support fp16 precision retVector.emplace_back(R"(.*INFERENCE_PRECISION_HINT=(F|f)16.*)"); } #elif defined(OPENVINO_ARCH_ARM64) || defined(OPENVINO_ARCH_ARM) -#if !defined(OV_CPU_ARM_ENABLE_FP16) +# if !defined(OV_CPU_ARM_ENABLE_FP16) // Skip fp16 tests for paltforms that don't support fp16 precision retVector.emplace_back(R"(.*INFERENCE_PRECISION_HINT=(F|f)16.*)"); -#else +# else // Issue 117407 - retVector.emplace_back(R"(.*EltwiseLayerCPUTest.*IS=\(\[1\.\.10\.2\.5\.6\]_\).*eltwiseOpType=SqDiff.*_configItem=INFERENCE_PRECISION_HINT=f16.*)"); -#endif // OV_CPU_ARM_ENABLE_FP16 + retVector.emplace_back( + R"(.*EltwiseLayerCPUTest.*IS=\(\[1\.\.10\.2\.5\.6\]_\).*eltwiseOpType=SqDiff.*_configItem=INFERENCE_PRECISION_HINT=f16.*)"); +# endif // OV_CPU_ARM_ENABLE_FP16 #endif - if (!InferenceEngine::with_cpu_x86_avx512_core_vnni() && !InferenceEngine::with_cpu_x86_avx512_core_amx_int8()) { + if (!ov::with_cpu_x86_avx512_core_vnni() && !ov::with_cpu_x86_avx512_core_amx_int8()) { // MatMul in Snippets uses BRGEMM that supports i8 only on platforms with VNNI or AMX instructions retVector.emplace_back(R"(.*Snippets.*MatMulFQ.*)"); retVector.emplace_back(R"(.*Snippets.*MatMul.*Quantized.*)"); @@ -328,11 +351,11 @@ std::vector disabledTestPatterns() { retVector.emplace_back(R"(.*Snippets.*MHAINT8.*)"); retVector.emplace_back(R"(.*Snippets.*MHAQuant.*)"); } - if (!InferenceEngine::with_cpu_x86_avx512_core_amx_int8()) - //TODO: Issue 92895 + if (!ov::with_cpu_x86_avx512_core_amx_int8()) + // TODO: Issue 92895 // on platforms which do not support AMX, we are disabling I8 input tests retVector.emplace_back(R"(smoke_LPT/FakeQuantizeWithNotOptimalTransformation.CompareWithRefImpl.*CPU.*i8.*)"); - if (!InferenceEngine::with_cpu_x86_avx512_core_amx_bf16() && !InferenceEngine::with_cpu_x86_bfloat16()) { + if (!ov::with_cpu_x86_avx512_core_amx_bf16() && !ov::with_cpu_x86_bfloat16()) { // ignored for not supported bf16 platforms retVector.emplace_back(R"(.*smoke_Snippets_EnforcePrecision_bf16.*)"); retVector.emplace_back(R"(.*smoke_Snippets_MHAWOTransposeEnforceBF16.*)"); diff --git a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/snippets/matmul.cpp b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/snippets/matmul.cpp index 78c1c8dccf0f84..77c78e31ca6b00 100644 --- a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/snippets/matmul.cpp +++ b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/snippets/matmul.cpp @@ -20,6 +20,7 @@ std::vector> input_shapes{ {{1, 1, 32, 23}, {1, 1, 23, 68}}, {{1, 16, 384, 64}, {1, 16, 64, 384}}, {{1, 1, 100, 700}, {1, 1, 700, 100}}, + {{1, 1, 100, 2500}, {1, 1, 2500, 100}}, }; static inline std::vector> quantized_precisions() { diff --git a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/subgraph_tests/quantized_convolution_backprop_data.cpp b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/subgraph_tests/quantized_convolution_backprop_data.cpp index 0a4d6d2e6e23b4..fe5bc52f776990 100644 --- a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/subgraph_tests/quantized_convolution_backprop_data.cpp +++ b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/subgraph_tests/quantized_convolution_backprop_data.cpp @@ -34,7 +34,7 @@ const auto quantConvBackpropData2DParams = ::testing::Combine( ::testing::ValuesIn(padEnds2D), ::testing::ValuesIn(dilations2D), ::testing::ValuesIn(numOutChannels), - ::testing::Values(ngraph::op::PadType::AUTO), + ::testing::Values(ov::op::PadType::AUTO), ::testing::ValuesIn(levels), ::testing::ValuesIn(granularity) ); diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/adaptive_pooling.cpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/adaptive_pooling.cpp index 575d8031216c6e..6b0a97a84a50fa 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/adaptive_pooling.cpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/adaptive_pooling.cpp @@ -2,49 +2,42 @@ // SPDX-License-Identifier: Apache-2.0 // -#include +#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 "ov_models/builders.hpp" -#include "ov_models/utils/ov_helpers.hpp" -using namespace InferenceEngine; using namespace CPUTestUtils; -using namespace ov::test; -namespace CPULayerTestsDefinitions { -namespace { - std::vector pooledSpatialShape; - std::string mode; - std::vector inputShape; -} // namespace +namespace ov { +namespace test { -using AdaPoolSpecificParams = std::tuple< - std::vector, // pooled vector - std::vector>; // feature map shape +using AdaPoolSpecificParams = std::tuple, // pooled vector + std::vector>; // feature map shape -using AdaPoolLayerTestParams = std::tuple< - AdaPoolSpecificParams, - std::string, // mode - bool, // second Input is Constant - ElementType, // Net precision - TargetDevice>; // Device name +using AdaPoolLayerTestParams = std::tuple; // Device name -using AdaPoolLayerCPUTestParamsSet = std::tuple< - CPULayerTestsDefinitions::AdaPoolLayerTestParams, - CPUSpecificParams>; +using AdaPoolLayerCPUTestParamsSet = std::tuple; class AdaPoolLayerCPUTest : public testing::WithParamInterface, - virtual public SubgraphBaseTest, public CPUTestsBase { + virtual public SubgraphBaseTest, + public CPUTestsBase { public: static std::string getTestCaseName(testing::TestParamInfo obj) { - CPULayerTestsDefinitions::AdaPoolLayerTestParams basicParamsSet; + AdaPoolLayerTestParams basicParamsSet; CPUSpecificParams cpuParams; std::tie(basicParamsSet, cpuParams) = obj.param; std::string td; ElementType netPr; bool isStatic; AdaPoolSpecificParams adaPar; + std::vector pooledSpatialShape; + std::vector inputShape; + std::string mode; std::tie(adaPar, mode, isStatic, netPr, td) = basicParamsSet; std::tie(pooledSpatialShape, inputShape) = adaPar; std::ostringstream result; @@ -66,22 +59,24 @@ class AdaPoolLayerCPUTest : public testing::WithParamInterfaceGetParam(); std::tie(inFmts, outFmts, priority, selectedType) = cpuParams; - CPULayerTestsDefinitions::AdaPoolSpecificParams adaPoolParams; + AdaPoolSpecificParams adaPoolParams; ElementType 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) { + for (auto& target : targetStaticShapes) { target.push_back({pooledVector.size()}); } } @@ -105,34 +100,36 @@ class AdaPoolLayerCPUTest : public testing::WithParamInterface createFunction(bool secondInputConst) { - ov::ParameterVector params{std::make_shared(ngraph::element::f32, inputDynamicShapes[0])}; + 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) { - secondInput = ngraph::op::Constant::create(ngraph::element::i32, ngraph::Shape{pooledVector.size()}, pooledVector); + secondInput = ov::op::v0::Constant::create(ov::element::i32, ov::Shape{pooledVector.size()}, pooledVector); } else { - auto pooledParam = std::make_shared(ngraph::element::i32, ngraph::Shape{pooledVector.size()}); + auto pooledParam = + std::make_shared(ov::element::i32, ov::Shape{pooledVector.size()}); pooledParam->set_friendly_name("ParamSecondInput"); params.push_back(pooledParam); secondInput = pooledParam; } - auto adapoolMax = std::make_shared(params[0], secondInput, ngraph::element::i32); + auto adapoolMax = std::make_shared(params[0], secondInput, ov::element::i32); adapoolMax->get_rt_info() = getCPUInfo(); - auto adapoolAvg = std::make_shared(params[0], secondInput); + auto adapoolAvg = std::make_shared(params[0], secondInput); adapoolAvg->get_rt_info() = getCPUInfo(); - auto function = (mode == "max" ? std::make_shared(adapoolMax->outputs(), params, "AdaPoolMax") : - std::make_shared(adapoolAvg->outputs(), params, "AdaPoolAvg")); + 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> ¶ms) { + 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()); @@ -140,10 +137,10 @@ class AdaPoolLayerCPUTest : public testing::WithParamInterface(); + auto* dataPtr = tensor.data(); for (size_t i = 0; i < pooledVector.size(); i++) { dataPtr[i] = pooledVector[i]; } } else { - tensor = ov::test::utils::create_and_fill_tensor(funcInput.get_element_type(), targetInputStaticShapes[i], 2560, 0, 256); + tensor = ov::test::utils::create_and_fill_tensor(funcInput.get_element_type(), + targetInputStaticShapes[i], + 2560, + 0, + 256); } inputs.insert({funcInput.get_node_shared_ptr(), tensor}); } @@ -170,6 +171,7 @@ class AdaPoolLayerCPUTest : public testing::WithParamInterface pooledVector; + std::string mode; }; TEST_P(AdaPoolLayerCPUTest, CompareWithRefs) { @@ -238,329 +240,275 @@ std::vector filterCPUInfoForDevice(std::string dims = "3D", s return resCPUParams; } -const std::vector netPrecisions = { - ElementType::f32, - ElementType::bf16 -}; +const std::vector netPrecisions = {ElementType::f32, ElementType::bf16}; -const std::vector> pooled3DVector = { - { 1 }, - { 3 }, - { 5 } -}; -const std::vector> pooled4DVector = { - { 1, 1 }, - { 3, 5 }, - { 5, 5 } -}; +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 }, + {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}}}} - } -}; + {{{{-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}}}} - } -}; + {{{{-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}}}; +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}}}} - } -}; + {{{{-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 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 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 +const auto adaPool5DParams = ::testing::Combine(::testing::ValuesIn(pooled5DVector), // output spatial shape + ::testing::ValuesIn(input5DShapeVector) // feature map shape ); const auto staticAdaPool3DParams = ::testing::Combine( - ::testing::ValuesIn(pooled3DVector), // output spatial shape - ::testing::ValuesIn(static_shapes_to_test_representation(staticInput3DShapeVector)) // feature map shape + ::testing::ValuesIn(pooled3DVector), // output spatial shape + ::testing::ValuesIn(static_shapes_to_test_representation(staticInput3DShapeVector)) // feature map shape ); const auto staticAdaPool4DParams = ::testing::Combine( - ::testing::ValuesIn(pooled4DVector), // output spatial shape - ::testing::ValuesIn(static_shapes_to_test_representation(staticInput4DShapeVector)) // feature map shape + ::testing::ValuesIn(pooled4DVector), // output spatial shape + ::testing::ValuesIn(static_shapes_to_test_representation(staticInput4DShapeVector)) // feature map shape ); const auto staticAdaPool5DParams = ::testing::Combine( - ::testing::ValuesIn(pooled5DVector), // output spatial shape - ::testing::ValuesIn(static_shapes_to_test_representation(staticInput5DShapeVector)) // feature map shape + ::testing::ValuesIn(pooled5DVector), // output spatial shape + ::testing::ValuesIn(static_shapes_to_test_representation(staticInput5DShapeVector)) // feature map shape ); -INSTANTIATE_TEST_SUITE_P(smoke_AdaPoolAvg3DLayoutTest, AdaPoolLayerCPUTest, - ::testing::Combine( - ::testing::Combine( - adaPool3DParams, - ::testing::Values("avg"), - ::testing::Values(false), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - ::testing::ValuesIn(filterCPUInfoForDevice("3D", "avg"))), +INSTANTIATE_TEST_SUITE_P(smoke_AdaPoolAvg3DLayoutTest, + AdaPoolLayerCPUTest, + ::testing::Combine(::testing::Combine(adaPool3DParams, + ::testing::Values("avg"), + ::testing::Values(false), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::ValuesIn(filterCPUInfoForDevice("3D", "avg"))), AdaPoolLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_SUITE_P(smoke_AdaPoolAvg4DLayoutTest, AdaPoolLayerCPUTest, - ::testing::Combine( - ::testing::Combine( - adaPool4DParams, - ::testing::Values("avg"), - ::testing::Values(false), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - ::testing::ValuesIn(filterCPUInfoForDevice("4D", "avg"))), +INSTANTIATE_TEST_SUITE_P(smoke_AdaPoolAvg4DLayoutTest, + AdaPoolLayerCPUTest, + ::testing::Combine(::testing::Combine(adaPool4DParams, + ::testing::Values("avg"), + ::testing::Values(false), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::ValuesIn(filterCPUInfoForDevice("4D", "avg"))), AdaPoolLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_SUITE_P(smoke_AdaPoolAvg5DLayoutTest, AdaPoolLayerCPUTest, - ::testing::Combine( - ::testing::Combine( - adaPool5DParams, - ::testing::Values("avg"), - ::testing::Values(false), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - ::testing::ValuesIn(filterCPUInfoForDevice("5D", "avg"))), +INSTANTIATE_TEST_SUITE_P(smoke_AdaPoolAvg5DLayoutTest, + AdaPoolLayerCPUTest, + ::testing::Combine(::testing::Combine(adaPool5DParams, + ::testing::Values("avg"), + ::testing::Values(false), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::ValuesIn(filterCPUInfoForDevice("5D", "avg"))), AdaPoolLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_SUITE_P(smoke_AdaPoolMax3DLayoutTest, AdaPoolLayerCPUTest, - ::testing::Combine( - ::testing::Combine( - adaPool3DParams, - ::testing::Values("max"), - ::testing::Values(false), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - ::testing::ValuesIn(filterCPUInfoForDevice("3D", "max"))), +INSTANTIATE_TEST_SUITE_P(smoke_AdaPoolMax3DLayoutTest, + AdaPoolLayerCPUTest, + ::testing::Combine(::testing::Combine(adaPool3DParams, + ::testing::Values("max"), + ::testing::Values(false), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::ValuesIn(filterCPUInfoForDevice("3D", "max"))), AdaPoolLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_SUITE_P(smoke_AdaPoolMax4DLayoutTest, AdaPoolLayerCPUTest, - ::testing::Combine( - ::testing::Combine( - adaPool4DParams, - ::testing::Values("max"), - ::testing::Values(false), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - ::testing::ValuesIn(filterCPUInfoForDevice("4D", "max"))), +INSTANTIATE_TEST_SUITE_P(smoke_AdaPoolMax4DLayoutTest, + AdaPoolLayerCPUTest, + ::testing::Combine(::testing::Combine(adaPool4DParams, + ::testing::Values("max"), + ::testing::Values(false), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::ValuesIn(filterCPUInfoForDevice("4D", "max"))), AdaPoolLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_SUITE_P(smoke_AdaPoolMax5DLayoutTest, AdaPoolLayerCPUTest, - ::testing::Combine( - ::testing::Combine( - adaPool5DParams, - ::testing::Values("max"), - ::testing::Values(false), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - ::testing::ValuesIn(filterCPUInfoForDevice("5D", "max"))), +INSTANTIATE_TEST_SUITE_P(smoke_AdaPoolMax5DLayoutTest, + AdaPoolLayerCPUTest, + ::testing::Combine(::testing::Combine(adaPool5DParams, + ::testing::Values("max"), + ::testing::Values(false), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::ValuesIn(filterCPUInfoForDevice("5D", "max"))), AdaPoolLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_SUITE_P(smoke_StaticAdaPoolAvg3DLayoutTest, AdaPoolLayerCPUTest, - ::testing::Combine( - ::testing::Combine( - staticAdaPool3DParams, - ::testing::Values("avg"), - ::testing::Values(true), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - ::testing::ValuesIn(filterCPUInfoForDevice("3D", "avg"))), +INSTANTIATE_TEST_SUITE_P(smoke_StaticAdaPoolAvg3DLayoutTest, + AdaPoolLayerCPUTest, + ::testing::Combine(::testing::Combine(staticAdaPool3DParams, + ::testing::Values("avg"), + ::testing::Values(true), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::ValuesIn(filterCPUInfoForDevice("3D", "avg"))), AdaPoolLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_SUITE_P(smoke_StaticAdaPoolAvg4DLayoutTest, AdaPoolLayerCPUTest, - ::testing::Combine( - ::testing::Combine( - staticAdaPool4DParams, - ::testing::Values("avg"), - ::testing::Values(true), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - ::testing::ValuesIn(filterCPUInfoForDevice("4D", "avg"))), +INSTANTIATE_TEST_SUITE_P(smoke_StaticAdaPoolAvg4DLayoutTest, + AdaPoolLayerCPUTest, + ::testing::Combine(::testing::Combine(staticAdaPool4DParams, + ::testing::Values("avg"), + ::testing::Values(true), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::ValuesIn(filterCPUInfoForDevice("4D", "avg"))), AdaPoolLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_SUITE_P(smoke_StaticAdaPoolAvg5DLayoutTest, AdaPoolLayerCPUTest, - ::testing::Combine( - ::testing::Combine( - staticAdaPool5DParams, - ::testing::Values("avg"), - ::testing::Values(true), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - ::testing::ValuesIn(filterCPUInfoForDevice("5D", "avg"))), +INSTANTIATE_TEST_SUITE_P(smoke_StaticAdaPoolAvg5DLayoutTest, + AdaPoolLayerCPUTest, + ::testing::Combine(::testing::Combine(staticAdaPool5DParams, + ::testing::Values("avg"), + ::testing::Values(true), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::ValuesIn(filterCPUInfoForDevice("5D", "avg"))), AdaPoolLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_SUITE_P(smoke_StaticAdaPoolMax3DLayoutTest, AdaPoolLayerCPUTest, - ::testing::Combine( - ::testing::Combine( - staticAdaPool3DParams, - ::testing::Values("max"), - ::testing::Values(true), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - ::testing::ValuesIn(filterCPUInfoForDevice("3D", "max"))), +INSTANTIATE_TEST_SUITE_P(smoke_StaticAdaPoolMax3DLayoutTest, + AdaPoolLayerCPUTest, + ::testing::Combine(::testing::Combine(staticAdaPool3DParams, + ::testing::Values("max"), + ::testing::Values(true), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::ValuesIn(filterCPUInfoForDevice("3D", "max"))), AdaPoolLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_SUITE_P(smoke_StaticAdaPoolMax4DLayoutTest, AdaPoolLayerCPUTest, - ::testing::Combine( - ::testing::Combine( - staticAdaPool4DParams, - ::testing::Values("max"), - ::testing::Values(true), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - ::testing::ValuesIn(filterCPUInfoForDevice("4D", "max"))), +INSTANTIATE_TEST_SUITE_P(smoke_StaticAdaPoolMax4DLayoutTest, + AdaPoolLayerCPUTest, + ::testing::Combine(::testing::Combine(staticAdaPool4DParams, + ::testing::Values("max"), + ::testing::Values(true), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::ValuesIn(filterCPUInfoForDevice("4D", "max"))), AdaPoolLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_SUITE_P(smoke_StaticAdaPoolMax5DLayoutTest, AdaPoolLayerCPUTest, - ::testing::Combine( - ::testing::Combine( - staticAdaPool5DParams, - ::testing::Values("max"), - ::testing::Values(true), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - ::testing::ValuesIn(filterCPUInfoForDevice("5D", "max"))), +INSTANTIATE_TEST_SUITE_P(smoke_StaticAdaPoolMax5DLayoutTest, + AdaPoolLayerCPUTest, + ::testing::Combine(::testing::Combine(staticAdaPool5DParams, + ::testing::Values("max"), + ::testing::Values(true), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::ValuesIn(filterCPUInfoForDevice("5D", "max"))), AdaPoolLayerCPUTest::getTestCaseName); - -// in 1-channel cases {..., 1, 1, 1} shape cannot be correctly resolved on oneDnn level, so it was removed from instances +// in 1-channel cases {..., 1, 1, 1} shape cannot be correctly resolved on oneDnn level, so it was removed from +// instances const std::vector> input3DShape1Channel = { - { - {{{-1, -1, -1}, {{1, 1, 2}, {1, 1, 2}, {1, 1, 2}}}}, - {{{{1, 10}, {1, 10}, {1, 10}}, {{1, 1, 2}, {2, 1, 2}, {2, 1, 2}}}} - } -}; + {{{{-1, -1, -1}, {{1, 1, 2}, {1, 1, 2}, {1, 1, 2}}}}, + {{{{1, 10}, {1, 10}, {1, 10}}, {{1, 1, 2}, {2, 1, 2}, {2, 1, 2}}}}}}; const std::vector> input4DShape1Channel = { - { - {{{-1, -1, -1, -1}, {{1, 1, 1, 2}, {2, 1, 2, 1}, {2, 1, 2, 1}}}}, - {{{{1, 10}, {1, 10}, {1, 10}, {1, 10}}, {{1, 1, 1, 2}, {1, 1, 1, 2}, {2, 1, 2, 1}}}} - } -}; + {{{{-1, -1, -1, -1}, {{1, 1, 1, 2}, {2, 1, 2, 1}, {2, 1, 2, 1}}}}, + {{{{1, 10}, {1, 10}, {1, 10}, {1, 10}}, {{1, 1, 1, 2}, {1, 1, 1, 2}, {2, 1, 2, 1}}}}}}; const std::vector> input5DShape1Channel = { - { - {{{-1, -1, -1, -1, -1}, {{1, 1, 1, 1, 2}, {1, 1, 1, 1, 2}, {2, 1, 1, 2, 1}}}}, - {{{{1, 10}, {1, 10}, {1, 10}, {1, 10}, {1, 10}}, {{1, 1, 1, 1, 2}, {1, 1, 1, 1, 2}, {2, 1, 1, 2, 1}}}} - } -}; - -INSTANTIATE_TEST_SUITE_P(smoke_AdaPool_1ch_Avg3DLayoutTest, AdaPoolLayerCPUTest, - ::testing::Combine( - ::testing::Combine( - ::testing::Combine( - ::testing::ValuesIn(std::vector> { - {1}, {2}}), - ::testing::ValuesIn(input3DShape1Channel)), - ::testing::Values("avg"), - ::testing::Values(true), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - ::testing::Values(CPUSpecificParams{{ncw, x}, {ncw}, {}, {}})), - AdaPoolLayerCPUTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_AdaPool_1ch_Avg4DLayoutTest, AdaPoolLayerCPUTest, - ::testing::Combine( - ::testing::Combine( - ::testing::Combine( - ::testing::ValuesIn(std::vector> { - {1, 1}, - {2, 2} - }), - ::testing::ValuesIn(input4DShape1Channel)), - ::testing::Values("avg"), - ::testing::Values(true), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - ::testing::Values(CPUSpecificParams{{nchw, x}, {nchw}, {}, {}})), - AdaPoolLayerCPUTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_AdaPool_1ch_Avg5DLayoutTest, AdaPoolLayerCPUTest, - ::testing::Combine( - ::testing::Combine( - ::testing::Combine( - ::testing::ValuesIn(std::vector> { - {1, 1, 1}, {2, 2, 2}}), - ::testing::ValuesIn(input5DShape1Channel)), - ::testing::Values("avg"), - ::testing::Values(true), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - ::testing::Values(CPUSpecificParams{{ncdhw, x}, {ncdhw}, {}, {}})), - AdaPoolLayerCPUTest::getTestCaseName); - + {{{{-1, -1, -1, -1, -1}, {{1, 1, 1, 1, 2}, {1, 1, 1, 1, 2}, {2, 1, 1, 2, 1}}}}, + {{{{1, 10}, {1, 10}, {1, 10}, {1, 10}, {1, 10}}, {{1, 1, 1, 1, 2}, {1, 1, 1, 1, 2}, {2, 1, 1, 2, 1}}}}}}; + +INSTANTIATE_TEST_SUITE_P( + smoke_AdaPool_1ch_Avg3DLayoutTest, + AdaPoolLayerCPUTest, + ::testing::Combine(::testing::Combine(::testing::Combine(::testing::ValuesIn(std::vector>{{1}, + {2}}), + ::testing::ValuesIn(input3DShape1Channel)), + ::testing::Values("avg"), + ::testing::Values(true), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::Values(CPUSpecificParams{{ncw, x}, {ncw}, {}, {}})), + AdaPoolLayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P( + smoke_AdaPool_1ch_Avg4DLayoutTest, + AdaPoolLayerCPUTest, + ::testing::Combine(::testing::Combine(::testing::Combine(::testing::ValuesIn(std::vector>{{1, 1}, + {2, 2}}), + ::testing::ValuesIn(input4DShape1Channel)), + ::testing::Values("avg"), + ::testing::Values(true), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::Values(CPUSpecificParams{{nchw, x}, {nchw}, {}, {}})), + AdaPoolLayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P( + smoke_AdaPool_1ch_Avg5DLayoutTest, + AdaPoolLayerCPUTest, + ::testing::Combine( + ::testing::Combine(::testing::Combine(::testing::ValuesIn(std::vector>{{1, 1, 1}, {2, 2, 2}}), + ::testing::ValuesIn(input5DShape1Channel)), + ::testing::Values("avg"), + ::testing::Values(true), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::Values(CPUSpecificParams{{ncdhw, x}, {ncdhw}, {}, {}})), + AdaPoolLayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P( + smoke_AdaPool_1ch_Max3DLayoutTest, + AdaPoolLayerCPUTest, + ::testing::Combine(::testing::Combine(::testing::Combine(::testing::ValuesIn(std::vector>{{1}, + {2}}), + ::testing::ValuesIn(input3DShape1Channel)), + ::testing::Values("max"), + ::testing::Values(true), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::Values(CPUSpecificParams{{ncw, x}, {ncw}, {}, {}})), + AdaPoolLayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P( + smoke_AdaPool_1ch_Max4DLayoutTest, + AdaPoolLayerCPUTest, + ::testing::Combine(::testing::Combine(::testing::Combine(::testing::ValuesIn(std::vector>{{1, 1}, + {2, 2}}), + ::testing::ValuesIn(input4DShape1Channel)), + ::testing::Values("max"), + ::testing::Values(true), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::Values(CPUSpecificParams{{nchw, x}, {nchw}, {}, {}})), + AdaPoolLayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P( + smoke_AdaPool_1ch_Max5DLayoutTest, + AdaPoolLayerCPUTest, + ::testing::Combine( + ::testing::Combine(::testing::Combine(::testing::ValuesIn(std::vector>{{1, 1, 1}, {2, 2, 2}}), + ::testing::ValuesIn(input5DShape1Channel)), + ::testing::Values("max"), + ::testing::Values(true), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::Values(CPUSpecificParams{{ncdhw, x}, {ncdhw}, {}, {}})), + AdaPoolLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_SUITE_P(smoke_AdaPool_1ch_Max3DLayoutTest, AdaPoolLayerCPUTest, - ::testing::Combine( - ::testing::Combine( - ::testing::Combine( - ::testing::ValuesIn(std::vector> { - {1}, {2}}), - ::testing::ValuesIn(input3DShape1Channel)), - ::testing::Values("max"), - ::testing::Values(true), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - ::testing::Values(CPUSpecificParams{{ncw, x}, {ncw}, {}, {}})), - AdaPoolLayerCPUTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_AdaPool_1ch_Max4DLayoutTest, AdaPoolLayerCPUTest, - ::testing::Combine( - ::testing::Combine( - ::testing::Combine( - ::testing::ValuesIn(std::vector> { - {1, 1}, {2, 2}}), - ::testing::ValuesIn(input4DShape1Channel)), - ::testing::Values("max"), - ::testing::Values(true), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - ::testing::Values(CPUSpecificParams{{nchw, x}, {nchw}, {}, {}})), - AdaPoolLayerCPUTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_AdaPool_1ch_Max5DLayoutTest, AdaPoolLayerCPUTest, - ::testing::Combine( - ::testing::Combine( - ::testing::Combine( - ::testing::ValuesIn(std::vector> { - {1, 1, 1}, - {2, 2, 2} - }), - ::testing::ValuesIn(input5DShape1Channel)), - ::testing::Values("max"), - ::testing::Values(true), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - ::testing::Values(CPUSpecificParams{{ncdhw, x}, {ncdhw}, {}, {}})), - AdaPoolLayerCPUTest::getTestCaseName); - -} // namespace -} // namespace CPULayerTestsDefinitions +} // namespace +} // namespace test +} // namespace ov diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/augru_cell.cpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/augru_cell.cpp index bc407ef7e19303..2c5f131cbbe448 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/augru_cell.cpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/augru_cell.cpp @@ -2,39 +2,47 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "shared_test_classes/base/ov_subgraph.hpp" #include "common_test_utils/node_builders/augru_cell.hpp" + +#include "shared_test_classes/base/ov_subgraph.hpp" #include "test_utils/cpu_test_utils.hpp" using namespace CPUTestUtils; -using namespace ov::test; -namespace CPULayerTestsDefinitions { +namespace ov { +namespace test { -using AUGRUCellCpuSpecificParams = typename std::tuple< - std::vector, // Shapes - bool, // Using decompose to sub-ops transformation - std::vector, // Activations - float, // Clip - bool, // Linear before reset - ElementType, // Network precision - CPUSpecificParams, // CPU specific params - std::map // Additional config ->; +using AUGRUCellCpuSpecificParams = typename std::tuple, // Shapes + bool, // Using decompose to sub-ops transformation + std::vector, // Activations + float, // Clip + bool, // Linear before reset + ElementType, // Network precision + CPUSpecificParams, // CPU specific params + ov::AnyMap // Additional config + >; class AUGRUCellCPUTest : public testing::WithParamInterface, - virtual public ov::test::SubgraphBaseTest, public CPUTestsBase { + virtual public ov::test::SubgraphBaseTest, + public CPUTestsBase { public: - static std::string getTestCaseName(const testing::TestParamInfo &obj) { + static std::string getTestCaseName(const testing::TestParamInfo& obj) { std::vector inputShapes; bool decompose, linearBeforeReset; std::vector activations; float clip = 0.f; ElementType netPrecision; CPUSpecificParams cpuParams; - std::map additionalConfig; + ov::AnyMap additionalConfig; - std::tie(inputShapes, decompose, activations, clip, linearBeforeReset, netPrecision, cpuParams, additionalConfig) = obj.param; + std::tie(inputShapes, + decompose, + activations, + clip, + linearBeforeReset, + netPrecision, + cpuParams, + additionalConfig) = obj.param; std::ostringstream result; result << "IS=("; @@ -50,7 +58,7 @@ class AUGRUCellCPUTest : public testing::WithParamInterface> additionalConfig - = {{{InferenceEngine::PluginConfigParams::KEY_ENFORCE_BF16, InferenceEngine::PluginConfigParams::NO}}, - {{InferenceEngine::PluginConfigParams::KEY_ENFORCE_BF16, InferenceEngine::PluginConfigParams::YES}}}; +std::vector additionalConfig = {{ov::hint::inference_precision(ov::element::f32)}, + {ov::hint::inference_precision(ov::element::bf16)}}; CPUSpecificParams cpuParams{{nc, nc}, {nc}, {"ref_any"}, "ref_any"}; @@ -127,79 +144,80 @@ std::vector> activations = {{"sigmoid", "tanh"}}; std::vector clip = {0.f}; // dev_api::augrucell does not support lbr so far. std::vector linearBeforeReset = {false}; -std::vector netPrecisions = { ElementType::f32 }; - -const std::vector> staticShapes = { - { { {}, { {1, 1} } }, // Static shapes - { {}, { {1, 1} } }, - { {}, { {1, 1} } } }, - { { {}, { {1, 1} } }, // Static shapes - { {}, { {1, 10} } }, - { {}, { {1, 1} } } }, - { { {}, { {1, 30} } }, // Static shapes - { {}, { {1, 10} } }, - { {}, { {1, 1} } } }, - { { {}, { {1, 30} } }, // Static shapes - { {}, { {1, 1} } }, - { {}, { {1, 1} } } }, - { { {}, { {3, 1} } }, // Static shapes - { {}, { {3, 1} } }, - { {}, { {3, 1} } } }, - { { {}, { {5, 1} } }, // Static shapes - { {}, { {5, 1} } }, - { {}, { {5, 1} } } }, - { { {}, { {5, 30} } }, // Static shapes - { {}, { {5, 10} } }, - { {}, { {5, 1} } } } -}; - -INSTANTIATE_TEST_SUITE_P(smoke_static, AUGRUCellCPUTest, - ::testing::Combine(::testing::ValuesIn(staticShapes), - ::testing::ValuesIn(shouldDecompose), - ::testing::ValuesIn(activations), - ::testing::ValuesIn(clip), - ::testing::ValuesIn(linearBeforeReset), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(cpuParams), - ::testing::ValuesIn(additionalConfig)), - AUGRUCellCPUTest::getTestCaseName); +std::vector netPrecisions = {ElementType::f32}; + +const std::vector> staticShapes = {{{{}, {{1, 1}}}, // Static shapes + {{}, {{1, 1}}}, + {{}, {{1, 1}}}}, + {{{}, {{1, 1}}}, // Static shapes + {{}, {{1, 10}}}, + {{}, {{1, 1}}}}, + {{{}, {{1, 30}}}, // Static shapes + {{}, {{1, 10}}}, + {{}, {{1, 1}}}}, + {{{}, {{1, 30}}}, // Static shapes + {{}, {{1, 1}}}, + {{}, {{1, 1}}}}, + {{{}, {{3, 1}}}, // Static shapes + {{}, {{3, 1}}}, + {{}, {{3, 1}}}}, + {{{}, {{5, 1}}}, // Static shapes + {{}, {{5, 1}}}, + {{}, {{5, 1}}}}, + {{{}, {{5, 30}}}, // Static shapes + {{}, {{5, 10}}}, + {{}, {{5, 1}}}}}; + +INSTANTIATE_TEST_SUITE_P(smoke_static, + AUGRUCellCPUTest, + ::testing::Combine(::testing::ValuesIn(staticShapes), + ::testing::ValuesIn(shouldDecompose), + ::testing::ValuesIn(activations), + ::testing::ValuesIn(clip), + ::testing::ValuesIn(linearBeforeReset), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(cpuParams), + ::testing::ValuesIn(additionalConfig)), + AUGRUCellCPUTest::getTestCaseName); const std::vector> dynamicShapes = { - { { { {-1}, 1 }, // Dynamic shape 0 - { {1, 1}, {3, 1}, {5, 1} } }, // Target shapes - { { {-1}, 1 }, // Dynamic shape 1 - { {1, 1}, {3, 1}, {5, 1} } }, // Target shapes - { { {-1}, 1 }, // Dynamic shape 2 - { {1, 1}, {3, 1}, {5, 1} } } }, // Target shapes - { { { {1, 10}, 30 }, // Dynamic shape 0 - { {2, 30}, {5, 30}, {8, 30} } }, // Target shapes - { { {1, 10}, 10 }, // Dynamic shape 1 - { {2, 10}, {5, 10}, {8, 10} } }, // Target shapes - { { {1, 10}, 1 }, // Dynamic shape 2 - { {2, 1}, {5, 1}, {8, 1} } } }, // Target shapes - { { { {1, 10}, {25, 35} }, // Dynamic shape 0 - { {2, 30}, {5, 30}, {8, 30} } }, // Target shapes - { { {1, 10}, -1 }, // Dynamic shape 1 - { {2, 10}, {5, 10}, {8, 10} } }, // Target shapes - { { {1, 10}, 1 }, // Dynamic shape 2 - { {2, 1}, {5, 1}, {8, 1} } } }, // Target shapes - { { { {1, 10}, {25, 35} }, // Dynamic shape 0 - { {2, 30}, {5, 30}, {8, 30}, {2, 30}, {5, 30}, {8, 30} } }, // Target shapes - { { {1, 10}, -1 }, // Dynamic shape 1 - { {2, 10}, {5, 10}, {8, 10}, {2, 10}, {5, 10}, {8, 10} } }, // Target shapes - { { {1, 10}, 1 }, // Dynamic shape 2 - { {2, 1}, {5, 1}, {8, 1}, {2, 1}, {5, 1}, {8, 1} } } } // Target shapes + {{{{-1}, 1}, // Dynamic shape 0 + {{1, 1}, {3, 1}, {5, 1}}}, // Target shapes + {{{-1}, 1}, // Dynamic shape 1 + {{1, 1}, {3, 1}, {5, 1}}}, // Target shapes + {{{-1}, 1}, // Dynamic shape 2 + {{1, 1}, {3, 1}, {5, 1}}}}, // Target shapes + {{{{1, 10}, 30}, // Dynamic shape 0 + {{2, 30}, {5, 30}, {8, 30}}}, // Target shapes + {{{1, 10}, 10}, // Dynamic shape 1 + {{2, 10}, {5, 10}, {8, 10}}}, // Target shapes + {{{1, 10}, 1}, // Dynamic shape 2 + {{2, 1}, {5, 1}, {8, 1}}}}, // Target shapes + {{{{1, 10}, {25, 35}}, // Dynamic shape 0 + {{2, 30}, {5, 30}, {8, 30}}}, // Target shapes + {{{1, 10}, -1}, // Dynamic shape 1 + {{2, 10}, {5, 10}, {8, 10}}}, // Target shapes + {{{1, 10}, 1}, // Dynamic shape 2 + {{2, 1}, {5, 1}, {8, 1}}}}, // Target shapes + {{{{1, 10}, {25, 35}}, // Dynamic shape 0 + {{2, 30}, {5, 30}, {8, 30}, {2, 30}, {5, 30}, {8, 30}}}, // Target shapes + {{{1, 10}, -1}, // Dynamic shape 1 + {{2, 10}, {5, 10}, {8, 10}, {2, 10}, {5, 10}, {8, 10}}}, // Target shapes + {{{1, 10}, 1}, // Dynamic shape 2 + {{2, 1}, {5, 1}, {8, 1}, {2, 1}, {5, 1}, {8, 1}}}} // Target shapes }; -INSTANTIATE_TEST_SUITE_P(smoke_dynamic, AUGRUCellCPUTest, - ::testing::Combine(::testing::ValuesIn(dynamicShapes), - ::testing::ValuesIn(shouldDecompose), - ::testing::ValuesIn(activations), - ::testing::ValuesIn(clip), - ::testing::ValuesIn(linearBeforeReset), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(cpuParams), - ::testing::ValuesIn(additionalConfig)), - AUGRUCellCPUTest::getTestCaseName); -} // namespace -} // namespace CPULayerTestsDefinitions +INSTANTIATE_TEST_SUITE_P(smoke_dynamic, + AUGRUCellCPUTest, + ::testing::Combine(::testing::ValuesIn(dynamicShapes), + ::testing::ValuesIn(shouldDecompose), + ::testing::ValuesIn(activations), + ::testing::ValuesIn(clip), + ::testing::ValuesIn(linearBeforeReset), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(cpuParams), + ::testing::ValuesIn(additionalConfig)), + AUGRUCellCPUTest::getTestCaseName); +} // namespace +} // namespace test +} // namespace ov diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/augru_sequence.cpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/augru_sequence.cpp index 0765b65907d7d2..3940d3bd77b6fb 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/augru_sequence.cpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/augru_sequence.cpp @@ -2,44 +2,53 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "shared_test_classes/base/ov_subgraph.hpp" #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 "transformations/op_conversions/bidirectional_sequences_decomposition.hpp" #include "transformations/op_conversions/convert_sequences_to_tensor_iterator.hpp" using namespace CPUTestUtils; -using namespace ov::test; - -namespace CPULayerTestsDefinitions { - -using AUGRUSequenceCpuSpecificParams = typename std::tuple< - std::vector, // Shapes - ngraph::helpers::SequenceTestsMode, // Pure Sequence or TensorIterator - std::vector, // Activations - float, // Clip - bool, // Linear_before_reset - ov::op::RecurrentSequenceDirection, // Direction - ElementType, // Network precision - CPUSpecificParams, // CPU specific params - std::map // Additional config ->; + +namespace ov { +namespace test { + +using AUGRUSequenceCpuSpecificParams = + typename std::tuple, // Shapes + ov::test::utils::SequenceTestsMode, // Pure Sequence or TensorIterator + std::vector, // Activations + float, // Clip + bool, // Linear_before_reset + ov::op::RecurrentSequenceDirection, // Direction + ElementType, // Network precision + CPUSpecificParams, // CPU specific params + ov::AnyMap // Additional config + >; class AUGRUSequenceCPUTest : public testing::WithParamInterface, - virtual public ov::test::SubgraphBaseTest, public CPUTestsBase { + virtual public ov::test::SubgraphBaseTest, + public CPUTestsBase { public: - static std::string getTestCaseName(const testing::TestParamInfo &obj) { + static std::string getTestCaseName(const testing::TestParamInfo& obj) { std::vector inputShapes; - ngraph::helpers::SequenceTestsMode seqMode; + ov::test::utils::SequenceTestsMode seqMode; std::vector activations; float clip; bool linearBeforeRest; ov::op::RecurrentSequenceDirection direction; ElementType netPrecision; CPUSpecificParams cpuParams; - std::map additionalConfig; - - std::tie(inputShapes, seqMode, activations, clip, linearBeforeRest, direction, netPrecision, cpuParams, additionalConfig) = obj.param; + ov::AnyMap additionalConfig; + + std::tie(inputShapes, + seqMode, + activations, + clip, + linearBeforeRest, + direction, + netPrecision, + cpuParams, + additionalConfig) = obj.param; std::ostringstream result; result << "IS=("; @@ -55,7 +64,7 @@ class AUGRUSequenceCPUTest : public testing::WithParamInterface(netPrecision, shape)); } - const size_t batchSize = inputDynamicShapes[0][0].is_static() ? inputDynamicShapes[0][0].get_length() : - inputDynamicShapes[1][0].is_static() ? inputDynamicShapes[1][0].get_length() : - inputDynamicShapes.size() > 2 && inputDynamicShapes[2][0].is_static() ? inputDynamicShapes[2][0].get_length() : - 1lu; - /** - * There are 2 options to paramter "in" when "make_sequence" is true. - * 0 1 2 3 - * X init_hidden_state attention seq_length - * or, - * 0 1 2 - * X init_hidden_state attention - * - */ + const size_t batchSize = inputDynamicShapes[0][0].is_static() ? inputDynamicShapes[0][0].get_length() + : inputDynamicShapes[1][0].is_static() ? inputDynamicShapes[1][0].get_length() + : inputDynamicShapes.size() > 2 && inputDynamicShapes[2][0].is_static() + ? inputDynamicShapes[2][0].get_length() + : 1lu; + /** + * There are 2 options to paramter "in" when "make_sequence" is true. + * 0 1 2 3 + * X init_hidden_state attention seq_length + * or, + * 0 1 2 + * X init_hidden_state attention + * + */ if (inputDynamicShapes.size() > 3) { if (!inputDynamicShapes[3].is_dynamic() && - seqMode != ngraph::helpers::SequenceTestsMode::CONVERT_TO_TI_MAX_SEQ_LEN_PARAM && - seqMode != ngraph::helpers::SequenceTestsMode::CONVERT_TO_TI_RAND_SEQ_LEN_PARAM) { + seqMode != ov::test::utils::SequenceTestsMode::CONVERT_TO_TI_MAX_SEQ_LEN_PARAM && + seqMode != ov::test::utils::SequenceTestsMode::CONVERT_TO_TI_RAND_SEQ_LEN_PARAM) { params.pop_back(); } else { params[3]->set_element_type(ElementType::i64); @@ -134,18 +153,15 @@ class AUGRUSequenceCPUTest : public testing::WithParamInterface WRB = {{numDirections, 3 * hiddenSize, inputSize}, {numDirections, 3 * hiddenSize, hiddenSize}, - {numDirections, (linearBeforeReset ? 4 : 3) * hiddenSize}, {batchSize}}; - auto augruSequenceOp = ov::test::utils::make_augru(paramsOuts, - WRB, - hiddenSize, - true, - direction, - seqMode); + std::vector WRB = {{numDirections, 3 * hiddenSize, inputSize}, + {numDirections, 3 * hiddenSize, hiddenSize}, + {numDirections, (linearBeforeReset ? 4 : 3) * hiddenSize}, + {batchSize}}; + auto augruSequenceOp = ov::test::utils::make_augru(paramsOuts, WRB, hiddenSize, true, direction, seqMode); function = makeNgraphFunction(netPrecision, params, augruSequenceOp, "augruSequenceOp"); - if (seqMode != ngraph::helpers::SequenceTestsMode::PURE_SEQ) { + if (seqMode != ov::test::utils::SequenceTestsMode::PURE_SEQ) { // TODO: ConvertAUGRUSequenceToTensorIterator throw std::runtime_error("ConvertAUGRUSequenceToTensorIterator not implemented yet."); } else { @@ -178,14 +194,13 @@ TEST_P(AUGRUSequenceCPUTest, CompareWithRefs) { namespace { /* CPU PARAMS */ -std::vector> additionalConfig - = {{{InferenceEngine::PluginConfigParams::KEY_ENFORCE_BF16, InferenceEngine::PluginConfigParams::NO}}, - {{InferenceEngine::PluginConfigParams::KEY_ENFORCE_BF16, InferenceEngine::PluginConfigParams::YES}}}; +std::vector additionalConfig = {{ov::hint::inference_precision(ov::element::f32)}, + {ov::hint::inference_precision(ov::element::bf16)}}; CPUSpecificParams cpuParams{{ntc, tnc}, {ntc, tnc}, {"ref_any"}, "ref_any"}; -CPUSpecificParams cpuParamsBatchSizeOne{{tnc, tnc}, {tnc, tnc}, {"ref_any"}, "ref_any"};; +CPUSpecificParams cpuParamsBatchSizeOne{{tnc, tnc}, {tnc, tnc}, {"ref_any"}, "ref_any"}; -std::vector mode{ngraph::helpers::SequenceTestsMode::PURE_SEQ}; +std::vector mode{ov::test::utils::SequenceTestsMode::PURE_SEQ}; // output values increase rapidly without clip, so use only seq_lengths = 2 std::vector> activations = {{"sigmoid", "tanh"}}; // dev_api::augrucell does not support lbr so far. @@ -194,190 +209,198 @@ std::vector clip{0.f}; // dev_api::augrusequence only supports forward so far. std::vector direction = {ov::op::RecurrentSequenceDirection::FORWARD}; -std::vector netPrecisions = { ElementType::f32 }; - -const std::vector> staticShapes = { - { { {}, { {10, 2, 10} } }, // #0. Static shapes - { {}, { {10, 1, 1} } }, - { {}, { {10, 2, 1} } }, - { {}, { {10} } } }, - { { {}, { {10, 2, 10} } }, // #1. Static shapes - { {}, { {10, 1, 10} } }, - { {}, { {10, 2, 1} } }, - { {}, { {10} } } }, - { { {}, { {1, 2, 10} } }, // #2. Static shapes - { {}, { {1, 1, 1} } }, - { {}, { {1, 2, 1} } }, - { {}, { {1} } } }, - { { {}, { {1, 2, 10} } }, // #3. Static shapes - { {}, { {1, 1, 10} } }, - { {}, { {1, 2, 1} } }, - { {}, { {1} } } }, - { { {}, { {10, 2, 10} } }, // #4. Static shapes - { {}, { {10, 1, 1} } }, - { {}, { {10, 2, 1} } } }, - { { {}, { {10, 2, 10} } }, // #5. Static shapes - { {}, { {10, 1, 10} } }, - { {}, { {10, 2, 1} } } } -}; - -INSTANTIATE_TEST_SUITE_P(smoke_static, AUGRUSequenceCPUTest, - ::testing::Combine(::testing::ValuesIn(std::vector>{staticShapes[0], staticShapes[1]}), - ::testing::ValuesIn(mode), - ::testing::ValuesIn(activations), - ::testing::ValuesIn(clip), - ::testing::ValuesIn(linearBeforeReset), - ::testing::ValuesIn(direction), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(cpuParams), - ::testing::Values(std::map{})), - AUGRUSequenceCPUTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_static_BatchSizeOne, AUGRUSequenceCPUTest, - ::testing::Combine(::testing::ValuesIn(std::vector>{staticShapes[3]}), - ::testing::ValuesIn(mode), - ::testing::ValuesIn(activations), - ::testing::ValuesIn(clip), - ::testing::ValuesIn(linearBeforeReset), - ::testing::ValuesIn(direction), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(cpuParamsBatchSizeOne), - ::testing::Values(std::map{})), - AUGRUSequenceCPUTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(nightly_static_bf16, AUGRUSequenceCPUTest, - ::testing::Combine(::testing::ValuesIn(std::vector>{staticShapes[4], staticShapes[5]}), - ::testing::ValuesIn(mode), - ::testing::ValuesIn(activations), - ::testing::ValuesIn(clip), - ::testing::ValuesIn(linearBeforeReset), - ::testing::ValuesIn(direction), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(cpuParams), - ::testing::Values(additionalConfig[1])), - AUGRUSequenceCPUTest::getTestCaseName); +std::vector netPrecisions = {ElementType::f32}; + +const std::vector> staticShapes = {{{{}, {{10, 2, 10}}}, // #0. Static shapes + {{}, {{10, 1, 1}}}, + {{}, {{10, 2, 1}}}, + {{}, {{10}}}}, + {{{}, {{10, 2, 10}}}, // #1. Static shapes + {{}, {{10, 1, 10}}}, + {{}, {{10, 2, 1}}}, + {{}, {{10}}}}, + {{{}, {{1, 2, 10}}}, // #2. Static shapes + {{}, {{1, 1, 1}}}, + {{}, {{1, 2, 1}}}, + {{}, {{1}}}}, + {{{}, {{1, 2, 10}}}, // #3. Static shapes + {{}, {{1, 1, 10}}}, + {{}, {{1, 2, 1}}}, + {{}, {{1}}}}, + {{{}, {{10, 2, 10}}}, // #4. Static shapes + {{}, {{10, 1, 1}}}, + {{}, {{10, 2, 1}}}}, + {{{}, {{10, 2, 10}}}, // #5. Static shapes + {{}, {{10, 1, 10}}}, + {{}, {{10, 2, 1}}}}}; + +INSTANTIATE_TEST_SUITE_P(smoke_static, + AUGRUSequenceCPUTest, + ::testing::Combine(::testing::ValuesIn(std::vector>{staticShapes[0], + staticShapes[1]}), + ::testing::ValuesIn(mode), + ::testing::ValuesIn(activations), + ::testing::ValuesIn(clip), + ::testing::ValuesIn(linearBeforeReset), + ::testing::ValuesIn(direction), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(cpuParams), + ::testing::Values(ov::AnyMap{})), + AUGRUSequenceCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_static_BatchSizeOne, + AUGRUSequenceCPUTest, + ::testing::Combine(::testing::ValuesIn(std::vector>{staticShapes[3]}), + ::testing::ValuesIn(mode), + ::testing::ValuesIn(activations), + ::testing::ValuesIn(clip), + ::testing::ValuesIn(linearBeforeReset), + ::testing::ValuesIn(direction), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(cpuParamsBatchSizeOne), + ::testing::Values(ov::AnyMap{})), + AUGRUSequenceCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(nightly_static_bf16, + AUGRUSequenceCPUTest, + ::testing::Combine(::testing::ValuesIn(std::vector>{staticShapes[4], + staticShapes[5]}), + ::testing::ValuesIn(mode), + ::testing::ValuesIn(activations), + ::testing::ValuesIn(clip), + ::testing::ValuesIn(linearBeforeReset), + ::testing::ValuesIn(direction), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(cpuParams), + ::testing::Values(additionalConfig[1])), + AUGRUSequenceCPUTest::getTestCaseName); const std::vector> dynamicShapes = { - { { {-1, {1, 5}, 10}, // #0. Dynamic shape 0 - { {10, 2, 10}, {8, 3, 10}, {5, 4, 10} } }, // Target shapes - { {{0, 15}, 1, 1}, // Dynamic shape 1 - { {10, 1, 1}, {8, 1, 1}, {5, 1, 1} } }, // Target shapes - { {-1, {1, 5}, 1}, // Dynamic shape 2 - { {10, 2, 1}, {8, 3, 1}, {5, 4, 1} } }, // Target shapes - { {{0, 12}}, // Dynamic shape 3 - { {10}, {8}, {5} } } }, // Target shapes - { { {{0, 11}, -1, 10}, // #1. Dynamic shape 0 - { {10, 2, 10}, {3, 4, 10}, {5, 5, 10} } }, // Target shapes - { {-1, 1, 10}, // Dynamic shape 1 - { {10, 1, 10}, {3, 1, 10}, {5, 1, 10} } }, // Target shapes - { {{0, 11}, -1, 1}, // Dynamic shape 3 - { {10, 2, 1}, {3, 4, 1}, {5, 5, 1} } }, // Target shapes - { {-1}, // Dynamic shape 2 - { {10}, {3}, {5} } } }, // Target shapes - { { {{0, 11}, -1, {7, 11}}, // #2. Dynamic shape 0 - { {10, 2, 10}, {3, 4, 10}, {5, 5, 10} } }, // Target shapes - { {-1, 1, {8, 12}}, // Dynamic shape 1 - { {10, 1, 10}, {3, 1, 10}, {5, 1, 10} } }, // Target shapes - { {{0, 11}, -1, 1}, // Dynamic shape 3 - { {10, 2, 1}, {3, 4, 1}, {5, 5, 1} } } , // Target shapes - { {-1}, // Dynamic shape 2 - { {10}, {3}, {5} } } }, // Target shapes - { { {-1, {0, 7}, 10}, // #3. Dynamic shape 0 - { {1, 2, 10}, {1, 3, 10}, {1, 6, 10} } }, // Target shapes - { {-1, 1, 1}, // Dynamic shape 1 - { {1, 1, 1}, {1, 1, 1}, {1, 1, 1} } }, // Target shapes - { {-1, {0, 7}, 1}, // Dynamic shape 3 - { {1, 2, 1}, {1, 3, 1}, {1, 6, 1} } }, // Target shapes - { {-1}, // Dynamic shape 2 - { {1}, {1}, {1} } } }, // Target shapes - { { {1, -1, 10}, // #4. Dynamic shape 0 - { {1, 2, 10}, {1, 4, 10}, {1, 8, 10} } }, // Target shapes - { {1, 1, 10}, // Dynamic shape 1 - { {1, 1, 10}, {1, 1, 10}, {1, 1, 10} } }, // Target shapes - { {1, -1, 1}, // Dynamic shape 0 - { {1, 2, 1}, {1, 4, 1}, {1, 8, 1} } }, // Target shapes - { {-1}, // Dynamic shape 2 - { {1}, {1}, {1} } } }, // Target shapes - { { {-1, -1, -1}, // #5. Dynamic shape 0 - { {1, 2, 10}, {1, 4, 10}, {1, 8, 10} } }, // Target shapes - { {-1, -1, -1}, // Dynamic shape 1 - { {1, 1, 10}, {1, 1, 10}, {1, 1, 10} } }, // Target shapes - { {-1, -1, -1}, // Dynamic shape 0 - { {1, 2, 1}, {1, 4, 1}, {1, 8, 1} } }, // Target shapes - { {-1}, // Dynamic shape 2 - { {1}, {1}, {1} } } }, // Target shapes - { { {2, {1, 5}, 10}, // #6. Dynamic shape 0 - { {2, 2, 10}, {2, 3, 10}, {2, 4, 10} } }, // Target shapes - { {2, 1, 1}, // Dynamic shape 1 - { {2, 1, 1}, {2, 1, 1}, {2, 1, 1} } }, // Target shapes - { {2, {1, 5}, 1}, // Dynamic shape 2 - { {2, 2, 1}, {2, 3, 1}, {2, 4, 1} } }, // Target shapes - { {-1}, // Dynamic shape 2 - { {2}, {2}, {2} } } }, // Target shapes - { { {5, -1, 10}, // #7. Dynamic shape 0 - { {5, 2, 10}, {5, 4, 10}, {5, 5, 10} } }, // Target shapes - { {5, 1, 10}, // Dynamic shape 1 - { {5, 1, 10}, {5, 1, 10}, {5, 1, 10} } }, // Target shapes - { {5, -1, 1}, // Dynamic shape 0 - { {5, 2, 1}, {5, 4, 1}, {5, 5, 1} } }, // Target shapes - { {-1}, // Dynamic shape 2 - { {5}, {5}, {5} } } }, // Target shapes - { { {{0, 11}, -1, {7, 11}}, // #8. Dynamic shape 0 - { {10, 2, 10}, {3, 4, 10}, {5, 5, 10}, {10, 2, 10}, {5, 5, 10} } }, // Target shapes - { {-1, 1, {8, 12}}, // Dynamic shape 1 - { {10, 1, 10}, {3, 1, 10}, {5, 1, 10}, {10, 1, 10}, {5, 1, 10} } }, // Target shapes - { {{0, 11}, -1, 1}, // Dynamic shape 3 - { {10, 2, 1}, {3, 4, 1}, {5, 5, 1}, {10, 2, 1}, {5, 5, 1} } }, // Target shapes - { {-1}, // Dynamic shape 2 - { {10}, {3}, {5}, {10}, {5} } } } // Target shapes + {{{-1, {1, 5}, 10}, // #0. Dynamic shape 0 + {{10, 2, 10}, {8, 3, 10}, {5, 4, 10}}}, // Target shapes + {{{0, 15}, 1, 1}, // Dynamic shape 1 + {{10, 1, 1}, {8, 1, 1}, {5, 1, 1}}}, // Target shapes + {{-1, {1, 5}, 1}, // Dynamic shape 2 + {{10, 2, 1}, {8, 3, 1}, {5, 4, 1}}}, // Target shapes + {{{0, 12}}, // Dynamic shape 3 + {{10}, {8}, {5}}}}, // Target shapes + {{{{0, 11}, -1, 10}, // #1. Dynamic shape 0 + {{10, 2, 10}, {3, 4, 10}, {5, 5, 10}}}, // Target shapes + {{-1, 1, 10}, // Dynamic shape 1 + {{10, 1, 10}, {3, 1, 10}, {5, 1, 10}}}, // Target shapes + {{{0, 11}, -1, 1}, // Dynamic shape 3 + {{10, 2, 1}, {3, 4, 1}, {5, 5, 1}}}, // Target shapes + {{-1}, // Dynamic shape 2 + {{10}, {3}, {5}}}}, // Target shapes + {{{{0, 11}, -1, {7, 11}}, // #2. Dynamic shape 0 + {{10, 2, 10}, {3, 4, 10}, {5, 5, 10}}}, // Target shapes + {{-1, 1, {8, 12}}, // Dynamic shape 1 + {{10, 1, 10}, {3, 1, 10}, {5, 1, 10}}}, // Target shapes + {{{0, 11}, -1, 1}, // Dynamic shape 3 + {{10, 2, 1}, {3, 4, 1}, {5, 5, 1}}}, // Target shapes + {{-1}, // Dynamic shape 2 + {{10}, {3}, {5}}}}, // Target shapes + {{{-1, {0, 7}, 10}, // #3. Dynamic shape 0 + {{1, 2, 10}, {1, 3, 10}, {1, 6, 10}}}, // Target shapes + {{-1, 1, 1}, // Dynamic shape 1 + {{1, 1, 1}, {1, 1, 1}, {1, 1, 1}}}, // Target shapes + {{-1, {0, 7}, 1}, // Dynamic shape 3 + {{1, 2, 1}, {1, 3, 1}, {1, 6, 1}}}, // Target shapes + {{-1}, // Dynamic shape 2 + {{1}, {1}, {1}}}}, // Target shapes + {{{1, -1, 10}, // #4. Dynamic shape 0 + {{1, 2, 10}, {1, 4, 10}, {1, 8, 10}}}, // Target shapes + {{1, 1, 10}, // Dynamic shape 1 + {{1, 1, 10}, {1, 1, 10}, {1, 1, 10}}}, // Target shapes + {{1, -1, 1}, // Dynamic shape 0 + {{1, 2, 1}, {1, 4, 1}, {1, 8, 1}}}, // Target shapes + {{-1}, // Dynamic shape 2 + {{1}, {1}, {1}}}}, // Target shapes + {{{-1, -1, -1}, // #5. Dynamic shape 0 + {{1, 2, 10}, {1, 4, 10}, {1, 8, 10}}}, // Target shapes + {{-1, -1, -1}, // Dynamic shape 1 + {{1, 1, 10}, {1, 1, 10}, {1, 1, 10}}}, // Target shapes + {{-1, -1, -1}, // Dynamic shape 0 + {{1, 2, 1}, {1, 4, 1}, {1, 8, 1}}}, // Target shapes + {{-1}, // Dynamic shape 2 + {{1}, {1}, {1}}}}, // Target shapes + {{{2, {1, 5}, 10}, // #6. Dynamic shape 0 + {{2, 2, 10}, {2, 3, 10}, {2, 4, 10}}}, // Target shapes + {{2, 1, 1}, // Dynamic shape 1 + {{2, 1, 1}, {2, 1, 1}, {2, 1, 1}}}, // Target shapes + {{2, {1, 5}, 1}, // Dynamic shape 2 + {{2, 2, 1}, {2, 3, 1}, {2, 4, 1}}}, // Target shapes + {{-1}, // Dynamic shape 2 + {{2}, {2}, {2}}}}, // Target shapes + {{{5, -1, 10}, // #7. Dynamic shape 0 + {{5, 2, 10}, {5, 4, 10}, {5, 5, 10}}}, // Target shapes + {{5, 1, 10}, // Dynamic shape 1 + {{5, 1, 10}, {5, 1, 10}, {5, 1, 10}}}, // Target shapes + {{5, -1, 1}, // Dynamic shape 0 + {{5, 2, 1}, {5, 4, 1}, {5, 5, 1}}}, // Target shapes + {{-1}, // Dynamic shape 2 + {{5}, {5}, {5}}}}, // Target shapes + {{{{0, 11}, -1, {7, 11}}, // #8. Dynamic shape 0 + {{10, 2, 10}, {3, 4, 10}, {5, 5, 10}, {10, 2, 10}, {5, 5, 10}}}, // Target shapes + {{-1, 1, {8, 12}}, // Dynamic shape 1 + {{10, 1, 10}, {3, 1, 10}, {5, 1, 10}, {10, 1, 10}, {5, 1, 10}}}, // Target shapes + {{{0, 11}, -1, 1}, // Dynamic shape 3 + {{10, 2, 1}, {3, 4, 1}, {5, 5, 1}, {10, 2, 1}, {5, 5, 1}}}, // Target shapes + {{-1}, // Dynamic shape 2 + {{10}, {3}, {5}, {10}, {5}}}} // Target shapes }; -INSTANTIATE_TEST_SUITE_P(smoke_dynamic, AUGRUSequenceCPUTest, - ::testing::Combine(::testing::ValuesIn({dynamicShapes[0], dynamicShapes[1], dynamicShapes[2]}), - ::testing::ValuesIn(mode), - ::testing::ValuesIn(activations), - ::testing::ValuesIn(clip), - ::testing::ValuesIn(linearBeforeReset), - ::testing::ValuesIn(direction), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(cpuParams), - ::testing::Values(std::map{})), - AUGRUSequenceCPUTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_dynamic_BatchSizeOne, AUGRUSequenceCPUTest, - ::testing::Combine(::testing::ValuesIn({dynamicShapes[4]}), - ::testing::ValuesIn(mode), - ::testing::ValuesIn(activations), - ::testing::ValuesIn(clip), - ::testing::ValuesIn(linearBeforeReset), - ::testing::ValuesIn(direction), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(cpuParamsBatchSizeOne), - ::testing::Values(std::map{})), - AUGRUSequenceCPUTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(nightly_dynamic, AUGRUSequenceCPUTest, - ::testing::Combine(::testing::ValuesIn({dynamicShapes[5], dynamicShapes[8]}), - ::testing::ValuesIn(mode), - ::testing::ValuesIn(activations), - ::testing::ValuesIn(clip), - ::testing::ValuesIn(linearBeforeReset), - ::testing::ValuesIn(direction), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(cpuParams), - ::testing::Values(std::map{})), - AUGRUSequenceCPUTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(nightly_dynamic_bf16, AUGRUSequenceCPUTest, - ::testing::Combine(::testing::ValuesIn({dynamicShapes[6], dynamicShapes[7]}), - ::testing::ValuesIn(mode), - ::testing::ValuesIn(activations), - ::testing::ValuesIn(clip), - ::testing::ValuesIn(linearBeforeReset), - ::testing::ValuesIn(direction), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(cpuParams), - ::testing::Values(additionalConfig[1])), - AUGRUSequenceCPUTest::getTestCaseName); -} // namespace -} // namespace CPULayerTestsDefinitions +INSTANTIATE_TEST_SUITE_P(smoke_dynamic, + AUGRUSequenceCPUTest, + ::testing::Combine(::testing::ValuesIn({dynamicShapes[0], dynamicShapes[1], dynamicShapes[2]}), + ::testing::ValuesIn(mode), + ::testing::ValuesIn(activations), + ::testing::ValuesIn(clip), + ::testing::ValuesIn(linearBeforeReset), + ::testing::ValuesIn(direction), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(cpuParams), + ::testing::Values(ov::AnyMap{})), + AUGRUSequenceCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_dynamic_BatchSizeOne, + AUGRUSequenceCPUTest, + ::testing::Combine(::testing::ValuesIn({dynamicShapes[4]}), + ::testing::ValuesIn(mode), + ::testing::ValuesIn(activations), + ::testing::ValuesIn(clip), + ::testing::ValuesIn(linearBeforeReset), + ::testing::ValuesIn(direction), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(cpuParamsBatchSizeOne), + ::testing::Values(ov::AnyMap{})), + AUGRUSequenceCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(nightly_dynamic, + AUGRUSequenceCPUTest, + ::testing::Combine(::testing::ValuesIn({dynamicShapes[5], dynamicShapes[8]}), + ::testing::ValuesIn(mode), + ::testing::ValuesIn(activations), + ::testing::ValuesIn(clip), + ::testing::ValuesIn(linearBeforeReset), + ::testing::ValuesIn(direction), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(cpuParams), + ::testing::Values(ov::AnyMap{})), + AUGRUSequenceCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(nightly_dynamic_bf16, + AUGRUSequenceCPUTest, + ::testing::Combine(::testing::ValuesIn({dynamicShapes[6], dynamicShapes[7]}), + ::testing::ValuesIn(mode), + ::testing::ValuesIn(activations), + ::testing::ValuesIn(clip), + ::testing::ValuesIn(linearBeforeReset), + ::testing::ValuesIn(direction), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(cpuParams), + ::testing::Values(additionalConfig[1])), + AUGRUSequenceCPUTest::getTestCaseName); +} // namespace +} // namespace test +} // namespace ov diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/batch_to_space.cpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/batch_to_space.cpp index 99367ef14e8ba9..39eb90391a8e23 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/batch_to_space.cpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/batch_to_space.cpp @@ -3,32 +3,32 @@ // #include -#include "shared_test_classes/base/ov_subgraph.hpp" + #include "ov_models/builders.hpp" +#include "shared_test_classes/base/ov_subgraph.hpp" #include "test_utils/cpu_test_utils.hpp" -using namespace InferenceEngine; using namespace CPUTestUtils; -using namespace ov::test; -namespace CPULayerTestsDefinitions { +namespace ov { +namespace test { namespace { - std::vector blockShape, cropsBegin, cropsEnd; +std::vector blockShape, cropsBegin, cropsEnd; } // namespace -using BatchToSpaceLayerTestCPUParams = std::tuple< - std::vector, // Input shapes - std::vector, // block shape - std::vector, // crops begin - std::vector, // crops end - ov::element::Type, // Network precision - CPUSpecificParams>; +using BatchToSpaceLayerTestCPUParams = std::tuple, // Input shapes + std::vector, // block shape + std::vector, // crops begin + std::vector, // crops end + ov::element::Type, // Network precision + CPUSpecificParams>; class BatchToSpaceCPULayerTest : public testing::WithParamInterface, - virtual public SubgraphBaseTest, public CPUTestsBase { + virtual public SubgraphBaseTest, + public CPUTestsBase { public: - static std::string getTestCaseName(const testing::TestParamInfo &obj) { + static std::string getTestCaseName(const testing::TestParamInfo& obj) { std::vector inputShapes; ov::element::Type model_type; CPUSpecificParams cpuParams; @@ -36,7 +36,7 @@ class BatchToSpaceCPULayerTest : public testing::WithParamInterfaceget_output_element_type(0); const auto& static_shape = targetInputStaticShapes[i]; switch (i) { - case 0: { - tensor = ov::test::utils::create_and_fill_tensor(param_type, static_shape, 2560, 0, 256); - break; - } - case 1: { - ASSERT_EQ(ov::shape_size(static_shape), blockShape.size()); - tensor = ov::Tensor(param_type, static_shape, blockShape.data()); - break; - } - case 2: - case 3: { - ASSERT_EQ(ov::shape_size(static_shape), cropsEnd.size()); - tensor = ov::Tensor(param_type, static_shape, cropsEnd.data()); - break; - } - default: { - throw std::runtime_error("Incorrect parameter number!"); - } + case 0: { + tensor = ov::test::utils::create_and_fill_tensor(param_type, static_shape, 2560, 0, 256); + break; + } + case 1: { + ASSERT_EQ(ov::shape_size(static_shape), blockShape.size()); + tensor = ov::Tensor(param_type, static_shape, blockShape.data()); + break; + } + case 2: + case 3: { + ASSERT_EQ(ov::shape_size(static_shape), cropsEnd.size()); + tensor = ov::Tensor(param_type, static_shape, cropsEnd.data()); + break; + } + default: { + throw std::runtime_error("Incorrect parameter number!"); + } } inputs.insert({parameter, tensor}); } @@ -92,7 +92,7 @@ class BatchToSpaceCPULayerTest : public testing::WithParamInterface inputShapes; + std::vector inputShapes; ov::element::Type model_type; CPUSpecificParams cpuParams; std::tie(inputShapes, blockShape, cropsBegin, cropsEnd, model_type, cpuParams) = this->GetParam(); @@ -120,8 +120,8 @@ class BatchToSpaceCPULayerTest : public testing::WithParamInterface(ov::element::Type_t::i64, inputDynamicShapes[3]); auto btsNode = std::make_shared(in0, in1, in2, in3); btsNode->get_rt_info() = getCPUInfo(); - ngraph::ResultVector results{std::make_shared(btsNode)}; - function = std::make_shared(results, ov::ParameterVector{in0, in1, in2, in3}, "BatchToSpace"); + ov::ResultVector results{std::make_shared(btsNode)}; + function = std::make_shared(results, ov::ParameterVector{in0, in1, in2, in3}, "BatchToSpace"); } }; @@ -132,310 +132,273 @@ TEST_P(BatchToSpaceCPULayerTest, CompareWithRefs) { namespace { -const std::vector model_types = { - ov::element::Type_t::u8, - ov::element::Type_t::i8, - ov::element::Type_t::i32, - ov::element::Type_t::f32, - ov::element::Type_t::bf16 -}; +const std::vector model_types = {ov::element::Type_t::u8, + ov::element::Type_t::i8, + ov::element::Type_t::i32, + ov::element::Type_t::f32, + ov::element::Type_t::bf16}; -const std::vector> blockShape4D1 = {{1, 1, 1, 2}, {1, 2, 2, 1}}; -const std::vector> cropsBegin4D1 = {{0, 0, 0, 0}, {0, 0, 0, 1}, {0, 0, 2, 0}}; -const std::vector> cropsEnd4D1 = {{0, 0, 0, 0}, {0, 0, 1, 0}, {0, 0, 1, 1}}; +const std::vector> blockShape4D1 = {{1, 1, 1, 2}, {1, 2, 2, 1}}; +const std::vector> cropsBegin4D1 = {{0, 0, 0, 0}, {0, 0, 0, 1}, {0, 0, 2, 0}}; +const std::vector> cropsEnd4D1 = {{0, 0, 0, 0}, {0, 0, 1, 0}, {0, 0, 1, 1}}; -std::vector> staticInputShapes4D1 = { - {{8, 16, 10, 10}, {4}, {4}, {4}} -}; +std::vector> staticInputShapes4D1 = {{{8, 16, 10, 10}, {4}, {4}, {4}}}; std::vector> dynamicInputShapes4D1 = { - { - {{-1, -1, -1, -1}, {{8, 8, 6, 7}, {4, 10, 5, 5}, {12, 9, 7, 5}}}, - {{4}, {{4}, {4}, {4}}}, - {{4}, {{4}, {4}, {4}}}, - {{4}, {{4}, {4}, {4}}} - }, - { - {{{4, 12}, {8, 16}, 6, -1}, {{8, 8, 6, 7}, {4, 10, 6, 5}, {12, 9, 6, 5}}}, - {{4}, {{4}, {4}, {4}}}, - {{4}, {{4}, {4}, {4}}}, - {{4}, {{4}, {4}, {4}}} - } -}; + {{{-1, -1, -1, -1}, {{8, 8, 6, 7}, {4, 10, 5, 5}, {12, 9, 7, 5}}}, + {{4}, {{4}, {4}, {4}}}, + {{4}, {{4}, {4}, {4}}}, + {{4}, {{4}, {4}, {4}}}}, + {{{{4, 12}, {8, 16}, 6, -1}, {{8, 8, 6, 7}, {4, 10, 6, 5}, {12, 9, 6, 5}}}, + {{4}, {{4}, {4}, {4}}}, + {{4}, {{4}, {4}, {4}}}, + {{4}, {{4}, {4}, {4}}}}}; std::vector> dynamicInputShapes4D1Blocked = { - { - {{-1, 16, -1, -1}, {{4, 16, 5, 8}, {8, 16, 7, 6}, {12, 16, 4, 5}}}, - {{4}, {{4}, {4}, {4}}}, - {{4}, {{4}, {4}, {4}}}, - {{4}, {{4}, {4}, {4}}} - } -}; + {{{-1, 16, -1, -1}, {{4, 16, 5, 8}, {8, 16, 7, 6}, {12, 16, 4, 5}}}, + {{4}, {{4}, {4}, {4}}}, + {{4}, {{4}, {4}, {4}}}, + {{4}, {{4}, {4}, {4}}}}}; -const std::vector> blockShape4D2 = {{1, 2, 3, 4}, {1, 3, 4, 2}}; -const std::vector> cropsBegin4D2 = {{0, 0, 0, 1}, {0, 0, 1, 2}}; -const std::vector> cropsEnd4D2 = {{0, 0, 1, 0}, {0, 0, 3, 1}}; +const std::vector> blockShape4D2 = {{1, 2, 3, 4}, {1, 3, 4, 2}}; +const std::vector> cropsBegin4D2 = {{0, 0, 0, 1}, {0, 0, 1, 2}}; +const std::vector> cropsEnd4D2 = {{0, 0, 1, 0}, {0, 0, 3, 1}}; -std::vector> staticInputShapes4D2 = { - {{24, 16, 7, 8}, {4}, {4}, {4}} -}; +std::vector> staticInputShapes4D2 = {{{24, 16, 7, 8}, {4}, {4}, {4}}}; std::vector> dynamicInputShapes4D2 = { - { - {{-1, -1, -1, -1}, {{48, 4, 7, 8}, {24, 8, 6, 7}, {24, 16, 5, 5}}}, - {{4}, {{4}, {4}, {4}}}, - {{4}, {{4}, {4}, {4}}}, - {{4}, {{4}, {4}, {4}}} - }, - { - {{24, {4, 10}, -1, -1}, {{24, 8, 6, 7}, {24, 6, 7, 5}, {24, 4, 5, 5}}}, - {{4}, {{4}, {4}, {4}}}, - {{4}, {{4}, {4}, {4}}}, - {{4}, {{4}, {4}, {4}}} - } -}; + {{{-1, -1, -1, -1}, {{48, 4, 7, 8}, {24, 8, 6, 7}, {24, 16, 5, 5}}}, + {{4}, {{4}, {4}, {4}}}, + {{4}, {{4}, {4}, {4}}}, + {{4}, {{4}, {4}, {4}}}}, + {{{24, {4, 10}, -1, -1}, {{24, 8, 6, 7}, {24, 6, 7, 5}, {24, 4, 5, 5}}}, + {{4}, {{4}, {4}, {4}}}, + {{4}, {{4}, {4}, {4}}}, + {{4}, {{4}, {4}, {4}}}}}; std::vector> dynamicInputShapes4D2Blocked = { - { - {{-1, 16, -1, -1}, {{24, 16, 5, 5}, {24, 16, 6, 7}, {48, 16, 4, 4}}}, - {{4}, {{4}, {4}, {4}}}, - {{4}, {{4}, {4}, {4}}}, - {{4}, {{4}, {4}, {4}}} - } -}; - -const std::vector cpuParamsWithBlock_4D = { - CPUSpecificParams({nChw16c}, {nChw16c}, {}, {}), - CPUSpecificParams({nChw8c}, {nChw8c}, {}, {}), - CPUSpecificParams({nhwc}, {nhwc}, {}, {}), - CPUSpecificParams({nchw}, {nchw}, {}, {}) -}; - -const std::vector cpuParams_4D = { - CPUSpecificParams({nhwc}, {nhwc}, {}, {}), - CPUSpecificParams({nchw}, {nchw}, {}, {}) -}; - -const auto staticBatchToSpaceParamsSet4D1 = ::testing::Combine( - ::testing::ValuesIn(static_shapes_to_test_representation(staticInputShapes4D1)), - ::testing::ValuesIn(blockShape4D1), - ::testing::ValuesIn(cropsBegin4D1), - ::testing::ValuesIn(cropsEnd4D1), - ::testing::ValuesIn(model_types), - ::testing::ValuesIn(cpuParamsWithBlock_4D)); - -const auto dynamicBatchToSpaceParamsSet4D1 = ::testing::Combine( - ::testing::ValuesIn(dynamicInputShapes4D1), - ::testing::ValuesIn(blockShape4D1), - ::testing::ValuesIn(cropsBegin4D1), - ::testing::ValuesIn(cropsEnd4D1), - ::testing::ValuesIn(model_types), - ::testing::ValuesIn(cpuParams_4D)); - -const auto dynamicBatchToSpaceParamsWithBlockedSet4D1 = ::testing::Combine( - ::testing::ValuesIn(dynamicInputShapes4D1Blocked), - ::testing::ValuesIn(blockShape4D1), - ::testing::ValuesIn(cropsBegin4D1), - ::testing::ValuesIn(cropsEnd4D1), - ::testing::ValuesIn(model_types), - ::testing::ValuesIn(cpuParamsWithBlock_4D)); - -const auto staticBatchToSpaceParamsSet4D2 = ::testing::Combine( - ::testing::ValuesIn(static_shapes_to_test_representation(staticInputShapes4D2)), - ::testing::ValuesIn(blockShape4D2), - ::testing::ValuesIn(cropsBegin4D2), - ::testing::ValuesIn(cropsEnd4D2), - ::testing::ValuesIn(model_types), - ::testing::ValuesIn(cpuParamsWithBlock_4D)); - -const auto dynamicBatchToSpaceParamsSet4D2 = ::testing::Combine( - ::testing::ValuesIn(dynamicInputShapes4D2), - ::testing::ValuesIn(blockShape4D2), - ::testing::ValuesIn(cropsBegin4D2), - ::testing::ValuesIn(cropsEnd4D2), - ::testing::ValuesIn(model_types), - ::testing::ValuesIn(cpuParams_4D)); - -const auto dynamicBatchToSpaceParamsWithBlockedSet4D2 = ::testing::Combine( - ::testing::ValuesIn(dynamicInputShapes4D2Blocked), - ::testing::ValuesIn(blockShape4D2), - ::testing::ValuesIn(cropsBegin4D2), - ::testing::ValuesIn(cropsEnd4D2), - ::testing::ValuesIn(model_types), - ::testing::ValuesIn(cpuParamsWithBlock_4D)); - -INSTANTIATE_TEST_SUITE_P(smoke_StaticBatchToSpaceCPULayerTestCase1_4D, BatchToSpaceCPULayerTest, - staticBatchToSpaceParamsSet4D1, BatchToSpaceCPULayerTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_DynamicBatchToSpaceCPULayerTestCase1_4D, BatchToSpaceCPULayerTest, - dynamicBatchToSpaceParamsSet4D1, BatchToSpaceCPULayerTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_DynamicBatchToSpaceCPULayerTestCaseWithBlocked1_4D, BatchToSpaceCPULayerTest, - dynamicBatchToSpaceParamsWithBlockedSet4D1, BatchToSpaceCPULayerTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_StaticBatchToSpaceCPULayerTestCase2_4D, BatchToSpaceCPULayerTest, - staticBatchToSpaceParamsSet4D2, BatchToSpaceCPULayerTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_DynamicBatchToSpaceCPULayerTestCase2_4D, BatchToSpaceCPULayerTest, - dynamicBatchToSpaceParamsSet4D2, BatchToSpaceCPULayerTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_DynamicBatchToSpaceCPULayerTestCaseWithBlocked2_4D, BatchToSpaceCPULayerTest, - dynamicBatchToSpaceParamsWithBlockedSet4D2, BatchToSpaceCPULayerTest::getTestCaseName); - -const std::vector> blockShape5D1 = {{1, 1, 2, 2, 1}, {1, 2, 1, 2, 2}}; -const std::vector> cropsBegin5D1 = {{0, 0, 0, 0, 0}, {0, 0, 0, 3, 3}}; -const std::vector> cropsEnd5D1 = {{0, 0, 0, 0, 0}, {0, 0, 1, 0, 1}}; - -std::vector> staticInputShapes5D1 = { - {{8, 16, 4, 10, 10}, {5}, {5}, {5}} -}; - + {{{-1, 16, -1, -1}, {{24, 16, 5, 5}, {24, 16, 6, 7}, {48, 16, 4, 4}}}, + {{4}, {{4}, {4}, {4}}}, + {{4}, {{4}, {4}, {4}}}, + {{4}, {{4}, {4}, {4}}}}}; + +const std::vector cpuParamsWithBlock_4D = {CPUSpecificParams({nChw16c}, {nChw16c}, {}, {}), + CPUSpecificParams({nChw8c}, {nChw8c}, {}, {}), + CPUSpecificParams({nhwc}, {nhwc}, {}, {}), + CPUSpecificParams({nchw}, {nchw}, {}, {})}; + +const std::vector cpuParams_4D = {CPUSpecificParams({nhwc}, {nhwc}, {}, {}), + CPUSpecificParams({nchw}, {nchw}, {}, {})}; + +const auto staticBatchToSpaceParamsSet4D1 = + ::testing::Combine(::testing::ValuesIn(static_shapes_to_test_representation(staticInputShapes4D1)), + ::testing::ValuesIn(blockShape4D1), + ::testing::ValuesIn(cropsBegin4D1), + ::testing::ValuesIn(cropsEnd4D1), + ::testing::ValuesIn(model_types), + ::testing::ValuesIn(cpuParamsWithBlock_4D)); + +const auto dynamicBatchToSpaceParamsSet4D1 = ::testing::Combine(::testing::ValuesIn(dynamicInputShapes4D1), + ::testing::ValuesIn(blockShape4D1), + ::testing::ValuesIn(cropsBegin4D1), + ::testing::ValuesIn(cropsEnd4D1), + ::testing::ValuesIn(model_types), + ::testing::ValuesIn(cpuParams_4D)); + +const auto dynamicBatchToSpaceParamsWithBlockedSet4D1 = + ::testing::Combine(::testing::ValuesIn(dynamicInputShapes4D1Blocked), + ::testing::ValuesIn(blockShape4D1), + ::testing::ValuesIn(cropsBegin4D1), + ::testing::ValuesIn(cropsEnd4D1), + ::testing::ValuesIn(model_types), + ::testing::ValuesIn(cpuParamsWithBlock_4D)); + +const auto staticBatchToSpaceParamsSet4D2 = + ::testing::Combine(::testing::ValuesIn(static_shapes_to_test_representation(staticInputShapes4D2)), + ::testing::ValuesIn(blockShape4D2), + ::testing::ValuesIn(cropsBegin4D2), + ::testing::ValuesIn(cropsEnd4D2), + ::testing::ValuesIn(model_types), + ::testing::ValuesIn(cpuParamsWithBlock_4D)); + +const auto dynamicBatchToSpaceParamsSet4D2 = ::testing::Combine(::testing::ValuesIn(dynamicInputShapes4D2), + ::testing::ValuesIn(blockShape4D2), + ::testing::ValuesIn(cropsBegin4D2), + ::testing::ValuesIn(cropsEnd4D2), + ::testing::ValuesIn(model_types), + ::testing::ValuesIn(cpuParams_4D)); + +const auto dynamicBatchToSpaceParamsWithBlockedSet4D2 = + ::testing::Combine(::testing::ValuesIn(dynamicInputShapes4D2Blocked), + ::testing::ValuesIn(blockShape4D2), + ::testing::ValuesIn(cropsBegin4D2), + ::testing::ValuesIn(cropsEnd4D2), + ::testing::ValuesIn(model_types), + ::testing::ValuesIn(cpuParamsWithBlock_4D)); + +INSTANTIATE_TEST_SUITE_P(smoke_StaticBatchToSpaceCPULayerTestCase1_4D, + BatchToSpaceCPULayerTest, + staticBatchToSpaceParamsSet4D1, + BatchToSpaceCPULayerTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_DynamicBatchToSpaceCPULayerTestCase1_4D, + BatchToSpaceCPULayerTest, + dynamicBatchToSpaceParamsSet4D1, + BatchToSpaceCPULayerTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_DynamicBatchToSpaceCPULayerTestCaseWithBlocked1_4D, + BatchToSpaceCPULayerTest, + dynamicBatchToSpaceParamsWithBlockedSet4D1, + BatchToSpaceCPULayerTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_StaticBatchToSpaceCPULayerTestCase2_4D, + BatchToSpaceCPULayerTest, + staticBatchToSpaceParamsSet4D2, + BatchToSpaceCPULayerTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_DynamicBatchToSpaceCPULayerTestCase2_4D, + BatchToSpaceCPULayerTest, + dynamicBatchToSpaceParamsSet4D2, + BatchToSpaceCPULayerTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_DynamicBatchToSpaceCPULayerTestCaseWithBlocked2_4D, + BatchToSpaceCPULayerTest, + dynamicBatchToSpaceParamsWithBlockedSet4D2, + BatchToSpaceCPULayerTest::getTestCaseName); + +const std::vector> blockShape5D1 = {{1, 1, 2, 2, 1}, {1, 2, 1, 2, 2}}; +const std::vector> cropsBegin5D1 = {{0, 0, 0, 0, 0}, {0, 0, 0, 3, 3}}; +const std::vector> cropsEnd5D1 = {{0, 0, 0, 0, 0}, {0, 0, 1, 0, 1}}; + +std::vector> staticInputShapes5D1 = {{{8, 16, 4, 10, 10}, {5}, {5}, {5}}}; std::vector> dynamicInputShapes5D1 = { - { - {{-1, -1, -1, -1, -1}, {{8, 16, 4, 10, 10}, {16, 10, 5, 11, 9}, {24, 6, 6, 8, 8}}}, - {{5}, {{5}, {5}, {5}}}, - {{5}, {{5}, {5}, {5}}}, - {{5}, {{5}, {5}, {5}}} - }, - { - {{{8, 16}, {8, 16}, {2, 7}, -1, -1}, {{8, 16, 2, 6, 8}, {8, 10, 4, 7, 5}, {16, 8, 7, 5, 10}}}, - {{5}, {{5}, {5}, {5}}}, - {{5}, {{5}, {5}, {5}}}, - {{5}, {{5}, {5}, {5}}} - } -}; + {{{-1, -1, -1, -1, -1}, {{8, 16, 4, 10, 10}, {16, 10, 5, 11, 9}, {24, 6, 6, 8, 8}}}, + {{5}, {{5}, {5}, {5}}}, + {{5}, {{5}, {5}, {5}}}, + {{5}, {{5}, {5}, {5}}}}, + {{{{8, 16}, {8, 16}, {2, 7}, -1, -1}, {{8, 16, 2, 6, 8}, {8, 10, 4, 7, 5}, {16, 8, 7, 5, 10}}}, + {{5}, {{5}, {5}, {5}}}, + {{5}, {{5}, {5}, {5}}}, + {{5}, {{5}, {5}, {5}}}}}; std::vector> dynamicInputShapes5D1Blocked = { - { - {{-1, 16, -1, -1, -1}, {{24, 16, 3, 6, 7}, {48, 16, 4, 5, 5}, {24, 16, 5, 8, 5}}}, - {{5}, {{5}, {5}, {5}}}, - {{5}, {{5}, {5}, {5}}}, - {{5}, {{5}, {5}, {5}}} - } -}; + {{{-1, 16, -1, -1, -1}, {{24, 16, 3, 6, 7}, {48, 16, 4, 5, 5}, {24, 16, 5, 8, 5}}}, + {{5}, {{5}, {5}, {5}}}, + {{5}, {{5}, {5}, {5}}}, + {{5}, {{5}, {5}, {5}}}}}; -const std::vector> blockShape5D2 = {{1, 2, 4, 3, 1}, {1, 1, 2, 4, 3}}; -const std::vector> cropsBegin5D2 = {{0, 0, 1, 2, 0}, {0, 0, 1, 0, 1}}; -const std::vector> cropsEnd5D2 = {{0, 0, 1, 0, 1}, {0, 0, 1, 1, 1}}; +const std::vector> blockShape5D2 = {{1, 2, 4, 3, 1}, {1, 1, 2, 4, 3}}; +const std::vector> cropsBegin5D2 = {{0, 0, 1, 2, 0}, {0, 0, 1, 0, 1}}; +const std::vector> cropsEnd5D2 = {{0, 0, 1, 0, 1}, {0, 0, 1, 1, 1}}; -std::vector> staticInputShapes5D2 = { - {{48, 16, 3, 3, 3}, {5}, {5}, {5}} -}; +std::vector> staticInputShapes5D2 = {{{48, 16, 3, 3, 3}, {5}, {5}, {5}}}; std::vector> dynamicInputShapes5D2 = { - { - {{-1, -1, -1, -1, -1}, {{48, 4, 3, 3, 3}, {24, 16, 5, 3, 5}, {24, 8, 7, 5, 5}}}, - {{5}, {{5}, {5}, {5}}}, - {{5}, {{5}, {5}, {5}}}, - {{5}, {{5}, {5}, {5}}} - }, - { - {{24, {8, 16}, {3, 5}, -1, -1}, {{24, 16, 3, 4, 3}, {24, 12, 5, 3, 5}, {24, 8, 4, 5, 5}}}, - {{5}, {{5}, {5}, {5}}}, - {{5}, {{5}, {5}, {5}}}, - {{5}, {{5}, {5}, {5}}} - }, - { - // special case - {{{1, 24}, {1, 16}, {1, 10}, {1, 10}, {1, 10}}, - { - {24, 16, 5, 3, 5}, - {24, 16, 5, 3, 5}, - {24, 16, 7, 5, 5} - }}, - {{5}, {{5}, {5}, {5}}}, - {{5}, {{5}, {5}, {5}}}, - {{5}, {{5}, {5}, {5}}} - } -}; + {{{-1, -1, -1, -1, -1}, {{48, 4, 3, 3, 3}, {24, 16, 5, 3, 5}, {24, 8, 7, 5, 5}}}, + {{5}, {{5}, {5}, {5}}}, + {{5}, {{5}, {5}, {5}}}, + {{5}, {{5}, {5}, {5}}}}, + {{{24, {8, 16}, {3, 5}, -1, -1}, {{24, 16, 3, 4, 3}, {24, 12, 5, 3, 5}, {24, 8, 4, 5, 5}}}, + {{5}, {{5}, {5}, {5}}}, + {{5}, {{5}, {5}, {5}}}, + {{5}, {{5}, {5}, {5}}}}, + {// special case + {{{1, 24}, {1, 16}, {1, 10}, {1, 10}, {1, 10}}, {{24, 16, 5, 3, 5}, {24, 16, 5, 3, 5}, {24, 16, 7, 5, 5}}}, + {{5}, {{5}, {5}, {5}}}, + {{5}, {{5}, {5}, {5}}}, + {{5}, {{5}, {5}, {5}}}}}; std::vector> dynamicInputShapes5D2Blocked = { - { - {{-1, 16, -1, -1, -1}, {{24, 16, 4, 5, 5}, {48, 16, 3, 4, 3}, {24, 16, 5, 3, 5}}}, - {{5}, {{5}, {5}, {5}}}, - {{5}, {{5}, {5}, {5}}}, - {{5}, {{5}, {5}, {5}}} - } -}; - -const std::vector cpuParamsWithBlock_5D = { - CPUSpecificParams({nCdhw16c}, {nCdhw16c}, {}, {}), - CPUSpecificParams({nCdhw8c}, {nCdhw8c}, {}, {}), - CPUSpecificParams({ndhwc}, {ndhwc}, {}, {}), - CPUSpecificParams({ncdhw}, {ncdhw}, {}, {}) -}; - -const std::vector cpuParams_5D = { - CPUSpecificParams({ndhwc}, {ndhwc}, {}, {}), - CPUSpecificParams({ncdhw}, {ncdhw}, {}, {}) -}; - -const auto staticBatchToSpaceParamsSet5D1 = ::testing::Combine( - ::testing::ValuesIn(static_shapes_to_test_representation(staticInputShapes5D1)), - ::testing::ValuesIn(blockShape5D1), - ::testing::ValuesIn(cropsBegin5D1), - ::testing::ValuesIn(cropsEnd5D1), - ::testing::ValuesIn(model_types), - ::testing::ValuesIn(cpuParamsWithBlock_5D)); - -const auto dynamicBatchToSpaceParamsSet5D1 = ::testing::Combine( - ::testing::ValuesIn(dynamicInputShapes5D1), - ::testing::ValuesIn(blockShape5D1), - ::testing::ValuesIn(cropsBegin5D1), - ::testing::ValuesIn(cropsEnd5D1), - ::testing::ValuesIn(model_types), - ::testing::ValuesIn(cpuParams_5D)); - -const auto dynamicBatchToSpaceParamsWithBlockedSet5D1 = ::testing::Combine( - ::testing::ValuesIn(dynamicInputShapes5D1Blocked), - ::testing::ValuesIn(blockShape5D1), - ::testing::ValuesIn(cropsBegin5D1), - ::testing::ValuesIn(cropsEnd5D1), - ::testing::ValuesIn(model_types), - ::testing::ValuesIn(cpuParamsWithBlock_5D)); - -const auto staticBatchToSpaceParamsSet5D2 = ::testing::Combine( - ::testing::ValuesIn(static_shapes_to_test_representation(staticInputShapes5D2)), - ::testing::ValuesIn(blockShape5D2), - ::testing::ValuesIn(cropsBegin5D2), - ::testing::ValuesIn(cropsEnd5D2), - ::testing::ValuesIn(model_types), - ::testing::ValuesIn(cpuParamsWithBlock_5D)); - -const auto dynamicBatchToSpaceParamsSet5D2 = ::testing::Combine( - ::testing::ValuesIn(dynamicInputShapes5D2), - ::testing::ValuesIn(blockShape5D2), - ::testing::ValuesIn(cropsBegin5D2), - ::testing::ValuesIn(cropsEnd5D2), - ::testing::ValuesIn(model_types), - ::testing::ValuesIn(cpuParams_5D)); - -const auto dynamicBatchToSpaceParamsWithBlockedSet5D2 = ::testing::Combine( - ::testing::ValuesIn(dynamicInputShapes5D2Blocked), - ::testing::ValuesIn(blockShape5D2), - ::testing::ValuesIn(cropsBegin5D2), - ::testing::ValuesIn(cropsEnd5D2), - ::testing::ValuesIn(model_types), - ::testing::ValuesIn(cpuParamsWithBlock_5D)); - -INSTANTIATE_TEST_SUITE_P(smoke_StaticBatchToSpaceCPULayerTestCase1_5D, BatchToSpaceCPULayerTest, - staticBatchToSpaceParamsSet5D1, BatchToSpaceCPULayerTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_DynamicBatchToSpaceCPULayerTestCase1_5D, BatchToSpaceCPULayerTest, - dynamicBatchToSpaceParamsSet5D1, BatchToSpaceCPULayerTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_DynamicBatchToSpaceCPULayerTestCaseWithBlocked1_5D, BatchToSpaceCPULayerTest, - dynamicBatchToSpaceParamsWithBlockedSet5D1, BatchToSpaceCPULayerTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_StaticBatchToSpaceCPULayerTestCase2_5D, BatchToSpaceCPULayerTest, - staticBatchToSpaceParamsSet5D2, BatchToSpaceCPULayerTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_DynamicBatchToSpaceCPULayerTestCase2_5D, BatchToSpaceCPULayerTest, - dynamicBatchToSpaceParamsSet5D2, BatchToSpaceCPULayerTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_DynamicBatchToSpaceCPULayerTestCaseWithBlocked2_5D, BatchToSpaceCPULayerTest, - dynamicBatchToSpaceParamsWithBlockedSet5D2, BatchToSpaceCPULayerTest::getTestCaseName); + {{{-1, 16, -1, -1, -1}, {{24, 16, 4, 5, 5}, {48, 16, 3, 4, 3}, {24, 16, 5, 3, 5}}}, + {{5}, {{5}, {5}, {5}}}, + {{5}, {{5}, {5}, {5}}}, + {{5}, {{5}, {5}, {5}}}}}; + +const std::vector cpuParamsWithBlock_5D = {CPUSpecificParams({nCdhw16c}, {nCdhw16c}, {}, {}), + CPUSpecificParams({nCdhw8c}, {nCdhw8c}, {}, {}), + CPUSpecificParams({ndhwc}, {ndhwc}, {}, {}), + CPUSpecificParams({ncdhw}, {ncdhw}, {}, {})}; + +const std::vector cpuParams_5D = {CPUSpecificParams({ndhwc}, {ndhwc}, {}, {}), + CPUSpecificParams({ncdhw}, {ncdhw}, {}, {})}; + +const auto staticBatchToSpaceParamsSet5D1 = + ::testing::Combine(::testing::ValuesIn(static_shapes_to_test_representation(staticInputShapes5D1)), + ::testing::ValuesIn(blockShape5D1), + ::testing::ValuesIn(cropsBegin5D1), + ::testing::ValuesIn(cropsEnd5D1), + ::testing::ValuesIn(model_types), + ::testing::ValuesIn(cpuParamsWithBlock_5D)); + +const auto dynamicBatchToSpaceParamsSet5D1 = ::testing::Combine(::testing::ValuesIn(dynamicInputShapes5D1), + ::testing::ValuesIn(blockShape5D1), + ::testing::ValuesIn(cropsBegin5D1), + ::testing::ValuesIn(cropsEnd5D1), + ::testing::ValuesIn(model_types), + ::testing::ValuesIn(cpuParams_5D)); + +const auto dynamicBatchToSpaceParamsWithBlockedSet5D1 = + ::testing::Combine(::testing::ValuesIn(dynamicInputShapes5D1Blocked), + ::testing::ValuesIn(blockShape5D1), + ::testing::ValuesIn(cropsBegin5D1), + ::testing::ValuesIn(cropsEnd5D1), + ::testing::ValuesIn(model_types), + ::testing::ValuesIn(cpuParamsWithBlock_5D)); + +const auto staticBatchToSpaceParamsSet5D2 = + ::testing::Combine(::testing::ValuesIn(static_shapes_to_test_representation(staticInputShapes5D2)), + ::testing::ValuesIn(blockShape5D2), + ::testing::ValuesIn(cropsBegin5D2), + ::testing::ValuesIn(cropsEnd5D2), + ::testing::ValuesIn(model_types), + ::testing::ValuesIn(cpuParamsWithBlock_5D)); + +const auto dynamicBatchToSpaceParamsSet5D2 = ::testing::Combine(::testing::ValuesIn(dynamicInputShapes5D2), + ::testing::ValuesIn(blockShape5D2), + ::testing::ValuesIn(cropsBegin5D2), + ::testing::ValuesIn(cropsEnd5D2), + ::testing::ValuesIn(model_types), + ::testing::ValuesIn(cpuParams_5D)); + +const auto dynamicBatchToSpaceParamsWithBlockedSet5D2 = + ::testing::Combine(::testing::ValuesIn(dynamicInputShapes5D2Blocked), + ::testing::ValuesIn(blockShape5D2), + ::testing::ValuesIn(cropsBegin5D2), + ::testing::ValuesIn(cropsEnd5D2), + ::testing::ValuesIn(model_types), + ::testing::ValuesIn(cpuParamsWithBlock_5D)); + +INSTANTIATE_TEST_SUITE_P(smoke_StaticBatchToSpaceCPULayerTestCase1_5D, + BatchToSpaceCPULayerTest, + staticBatchToSpaceParamsSet5D1, + BatchToSpaceCPULayerTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_DynamicBatchToSpaceCPULayerTestCase1_5D, + BatchToSpaceCPULayerTest, + dynamicBatchToSpaceParamsSet5D1, + BatchToSpaceCPULayerTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_DynamicBatchToSpaceCPULayerTestCaseWithBlocked1_5D, + BatchToSpaceCPULayerTest, + dynamicBatchToSpaceParamsWithBlockedSet5D1, + BatchToSpaceCPULayerTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_StaticBatchToSpaceCPULayerTestCase2_5D, + BatchToSpaceCPULayerTest, + staticBatchToSpaceParamsSet5D2, + BatchToSpaceCPULayerTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_DynamicBatchToSpaceCPULayerTestCase2_5D, + BatchToSpaceCPULayerTest, + dynamicBatchToSpaceParamsSet5D2, + BatchToSpaceCPULayerTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_DynamicBatchToSpaceCPULayerTestCaseWithBlocked2_5D, + BatchToSpaceCPULayerTest, + dynamicBatchToSpaceParamsWithBlockedSet5D2, + BatchToSpaceCPULayerTest::getTestCaseName); } // namespace -} // namespace CPULayerTestsDefinitions +} // namespace test +} // namespace ov diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/broadcast.cpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/broadcast.cpp index cd5f2bae07f85f..62df3e54608a48 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/broadcast.cpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/broadcast.cpp @@ -2,30 +2,30 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "test_utils/cpu_test_utils.hpp" +#include + #include "ov_models/builders.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include +#include "test_utils/cpu_test_utils.hpp" using namespace CPUTestUtils; -namespace CPULayerTestsDefinitions { +namespace ov { +namespace test { -using BroadcastLayerTestParamsSet = typename std::tuple< - std::vector, // Shapes - std::vector, // Target shapes - std::vector, // Axes mapping - ov::op::BroadcastType, // Broadcast mode - ov::element::Type_t, // Network precision - std::vector, // Const inputs - std::string>; // Device name +using BroadcastLayerTestParamsSet = typename std::tuple, // Shapes + std::vector, // Target shapes + std::vector, // Axes mapping + ov::op::BroadcastType, // Broadcast mode + ov::element::Type_t, // Network precision + std::vector, // Const inputs + std::string>; // Device name -using BroadcastLayerCPUTestParamsSet = typename std::tuple< - BroadcastLayerTestParamsSet, - CPUSpecificParams>; +using BroadcastLayerCPUTestParamsSet = typename std::tuple; class BroadcastLayerCPUTest : public testing::WithParamInterface, - virtual public ov::test::SubgraphBaseTest, public CPUTestsBase { + virtual public ov::test::SubgraphBaseTest, + public CPUTestsBase { public: static std::string getTestCaseName(testing::TestParamInfo obj) { BroadcastLayerTestParamsSet basicParamsSet; @@ -38,7 +38,8 @@ class BroadcastLayerCPUTest : public testing::WithParamInterface isConstInputs; std::string deviceName; - std::tie(inputShapes, targetShapes, axesMapping, mode, netPrecision, isConstInputs, deviceName) = basicParamsSet; + std::tie(inputShapes, targetShapes, axesMapping, mode, netPrecision, isConstInputs, deviceName) = + basicParamsSet; std::ostringstream result; result << "IS=("; @@ -51,11 +52,12 @@ class BroadcastLayerCPUTest : public testing::WithParamInterface(targetShape.size()) }); + inputDynamicShapes.push_back({static_cast(targetShape.size())}); } if (!isAxesMapConst) { - inputDynamicShapes.push_back({ static_cast(axesMapping.size()) }); + inputDynamicShapes.push_back({static_cast(axesMapping.size())}); } } const size_t targetStaticShapeSize = inputShapes.front().second.size(); @@ -96,22 +99,25 @@ class BroadcastLayerCPUTest : public testing::WithParamInterface(netPrecision, targetStaticShapes.front().front())); + functionParams.push_back( + std::make_shared(netPrecision, targetStaticShapes.front().front())); } else { functionParams.push_back(std::make_shared(netPrecision, inputDynamicShapes.front())); if (!isTargetShapeConst) { - functionParams.push_back(std::make_shared(ov::element::i64, inputDynamicShapes[1])); + functionParams.push_back( + std::make_shared(ov::element::i64, inputDynamicShapes[1])); functionParams.back()->set_friendly_name("targetShape"); } if (!isAxesMapConst) { - functionParams.push_back(std::make_shared(ov::element::i64, inputDynamicShapes.back())); + functionParams.push_back( + std::make_shared(ov::element::i64, inputDynamicShapes.back())); functionParams.back()->set_friendly_name("axesMapping"); } } @@ -131,27 +137,21 @@ class BroadcastLayerCPUTest : public testing::WithParamInterface 2 ? functionParams[2] : functionParams[1]; } - broadcastOp = std::make_shared(functionParams[0], - targetShapeOp, - axesMappingOp, - mode); + broadcastOp = + std::make_shared(functionParams[0], targetShapeOp, axesMappingOp, mode); } else if (mode == ov::op::BroadcastType::NUMPY) { if (isTargetShapeConst) { auto targetShapeConst = ov::op::v0::Constant::create(ov::element::i64, {targetShapeRank}, targetShape); - broadcastOp = std::make_shared(functionParams[0], - targetShapeConst, - mode); + broadcastOp = std::make_shared(functionParams[0], targetShapeConst, mode); } else { - broadcastOp = std::make_shared(functionParams[0], - functionParams[1], - mode); + broadcastOp = std::make_shared(functionParams[0], functionParams[1], mode); } } function = makeNgraphFunction(netPrecision, functionParams, broadcastOp, "Broadcast"); } - void generate_inputs(const std::vector& targetInputStaticShapes) override { + void generate_inputs(const std::vector& targetInputStaticShapes) override { inputs.clear(); const auto& funcInputs = function->inputs(); for (size_t i = 0lu; i < funcInputs.size(); i++) { @@ -171,10 +171,14 @@ class BroadcastLayerCPUTest : public testing::WithParamInterface inputPrecisions = { - ov::element::f32, - ov::element::bf16, - ov::element::i32, - ov::element::i8 -}; +const std::vector inputPrecisions = {ov::element::f32, + ov::element::bf16, + ov::element::i32, + ov::element::i8}; /* ============= */ /* INSTANCES */ // 4D -const std::vector CPUParams4D = { - cpuParams_nChw16c, - cpuParams_nChw8c, - cpuParams_nhwc -}; - -const std::vector> staticInputShapes4D = { - { - {{}, - { // Static shapes - {1, 16, 1, 1} - } - } - }, - { - {{}, - { // Static shapes - {50, 50} - } - } - } -}; - -INSTANTIATE_TEST_CASE_P(smoke_StaticShape4D, BroadcastLayerCPUTest, - ::testing::Combine( - ::testing::Combine( - ::testing::Values(staticInputShapes4D[0]), - ::testing::ValuesIn(std::vector>{{1, 16, 3, 3}, {1, 16, 1, 3}}), - ::testing::Values(std::vector{}), - ::testing::Values(ov::op::BroadcastType::NUMPY), - ::testing::ValuesIn(inputPrecisions), - ::testing::Values(std::vector{true, true}), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - ::testing::ValuesIn(CPUParams4D)), - BroadcastLayerCPUTest::getTestCaseName); - -INSTANTIATE_TEST_CASE_P(smoke_StaticShape4DE, BroadcastLayerCPUTest, - ::testing::Combine( - ::testing::Combine( - ::testing::Values(staticInputShapes4D[1]), - ::testing::Values(std::vector{1, 50, 50, 16}), - ::testing::Values(std::vector{1, 2}), - ::testing::Values(ov::op::BroadcastType::EXPLICIT), - ::testing::ValuesIn(inputPrecisions), - ::testing::Values(std::vector{true, true}), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - ::testing::Values(CPUSpecificParams{{}, {}, {}, "ref"})), - BroadcastLayerCPUTest::getTestCaseName); - -const std::vector> staticInputShapesScalar = { - { - {{}, - { // Static shapes - {1} - } - } - } -}; - -INSTANTIATE_TEST_CASE_P(smoke_StaticShape4DScalar, BroadcastLayerCPUTest, - ::testing::Combine( - ::testing::Combine( - ::testing::ValuesIn(staticInputShapesScalar), - ::testing::Values(std::vector{1, 16, 3, 3}), - ::testing::Values(std::vector{}), - ::testing::Values(ov::op::BroadcastType::NUMPY), - ::testing::ValuesIn(inputPrecisions), - ::testing::Values(std::vector{true, true}), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - ::testing::Values(CPUSpecificParams{{}, {}, {}, "ref"})), - BroadcastLayerCPUTest::getTestCaseName); +const std::vector CPUParams4D = {cpuParams_nChw16c, cpuParams_nChw8c, cpuParams_nhwc}; + +const std::vector> staticInputShapes4D = {{{{}, + {// Static shapes + {1, 16, 1, 1}}}}, + {{{}, + {// Static shapes + {50, 50}}}}}; + +INSTANTIATE_TEST_CASE_P(smoke_StaticShape4D, + BroadcastLayerCPUTest, + ::testing::Combine(::testing::Combine(::testing::Values(staticInputShapes4D[0]), + ::testing::ValuesIn(std::vector>{ + {1, 16, 3, 3}, + {1, 16, 1, 3}}), + ::testing::Values(std::vector{}), + ::testing::Values(ov::op::BroadcastType::NUMPY), + ::testing::ValuesIn(inputPrecisions), + ::testing::Values(std::vector{true, true}), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::ValuesIn(CPUParams4D)), + BroadcastLayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_CASE_P(smoke_StaticShape4DE, + BroadcastLayerCPUTest, + ::testing::Combine(::testing::Combine(::testing::Values(staticInputShapes4D[1]), + ::testing::Values(std::vector{1, 50, 50, 16}), + ::testing::Values(std::vector{1, 2}), + ::testing::Values(ov::op::BroadcastType::EXPLICIT), + ::testing::ValuesIn(inputPrecisions), + ::testing::Values(std::vector{true, true}), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::Values(CPUSpecificParams{{}, {}, {}, "ref"})), + BroadcastLayerCPUTest::getTestCaseName); + +const std::vector> staticInputShapesScalar = {{{{}, + {// Static shapes + {1}}}}}; + +INSTANTIATE_TEST_CASE_P(smoke_StaticShape4DScalar, + BroadcastLayerCPUTest, + ::testing::Combine(::testing::Combine(::testing::ValuesIn(staticInputShapesScalar), + ::testing::Values(std::vector{1, 16, 3, 3}), + ::testing::Values(std::vector{}), + ::testing::Values(ov::op::BroadcastType::NUMPY), + ::testing::ValuesIn(inputPrecisions), + ::testing::Values(std::vector{true, true}), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::Values(CPUSpecificParams{{}, {}, {}, "ref"})), + BroadcastLayerCPUTest::getTestCaseName); const std::vector> dynamicInputShapes4D = { { - { // Origin dynamic shapes - {ov::Dimension(1, 20), ov::Dimension(1, 20), ov::Dimension(1, 20), ov::Dimension(1, 20)}, - { // Dynamic shapes instances - {1, 16, 1, 1}, - {8, 1, 1, 7}, - {1, 1, 1, 7} - } - }, + {// Origin dynamic shapes + {ov::Dimension(1, 20), ov::Dimension(1, 20), ov::Dimension(1, 20), ov::Dimension(1, 20)}, + {// Dynamic shapes instances + {1, 16, 1, 1}, + {8, 1, 1, 7}, + {1, 1, 1, 7}}}, }, - { - { // Origin dynamic shapes - {-1, -1, -1, -1}, - { // Dynamic shapes instances - {{1, 16, 1, 1}}, - {{8, 1, 1, 1}} - } - } - } -}; - -INSTANTIATE_TEST_CASE_P(smoke_DynamicShape4D, BroadcastLayerCPUTest, - ::testing::Combine(::testing::Combine( - ::testing::ValuesIn(dynamicInputShapes4D), - ::testing::ValuesIn(std::vector>{{8, 16, 1, 7}, {8, 16, 10, 7}}), - ::testing::Values(std::vector{}), - ::testing::Values(ov::op::BroadcastType::NUMPY), - ::testing::ValuesIn(inputPrecisions), - ::testing::ValuesIn(std::vector>{{true, true}, {false, true}}), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - ::testing::Values(CPUSpecificParams{{}, {}, {}, "ref"})), - BroadcastLayerCPUTest::getTestCaseName); - -const std::vector> dynamicInputShapesScalar = { - { - { // Origin dynamic shapes - {-1}, - { // Dynamic shapes instances - {1}, - {7} - } - } - } -}; - -INSTANTIATE_TEST_CASE_P(smoke_DynamicShape4DScalar, BroadcastLayerCPUTest, - ::testing::Combine(::testing::Combine( - ::testing::ValuesIn(dynamicInputShapesScalar), - ::testing::Values(std::vector{8, 16, 1, 7}), - ::testing::Values(std::vector{}), - ::testing::Values(ov::op::BroadcastType::NUMPY), - ::testing::ValuesIn(inputPrecisions), - ::testing::ValuesIn(std::vector>{{true, true}, {false, true}}), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - ::testing::Values(CPUSpecificParams{{}, {}, {}, "ref"})), - BroadcastLayerCPUTest::getTestCaseName); + {{// Origin dynamic shapes + {-1, -1, -1, -1}, + {// Dynamic shapes instances + {{1, 16, 1, 1}}, + {{8, 1, 1, 1}}}}}}; + +INSTANTIATE_TEST_CASE_P( + smoke_DynamicShape4D, + BroadcastLayerCPUTest, + ::testing::Combine( + ::testing::Combine(::testing::ValuesIn(dynamicInputShapes4D), + ::testing::ValuesIn(std::vector>{{8, 16, 1, 7}, {8, 16, 10, 7}}), + ::testing::Values(std::vector{}), + ::testing::Values(ov::op::BroadcastType::NUMPY), + ::testing::ValuesIn(inputPrecisions), + ::testing::ValuesIn(std::vector>{{true, true}, {false, true}}), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::Values(CPUSpecificParams{{}, {}, {}, "ref"})), + BroadcastLayerCPUTest::getTestCaseName); + +const std::vector> dynamicInputShapesScalar = {{{// Origin dynamic shapes + {-1}, + {// Dynamic shapes instances + {1}, + {7}}}}}; + +INSTANTIATE_TEST_CASE_P(smoke_DynamicShape4DScalar, + BroadcastLayerCPUTest, + ::testing::Combine(::testing::Combine(::testing::ValuesIn(dynamicInputShapesScalar), + ::testing::Values(std::vector{8, 16, 1, 7}), + ::testing::Values(std::vector{}), + ::testing::Values(ov::op::BroadcastType::NUMPY), + ::testing::ValuesIn(inputPrecisions), + ::testing::ValuesIn(std::vector>{ + {true, true}, + {false, true}}), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::Values(CPUSpecificParams{{}, {}, {}, "ref"})), + BroadcastLayerCPUTest::getTestCaseName); // 5D -const std::vector> staticInputShapes5D = { - { - {{}, - { // Static shapes - {1, 16, 1, 1, 1} - } - } - } -}; +const std::vector> staticInputShapes5D = {{{{}, + {// Static shapes + {1, 16, 1, 1, 1}}}}}; const std::vector> dynamicInputShapes5D = { - { - { // Origin dynamic shapes - {ov::Dimension(1, 20), ov::Dimension(1, 20), ov::Dimension(1, 20), ov::Dimension(1, 20), ov::Dimension(1, 20)}, - { // Dynamic shapes instances - {1, 16, 1, 1, 1}, - {8, 1, 1, 7, 1}, - {8, 1, 1, 1, 1} - } - } - }, - { - { // Origin dynamic shapes - {-1, -1, -1, -1, -1}, - { // Dynamic shapes instances - {1, 16, 1, 1, 1}, - {8, 16, 1, 7, 1} - } - } - } -}; -std::vector> targetShapes5D { - {8, 16, 1, 7, 1}, - {8, 16, 10, 7, 4} -}; + {{// Origin dynamic shapes + {ov::Dimension(1, 20), ov::Dimension(1, 20), ov::Dimension(1, 20), ov::Dimension(1, 20), ov::Dimension(1, 20)}, + {// Dynamic shapes instances + {1, 16, 1, 1, 1}, + {8, 1, 1, 7, 1}, + {8, 1, 1, 1, 1}}}}, + {{// Origin dynamic shapes + {-1, -1, -1, -1, -1}, + {// Dynamic shapes instances + {1, 16, 1, 1, 1}, + {8, 16, 1, 7, 1}}}}}; +std::vector> targetShapes5D{{8, 16, 1, 7, 1}, {8, 16, 10, 7, 4}}; const std::vector CPUParams5D = { - cpuParams_nCdhw16c, - cpuParams_nCdhw8c, - cpuParams_ndhwc, + cpuParams_nCdhw16c, + cpuParams_nCdhw8c, + cpuParams_ndhwc, }; -INSTANTIATE_TEST_CASE_P(smoke_StaticShape5D, BroadcastLayerCPUTest, - ::testing::Combine( - ::testing::Combine( - ::testing::ValuesIn(staticInputShapes5D), - ::testing::ValuesIn(std::vector>{{1, 16, 1, 1, 3}, {1, 16, 3, 1, 3}}), - ::testing::Values(std::vector{}), - ::testing::Values(ov::op::BroadcastType::NUMPY), - ::testing::ValuesIn(inputPrecisions), - ::testing::Values(std::vector{true, true}), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - ::testing::ValuesIn(CPUParams5D)), - BroadcastLayerCPUTest::getTestCaseName); - -INSTANTIATE_TEST_CASE_P(smoke_StaticShape5DScalar, BroadcastLayerCPUTest, - ::testing::Combine( - ::testing::Combine( - ::testing::ValuesIn(staticInputShapesScalar), - ::testing::Values(std::vector{1, 16, 3, 1, 3}), - ::testing::Values(std::vector{}), - ::testing::Values(ov::op::BroadcastType::NUMPY), - ::testing::ValuesIn(inputPrecisions), - ::testing::Values(std::vector{true, true}), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - ::testing::Values(CPUSpecificParams{{}, {}, {}, "ref"})), - BroadcastLayerCPUTest::getTestCaseName); - -INSTANTIATE_TEST_CASE_P(smoke_DynamicShape5D, BroadcastLayerCPUTest, - ::testing::Combine( - ::testing::Combine( - ::testing::ValuesIn(dynamicInputShapes5D), - ::testing::ValuesIn(targetShapes5D), - ::testing::Values(std::vector{}), - ::testing::Values(ov::op::BroadcastType::NUMPY), - ::testing::ValuesIn(inputPrecisions), - ::testing::ValuesIn(std::vector>{{true, true}, {false, true}}), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - ::testing::Values(CPUSpecificParams{{}, {}, {}, "ref"})), - BroadcastLayerCPUTest::getTestCaseName); - -INSTANTIATE_TEST_CASE_P(smoke_DynamicShape5DScalar, BroadcastLayerCPUTest, - ::testing::Combine( - ::testing::Combine( - ::testing::ValuesIn(dynamicInputShapesScalar), - ::testing::Values(std::vector{8, 16, 1, 1, 7}), - ::testing::Values(std::vector{}), - ::testing::Values(ov::op::BroadcastType::NUMPY), - ::testing::ValuesIn(inputPrecisions), - ::testing::ValuesIn(std::vector>{{true, true}, {false, true}}), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - ::testing::Values(CPUSpecificParams{{}, {}, {}, "ref"})), - BroadcastLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_CASE_P(smoke_StaticShape5D, + BroadcastLayerCPUTest, + ::testing::Combine(::testing::Combine(::testing::ValuesIn(staticInputShapes5D), + ::testing::ValuesIn(std::vector>{ + {1, 16, 1, 1, 3}, + {1, 16, 3, 1, 3}}), + ::testing::Values(std::vector{}), + ::testing::Values(ov::op::BroadcastType::NUMPY), + ::testing::ValuesIn(inputPrecisions), + ::testing::Values(std::vector{true, true}), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::ValuesIn(CPUParams5D)), + BroadcastLayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_CASE_P(smoke_StaticShape5DScalar, + BroadcastLayerCPUTest, + ::testing::Combine(::testing::Combine(::testing::ValuesIn(staticInputShapesScalar), + ::testing::Values(std::vector{1, 16, 3, 1, 3}), + ::testing::Values(std::vector{}), + ::testing::Values(ov::op::BroadcastType::NUMPY), + ::testing::ValuesIn(inputPrecisions), + ::testing::Values(std::vector{true, true}), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::Values(CPUSpecificParams{{}, {}, {}, "ref"})), + BroadcastLayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_CASE_P(smoke_DynamicShape5D, + BroadcastLayerCPUTest, + ::testing::Combine(::testing::Combine(::testing::ValuesIn(dynamicInputShapes5D), + ::testing::ValuesIn(targetShapes5D), + ::testing::Values(std::vector{}), + ::testing::Values(ov::op::BroadcastType::NUMPY), + ::testing::ValuesIn(inputPrecisions), + ::testing::ValuesIn(std::vector>{ + {true, true}, + {false, true}}), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::Values(CPUSpecificParams{{}, {}, {}, "ref"})), + BroadcastLayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_CASE_P(smoke_DynamicShape5DScalar, + BroadcastLayerCPUTest, + ::testing::Combine(::testing::Combine(::testing::ValuesIn(dynamicInputShapesScalar), + ::testing::Values(std::vector{8, 16, 1, 1, 7}), + ::testing::Values(std::vector{}), + ::testing::Values(ov::op::BroadcastType::NUMPY), + ::testing::ValuesIn(inputPrecisions), + ::testing::ValuesIn(std::vector>{ + {true, true}, + {false, true}}), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::Values(CPUSpecificParams{{}, {}, {}, "ref"})), + BroadcastLayerCPUTest::getTestCaseName); // 1D -const std::vector> dynamicShapes1D = { - { - { // Origin dynamic shapes - {-1}, - { // Dynamic shapes instances - {1}, - {1} - } - } - } -}; - -INSTANTIATE_TEST_CASE_P(smoke_DynamicShapes1D, BroadcastLayerCPUTest, - ::testing::Combine(::testing::Combine( - ::testing::ValuesIn(dynamicShapes1D), - ::testing::Values(std::vector{0}), - ::testing::Values(std::vector{}), - ::testing::Values(ov::op::BroadcastType::NUMPY), - ::testing::ValuesIn(inputPrecisions), - ::testing::ValuesIn(std::vector>{{false, true}}), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - ::testing::Values(CPUSpecificParams{{}, {}, {}, "ref"})), - BroadcastLayerCPUTest::getTestCaseName); +const std::vector> dynamicShapes1D = {{{// Origin dynamic shapes + {-1}, + {// Dynamic shapes instances + {1}, + {1}}}}}; + +INSTANTIATE_TEST_CASE_P(smoke_DynamicShapes1D, + BroadcastLayerCPUTest, + ::testing::Combine(::testing::Combine(::testing::ValuesIn(dynamicShapes1D), + ::testing::Values(std::vector{0}), + ::testing::Values(std::vector{}), + ::testing::Values(ov::op::BroadcastType::NUMPY), + ::testing::ValuesIn(inputPrecisions), + ::testing::ValuesIn(std::vector>{ + {false, true}}), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::Values(CPUSpecificParams{{}, {}, {}, "ref"})), + BroadcastLayerCPUTest::getTestCaseName); /* ========= */ -} // namespace +} // namespace -} // namespace CPULayerTestsDefinitions +} // namespace test +} // namespace ov diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/bucketize.cpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/bucketize.cpp index 6c345226e4f69f..2e2cf824bd5745 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/bucketize.cpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/bucketize.cpp @@ -3,16 +3,14 @@ // #include -#include "ov_models/builders.hpp" + #include "shared_test_classes/base/ov_subgraph.hpp" #include "test_utils/cpu_test_utils.hpp" -using namespace InferenceEngine; using namespace CPUTestUtils; -using namespace ngraph::opset3; -using namespace ov::test; -namespace CPULayerTestsDefinitions { +namespace ov { +namespace test { using BucketizeCPUParamsTuple = std::tuple& targetInputStaticShapes) override { + void generate_inputs(const std::vector& targetInputStaticShapes) override { inputs.clear(); const auto& funcInputs = function->inputs(); auto data_size = shape_size(targetInputStaticShapes[0]); ov::Tensor tensorData = ov::test::utils::create_and_fill_tensor(funcInputs[0].get_element_type(), - targetInputStaticShapes[0], - data_size * 5, - 0, - 10, - 7235346); + targetInputStaticShapes[0], + data_size * 5, + 0, + 10, + 7235346); ov::Tensor tensorBucket = ov::test::utils::create_and_fill_tensor_unique_sequence(funcInputs[1].get_element_type(), @@ -91,14 +89,14 @@ class BucketizeLayerCPUTest : public testing::WithParamInterfaceGetParam(); init_input_shapes({dataShape, bucketsShape}); - auto data = std::make_shared(inDataPrc, inputDynamicShapes[0]); + auto data = std::make_shared(inDataPrc, inputDynamicShapes[0]); data->set_friendly_name("a_data"); - auto buckets = std::make_shared(inBucketsPrc, inputDynamicShapes[1]); + auto buckets = std::make_shared(inBucketsPrc, inputDynamicShapes[1]); buckets->set_friendly_name("b_buckets"); - auto bucketize = std::make_shared(data, buckets, netPrc, with_right_bound); - function = std::make_shared(std::make_shared(bucketize), - ngraph::ParameterVector{data, buckets}, - "Bucketize"); + auto bucketize = std::make_shared(data, buckets, netPrc, with_right_bound); + function = std::make_shared(std::make_shared(bucketize), + ov::ParameterVector{data, buckets}, + "Bucketize"); } }; @@ -109,11 +107,11 @@ TEST_P(BucketizeLayerCPUTest, CompareWithRefs) { namespace { const std::vector dataShapesDynamic = { - {{ngraph::Dimension(1, 10), ngraph::Dimension::dynamic(), ngraph::Dimension::dynamic()}, + {{ov::Dimension(1, 10), ov::Dimension::dynamic(), ov::Dimension::dynamic()}, {{1, 20, 20}, {3, 16, 16}, {10, 16, 16}}}, - {{ngraph::Dimension(1, 10), 3, 50, 50}, {{1, 3, 50, 50}, {2, 3, 50, 50}, {10, 3, 50, 50}}}}; + {{ov::Dimension(1, 10), 3, 50, 50}, {{1, 3, 50, 50}, {2, 3, 50, 50}, {10, 3, 50, 50}}}}; -const std::vector bucketsShapesDynamic = {{{ngraph::Dimension::dynamic()}, {{5}, {20}, {100}}}}; +const std::vector bucketsShapesDynamic = {{{ov::Dimension::dynamic()}, {{5}, {20}, {100}}}}; const std::vector inPrc = {ov::element::f32, ov::element::i64, ov::element::i32}; const std::vector outPrc = {ov::element::i64, ov::element::i32}; @@ -142,4 +140,5 @@ INSTANTIATE_TEST_SUITE_P(smoke_TestsBucketize_left_Dynamic, BucketizeLayerCPUTest::getTestCaseName); } // namespace -} // namespace CPULayerTestsDefinitions +} // namespace test +} // namespace ov diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/activation.cpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/activation.cpp index f061a6482ded74..587547fcb73164 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/activation.cpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/activation.cpp @@ -5,24 +5,24 @@ #include "activation.hpp" #include "gtest/gtest.h" #include "test_utils/cpu_test_utils.hpp" +#include "common_test_utils/node_builders/activation.hpp" +#include "shared_test_classes/single_op/activation.hpp" -using namespace InferenceEngine; using namespace CPUTestUtils; -using namespace ngraph::helpers; -using namespace ov::test; - -namespace CPULayerTestsDefinitions { +using namespace ov::test::utils; +namespace ov { +namespace test { std::string ActivationLayerCPUTest::getTestCaseName(const testing::TestParamInfo &obj) { std::vector inputShapes; std::vector activationShapes; - std::pair> activationTypeAndConstValue; - InferenceEngine::Precision netPrecision, inPrecision, outPrecision; + std::pair> activationTypeAndConstValue; + ov::element::Type netPrecision, inPrecision, outPrecision; CPUTestUtils::CPUSpecificParams cpuParams; std::tie(inputShapes, activationShapes, activationTypeAndConstValue, netPrecision, inPrecision, outPrecision, cpuParams) = obj.param; std::ostringstream result; - result << LayerTestsDefinitions::activationNames[activationTypeAndConstValue.first] << "_"; + result << activationNames[activationTypeAndConstValue.first] << "_"; if (inputShapes.front().first.size() != 0) { result << "IS=("; for (const auto &shape : inputShapes) { @@ -39,30 +39,30 @@ std::string ActivationLayerCPUTest::getTestCaseName(const testing::TestParamInfo } result << "AS=" << ov::test::utils::vec2str(activationShapes) << "_"; result << "ConstantsValue=" << ov::test::utils::vec2str(activationTypeAndConstValue.second) << "_"; - result << "netPRC=" << netPrecision.name() << "_"; - result << "inPRC=" << inPrecision.name() << "_"; - result << "outPRC=" << outPrecision.name() << "_"; + result << "netPRC=" << netPrecision.to_string() << "_"; + result << "inPRC=" << inPrecision.to_string() << "_"; + result << "outPRC=" << outPrecision.to_string() << "_"; result << CPUTestUtils::CPUTestsBase::getTestCaseName(cpuParams); return result.str(); } -void ActivationLayerCPUTest::generate_inputs(const std::vector& targetInputStaticShapes) { +void ActivationLayerCPUTest::generate_inputs(const std::vector& targetInputStaticShapes) { int32_t startFrom = 0; uint32_t range = 0; int32_t resolution = 0; - if (activationType == ActivationTypes::Exp && netPrecision == Precision::BF16) { + if (activationType == utils::ActivationTypes::Exp && netPrecision == ov::element::bf16) { startFrom = 0; range = 2; resolution = 32768; - } else if (activationType == ActivationTypes::Acosh) { + } else if (activationType == utils::ActivationTypes::Acosh) { startFrom = 2; range = 2; resolution = 128; - } else if (activationType == ActivationTypes::Acos || - activationType == ActivationTypes::Asin || - activationType == ActivationTypes::Atanh) { + } else if (activationType == utils::ActivationTypes::Acos || + activationType == utils::ActivationTypes::Asin || + activationType == utils::ActivationTypes::Atanh) { // range [-1. 1] is required startFrom = -1; range = 2; @@ -92,39 +92,38 @@ void ActivationLayerCPUTest::SetUp() { std::vector inputShapes; std::vector activationShapes; - std::pair> activationTypeAndConstValue; - InferenceEngine::Precision inPrecision, outPrecision; + std::pair> activationTypeAndConstValue; + ov::element::Type inPrecision, outPrecision; CPUTestUtils::CPUSpecificParams cpuParams; std::tie(inputShapes, activationShapes, activationTypeAndConstValue, netPrecision, inPrecision, outPrecision, cpuParams) = this->GetParam(); std::tie(inFmts, outFmts, priority, selectedType) = cpuParams; activationType = activationTypeAndConstValue.first; auto constantsValue = activationTypeAndConstValue.second; - inType = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(inPrecision); - outType = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(outPrecision); - selectedType = getPrimitiveType() + "_" + netPrecision.name(); + inType = inPrecision; + outType = outPrecision; + selectedType = getPrimitiveType() + "_" + netPrecision.to_string(); #if defined(OPENVINO_ARCH_ARM) || defined(OPENVINO_ARCH_ARM64) # if defined(OPENVINO_ARCH_ARM) - if (activationType == ngraph::helpers::ActivationTypes::GeluErf) // @todo tmp fallback to ref, gelu erf is disabled for 32bit ARM - selectedType = std::string("ref_") + netPrecision.name(); + if (activationType == utils::ActivationTypes::GeluErf) // @todo tmp fallback to ref, gelu erf is disabled for 32bit ARM + selectedType = std::string("ref_") + netPrecision.to_string(); # endif - if (activationType == ngraph::helpers::ActivationTypes::GeluTanh || // @todo not supported by ACL, can be decomposed with ngraph transformation - activationType == ngraph::helpers::ActivationTypes::SoftSign || // @todo not supported by ACL, can be decomposed with ngraph transformation + if (activationType == utils::ActivationTypes::GeluTanh || // @todo not supported by ACL, can be decomposed with transformation + activationType == utils::ActivationTypes::SoftSign || // @todo not supported by ACL, can be decomposed with transformation inputShapes.front().first.rank().get_length() > 5) // @todo tmp fallback to ref, remove after 6D+ ranks are properly supported - selectedType = std::string("ref_") + netPrecision.name(); + selectedType = std::string("ref_") + netPrecision.to_string(); #else - if (activationType == ngraph::helpers::ActivationTypes::Log) // @todo tmp fallback to ref, remove after Log is supported in emitters - selectedType = std::string("ref_") + netPrecision.name(); + if (activationType == utils::ActivationTypes::Log) // @todo tmp fallback to ref, remove after Log is supported in emitters + selectedType = std::string("ref_") + netPrecision.to_string(); #endif init_input_shapes(inputShapes); - auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); - auto params = std::make_shared(ngPrc, inputDynamicShapes.front()); - auto activation = ngraph::builder::makeActivation(params, ngPrc, activationType, activationShapes, constantsValue); + auto params = std::make_shared(netPrecision, inputDynamicShapes.front()); + auto activation = utils::make_activation(params, netPrecision, activationType, activationShapes, constantsValue); activation->get_rt_info() = getCPUInfo(); - function = std::make_shared(ngraph::NodeVector{activation}, ov::ParameterVector{params}, "Activation"); + function = std::make_shared(ov::NodeVector{activation}, ov::ParameterVector{params}, "Activation"); } TEST_P(ActivationLayerCPUTest, CompareWithRefs) { @@ -138,8 +137,8 @@ const std::vector activationShapes() { return {}; } -const std::map>>& activationTypes() { - static const std::map>> activationTypes { +const std::map>>& activationTypes() { + static const std::map>> activationTypes { {Sqrt, {{}}}, {Sigmoid, {{}}}, {Tanh, {{}}}, @@ -160,8 +159,8 @@ const std::map>>& activationType return activationTypes; } -const std::vector& netPrc() { - static const std::vector netPrc{Precision::FP32}; +const std::vector& netPrc() { + static const std::vector netPrc{ov::element::f32}; return netPrc; } @@ -223,8 +222,8 @@ const std::vector>& basic5D() { return basic5D; } -const std::map>>& activationTypesDynamicMath() { - static const std::map>> activationTypesDynamicMath { +const std::map>>& activationTypesDynamicMath() { + static const std::map>> activationTypesDynamicMath { {Log, {{}}}, {Sign, {{}}}, {Acos, {{}}}, @@ -245,9 +244,9 @@ const std::map>>& activationType return activationTypesDynamicMath; } -const std::vector& netPrecisions() { - static const std::vector netPrecisions { - InferenceEngine::Precision::FP32 +const std::vector& netPrecisions() { + static const std::vector netPrecisions { + ov::element::f32 }; return netPrecisions; @@ -269,5 +268,6 @@ const std::vector>& dynamicMathBasic() { return dynamicMathBasic; } -} // namespace Activation -} // namespace CPULayerTestsDefinitions +} // namespace Activation +} // namespace test +} // namespace ov diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/activation.hpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/activation.hpp index b7881fae053691..26ac7d2c7f93cf 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/activation.hpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/activation.hpp @@ -7,19 +7,20 @@ #include "shared_test_classes/single_layer/activation.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include +#include "common_test_utils/ov_tensor_utils.hpp" #include "test_utils/cpu_test_utils.hpp" #include "gtest/gtest.h" -namespace CPULayerTestsDefinitions { +namespace ov { +namespace test { using ActivationLayerCPUTestParamSet = - std::tuple, // Input shapes - std::vector, // Activation shapes - std::pair>, // Activation type and constant value - InferenceEngine::Precision, // Net precision - InferenceEngine::Precision, // Input precision - InferenceEngine::Precision, // Output precision + std::tuple, // Input shapes + std::vector, // Activation shapes + std::pair>, // Activation type and constant value + ov::element::Type, // Net precision + ov::element::Type, // Input precision + ov::element::Type, // Output precision CPUTestUtils::CPUSpecificParams>; class ActivationLayerCPUTest : public testing::WithParamInterface, @@ -27,23 +28,23 @@ class ActivationLayerCPUTest : public testing::WithParamInterface &obj); - void generate_inputs(const std::vector& targetInputStaticShapes) override; + void generate_inputs(const std::vector& targetInputStaticShapes) override; protected: void SetUp() override; private: - InferenceEngine::Precision netPrecision = InferenceEngine::Precision::UNSPECIFIED; - ngraph::helpers::ActivationTypes activationType = ngraph::helpers::None; + ov::element::Type netPrecision = ov::element::undefined; + utils::ActivationTypes activationType = utils::ActivationTypes::None; }; namespace Activation { const std::vector activationShapes(); -const std::map>>& activationTypes(); +const std::map>>& activationTypes(); -const std::vector& netPrc(); +const std::vector& netPrc(); /* ============= Activation (1D) ============= */ const std::vector& cpuParams3D(); @@ -60,13 +61,14 @@ const std::vector& cpuParams5D(); const std::vector>& basic5D(); -const std::map>>& activationTypesDynamicMath(); +const std::map>>& activationTypesDynamicMath(); -const std::vector& netPrecisions(); +const std::vector& netPrecisions(); const std::vector& cpuParamsDynamicMath(); const std::vector>& dynamicMathBasic(); -} // namespace Activation -} // namespace CPULayerTestsDefinitions +} // namespace Activation +} // namespace test +} // namespace ov diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/conversion.cpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/conversion.cpp index 3b118f7037c689..39bc1917dee262 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/conversion.cpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/conversion.cpp @@ -7,16 +7,14 @@ #include "gtest/gtest.h" #include "test_utils/cpu_test_utils.hpp" -using namespace InferenceEngine; using namespace CPUTestUtils; -using namespace ngraph::helpers; -using namespace ov::test; -namespace CPULayerTestsDefinitions { +namespace ov { +namespace test { std::string ConvertCPULayerTest::getTestCaseName(testing::TestParamInfo obj) { InputShape inputShape; - InferenceEngine::Precision inPrc, outPrc; + ov::element::Type inPrc, outPrc; CPUSpecificParams cpuParams; std::tie(inputShape, inPrc, outPrc, cpuParams) = obj.param; @@ -27,27 +25,26 @@ std::string ConvertCPULayerTest::getTestCaseName(testing::TestParamInfo primitive has to be changed // TODO: remove the WA after I32 is supported in snippets (ticket: 99803) #if defined(OPENVINO_ARCH_X86) || defined(OPENVINO_ARCH_X86_64) - if (inPrc == InferenceEngine::Precision::I32 || outPrc == InferenceEngine::Precision::I32) + if (inPrc == ov::element::i32 || outPrc == ov::element::i32) return false; #endif - // ACL does not support specific in-out precision pairs + // ACL does not support specific in-out precision pairs #if defined(OPENVINO_ARCH_ARM) || defined(OPENVINO_ARCH_ARM64) - if ((inPrc == InferenceEngine::Precision::I8 && outPrc == InferenceEngine::Precision::U8) || - (inPrc == InferenceEngine::Precision::U8 && outPrc == InferenceEngine::Precision::I8) || - (inPrc == InferenceEngine::Precision::FP32 && (outPrc == InferenceEngine::Precision::U8 || - outPrc == InferenceEngine::Precision::I8))) - return false; + if ((inPrc == ov::element::i8 && outPrc == ov::element::u8) || + (inPrc == ov::element::u8 && outPrc == ov::element::i8) || + (inPrc == ov::element::f32 && (outPrc == ov::element::u8 || outPrc == ov::element::i8))) + return false; #endif return true; } @@ -66,30 +63,26 @@ void ConvertCPULayerTest::SetUp() { if (!isInOutPrecisionSupported(inPrc, outPrc)) primitive = "ref"; - auto exec_type_precision = inPrc != InferenceEngine::Precision::U8 - ? inPrc - : InferenceEngine::Precision(InferenceEngine::Precision::I8); - selectedType = makeSelectedTypeStr(primitive, InferenceEngine::details::convertPrecision(exec_type_precision)); + auto exec_type_precision = inPrc != ov::element::u8 ? inPrc : ov::element::Type(ov::element::i8); + selectedType = makeSelectedTypeStr(primitive, exec_type_precision); for (size_t i = 0; i < shapes.second.size(); i++) { - targetStaticShapes.push_back(std::vector{shapes.second[i]}); + targetStaticShapes.push_back(std::vector{shapes.second[i]}); } inputDynamicShapes.push_back(shapes.first); - auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(inPrc); - auto targetPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(outPrc); ov::ParameterVector params; for (auto&& shape : inputDynamicShapes) { - params.push_back(std::make_shared(ngPrc, shape)); + params.push_back(std::make_shared(inPrc, shape)); } - auto conversion = std::make_shared(params.front(), targetPrc); + auto conversion = std::make_shared(params.front(), outPrc); - function = makeNgraphFunction(ngPrc, params, conversion, "ConversionCPU"); + function = makeNgraphFunction(inPrc, params, conversion, "ConversionCPU"); } -void ConvertCPULayerTest::generate_inputs(const std::vector& targetInputStaticShapes) { - if (outPrc != Precision::BOOL) { +void ConvertCPULayerTest::generate_inputs(const std::vector& targetInputStaticShapes) { + if (outPrc != ov::element::boolean) { SubgraphBaseTest::generate_inputs(targetInputStaticShapes); return; } @@ -97,7 +90,7 @@ void ConvertCPULayerTest::generate_inputs(const std::vector& targ // In the scenario where input precision is floating point and output precision is boolean, // for CPU plugin, the output precision boolean will be converted to u8 during common transformation, // the elements in the output tensor will retain the format of u8 with the range [0, 255]. - // But the output precision in ngraph reference is literal boolean, the elements are either 0 or 1. + // But the output precision in reference model is literal boolean, the elements are either 0 or 1. // Here input floating points values are set to be in the range of [-1, 1], so no extra precision // converting between actual output and expected output will be needed from the side of single layer tests. inputs.clear(); @@ -107,18 +100,18 @@ void ConvertCPULayerTest::generate_inputs(const std::vector& targ size_t size = shape_size(shape); ov::Tensor tensor = ov::test::utils::create_and_fill_tensor(funcInputs[0].get_element_type(), shape, 2 * size); - if (inPrc == Precision::FP32) { + if (inPrc == ov::element::f32) { auto* rawBlobDataPtr = static_cast(tensor.data()); for (size_t i = 0; i < size; ++i) { rawBlobDataPtr[i] = rawBlobDataPtr[i] / size - 1; } - } else if (inPrc == Precision::BF16) { - auto* rawBlobDataPtr = static_cast(tensor.data()); + } else if (inPrc == ov::element::bf16) { + auto* rawBlobDataPtr = static_cast(tensor.data()); for (size_t i = 0; i < size; ++i) { rawBlobDataPtr[i] = rawBlobDataPtr[i] / size - 1; } } else { - FAIL() << "Generating inputs with precision" << inPrc << " isn't supported, if output precision is boolean."; + FAIL() << "Generating inputs with precision " << inPrc.to_string() << " isn't supported, if output precision is boolean."; } inputs.insert({funcInputs[0].get_node_shared_ptr(), tensor}); @@ -199,16 +192,17 @@ const std::vector& inShapes_7D_dynamic() { return inShapes_7D_dynamic; } -const std::vector& precisions() { - static const std::vector precisions = { - Precision::U8, - Precision::I8, - Precision::I32, - Precision::FP32, - Precision::BF16 +const std::vector& precisions() { + static const std::vector precisions = { + ov::element::u8, + ov::element::i8, + ov::element::i32, + ov::element::f32, + ov::element::bf16 }; return precisions; } } // namespace Conversion -} // namespace CPULayerTestsDefinitions \ No newline at end of file +} // namespace test +} // namespace ov \ No newline at end of file diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/conversion.hpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/conversion.hpp index 4cac9c96a2501c..f0fbfbd29a2beb 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/conversion.hpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/conversion.hpp @@ -5,41 +5,39 @@ #pragma once #include "shared_test_classes/single_layer/activation.hpp" -#include "ov_models/builders.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include +#include "common_test_utils/ov_tensor_utils.hpp" #include "test_utils/cpu_test_utils.hpp" #include "gtest/gtest.h" -using namespace InferenceEngine; -using namespace ngraph; using namespace CPUTestUtils; -using namespace ov::test; -namespace CPULayerTestsDefinitions { -using convertLayerTestParamsSet = std::tuple; +namespace ov { +namespace test { +using convertLayerTestParamsSet = std::tuple; class ConvertCPULayerTest : public testing::WithParamInterface, virtual public SubgraphBaseTest, public CPUTestsBase { public: static std::string getTestCaseName(testing::TestParamInfo obj); - static bool isInOutPrecisionSupported(InferenceEngine::Precision inPrc, InferenceEngine::Precision outPrc); + static bool isInOutPrecisionSupported(ov::element::Type inPrc, ov::element::Type outPrc); protected: void SetUp() override; - void generate_inputs(const std::vector& targetInputStaticShapes) override; + void generate_inputs(const std::vector& targetInputStaticShapes) override; private: - InferenceEngine::Precision inPrc, outPrc; + ov::element::Type inPrc, outPrc; }; namespace Conversion { - const std::vector& inShapes_4D_static(); - const std::vector& inShapes_4D_dynamic(); - const std::vector& inShapes_7D_static(); - const std::vector& inShapes_7D_dynamic(); - const std::vector& precisions(); -} // namespace Conversion -} // namespace CPULayerTestsDefinitions \ No newline at end of file +const std::vector& inShapes_4D_static(); +const std::vector& inShapes_4D_dynamic(); +const std::vector& inShapes_7D_static(); +const std::vector& inShapes_7D_dynamic(); +const std::vector& precisions(); +} // namespace Conversion +} // namespace test +} // namespace ov \ No newline at end of file diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/convolution.cpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/convolution.cpp new file mode 100644 index 00000000000000..d6c83c16ba5978 --- /dev/null +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/convolution.cpp @@ -0,0 +1,764 @@ +// Copyright (C) 2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "convolution.hpp" + +#include "gtest/gtest.h" +#include "test_utils/cpu_test_utils.hpp" +#include "utils/general_utils.h" + +using namespace InferenceEngine; +using namespace CPUTestUtils; +using namespace ngraph::helpers; +using namespace ov::test; +using namespace ov::intel_cpu; + +namespace CPULayerTestsDefinitions { +std::string ConvolutionLayerCPUTest::getTestCaseName(const testing::TestParamInfo& obj) { + convLayerTestParamsSet basicParamsSet; + CPUSpecificParams cpuParams; + fusingSpecificParams fusingParams; + std::map additionalConfig; + std::tie(basicParamsSet, cpuParams, fusingParams, additionalConfig) = obj.param; + + convSpecificParams convParams; + ElementType netType; + ElementType inType, outType; + InputShape inputShape; + std::string targetDevice; + std::tie(convParams, netType, inType, outType, inputShape, targetDevice) = basicParamsSet; + ngraph::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="; + result << ov::test::utils::partialShape2str({inputShape.first}) << "_"; + result << "TS=("; + for (const auto& shape : inputShape.second) { + result << ov::test::utils::vec2str(shape) << "_"; + } + result << ")_"; + 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=" << netType << "_"; + result << "inPRC=" << inType << "_"; + result << "outPRC=" << outType << "_"; + result << "trgDev=" << targetDevice; + + result << CPUTestsBase::getTestCaseName(cpuParams); + result << CpuTestWithFusing::getTestCaseName(fusingParams); + + if (!additionalConfig.empty()) { + result << "_PluginConf"; + for (auto& item : additionalConfig) { + result << "_" << item.first << "=" << item.second; + } + } + + return result.str(); +} + +void ConvolutionLayerCPUTest::checkBiasFusing(ov::CompiledModel& execNet) const { + if (!execNet) + return; + + auto execGraph = execNet.get_runtime_model(); + ASSERT_NE(nullptr, execGraph); + + bool foundConv = false; + for (const auto& node : execGraph->get_ops()) { + const auto& rtInfo = node->get_rt_info(); + auto getExecValue = [&rtInfo](const std::string& paramName) -> std::string { + auto it = rtInfo.find(paramName); + OPENVINO_ASSERT(rtInfo.end() != it); + return it->second.as(); + }; + + if (getExecValue(ExecGraphInfoSerialization::LAYER_TYPE) == "Convolution") { + foundConv = true; + ASSERT_EQ(3, node->inputs().size()); + break; + } + } + + ASSERT_TRUE(foundConv) << "Can't find Convolution node"; +} + +std::shared_ptr ConvolutionLayerCPUTest::modifyGraph(const ngraph::element::Type& ngPrc, + ngraph::ParameterVector& params, + const std::shared_ptr& lastNode) { + auto retNode = CpuTestWithFusing::modifyGraph(ngPrc, params, lastNode); + std::shared_ptr opToShapeInfer = nullptr; + for (auto& targetShapes : targetStaticShapes) { + for (size_t i = targetShapes.size(); i < params.size(); ++i) { + const auto& shape = params[i]->get_output_partial_shape(0); + if (shape.is_static()) { + targetShapes.push_back(shape.get_shape()); + } else { + // It is assumed that in such tests we have second parameter only if sum fusion is tested. + // Considering this fact, we need to set the appropriate static shape for the second term of the sum + // operation, and it has to match the convolution output shape. So the most suitable solution here is to + // perform shape inference on the convolution node + if (!opToShapeInfer) { + ngraph::OutputVector inputsForShapeInfer; + for (size_t j = 0; j < lastNode->get_input_size(); j++) { + if (ngraph::is_type(lastNode->get_input_node_ptr(j))) { + inputsForShapeInfer.push_back(lastNode->get_input_node_shared_ptr(j)); + } else { + inputsForShapeInfer.push_back( + std::make_shared(lastNode->get_input_element_type(j), + lastNode->get_input_partial_shape(j))); + } + } + opToShapeInfer = lastNode->clone_with_new_inputs(inputsForShapeInfer); + } + + std::vector secondParameterShapes; + if (auto parameter = dynamic_cast(opToShapeInfer->get_input_node_ptr(0))) { + parameter->set_partial_shape(targetShapes.front()); + parameter->validate_and_infer_types(); + } + opToShapeInfer->validate_and_infer_types(); + targetShapes.push_back(opToShapeInfer->get_output_shape(0)); + } + } + } + return retNode; +} + +void ConvolutionLayerCPUTest::SetUp() { + rel_threshold = 1e-4f; + + convLayerTestParamsSet basicParamsSet; + CPUSpecificParams cpuParams; + fusingSpecificParams fusingParams; + std::map additionalConfig; + std::tie(basicParamsSet, cpuParams, fusingParams, additionalConfig) = this->GetParam(); + + configuration.insert(additionalConfig.begin(), additionalConfig.end()); + + std::tie(inFmts, outFmts, priority, selectedType) = cpuParams; + std::tie(postOpMgrPtr, fusedOps) = fusingParams; + + if (postOpMgrPtr) + isBias = (postOpMgrPtr->getFusedOpsNames() == "Add(PerChannel)" && selectedType != "jit_avx512_winograd"); + + convSpecificParams convParams; + InputShape inputShape; + auto netType = ElementType::undefined; + std::tie(convParams, netType, inType, outType, inputShape, targetDevice) = basicParamsSet; + + init_input_shapes({inputShape}); + + if (configuration.count(PluginConfigParams::KEY_ENFORCE_BF16) && + PluginConfigParams::YES == configuration[PluginConfigParams::KEY_ENFORCE_BF16].as()) { + selectedType += "_BF16"; + rel_threshold = 1e-2f; + if (selectedType == "jit_gemm_BF16") + rel_threshold = 0.05f; + } else { + selectedType = makeSelectedTypeStr(selectedType, netType); + } + + ngraph::op::PadType padType; + InferenceEngine::SizeVector stride; + std::vector padBegin, padEnd; + size_t convOutChannels; + std::tie(kernel, stride, padBegin, padEnd, dilation, convOutChannels, padType) = convParams; + + ov::ParameterVector inputParams; + for (auto&& shape : inputDynamicShapes) + inputParams.push_back(std::make_shared(ov::element::f32, shape)); + auto convolutionNode = ov::test::utils::make_convolution(inputParams[0], netType, kernel, stride, padBegin, + padEnd, dilation, padType, convOutChannels); + + function = makeNgraphFunction(netType, inputParams, convolutionNode, "Convolution"); +} + +TEST_P(ConvolutionLayerCPUTest, CompareWithRefs) { + // Skip tests for sse41 convolution where ic or oc cannot be exactly divided by the block size, + // since tails processing for sse41 nspc layout is not supported yet (see 52736). + if (!inFmts.empty() && (inFmts.front() == nwc || inFmts.front() == nhwc || inFmts.front() == ndhwc) && selectedType.find("jit_sse") != std::string::npos) { + auto inpChannels = function->get_parameters().front()->get_partial_shape()[1].get_length(); + auto outChannels = function->get_output_partial_shape(0)[1].get_length(); + if ((inpChannels % 8) || (outChannels % 8)) { + GTEST_SKIP() << "Disabled test due to the sse41 convolution kernel does not support tails for nspc layout." << std::endl; + } + } + + 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; + for (const auto &i : kernel) { + if (i != 1) { + is_1x1 = false; + break; + } + } + if (is_1x1) { + GTEST_SKIP() << "Disabled test due to the brgconv does not support 1x1 convolution kernel." << std::endl; + } + } + + // Skip tests for brgconv_amx convolution where dilation is not 1 + if (priority[0].find("amx") != std::string::npos) { + bool dilation_is_1x1 = true; + for (const auto &i : dilation) { + if (i != 1) { + dilation_is_1x1 = false; + break; + } + } + if (!dilation_is_1x1) { + GTEST_SKIP() << "Disabled test due to the brgconv amx does not support non 1 dilation convolution kernel." << std::endl; + } + } + } + +// FIXME: ACL output shape check fails if kernel, stride and padding equal to 1 +// CpuGemm::validate checks that 2nd and 3rd dimention of the input and output shapes are equal and fails (ticket 114201) +#if defined(OPENVINO_ARCH_ARM) || defined(OPENVINO_ARCH_ARM64) + if (std::all_of(kernel.begin(), kernel.end(), [](size_t i){return i == 1;}) && + std::all_of(stride.begin(), stride.end(), [](size_t i){return i == 1;}) && + std::all_of(padBegin.begin(), padBegin.end(), [](ptrdiff_t i){return i == 1;})) { + GTEST_SKIP() << "Disabled test due to output shape check failed" << std::endl; + } +#endif + run(); + + if (isBias) { + checkBiasFusing(compiledModel); + } + CheckPluginRelatedResults(compiledModel, "Convolution"); +} + +namespace Convolution { + +const SizeVector& numOutChannels() { + static const SizeVector numOutChannels = { 64, 63 }; + return numOutChannels; +} + +const SizeVector& numOutChannels_Gemm() { + static const SizeVector numOutChannels_Gemm = { 6 }; + return numOutChannels_Gemm; +} + +const std::vector& kernels1d() { + static const std::vector kernels1d = { {3}, {1} }; + return kernels1d; +} + +const std::vector& strides1d() { + static const std::vector strides1d = { {1}, {2} }; + return strides1d; +} + +const std::vector>& padBegins1d() { + static const std::vector> padBegins1d = { {0}, {1} }; + return padBegins1d; +} + +const std::vector>& padEnds1d() { + static const std::vector> padEnds1d = { {0} }; + return padEnds1d; +} + +const std::vector& dilations1d() { + static const std::vector dilations1d = { {1}, {2} }; + return dilations1d; +} + +const std::vector& kernels2d() { + static const std::vector kernels2d = { {3, 3}, {1, 1} }; + return kernels2d; +} + +const std::vector& strides2d() { + static const std::vector strides2d = { {1, 1}, {2, 2} }; + return strides2d; +} + +const std::vector>& padBegins2d() { + static const std::vector> padBegins2d = { {0, 0}, {1, 1} }; + return padBegins2d; +} + +const std::vector>& padEnds2d() { + static const std::vector> padEnds2d = { {0, 0} }; + return padEnds2d; +} + +const std::vector& dilations2d() { + static const std::vector dilations2d = { {1, 1} }; + return dilations2d; +} + +const std::vector& inShapesGemm2D() { + static const std::vector inShapesGemm2D = { + {{}, {{ 2, 12, 7, 7 }}}, + { + //dynamic shape + { {1, 200}, 12, -1, {1, 200} }, + { //target static shapes + { 2, 12, 7, 7 }, + { 1, 12, 5, 5 } + } + } + }; + return inShapesGemm2D; +} + +const std::vector& inShapesGemm2D_cache() { + static const std::vector inShapesGemm2D_cache = { + {{}, {{ 2, 12, 7, 7 }}}, + { + //dynamic shape + { {1, 200}, 12, -1, {1, 200} }, + { //target static shapes + { 1, 12, 5, 5 }, + { 1, 12, 7, 7 }, + { 1, 12, 5, 5 } + } + } + }; + return inShapesGemm2D_cache; +} + +const std::vector& CPUParams_2D() { + static const std::vector CPUParams_2D = { + conv_sse42_2D, + conv_avx2_2D, + conv_avx512_2D, + conv_sse42_2D_nspc, + conv_avx2_2D_nspc, + conv_avx2_2D_nspc_brgconv, + conv_avx512_2D_nspc, + conv_avx512_2D_nspc_brgconv + }; + return CPUParams_2D; +} + +const std::vector& CPUParams_GEMM_1D() { + static const std::vector CPUParams_GEMM_1D = { + conv_gemm_1D, + conv_gemm_1D_nspc + }; + return CPUParams_GEMM_1D; +} + +const std::vector& CPUParams_GEMM_2D() { + static const std::vector CPUParams_GEMM_2D = { + conv_gemm_2D, + conv_gemm_2D_nspc, + conv_gemm_acl_2D_nspc + }; + return CPUParams_GEMM_2D; +} + +const std::vector& inputShapes1d() { + static const std::vector inputShapes1d = { + {{}, {{ 2, 64, 7 }}}, + {{}, {{ 1, 67, 7 }}}, + { + //dynamic shape + { -1, 64, {1, 200} }, + { //target static shapes + { 2, 64, 7 }, + { 1, 64, 9 } + } + }, + { + //dynamic shape + { -1, 67, {1, 200} }, + { //target static shapes + { 2, 67, 7 }, + { 1, 67, 9 } + } + }, + { + //dynamic shape + { {1, 200}, 64, -1 }, + { //target static shapes + { 2, 64, 7 }, + { 1, 64, 5 } + } + } + }; + return inputShapes1d; +} + +const std::vector& inputShapes2d() { + static const std::vector inputShapes2d = { + {{}, {{ 1, 64, 7, 7 }}}, + {{}, {{ 1, 67, 7, 7 }}}, + { + //dynamic shape + { -1, 64, -1, {1, 200} }, + { //target static shapes + { 2, 64, 7, 7 }, + { 1, 64, 9, 9} + } + }, + { + //dynamic shape + { -1, 67, -1, {1, 200} }, + { //target static shapes + { 2, 67, 7, 7 }, + { 1, 67, 9, 9} + } + } + }; + return inputShapes2d; +} + +const std::vector& inputShapesPlain2Blocked2d() { + static const std::vector inputShapesPlain2Blocked2d = { + {{}, {{ 1, 1, 7, 7 }}}, + {{}, {{ 1, 2, 7, 7 }}}, + {{}, {{ 1, 3, 7, 7 }}}, + { + //dynamic shape + { -1, 1, -1, {1, 200} }, + { //target static shapes + { 2, 1, 7, 7 }, + { 1, 1, 9, 9} + } + }, + { + //dynamic shape + { -1, 3, -1, {1, 200} }, + { //target static shapes + { 2, 3, 7, 7 }, + { 1, 3, 9, 9} + } + } + }; + return inputShapesPlain2Blocked2d; +} + +const std::vector& inputShapes2d_dynBatch() { + static const std::vector inputShapes2d_dynBatch = { + { + //dynamic shape + { {1, 10}, 64, 7, 7 }, + { //target static shapes + { 2, 64, 7, 7 }, + { 1, 64, 7, 7 } + } + }, + }; + return inputShapes2d_dynBatch; +} + +const std::vector& CPUParams_1x1_1D() { + static const std::vector CPUParams_1x1_1D = { + conv_sse42_1D_1x1, + conv_avx2_1D_1x1, + conv_avx512_1D_1x1, + conv_sse42_1D_1x1_nspc, + conv_avx2_1D_1x1_nspc, + conv_avx2_1D_1x1_nspc_brgconv, + conv_avx512_1D_1x1_nspc, + conv_avx512_1D_1x1_nspc_brgconv + }; + return CPUParams_1x1_1D; +} + +const std::vector& kernels3d() { + static const std::vector kernels3d = { {3, 3, 3}, {1, 1, 1} }; + return kernels3d; +} + +const std::vector& strides3d() { + static const std::vector strides3d = { {1, 1, 1}, {2, 2, 2} }; + return strides3d; +} + +const std::vector>& padBegins3d() { + static const std::vector> padBegins3d = { {0, 0, 0}, {1, 1, 1} }; + return padBegins3d; +} + +const std::vector>& padEnds3d() { + static const std::vector> padEnds3d = { {0, 0, 0} }; + return padEnds3d; +} + +const std::vector& dilations3d() { + static const std::vector dilations3d = { {1, 1, 1} }; + return dilations3d; +} + +const std::vector & inputShapes3d() { + static const std::vector inputShapes3d = { + {{}, {{ 1, 64, 7, 7, 7 }}}, + {{}, {{ 1, 67, 7, 7, 7 }}}, + { + //dynamic shapes + { -1, 64, -1, {1, 200}, -1 }, + { //target static shapes + { 1, 64, 7, 7, 7 }, + { 1, 64, 9, 9, 9} + } + }, + { + //dynamic shapes + { -1, 67, -1, {1, 200}, -1 }, + { //target static shapes + { 1, 67, 7, 7, 7 }, + { 1, 67, 9, 9, 9} + } + } + }; + return inputShapes3d; +} + +const std::vector & inShapesGemm3D() { + static const std::vector inShapesGemm3D = { + {{}, {{ 2, 12, 7, 7, 7 }}}, + { + //dynamic shape + { {1, 200}, 12, -1, {1, 200}, -1 }, + { //target static shapes + { 2, 12, 7, 7, 7 }, + { 1, 12, 5, 5, 5 } + } + } + }; + return inShapesGemm3D; +} + +const std::vector& CPUParams_GEMM_3D() { + static const std::vector CPUParams_GEMM_3D = { + conv_gemm_3D, + conv_gemm_3D_nspc, + conv_gemm_acl_3D, + conv_gemm_acl_3D_nspc + }; + return CPUParams_GEMM_3D; +} + +const std::vector& CPUParams_1x1_2D() { + static const std::vector CPUParams_1x1_2D = { + conv_sse42_2D_1x1, + conv_avx2_2D_1x1, + conv_avx512_2D_1x1, + conv_sse42_2D_1x1_nspc, + conv_avx2_2D_1x1_nspc, + conv_avx2_2D_1x1_nspc_brgconv, + conv_avx512_2D_1x1_nspc, + conv_avx512_2D_1x1_nspc_brgconv + }; + return CPUParams_1x1_2D; +} + +const std::vector& inputShapes2d_cache() { + static const std::vector inputShapes2d_cache = { + {{}, {{ 1, 64, 7, 7 }}}, + {{}, {{ 1, 67, 7, 7 }}}, + { + //dynamic shape + { -1, 64, -1, {1, 200} }, + { //target static shapes + { 1, 64, 7, 7 }, + { 1, 64, 9, 9 }, + { 1, 64, 7, 7 } + } + }, + { + //dynamic shape + { -1, 67, -1, {1, 200} }, + { //target static shapes + { 1, 67, 7, 7 }, + { 1, 67, 9, 9} + } + } + }; + return inputShapes2d_cache; +} + +const std::vector& fusingParamsSetWithEmpty() { + static const std::vector fusingParamsSetWithEmpty = { + emptyFusingSpec, + // eltwise + fusingRelu, + fusingPRelu1DScaleShift, + // depthwise + fusingReluScaleShift, + // fake quantize + fusingFakeQuantizePerTensorRelu, + fusingFakeQuantizePerChannelRelu, + // sum + fusingSumEluFQ, + fusingSum, + // bias + fusingAddPerChannel + }; + return fusingParamsSetWithEmpty; +} + +const std::vector& inShapesGemm1D() { + static const std::vector inShapesGemm1D = { + {{}, {{ 2, 12, 7 }}}, + { + //dynamic shape + { {1, 200}, 12, {1, 200} }, + { //target static shapes + { 2, 12, 7 }, + { 1, 12, 5 } + } + } + }; + return inShapesGemm1D; +} + +const convParams_ExplicitPaddingType& convParams_ExplicitPadding_GEMM_2D() { + static const auto convParams_ExplicitPadding_GEMM_2D = ::testing::Combine( + ::testing::ValuesIn(kernels2d()), + ::testing::ValuesIn(strides2d()), + ::testing::ValuesIn(padBegins2d()), + ::testing::ValuesIn(padEnds2d()), + ::testing::ValuesIn(dilations2d()), + ::testing::ValuesIn(numOutChannels_Gemm()), + ::testing::Values(ngraph::op::PadType::EXPLICIT)); + return convParams_ExplicitPadding_GEMM_2D; +} + +const convParams_ExplicitPaddingDilatedType& convParams_ExplicitPadding_GEMM_2D_dilated() { + static const auto convParams_ExplicitPadding_GEMM_2D_dilated = ::testing::Combine( + ::testing::ValuesIn(kernels2d()), + ::testing::ValuesIn(strides2d()), + ::testing::ValuesIn(padBegins2d()), + ::testing::ValuesIn(padEnds2d()), + ::testing::Values(SizeVector{2, 2}), + ::testing::ValuesIn(numOutChannels_Gemm()), + ::testing::Values(ngraph::op::PadType::EXPLICIT)); + return convParams_ExplicitPadding_GEMM_2D_dilated; +} + +const convParams_ExplicitPaddingType& convParams_ExplicitPadding_GEMM_1D() { + static const auto convParams_ExplicitPadding_GEMM_1D = ::testing::Combine( + ::testing::ValuesIn(kernels1d()), + ::testing::ValuesIn(strides1d()), + ::testing::ValuesIn(padBegins1d()), + ::testing::ValuesIn(padEnds1d()), + ::testing::ValuesIn(dilations1d()), + ::testing::ValuesIn(numOutChannels_Gemm()), + ::testing::Values(ngraph::op::PadType::EXPLICIT)); + return convParams_ExplicitPadding_GEMM_1D; +} + +const convParams_ExplicitPaddingType& convParams_ExplicitPadding_2D() { + static const auto convParams_ExplicitPadding_2D = ::testing::Combine( + ::testing::ValuesIn(kernels2d()), + ::testing::ValuesIn(strides2d()), + ::testing::ValuesIn(padBegins2d()), + ::testing::ValuesIn(padEnds2d()), + ::testing::ValuesIn(dilations2d()), + ::testing::ValuesIn(numOutChannels()), + ::testing::Values(ngraph::op::PadType::EXPLICIT)); + return convParams_ExplicitPadding_2D; +} + +const convParams_ExplicitPaddingDilatedType& convParams_ExplicitPadding_2D_dilated() { + static const auto convParams_ExplicitPadding_2D_dilated = ::testing::Combine( + ::testing::ValuesIn(kernels2d()), + ::testing::ValuesIn(strides2d()), + ::testing::ValuesIn(padBegins2d()), + ::testing::ValuesIn(padEnds2d()), + ::testing::Values(SizeVector{2, 2}), + ::testing::ValuesIn(numOutChannels()), + ::testing::Values(ngraph::op::PadType::EXPLICIT)); + return convParams_ExplicitPadding_2D_dilated; +} + +const convParams_ExplicitPaddingType& convParams_ExplicitPadding_GEMM_3D() { + static const auto convParams_ExplicitPadding_GEMM_3D = ::testing::Combine( + ::testing::ValuesIn(kernels3d()), + ::testing::ValuesIn(strides3d()), + ::testing::ValuesIn(padBegins3d()), + ::testing::ValuesIn(padEnds3d()), + ::testing::ValuesIn(dilations3d()), + ::testing::ValuesIn(numOutChannels_Gemm()), + ::testing::Values(ngraph::op::PadType::EXPLICIT)); + return convParams_ExplicitPadding_GEMM_3D; +} + +const convParams_ExplicitPaddingDilatedType& convParams_ExplicitPadding_GEMM_3D_dilated() { + static const auto convParams_ExplicitPadding_GEMM_3D_dilated = ::testing::Combine( + ::testing::ValuesIn(kernels3d()), + ::testing::ValuesIn(strides3d()), + ::testing::ValuesIn(padBegins3d()), + ::testing::ValuesIn(padEnds3d()), + ::testing::Values(SizeVector{2, 2, 2}), + ::testing::ValuesIn(numOutChannels_Gemm()), + ::testing::Values(ngraph::op::PadType::EXPLICIT)); + return convParams_ExplicitPadding_GEMM_3D_dilated; +} + +const convParams_ExplicitPaddingType& convParams_ExplicitPadding_3D() { + static const auto convParams_ExplicitPadding_3D = ::testing::Combine( + ::testing::ValuesIn(kernels3d()), + ::testing::ValuesIn(strides3d()), + ::testing::ValuesIn(padBegins3d()), + ::testing::ValuesIn(padEnds3d()), + ::testing::ValuesIn(dilations3d()), + ::testing::ValuesIn(numOutChannels()), + ::testing::Values(ngraph::op::PadType::EXPLICIT)); + return convParams_ExplicitPadding_3D; +} + +const convParams_ExplicitPaddingDilatedType& convParams_ExplicitPadding_3D_dilated() { + static const auto convParams_ExplicitPadding_3D_dilated = ::testing::Combine( + ::testing::ValuesIn(kernels3d()), + ::testing::ValuesIn(strides3d()), + ::testing::ValuesIn(padBegins3d()), + ::testing::ValuesIn(padEnds3d()), + ::testing::Values(SizeVector{2, 2, 2}), + ::testing::ValuesIn(numOutChannels()), + ::testing::Values(ngraph::op::PadType::EXPLICIT)); + return convParams_ExplicitPadding_3D_dilated; +} + +const convParams_ExplicitPadding_1x1_Type& convParams_ExplicitPadding_1x1_1D() { + static const auto convParams_ExplicitPadding_1x1_1D = ::testing::Combine( + ::testing::Values(SizeVector({1})), + ::testing::Values(SizeVector({1})), + ::testing::Values(std::vector({0})), + ::testing::Values(std::vector({0})), + ::testing::Values(SizeVector({1})), + ::testing::Values(63), + ::testing::Values(ngraph::op::PadType::EXPLICIT)); + return convParams_ExplicitPadding_1x1_1D; +} + +const convParams_ExplicitPadding_1x1_Type& convParams_ExplicitPadding_1x1_2D() { + static const auto convParams_ExplicitPadding_1x1_2D = ::testing::Combine( + ::testing::Values(SizeVector({1, 1})), + ::testing::Values(SizeVector({1, 1})), + ::testing::Values(std::vector({0, 0})), + ::testing::Values(std::vector({0, 0})), + ::testing::Values(SizeVector({1, 1})), + ::testing::Values(63), + ::testing::Values(ngraph::op::PadType::EXPLICIT)); + return convParams_ExplicitPadding_1x1_2D; +} + +} // namespace Convolution +} // namespace CPULayerTestsDefinitions diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/convolution.hpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/convolution.hpp new file mode 100644 index 00000000000000..9d6ae7eb48a0b1 --- /dev/null +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/convolution.hpp @@ -0,0 +1,138 @@ +// Copyright (C) 2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include "shared_test_classes/single_layer/convolution.hpp" + +#include "test_utils/cpu_test_utils.hpp" +#include "test_utils/convolution_params.hpp" +#include "test_utils/fusing_test_utils.hpp" +#include "shared_test_classes/base/ov_subgraph.hpp" +#include "ov_models/utils/ov_helpers.hpp" +#include "common_test_utils/node_builders/convolution.hpp" +#include "openvino/core/visibility.hpp" +#include + +using namespace InferenceEngine; +using namespace CPUTestUtils; +using namespace ov::test; + +namespace CPULayerTestsDefinitions { +using LayerTestsDefinitions::convSpecificParams; + +typedef std::tuple< + convSpecificParams, + ElementType, // Net precision + ElementType, // Input precision + ElementType, // Output precision + InputShape, // Input shape + LayerTestsUtils::TargetDevice // Device name +> convLayerTestParamsSet; + +typedef std::tuple< + convLayerTestParamsSet, + CPUSpecificParams, + fusingSpecificParams, + std::map > convLayerCPUTestParamsSet; + +class ConvolutionLayerCPUTest : public testing::WithParamInterface, + virtual public SubgraphBaseTest, public CpuTestWithFusing { +public: + static std::string getTestCaseName(const testing::TestParamInfo& obj); +protected: + bool isBias = false; + InferenceEngine::SizeVector kernel, dilation; + InferenceEngine::SizeVector stride; + std::vector padBegin, padEnd; + + void checkBiasFusing(ov::CompiledModel &execNet) const; + std::shared_ptr modifyGraph(const ngraph::element::Type &ngPrc, + ngraph::ParameterVector ¶ms, + const std::shared_ptr &lastNode) override; + void SetUp() override; +}; + +namespace Convolution { + const std::vector& kernels1d(); + const std::vector& strides1d(); + const std::vector>& padBegins1d(); + const std::vector>& padEnds1d(); + const std::vector& dilations1d(); + + const std::vector& kernels2d(); + const std::vector& strides2d(); + const std::vector>& padBegins2d(); + const std::vector>& padEnds2d(); + const std::vector& dilations2d(); + + const std::vector& kernels3d(); + const std::vector& strides3d(); + const std::vector>& padBegins3d(); + const std::vector>& padEnds3d(); + const std::vector& dilations3d(); + + const std::vector& CPUParams_1x1_1D(); + const std::vector& CPUParams_1x1_2D(); + const std::vector& CPUParams_2D(); + const std::vector& CPUParams_GEMM_1D(); + const std::vector& CPUParams_GEMM_2D(); + const std::vector& CPUParams_GEMM_3D(); + + const std::vector& inputShapes1d(); + const std::vector& inputShapes2d(); + const std::vector& inputShapes3d(); + const std::vector& inputShapes2d_cache(); + const std::vector& inputShapesPlain2Blocked2d(); + const std::vector& inputShapes2d_dynBatch(); + const std::vector& inShapesGemm1D(); + + const std::vector& inShapesGemm2D(); + const std::vector& inShapesGemm2D_cache(); + const std::vector& inShapesGemm3D(); + + const SizeVector& numOutChannels(); + const SizeVector& numOutChannels_Gemm(); + + const std::vector& fusingParamsSetWithEmpty(); + + using convParams_ExplicitPaddingType = decltype(::testing::Combine( + ::testing::ValuesIn(kernels2d()), + ::testing::ValuesIn(strides2d()), + ::testing::ValuesIn(padBegins2d()), + ::testing::ValuesIn(padEnds2d()), + ::testing::ValuesIn(dilations2d()), + ::testing::ValuesIn(numOutChannels_Gemm()), + ::testing::Values(ngraph::op::PadType::EXPLICIT))); + using convParams_ExplicitPaddingDilatedType = decltype(::testing::Combine( + ::testing::ValuesIn(kernels2d()), + ::testing::ValuesIn(strides2d()), + ::testing::ValuesIn(padBegins2d()), + ::testing::ValuesIn(padEnds2d()), + ::testing::Values(SizeVector{2, 2}), + ::testing::ValuesIn(numOutChannels_Gemm()), + ::testing::Values(ngraph::op::PadType::EXPLICIT))); + using convParams_ExplicitPadding_1x1_Type = decltype(::testing::Combine( + ::testing::Values(SizeVector({1})), + ::testing::Values(SizeVector({1})), + ::testing::Values(std::vector({0})), + ::testing::Values(std::vector({0})), + ::testing::Values(SizeVector({1})), + ::testing::Values(63), + ::testing::Values(ngraph::op::PadType::EXPLICIT))); + const convParams_ExplicitPaddingType& convParams_ExplicitPadding_GEMM_1D(); + const convParams_ExplicitPaddingType& convParams_ExplicitPadding_GEMM_2D(); + const convParams_ExplicitPaddingType& convParams_ExplicitPadding_GEMM_3D(); + const convParams_ExplicitPaddingType& convParams_ExplicitPadding_2D(); + const convParams_ExplicitPaddingType& convParams_ExplicitPadding_3D(); + + const convParams_ExplicitPaddingDilatedType& convParams_ExplicitPadding_2D_dilated(); + const convParams_ExplicitPaddingDilatedType& convParams_ExplicitPadding_3D_dilated(); + const convParams_ExplicitPaddingDilatedType& convParams_ExplicitPadding_GEMM_2D_dilated(); + const convParams_ExplicitPaddingDilatedType& convParams_ExplicitPadding_GEMM_3D_dilated(); + + const convParams_ExplicitPadding_1x1_Type& convParams_ExplicitPadding_1x1_1D(); + const convParams_ExplicitPadding_1x1_Type& convParams_ExplicitPadding_1x1_2D(); +} // namespace Convolution +} // namespace CPULayerTestsDefinitions \ No newline at end of file diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/eltwise.cpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/eltwise.cpp index 667a1b08f6af18..633cc1f7df6390 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/eltwise.cpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/eltwise.cpp @@ -3,18 +3,17 @@ // #include "eltwise.hpp" + +#include "common_test_utils/node_builders/eltwise.hpp" #include "gtest/gtest.h" #include "openvino/core/type/element_type.hpp" #include "openvino/runtime/properties.hpp" #include "test_utils/cpu_test_utils.hpp" -#include "cpp_interfaces/interface/ie_internal_plugin_config.hpp" -using namespace InferenceEngine; using namespace CPUTestUtils; -using namespace ngraph::helpers; -using namespace ov::test; -namespace CPULayerTestsDefinitions { +namespace ov { +namespace test { std::string EltwiseLayerCPUTest::getTestCaseName(testing::TestParamInfo obj) { subgraph::EltwiseTestParams basicParamsSet; @@ -33,7 +32,7 @@ std::string EltwiseLayerCPUTest::getTestCaseName(testing::TestParamInfo& targetInputStaticShapes) { +void EltwiseLayerCPUTest::generate_inputs(const std::vector& targetInputStaticShapes) { inputs.clear(); const auto& funcInputs = function->inputs(); for (size_t i = 0; i < funcInputs.size(); ++i) { @@ -105,7 +104,7 @@ void EltwiseLayerCPUTest::SetUp() { std::tie(basicParamsSet, cpuParams, fusingParams, enforceSnippets) = this->GetParam(); std::vector shapes; ElementType netType; - ngraph::helpers::InputLayerType secondaryInputType; + utils::InputLayerType secondaryInputType; ov::test::utils::OpType opType; ov::AnyMap additionalConfig; std::tie(shapes, eltwiseType, secondaryInputType, opType, netType, inType, outType, targetDevice, additionalConfig) = basicParamsSet; @@ -127,7 +126,7 @@ void EltwiseLayerCPUTest::SetUp() { shapes.resize(2); switch (opType) { case ov::test::utils::OpType::SCALAR: { - std::vector identityShapes(shapes[0].second.size(), {1}); + std::vector identityShapes(shapes[0].second.size(), {1}); shapes[1] = {{}, identityShapes}; break; } @@ -145,31 +144,29 @@ void EltwiseLayerCPUTest::SetUp() { updateSelectedType(getPrimitiveType(), netType, configuration); // selectedType = makeSelectedTypeStr(getPrimitiveType(), netType); #if defined(OPENVINO_ARCH_ARM) || defined(OPENVINO_ARCH_ARM64) - if (eltwiseType == POWER) { + if (eltwiseType == utils::POWER) { selectedType = std::regex_replace(selectedType, std::regex("acl"), "ref"); } #endif - if (enforceSnippets) { - configuration.insert({InferenceEngine::PluginConfigInternalParams::KEY_SNIPPETS_MODE, - InferenceEngine::PluginConfigInternalParams::IGNORE_CALLBACK}); - } else { - configuration.insert({InferenceEngine::PluginConfigInternalParams::KEY_SNIPPETS_MODE, - InferenceEngine::PluginConfigInternalParams::DISABLE}); - } + if (enforceSnippets) { + configuration.insert({"SNIPPETS_MODE", "IGNORE_CALLBACK"}); + } else { + configuration.insert({"SNIPPETS_MODE", "DISABLE"}); + } ov::ParameterVector parameters{std::make_shared(netType, inputDynamicShapes.front())}; - std::shared_ptr secondaryInput; - if (eltwiseType != ngraph::helpers::EltwiseTypes::BITWISE_NOT) { + std::shared_ptr secondaryInput; + if (eltwiseType != utils::EltwiseTypes::BITWISE_NOT) { switch (secondaryInputType) { - case ngraph::helpers::InputLayerType::PARAMETER: { + case utils::InputLayerType::PARAMETER: { auto param = std::make_shared(netType, inputDynamicShapes.back()); secondaryInput = param; parameters.push_back(param); break; } - case ngraph::helpers::InputLayerType::CONSTANT: { + case utils::InputLayerType::CONSTANT: { auto pShape = inputDynamicShapes.back(); - ngraph::Shape shape; + ov::Shape shape; if (pShape.is_static()) { shape = pShape.get_shape(); } else { @@ -185,23 +182,23 @@ void EltwiseLayerCPUTest::SetUp() { auto data_tensor = generate_eltwise_input(netType, shape); if ((netType == ElementType::i8) || (netType == ElementType::u8)) { auto data_ptr = reinterpret_cast(data_tensor.data()); - std::vector data(data_ptr, data_ptr + ngraph::shape_size(shape)); + std::vector data(data_ptr, data_ptr + ov::shape_size(shape)); secondaryInput = ngraph::builder::makeConstant(netType, shape, data); } else if ((netType == ElementType::i16) || (netType == ElementType::u16)) { auto data_ptr = reinterpret_cast(data_tensor.data()); - std::vector data(data_ptr, data_ptr + ngraph::shape_size(shape)); + std::vector data(data_ptr, data_ptr + ov::shape_size(shape)); secondaryInput = ngraph::builder::makeConstant(netType, shape, data); } else if ((netType == ElementType::i32) || (netType == ElementType::u32)) { auto data_ptr = reinterpret_cast(data_tensor.data()); - std::vector data(data_ptr, data_ptr + ngraph::shape_size(shape)); + std::vector data(data_ptr, data_ptr + ov::shape_size(shape)); secondaryInput = ngraph::builder::makeConstant(netType, shape, data); } else if (netType == ElementType::f16) { auto data_ptr = reinterpret_cast(data_tensor.data()); - std::vector data(data_ptr, data_ptr + ngraph::shape_size(shape)); + std::vector data(data_ptr, data_ptr + ov::shape_size(shape)); secondaryInput = ngraph::builder::makeConstant(netType, shape, data); } else { auto data_ptr = reinterpret_cast(data_tensor.data()); - std::vector data(data_ptr, data_ptr + ngraph::shape_size(shape)); + std::vector data(data_ptr, data_ptr + ov::shape_size(shape)); secondaryInput = ngraph::builder::makeConstant(netType, shape, data); } break; @@ -211,7 +208,7 @@ void EltwiseLayerCPUTest::SetUp() { } } } - auto eltwise = ngraph::builder::makeEltwise(parameters[0], secondaryInput, eltwiseType); + auto eltwise = utils::makeEltwise(parameters[0], secondaryInput, eltwiseType); function = makeNgraphFunction(netType, parameters, eltwise, "Eltwise"); } @@ -242,36 +239,36 @@ const std::vector& opTypes() { return opTypes; } -const std::vector& eltwiseOpTypesBinInp() { - static const std::vector eltwiseOpTypesBinInp = { - ngraph::helpers::EltwiseTypes::ADD, - ngraph::helpers::EltwiseTypes::MULTIPLY, +const std::vector& eltwiseOpTypesBinInp() { + static const std::vector eltwiseOpTypesBinInp = { + utils::EltwiseTypes::ADD, + utils::EltwiseTypes::MULTIPLY, #if defined(OPENVINO_ARCH_X86) || defined(OPENVINO_ARCH_X86_64) - ngraph::helpers::EltwiseTypes::SUBTRACT, // TODO: Fix CVS-105430 - ngraph::helpers::EltwiseTypes::DIVIDE, // TODO: Fix CVS-105430 - ngraph::helpers::EltwiseTypes::FLOOR_MOD, // TODO: Fix CVS-111875 + utils::EltwiseTypes::SUBTRACT, // TODO: Fix CVS-105430 + utils::EltwiseTypes::DIVIDE, // TODO: Fix CVS-105430 + utils::EltwiseTypes::FLOOR_MOD, // TODO: Fix CVS-111875 #endif - ngraph::helpers::EltwiseTypes::SQUARED_DIFF, + utils::EltwiseTypes::SQUARED_DIFF, }; return eltwiseOpTypesBinInp; } -const std::vector& eltwiseOpTypesDiffInp() { - static const std::vector eltwiseOpTypesDiffInp = { // Different number of input nodes depending on optimizations - ngraph::helpers::EltwiseTypes::POWER, - // ngraph::helpers::EltwiseTypes::MOD // Does not execute because of transformations +const std::vector& eltwiseOpTypesDiffInp() { + static const std::vector eltwiseOpTypesDiffInp = { // Different number of input nodes depending on optimizations + utils::EltwiseTypes::POWER, + // utils::EltwiseTypes::MOD // Does not execute because of transformations }; return eltwiseOpTypesDiffInp; } -const std::vector& eltwiseOpTypesBinDyn() { - static const std::vector eltwiseOpTypesBinDyn = { - ngraph::helpers::EltwiseTypes::ADD, - ngraph::helpers::EltwiseTypes::MULTIPLY, +const std::vector& eltwiseOpTypesBinDyn() { + static const std::vector eltwiseOpTypesBinDyn = { + utils::EltwiseTypes::ADD, + utils::EltwiseTypes::MULTIPLY, #if defined(OPENVINO_ARCH_X86) || defined(OPENVINO_ARCH_X86_64) // TODO: Fix CVS-105430 - ngraph::helpers::EltwiseTypes::SUBTRACT, + utils::EltwiseTypes::SUBTRACT, #endif - ngraph::helpers::EltwiseTypes::SQUARED_DIFF, + utils::EltwiseTypes::SQUARED_DIFF, }; return eltwiseOpTypesBinDyn; } @@ -312,29 +309,29 @@ const std::vector>& inShapes_5D() { return inShapes_5D; } -const std::vector& eltwiseOpTypesI32() { - static const std::vector eltwiseOpTypesI32 = { - ngraph::helpers::EltwiseTypes::ADD, - ngraph::helpers::EltwiseTypes::MULTIPLY, +const std::vector& eltwiseOpTypesI32() { + static const std::vector eltwiseOpTypesI32 = { + utils::EltwiseTypes::ADD, + utils::EltwiseTypes::MULTIPLY, #if defined(OPENVINO_ARCH_X86) || defined(OPENVINO_ARCH_X86_64) // TODO: Fix CVS-105430 - ngraph::helpers::EltwiseTypes::SUBTRACT, - ngraph::helpers::EltwiseTypes::DIVIDE, + utils::EltwiseTypes::SUBTRACT, + utils::EltwiseTypes::DIVIDE, #endif - ngraph::helpers::EltwiseTypes::SQUARED_DIFF, + utils::EltwiseTypes::SQUARED_DIFF, }; return eltwiseOpTypesI32; } -const std::vector& secondaryInputTypes() { - static const std::vector secondaryInputTypes = { - ngraph::helpers::InputLayerType::CONSTANT, - ngraph::helpers::InputLayerType::PARAMETER, +const std::vector& secondaryInputTypes() { + static const std::vector secondaryInputTypes = { + utils::InputLayerType::CONSTANT, + utils::InputLayerType::PARAMETER, }; return secondaryInputTypes; } -const std::vector>& inShapes_4D_1D() { - static const std::vector> inShapes_4D_1D = { +const std::vector>& inShapes_4D_1D() { + static const std::vector> inShapes_4D_1D = { {{2, 17, 5, 4}, {4}}, {{1, 3, 3, 3}, {3}}, }; @@ -356,8 +353,8 @@ const std::vector& cpuParams_4D_1D_Parameter_mode() { return cpuParams_4D_1D_Parameter_mode; } -const std::vector>& inShapes_5D_1D() { - static const std::vector> inShapes_5D_1D = { +const std::vector>& inShapes_5D_1D() { + static const std::vector> inShapes_5D_1D = { {{2, 17, 5, 4, 10}, {10}}, {{1, 3, 3, 3, 3}, {3}}, }; @@ -484,5 +481,6 @@ const std::vector& enforceSnippets() { return enforceSnippets; } -} // namespace Eltwise -} // namespace CPULayerTestsDefinitions +} // namespace Eltwise +} // namespace test +} // namespace ov diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/eltwise.hpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/eltwise.hpp index 3b17539e6117c5..3271a37a78f6ac 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/eltwise.hpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/eltwise.hpp @@ -7,15 +7,15 @@ #include "shared_test_classes/single_layer/eltwise.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include +#include "common_test_utils/ov_tensor_utils.hpp" #include "test_utils/fusing_test_utils.hpp" #include "test_utils/cpu_test_utils.hpp" #include "gtest/gtest.h" using namespace CPUTestUtils; -using namespace ov::test; -namespace CPULayerTestsDefinitions { +namespace ov { +namespace test { typedef std::tuple< subgraph::EltwiseTestParams, @@ -29,12 +29,12 @@ class EltwiseLayerCPUTest : public testing::WithParamInterface obj); protected: - ov::Tensor generate_eltwise_input(const ov::element::Type& type, const ngraph::Shape& shape); - void generate_inputs(const std::vector& targetInputStaticShapes) override; + ov::Tensor generate_eltwise_input(const ov::element::Type& type, const ov::Shape& shape); + void generate_inputs(const std::vector& targetInputStaticShapes) override; void SetUp() override; private: - ngraph::helpers::EltwiseTypes eltwiseType; + utils::EltwiseTypes eltwiseType; }; namespace Eltwise { @@ -43,32 +43,33 @@ const std::vector& additional_config(); const std::vector& netType(); const std::vector& opTypes(); -const std::vector& eltwiseOpTypesBinInp(); -const std::vector& secondaryInputTypes(); +const std::vector& eltwiseOpTypesBinInp(); +const std::vector& secondaryInputTypes(); -const std::vector& eltwiseOpTypesBinInp(); -const std::vector& eltwiseOpTypesDiffInp(); -const std::vector& eltwiseOpTypesBinDyn(); +const std::vector& eltwiseOpTypesBinInp(); +const std::vector& eltwiseOpTypesDiffInp(); +const std::vector& eltwiseOpTypesBinDyn(); const std::vector& cpuParams_4D(); const std::vector>& inShapes_4D(); const std::vector>& inShapes_4D_dyn_const(); const std::vector& inShapes_4D_dyn_param(); -const std::vector>& inShapes_4D_1D(); +const std::vector>& inShapes_4D_1D(); const std::vector & cpuParams_4D_1D_Constant_mode(); const std::vector& cpuParams_4D_1D_Parameter_mode(); const std::vector& cpuParams_5D(); const std::vector>& inShapes_5D(); -const std::vector>& inShapes_5D_1D(); +const std::vector>& inShapes_5D_1D(); const std::vector& inShapes_5D_dyn_const(); const std::vector& inShapes_5D_dyn_param(); const std::vector& cpuParams_5D_1D_constant(); const std::vector& cpuParams_5D_1D_parameter(); -const std::vector& eltwiseOpTypesI32(); +const std::vector& eltwiseOpTypesI32(); const std::vector& enforceSnippets(); -} // namespace Eltwise -} // namespace CPULayerTestsDefinitions +} // namespace Eltwise +} // namespace test +} // namespace ov diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/matmul.cpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/matmul.cpp index e09ac9a9606e26..614e85a3afae4e 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/matmul.cpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/matmul.cpp @@ -7,14 +7,12 @@ #include "openvino/core/type/element_type.hpp" #include "openvino/runtime/properties.hpp" #include "test_utils/cpu_test_utils.hpp" -#include "cpp_interfaces/interface/ie_internal_plugin_config.hpp" #include "common_test_utils/ov_tensor_utils.hpp" -using namespace InferenceEngine; using namespace CPUTestUtils; -using namespace ov::test; -namespace CPULayerTestsDefinitions { +namespace ov { +namespace test { std::string MatMulLayerCPUTest::getTestCaseName(const testing::TestParamInfo& obj) { MatMulLayerTestParamsSet basicParamsSet; @@ -27,9 +25,9 @@ std::string MatMulLayerCPUTest::getTestCaseName(const testing::TestParamInfo additionalConfig; + ov::AnyMap additionalConfig; std::tie(shapeRelatedParams, netType, inType, outType, secondaryInputType, targetDevice, additionalConfig) = basicParamsSet; @@ -59,7 +57,7 @@ std::string MatMulLayerCPUTest::getTestCaseName(const testing::TestParamInfo() << ":"; } result << ")"; result << CpuTestWithFusing::getTestCaseName(fusingParams); @@ -85,8 +83,8 @@ void MatMulLayerCPUTest::SetUp() { ShapeRelatedParams shapeRelatedParams; ElementType netType; - helpers::InputLayerType secondaryInputType; - std::map additionalConfig; + utils::InputLayerType secondaryInputType; + ov::AnyMap additionalConfig; std::tie(shapeRelatedParams, netType, inType, outType, secondaryInputType, targetDevice, additionalConfig) = basicParamsSet; @@ -119,7 +117,8 @@ void MatMulLayerCPUTest::SetUp() { configuration.insert(additionalConfig.begin(), additionalConfig.end()); - if (additionalConfig[PluginConfigParams::KEY_ENFORCE_BF16] == PluginConfigParams::YES) + auto it = additionalConfig.find(ov::hint::inference_precision.name()); + if (it != additionalConfig.end() && it->second.as() == ov::element::bf16) inType = outType = netType = ElementType::bf16; else inType = outType = netType; @@ -130,7 +129,7 @@ void MatMulLayerCPUTest::SetUp() { ov::ParameterVector params{std::make_shared(netType, inShapeA)}; std::shared_ptr matrixB; - if (secondaryInputType == helpers::InputLayerType::PARAMETER) { + if (secondaryInputType == utils::InputLayerType::PARAMETER) { auto param = std::make_shared(netType, inShapeB); matrixB = param; params.push_back(param); @@ -139,7 +138,13 @@ void MatMulLayerCPUTest::SetUp() { auto tensor = ov::test::utils::create_and_fill_tensor(netType, inShapeB.to_shape()); matrixB = std::make_shared(tensor); } - auto paramOuts = helpers::convert2OutputVector(helpers::castOps2Nodes(params)); + + ov::OutputVector paramOuts; + for (auto&& node : params) { + for (auto&& param : node->outputs()) + paramOuts.push_back(param); + } + auto matMul = std::make_shared(paramOuts[0], matrixB, transpA, transpB); function = makeNgraphFunction(netType, params, matMul, cpuNodeType); checkFusingPosition = false; @@ -161,8 +166,8 @@ TEST_P(MatMulLayerCPUTest, CompareWithRefs) { } namespace MatMul { -const std::map& emptyAdditionalConfig() { - static const std::map emptyAdditionalConfig; +const ov::AnyMap& emptyAdditionalConfig() { + static const ov::AnyMap emptyAdditionalConfig; return emptyAdditionalConfig; } @@ -181,14 +186,13 @@ const std::vector& netPRCs() { return netPRCs; } -const std::vector>& additionalConfig() { - static std::vector> additionalConfig { - #ifndef OV_CPU_WITH_MLAS +const std::vector& additionalConfig() { + static std::vector additionalConfig{ +#ifndef OV_CPU_WITH_MLAS // FP32 precision is covered by MLAS - std::map{/* empty config */}, - #endif - {{PluginConfigParams::KEY_ENFORCE_BF16, PluginConfigParams::YES}} - }; + ov::AnyMap{/* empty config */}, +#endif + {ov::hint::inference_precision(ov::element::bf16)}}; return additionalConfig; } @@ -313,5 +317,6 @@ const std::vector& IS3D_smoke() { return IS3D_smoke; } -} // namespace MatMul -} // namespace CPULayerTestsDefinitions +} // namespace MatMul +} // namespace test +} // namespace ov diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/matmul.hpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/matmul.hpp index b965fab5ee5b46..c7a0c09fee3d1d 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/matmul.hpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/matmul.hpp @@ -6,16 +6,12 @@ #include "shared_test_classes/single_layer/mat_mul.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include "ie_precision.hpp" #include "test_utils/fusing_test_utils.hpp" -#include "ov_models/builders.hpp" -using namespace ngraph; -using namespace InferenceEngine; using namespace CPUTestUtils; -using namespace ov::test; -namespace CPULayerTestsDefinitions { +namespace ov { +namespace test { enum class MatMulNodeType { MatMul, @@ -27,15 +23,15 @@ struct ShapeRelatedParams { std::pair transpose; }; -typedef std::tuple< - ShapeRelatedParams, - ElementType, // Network precision - ElementType, // Input precision - ElementType, // Output precision - ngraph::helpers::InputLayerType, // Secondary input type - TargetDevice, // Device name - std::map // Additional network configuration -> MatMulLayerTestParamsSet; +typedef std::tuple + MatMulLayerTestParamsSet; using MatMulLayerCPUTestParamSet = std::tuple& netPRCs(); const std::vector& matmulFusingParams(); - const std::vector>& additionalConfig(); - const std::map& emptyAdditionalConfig(); + const std::vector& additionalConfig(); + const ov::AnyMap& emptyAdditionalConfig(); const std::vector& filterSpecificParams(); const std::vector& IS2D_nightly(); const std::vector& IS2D_smoke(); const std::vector& IS3D_smoke(); -} // namespace MatMul -} // namespace CPULayerTestsDefinitions +} // namespace MatMul +} // namespace test +} // namespace ov diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/mvn.cpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/mvn.cpp index 53aa6ca9604fc3..e12a5478b85cef 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/mvn.cpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/mvn.cpp @@ -6,24 +6,22 @@ #include "gtest/gtest.h" #include "test_utils/cpu_test_utils.hpp" -using namespace InferenceEngine; using namespace CPUTestUtils; -using namespace ngraph::helpers; -using namespace ov::test; -namespace CPULayerTestsDefinitions { +namespace ov { +namespace test { std::string MvnLayerCPUTest::getTestCaseName(testing::TestParamInfo obj) { basicCpuMvnParams basicParamsSet; CPUSpecificParams cpuParams; fusingSpecificParams fusingParams; ElementType inputPrecision, outputPrecision; - std::map additionalConfig; + ov::AnyMap additionalConfig; std::tie(basicParamsSet, cpuParams, fusingParams, inputPrecision, outputPrecision, additionalConfig) = obj.param; InputShape inputShapes; ElementType netPrecision; - ngraph::AxisSet axes; + ov::AxisSet axes; bool acrossChanels, normalizeVariance; double eps; std::tie(inputShapes, netPrecision, axes, acrossChanels, normalizeVariance, eps) = basicParamsSet; @@ -50,7 +48,7 @@ std::string MvnLayerCPUTest::getTestCaseName(testing::TestParamInfo +#include "common_test_utils/ov_tensor_utils.hpp" #include "test_utils/fusing_test_utils.hpp" #include "test_utils/cpu_test_utils.hpp" #include "gtest/gtest.h" - -using namespace InferenceEngine; using namespace CPUTestUtils; -using namespace ov::test; -namespace CPULayerTestsDefinitions { +namespace ov { +namespace test { using basicCpuMvnParams = std::tuple< InputShape, // Input shapes ElementType, // Input precision - ngraph::AxisSet, // Reduction axes + ov::AxisSet, // Reduction axes bool, // Across channels bool, // Normalize variance double>; // Epsilon @@ -31,9 +28,9 @@ using MvnLayerCPUTestParamSet = std::tuple< basicCpuMvnParams, CPUSpecificParams, fusingSpecificParams, - ElementType, // CNNNetwork input precision - ElementType, // CNNNetwork output precision - std::map>; + ElementType, // model input precision + ElementType, // model output precision + ov::AnyMap>; class MvnLayerCPUTest : public testing::WithParamInterface, virtual public SubgraphBaseTest, public CpuTestWithFusing { @@ -58,10 +55,11 @@ namespace MVN { const std::vector& inputShapesStatic_4D(); const std::vector& inputShapesStatic_5D(); - const std::vector& emptyReductionAxes(); + const std::vector& emptyReductionAxes(); const std::vector& acrossChannels(); const std::vector& epsilon(); - const std::vector>& additionalConfig(); -} // namespace MVN -} // namespace CPULayerTestsDefinitions \ No newline at end of file + const std::vector& additionalConfig(); +} // namespace MVN +} // namespace test +} // namespace ov \ No newline at end of file diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/pooling.cpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/pooling.cpp index 2d0f42fe85c318..c7c2ae3e938d83 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/pooling.cpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/pooling.cpp @@ -6,15 +6,13 @@ #include "pooling.hpp" #include "test_utils/cpu_test_utils.hpp" -using namespace InferenceEngine; using namespace CPUTestUtils; -using namespace ngraph::helpers; -using namespace ov::test; -namespace CPULayerTestsDefinitions { +namespace ov { +namespace test { std::string PoolingLayerCPUTest::getTestCaseName(const testing::TestParamInfo& obj) { - LayerTestsDefinitions::poolSpecificParams basicParamsSet; + ov::test::poolSpecificParams basicParamsSet; InputShape inputShapes; ElementType inPrc; bool isInt8; @@ -22,11 +20,11 @@ std::string PoolingLayerCPUTest::getTestCaseName(const testing::TestParamInfo kernel, stride; std::vector padBegin, padEnd; - ngraph::op::PadType padType; - ngraph::op::RoundingType roundingType; + ov::op::PadType padType; + ov::op::RoundingType roundingType; bool excludePad; std::tie(poolType, kernel, stride, padBegin, padEnd, roundingType, padType, excludePad) = basicParamsSet; @@ -39,10 +37,10 @@ std::string PoolingLayerCPUTest::getTestCaseName(const testing::TestParamInfoGetParam(); - ngraph::helpers::PoolingTypes poolType; + utils::PoolingTypes poolType; std::vector kernel, stride; std::vector padBegin, padEnd; - ngraph::op::PadType padType; - ngraph::op::RoundingType roundingType; + ov::op::PadType padType; + ov::op::RoundingType roundingType; bool excludePad; std::tie(poolType, kernel, stride, padBegin, padEnd, roundingType, padType, excludePad) = basicParamsSet; @@ -97,7 +95,7 @@ void PoolingLayerCPUTest::SetUp() { params.push_back(std::make_shared(inPrc, shape)); } - std::shared_ptr poolInput = params[0]; + std::shared_ptr poolInput = params[0]; if (isInt8) { ov::Shape newShape(poolInput->get_output_partial_shape(0).size(), 1); poolInput = ngraph::builder::makeFakeQuantize(poolInput, inPrc, 256, newShape); @@ -115,7 +113,7 @@ void PoolingLayerCPUTest::SetUp() { std::string MaxPoolingV8LayerCPUTest::getTestCaseName( const testing::TestParamInfo& obj) { - LayerTestsDefinitions::maxPoolV8SpecificParams basicParamsSet; + maxPoolV8SpecificParams basicParamsSet; InputShape inputShapes; ElementType inPrc; CPUSpecificParams cpuParams; @@ -123,9 +121,9 @@ std::string MaxPoolingV8LayerCPUTest::getTestCaseName( std::vector kernel, stride, dilation; std::vector padBegin, padEnd; - ngraph::op::PadType padType; - ngraph::op::RoundingType roundingType; - ngraph::element::Type indexElementType; + 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) = basicParamsSet; @@ -154,7 +152,7 @@ std::string MaxPoolingV8LayerCPUTest::getTestCaseName( void MaxPoolingV8LayerCPUTest::SetUp() { targetDevice = ov::test::utils::DEVICE_CPU; - LayerTestsDefinitions::maxPoolV8SpecificParams basicParamsSet; + maxPoolV8SpecificParams basicParamsSet; InputShape inputShapes; ElementType inPrc; CPUSpecificParams cpuParams; @@ -162,9 +160,9 @@ void MaxPoolingV8LayerCPUTest::SetUp() { std::vector kernel, stride, dilation; std::vector padBegin, padEnd; - ngraph::op::PadType padType; - ngraph::op::RoundingType roundingType; - ngraph::element::Type indexElementType; + 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) = basicParamsSet; @@ -191,8 +189,8 @@ void MaxPoolingV8LayerCPUTest::SetUp() { indexElementType, axis); pooling->get_rt_info() = getCPUInfo(); - ngraph::ResultVector results{std::make_shared(pooling->output(0))}; - function = std::make_shared(results, params, "MaxPooling"); + ov::ResultVector results{std::make_shared(pooling->output(0))}; + function = std::make_shared(results, params, "MaxPooling"); } TEST_P(PoolingLayerCPUTest, CompareWithRefs) { @@ -208,34 +206,34 @@ TEST_P(MaxPoolingV8LayerCPUTest, CompareWithRefs) { namespace Pooling { // The combination of parameters: NCHW + CEIL gives an accuracy problem in ACL AvgPool -const ngraph::op::RoundingType expectedAvgRoundingType() { +const ov::op::RoundingType expectedAvgRoundingType() { #if defined(OPENVINO_ARCH_ARM) || defined(OPENVINO_ARCH_ARM64) - return ngraph::op::RoundingType::FLOOR; + return ov::op::RoundingType::FLOOR; #else - return ngraph::op::RoundingType::CEIL; + return ov::op::RoundingType::CEIL; #endif } -const std::vector& paramsMax3D() { - static const std::vector paramsMax3D = { - LayerTestsDefinitions::poolSpecificParams{ ngraph::helpers::PoolingTypes::MAX, {2}, {2}, {0}, {0}, - ngraph::op::RoundingType::CEIL, ngraph::op::PadType::EXPLICIT, false }, - LayerTestsDefinitions::poolSpecificParams{ ngraph::helpers::PoolingTypes::MAX, {4}, {2}, {0}, {0}, - ngraph::op::RoundingType::CEIL, ngraph::op::PadType::EXPLICIT, false }, - LayerTestsDefinitions::poolSpecificParams{ ngraph::helpers::PoolingTypes::MAX, {2}, {1}, {0}, {0}, - ngraph::op::RoundingType::CEIL, ngraph::op::PadType::EXPLICIT, false }, +const std::vector& paramsMax3D() { + static const std::vector paramsMax3D = { + poolSpecificParams{ utils::PoolingTypes::MAX, {2}, {2}, {0}, {0}, + ov::op::RoundingType::CEIL, ov::op::PadType::EXPLICIT, false }, + poolSpecificParams{ utils::PoolingTypes::MAX, {4}, {2}, {0}, {0}, + ov::op::RoundingType::CEIL, ov::op::PadType::EXPLICIT, false }, + poolSpecificParams{ utils::PoolingTypes::MAX, {2}, {1}, {0}, {0}, + ov::op::RoundingType::CEIL, ov::op::PadType::EXPLICIT, false }, }; return paramsMax3D; } -const std::vector& paramsAvg3D() { - static const std::vector paramsAvg3D = { - LayerTestsDefinitions::poolSpecificParams{ ngraph::helpers::PoolingTypes::AVG, {3}, {1}, {1}, {0}, - expectedAvgRoundingType(), ngraph::op::PadType::SAME_UPPER, false }, - LayerTestsDefinitions::poolSpecificParams{ ngraph::helpers::PoolingTypes::AVG, {3}, {1}, {1}, {0}, - expectedAvgRoundingType(), ngraph::op::PadType::EXPLICIT, true }, - LayerTestsDefinitions::poolSpecificParams{ ngraph::helpers::PoolingTypes::AVG, {4}, {4}, {2}, {2}, - expectedAvgRoundingType(), ngraph::op::PadType::EXPLICIT, true }, +const std::vector& paramsAvg3D() { + static const std::vector paramsAvg3D = { + poolSpecificParams{ utils::PoolingTypes::AVG, {3}, {1}, {1}, {0}, + expectedAvgRoundingType(), ov::op::PadType::SAME_UPPER, false }, + poolSpecificParams{ utils::PoolingTypes::AVG, {3}, {1}, {1}, {0}, + expectedAvgRoundingType(), ov::op::PadType::EXPLICIT, true }, + poolSpecificParams{ utils::PoolingTypes::AVG, {4}, {4}, {2}, {2}, + expectedAvgRoundingType(), ov::op::PadType::EXPLICIT, true }, }; return paramsAvg3D; } @@ -245,25 +243,25 @@ const std::vector& inpOutPrecision() { return inpOutPrecision; } -const std::vector& paramsMax4D() { - static const std::vector paramsMax4D = { - LayerTestsDefinitions::poolSpecificParams{ ngraph::helpers::PoolingTypes::MAX, {2, 2}, {2, 2}, {0, 0}, {0, 0}, - ngraph::op::RoundingType::CEIL, ngraph::op::PadType::SAME_LOWER, false }, - LayerTestsDefinitions::poolSpecificParams{ ngraph::helpers::PoolingTypes::MAX, {2, 2}, {2, 2}, {0, 0}, {0, 0}, - ngraph::op::RoundingType::CEIL, ngraph::op::PadType::SAME_UPPER, false }, - LayerTestsDefinitions::poolSpecificParams{ ngraph::helpers::PoolingTypes::MAX, {4, 2}, {2, 2}, {0, 0}, {0, 0}, - ngraph::op::RoundingType::CEIL, ngraph::op::PadType::EXPLICIT, false }, - LayerTestsDefinitions::poolSpecificParams{ ngraph::helpers::PoolingTypes::MAX, {4, 2}, {2, 1}, {0, 0}, {0, 0}, - ngraph::op::RoundingType::CEIL, ngraph::op::PadType::EXPLICIT, false }, +const std::vector& paramsMax4D() { + static const std::vector paramsMax4D = { + poolSpecificParams{ utils::PoolingTypes::MAX, {2, 2}, {2, 2}, {0, 0}, {0, 0}, + ov::op::RoundingType::CEIL, ov::op::PadType::SAME_LOWER, false }, + poolSpecificParams{ utils::PoolingTypes::MAX, {2, 2}, {2, 2}, {0, 0}, {0, 0}, + ov::op::RoundingType::CEIL, ov::op::PadType::SAME_UPPER, false }, + poolSpecificParams{ utils::PoolingTypes::MAX, {4, 2}, {2, 2}, {0, 0}, {0, 0}, + ov::op::RoundingType::CEIL, ov::op::PadType::EXPLICIT, false }, + poolSpecificParams{ utils::PoolingTypes::MAX, {4, 2}, {2, 1}, {0, 0}, {0, 0}, + ov::op::RoundingType::CEIL, ov::op::PadType::EXPLICIT, false }, }; return paramsMax4D; } -const std::vector& paramsMaxV84D() { - static const std::vector paramsMaxV84D = { - LayerTestsDefinitions::maxPoolV8SpecificParams{ {2, 2}, {2, 2}, {1, 1}, {0, 0}, {0, 0}, - ngraph::element::Type_t::i32, 0, - ngraph::op::RoundingType::CEIL, ngraph::op::PadType::SAME_LOWER }, +const std::vector& paramsMaxV84D() { + static const std::vector paramsMaxV84D = { + maxPoolV8SpecificParams{ {2, 2}, {2, 2}, {1, 1}, {0, 0}, {0, 0}, + ov::element::Type_t::i32, 0, + ov::op::RoundingType::CEIL, ov::op::PadType::SAME_LOWER }, }; return paramsMaxV84D; } @@ -371,71 +369,71 @@ const std::vector& inputShapes5D() { return inputShapes5D; } -const std::vector& paramsMaxV85D() { - static const std::vector paramsMaxV85D = { - LayerTestsDefinitions::maxPoolV8SpecificParams{ {2, 2, 2}, {1, 1, 1}, {1, 1, 1}, {0, 0, 0}, {0, 0, 0}, - ngraph::element::Type_t::i32, 0, - ngraph::op::RoundingType::CEIL, ngraph::op::PadType::SAME_LOWER }, +const std::vector& paramsMaxV85D() { + static const std::vector paramsMaxV85D = { + maxPoolV8SpecificParams{ {2, 2, 2}, {1, 1, 1}, {1, 1, 1}, {0, 0, 0}, {0, 0, 0}, + ov::element::Type_t::i32, 0, + ov::op::RoundingType::CEIL, ov::op::PadType::SAME_LOWER }, }; return paramsMaxV85D; } -const std::vector& paramsAvg4D() { - static const std::vector paramsAvg4D = { - LayerTestsDefinitions::poolSpecificParams{ ngraph::helpers::PoolingTypes::AVG, {2, 2}, {2, 2}, {1, 0}, {0, 0}, - expectedAvgRoundingType(), ngraph::op::PadType::SAME_LOWER, true }, - LayerTestsDefinitions::poolSpecificParams{ ngraph::helpers::PoolingTypes::AVG, {2, 2}, {2, 2}, {1, 0}, {0, 0}, - expectedAvgRoundingType(), ngraph::op::PadType::SAME_UPPER, true }, - LayerTestsDefinitions::poolSpecificParams{ ngraph::helpers::PoolingTypes::AVG, {2, 2}, {2, 2}, {1, 0}, {0, 0}, - expectedAvgRoundingType(), ngraph::op::PadType::SAME_LOWER, false }, - LayerTestsDefinitions::poolSpecificParams{ ngraph::helpers::PoolingTypes::AVG, {2, 2}, {2, 2}, {1, 0}, {0, 0}, - expectedAvgRoundingType(), ngraph::op::PadType::SAME_UPPER, false }, - LayerTestsDefinitions::poolSpecificParams{ ngraph::helpers::PoolingTypes::AVG, {2, 2}, {2, 2}, {0, 0}, {0, 0}, - expectedAvgRoundingType(), ngraph::op::PadType::EXPLICIT, true }, - LayerTestsDefinitions::poolSpecificParams{ ngraph::helpers::PoolingTypes::AVG, {4, 4}, {4, 4}, {2, 2}, {2, 2}, - expectedAvgRoundingType(), ngraph::op::PadType::EXPLICIT, true }, +const std::vector& paramsAvg4D() { + static const std::vector paramsAvg4D = { + poolSpecificParams{ utils::PoolingTypes::AVG, {2, 2}, {2, 2}, {1, 0}, {0, 0}, + expectedAvgRoundingType(), ov::op::PadType::SAME_LOWER, true }, + poolSpecificParams{ utils::PoolingTypes::AVG, {2, 2}, {2, 2}, {1, 0}, {0, 0}, + expectedAvgRoundingType(), ov::op::PadType::SAME_UPPER, true }, + poolSpecificParams{ utils::PoolingTypes::AVG, {2, 2}, {2, 2}, {1, 0}, {0, 0}, + expectedAvgRoundingType(), ov::op::PadType::SAME_LOWER, false }, + poolSpecificParams{ utils::PoolingTypes::AVG, {2, 2}, {2, 2}, {1, 0}, {0, 0}, + expectedAvgRoundingType(), ov::op::PadType::SAME_UPPER, false }, + poolSpecificParams{ utils::PoolingTypes::AVG, {2, 2}, {2, 2}, {0, 0}, {0, 0}, + expectedAvgRoundingType(), ov::op::PadType::EXPLICIT, true }, + poolSpecificParams{ utils::PoolingTypes::AVG, {4, 4}, {4, 4}, {2, 2}, {2, 2}, + expectedAvgRoundingType(), ov::op::PadType::EXPLICIT, true }, }; return paramsAvg4D; } -const std::vector& paramsAvg5D() { - static const std::vector paramsAvg5D = { - LayerTestsDefinitions::poolSpecificParams{ ngraph::helpers::PoolingTypes::AVG, {2, 2, 2}, {2, 2, 2}, {1, 0, 0}, {0, 0, 0}, - expectedAvgRoundingType(), ngraph::op::PadType::SAME_LOWER, true }, - LayerTestsDefinitions::poolSpecificParams{ ngraph::helpers::PoolingTypes::AVG, {2, 2, 2}, {2, 2, 2}, {1, 0, 0}, {0, 0, 0}, - expectedAvgRoundingType(), ngraph::op::PadType::SAME_UPPER, true }, - LayerTestsDefinitions::poolSpecificParams{ ngraph::helpers::PoolingTypes::AVG, {2, 2, 2}, {2, 2, 2}, {1, 0, 0}, {0, 0, 0}, - expectedAvgRoundingType(), ngraph::op::PadType::SAME_LOWER, false }, - LayerTestsDefinitions::poolSpecificParams{ ngraph::helpers::PoolingTypes::AVG, {2, 2, 2}, {2, 2, 2}, {1, 0, 0}, {0, 0, 0}, - expectedAvgRoundingType(), ngraph::op::PadType::SAME_UPPER, false }, - LayerTestsDefinitions::poolSpecificParams{ ngraph::helpers::PoolingTypes::AVG, {2, 2, 2}, {2, 2, 2}, {0, 0, 0}, {0, 0, 0}, - expectedAvgRoundingType(), ngraph::op::PadType::EXPLICIT, true }, - LayerTestsDefinitions::poolSpecificParams{ ngraph::helpers::PoolingTypes::AVG, {3, 3, 3}, {3, 3, 3}, {1, 1, 1}, {0, 0, 0}, - expectedAvgRoundingType(), ngraph::op::PadType::EXPLICIT, true }, - LayerTestsDefinitions::poolSpecificParams{ ngraph::helpers::PoolingTypes::AVG, {4, 4, 4}, {2, 2, 2}, {2, 2, 2}, {2, 2, 2}, - expectedAvgRoundingType(), ngraph::op::PadType::EXPLICIT, true }, +const std::vector& paramsAvg5D() { + static const std::vector paramsAvg5D = { + poolSpecificParams{ utils::PoolingTypes::AVG, {2, 2, 2}, {2, 2, 2}, {1, 0, 0}, {0, 0, 0}, + expectedAvgRoundingType(), ov::op::PadType::SAME_LOWER, true }, + poolSpecificParams{ utils::PoolingTypes::AVG, {2, 2, 2}, {2, 2, 2}, {1, 0, 0}, {0, 0, 0}, + expectedAvgRoundingType(), ov::op::PadType::SAME_UPPER, true }, + poolSpecificParams{ utils::PoolingTypes::AVG, {2, 2, 2}, {2, 2, 2}, {1, 0, 0}, {0, 0, 0}, + expectedAvgRoundingType(), ov::op::PadType::SAME_LOWER, false }, + poolSpecificParams{ utils::PoolingTypes::AVG, {2, 2, 2}, {2, 2, 2}, {1, 0, 0}, {0, 0, 0}, + expectedAvgRoundingType(), ov::op::PadType::SAME_UPPER, false }, + poolSpecificParams{ utils::PoolingTypes::AVG, {2, 2, 2}, {2, 2, 2}, {0, 0, 0}, {0, 0, 0}, + expectedAvgRoundingType(), ov::op::PadType::EXPLICIT, true }, + poolSpecificParams{ utils::PoolingTypes::AVG, {3, 3, 3}, {3, 3, 3}, {1, 1, 1}, {0, 0, 0}, + expectedAvgRoundingType(), ov::op::PadType::EXPLICIT, true }, + poolSpecificParams{ utils::PoolingTypes::AVG, {4, 4, 4}, {2, 2, 2}, {2, 2, 2}, {2, 2, 2}, + expectedAvgRoundingType(), ov::op::PadType::EXPLICIT, true }, }; return paramsAvg5D; } -const std::vector& paramsMax5D() { - static const std::vector paramsMax5D = { - LayerTestsDefinitions::poolSpecificParams{ ngraph::helpers::PoolingTypes::MAX, {2, 2, 2}, {1, 1, 1}, {0, 0, 0}, {0, 0, 0}, - ngraph::op::RoundingType::CEIL, ngraph::op::PadType::SAME_LOWER, false }, - LayerTestsDefinitions::poolSpecificParams{ ngraph::helpers::PoolingTypes::MAX, {2, 2, 2}, {1, 1, 1}, {0, 0, 0}, {0, 0, 0}, - ngraph::op::RoundingType::CEIL, ngraph::op::PadType::SAME_UPPER, false }, - LayerTestsDefinitions::poolSpecificParams{ ngraph::helpers::PoolingTypes::MAX, {2, 2, 2}, {1, 1, 1}, {1, 1, 1}, {1, 1, 1}, - ngraph::op::RoundingType::CEIL, ngraph::op::PadType::EXPLICIT, false }, - LayerTestsDefinitions::poolSpecificParams{ ngraph::helpers::PoolingTypes::MAX, {3, 3, 3}, {2, 2, 2}, {1, 1, 1}, {1, 1, 1}, - ngraph::op::RoundingType::CEIL, ngraph::op::PadType::EXPLICIT, false }, +const std::vector& paramsMax5D() { + static const std::vector paramsMax5D = { + poolSpecificParams{ utils::PoolingTypes::MAX, {2, 2, 2}, {1, 1, 1}, {0, 0, 0}, {0, 0, 0}, + ov::op::RoundingType::CEIL, ov::op::PadType::SAME_LOWER, false }, + poolSpecificParams{ utils::PoolingTypes::MAX, {2, 2, 2}, {1, 1, 1}, {0, 0, 0}, {0, 0, 0}, + ov::op::RoundingType::CEIL, ov::op::PadType::SAME_UPPER, false }, + poolSpecificParams{ utils::PoolingTypes::MAX, {2, 2, 2}, {1, 1, 1}, {1, 1, 1}, {1, 1, 1}, + ov::op::RoundingType::CEIL, ov::op::PadType::EXPLICIT, false }, + poolSpecificParams{ utils::PoolingTypes::MAX, {3, 3, 3}, {2, 2, 2}, {1, 1, 1}, {1, 1, 1}, + ov::op::RoundingType::CEIL, ov::op::PadType::EXPLICIT, false }, }; return paramsMax5D; } -const std::vector& paramsAvg4D_Large() { - static const std::vector paramsAvg4D_Large = { - LayerTestsDefinitions::poolSpecificParams{ ngraph::helpers::PoolingTypes::AVG, {65, 65}, {65, 65}, {0, 0}, {0, 0}, - ngraph::op::RoundingType::FLOOR, ngraph::op::PadType::VALID, true }, +const std::vector& paramsAvg4D_Large() { + static const std::vector paramsAvg4D_Large = { + poolSpecificParams{ utils::PoolingTypes::AVG, {65, 65}, {65, 65}, {0, 0}, {0, 0}, + ov::op::RoundingType::FLOOR, ov::op::PadType::VALID, true }, }; return paramsAvg4D_Large; } @@ -458,4 +456,5 @@ const std::vector& inputShapes4D_Large() { } // namespace Pooling -} // namespace CPULayerTestsDefinitions \ No newline at end of file +} // namespace test +} // namespace ov \ No newline at end of file diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/pooling.hpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/pooling.hpp index ecf12a0360de1f..505019bb763b60 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/pooling.hpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/pooling.hpp @@ -9,20 +9,21 @@ #include "test_utils/fusing_test_utils.hpp" #include "shared_test_classes/single_layer/pooling.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" +#include "shared_test_classes/single_op/pooling.hpp" -using namespace ov::test; using namespace CPUTestUtils; -namespace CPULayerTestsDefinitions { +namespace ov { +namespace test { -using poolLayerCpuTestParamsSet = std::tuple; -using maxPoolV8LayerCpuTestParamsSet = std::tuple; @@ -47,23 +48,24 @@ class MaxPoolingV8LayerCPUTest : public testing::WithParamInterface& inpOutPrecision(); -const ngraph::op::RoundingType expectedAvgRoundingType(); +const ov::op::RoundingType expectedAvgRoundingType(); -const std::vector& paramsMax3D(); -const std::vector& paramsAvg3D(); -const std::vector& paramsMax4D(); +const std::vector& paramsMax3D(); +const std::vector& paramsAvg3D(); +const std::vector& paramsMax4D(); -const std::vector& paramsMaxV84D(); -const std::vector& paramsMaxV85D(); +const std::vector& paramsMaxV84D(); +const std::vector& paramsMaxV85D(); const std::vector& inputShapes3D(); const std::vector& inputShapes4D(); const std::vector& inputShapes4D_Large(); const std::vector& inputShapes5D(); -const std::vector& paramsAvg4D(); -const std::vector& paramsAvg4D_Large(); -const std::vector& paramsAvg5D(); -const std::vector& paramsMax5D(); -} // namespace Pooling -} // namespace CPULayerTestsDefinitions \ No newline at end of file +const std::vector& paramsAvg4D(); +const std::vector& paramsAvg4D_Large(); +const std::vector& paramsAvg5D(); +const std::vector& paramsMax5D(); +} // namespace Pooling +} // namespace test +} // namespace ov \ No newline at end of file diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/random_uniform.cpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/random_uniform.cpp index 282ebef47ba9bb..bc34f3234cffb3 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/random_uniform.cpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/random_uniform.cpp @@ -6,9 +6,9 @@ #include "ov_models/builders.hpp" using namespace CPUTestUtils; -using namespace ov::test; -namespace CPULayerTestsDefinitions { +namespace ov { +namespace test { std::string RandomUniformLayerTestCPU::getTestCaseName(const testing::TestParamInfo& obj) { const auto& out_shape = std::get<0>(obj.param); @@ -71,13 +71,13 @@ void RandomUniformLayerTestCPU::SetUp() { } else if (output_prc == ElementType::f64) { updateSelectedType(getPrimitiveType(), ElementType::f32, configuration); } else if (output_prc == ElementType::f16) { - if (InferenceEngine::with_cpu_x86_avx512_core_fp16()) { + if (ov::with_cpu_x86_avx512_core_fp16()) { updateSelectedType(getPrimitiveType(), ElementType::f16, configuration); } else { updateSelectedType(getPrimitiveType(), ElementType::f32, configuration); } } else if (output_prc == ElementType::bf16) { - if (InferenceEngine::with_cpu_x86_bfloat16()) { + if (ov::with_cpu_x86_bfloat16()) { updateSelectedType(getPrimitiveType(), ElementType::bf16, configuration); } else { updateSelectedType("ref_any", ElementType::bf16, configuration); @@ -124,10 +124,10 @@ void RandomUniformLayerTestCPU::SetUp() { function = std::make_shared(results, in_params, "RandomUniformLayerTestCPU"); // todo: issue: 123320 - if (!InferenceEngine::with_cpu_x86_avx512_core()) { + if (!ov::with_cpu_x86_avx512_core()) { convert_precisions.insert({ ov::element::bf16, ov::element::f32 }); } - if (!InferenceEngine::with_cpu_x86_avx512_core_fp16()) { + if (!ov::with_cpu_x86_avx512_core_fp16()) { convert_precisions.insert({ ov::element::f16, ov::element::f32 }); } } @@ -257,4 +257,5 @@ TEST_P(RandomUniformLayerTestCPU, CompareWithRefs) { CheckPluginRelatedResults(compiledModel, "RandomUniform"); } -} // namespace CPULayerTestsDefinitions +} // namespace test +} // namespace ov diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/random_uniform.hpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/random_uniform.hpp index a7d5dcecc42187..2d32426cb0a782 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/random_uniform.hpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/random_uniform.hpp @@ -7,7 +7,8 @@ #include "shared_test_classes/base/ov_subgraph.hpp" #include "test_utils/cpu_test_utils.hpp" -namespace CPULayerTestsDefinitions { +namespace ov { +namespace test { typedef std::tuple< ov::Shape, // Output shapes @@ -48,4 +49,5 @@ class RandomUniformLayerTestCPU : public testing::WithParamInterface obj) { basicReduceParams basicParams; @@ -25,7 +24,7 @@ std::string ReduceCPULayerTest::getTestCaseName(testing::TestParamInfo axes; ov::test::utils::OpType opType; bool keepDims; - ngraph::helpers::ReductionType reductionType; + utils::ReductionType reductionType; ElementType netPrecision, inPrc, outPrc; std::vector inputShapes; @@ -110,10 +109,10 @@ void ReduceCPULayerTest::SetUp() { default: FAIL() << "Reduce op doesn't support operation type: " << opType; } - auto reductionAxesNode = std::dynamic_pointer_cast( - std::make_shared(ngraph::element::Type_t::i64, ngraph::Shape(shapeAxes), axes)); + 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 auto reduce = utils::make_reduce(params[0], reductionAxesNode, keepDims, reductionType); // hybrid layouts if (inFmts.size() != 0 && outFmts.size() == 0) { @@ -140,13 +139,13 @@ void ReduceCPULayerTest::SetUp() { function = makeNgraphFunction(netPrecision, params, reduce, "Reduce"); } -void ReduceCPULayerTest::generate_inputs(const std::vector& targetInputStaticShapes) { +void ReduceCPULayerTest::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 (reductionType == ngraph::helpers::ReductionType::Prod) { + if (reductionType == utils::ReductionType::Prod) { tensor = ov::test::utils::create_and_fill_tensor(funcInput.get_element_type(), targetInputStaticShapes[i], 10, @@ -157,12 +156,12 @@ void ReduceCPULayerTest::generate_inputs(const std::vector& targe rawBlobDataPtr[i] /= 10.f; } } else if (netPrecision == ElementType::f16) { - auto *rawBlobDataPtr = static_cast(tensor.data()); + auto *rawBlobDataPtr = static_cast(tensor.data()); for (size_t i = 0; i < tensor.get_size(); ++i) { rawBlobDataPtr[i] /= 10.f; } } else if (netPrecision == ElementType::bf16) { - auto* rawBlobDataPtr = static_cast(tensor.data()); + auto* rawBlobDataPtr = static_cast(tensor.data()); for (size_t i = 0; i < tensor.get_size(); ++i) { rawBlobDataPtr[i] /= 10.f; } @@ -225,15 +224,15 @@ const std::vector& opTypes() { return opTypes; } -const std::vector& reductionTypes() { - static const std::vector reductionTypes = { - ngraph::helpers::ReductionType::Mean, - ngraph::helpers::ReductionType::Max, - ngraph::helpers::ReductionType::Sum, - ngraph::helpers::ReductionType::Min, - ngraph::helpers::ReductionType::Prod, - ngraph::helpers::ReductionType::L1, - ngraph::helpers::ReductionType::L2, +const std::vector& reductionTypes() { + static const std::vector reductionTypes = { + utils::ReductionType::Mean, + utils::ReductionType::Max, + utils::ReductionType::Sum, + utils::ReductionType::Min, + utils::ReductionType::Prod, + utils::ReductionType::L1, + utils::ReductionType::L2, }; return reductionTypes; } @@ -262,15 +261,16 @@ const std::vector> additionalConfigFP32 return additionalConfig; } -const std::vector& reductionTypesInt32() { - static const std::vector reductionTypesInt32 = { - ngraph::helpers::ReductionType::Sum, - ngraph::helpers::ReductionType::Min, - ngraph::helpers::ReductionType::Max, - ngraph::helpers::ReductionType::L1, +const std::vector& reductionTypesInt32() { + static const std::vector reductionTypesInt32 = { + utils::ReductionType::Sum, + utils::ReductionType::Min, + utils::ReductionType::Max, + utils::ReductionType::L1, }; return reductionTypesInt32; } } // namespace Reduce -} // namespace CPULayerTestsDefinitions +} // namespace test +} // namespace ov diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/reduce.hpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/reduce.hpp index 31022372a8234e..6d9913d22f7969 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/reduce.hpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/reduce.hpp @@ -5,26 +5,26 @@ #pragma once #include "shared_test_classes/base/ov_subgraph.hpp" -#include "ov_models/builders.hpp" #include "test_utils/cpu_test_utils.hpp" -#include +#include "common_test_utils/ov_tensor_utils.hpp" #include "test_utils/fusing_test_utils.hpp" using namespace CPUTestUtils; using namespace ov::test; -namespace CPULayerTestsDefinitions { +namespace ov { +namespace test { -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 - ElementType, // Net precision - ElementType, // Input precision - ElementType, // Output precision - std::vector // Input shapes -> basicReduceParams; +typedef std::tuple, // Axis to reduce order + ov::test::utils::OpType, // Scalar or vector type axis + bool, // Keep dims + utils::ReductionType, // Reduce operation type + ElementType, // Net precision + ElementType, // Input precision + ElementType, // Output precision + std::vector // Input shapes + > + basicReduceParams; typedef std::tuple< basicReduceParams, @@ -38,10 +38,10 @@ class ReduceCPULayerTest : public testing::WithParamInterface obj); protected: void SetUp() override; - void generate_inputs(const std::vector& targetInputStaticShapes) override; + void generate_inputs(const std::vector& targetInputStaticShapes) override; private: - ngraph::helpers::ReductionType reductionType; + utils::ReductionType reductionType; ElementType netPrecision; }; @@ -51,11 +51,12 @@ const std::vector& keepDims(); const std::vector>& axes(); const std::vector>& axesND(); const std::vector& opTypes(); -const std::vector& reductionTypes(); +const std::vector& reductionTypes(); const std::vector& inpOutPrc(); const std::vector> additionalConfig(); const std::vector> additionalConfigFP32(); -const std::vector& reductionTypesInt32(); +const std::vector& reductionTypesInt32(); -} // namespace Reduce -} // namespace CPULayerTestsDefinitions +} // namespace Reduce +} // namespace test +} // namespace ov diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/scaled_attn.cpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/scaled_attn.cpp index 644f94bc2bf326..46513a36016620 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/scaled_attn.cpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/scaled_attn.cpp @@ -2,18 +2,17 @@ // SPDX-License-Identifier: Apache-2.0 // -#include -#include #include "scaled_attn.hpp" + #include "gtest/gtest.h" +#include "openvino/opsets/opset13.hpp" #include "test_utils/cpu_test_utils.hpp" +#include "transformations/op_conversions/scaled_dot_product_attention_decomposition.hpp" -using namespace InferenceEngine; using namespace CPUTestUtils; -using namespace ngraph::helpers; -using namespace ov::test; -namespace CPULayerTestsDefinitions { +namespace ov { +namespace test { std::string ScaledAttnLayerCPUTest::getTestCaseName(const testing::TestParamInfo& obj) { CPUSpecificParams cpuParams; @@ -132,4 +131,5 @@ TEST_P(ScaledAttnLayerCPUTest, CompareWithRefs) { namespace ScaledAttn { } // namespace ScaledAttn -} // namespace CPULayerTestsDefinitions +} // namespace test +} // namespace ov diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/scaled_attn.hpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/scaled_attn.hpp index 0a11d159b50b62..9480f897b6b3c7 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/scaled_attn.hpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/scaled_attn.hpp @@ -2,8 +2,6 @@ // SPDX-License-Identifier: Apache-2.0 // -#include - #include "shared_test_classes/base/ov_subgraph.hpp" #include "test_utils/cpu_test_utils.hpp" @@ -11,7 +9,8 @@ using namespace InferenceEngine; using namespace CPUTestUtils; using namespace ov::test; -namespace CPULayerTestsDefinitions { +namespace ov { +namespace test { typedef std::tuple, // shape @@ -36,4 +35,5 @@ class ScaledAttnLayerCPUTest : public testing::WithParamInterface& obj) { CPUSpecificParams cpuParams; @@ -56,7 +54,7 @@ void SoftMaxLayerCPUTest::SetUp() { for (auto&& shape : inputDynamicShapes) params.push_back(std::make_shared(inType, shape)); - const auto softMax = std::make_shared(params.at(0), config.axis); + const auto softMax = std::make_shared(params.at(0), config.axis); function = makeNgraphFunction(inType, params, softMax, "SoftMax"); } @@ -69,4 +67,5 @@ TEST_P(SoftMaxLayerCPUTest, CompareWithRefs) { namespace SoftMax { } // namespace SoftMax -} // namespace CPULayerTestsDefinitions +} // namespace test +} // namespace ov diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/softmax.hpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/softmax.hpp index 06e03d79a493a1..f31bc35b97b712 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/softmax.hpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/softmax.hpp @@ -2,16 +2,13 @@ // SPDX-License-Identifier: Apache-2.0 // -#include - #include "shared_test_classes/base/ov_subgraph.hpp" #include "test_utils/cpu_test_utils.hpp" -using namespace InferenceEngine; using namespace CPUTestUtils; -using namespace ov::test; -namespace CPULayerTestsDefinitions { +namespace ov { +namespace test { struct SoftMaxConfig { ov::test::InputShape inputShape; @@ -38,4 +35,5 @@ namespace SoftMax { } // namespace SoftMax -} // namespace CPULayerTestsDefinitions +} // namespace test +} // namespace ov diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/transpose.cpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/transpose.cpp index 029e97a2eae21d..daff97d5077515 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/transpose.cpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/transpose.cpp @@ -7,19 +7,17 @@ #include "gtest/gtest.h" #include "test_utils/cpu_test_utils.hpp" -using namespace InferenceEngine; using namespace CPUTestUtils; -using namespace ngraph::helpers; -using namespace ov::test; -namespace CPULayerTestsDefinitions { +namespace ov { +namespace test { std::string TransposeLayerCPUTest::getTestCaseName(testing::TestParamInfo obj) { - Precision netPrecision; + ov::element::Type netPrecision; InputShape inputShapes; std::vector inputOrder; std::string targetDevice; CPUSpecificParams cpuParams; - std::map additionalConfig; + ov::AnyMap additionalConfig; std::tie(inputShapes, inputOrder, netPrecision, targetDevice, additionalConfig, cpuParams) = obj.param; std::ostringstream result; @@ -30,12 +28,12 @@ std::string TransposeLayerCPUTest::getTestCaseName(testing::TestParamInfo(results, ov::ParameterVector{params}, "TransposeLayerCPUTest"); + functionRefs = ov::clone_model(*function); } TEST_P(TransposeLayerCPUTest, CompareWithRefs) { @@ -77,8 +75,8 @@ TEST_P(TransposeLayerCPUTest, CompareWithRefs) { } namespace Transpose { -const std::vector& netPrecisionsPerChannels() { - static const std::vector netPrecisionsPerChannels = {Precision::I8, Precision::FP32}; +const std::vector& netPrecisionsPerChannels() { + static const std::vector netPrecisionsPerChannels = {ov::element::i8, ov::element::f32}; return netPrecisionsPerChannels; } @@ -123,4 +121,5 @@ const std::vector>& inputOrder4D() { return inputOrder4D; } } // namespace Transpose -} // namespace CPULayerTestsDefinitions +} // namespace test +} // namespace ov diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/transpose.hpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/transpose.hpp index 5b8300106c83df..f11f84f89a7093 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/transpose.hpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/transpose.hpp @@ -5,24 +5,22 @@ #pragma once #include "shared_test_classes/single_layer/transpose.hpp" -#include "ov_models/builders.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" #include "test_utils/cpu_test_utils.hpp" #include "gtest/gtest.h" -using namespace InferenceEngine; using namespace CPUTestUtils; -using namespace ov::test; -namespace CPULayerTestsDefinitions { -typedef std::tuple< - InputShape, // Input shapes - std::vector, // Input order - InferenceEngine::Precision, // Net precision - std::string, // Target device name - std::map, // Additional network configuration - CPUSpecificParams> TransposeLayerCPUTestParamSet; +namespace ov { +namespace test { +typedef std::tuple, // Input order + ov::element::Type, // Net precision + std::string, // Target device name + ov::AnyMap, // Additional network configuration + CPUSpecificParams> + TransposeLayerCPUTestParamSet; class TransposeLayerCPUTest : public testing::WithParamInterface, public ov::test::SubgraphBaseTest, public CPUTestsBase { @@ -33,10 +31,11 @@ class TransposeLayerCPUTest : public testing::WithParamInterface& netPrecisionsPerChannels(); + const std::vector& netPrecisionsPerChannels(); const std::vector& dynamicInputShapes4DC16(); const std::vector& dynamicInputShapes4DC32(); const std::vector& dynamicInputShapes4D(); const std::vector>& inputOrder4D(); -} // namespace Transpose -} // namespace CPULayerTestsDefinitions \ No newline at end of file +} // namespace Transpose +} // namespace test +} // namespace ov \ No newline at end of file diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/concat.cpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/concat.cpp index e805d802abeb7d..0a71bfe87ead9a 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/concat.cpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/concat.cpp @@ -2,24 +2,24 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "shared_test_classes/base/ov_subgraph.hpp" #include "ov_models/builders.hpp" +#include "shared_test_classes/base/ov_subgraph.hpp" #include "test_utils/cpu_test_utils.hpp" -using namespace ov::test; using namespace CPUTestUtils; -namespace CPULayerTestsDefinitions { +namespace ov { +namespace test { -typedef std::tuple< - size_t, // Concat axis - std::vector, // Input shapes - ElementType, // Network precision - CPUSpecificParams -> concatCPUTestParams; +typedef std::tuple, // Input shapes + ElementType, // Network precision + CPUSpecificParams> + concatCPUTestParams; class ConcatLayerCPUTest : public testing::WithParamInterface, - virtual public SubgraphBaseTest, public CPUTestsBase { + virtual public SubgraphBaseTest, + public CPUTestsBase { public: static std::string getTestCaseName(testing::TestParamInfo obj) { int axis; @@ -49,7 +49,7 @@ class ConcatLayerCPUTest : public testing::WithParamInterface &expected, const std::vector &actual) override { + void compare(const std::vector& expected, const std::vector& actual) override { if (actual.front().get_size() == 0) { ASSERT_EQ(0, expected.front().get_size()); for (const auto& shape : targetStaticShapes[inferNum]) { @@ -74,7 +74,7 @@ class ConcatLayerCPUTest : public testing::WithParamInterfaceGetParam(); std::tie(inFmts, outFmts, priority, selectedType) = cpuParams; - selectedType += std::string("_") + InferenceEngine::details::convertPrecision(netPrecision).name(); + selectedType += std::string("_") + ov::element::Type(netPrecision).get_type_name(); init_input_shapes(inputShape); @@ -85,7 +85,7 @@ class ConcatLayerCPUTest : public testing::WithParamInterface(paramsOuts, axis); + auto concat = std::make_shared(paramsOuts, axis); function = makeNgraphFunction(netPrecision, params, concat, "ConcatCPU"); } @@ -119,615 +119,699 @@ const auto blocked16_4D_ref = CPUSpecificParams{{nChw16c}, {nChw16c}, {}, "ref"} const auto blocked16_5D_ref = CPUSpecificParams{{nCdhw16c}, {nCdhw16c}, {}, "ref"}; // List of precisions natively supported by onednn. -const std::vector netPrecisions = { - ElementType::i8, - ElementType::i32, - ElementType::f32, - ElementType::bf16 -}; - -INSTANTIATE_TEST_SUITE_P(smoke_Concat4D_CPU_Block8_static, ConcatLayerCPUTest, - ::testing::Combine( - ::testing::Values(1, -2, 3), - ::testing::Values(static_shapes_to_test_representation({{2, 16, 3, 5}, {2, 16, 3, 5}})), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(planar_4D_ref, planarChannels_4D, blocked8_4D_ref)), - ConcatLayerCPUTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_Concat4D_CPU_Block16_static, ConcatLayerCPUTest, - ::testing::Combine( - ::testing::Values(1, 2, -1), - ::testing::Values(static_shapes_to_test_representation({{3, 32, 3, 5}, {3, 32, 3, 5}})), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(blocked16_4D_ref)), - ConcatLayerCPUTest::getTestCaseName); +const std::vector netPrecisions = {ElementType::i8, ElementType::i32, ElementType::f32, ElementType::bf16}; + +INSTANTIATE_TEST_SUITE_P(smoke_Concat4D_CPU_Block8_static, + ConcatLayerCPUTest, + ::testing::Combine(::testing::Values(1, -2, 3), + ::testing::Values(static_shapes_to_test_representation({{2, 16, 3, 5}, + {2, 16, 3, 5}})), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(planar_4D_ref, planarChannels_4D, blocked8_4D_ref)), + ConcatLayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_Concat4D_CPU_Block16_static, + ConcatLayerCPUTest, + ::testing::Combine(::testing::Values(1, 2, -1), + ::testing::Values(static_shapes_to_test_representation({{3, 32, 3, 5}, + {3, 32, 3, 5}})), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(blocked16_4D_ref)), + ConcatLayerCPUTest::getTestCaseName); const std::vector> inputShapes4D_Block_axis1 = { - { - // {{dynamic shape}, {{static shape case1}, {static shape case2}, ...} - {{-1, 32, -1, -1}, {{2, 32, 5, 7}, {1, 32, 10, 2}, {3, 32, 1, 8}}}, // input 0 - {{-1, 16, -1, -1}, {{2, 16, 5, 7}, {1, 16, 10, 2}, {3, 16, 1, 8}}}, // input 1 - {{-1, 64, -1, -1}, {{2, 64, 5, 7}, {1, 64, 10, 2}, {3, 64, 1, 8}}} // input 2 - }, - { - {{{1, 5}, 32, {1, 10}, {2, 8}}, {{2, 32, 5, 7}, {1, 32, 10, 2}, {3, 32, 1, 8}}}, - {{{1, 3}, 16, {1, 10}, {2, 8}}, {{2, 16, 5, 7}, {1, 16, 10, 2}, {3, 16, 1, 8}}}, - {{{1, 3}, 64, {1, 10}, {2, 8}}, {{2, 64, 5, 7}, {1, 64, 10, 2}, {3, 64, 1, 8}}} - }, - { - {{{1, 10}, 32, 2, 3}, {{2, 32, 2, 3}, {1, 32, 2, 3}}}, - {{{1, 10}, 16, 2, 3}, {{2, 16, 2, 3}, {1, 16, 2, 3}}}, - {{{1, 10}, 64, 2, 3}, {{2, 64, 2, 3}, {1, 64, 2, 3}}} - }, + { + // {{dynamic shape}, {{static shape case1}, {static shape case2}, ...} + {{-1, 32, -1, -1}, {{2, 32, 5, 7}, {1, 32, 10, 2}, {3, 32, 1, 8}}}, // input 0 + {{-1, 16, -1, -1}, {{2, 16, 5, 7}, {1, 16, 10, 2}, {3, 16, 1, 8}}}, // input 1 + {{-1, 64, -1, -1}, {{2, 64, 5, 7}, {1, 64, 10, 2}, {3, 64, 1, 8}}} // input 2 + }, + {{{{1, 5}, 32, {1, 10}, {2, 8}}, {{2, 32, 5, 7}, {1, 32, 10, 2}, {3, 32, 1, 8}}}, + {{{1, 3}, 16, {1, 10}, {2, 8}}, {{2, 16, 5, 7}, {1, 16, 10, 2}, {3, 16, 1, 8}}}, + {{{1, 3}, 64, {1, 10}, {2, 8}}, {{2, 64, 5, 7}, {1, 64, 10, 2}, {3, 64, 1, 8}}}}, + {{{{1, 10}, 32, 2, 3}, {{2, 32, 2, 3}, {1, 32, 2, 3}}}, + {{{1, 10}, 16, 2, 3}, {{2, 16, 2, 3}, {1, 16, 2, 3}}}, + {{{1, 10}, 64, 2, 3}, {{2, 64, 2, 3}, {1, 64, 2, 3}}}}, }; -INSTANTIATE_TEST_SUITE_P(smoke_Concat4D_CPU_Block_dynamic_axis_1, ConcatLayerCPUTest, - ::testing::Combine( - ::testing::Values(1, -3), - ::testing::ValuesIn(inputShapes4D_Block_axis1), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(blocked8_4D_ref, blocked16_4D_ref)), - ConcatLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_Concat4D_CPU_Block_dynamic_axis_1, + ConcatLayerCPUTest, + ::testing::Combine(::testing::Values(1, -3), + ::testing::ValuesIn(inputShapes4D_Block_axis1), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(blocked8_4D_ref, blocked16_4D_ref)), + ConcatLayerCPUTest::getTestCaseName); const std::vector> inputShapes4D_axis1 = { - { - {{-1, -1, -1, -1}, {{2, 32, 0, 7}, {2, 32, 5, 7}, {2, 32, 5, 7}, {1, 18, 10, 2}, {2, 32, 5, 7}, {3, 8, 1, 8}, {2, 0, 5, 7}}}, - {{-1, -1, -1, -1}, {{2, 16, 0, 7}, {2, 16, 5, 7}, {2, 16, 5, 7}, {1, 5, 10, 2}, {2, 0, 5, 7}, {3, 3, 1, 8}, {2, 16, 5, 7}}}, - {{-1, -1, -1, -1}, {{2, 64, 0, 7}, {2, 64, 5, 7}, {2, 0, 5, 7}, {1, 45, 10, 2}, {2, 64, 5, 7}, {3, 1, 1, 8}, {2, 64, 5, 7}}} - }, - { - {{{1, 3}, {8, 32}, {1, 10}, {2, 8}}, {{2, 32, 5, 7}, {1, 18, 10, 2}, {3, 8, 1, 8}}}, - {{{1, 3}, {3, 16}, {1, 10}, {2, 8}}, {{2, 16, 5, 7}, {1, 5, 10, 2}, {3, 3, 1, 8}}}, - {{{1, 3}, {1, 64}, {1, 10}, {2, 8}}, {{2, 64, 5, 7}, {1, 45, 10, 2}, {3, 1, 1, 8}}} - }, - { - {{{1, 18, 10, 2}}, {{1, 18, 10, 2}, {1, 18, 10, 2}}}, - {{-1, -1, -1, -1}, {{1, 3, 10, 2}, {1, 5, 10, 2}}}, - {{{1, 5, 10, 2}}, {{1, 5, 10, 2}, {1, 5, 10, 2}}} - }, - { - {{{-1, 8, -1, -1}}, {{2, 8, 5, 7}, {1, 8, 10, 2}}}, - {{{-1, 3, -1, -1}}, {{2, 3, 5, 7}, {1, 3, 10, 2}}}, - {{{-1, -1, -1, -1}}, {{2, 16, 5, 7}, {1, 7, 10, 2}}} - } -}; - -INSTANTIATE_TEST_SUITE_P(smoke_Concat4D_CPU_dynamic_axis_1, ConcatLayerCPUTest, - ::testing::Combine( - ::testing::Values(1), - ::testing::ValuesIn(inputShapes4D_axis1), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(planar_4D_ref, planarChannels_4D)), - ConcatLayerCPUTest::getTestCaseName); + {{{-1, -1, -1, -1}, + {{2, 32, 0, 7}, {2, 32, 5, 7}, {2, 32, 5, 7}, {1, 18, 10, 2}, {2, 32, 5, 7}, {3, 8, 1, 8}, {2, 0, 5, 7}}}, + {{-1, -1, -1, -1}, + {{2, 16, 0, 7}, {2, 16, 5, 7}, {2, 16, 5, 7}, {1, 5, 10, 2}, {2, 0, 5, 7}, {3, 3, 1, 8}, {2, 16, 5, 7}}}, + {{-1, -1, -1, -1}, + {{2, 64, 0, 7}, {2, 64, 5, 7}, {2, 0, 5, 7}, {1, 45, 10, 2}, {2, 64, 5, 7}, {3, 1, 1, 8}, {2, 64, 5, 7}}}}, + {{{{1, 3}, {8, 32}, {1, 10}, {2, 8}}, {{2, 32, 5, 7}, {1, 18, 10, 2}, {3, 8, 1, 8}}}, + {{{1, 3}, {3, 16}, {1, 10}, {2, 8}}, {{2, 16, 5, 7}, {1, 5, 10, 2}, {3, 3, 1, 8}}}, + {{{1, 3}, {1, 64}, {1, 10}, {2, 8}}, {{2, 64, 5, 7}, {1, 45, 10, 2}, {3, 1, 1, 8}}}}, + {{{{1, 18, 10, 2}}, {{1, 18, 10, 2}, {1, 18, 10, 2}}}, + {{-1, -1, -1, -1}, {{1, 3, 10, 2}, {1, 5, 10, 2}}}, + {{{1, 5, 10, 2}}, {{1, 5, 10, 2}, {1, 5, 10, 2}}}}, + {{{{-1, 8, -1, -1}}, {{2, 8, 5, 7}, {1, 8, 10, 2}}}, + {{{-1, 3, -1, -1}}, {{2, 3, 5, 7}, {1, 3, 10, 2}}}, + {{{-1, -1, -1, -1}}, {{2, 16, 5, 7}, {1, 7, 10, 2}}}}}; + +INSTANTIATE_TEST_SUITE_P(smoke_Concat4D_CPU_dynamic_axis_1, + ConcatLayerCPUTest, + ::testing::Combine(::testing::Values(1), + ::testing::ValuesIn(inputShapes4D_axis1), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(planar_4D_ref, planarChannels_4D)), + ConcatLayerCPUTest::getTestCaseName); const std::vector> inputShapes4D_Block_axis2 = { - { - {{-1, 16, -1, -1}, {{2, 16, 5, 7}, {1, 16, 16, 2}, {3, 16, 2, 8}}}, - {{-1, 16, -1, -1}, {{2, 16, 1, 7}, {1, 16, 3, 2}, {3, 16, 11, 8}}}, - {{-1, 16, -1, -1}, {{2, 16, 10, 7}, {1, 16, 5, 2}, {3, 16, 1, 8}}}, - }, - { - {{{1, 3}, 16, {2, 16}, {2, 8}}, {{2, 16, 5, 7}, {1, 16, 16, 2}, {3, 16, 2, 8}}}, - {{{1, 3}, 16, {1, 11}, {2, 8}}, {{2, 16, 1, 7}, {1, 16, 3, 2}, {3, 16, 11, 8}}}, - {{{1, 3}, 16, {1, 10}, {2, 8}}, {{2, 16, 10, 7}, {1, 16, 5, 2}, {3, 16, 1, 8}}}, - }, - { - {{{1, 5}, 16, 5, 7}, {{2, 16, 5, 7}, {1, 16, 5, 7}}}, - {{{1, 5}, 16, 1, 7}, {{2, 16, 1, 7}, {1, 16, 1, 7}}}, - {{{1, 5}, 16, 10, 7}, {{2, 16, 10, 7}, {1, 16, 10, 7}}}, - }, + { + {{-1, 16, -1, -1}, {{2, 16, 5, 7}, {1, 16, 16, 2}, {3, 16, 2, 8}}}, + {{-1, 16, -1, -1}, {{2, 16, 1, 7}, {1, 16, 3, 2}, {3, 16, 11, 8}}}, + {{-1, 16, -1, -1}, {{2, 16, 10, 7}, {1, 16, 5, 2}, {3, 16, 1, 8}}}, + }, + { + {{{1, 3}, 16, {2, 16}, {2, 8}}, {{2, 16, 5, 7}, {1, 16, 16, 2}, {3, 16, 2, 8}}}, + {{{1, 3}, 16, {1, 11}, {2, 8}}, {{2, 16, 1, 7}, {1, 16, 3, 2}, {3, 16, 11, 8}}}, + {{{1, 3}, 16, {1, 10}, {2, 8}}, {{2, 16, 10, 7}, {1, 16, 5, 2}, {3, 16, 1, 8}}}, + }, + { + {{{1, 5}, 16, 5, 7}, {{2, 16, 5, 7}, {1, 16, 5, 7}}}, + {{{1, 5}, 16, 1, 7}, {{2, 16, 1, 7}, {1, 16, 1, 7}}}, + {{{1, 5}, 16, 10, 7}, {{2, 16, 10, 7}, {1, 16, 10, 7}}}, + }, }; -INSTANTIATE_TEST_SUITE_P(smoke_Concat4D_CPU_Block_dynamic_axis_2, ConcatLayerCPUTest, - ::testing::Combine( - ::testing::Values(2), - ::testing::ValuesIn(inputShapes4D_Block_axis2), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(blocked8_4D_ref, blocked16_4D_ref)), - ConcatLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_Concat4D_CPU_Block_dynamic_axis_2, + ConcatLayerCPUTest, + ::testing::Combine(::testing::Values(2), + ::testing::ValuesIn(inputShapes4D_Block_axis2), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(blocked8_4D_ref, blocked16_4D_ref)), + ConcatLayerCPUTest::getTestCaseName); const std::vector> inputShapes4D_axis2 = { - { - {{-1, -1, -1, -1}, {{2, 16, 5, 7}, {1, 16, 16, 2}, {3, 16, 2, 8}}}, - {{-1, -1, -1, -1}, {{2, 16, 1, 7}, {1, 16, 3, 2}, {3, 16, 11, 8}}}, - {{-1, -1, -1, -1}, {{2, 16, 10, 7}, {1, 16, 5, 2}, {3, 16, 1, 8}}}, - }, - { - {{{1, 3}, {1, 16}, {2, 16}, {2, 8}}, {{2, 16, 5, 7}, {1, 16, 16, 2}, {3, 16, 2, 8}}}, - {{{1, 3}, {1, 16}, {1, 11}, {2, 8}}, {{2, 16, 1, 7}, {1, 16, 3, 2}, {3, 16, 11, 8}}}, - {{{1, 3}, {1, 16}, {1, 10}, {2, 8}}, {{2, 16, 10, 7}, {1, 16, 5, 2}, {3, 16, 1, 8}}}, - }, + { + {{-1, -1, -1, -1}, {{2, 16, 5, 7}, {1, 16, 16, 2}, {3, 16, 2, 8}}}, + {{-1, -1, -1, -1}, {{2, 16, 1, 7}, {1, 16, 3, 2}, {3, 16, 11, 8}}}, + {{-1, -1, -1, -1}, {{2, 16, 10, 7}, {1, 16, 5, 2}, {3, 16, 1, 8}}}, + }, + { + {{{1, 3}, {1, 16}, {2, 16}, {2, 8}}, {{2, 16, 5, 7}, {1, 16, 16, 2}, {3, 16, 2, 8}}}, + {{{1, 3}, {1, 16}, {1, 11}, {2, 8}}, {{2, 16, 1, 7}, {1, 16, 3, 2}, {3, 16, 11, 8}}}, + {{{1, 3}, {1, 16}, {1, 10}, {2, 8}}, {{2, 16, 10, 7}, {1, 16, 5, 2}, {3, 16, 1, 8}}}, + }, }; -INSTANTIATE_TEST_SUITE_P(smoke_Concat4D_CPU_dynamic_axis_2, ConcatLayerCPUTest, - ::testing::Combine( - ::testing::Values(2, -2), - ::testing::ValuesIn(inputShapes4D_axis2), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(planar_4D_ref, planarChannels_4D)), - ConcatLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_Concat4D_CPU_dynamic_axis_2, + ConcatLayerCPUTest, + ::testing::Combine(::testing::Values(2, -2), + ::testing::ValuesIn(inputShapes4D_axis2), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(planar_4D_ref, planarChannels_4D)), + ConcatLayerCPUTest::getTestCaseName); const std::vector> inputShapes4D_Block_axis3 = { - { - {{-1, 32, -1, -1}, {{2, 32, 4, 5}, {1, 32, 1, 16}, {3, 32, 7, 2}, }}, - {{-1, 32, -1, -1}, {{2, 32, 4, 1}, {1, 32, 1, 3}, {3, 32, 7, 11}}}, - {{-1, 32, -1, -1}, {{2, 32, 4, 10}, {1, 32, 1, 5}, {3, 32, 7, 1}}}, - }, - { - {{{1, 3}, 32, {1, 7}, {2, 16}}, {{2, 32, 4, 5}, {1, 32, 1, 16}, {3, 32, 7, 2}}}, - {{{1, 3}, 32, {1, 7}, {1, 11}}, {{2, 32, 4, 1}, {1, 32, 1, 3}, {3, 32, 7, 11}}}, - {{{1, 3}, 32, {1, 7}, {1, 10}}, {{2, 32, 4, 10}, {1, 32, 1, 5}, {3, 32, 7, 1}}}, - }, + { + {{-1, 32, -1, -1}, + { + {2, 32, 4, 5}, + {1, 32, 1, 16}, + {3, 32, 7, 2}, + }}, + {{-1, 32, -1, -1}, {{2, 32, 4, 1}, {1, 32, 1, 3}, {3, 32, 7, 11}}}, + {{-1, 32, -1, -1}, {{2, 32, 4, 10}, {1, 32, 1, 5}, {3, 32, 7, 1}}}, + }, + { + {{{1, 3}, 32, {1, 7}, {2, 16}}, {{2, 32, 4, 5}, {1, 32, 1, 16}, {3, 32, 7, 2}}}, + {{{1, 3}, 32, {1, 7}, {1, 11}}, {{2, 32, 4, 1}, {1, 32, 1, 3}, {3, 32, 7, 11}}}, + {{{1, 3}, 32, {1, 7}, {1, 10}}, {{2, 32, 4, 10}, {1, 32, 1, 5}, {3, 32, 7, 1}}}, + }, }; -INSTANTIATE_TEST_SUITE_P(smoke_Concat4D_CPU_Block_dynamic_axis_3, ConcatLayerCPUTest, - ::testing::Combine( - ::testing::Values(3), - ::testing::ValuesIn(inputShapes4D_Block_axis3), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(blocked8_4D_ref, blocked16_4D_ref)), - ConcatLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_Concat4D_CPU_Block_dynamic_axis_3, + ConcatLayerCPUTest, + ::testing::Combine(::testing::Values(3), + ::testing::ValuesIn(inputShapes4D_Block_axis3), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(blocked8_4D_ref, blocked16_4D_ref)), + ConcatLayerCPUTest::getTestCaseName); const std::vector> inputShapes4D_axis3 = { - { - {{-1, -1, -1, -1}, {{2, 32, 4, 5}, {1, 32, 1, 16}, {3, 32, 7, 2}}}, - {{-1, -1, -1, -1}, {{2, 32, 4, 1}, {1, 32, 1, 3}, {3, 32, 7, 11}}}, - {{-1, -1, -1, -1}, {{2, 32, 4, 10}, {1, 32, 1, 5}, {3, 32, 7, 1}}}, - }, - { - {{{1, 3}, {1, 32}, {1, 7}, {2, 16}}, {{2, 32, 4, 5}, {1, 32, 1, 16}, {3, 32, 7, 2}}}, - {{{1, 3}, {1, 32}, {1, 7}, {1, 11}}, {{2, 32, 4, 1}, {1, 32, 1, 3}, {3, 32, 7, 11}}}, - {{{1, 3}, {1, 32}, {1, 7}, {1, 10}}, {{2, 32, 4, 10}, {1, 32, 1, 5}, {3, 32, 7, 1}}}, - }, - { - {{{1, 3}, 32, 4, 5}, {{1, 32, 4, 5}, {2, 32, 4, 5}}}, - {{{1, 3}, 32, 4, 1}, {{1, 32, 4, 1}, {2, 32, 4, 1}}}, - {{{1, 3}, 32, 4, 10}, {{1, 32, 4, 10}, {2, 32, 4, 10}}}, - }, + { + {{-1, -1, -1, -1}, {{2, 32, 4, 5}, {1, 32, 1, 16}, {3, 32, 7, 2}}}, + {{-1, -1, -1, -1}, {{2, 32, 4, 1}, {1, 32, 1, 3}, {3, 32, 7, 11}}}, + {{-1, -1, -1, -1}, {{2, 32, 4, 10}, {1, 32, 1, 5}, {3, 32, 7, 1}}}, + }, + { + {{{1, 3}, {1, 32}, {1, 7}, {2, 16}}, {{2, 32, 4, 5}, {1, 32, 1, 16}, {3, 32, 7, 2}}}, + {{{1, 3}, {1, 32}, {1, 7}, {1, 11}}, {{2, 32, 4, 1}, {1, 32, 1, 3}, {3, 32, 7, 11}}}, + {{{1, 3}, {1, 32}, {1, 7}, {1, 10}}, {{2, 32, 4, 10}, {1, 32, 1, 5}, {3, 32, 7, 1}}}, + }, + { + {{{1, 3}, 32, 4, 5}, {{1, 32, 4, 5}, {2, 32, 4, 5}}}, + {{{1, 3}, 32, 4, 1}, {{1, 32, 4, 1}, {2, 32, 4, 1}}}, + {{{1, 3}, 32, 4, 10}, {{1, 32, 4, 10}, {2, 32, 4, 10}}}, + }, }; -INSTANTIATE_TEST_SUITE_P(smoke_Concat4D_CPU_dynamic_axis_3, ConcatLayerCPUTest, - ::testing::Combine( - ::testing::Values(3, -1), - ::testing::ValuesIn(inputShapes4D_axis3), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(planar_4D_ref, planarChannels_4D)), - ConcatLayerCPUTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_Concat5D_CPU_Block8_static, ConcatLayerCPUTest, - ::testing::Combine( - ::testing::Values(2, 3, -2), - ::testing::Values(static_shapes_to_test_representation({{2, 16, 3, 5, 7}, {2, 16, 3, 5, 7}})), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(planar_5D_ref, planarChannels_5D, blocked8_5D_ref)), - ConcatLayerCPUTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_Concat5D_CPU_Block16_static, ConcatLayerCPUTest, - ::testing::Combine( - ::testing::Values(2, 3, 4), - ::testing::Values(static_shapes_to_test_representation({{2, 32, 3, 5, 7}, {2, 32, 3, 5, 7}})), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(blocked16_5D_ref)), - ConcatLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_Concat4D_CPU_dynamic_axis_3, + ConcatLayerCPUTest, + ::testing::Combine(::testing::Values(3, -1), + ::testing::ValuesIn(inputShapes4D_axis3), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(planar_4D_ref, planarChannels_4D)), + ConcatLayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_Concat5D_CPU_Block8_static, + ConcatLayerCPUTest, + ::testing::Combine(::testing::Values(2, 3, -2), + ::testing::Values(static_shapes_to_test_representation({{2, 16, 3, 5, 7}, + {2, 16, 3, 5, 7}})), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(planar_5D_ref, planarChannels_5D, blocked8_5D_ref)), + ConcatLayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_Concat5D_CPU_Block16_static, + ConcatLayerCPUTest, + ::testing::Combine(::testing::Values(2, 3, 4), + ::testing::Values(static_shapes_to_test_representation({{2, 32, 3, 5, 7}, + {2, 32, 3, 5, 7}})), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(blocked16_5D_ref)), + ConcatLayerCPUTest::getTestCaseName); const std::vector> inputShapes5D_Block_axis1 = { - { - {{-1, 32, -1, -1, -1}, {{2, 32, 5, 7, 6}, {1, 32, 10, 2, 8}, {3, 32, 1, 8, 10}}}, - {{-1, 16, -1, -1, -1}, {{2, 16, 5, 7, 6}, {1, 16, 10, 2, 8}, {3, 16, 1, 8, 10}}}, - {{-1, 64, -1, -1, -1}, {{2, 64, 5, 7, 6}, {1, 64, 10, 2, 8}, {3, 64, 1, 8, 10}}}, - }, - { - {{{1, 3}, 32, {1, 10}, {2, 8}, {6, 10}}, {{2, 32, 5, 7, 6}, {1, 32, 10, 2, 8}, {3, 32, 1, 8, 10}}}, - {{{1, 3}, 16, {1, 10}, {2, 8}, {6, 10}}, {{2, 16, 5, 7, 6}, {1, 16, 10, 2, 8}, {3, 16, 1, 8, 10}}}, - {{{1, 3}, 64, {1, 10}, {2, 8}, {6, 10}}, {{2, 64, 5, 7, 6}, {1, 64, 10, 2, 8}, {3, 64, 1, 8, 10}}}, - }, + { + {{-1, 32, -1, -1, -1}, {{2, 32, 5, 7, 6}, {1, 32, 10, 2, 8}, {3, 32, 1, 8, 10}}}, + {{-1, 16, -1, -1, -1}, {{2, 16, 5, 7, 6}, {1, 16, 10, 2, 8}, {3, 16, 1, 8, 10}}}, + {{-1, 64, -1, -1, -1}, {{2, 64, 5, 7, 6}, {1, 64, 10, 2, 8}, {3, 64, 1, 8, 10}}}, + }, + { + {{{1, 3}, 32, {1, 10}, {2, 8}, {6, 10}}, {{2, 32, 5, 7, 6}, {1, 32, 10, 2, 8}, {3, 32, 1, 8, 10}}}, + {{{1, 3}, 16, {1, 10}, {2, 8}, {6, 10}}, {{2, 16, 5, 7, 6}, {1, 16, 10, 2, 8}, {3, 16, 1, 8, 10}}}, + {{{1, 3}, 64, {1, 10}, {2, 8}, {6, 10}}, {{2, 64, 5, 7, 6}, {1, 64, 10, 2, 8}, {3, 64, 1, 8, 10}}}, + }, }; -INSTANTIATE_TEST_SUITE_P(smoke_Concat5D_CPU_Block_dynamic_axis_1, ConcatLayerCPUTest, - ::testing::Combine( - ::testing::Values(1), - ::testing::ValuesIn(inputShapes5D_Block_axis1), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(blocked8_5D_ref, blocked16_5D_ref)), - ConcatLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_Concat5D_CPU_Block_dynamic_axis_1, + ConcatLayerCPUTest, + ::testing::Combine(::testing::Values(1), + ::testing::ValuesIn(inputShapes5D_Block_axis1), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(blocked8_5D_ref, blocked16_5D_ref)), + ConcatLayerCPUTest::getTestCaseName); const std::vector> inputShapes5D_axis1 = { - { - {{-1, -1, -1, -1, -1}, {{2, 5, 5, 7, 6}, {1, 3, 10, 2, 8}, {3, 4, 1, 8, 10}}}, - {{-1, -1, -1, -1, -1}, {{2, 16, 5, 7, 6}, {1, 20, 10, 2, 8}, {3, 5, 1, 8, 10}, }}, - {{-1, -1, -1, -1, -1}, {{2, 1, 5, 7, 6}, {1, 17, 10, 2, 8}, {3, 5, 1, 8, 10}}}, - }, - { - {{{1, 3}, {3, 5}, {1, 10}, {2, 8}, {6, 10}}, {{2, 5, 5, 7, 6}, {1, 3, 10, 2, 8}, {3, 4, 1, 8, 10}}}, - {{{1, 3}, {5, 20}, {1, 10}, {2, 8}, {4, 10}}, {{2, 16, 5, 7, 6}, {1, 20, 10, 2, 8}, {3, 5, 1, 8, 10}, }}, - {{{1, 3}, {1, 17}, {1, 10}, {2, 8}, {6, 10}}, {{2, 1, 5, 7, 6}, {1, 17, 10, 2, 8}, {3, 5, 1, 8, 10}}}, - }, + { + {{-1, -1, -1, -1, -1}, {{2, 5, 5, 7, 6}, {1, 3, 10, 2, 8}, {3, 4, 1, 8, 10}}}, + {{-1, -1, -1, -1, -1}, + { + {2, 16, 5, 7, 6}, + {1, 20, 10, 2, 8}, + {3, 5, 1, 8, 10}, + }}, + {{-1, -1, -1, -1, -1}, {{2, 1, 5, 7, 6}, {1, 17, 10, 2, 8}, {3, 5, 1, 8, 10}}}, + }, + { + {{{1, 3}, {3, 5}, {1, 10}, {2, 8}, {6, 10}}, {{2, 5, 5, 7, 6}, {1, 3, 10, 2, 8}, {3, 4, 1, 8, 10}}}, + {{{1, 3}, {5, 20}, {1, 10}, {2, 8}, {4, 10}}, + { + {2, 16, 5, 7, 6}, + {1, 20, 10, 2, 8}, + {3, 5, 1, 8, 10}, + }}, + {{{1, 3}, {1, 17}, {1, 10}, {2, 8}, {6, 10}}, {{2, 1, 5, 7, 6}, {1, 17, 10, 2, 8}, {3, 5, 1, 8, 10}}}, + }, }; -INSTANTIATE_TEST_SUITE_P(smoke_Concat5D_CPU_dynamic_axis_1, ConcatLayerCPUTest, - ::testing::Combine( - ::testing::Values(1), - ::testing::ValuesIn(inputShapes5D_axis1), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(planar_5D_ref, planarChannels_5D)), - ConcatLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_Concat5D_CPU_dynamic_axis_1, + ConcatLayerCPUTest, + ::testing::Combine(::testing::Values(1), + ::testing::ValuesIn(inputShapes5D_axis1), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(planar_5D_ref, planarChannels_5D)), + ConcatLayerCPUTest::getTestCaseName); const std::vector> inputShapes5D_Block_axis2 = { - { - {{-1, 16, -1, -1, -1}, {{2, 16, 5, 8, 7}, {1, 16, 16, 1, 2}, {3, 16, 2, 5, 8}, }}, - {{-1, 16, -1, -1, -1}, {{2, 16, 1, 8, 7}, {1, 16, 3, 1, 2}, {3, 16, 11, 5, 8}}}, - {{-1, 16, -1, -1, -1}, {{2, 16, 10, 8, 7}, {1, 16, 5, 1, 2}, {3, 16, 1, 5, 8}}}, - }, - { - {{{1, 3}, 16, {2, 16}, {1, 8}, {2, 8}}, {{2, 16, 5, 8, 7}, {1, 16, 16, 1, 2}, {3, 16, 2, 5, 8}, }}, - {{{1, 5}, 16, {1, 11}, {1, 8}, {1, 8}}, {{2, 16, 1, 8, 7}, {1, 16, 3, 1, 2}, {3, 16, 11, 5, 8}}}, - {{{1, 6}, 16, {1, 10}, {1, 8}, {2, 10}}, {{2, 16, 10, 8, 7}, {1, 16, 5, 1, 2}, {3, 16, 1, 5, 8}}}, - }, + { + {{-1, 16, -1, -1, -1}, + { + {2, 16, 5, 8, 7}, + {1, 16, 16, 1, 2}, + {3, 16, 2, 5, 8}, + }}, + {{-1, 16, -1, -1, -1}, {{2, 16, 1, 8, 7}, {1, 16, 3, 1, 2}, {3, 16, 11, 5, 8}}}, + {{-1, 16, -1, -1, -1}, {{2, 16, 10, 8, 7}, {1, 16, 5, 1, 2}, {3, 16, 1, 5, 8}}}, + }, + { + {{{1, 3}, 16, {2, 16}, {1, 8}, {2, 8}}, + { + {2, 16, 5, 8, 7}, + {1, 16, 16, 1, 2}, + {3, 16, 2, 5, 8}, + }}, + {{{1, 5}, 16, {1, 11}, {1, 8}, {1, 8}}, {{2, 16, 1, 8, 7}, {1, 16, 3, 1, 2}, {3, 16, 11, 5, 8}}}, + {{{1, 6}, 16, {1, 10}, {1, 8}, {2, 10}}, {{2, 16, 10, 8, 7}, {1, 16, 5, 1, 2}, {3, 16, 1, 5, 8}}}, + }, }; -INSTANTIATE_TEST_SUITE_P(smoke_Concat5D_CPU_Block_dynamic_axis_2, ConcatLayerCPUTest, - ::testing::Combine( - ::testing::Values(-3), - ::testing::ValuesIn(inputShapes5D_Block_axis2), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(blocked8_5D_ref, blocked16_5D_ref)), - ConcatLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_Concat5D_CPU_Block_dynamic_axis_2, + ConcatLayerCPUTest, + ::testing::Combine(::testing::Values(-3), + ::testing::ValuesIn(inputShapes5D_Block_axis2), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(blocked8_5D_ref, blocked16_5D_ref)), + ConcatLayerCPUTest::getTestCaseName); const std::vector> inputShapes5D_axis2 = { - { - {{-1, -1, -1, -1, -1}, {{2, 4, 5, 8, 7}, {1, 20, 16, 1, 2}, {3, 8, 2, 5, 8}}}, - {{-1, -1, -1, -1, -1}, {{2, 4, 1, 8, 7}, {1, 20, 3, 1, 2}, {3, 8, 11, 5, 8}}}, - {{-1, -1, -1, -1, -1}, {{2, 4, 10, 8, 7}, {1, 20, 5, 1, 2}, {3, 8, 1, 5, 8}}}, - }, - { - {{{1, 3}, {4, 20}, {1, 16}, {1, 8}, {2, 8}}, {{2, 4, 5, 8, 7}, {1, 20, 16, 1, 2}, {3, 8, 2, 5, 8}}}, - {{{1, 3}, {4, 20}, {1, 11}, {1, 10}, {1, 15}}, {{2, 4, 1, 8, 7}, {1, 20, 3, 1, 2}, {3, 8, 11, 5, 8}}}, - {{{1, 3}, {1, 20}, {1, 15}, {1, 10}, {2, 8}}, {{2, 4, 10, 8, 7}, {1, 20, 5, 1, 2}, {3, 8, 1, 5, 8}}}, - }, + { + {{-1, -1, -1, -1, -1}, {{2, 4, 5, 8, 7}, {1, 20, 16, 1, 2}, {3, 8, 2, 5, 8}}}, + {{-1, -1, -1, -1, -1}, {{2, 4, 1, 8, 7}, {1, 20, 3, 1, 2}, {3, 8, 11, 5, 8}}}, + {{-1, -1, -1, -1, -1}, {{2, 4, 10, 8, 7}, {1, 20, 5, 1, 2}, {3, 8, 1, 5, 8}}}, + }, + { + {{{1, 3}, {4, 20}, {1, 16}, {1, 8}, {2, 8}}, {{2, 4, 5, 8, 7}, {1, 20, 16, 1, 2}, {3, 8, 2, 5, 8}}}, + {{{1, 3}, {4, 20}, {1, 11}, {1, 10}, {1, 15}}, {{2, 4, 1, 8, 7}, {1, 20, 3, 1, 2}, {3, 8, 11, 5, 8}}}, + {{{1, 3}, {1, 20}, {1, 15}, {1, 10}, {2, 8}}, {{2, 4, 10, 8, 7}, {1, 20, 5, 1, 2}, {3, 8, 1, 5, 8}}}, + }, }; -INSTANTIATE_TEST_SUITE_P(smoke_Concat5D_CPU_dynamic_axis_2, ConcatLayerCPUTest, - ::testing::Combine( - ::testing::Values(2), - ::testing::ValuesIn(inputShapes5D_axis2), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(planar_5D_ref, planarChannels_5D)), - ConcatLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_Concat5D_CPU_dynamic_axis_2, + ConcatLayerCPUTest, + ::testing::Combine(::testing::Values(2), + ::testing::ValuesIn(inputShapes5D_axis2), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(planar_5D_ref, planarChannels_5D)), + ConcatLayerCPUTest::getTestCaseName); const std::vector> inputShapes5D_Block_axis3 = { - { - {{-1, 32, -1, -1, -1}, {{2, 32, 4, 5, 7}, {1, 32, 1, 16, 3}, {3, 32, 7, 2, 4}}}, - {{-1, 32, -1, -1, -1}, {{2, 32, 4, 1, 7}, {1, 32, 1, 3, 3}, {3, 32, 7, 11, 4}}}, - {{-1, 32, -1, -1, -1}, {{2, 32, 4, 10, 7}, {1, 32, 1, 5, 3}, {3, 32, 7, 1, 4}}}, - }, - { - {{{1, 3}, 32, {1, 7}, {2, 16}, {3, 7}}, {{2, 32, 4, 5, 7}, {1, 32, 1, 16, 3}, {3, 32, 7, 2, 4}, }}, - {{{1, 5}, 32, {1, 7}, {1, 11}, {3, 7}}, {{2, 32, 4, 1, 7}, {1, 32, 1, 3, 3}, {3, 32, 7, 11, 4}}}, - {{{1, 6}, 32, {1, 15}, {1, 10}, {1, 20}}, {{2, 32, 4, 10, 7}, {1, 32, 1, 5, 3}, {3, 32, 7, 1, 4}}}, - }, + { + {{-1, 32, -1, -1, -1}, {{2, 32, 4, 5, 7}, {1, 32, 1, 16, 3}, {3, 32, 7, 2, 4}}}, + {{-1, 32, -1, -1, -1}, {{2, 32, 4, 1, 7}, {1, 32, 1, 3, 3}, {3, 32, 7, 11, 4}}}, + {{-1, 32, -1, -1, -1}, {{2, 32, 4, 10, 7}, {1, 32, 1, 5, 3}, {3, 32, 7, 1, 4}}}, + }, + { + {{{1, 3}, 32, {1, 7}, {2, 16}, {3, 7}}, + { + {2, 32, 4, 5, 7}, + {1, 32, 1, 16, 3}, + {3, 32, 7, 2, 4}, + }}, + {{{1, 5}, 32, {1, 7}, {1, 11}, {3, 7}}, {{2, 32, 4, 1, 7}, {1, 32, 1, 3, 3}, {3, 32, 7, 11, 4}}}, + {{{1, 6}, 32, {1, 15}, {1, 10}, {1, 20}}, {{2, 32, 4, 10, 7}, {1, 32, 1, 5, 3}, {3, 32, 7, 1, 4}}}, + }, }; -INSTANTIATE_TEST_SUITE_P(smoke_Concat5D_CPU_Block_dynamic_axis_3, ConcatLayerCPUTest, - ::testing::Combine( - ::testing::Values(3), - ::testing::ValuesIn(inputShapes5D_Block_axis3), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(blocked8_5D_ref, blocked16_5D_ref)), - ConcatLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_Concat5D_CPU_Block_dynamic_axis_3, + ConcatLayerCPUTest, + ::testing::Combine(::testing::Values(3), + ::testing::ValuesIn(inputShapes5D_Block_axis3), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(blocked8_5D_ref, blocked16_5D_ref)), + ConcatLayerCPUTest::getTestCaseName); const std::vector> inputShapes5D_axis3 = { - { - {{-1, -1, -1, -1, -1}, {{2, 32, 4, 5, 7}, {1, 11, 1, 16, 3}, {3, 7, 7, 2, 4}}}, - {{-1, -1, -1, -1, -1}, {{2, 32, 4, 1, 7}, {1, 11, 1, 3, 3}, {3, 7, 7, 11, 4}}}, - {{-1, -1, -1, -1, -1}, {{2, 32, 4, 10, 7}, {1, 11, 1, 5, 3}, {3, 7, 7, 1, 4}}}, - }, - { - {{{1, 7}, {7, 32}, {1, 7}, {1, 16}, {3, 14}}, {{2, 32, 4, 5, 7}, {1, 11, 1, 16, 3}, {3, 7, 7, 2, 4}, }}, - {{{1, 7}, {7, 32}, {1, 10}, {1, 11}, {3, 7}}, {{2, 32, 4, 1, 7}, {1, 11, 1, 3, 3}, {3, 7, 7, 11, 4}}}, - {{{1, 7}, {1, 32}, {1, 10}, {1, 10}, {1, 10}}, {{2, 32, 4, 10, 7}, {1, 11, 1, 5, 3}, {3, 7, 7, 1, 4}}}, - }, + { + {{-1, -1, -1, -1, -1}, {{2, 32, 4, 5, 7}, {1, 11, 1, 16, 3}, {3, 7, 7, 2, 4}}}, + {{-1, -1, -1, -1, -1}, {{2, 32, 4, 1, 7}, {1, 11, 1, 3, 3}, {3, 7, 7, 11, 4}}}, + {{-1, -1, -1, -1, -1}, {{2, 32, 4, 10, 7}, {1, 11, 1, 5, 3}, {3, 7, 7, 1, 4}}}, + }, + { + {{{1, 7}, {7, 32}, {1, 7}, {1, 16}, {3, 14}}, + { + {2, 32, 4, 5, 7}, + {1, 11, 1, 16, 3}, + {3, 7, 7, 2, 4}, + }}, + {{{1, 7}, {7, 32}, {1, 10}, {1, 11}, {3, 7}}, {{2, 32, 4, 1, 7}, {1, 11, 1, 3, 3}, {3, 7, 7, 11, 4}}}, + {{{1, 7}, {1, 32}, {1, 10}, {1, 10}, {1, 10}}, {{2, 32, 4, 10, 7}, {1, 11, 1, 5, 3}, {3, 7, 7, 1, 4}}}, + }, }; -INSTANTIATE_TEST_SUITE_P(smoke_Concat5D_CPU_dynamic_axis_3, ConcatLayerCPUTest, - ::testing::Combine( - ::testing::Values(3), - ::testing::ValuesIn(inputShapes5D_axis3), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(planar_5D_ref, planarChannels_5D)), - ConcatLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_Concat5D_CPU_dynamic_axis_3, + ConcatLayerCPUTest, + ::testing::Combine(::testing::Values(3), + ::testing::ValuesIn(inputShapes5D_axis3), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(planar_5D_ref, planarChannels_5D)), + ConcatLayerCPUTest::getTestCaseName); const std::vector> inputShapes5D_Block_axis4 = { - { - {{-1, 32, -1, -1, -1}, {{2, 32, 4, 5, 5}, {1, 32, 1, 1, 16}, {3, 32, 7, 9, 2}, }}, - {{-1, 32, -1, -1, -1}, {{2, 32, 4, 5, 1}, {1, 32, 1, 1, 3}, {3, 32, 7, 9, 11}}}, - {{-1, 32, -1, -1, -1}, {{2, 32, 4, 5, 10}, {1, 32, 1, 1, 5}, {3, 32, 7, 9, 1}}}, - }, - { - {{{1, 15}, 32, {1, 10}, {1, 10}, {1, 16}}, {{2, 32, 4, 5, 5}, {1, 32, 1, 1, 16}, {3, 32, 7, 9, 2}, }}, - {{{1, 15}, 32, {1, 10}, {1, 10}, {1, 11}}, {{2, 32, 4, 5, 1}, {1, 32, 1, 1, 3}, {3, 32, 7, 9, 11}}}, - {{{1, 15}, 32, {1, 10}, {1, 10}, {1, 11}}, {{2, 32, 4, 5, 10}, {1, 32, 1, 1, 5}, {3, 32, 7, 9, 1}}}, - }, + { + {{-1, 32, -1, -1, -1}, + { + {2, 32, 4, 5, 5}, + {1, 32, 1, 1, 16}, + {3, 32, 7, 9, 2}, + }}, + {{-1, 32, -1, -1, -1}, {{2, 32, 4, 5, 1}, {1, 32, 1, 1, 3}, {3, 32, 7, 9, 11}}}, + {{-1, 32, -1, -1, -1}, {{2, 32, 4, 5, 10}, {1, 32, 1, 1, 5}, {3, 32, 7, 9, 1}}}, + }, + { + {{{1, 15}, 32, {1, 10}, {1, 10}, {1, 16}}, + { + {2, 32, 4, 5, 5}, + {1, 32, 1, 1, 16}, + {3, 32, 7, 9, 2}, + }}, + {{{1, 15}, 32, {1, 10}, {1, 10}, {1, 11}}, {{2, 32, 4, 5, 1}, {1, 32, 1, 1, 3}, {3, 32, 7, 9, 11}}}, + {{{1, 15}, 32, {1, 10}, {1, 10}, {1, 11}}, {{2, 32, 4, 5, 10}, {1, 32, 1, 1, 5}, {3, 32, 7, 9, 1}}}, + }, }; -INSTANTIATE_TEST_SUITE_P(smoke_Concat5D_CPU_Block_dynamic_axis_4, ConcatLayerCPUTest, - ::testing::Combine( - ::testing::Values(4), - ::testing::ValuesIn(inputShapes5D_Block_axis4), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(blocked8_5D_ref, blocked16_5D_ref)), - ConcatLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_Concat5D_CPU_Block_dynamic_axis_4, + ConcatLayerCPUTest, + ::testing::Combine(::testing::Values(4), + ::testing::ValuesIn(inputShapes5D_Block_axis4), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(blocked8_5D_ref, blocked16_5D_ref)), + ConcatLayerCPUTest::getTestCaseName); const std::vector> inputShapes5D_axis4 = { - { - {{-1, -1, -1, -1, -1}, {{2, 1, 4, 5, 5}, {1, 4, 1, 1, 16}, {3, 14, 7, 9, 2}}}, - {{-1, -1, -1, -1, -1}, {{2, 1, 4, 5, 1}, {1, 4, 1, 1, 3}, {3, 14, 7, 9, 11}}}, - {{-1, -1, -1, -1, -1}, {{2, 1, 4, 5, 10}, {1, 4, 1, 1, 5}, {3, 14, 7, 9, 1}}}, - }, - { - {{{1, 3}, {1, 14}, {1, 7}, {1, 10}, {2, 16}}, {{2, 1, 4, 5, 5}, {1, 4, 1, 1, 16}, {3, 14, 7, 9, 2}}}, - {{{1, 3}, {1, 14}, {1, 7}, {1, 9}, {1, 11}}, {{2, 1, 4, 5, 1}, {1, 4, 1, 1, 3}, {3, 14, 7, 9, 11}}}, - {{{1, 3}, {1, 14}, {1, 7}, {1, 9}, {1, 10}}, {{2, 1, 4, 5, 10}, {1, 4, 1, 1, 5}, {3, 14, 7, 9, 1}}}, - }, + { + {{-1, -1, -1, -1, -1}, {{2, 1, 4, 5, 5}, {1, 4, 1, 1, 16}, {3, 14, 7, 9, 2}}}, + {{-1, -1, -1, -1, -1}, {{2, 1, 4, 5, 1}, {1, 4, 1, 1, 3}, {3, 14, 7, 9, 11}}}, + {{-1, -1, -1, -1, -1}, {{2, 1, 4, 5, 10}, {1, 4, 1, 1, 5}, {3, 14, 7, 9, 1}}}, + }, + { + {{{1, 3}, {1, 14}, {1, 7}, {1, 10}, {2, 16}}, {{2, 1, 4, 5, 5}, {1, 4, 1, 1, 16}, {3, 14, 7, 9, 2}}}, + {{{1, 3}, {1, 14}, {1, 7}, {1, 9}, {1, 11}}, {{2, 1, 4, 5, 1}, {1, 4, 1, 1, 3}, {3, 14, 7, 9, 11}}}, + {{{1, 3}, {1, 14}, {1, 7}, {1, 9}, {1, 10}}, {{2, 1, 4, 5, 10}, {1, 4, 1, 1, 5}, {3, 14, 7, 9, 1}}}, + }, }; -INSTANTIATE_TEST_SUITE_P(smoke_Concat5D_CPU_dynamic_axis_4, ConcatLayerCPUTest, - ::testing::Combine( - ::testing::Values(4), - ::testing::ValuesIn(inputShapes5D_axis4), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(planar_5D_ref, planarChannels_5D)), - ConcatLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_Concat5D_CPU_dynamic_axis_4, + ConcatLayerCPUTest, + ::testing::Combine(::testing::Values(4), + ::testing::ValuesIn(inputShapes5D_axis4), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(planar_5D_ref, planarChannels_5D)), + ConcatLayerCPUTest::getTestCaseName); const std::vector> inputShapes_byBatch_static = { - static_shapes_to_test_representation({{5, 2, 2, 2}, {2, 2, 2, 2}}), - static_shapes_to_test_representation({{1, 3, 5}, {3, 3, 5}}), - static_shapes_to_test_representation({{4, 3, 2}, {1, 3, 2}}) -}; + static_shapes_to_test_representation({{5, 2, 2, 2}, {2, 2, 2, 2}}), + static_shapes_to_test_representation({{1, 3, 5}, {3, 3, 5}}), + static_shapes_to_test_representation({{4, 3, 2}, {1, 3, 2}})}; const std::vector> inputShapes_byBatch_dynamic = { - // 5D - { - {{-1, -1, -1, -1, -1}, {{10, 32, 4, 5, 5}, {4, 7, 1, 1, 3}, {3, 20, 7, 9, 1}, }}, - {{-1, -1, -1, -1, -1}, {{5, 32, 4, 5, 5}, {7, 7, 1, 1, 3}, {3, 20, 7, 9, 1}}}, - {{-1, -1, -1, -1, -1}, {{1, 32, 4, 5, 5}, {1, 7, 1, 1, 3}, {6, 20, 7, 9, 1}}}, - }, - { - {{{3, 10}, {7, 32}, {1, 9}, {1, 10}, {1, 5}}, {{10, 32, 4, 5, 5}, {4, 7, 1, 1, 3}, {3, 20, 7, 9, 1}, }}, - {{{3, 7}, {7, 32}, {1, 7}, {1, 9}, {1, 5}}, {{5, 32, 4, 5, 5}, {7, 7, 1, 1, 3}, {3, 20, 7, 9, 1}}}, - {{{1, 6}, {7, 32}, {1, 7}, {1, 9}, {1, 5}}, {{1, 32, 4, 5, 5}, {1, 7, 1, 1, 3}, {6, 20, 7, 9, 1}}}, - }, - // 4D - { - {{-1, -1, -1, -1}, {{10, 32, 4, 5}, {4, 7, 1, 1}, {3, 20, 7, 9}, }}, - {{-1, -1, -1, -1}, {{5, 32, 4, 5}, {7, 7, 1, 1}, {3, 20, 7, 9}}}, - {{-1, -1, -1, -1}, {{1, 32, 4, 5}, {1, 7, 1, 1}, {6, 20, 7, 9}}}, - }, - { - {{{1, 10}, {1, 32}, {1, 7}, {1, 9}}, {{10, 32, 4, 5}, {4, 7, 1, 1}, {3, 20, 7, 9}, }}, - {{{3, 7}, {7, 32}, {1, 7}, {1, 9}}, {{5, 32, 4, 5}, {7, 7, 1, 1}, {3, 20, 7, 9}}}, - {{{1, 6}, {7, 32}, {1, 7}, {1, 9}}, {{1, 32, 4, 5}, {1, 7, 1, 1}, {6, 20, 7, 9}}}, - }, - { - {{{1, 10}, 32, 4, 5}, {{10, 32, 4, 5}, {4, 32, 4, 5}}}, - {{{1, 10}, 32, 4, 5}, {{5, 32, 4, 5}, {7, 32, 4, 5}}}, - {{{1, 10}, 32, 4, 5}, {{1, 32, 4, 5}, {1, 32, 4, 5}}}, - } -}; - -INSTANTIATE_TEST_SUITE_P(smoke_Concat_byBatch_static, ConcatLayerCPUTest, - ::testing::Combine( - ::testing::Values(0), - ::testing::ValuesIn(inputShapes_byBatch_static), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(CPUSpecificParams{{}, {}, {}, "unknown"})), - ConcatLayerCPUTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_Concat_byBatch_dynamic, ConcatLayerCPUTest, - ::testing::Combine( - ::testing::Values(0), - ::testing::ValuesIn(inputShapes_byBatch_dynamic), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(CPUSpecificParams{{}, {}, {}, "ref"})), - ConcatLayerCPUTest::getTestCaseName); + // 5D + { + {{-1, -1, -1, -1, -1}, + { + {10, 32, 4, 5, 5}, + {4, 7, 1, 1, 3}, + {3, 20, 7, 9, 1}, + }}, + {{-1, -1, -1, -1, -1}, {{5, 32, 4, 5, 5}, {7, 7, 1, 1, 3}, {3, 20, 7, 9, 1}}}, + {{-1, -1, -1, -1, -1}, {{1, 32, 4, 5, 5}, {1, 7, 1, 1, 3}, {6, 20, 7, 9, 1}}}, + }, + { + {{{3, 10}, {7, 32}, {1, 9}, {1, 10}, {1, 5}}, + { + {10, 32, 4, 5, 5}, + {4, 7, 1, 1, 3}, + {3, 20, 7, 9, 1}, + }}, + {{{3, 7}, {7, 32}, {1, 7}, {1, 9}, {1, 5}}, {{5, 32, 4, 5, 5}, {7, 7, 1, 1, 3}, {3, 20, 7, 9, 1}}}, + {{{1, 6}, {7, 32}, {1, 7}, {1, 9}, {1, 5}}, {{1, 32, 4, 5, 5}, {1, 7, 1, 1, 3}, {6, 20, 7, 9, 1}}}, + }, + // 4D + { + {{-1, -1, -1, -1}, + { + {10, 32, 4, 5}, + {4, 7, 1, 1}, + {3, 20, 7, 9}, + }}, + {{-1, -1, -1, -1}, {{5, 32, 4, 5}, {7, 7, 1, 1}, {3, 20, 7, 9}}}, + {{-1, -1, -1, -1}, {{1, 32, 4, 5}, {1, 7, 1, 1}, {6, 20, 7, 9}}}, + }, + { + {{{1, 10}, {1, 32}, {1, 7}, {1, 9}}, + { + {10, 32, 4, 5}, + {4, 7, 1, 1}, + {3, 20, 7, 9}, + }}, + {{{3, 7}, {7, 32}, {1, 7}, {1, 9}}, {{5, 32, 4, 5}, {7, 7, 1, 1}, {3, 20, 7, 9}}}, + {{{1, 6}, {7, 32}, {1, 7}, {1, 9}}, {{1, 32, 4, 5}, {1, 7, 1, 1}, {6, 20, 7, 9}}}, + }, + { + {{{1, 10}, 32, 4, 5}, {{10, 32, 4, 5}, {4, 32, 4, 5}}}, + {{{1, 10}, 32, 4, 5}, {{5, 32, 4, 5}, {7, 32, 4, 5}}}, + {{{1, 10}, 32, 4, 5}, {{1, 32, 4, 5}, {1, 32, 4, 5}}}, + }}; + +INSTANTIATE_TEST_SUITE_P(smoke_Concat_byBatch_static, + ConcatLayerCPUTest, + ::testing::Combine(::testing::Values(0), + ::testing::ValuesIn(inputShapes_byBatch_static), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(CPUSpecificParams{{}, {}, {}, "unknown"})), + ConcatLayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_Concat_byBatch_dynamic, + ConcatLayerCPUTest, + ::testing::Combine(::testing::Values(0), + ::testing::ValuesIn(inputShapes_byBatch_dynamic), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(CPUSpecificParams{{}, {}, {}, "ref"})), + ConcatLayerCPUTest::getTestCaseName); const std::vector> inputShapes3D_axis1 = { - static_shapes_to_test_representation({{2, 4, 5}, {2, 4, 5}}), - { - {{-1, -1, -1}, {{2, 5, 12}, {1, 16, 1}, {5, 2, 6}, }}, - {{-1, -1, -1}, {{2, 1, 12}, {1, 3, 1}, {5, 11, 6}}}, - {{-1, -1, -1}, {{2, 10, 12}, {1, 5, 1}, {5, 1, 6}}}, - }, - { - {{{1, 5}, {2, 16}, {1, 12}}, {{2, 5, 12}, {1, 16, 1}, {5, 2, 6}, }}, - {{{1, 5}, {1, 11}, {1, 21}}, {{2, 1, 12}, {1, 3, 1}, {5, 11, 6}}}, - {{{1, 5}, {1, 10}, {1, 12}}, {{2, 10, 12}, {1, 5, 1}, {5, 1, 6}}}, - }, + static_shapes_to_test_representation({{2, 4, 5}, {2, 4, 5}}), + { + {{-1, -1, -1}, + { + {2, 5, 12}, + {1, 16, 1}, + {5, 2, 6}, + }}, + {{-1, -1, -1}, {{2, 1, 12}, {1, 3, 1}, {5, 11, 6}}}, + {{-1, -1, -1}, {{2, 10, 12}, {1, 5, 1}, {5, 1, 6}}}, + }, + { + {{{1, 5}, {2, 16}, {1, 12}}, + { + {2, 5, 12}, + {1, 16, 1}, + {5, 2, 6}, + }}, + {{{1, 5}, {1, 11}, {1, 21}}, {{2, 1, 12}, {1, 3, 1}, {5, 11, 6}}}, + {{{1, 5}, {1, 10}, {1, 12}}, {{2, 10, 12}, {1, 5, 1}, {5, 1, 6}}}, + }, }; -INSTANTIATE_TEST_SUITE_P(smoke_Concat_3D_axis1, ConcatLayerCPUTest, - ::testing::Combine( - ::testing::Values(1), - ::testing::ValuesIn(inputShapes3D_axis1), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(CPUSpecificParams{{}, {}, {}, "ref"})), - ConcatLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_Concat_3D_axis1, + ConcatLayerCPUTest, + ::testing::Combine(::testing::Values(1), + ::testing::ValuesIn(inputShapes3D_axis1), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(CPUSpecificParams{{}, {}, {}, "ref"})), + ConcatLayerCPUTest::getTestCaseName); const std::vector> inputShapes3D_axis2 = { - static_shapes_to_test_representation({{2, 4, 5}, {2, 4, 5}}), - { - {{-1, -1, -1}, {{4, 4, 5}, {3, 2, 16}, {1, 1, 2}}}, - {{-1, -1, -1}, {{4, 4, 1}, {3, 2, 3}, {1, 1, 11}}}, - {{-1, -1, -1}, {{4, 4, 10}, {3, 2, 5}, {1, 1, 1}}}, - }, - { - {{{1, 4}, {1, 4}, {2, 16}}, {{4, 4, 5}, {3, 2, 16}, {1, 1, 2}, }}, - {{{1, 4}, {1, 4}, {1, 11}}, {{4, 4, 1}, {3, 2, 3}, {1, 1, 11}}}, - {{{1, 4}, {1, 4}, {1, 10}}, {{4, 4, 10}, {3, 2, 5}, {1, 1, 1}}}, - }, + static_shapes_to_test_representation({{2, 4, 5}, {2, 4, 5}}), + { + {{-1, -1, -1}, {{4, 4, 5}, {3, 2, 16}, {1, 1, 2}}}, + {{-1, -1, -1}, {{4, 4, 1}, {3, 2, 3}, {1, 1, 11}}}, + {{-1, -1, -1}, {{4, 4, 10}, {3, 2, 5}, {1, 1, 1}}}, + }, + { + {{{1, 4}, {1, 4}, {2, 16}}, + { + {4, 4, 5}, + {3, 2, 16}, + {1, 1, 2}, + }}, + {{{1, 4}, {1, 4}, {1, 11}}, {{4, 4, 1}, {3, 2, 3}, {1, 1, 11}}}, + {{{1, 4}, {1, 4}, {1, 10}}, {{4, 4, 10}, {3, 2, 5}, {1, 1, 1}}}, + }, }; -INSTANTIATE_TEST_SUITE_P(smoke_Concat_3D_axis2, ConcatLayerCPUTest, - ::testing::Combine( - ::testing::Values(2), - ::testing::ValuesIn(inputShapes3D_axis2), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(CPUSpecificParams{{}, {}, {}, "ref"})), - ConcatLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_Concat_3D_axis2, + ConcatLayerCPUTest, + ::testing::Combine(::testing::Values(2), + ::testing::ValuesIn(inputShapes3D_axis2), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(CPUSpecificParams{{}, {}, {}, "ref"})), + ConcatLayerCPUTest::getTestCaseName); const std::vector> inputShapes2D_axis1 = { - static_shapes_to_test_representation({{3, 2}, {3, 10}}), - { - {{-1, -1}, {{19, 5}, {1, 16}, {8, 2}, }}, - {{-1, -1}, {{19, 1}, {1, 3}, {8, 11}}}, - {{-1, -1}, {{19, 10}, {1, 5}, {8, 1}}}, - }, - { - {{{1, 19}, {2, 16}}, {{19, 5}, {1, 16}, {8, 2}, }}, - {{{1, 19}, {1, 11}}, {{19, 1}, {1, 3}, {8, 11}}}, - {{{1, 19}, {1, 10}}, {{19, 10}, {1, 5}, {8, 1}}}, - }, + static_shapes_to_test_representation({{3, 2}, {3, 10}}), + { + {{-1, -1}, + { + {19, 5}, + {1, 16}, + {8, 2}, + }}, + {{-1, -1}, {{19, 1}, {1, 3}, {8, 11}}}, + {{-1, -1}, {{19, 10}, {1, 5}, {8, 1}}}, + }, + { + {{{1, 19}, {2, 16}}, + { + {19, 5}, + {1, 16}, + {8, 2}, + }}, + {{{1, 19}, {1, 11}}, {{19, 1}, {1, 3}, {8, 11}}}, + {{{1, 19}, {1, 10}}, {{19, 10}, {1, 5}, {8, 1}}}, + }, }; -INSTANTIATE_TEST_SUITE_P(smoke_Concat_2D_axis1, ConcatLayerCPUTest, - ::testing::Combine( - ::testing::Values(1), - ::testing::ValuesIn(inputShapes2D_axis1), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(CPUSpecificParams{{}, {}, {}, "ref"})), - ConcatLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_Concat_2D_axis1, + ConcatLayerCPUTest, + ::testing::Combine(::testing::Values(1), + ::testing::ValuesIn(inputShapes2D_axis1), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(CPUSpecificParams{{}, {}, {}, "ref"})), + ConcatLayerCPUTest::getTestCaseName); const std::vector> inputShapes1D_static = { - static_shapes_to_test_representation({ov::Shape{5}, ov::Shape{5}}), - static_shapes_to_test_representation({ov::Shape{2}, ov::Shape{2}}), - static_shapes_to_test_representation({ov::Shape{1}, ov::Shape{1}}), - static_shapes_to_test_representation({ov::Shape{3}, ov::Shape{3}}) -}; + static_shapes_to_test_representation({ov::Shape{5}, ov::Shape{5}}), + static_shapes_to_test_representation({ov::Shape{2}, ov::Shape{2}}), + static_shapes_to_test_representation({ov::Shape{1}, ov::Shape{1}}), + static_shapes_to_test_representation({ov::Shape{3}, ov::Shape{3}})}; const std::vector> inputShapes1D_dynamic = { - { - {{-1}, {{19}, {8}, {5}}}, - {{-1}, {{19}, {8}, {5}}}, - {{-1}, {{19}, {8}, {5}}}, - }, - { - {{{1, 20}}, {{19}, {8}, {5}}}, - {{{1, 20}}, {{19}, {8}, {5}}}, - {{{1, 20}}, {{19}, {8}, {5}}}, - }, + { + {{-1}, {{19}, {8}, {5}}}, + {{-1}, {{19}, {8}, {5}}}, + {{-1}, {{19}, {8}, {5}}}, + }, + { + {{{1, 20}}, {{19}, {8}, {5}}}, + {{{1, 20}}, {{19}, {8}, {5}}}, + {{{1, 20}}, {{19}, {8}, {5}}}, + }, }; -INSTANTIATE_TEST_SUITE_P(smoke_Concat_1D_static, ConcatLayerCPUTest, - ::testing::Combine( - ::testing::Values(0), - ::testing::ValuesIn(inputShapes1D_static), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(CPUSpecificParams{{}, {}, {}, "unknown"})), - ConcatLayerCPUTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_Concat_1D_dynamic, ConcatLayerCPUTest, - ::testing::Combine( - ::testing::Values(0), - ::testing::ValuesIn(inputShapes1D_dynamic), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(CPUSpecificParams{{}, {}, {}, "ref"})), - ConcatLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_Concat_1D_static, + ConcatLayerCPUTest, + ::testing::Combine(::testing::Values(0), + ::testing::ValuesIn(inputShapes1D_static), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(CPUSpecificParams{{}, {}, {}, "unknown"})), + ConcatLayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_Concat_1D_dynamic, + ConcatLayerCPUTest, + ::testing::Combine(::testing::Values(0), + ::testing::ValuesIn(inputShapes1D_dynamic), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(CPUSpecificParams{{}, {}, {}, "ref"})), + ConcatLayerCPUTest::getTestCaseName); // ============================================== inPlace cases ============================================ -INSTANTIATE_TEST_SUITE_P(concat_Concat4D_CPU_Block8inPlace, ConcatLayerCPUTest, - ::testing::Combine( - ::testing::Values(0, 1), - ::testing::Values(std::vector{ - {{}, {{1, 16, 5, 7}}}, - {{}, {{1, 16, 5, 7}}}, - {{}, {{1, 16, 5, 7}}}, - }, - std::vector{ - {{1, 16, -1, -1}, {{1, 16, 5, 7}, {1, 16, 16, 2}, {1, 16, 2, 8}}}, - {{1, 16, -1, -1}, {{1, 16, 5, 7}, {1, 16, 16, 2}, {1, 16, 2, 8}}}, - {{1, 16, -1, -1}, {{1, 16, 5, 7}, {1, 16, 16, 2}, {1, 16, 2, 8}}}, - }), - ::testing::Values(ElementType::f32), - ::testing::Values(planar_4D, blocked8_4D)), - ConcatLayerCPUTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_Concat4D_CPU_Block16inPlace_0, ConcatLayerCPUTest, - ::testing::Combine( - ::testing::Values(0), - ::testing::Values(std::vector{ - {{}, {{1, 32, 5, 7}}}, - {{}, {{1, 32, 5, 7}}}, - {{}, {{1, 32, 5, 7}}}, - }, - std::vector{ - {{1, 32, -1, -1}, {{1, 32, 5, 7}, {1, 32, 16, 2}, {1, 32, 2, 8}}}, - {{1, 32, -1, -1}, {{1, 32, 5, 7}, {1, 32, 16, 2}, {1, 32, 2, 8}}}, - {{1, 32, -1, -1}, {{1, 32, 5, 7}, {1, 32, 16, 2}, {1, 32, 2, 8}}}, - }), - ::testing::Values(ElementType::f32), - ::testing::Values(blocked16_4D)), - ConcatLayerCPUTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_Concat4D_CPU_Block16inPlace_1, ConcatLayerCPUTest, - ::testing::Combine( - ::testing::Values(1), - ::testing::Values(std::vector{ - {{}, {{1, 32, 5, 7}}}, - {{}, {{1, 16, 5, 7}}}, - {{}, {{1, 32, 5, 7}}}, - }, - std::vector{ - {{1, 32, -1, -1}, {{1, 32, 5, 7}, {1, 32, 16, 2}, {1, 32, 2, 8}}}, - {{1, 16, -1, -1}, {{1, 16, 5, 7}, {1, 16, 16, 2}, {1, 16, 2, 8}}}, - {{1, 32, -1, -1}, {{1, 32, 5, 7}, {1, 32, 16, 2}, {1, 32, 2, 8}}}, - }), - ::testing::Values(ElementType::f32), - ::testing::Values(blocked16_4D)), - ConcatLayerCPUTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(concat_Concat5D_CPU_Block8inPlace, ConcatLayerCPUTest, - ::testing::Combine( - ::testing::Values(0, 1), - ::testing::Values(std::vector{ - {{}, {{1, 16, 3, 5, 7}}}, - {{}, {{1, 16, 3, 5, 7}}}, - {{}, {{1, 16, 3, 5, 7}}}, - }, - std::vector{ - {{1, 32, -1, -1, -1}, {{1, 32, 5, 7, 3}, {1, 32, 16, 2, 3}, {1, 32, 2, 8, 3}}}, - {{1, 32, -1, -1, -1}, {{1, 32, 5, 7, 3}, {1, 32, 16, 2, 3}, {1, 32, 2, 8, 3}}}, - {{1, 32, -1, -1, -1}, {{1, 32, 5, 7, 3}, {1, 32, 16, 2, 3}, {1, 32, 2, 8, 3}}}, - }), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(planar_5D, blocked8_5D)), - ConcatLayerCPUTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_Concat5D_CPU_Block16inPlace, ConcatLayerCPUTest, - ::testing::Combine( - ::testing::Values(0, 1), - ::testing::Values(std::vector{ - {{}, {{1, 32, 3, 5, 7}}}, - {{}, {{1, 32, 3, 5, 7}}}, - {{}, {{1, 32, 3, 5, 7}}}, - }, - std::vector{ - {{1, 32, -1, -1, -1}, {{1, 32, 5, 7, 3}, {1, 32, 16, 2, 3}, {1, 32, 2, 8, 3}}}, - {{1, 32, -1, -1, -1}, {{1, 32, 5, 7, 3}, {1, 32, 16, 2, 3}, {1, 32, 2, 8, 3}}}, - {{1, 32, -1, -1, -1}, {{1, 32, 5, 7, 3}, {1, 32, 16, 2, 3}, {1, 32, 2, 8, 3}}}, - }), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(blocked16_5D)), - ConcatLayerCPUTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_Concat_inPlace, ConcatLayerCPUTest, - ::testing::Combine( - ::testing::Values(0, 1, 2, -1), - ::testing::ValuesIn(std::vector>{ - static_shapes_to_test_representation({{1, 1, 1, 10}, {1, 1, 1, 10}}), - static_shapes_to_test_representation({{1, 1, 5}, {1, 1, 5}})}), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(CPUSpecificParams{{}, {}, {}, "unknown"})), - ConcatLayerCPUTest::getTestCaseName); - -} // namespace - -} // namespace CPULayerTestsDefinitions +INSTANTIATE_TEST_SUITE_P(concat_Concat4D_CPU_Block8inPlace, + ConcatLayerCPUTest, + ::testing::Combine(::testing::Values(0, 1), + ::testing::Values( + std::vector{ + {{}, {{1, 16, 5, 7}}}, + {{}, {{1, 16, 5, 7}}}, + {{}, {{1, 16, 5, 7}}}, + }, + std::vector{ + {{1, 16, -1, -1}, {{1, 16, 5, 7}, {1, 16, 16, 2}, {1, 16, 2, 8}}}, + {{1, 16, -1, -1}, {{1, 16, 5, 7}, {1, 16, 16, 2}, {1, 16, 2, 8}}}, + {{1, 16, -1, -1}, {{1, 16, 5, 7}, {1, 16, 16, 2}, {1, 16, 2, 8}}}, + }), + ::testing::Values(ElementType::f32), + ::testing::Values(planar_4D, blocked8_4D)), + ConcatLayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_Concat4D_CPU_Block16inPlace_0, + ConcatLayerCPUTest, + ::testing::Combine(::testing::Values(0), + ::testing::Values( + std::vector{ + {{}, {{1, 32, 5, 7}}}, + {{}, {{1, 32, 5, 7}}}, + {{}, {{1, 32, 5, 7}}}, + }, + std::vector{ + {{1, 32, -1, -1}, {{1, 32, 5, 7}, {1, 32, 16, 2}, {1, 32, 2, 8}}}, + {{1, 32, -1, -1}, {{1, 32, 5, 7}, {1, 32, 16, 2}, {1, 32, 2, 8}}}, + {{1, 32, -1, -1}, {{1, 32, 5, 7}, {1, 32, 16, 2}, {1, 32, 2, 8}}}, + }), + ::testing::Values(ElementType::f32), + ::testing::Values(blocked16_4D)), + ConcatLayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_Concat4D_CPU_Block16inPlace_1, + ConcatLayerCPUTest, + ::testing::Combine(::testing::Values(1), + ::testing::Values( + std::vector{ + {{}, {{1, 32, 5, 7}}}, + {{}, {{1, 16, 5, 7}}}, + {{}, {{1, 32, 5, 7}}}, + }, + std::vector{ + {{1, 32, -1, -1}, {{1, 32, 5, 7}, {1, 32, 16, 2}, {1, 32, 2, 8}}}, + {{1, 16, -1, -1}, {{1, 16, 5, 7}, {1, 16, 16, 2}, {1, 16, 2, 8}}}, + {{1, 32, -1, -1}, {{1, 32, 5, 7}, {1, 32, 16, 2}, {1, 32, 2, 8}}}, + }), + ::testing::Values(ElementType::f32), + ::testing::Values(blocked16_4D)), + ConcatLayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P( + concat_Concat5D_CPU_Block8inPlace, + ConcatLayerCPUTest, + ::testing::Combine(::testing::Values(0, 1), + ::testing::Values( + std::vector{ + {{}, {{1, 16, 3, 5, 7}}}, + {{}, {{1, 16, 3, 5, 7}}}, + {{}, {{1, 16, 3, 5, 7}}}, + }, + std::vector{ + {{1, 32, -1, -1, -1}, {{1, 32, 5, 7, 3}, {1, 32, 16, 2, 3}, {1, 32, 2, 8, 3}}}, + {{1, 32, -1, -1, -1}, {{1, 32, 5, 7, 3}, {1, 32, 16, 2, 3}, {1, 32, 2, 8, 3}}}, + {{1, 32, -1, -1, -1}, {{1, 32, 5, 7, 3}, {1, 32, 16, 2, 3}, {1, 32, 2, 8, 3}}}, + }), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(planar_5D, blocked8_5D)), + ConcatLayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P( + smoke_Concat5D_CPU_Block16inPlace, + ConcatLayerCPUTest, + ::testing::Combine(::testing::Values(0, 1), + ::testing::Values( + std::vector{ + {{}, {{1, 32, 3, 5, 7}}}, + {{}, {{1, 32, 3, 5, 7}}}, + {{}, {{1, 32, 3, 5, 7}}}, + }, + std::vector{ + {{1, 32, -1, -1, -1}, {{1, 32, 5, 7, 3}, {1, 32, 16, 2, 3}, {1, 32, 2, 8, 3}}}, + {{1, 32, -1, -1, -1}, {{1, 32, 5, 7, 3}, {1, 32, 16, 2, 3}, {1, 32, 2, 8, 3}}}, + {{1, 32, -1, -1, -1}, {{1, 32, 5, 7, 3}, {1, 32, 16, 2, 3}, {1, 32, 2, 8, 3}}}, + }), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(blocked16_5D)), + ConcatLayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_Concat_inPlace, + ConcatLayerCPUTest, + ::testing::Combine(::testing::Values(0, 1, 2, -1), + ::testing::ValuesIn(std::vector>{ + static_shapes_to_test_representation({{1, 1, 1, 10}, {1, 1, 1, 10}}), + static_shapes_to_test_representation({{1, 1, 5}, {1, 1, 5}})}), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(CPUSpecificParams{{}, {}, {}, "unknown"})), + ConcatLayerCPUTest::getTestCaseName); + +} // namespace + +} // namespace test +} // namespace ov 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/single_layer_tests/convert_to_plugin_specific_node.cpp index 92e2e20e00a6b0..e4c9658218ccdd 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/convert_to_plugin_specific_node.cpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/convert_to_plugin_specific_node.cpp @@ -2,35 +2,36 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "test_utils/cpu_test_utils.hpp" +#include "common_test_utils/node_builders/eltwise.hpp" #include "ov_models/builders.hpp" +#include "shared_test_classes/base/ov_subgraph.hpp" +#include "test_utils/cpu_test_utils.hpp" -using namespace ngraph; -using namespace InferenceEngine; using namespace CPUTestUtils; -namespace CPULayerTestsDefinitions { +namespace ov { +namespace test { -using ConvertToPluginSpecificNodeParams = std::tuple; // expected number of constant node +using ConvertToPluginSpecificNodeParams = std::tuple; // expected number of constant node class ConvertToPluginSpecificNode : public testing::WithParamInterface, - public LayerTestsUtils::LayerTestsCommon { + public SubgraphBaseStaticTest { public: static std::string getTestCaseName(testing::TestParamInfo obj) { - SizeVector nonConstShape, constShape; - Precision prc; - helpers::EltwiseTypes nodeType; + ov::Shape nonConstShape, constShape; + ov::element::Type prc; + ov::test::utils::EltwiseTypes nodeType; size_t port, constNodeNum; std::tie(nonConstShape, constShape, prc, nodeType, port, constNodeNum) = obj.param; std::ostringstream result; - result << "IS_NON_CONST=" << ov::test::utils::vec2str(nonConstShape) << "_"; - result << "IS_CONST=" << ov::test::utils::vec2str(constShape) << "_"; + result << "IS_NON_CONST=" << nonConstShape << "_"; + result << "IS_CONST=" << constShape << "_"; result << "PRC=" << prc << "_"; result << "NODE=" << nodeType << "_"; result << "PORT=" << port << "_"; @@ -45,39 +46,36 @@ class ConvertToPluginSpecificNode : public testing::WithParamInterfaceGetParam(); OPENVINO_ASSERT(shape_size(constShape) == 1); - const auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(prc); - const auto param = std::make_shared(ngPrc, ngraph::Shape(nonConstShape)); - const auto constNode = builder::makeConstant(ngPrc, ngraph::Shape(constShape), std::vector{}, true); + const auto param = std::make_shared(prc, ov::Shape(nonConstShape)); + const auto constNode = ngraph::builder::makeConstant(prc, constShape, std::vector{}, true); OutputVector inputs(2); inputs[port] = constNode; inputs[1 - port] = param; - auto powerStatic = ngraph::builder::makeEltwise(inputs[0], inputs[1], nodeType); + auto powerStatic = ov::test::utils::makeEltwise(inputs[0], inputs[1], nodeType); - function = std::make_shared(powerStatic, ParameterVector{param}, "ConvertToPluginSpecificNode"); + function = std::make_shared(powerStatic, ParameterVector{param}, "ConvertToPluginSpecificNode"); } }; TEST_P(ConvertToPluginSpecificNode, CompareWithRefs) { - Run(); - CheckNumberOfNodesWithType(executableNetwork, "Const", constNodeNum); + run(); + CheckNumberOfNodesWithType(compiledModel, "Const", constNodeNum); } namespace { -const std::vector> nonConstIS = { - {3, 4, 5, 6} -}; +const std::vector nonConstIS = {{3, 4, 5, 6}}; -const std::vector> constIS = { +const std::vector constIS = { {}, {1}, {1, 1}, @@ -85,34 +83,37 @@ const std::vector> constIS = { {1, 1, 1, 1}, }; -std::vector nodeTypes = { - ngraph::helpers::EltwiseTypes::ADD, - ngraph::helpers::EltwiseTypes::SUBTRACT, - ngraph::helpers::EltwiseTypes::MULTIPLY -}; +std::vector nodeTypes = {ov::test::utils::EltwiseTypes::ADD, + ov::test::utils::EltwiseTypes::SUBTRACT, + ov::test::utils::EltwiseTypes::MULTIPLY}; -const std::vector port = { - 0, 1 -}; +const std::vector port = {0, 1}; const auto testParamsEltwise = ::testing::Combine(::testing::ValuesIn(nonConstIS), ::testing::ValuesIn(constIS), - ::testing::Values(Precision::FP32), + ::testing::Values(ov::element::f32), ::testing::ValuesIn(nodeTypes), ::testing::ValuesIn(port), ::testing::Values(0)); -INSTANTIATE_TEST_SUITE_P(smoke_CheckEltwise, ConvertToPluginSpecificNode, testParamsEltwise, ConvertToPluginSpecificNode::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_CheckEltwise, + ConvertToPluginSpecificNode, + testParamsEltwise, + ConvertToPluginSpecificNode::getTestCaseName); const auto testParamsPower = ::testing::Combine(::testing::ValuesIn(nonConstIS), ::testing::ValuesIn(constIS), - ::testing::Values(Precision::FP32), - ::testing::Values(ngraph::helpers::EltwiseTypes::POWER), + ::testing::Values(ov::element::f32), + ::testing::Values(ov::test::utils::EltwiseTypes::POWER), ::testing::Values(1), ::testing::Values(0)); -INSTANTIATE_TEST_SUITE_P(smoke_CheckPower, ConvertToPluginSpecificNode, testParamsPower, ConvertToPluginSpecificNode::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_CheckPower, + ConvertToPluginSpecificNode, + testParamsPower, + ConvertToPluginSpecificNode::getTestCaseName); -} // namespace +} // namespace -} // namespace CPULayerTestsDefinitions +} // namespace test +} // namespace ov diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/convolution.cpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/convolution.cpp deleted file mode 100755 index aed06f2840d61e..00000000000000 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/convolution.cpp +++ /dev/null @@ -1,1714 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "test_utils/cpu_test_utils.hpp" -#include "test_utils/filter_cpu_info.hpp" -#include "test_utils/convolution_params.hpp" -#include "test_utils/fusing_test_utils.hpp" -#include "shared_test_classes/base/ov_subgraph.hpp" -#include "ov_models/utils/ov_helpers.hpp" -#include "common_test_utils/node_builders/convolution.hpp" -#include "openvino/core/visibility.hpp" -#include -#include "utils/general_utils.h" - -using namespace InferenceEngine; -using namespace CPUTestUtils; -using namespace ov::test; -using namespace ov::intel_cpu; - -namespace CPULayerTestsDefinitions { -using LayerTestsDefinitions::convSpecificParams; - -typedef std::tuple< - convSpecificParams, - ElementType, // Net precision - ElementType, // Input precision - ElementType, // Output precision - InputShape, // Input shape - LayerTestsUtils::TargetDevice // Device name -> convLayerTestParamsSet; - -typedef std::tuple< - convLayerTestParamsSet, - CPUSpecificParams, - fusingSpecificParams, - std::map > convLayerCPUTestParamsSet; - -class ConvolutionLayerCPUTest : public testing::WithParamInterface, - virtual public SubgraphBaseTest, public CpuTestWithFusing { -public: - static std::string getTestCaseName(const testing::TestParamInfo& obj) { - convLayerTestParamsSet basicParamsSet; - CPUSpecificParams cpuParams; - fusingSpecificParams fusingParams; - std::map additionalConfig; - std::tie(basicParamsSet, cpuParams, fusingParams, additionalConfig) = obj.param; - - convSpecificParams convParams; - ElementType netType; - ElementType inType, outType; - InputShape inputShape; - std::string targetDevice; - std::tie(convParams, netType, inType, outType, inputShape, targetDevice) = basicParamsSet; - ngraph::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="; - result << ov::test::utils::partialShape2str({inputShape.first}) << "_"; - result << "TS=("; - for (const auto& shape : inputShape.second) { - result << ov::test::utils::vec2str(shape) << "_"; - } - result << ")_"; - 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=" << netType << "_"; - result << "inPRC=" << inType << "_"; - result << "outPRC=" << outType << "_"; - result << "trgDev=" << targetDevice; - - result << CPUTestsBase::getTestCaseName(cpuParams); - result << CpuTestWithFusing::getTestCaseName(fusingParams); - - if (!additionalConfig.empty()) { - result << "_PluginConf"; - for (auto& item : additionalConfig) { - result << "_" << item.first << "=" << item.second; - } - } - - return result.str(); - } -protected: - bool isBias = false; - InferenceEngine::SizeVector kernel, dilation; - - void checkBiasFusing(ov::CompiledModel &execNet) const { - if (!execNet) return; - - auto execGraph = execNet.get_runtime_model(); - ASSERT_NE(nullptr, execGraph); - - bool foundConv = false; - for (const auto &node : execGraph->get_ops()) { - const auto & rtInfo = node->get_rt_info(); - auto getExecValue = [&rtInfo](const std::string & paramName) -> std::string { - auto it = rtInfo.find(paramName); - OPENVINO_ASSERT(rtInfo.end() != it); - return it->second.as(); - }; - - if (getExecValue(ExecGraphInfoSerialization::LAYER_TYPE) == "Convolution") { - foundConv = true; - ASSERT_EQ(3, node->inputs().size()); - break; - } - } - - ASSERT_TRUE(foundConv) << "Can't find Convolution node"; - } - - std::shared_ptr modifyGraph(const ngraph::element::Type &ngPrc, - ngraph::ParameterVector ¶ms, - const std::shared_ptr &lastNode) override { - auto retNode = CpuTestWithFusing::modifyGraph(ngPrc, params, lastNode); - std::shared_ptr opToShapeInfer = nullptr; - for (auto& targetShapes : targetStaticShapes) { - for (size_t i = targetShapes.size(); i < params.size(); ++i) { - const auto &shape = params[i]->get_output_partial_shape(0); - if (shape.is_static()) { - targetShapes.push_back(shape.get_shape()); - } else { - // It is assumed that in such tests we have second parameter only if sum fusion is tested. - // Considering this fact, we need to set the appropriate static shape for the second term of the sum operation, and - // it has to match the convolution output shape. So the most suitable solution here is to perform shape inference on the - // convolution node - if (!opToShapeInfer) { - ngraph::OutputVector inputsForShapeInfer; - for (size_t j = 0; j < lastNode->get_input_size(); j++) { - if (ngraph::is_type(lastNode->get_input_node_ptr(j))) { - inputsForShapeInfer.push_back(lastNode->get_input_node_shared_ptr(j)); - } else { - inputsForShapeInfer.push_back(std::make_shared(lastNode->get_input_element_type(j), - lastNode->get_input_partial_shape(j))); - } - } - opToShapeInfer = lastNode->clone_with_new_inputs(inputsForShapeInfer); - } - - std::vector secondParameterShapes; - if (auto parameter = dynamic_cast(opToShapeInfer->get_input_node_ptr(0))) { - parameter->set_partial_shape(targetShapes.front()); - parameter->validate_and_infer_types(); - } - opToShapeInfer->validate_and_infer_types(); - targetShapes.push_back(opToShapeInfer->get_output_shape(0)); - } - } - } - return retNode; - } - - void SetUp() override { - rel_threshold = 1e-4f; - - convLayerTestParamsSet basicParamsSet; - CPUSpecificParams cpuParams; - fusingSpecificParams fusingParams; - std::map additionalConfig; - std::tie(basicParamsSet, cpuParams, fusingParams, additionalConfig) = this->GetParam(); - - configuration.insert(additionalConfig.begin(), additionalConfig.end()); - - std::tie(inFmts, outFmts, priority, selectedType) = cpuParams; - std::tie(postOpMgrPtr, fusedOps) = fusingParams; - - if (postOpMgrPtr) - isBias = (postOpMgrPtr->getFusedOpsNames() == "Add(PerChannel)" && selectedType != "jit_avx512_winograd"); - - convSpecificParams convParams; - InputShape inputShape; - auto netType = ElementType::undefined; - std::tie(convParams, netType, inType, outType, inputShape, targetDevice) = basicParamsSet; - - init_input_shapes({inputShape}); - - if (configuration.count(PluginConfigParams::KEY_ENFORCE_BF16) && - PluginConfigParams::YES == configuration[PluginConfigParams::KEY_ENFORCE_BF16].as()) { - selectedType += "_BF16"; - rel_threshold = 1e-2f; - if (selectedType == "jit_gemm_BF16") - rel_threshold = 0.05f; - } else { - selectedType = makeSelectedTypeStr(selectedType, netType); - } - - ngraph::op::PadType padType; - InferenceEngine::SizeVector stride; - std::vector padBegin, padEnd; - size_t convOutChannels; - std::tie(kernel, stride, padBegin, padEnd, dilation, convOutChannels, padType) = convParams; - - ov::ParameterVector inputParams; - for (auto&& shape : inputDynamicShapes) - inputParams.push_back(std::make_shared(ov::element::f32, shape)); - - auto convolutionNode = ov::test::utils::make_convolution(inputParams[0], netType, kernel, stride, padBegin, - padEnd, dilation, padType, convOutChannels); - - function = makeNgraphFunction(netType, inputParams, convolutionNode, "Convolution"); - } -}; - -TEST_P(ConvolutionLayerCPUTest, CompareWithRefs) { - // Skip tests for sse41 convolution where ic or oc cannot be exactly divided by the block size, - // since tails processing for sse41 nspc layout is not supported yet (see 52736). - if (!inFmts.empty() && (inFmts.front() == nwc || inFmts.front() == nhwc || inFmts.front() == ndhwc) && selectedType.find("jit_sse") != std::string::npos) { - auto inpChannels = function->get_parameters().front()->get_partial_shape()[1].get_length(); - auto outChannels = function->get_output_partial_shape(0)[1].get_length(); - if ((inpChannels % 8) || (outChannels % 8)) { - GTEST_SKIP() << "Disabled test due to the sse41 convolution kernel does not support tails for nspc layout." << std::endl; - } - } - - 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; - for (const auto &i : kernel) { - if (i != 1) { - is_1x1 = false; - break; - } - } - if (is_1x1) { - GTEST_SKIP() << "Disabled test due to the brgconv does not support 1x1 convolution kernel." << std::endl; - } - } - - // Skip tests for brgconv_amx convolution where dilation is not 1 - if (priority[0].find("amx") != std::string::npos) { - bool dilation_is_1x1 = true; - for (const auto &i : dilation) { - if (i != 1) { - dilation_is_1x1 = false; - break; - } - } - if (!dilation_is_1x1) { - GTEST_SKIP() << "Disabled test due to the brgconv amx does not support non 1 dilation convolution kernel." << std::endl; - } - } - } - - run(); - - if (isBias) { - checkBiasFusing(compiledModel); - } - CheckPluginRelatedResults(compiledModel, "Convolution"); -} - -namespace { - -std::vector filterCPUInfoForDevice_BF16(std::vector allParams) { - std::vector specificParams; - bool with_bf16 = with_cpu_x86_bfloat16(); - std::copy_if(allParams.begin(), allParams.end(), std::back_inserter(specificParams), [with_bf16](const CPUSpecificParams& item) { - const auto &selected = std::get<3>(item); - // when no bf16 hardware brgconv will not work - if (!with_bf16 && selected.find("brgconv") != std::string::npos) { - return false; - } - return true; - }); - - return filterCPUInfoForDevice(specificParams); -} - -/* COMMON PARAMS */ -const std::vector fusingParamsSet{ - emptyFusingSpec, - // eltwise - fusingRelu, - fusingPRelu1DScaleShift, - // depthwise - fusingReluScaleShift, - // fake quantize - fusingFakeQuantizePerTensorRelu, - fusingFakeQuantizePerChannelRelu, - // sum - fusingSumEluFQ, - fusingSum, - // bias - fusingAddPerChannel -}; - -const std::vector fusingParamsSetBF16{ - emptyFusingSpec, - // eltwise - fusingRelu, - // depthwise - fusingPRelu1DScaleShift, - // sum - fusingSum, - // bias - fusingAddPerChannel -}; - -/* ============= Convolution params (GEMM layout) ============= */ -const SizeVector numOutChannels_Gemm = { 6 }; - -/* ============= Convolution params (blocked and nspc layout) ============= */ -const SizeVector numOutChannels = { 64, 63 }; - -/* ============= Convolution params (1D) ============= */ -const std::vector kernels1d = { {3}, {1} }; -const std::vector strides1d = { {1}, {2} }; -const std::vector> padBegins1d = { {0}, {1} }; -const std::vector> padEnds1d = { {0} }; -const std::vector dilations1d = { {1}, {2} }; -std::vector inputShapes1d = { - {{}, {{ 2, 64, 7 }}}, - {{}, {{ 1, 67, 7 }}}, - { - //dynamic shape - { -1, 64, {1, 200} }, - { //target static shapes - { 2, 64, 7 }, - { 1, 64, 9 } - } - }, - { - //dynamic shape - { -1, 67, {1, 200} }, - { //target static shapes - { 2, 67, 7 }, - { 1, 67, 9 } - } - }, - { - //dynamic shape - { {1, 200}, 64, -1 }, - { //target static shapes - { 2, 64, 7 }, - { 1, 64, 5 } - } - } -}; -std::vector inputShapesPlain2Blocked1d = { - {{}, {{1, 1, 7}}}, - {{}, {{1, 2, 7}}}, - {{}, {{1, 3, 7}}}, - { - //dynamic shapes - {-1, 1, {1, 200}}, - { //target static shapes - {2, 1, 7}, - {1, 1, 9} - } - }, - { - //dynamic shapes - {-1, 3, {1, 200}}, - { //target static shapes - {2, 3, 7}, - {1, 3, 9} - } - } -}; - -/* ============= Convolution params (2D) ============= */ -const std::vector kernels2d = { {3, 3}, {1, 1} }; -const std::vector strides2d = { {1, 1}, {2, 2} }; -const std::vector> padBegins2d = { {0, 0}, {1, 1} }; -const std::vector> padEnds2d = { {0, 0} }; -const std::vector dilations2d = { {1, 1} }; - -std::vector inputShapes2d = { - {{}, {{ 1, 64, 7, 7 }}}, - {{}, {{ 1, 67, 7, 7 }}}, - { - //dynamic shape - { -1, 64, -1, {1, 200} }, - { //target static shapes - { 2, 64, 7, 7 }, - { 1, 64, 9, 9} - } - }, - { - //dynamic shape - { -1, 67, -1, {1, 200} }, - { //target static shapes - { 2, 67, 7, 7 }, - { 1, 67, 9, 9} - } - } -}; - -std::vector inputShapesPlain2Blocked2d = { - {{}, {{ 1, 1, 7, 7 }}}, - {{}, {{ 1, 2, 7, 7 }}}, - {{}, {{ 1, 3, 7, 7 }}}, - { - //dynamic shape - { -1, 1, -1, {1, 200} }, - { //target static shapes - { 2, 1, 7, 7 }, - { 1, 1, 9, 9} - } - }, - { - //dynamic shape - { -1, 3, -1, {1, 200} }, - { //target static shapes - { 2, 3, 7, 7 }, - { 1, 3, 9, 9} - } - } -}; - -/* ============= Convolution params (3D) ============= */ -const std::vector kernels3d = { {3, 3, 3}, {1, 1, 1} }; -const std::vector strides3d = { {1, 1, 1}, {2, 2, 2} }; -const std::vector> padBegins3d = { {0, 0, 0}, {1, 1, 1} }; -const std::vector> padEnds3d = { {0, 0, 0} }; -const std::vector dilations3d = { {1, 1, 1} }; -std::vector inputShapes3d = { - {{}, {{ 1, 64, 7, 7, 7 }}}, - {{}, {{ 1, 67, 7, 7, 7 }}}, - { - //dynamic shapes - { -1, 64, -1, {1, 200}, -1 }, - { //target static shapes - { 1, 64, 7, 7, 7 }, - { 1, 64, 9, 9, 9} - } - }, - { - //dynamic shapes - { -1, 67, -1, {1, 200}, -1 }, - { //target static shapes - { 1, 67, 7, 7, 7 }, - { 1, 67, 9, 9, 9} - } - } -}; -std::vector inputShapesPlain2Blocked3d = { - {{}, {{ 1, 1, 7, 7, 7 }}}, - {{}, {{ 1, 2, 7, 7, 7 }}}, - {{}, {{ 1, 3, 7, 7, 7 }}}, - { - //dynamic shapes - { -1, 1, -1, {1, 200}, -1 }, - { //target static shapes - { 2, 1, 7, 7, 7 }, - { 1, 1, 9, 9, 9 } - } - }, - { - //dynamic shapes - { -1, 3, -1, {1, 200}, -1 }, - { //target static shapes - { 2, 3, 7, 7, 7 }, - { 1, 3, 9, 9, 9 } - } - } -}; -/* ============= */ - -/* INSTANCES */ -/* ============= Convolution (Gemm 1D) ============= */ -const auto convParams_ExplicitPadding_GEMM_1D = ::testing::Combine( - ::testing::ValuesIn(kernels1d), - ::testing::ValuesIn(strides1d), - ::testing::ValuesIn(padBegins1d), - ::testing::ValuesIn(padEnds1d), - ::testing::ValuesIn(dilations1d), - ::testing::ValuesIn(numOutChannels_Gemm), - ::testing::Values(ngraph::op::PadType::EXPLICIT) -); - -const std::vector CPUParams_GEMM_1D = { - conv_gemm_1D, - conv_gemm_1D_nspc -}; - -std::vector inShapesGemm1D = { - {{}, {{ 2, 12, 7 }}}, - { - //dynamic shape - { {1, 200}, 12, {1, 200} }, - { //target static shapes - { 2, 12, 7 }, - { 1, 12, 5 } - } - } -}; - -INSTANTIATE_TEST_SUITE_P(smoke_Conv_1D_GEMM_FP32, ConvolutionLayerCPUTest, - ::testing::Combine( - ::testing::Combine( - convParams_ExplicitPadding_GEMM_1D, - ::testing::Values(ElementType::f32), - ::testing::Values(ElementType::undefined), - ::testing::Values(ElementType::undefined), - ::testing::ValuesIn(inShapesGemm1D), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - ::testing::ValuesIn(filterCPUInfoForDevice(CPUParams_GEMM_1D)), - ::testing::ValuesIn(fusingParamsSet), - ::testing::Values(cpuEmptyPluginConfig)), - ConvolutionLayerCPUTest::getTestCaseName); - -// Verify that even if primitive is missed in custom priority list there is still a fallback to the default priority list -const auto conv_gemm_1D_improperPriorityList = CPUSpecificParams{{ncw}, {ncw}, {"unknown"}, "jit_gemm"}; - -INSTANTIATE_TEST_SUITE_P(smoke_Conv_1D_GEMM_FP32_ImproperPriorityList, ConvolutionLayerCPUTest, - ::testing::Combine( - ::testing::Combine( - convParams_ExplicitPadding_GEMM_1D, - ::testing::Values(ElementType::f32), - ::testing::Values(ElementType::undefined), - ::testing::Values(ElementType::undefined), - ::testing::ValuesIn(inShapesGemm1D), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - ::testing::ValuesIn(filterCPUInfoForDevice({conv_gemm_1D})), - ::testing::Values(emptyFusingSpec), - ::testing::Values(cpuEmptyPluginConfig)), - ConvolutionLayerCPUTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_Conv_1D_GEMM_BF16, ConvolutionLayerCPUTest, - ::testing::Combine( - ::testing::Combine( - convParams_ExplicitPadding_GEMM_1D, - ::testing::Values(ElementType::f32), - ::testing::Values(ElementType::undefined), - ::testing::Values(ElementType::undefined), - ::testing::ValuesIn(inShapesGemm1D), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - ::testing::ValuesIn(filterCPUInfoForDevice({conv_gemm_1D})), // todo: [AV] what about conv_gemm_1D_nspc? - ::testing::ValuesIn(fusingParamsSetBF16), - ::testing::Values(cpuBF16PluginConfig)), - ConvolutionLayerCPUTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_Conv_1D_GEMM_I8, ConvolutionLayerCPUTest, - ::testing::Combine( - ::testing::Combine( - convParams_ExplicitPadding_GEMM_1D, - ::testing::Values(ElementType::f32), - ::testing::Values(ElementType::i8), - ::testing::Values(ElementType::undefined), - ::testing::ValuesIn(inShapesGemm1D), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - ::testing::ValuesIn(filterCPUInfoForDevice(CPUParams_GEMM_1D)), - ::testing::Values(fusingSum), - ::testing::Values(cpuEmptyPluginConfig)), - ConvolutionLayerCPUTest::getTestCaseName); - -/* ============= Convolution (Gemm 2D) ============= */ -const auto convParams_ExplicitPadding_GEMM_2D = ::testing::Combine( - ::testing::ValuesIn(kernels2d), - ::testing::ValuesIn(strides2d), - ::testing::ValuesIn(padBegins2d), - ::testing::ValuesIn(padEnds2d), - ::testing::ValuesIn(dilations2d), - ::testing::ValuesIn(numOutChannels_Gemm), - ::testing::Values(ngraph::op::PadType::EXPLICIT) -); - -const auto convParams_ExplicitPadding_GEMM_2D_dilated = ::testing::Combine( - ::testing::ValuesIn(kernels2d), - ::testing::ValuesIn(strides2d), - ::testing::ValuesIn(padBegins2d), - ::testing::ValuesIn(padEnds2d), - ::testing::Values(SizeVector{2, 2}), - ::testing::ValuesIn(numOutChannels_Gemm), - ::testing::Values(ngraph::op::PadType::EXPLICIT) -); - -const std::vector CPUParams_GEMM_2D = { - conv_gemm_2D, - conv_gemm_2D_nspc -}; - -std::vector inShapesGemm2D = { - {{}, {{ 2, 12, 7, 7 }}}, - { - //dynamic shape - { {1, 200}, 12, -1, {1, 200} }, - { //target static shapes - { 2, 12, 7, 7 }, - { 1, 12, 5, 5 } - } - } -}; - -std::vector inShapesGemm2D_cache = { - {{}, {{ 2, 12, 7, 7 }}}, - { - //dynamic shape - { {1, 200}, 12, -1, {1, 200} }, - { //target static shapes - { 1, 12, 5, 5 }, - { 1, 12, 7, 7 }, - { 1, 12, 5, 5 } - } - } -}; - -INSTANTIATE_TEST_SUITE_P(smoke_Conv_2D_GEMM_FP32, ConvolutionLayerCPUTest, - ::testing::Combine( - ::testing::Combine( - convParams_ExplicitPadding_GEMM_2D, - ::testing::Values(ElementType::f32), - ::testing::Values(ElementType::undefined), - ::testing::Values(ElementType::undefined), - ::testing::ValuesIn(inShapesGemm2D_cache), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - ::testing::ValuesIn(filterCPUInfoForDevice(CPUParams_GEMM_2D)), - ::testing::ValuesIn(fusingParamsSet), - ::testing::Values(cpuEmptyPluginConfig)), - ConvolutionLayerCPUTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_Conv_2D_GEMM_BF16, ConvolutionLayerCPUTest, - ::testing::Combine( - ::testing::Combine( - convParams_ExplicitPadding_GEMM_2D, - ::testing::Values(ElementType::f32), - ::testing::Values(ElementType::undefined), - ::testing::Values(ElementType::undefined), - ::testing::ValuesIn(inShapesGemm2D), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - ::testing::ValuesIn(filterCPUInfoForDevice(CPUParams_GEMM_2D)), - ::testing::ValuesIn(fusingParamsSetBF16), - ::testing::Values(cpuBF16PluginConfig)), - ConvolutionLayerCPUTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_Conv_2D_GEMM_I8, ConvolutionLayerCPUTest, - ::testing::Combine( - ::testing::Combine( - convParams_ExplicitPadding_GEMM_2D, - ::testing::Values(ElementType::f32), - ::testing::Values(ElementType::i8), - ::testing::Values(ElementType::undefined), - ::testing::ValuesIn(inShapesGemm2D), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - ::testing::ValuesIn(filterCPUInfoForDevice(CPUParams_GEMM_2D)), - ::testing::Values(fusingSum), - ::testing::Values(cpuEmptyPluginConfig)), - ConvolutionLayerCPUTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(Conv_2D_GEMM_FP32_dilated, ConvolutionLayerCPUTest, - ::testing::Combine( - ::testing::Combine( - convParams_ExplicitPadding_GEMM_2D_dilated, - ::testing::Values(ElementType::f32), - ::testing::Values(ElementType::undefined), - ::testing::Values(ElementType::undefined), - ::testing::ValuesIn(inShapesGemm2D), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - ::testing::ValuesIn(filterCPUInfoForDevice(CPUParams_GEMM_2D)), - ::testing::ValuesIn(fusingParamsSet), - ::testing::Values(cpuEmptyPluginConfig)), - ConvolutionLayerCPUTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(Conv_2D_GEMM_BF16_dilated, ConvolutionLayerCPUTest, - ::testing::Combine( - ::testing::Combine( - convParams_ExplicitPadding_GEMM_2D_dilated, - ::testing::Values(ElementType::f32), - ::testing::Values(ElementType::undefined), - ::testing::Values(ElementType::undefined), - ::testing::ValuesIn(inShapesGemm2D), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - ::testing::ValuesIn(filterCPUInfoForDevice(CPUParams_GEMM_2D)), - ::testing::ValuesIn(fusingParamsSetBF16), - ::testing::Values(cpuBF16PluginConfig)), - ConvolutionLayerCPUTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(Conv_2D_GEMM_I8_dilated, ConvolutionLayerCPUTest, - ::testing::Combine( - ::testing::Combine( - convParams_ExplicitPadding_GEMM_2D_dilated, - ::testing::Values(ElementType::f32), - ::testing::Values(ElementType::i8), - ::testing::Values(ElementType::undefined), - ::testing::ValuesIn(inShapesGemm2D), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - ::testing::ValuesIn(filterCPUInfoForDevice(CPUParams_GEMM_2D)), - ::testing::Values(fusingSum), - ::testing::Values(cpuEmptyPluginConfig)), - ConvolutionLayerCPUTest::getTestCaseName); - -/* ============= Convolution (GEMM 3D) ============= */ -const auto convParams_ExplicitPadding_GEMM_3D = ::testing::Combine( - ::testing::ValuesIn(kernels3d), - ::testing::ValuesIn(strides3d), - ::testing::ValuesIn(padBegins3d), - ::testing::ValuesIn(padEnds3d), - ::testing::ValuesIn(dilations3d), - ::testing::ValuesIn(numOutChannels_Gemm), - ::testing::Values(ngraph::op::PadType::EXPLICIT) -); - -const auto convParams_ExplicitPadding_GEMM_3D_dilated = ::testing::Combine( - ::testing::ValuesIn(kernels3d), - ::testing::ValuesIn(strides3d), - ::testing::ValuesIn(padBegins3d), - ::testing::ValuesIn(padEnds3d), - ::testing::Values(SizeVector{2, 2, 2}), - ::testing::ValuesIn(numOutChannels_Gemm), - ::testing::Values(ngraph::op::PadType::EXPLICIT) -); - -const std::vector CPUParams_GEMM_3D = { - conv_gemm_3D, - conv_gemm_3D_nspc -}; - -std::vector inShapesGemm3D = { - {{}, {{ 2, 12, 7, 7, 7 }}}, - { - //dynamic shape - { {1, 200}, 12, -1, {1, 200}, -1 }, - { //target static shapes - { 2, 12, 7, 7, 7 }, - { 1, 12, 5, 5, 5 } - } - } -}; - -INSTANTIATE_TEST_SUITE_P(smoke_Conv_3D_GEMM_FP32, ConvolutionLayerCPUTest, - ::testing::Combine( - ::testing::Combine( - convParams_ExplicitPadding_GEMM_3D, - ::testing::Values(ElementType::f32), - ::testing::Values(ElementType::undefined), - ::testing::Values(ElementType::undefined), - ::testing::ValuesIn(inShapesGemm3D), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - ::testing::ValuesIn(filterCPUInfoForDevice(CPUParams_GEMM_3D)), - ::testing::ValuesIn(fusingParamsSet), - ::testing::Values(cpuEmptyPluginConfig)), - ConvolutionLayerCPUTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_Conv_3D_GEMM_BF16, ConvolutionLayerCPUTest, - ::testing::Combine( - ::testing::Combine( - convParams_ExplicitPadding_GEMM_3D, - ::testing::Values(ElementType::f32), - ::testing::Values(ElementType::undefined), - ::testing::Values(ElementType::undefined), - ::testing::ValuesIn(inShapesGemm3D), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - ::testing::ValuesIn(filterCPUInfoForDevice(CPUParams_GEMM_3D)), - ::testing::ValuesIn(fusingParamsSetBF16), - ::testing::Values(cpuBF16PluginConfig)), - ConvolutionLayerCPUTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_Conv_3D_GEMM_I8, ConvolutionLayerCPUTest, - ::testing::Combine( - ::testing::Combine( - convParams_ExplicitPadding_GEMM_3D, - ::testing::Values(ElementType::f32), - ::testing::Values(ElementType::i8), - ::testing::Values(ElementType::undefined), - ::testing::ValuesIn(inShapesGemm3D), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - ::testing::ValuesIn(filterCPUInfoForDevice(CPUParams_GEMM_3D)), - ::testing::Values(fusingSum), - ::testing::Values(cpuEmptyPluginConfig)), - ConvolutionLayerCPUTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(Conv_3D_GEMM_FP32_dilated, ConvolutionLayerCPUTest, - ::testing::Combine( - ::testing::Combine( - convParams_ExplicitPadding_GEMM_3D_dilated, - ::testing::Values(ElementType::f32), - ::testing::Values(ElementType::undefined), - ::testing::Values(ElementType::undefined), - ::testing::ValuesIn(inShapesGemm3D), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - ::testing::ValuesIn(filterCPUInfoForDevice(CPUParams_GEMM_3D)), - ::testing::ValuesIn(fusingParamsSet), - ::testing::Values(cpuEmptyPluginConfig)), - ConvolutionLayerCPUTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(Conv_3D_GEMM_BF16_dilated, ConvolutionLayerCPUTest, - ::testing::Combine( - ::testing::Combine( - convParams_ExplicitPadding_GEMM_3D_dilated, - ::testing::Values(ElementType::f32), - ::testing::Values(ElementType::undefined), - ::testing::Values(ElementType::undefined), - ::testing::ValuesIn(inShapesGemm3D), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - ::testing::ValuesIn(filterCPUInfoForDevice(CPUParams_GEMM_3D)), - ::testing::ValuesIn(fusingParamsSetBF16), - ::testing::Values(cpuBF16PluginConfig)), - ConvolutionLayerCPUTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(Conv_3D_GEMM_I8_dilated, ConvolutionLayerCPUTest, - ::testing::Combine( - ::testing::Combine( - convParams_ExplicitPadding_GEMM_3D_dilated, - ::testing::Values(ElementType::f32), - ::testing::Values(ElementType::i8), - ::testing::Values(ElementType::undefined), - ::testing::ValuesIn(inShapesGemm3D), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - ::testing::ValuesIn(filterCPUInfoForDevice(CPUParams_GEMM_3D)), - ::testing::Values(fusingSum), - ::testing::Values(cpuEmptyPluginConfig)), - ConvolutionLayerCPUTest::getTestCaseName); - -/* ============= Convolution (1D) ============= */ -const auto convParams_ExplicitPadding_1D = ::testing::Combine( - ::testing::ValuesIn(kernels1d), - ::testing::ValuesIn(strides1d), - ::testing::ValuesIn(padBegins1d), - ::testing::ValuesIn(padEnds1d), - ::testing::ValuesIn(dilations1d), - ::testing::ValuesIn(numOutChannels), - ::testing::Values(ngraph::op::PadType::EXPLICIT) -); - -const std::vector CPUParams_1D = { - conv_sse42_1D, - conv_avx2_1D, - conv_avx512_1D, - conv_sse42_1D_nspc, - conv_avx2_1D_nspc, - conv_avx2_1D_nspc_brgconv, - conv_avx512_1D_nspc, - conv_avx512_1D_nspc_brgconv -}; - -INSTANTIATE_TEST_SUITE_P(smoke_Conv_1D_FP32, ConvolutionLayerCPUTest, - ::testing::Combine( - ::testing::Combine( - convParams_ExplicitPadding_1D, - ::testing::Values(ElementType::f32), - ::testing::Values(ElementType::undefined), - ::testing::Values(ElementType::undefined), - ::testing::ValuesIn(inputShapes1d), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - ::testing::ValuesIn(filterCPUInfoForDevice(CPUParams_1D)), - ::testing::ValuesIn(fusingParamsSet), - ::testing::Values(cpuEmptyPluginConfig)), - ConvolutionLayerCPUTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_Conv_1D_BF16, ConvolutionLayerCPUTest, - ::testing::Combine( - ::testing::Combine( - convParams_ExplicitPadding_1D, - ::testing::Values(ElementType::f32), - ::testing::Values(ElementType::undefined), - ::testing::Values(ElementType::undefined), - ::testing::ValuesIn(inputShapes1d), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - ::testing::ValuesIn(filterCPUInfoForDevice_BF16({conv_avx512_1D, - conv_avx512_1D_nspc_brgconv, conv_avx512_1D_nspc_brgconv_amx})), // todo: [AV] what about conv_avx512_1D_nspc? - ::testing::ValuesIn(fusingParamsSetBF16), - ::testing::Values(cpuBF16PluginConfig)), - ConvolutionLayerCPUTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_Conv_1D_I8, ConvolutionLayerCPUTest, - ::testing::Combine( - ::testing::Combine( - convParams_ExplicitPadding_1D, - ::testing::Values(ElementType::f32), - ::testing::Values(ElementType::i8), - ::testing::Values(ElementType::undefined), - ::testing::ValuesIn(inputShapes1d), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - ::testing::ValuesIn(filterCPUInfoForDevice(CPUParams_1D)), - ::testing::Values(fusingSum), - ::testing::Values(cpuEmptyPluginConfig)), - ConvolutionLayerCPUTest::getTestCaseName); - -const std::vector CPUParams_1D_plain_to_blocked = { - conv_sse42_plain_to_blocked_1D, - conv_avx2_plain_to_blocked_1D, - conv_avx512_plain_to_blocked_1D, -}; - -INSTANTIATE_TEST_SUITE_P(smoke_Conv_1D_PlainToBlocked_FP32, ConvolutionLayerCPUTest, - ::testing::Combine( - ::testing::Combine( - convParams_ExplicitPadding_1D, - ::testing::Values(ElementType::f32), - ::testing::Values(ElementType::undefined), - ::testing::Values(ElementType::undefined), - ::testing::ValuesIn(inputShapesPlain2Blocked1d), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - ::testing::ValuesIn(filterCPUInfoForDevice(CPUParams_1D_plain_to_blocked)), - ::testing::Values(emptyFusingSpec), - ::testing::Values(cpuEmptyPluginConfig)), - ConvolutionLayerCPUTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_Conv_1D_PlainToBlocked_BF16, ConvolutionLayerCPUTest, - ::testing::Combine( - ::testing::Combine( - convParams_ExplicitPadding_1D, - ::testing::Values(ElementType::f32), - ::testing::Values(ElementType::undefined), - ::testing::Values(ElementType::undefined), - ::testing::ValuesIn(inputShapesPlain2Blocked1d), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - ::testing::ValuesIn(filterCPUInfoForDevice({conv_avx512_plain_to_blocked_1D})), - ::testing::Values(emptyFusingSpec), - ::testing::Values(cpuEmptyPluginConfig)), - ConvolutionLayerCPUTest::getTestCaseName); - -/* ============= Convolution (2D) ============= */ -const auto convParams_ExplicitPadding_2D = ::testing::Combine( - ::testing::ValuesIn(kernels2d), - ::testing::ValuesIn(strides2d), - ::testing::ValuesIn(padBegins2d), - ::testing::ValuesIn(padEnds2d), - ::testing::ValuesIn(dilations2d), - ::testing::ValuesIn(numOutChannels), - ::testing::Values(ngraph::op::PadType::EXPLICIT) -); - -const auto convParams_ExplicitPadding_2D_dilated = ::testing::Combine( - ::testing::ValuesIn(kernels2d), - ::testing::ValuesIn(strides2d), - ::testing::ValuesIn(padBegins2d), - ::testing::ValuesIn(padEnds2d), - ::testing::Values(SizeVector{2, 2}), - ::testing::ValuesIn(numOutChannels), - ::testing::Values(ngraph::op::PadType::EXPLICIT) -); - -const std::vector CPUParams_2D = { - conv_sse42_2D, - conv_avx2_2D, - conv_avx512_2D, - conv_sse42_2D_nspc, - conv_avx2_2D_nspc, - conv_avx2_2D_nspc_brgconv, - conv_avx512_2D_nspc, - conv_avx512_2D_nspc_brgconv -}; - -std::vector inputShapes2d_cache = { - {{}, {{ 1, 64, 7, 7 }}}, - {{}, {{ 1, 67, 7, 7 }}}, - { - //dynamic shape - { -1, 64, -1, {1, 200} }, - { //target static shapes - { 1, 64, 7, 7 }, - { 1, 64, 9, 9 }, - { 1, 64, 7, 7 } - } - }, - { - //dynamic shape - { -1, 67, -1, {1, 200} }, - { //target static shapes - { 1, 67, 7, 7 }, - { 1, 67, 9, 9} - } - } -}; - -INSTANTIATE_TEST_SUITE_P(smoke_Conv_2D_FP32, ConvolutionLayerCPUTest, - ::testing::Combine( - ::testing::Combine( - convParams_ExplicitPadding_2D, - ::testing::Values(ElementType::f32), - ::testing::Values(ElementType::undefined), - ::testing::Values(ElementType::undefined), - ::testing::ValuesIn(inputShapes2d_cache), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - ::testing::ValuesIn(filterCPUInfoForDevice(CPUParams_2D)), - ::testing::ValuesIn(fusingParamsSet), - ::testing::Values(cpuEmptyPluginConfig)), - ConvolutionLayerCPUTest::getTestCaseName); - -std::vector inputShapes2d_dynBatch = { - { - //dynamic shape - { {1, 10}, 64, 7, 7 }, - { //target static shapes - { 2, 64, 7, 7 }, - { 1, 64, 7, 7 } - } - }, -}; - -const std::vector fusingParamsSet_dynBatch{ - emptyFusingSpec, - fusingReluScaleShift, - fusingSum, - fusingAddPerChannel -}; - -INSTANTIATE_TEST_SUITE_P(smoke_Conv_2D_FP32_dynBatch, ConvolutionLayerCPUTest, - ::testing::Combine( - ::testing::Combine( - convParams_ExplicitPadding_2D, - ::testing::Values(ElementType::f32), - ::testing::Values(ElementType::undefined), - ::testing::Values(ElementType::undefined), - ::testing::ValuesIn(inputShapes2d_dynBatch), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - ::testing::ValuesIn(filterCPUInfoForDevice(CPUParams_2D)), - ::testing::ValuesIn(fusingParamsSet_dynBatch), - ::testing::Values(cpuEmptyPluginConfig)), - ConvolutionLayerCPUTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_Conv_2D_BF16, ConvolutionLayerCPUTest, - ::testing::Combine( - ::testing::Combine( - convParams_ExplicitPadding_2D, - ::testing::Values(ElementType::f32), - ::testing::Values(ElementType::undefined), - ::testing::Values(ElementType::undefined), - ::testing::ValuesIn(inputShapes2d), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - ::testing::ValuesIn(filterCPUInfoForDevice_BF16({conv_avx512_2D, conv_avx512_2D_nspc, - conv_avx512_2D_nspc_brgconv, conv_avx512_2D_nspc_brgconv_amx})), - ::testing::ValuesIn(fusingParamsSetBF16), - ::testing::Values(cpuBF16PluginConfig)), - ConvolutionLayerCPUTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_Conv_2D_I8, ConvolutionLayerCPUTest, - ::testing::Combine( - ::testing::Combine( - convParams_ExplicitPadding_2D, - ::testing::Values(ElementType::f32), - ::testing::Values(ElementType::i8), - ::testing::Values(ElementType::undefined), - ::testing::ValuesIn(inputShapes2d), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - ::testing::ValuesIn(filterCPUInfoForDevice(CPUParams_2D)), - ::testing::Values(fusingSum), - ::testing::Values(cpuEmptyPluginConfig)), - ConvolutionLayerCPUTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(Conv_2D_FP32_dilated, ConvolutionLayerCPUTest, - ::testing::Combine( - ::testing::Combine( - convParams_ExplicitPadding_2D_dilated, - ::testing::Values(ElementType::f32), - ::testing::Values(ElementType::undefined), - ::testing::Values(ElementType::undefined), - ::testing::ValuesIn(inputShapes2d), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - ::testing::ValuesIn(filterCPUInfoForDevice(CPUParams_2D)), - ::testing::ValuesIn(fusingParamsSet), - ::testing::Values(cpuEmptyPluginConfig)), - ConvolutionLayerCPUTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(Conv_2D_BF16_dilated, ConvolutionLayerCPUTest, - ::testing::Combine( - ::testing::Combine( - convParams_ExplicitPadding_2D_dilated, - ::testing::Values(ElementType::f32), - ::testing::Values(ElementType::undefined), - ::testing::Values(ElementType::undefined), - ::testing::ValuesIn(inputShapes2d), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - ::testing::ValuesIn(filterCPUInfoForDevice_BF16({conv_avx512_2D, conv_avx512_2D_nspc, - conv_avx512_2D_nspc_brgconv, conv_avx512_2D_nspc_brgconv_amx})), - ::testing::ValuesIn(fusingParamsSetBF16), - ::testing::Values(cpuBF16PluginConfig)), - ConvolutionLayerCPUTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(Conv_2D_I8_dilated, ConvolutionLayerCPUTest, - ::testing::Combine( - ::testing::Combine( - convParams_ExplicitPadding_2D_dilated, - ::testing::Values(ElementType::f32), - ::testing::Values(ElementType::i8), - ::testing::Values(ElementType::undefined), - ::testing::ValuesIn(inputShapes2d), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - ::testing::ValuesIn(filterCPUInfoForDevice(CPUParams_2D)), - ::testing::Values(fusingSum), - ::testing::Values(cpuEmptyPluginConfig)), - ConvolutionLayerCPUTest::getTestCaseName); - -const std::vector CPUParams_2D_plain_to_blocked = { - conv_sse42_plain_to_blocked_2D, - conv_avx2_plain_to_blocked_2D, - conv_avx512_plain_to_blocked_2D, -}; - -INSTANTIATE_TEST_SUITE_P(smoke_Conv_2D_PlainToBlocked_FP32, ConvolutionLayerCPUTest, - ::testing::Combine( - ::testing::Combine( - convParams_ExplicitPadding_2D, - ::testing::Values(ElementType::f32), - ::testing::Values(ElementType::undefined), - ::testing::Values(ElementType::undefined), - ::testing::ValuesIn(inputShapesPlain2Blocked2d), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - ::testing::ValuesIn(filterCPUInfoForDevice(CPUParams_2D_plain_to_blocked)), - ::testing::Values(emptyFusingSpec), - ::testing::Values(cpuEmptyPluginConfig)), - ConvolutionLayerCPUTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_Conv_2D_PlainToBlocked_BF16, ConvolutionLayerCPUTest, - ::testing::Combine( - ::testing::Combine( - convParams_ExplicitPadding_2D, - ::testing::Values(ElementType::f32), - ::testing::Values(ElementType::undefined), - ::testing::Values(ElementType::undefined), - ::testing::ValuesIn(inputShapesPlain2Blocked2d), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - ::testing::ValuesIn(filterCPUInfoForDevice({conv_avx512_plain_to_blocked_2D})), - ::testing::Values(emptyFusingSpec), - ::testing::Values(cpuEmptyPluginConfig)), - ConvolutionLayerCPUTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(Conv_PlainToBlocked_2D_FP32_dilated, ConvolutionLayerCPUTest, - ::testing::Combine( - ::testing::Combine( - convParams_ExplicitPadding_2D_dilated, - ::testing::Values(ElementType::f32), - ::testing::Values(ElementType::undefined), - ::testing::Values(ElementType::undefined), - ::testing::ValuesIn(inputShapesPlain2Blocked2d), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - ::testing::ValuesIn(filterCPUInfoForDevice(CPUParams_2D_plain_to_blocked)), - ::testing::Values(emptyFusingSpec), - ::testing::Values(cpuEmptyPluginConfig)), - ConvolutionLayerCPUTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(Conv_PlainToBlocked_2D_BF16_dilated, ConvolutionLayerCPUTest, - ::testing::Combine( - ::testing::Combine( - convParams_ExplicitPadding_2D_dilated, - ::testing::Values(ElementType::f32), - ::testing::Values(ElementType::undefined), - ::testing::Values(ElementType::undefined), - ::testing::ValuesIn(inputShapesPlain2Blocked2d), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - ::testing::ValuesIn(filterCPUInfoForDevice({conv_avx512_plain_to_blocked_2D})), - ::testing::Values(emptyFusingSpec), - ::testing::Values(cpuEmptyPluginConfig)), - ConvolutionLayerCPUTest::getTestCaseName); - -/* ============= Reorder + Convolution ============= */ -const auto convParams_Reorder_2D = ::testing::Combine( - ::testing::Values(SizeVector{1, 1}), - ::testing::Values(SizeVector{2, 2}), - ::testing::Values(std::vector{0, 0}), - ::testing::Values(std::vector{0, 0}), - ::testing::Values(SizeVector{1, 1}), - ::testing::Values(64), - ::testing::Values(ngraph::op::PadType::EXPLICIT) -); - -std::vector inputShapes_Reorder_2D = { - { - // dynamic shape - { -1, 32, -1, -1 }, - // target static shapes - { - { 1, 32, 39, 40 }, - { 2, 32, 20, 20 }, - { 1, 32, 39, 40 }, - { 2, 32, 20, 20 } - } - } -}; - -const std::vector fusingParamsSet_reorder{ - emptyFusingSpec, - fusingReluScaleShift, - fusingAddPerChannel -}; - -INSTANTIATE_TEST_SUITE_P(smoke_reorder_Conv_2D, ConvolutionLayerCPUTest, - ::testing::Combine( - ::testing::Combine( - convParams_Reorder_2D, - ::testing::Values(ElementType::f32), - ::testing::Values(ElementType::undefined), - ::testing::Values(ElementType::undefined), - ::testing::ValuesIn(inputShapes_Reorder_2D), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - ::testing::ValuesIn(filterCPUInfoForDevice({conv_avx512_2D_1x1})), - ::testing::ValuesIn(fusingParamsSet_reorder), - ::testing::Values(cpuEmptyPluginConfig)), - ConvolutionLayerCPUTest::getTestCaseName); - -/* ============= Convolution (3D) ============= */ -const auto convParams_ExplicitPadding_3D = ::testing::Combine( - ::testing::ValuesIn(kernels3d), - ::testing::ValuesIn(strides3d), - ::testing::ValuesIn(padBegins3d), - ::testing::ValuesIn(padEnds3d), - ::testing::ValuesIn(dilations3d), - ::testing::ValuesIn(numOutChannels), - ::testing::Values(ngraph::op::PadType::EXPLICIT) -); - -const auto convParams_ExplicitPadding_3D_dilated = ::testing::Combine( - ::testing::ValuesIn(kernels3d), - ::testing::ValuesIn(strides3d), - ::testing::ValuesIn(padBegins3d), - ::testing::ValuesIn(padEnds3d), - ::testing::Values(SizeVector{2, 2, 2}), - ::testing::ValuesIn(numOutChannels), - ::testing::Values(ngraph::op::PadType::EXPLICIT) -); - -const std::vector CPUParams_3D = { - //conv_sse42_3D, // not supported jit_sse42 for 3d - conv_avx2_3D, - conv_avx512_3D, - conv_avx2_3D_nspc, - conv_avx2_3D_nspc_brgconv, - conv_avx512_3D_nspc, - conv_avx512_3D_nspc_brgconv -}; - -INSTANTIATE_TEST_SUITE_P(smoke_Conv_3D_FP32, ConvolutionLayerCPUTest, - ::testing::Combine( - ::testing::Combine( - convParams_ExplicitPadding_3D, - ::testing::Values(ElementType::f32), - ::testing::Values(ElementType::undefined), - ::testing::Values(ElementType::undefined), - ::testing::ValuesIn(inputShapes3d), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - ::testing::ValuesIn(filterCPUInfoForDevice(CPUParams_3D)), - ::testing::ValuesIn(fusingParamsSet), - ::testing::Values(cpuEmptyPluginConfig)), - ConvolutionLayerCPUTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_Conv_3D_FP32_fusingScaleShiftAndFakeQuantizePerChannel, ConvolutionLayerCPUTest, - ::testing::Combine( - ::testing::Combine( - convParams_ExplicitPadding_3D, - ::testing::Values(ElementType::f32), - ::testing::Values(ElementType::undefined), - ::testing::Values(ElementType::undefined), - ::testing::ValuesIn(inputShapes3d), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - ::testing::ValuesIn(filterCPUInfoForDevice(CPUParams_3D)), - ::testing::Values(fusingScaleShiftAndFakeQuantizePerChannel), - ::testing::Values(cpuEmptyPluginConfig)), - ConvolutionLayerCPUTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_Conv_3D_BF16, ConvolutionLayerCPUTest, - ::testing::Combine( - ::testing::Combine( - convParams_ExplicitPadding_3D, - ::testing::Values(ElementType::f32), - ::testing::Values(ElementType::undefined), - ::testing::Values(ElementType::undefined), - ::testing::ValuesIn(inputShapes3d), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - ::testing::ValuesIn(filterCPUInfoForDevice_BF16({conv_avx512_3D, conv_avx512_3D_nspc, - conv_avx512_3D_nspc_brgconv, conv_avx512_3D_nspc_brgconv_amx})), - ::testing::ValuesIn(fusingParamsSetBF16), - ::testing::Values(cpuBF16PluginConfig)), - ConvolutionLayerCPUTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_Conv_3D_I8, ConvolutionLayerCPUTest, - ::testing::Combine( - ::testing::Combine( - convParams_ExplicitPadding_3D, - ::testing::Values(ElementType::f32), - ::testing::Values(ElementType::i8), - ::testing::Values(ElementType::undefined), - ::testing::ValuesIn(inputShapes3d), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - ::testing::ValuesIn(filterCPUInfoForDevice(CPUParams_3D)), - ::testing::Values(fusingSum), - ::testing::Values(cpuEmptyPluginConfig)), - ConvolutionLayerCPUTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(Conv_3D_FP32_dilated, ConvolutionLayerCPUTest, - ::testing::Combine( - ::testing::Combine( - convParams_ExplicitPadding_3D_dilated, - ::testing::Values(ElementType::f32), - ::testing::Values(ElementType::undefined), - ::testing::Values(ElementType::undefined), - ::testing::ValuesIn(inputShapes3d), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - ::testing::ValuesIn(filterCPUInfoForDevice(CPUParams_3D)), - ::testing::ValuesIn(fusingParamsSet), - ::testing::Values(cpuEmptyPluginConfig)), - ConvolutionLayerCPUTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(Conv_3D_BF16_dilated, ConvolutionLayerCPUTest, - ::testing::Combine( - ::testing::Combine( - convParams_ExplicitPadding_3D_dilated, - ::testing::Values(ElementType::f32), - ::testing::Values(ElementType::undefined), - ::testing::Values(ElementType::undefined), - ::testing::ValuesIn(inputShapes3d), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - ::testing::ValuesIn(filterCPUInfoForDevice_BF16({conv_avx512_3D, conv_avx512_3D_nspc, - conv_avx512_3D_nspc_brgconv, conv_avx512_3D_nspc_brgconv_amx})), - ::testing::ValuesIn(fusingParamsSetBF16), - ::testing::Values(cpuBF16PluginConfig)), - ConvolutionLayerCPUTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(Conv_3D_I8_dilated, ConvolutionLayerCPUTest, - ::testing::Combine( - ::testing::Combine( - convParams_ExplicitPadding_3D_dilated, - ::testing::Values(ElementType::f32), - ::testing::Values(ElementType::i8), - ::testing::Values(ElementType::undefined), - ::testing::ValuesIn(inputShapes3d), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - ::testing::ValuesIn(filterCPUInfoForDevice(CPUParams_3D)), - ::testing::Values(fusingSum), - ::testing::Values(cpuEmptyPluginConfig)), - ConvolutionLayerCPUTest::getTestCaseName); - -const std::vector CPUParams_3D_plain_to_blocked = { - conv_avx2_plain_to_blocked_3D, - conv_avx512_plain_to_blocked_3D, -}; - -INSTANTIATE_TEST_SUITE_P(smoke_Conv_3D_PlainToBlocked_FP32, ConvolutionLayerCPUTest, - ::testing::Combine( - ::testing::Combine( - convParams_ExplicitPadding_3D, - ::testing::Values(ElementType::f32), - ::testing::Values(ElementType::undefined), - ::testing::Values(ElementType::undefined), - ::testing::ValuesIn(inputShapesPlain2Blocked3d), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - ::testing::ValuesIn(filterCPUInfoForDevice(CPUParams_3D_plain_to_blocked)), - ::testing::Values(emptyFusingSpec), - ::testing::Values(cpuEmptyPluginConfig)), - ConvolutionLayerCPUTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_Conv_3D_PlainToBlocked_BF16, ConvolutionLayerCPUTest, - ::testing::Combine( - ::testing::Combine( - convParams_ExplicitPadding_3D, - ::testing::Values(ElementType::f32), - ::testing::Values(ElementType::undefined), - ::testing::Values(ElementType::undefined), - ::testing::ValuesIn(inputShapesPlain2Blocked3d), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - ::testing::ValuesIn(filterCPUInfoForDevice({conv_avx512_plain_to_blocked_3D})), - ::testing::Values(emptyFusingSpec), - ::testing::Values(cpuEmptyPluginConfig)), - ConvolutionLayerCPUTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(Conv_PlainToBlocked_3D_FP32_dilated, ConvolutionLayerCPUTest, - ::testing::Combine( - ::testing::Combine( - convParams_ExplicitPadding_3D_dilated, - ::testing::Values(ElementType::f32), - ::testing::Values(ElementType::undefined), - ::testing::Values(ElementType::undefined), - ::testing::ValuesIn(inputShapesPlain2Blocked3d), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - ::testing::ValuesIn(filterCPUInfoForDevice(CPUParams_3D_plain_to_blocked)), - ::testing::Values(emptyFusingSpec), - ::testing::Values(cpuEmptyPluginConfig)), - ConvolutionLayerCPUTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(Conv_PlainToBlocked_3D_BF16_dilated, ConvolutionLayerCPUTest, - ::testing::Combine( - ::testing::Combine( - convParams_ExplicitPadding_3D_dilated, - ::testing::Values(ElementType::f32), - ::testing::Values(ElementType::undefined), - ::testing::Values(ElementType::undefined), - ::testing::ValuesIn(inputShapesPlain2Blocked3d), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - ::testing::ValuesIn(filterCPUInfoForDevice({conv_avx512_plain_to_blocked_3D})), - ::testing::Values(emptyFusingSpec), - ::testing::Values(cpuEmptyPluginConfig)), - ConvolutionLayerCPUTest::getTestCaseName); - -/* ============= Kernel_1x1 (1D) ============= */ - -const auto convParams_ExplicitPadding_1x1_1D = ::testing::Combine( - ::testing::Values(SizeVector({1})), - ::testing::Values(SizeVector({1})), - ::testing::Values(std::vector({0})), - ::testing::Values(std::vector({0})), - ::testing::Values(SizeVector({1})), - ::testing::Values(63), - ::testing::Values(ngraph::op::PadType::EXPLICIT) -); - -const std::vector CPUParams_1x1_1D = { - conv_sse42_1D_1x1, - conv_avx2_1D_1x1, - conv_avx512_1D_1x1, - conv_sse42_1D_1x1_nspc, - conv_avx2_1D_1x1_nspc, - conv_avx2_1D_1x1_nspc_brgconv, - conv_avx512_1D_1x1_nspc, - conv_avx512_1D_1x1_nspc_brgconv -}; - -INSTANTIATE_TEST_SUITE_P(smoke_Conv_1D_1x1_FP32, ConvolutionLayerCPUTest, - ::testing::Combine( - ::testing::Combine( - convParams_ExplicitPadding_1x1_1D, - ::testing::Values(ElementType::f32), - ::testing::Values(ElementType::undefined), - ::testing::Values(ElementType::undefined), - ::testing::ValuesIn(inputShapes1d), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - ::testing::ValuesIn(filterCPUInfoForDevice(CPUParams_1x1_1D)), - ::testing::ValuesIn(fusingParamsSet), - ::testing::Values(cpuEmptyPluginConfig)), - ConvolutionLayerCPUTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_Conv_1D_1x1_BF16, ConvolutionLayerCPUTest, - ::testing::Combine( - ::testing::Combine( - convParams_ExplicitPadding_1x1_1D, - ::testing::Values(ElementType::f32), - ::testing::Values(ElementType::undefined), - ::testing::Values(ElementType::undefined), - ::testing::ValuesIn(inputShapes1d), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - ::testing::ValuesIn(filterCPUInfoForDevice_BF16({conv_avx512_1D_1x1, conv_avx512_2D_1x1_nspc, - conv_avx512_1D_1x1_nspc_brgconv, conv_avx512_1D_1x1_nspc_brgconv_amx})), - ::testing::ValuesIn(fusingParamsSetBF16), - ::testing::Values(cpuBF16PluginConfig)), - ConvolutionLayerCPUTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_Conv_1D_1x1_I8, ConvolutionLayerCPUTest, - ::testing::Combine( - ::testing::Combine( - convParams_ExplicitPadding_1x1_1D, - ::testing::Values(ElementType::f32), - ::testing::Values(ElementType::i8), - ::testing::Values(ElementType::undefined), - ::testing::ValuesIn(inputShapes1d), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - ::testing::ValuesIn(filterCPUInfoForDevice(CPUParams_1x1_1D)), - ::testing::Values(fusingSum), - ::testing::Values(cpuEmptyPluginConfig)), - ConvolutionLayerCPUTest::getTestCaseName); - -/* ============= Kernel_1x1 (2D) ============= */ - -const auto convParams_ExplicitPadding_1x1_2D = ::testing::Combine( - ::testing::Values(SizeVector({1, 1})), - ::testing::Values(SizeVector({1, 1})), - ::testing::Values(std::vector({0, 0})), - ::testing::Values(std::vector({0, 0})), - ::testing::Values(SizeVector({1, 1})), - ::testing::Values(63), - ::testing::Values(ngraph::op::PadType::EXPLICIT) -); - -const std::vector CPUParams_1x1_2D = { - conv_sse42_2D_1x1, - conv_avx2_2D_1x1, - conv_avx512_2D_1x1, - conv_sse42_2D_1x1_nspc, - conv_avx2_2D_1x1_nspc, - conv_avx2_2D_1x1_nspc_brgconv, - conv_avx512_2D_1x1_nspc, - conv_avx512_2D_1x1_nspc_brgconv -}; - -INSTANTIATE_TEST_SUITE_P(smoke_Conv_2D_1x1_FP32, ConvolutionLayerCPUTest, - ::testing::Combine( - ::testing::Combine( - convParams_ExplicitPadding_1x1_2D, - ::testing::Values(ElementType::f32), - ::testing::Values(ElementType::undefined), - ::testing::Values(ElementType::undefined), - ::testing::ValuesIn(inputShapes2d), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - ::testing::ValuesIn(filterCPUInfoForDevice(CPUParams_1x1_2D)), - ::testing::ValuesIn(fusingParamsSet), - ::testing::Values(cpuEmptyPluginConfig)), - ConvolutionLayerCPUTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_Conv_2D_1x1_BF16, ConvolutionLayerCPUTest, - ::testing::Combine( - ::testing::Combine( - convParams_ExplicitPadding_1x1_2D, - ::testing::Values(ElementType::f32), - ::testing::Values(ElementType::undefined), - ::testing::Values(ElementType::undefined), - ::testing::ValuesIn(inputShapes2d), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - ::testing::ValuesIn(filterCPUInfoForDevice_BF16({conv_avx512_2D_1x1, conv_avx512_2D_1x1_nspc, - conv_avx512_2D_1x1_nspc_brgconv, conv_avx512_2D_1x1_nspc_brgconv_amx})), - ::testing::ValuesIn(fusingParamsSetBF16), - ::testing::Values(cpuBF16PluginConfig)), - ConvolutionLayerCPUTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_Conv_2D_1x1_I8, ConvolutionLayerCPUTest, - ::testing::Combine( - ::testing::Combine( - convParams_ExplicitPadding_1x1_2D, - ::testing::Values(ElementType::f32), - ::testing::Values(ElementType::i8), - ::testing::Values(ElementType::undefined), - ::testing::ValuesIn(inputShapes2d), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - ::testing::ValuesIn(filterCPUInfoForDevice(CPUParams_1x1_2D)), - ::testing::Values(fusingSum), - ::testing::Values(cpuEmptyPluginConfig)), - ConvolutionLayerCPUTest::getTestCaseName); - -/* ============= Jit Planar ============= */ - -/* ============= Convolution planar params (2D) ============= */ -const std::vector CPUParams_Jit_Planar_2D = { - // sse42 is not supported - conv_avx2_planar_2D, - conv_avx512_planar_2D, -}; - -const auto convParams_Planar_ExplicitPadding_2D = ::testing::Combine( - ::testing::ValuesIn(kernels2d), - ::testing::Values(SizeVector{1, 1}), - ::testing::ValuesIn(padBegins2d), - ::testing::ValuesIn(padEnds2d), - ::testing::ValuesIn(dilations2d), - ::testing::Values(1), - ::testing::Values(ngraph::op::PadType::EXPLICIT) -); - -const auto convParams_Planar_ExplicitPadding_2D_dilated = ::testing::Combine( - ::testing::ValuesIn(kernels2d), - ::testing::Values(SizeVector{1, 1}), - ::testing::ValuesIn(padBegins2d), - ::testing::ValuesIn(padEnds2d), - ::testing::Values(SizeVector{2, 2}), - ::testing::Values(1), - ::testing::Values(ngraph::op::PadType::EXPLICIT) -); - -INSTANTIATE_TEST_SUITE_P(smoke_Conv_2D_Jit_Planar_FP32, ConvolutionLayerCPUTest, - ::testing::Combine( - ::testing::Combine( - convParams_Planar_ExplicitPadding_2D, - ::testing::Values(ElementType::f32), - ::testing::Values(ElementType::undefined), - ::testing::Values(ElementType::undefined), - ::testing::ValuesIn(inputShapes2d), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - ::testing::ValuesIn(filterCPUInfoForDevice(CPUParams_Jit_Planar_2D)), - ::testing::Values(emptyFusingSpec, fusingRelu), - ::testing::Values(cpuEmptyPluginConfig)), - ConvolutionLayerCPUTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(Conv_2D_Jit_Planar_FP32_dilated, ConvolutionLayerCPUTest, - ::testing::Combine( - ::testing::Combine( - convParams_Planar_ExplicitPadding_2D_dilated, - ::testing::Values(ElementType::f32), - ::testing::Values(ElementType::undefined), - ::testing::Values(ElementType::undefined), - ::testing::ValuesIn(inputShapes2d), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - ::testing::ValuesIn(filterCPUInfoForDevice(CPUParams_Jit_Planar_2D)), - ::testing::Values(emptyFusingSpec, fusingRelu), - ::testing::Values(cpuEmptyPluginConfig)), - ConvolutionLayerCPUTest::getTestCaseName); - -/* ============= Convolution planar params (3D) ============= */ -const std::vector CPUParams_Jit_Planar_3D = { - // sse42 is not supported - conv_avx2_planar_3D, - conv_avx512_planar_3D, -}; - -const auto convParams_Planar_ExplicitPadding_3D = ::testing::Combine( - ::testing::ValuesIn(kernels3d), - ::testing::Values(SizeVector{1, 1, 1}), - ::testing::ValuesIn(padBegins3d), - ::testing::ValuesIn(padEnds3d), - ::testing::ValuesIn(dilations3d), - ::testing::Values(1), - ::testing::Values(ngraph::op::PadType::EXPLICIT) -); - -const auto convParams_Planar_ExplicitPadding_3D_dilated = ::testing::Combine( - ::testing::ValuesIn(kernels3d), - ::testing::Values(SizeVector{1, 1, 1}), - ::testing::ValuesIn(padBegins3d), - ::testing::ValuesIn(padEnds3d), - ::testing::Values(SizeVector{2, 2, 2}), - ::testing::Values(1), - ::testing::Values(ngraph::op::PadType::EXPLICIT) -); - -INSTANTIATE_TEST_SUITE_P(smoke_Conv_3D_Jit_Planar_FP32, ConvolutionLayerCPUTest, - ::testing::Combine( - ::testing::Combine( - convParams_Planar_ExplicitPadding_3D, - ::testing::Values(ElementType::f32), - ::testing::Values(ElementType::undefined), - ::testing::Values(ElementType::undefined), - ::testing::ValuesIn(inputShapes3d), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - ::testing::ValuesIn(filterCPUInfoForDevice(CPUParams_Jit_Planar_3D)), - ::testing::Values(emptyFusingSpec, fusingRelu), - ::testing::Values(cpuEmptyPluginConfig)), - ConvolutionLayerCPUTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(Conv_3D_Jit_Planar_FP32_dilated, ConvolutionLayerCPUTest, - ::testing::Combine( - ::testing::Combine( - convParams_Planar_ExplicitPadding_3D_dilated, - ::testing::Values(ElementType::f32), - ::testing::Values(ElementType::undefined), - ::testing::Values(ElementType::undefined), - ::testing::ValuesIn(inputShapes3d), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - ::testing::ValuesIn(filterCPUInfoForDevice(CPUParams_Jit_Planar_3D)), - ::testing::Values(emptyFusingSpec, fusingRelu), - ::testing::Values(cpuEmptyPluginConfig)), - ConvolutionLayerCPUTest::getTestCaseName); - -/* ============= Convolution auto padding tests ============= */ - -const auto convParams_AutoPadding_2D = ::testing::Combine( - ::testing::Values(kernels2d.front()), - ::testing::ValuesIn(strides2d), - ::testing::ValuesIn(padBegins2d), - ::testing::ValuesIn(padEnds2d), - ::testing::ValuesIn(dilations2d), - ::testing::ValuesIn(numOutChannels), - ::testing::Values(ngraph::op::PadType::SAME_UPPER, ngraph::op::PadType::SAME_LOWER) -); - -INSTANTIATE_TEST_SUITE_P(smoke_Conv_2D_AutoPad_FP32, ConvolutionLayerCPUTest, - ::testing::Combine( - ::testing::Combine( - convParams_AutoPadding_2D, - ::testing::Values(ElementType::f32), - ::testing::Values(ElementType::undefined), - ::testing::Values(ElementType::undefined), - ::testing::ValuesIn(inputShapes2d), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - ::testing::ValuesIn(filterCPUInfoForDevice(CPUParams_2D)), - ::testing::Values(emptyFusingSpec), - ::testing::Values(cpuEmptyPluginConfig)), - ConvolutionLayerCPUTest::getTestCaseName); - -/* ============= */ - -} // namespace - -/* ============= Large Filter Test ============= */ -namespace { - -const size_t outChannels = 80; - -const SizeVector kernel = { 251 }; -const SizeVector stride = { 10 }; -const std::vector padBegins = { 0 }; -const std::vector padEnds = { 0 }; -const SizeVector dilations = { 1 }; - -const auto convParams_1D = ::testing::Combine( - ::testing::Values(kernel), - ::testing::Values(stride), - ::testing::Values(padBegins), - ::testing::Values(padEnds), - ::testing::Values(dilations), - ::testing::Values(outChannels), - ::testing::Values(ngraph::op::PadType::EXPLICIT) -); - -std::vector inShapes = { - {{}, {{ 1, 1, 600 }}}, - { - //dynamic shape - { -1, 1, -1 }, - { //target static shapes - { 1, 1, 600 }, - { 10, 1, 700 }, - { 1, 1, 600 } - } - } -}; - -INSTANTIATE_TEST_SUITE_P(smoke_Conv_Large_Filter, ConvolutionLayerCPUTest, - ::testing::Combine( - ::testing::Combine( - convParams_1D, - ::testing::Values(ElementType::f32), - ::testing::Values(ElementType::f32), - ::testing::Values(ElementType::undefined), - ::testing::ValuesIn(inShapes), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - ::testing::Values(CPUSpecificParams{{}, {}, {}, CPUTestsBase::any_type}), - ::testing::Values(emptyFusingSpec), - ::testing::Values(cpuEmptyPluginConfig)), - ConvolutionLayerCPUTest::getTestCaseName); - -} // namespace -} // namespace CPULayerTestsDefinitions diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/ctc_greedy_decoder.cpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/ctc_greedy_decoder.cpp index 185ca4d29cc438..c75d192c1e98e6 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/ctc_greedy_decoder.cpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/ctc_greedy_decoder.cpp @@ -4,21 +4,13 @@ #include -#include -#include -#include -#include -#include -#include - +#include "common_test_utils/ov_tensor_utils.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" #include "test_utils/cpu_test_utils.hpp" -using namespace InferenceEngine; using namespace CPUTestUtils; -using namespace ov::test; - -namespace CPULayerTestsDefinitions { +namespace ov { +namespace test { using CtcGreedyDecoderParams = std::tuple(params[0], params[1], mergeRepeated); - ngraph::ResultVector results{std::make_shared(ctcGreedyDecoder)}; - function = std::make_shared(results, params, "CTCGreedyDecoderCPU"); + ov::ResultVector results{std::make_shared(ctcGreedyDecoder)}; + function = std::make_shared(results, params, "CTCGreedyDecoderCPU"); }; - void generate_inputs(const std::vector& targetInputStaticShapes) override { + void generate_inputs(const std::vector& targetInputStaticShapes) override { inputs.clear(); const auto& funcInputs = function->inputs(); for (size_t i = 0; i < funcInputs.size(); ++i) { @@ -173,4 +165,5 @@ INSTANTIATE_TEST_SUITE_P(smoke_CtcGreedyDecoderCPU, CTCGreedyDecoderLayerCPUTest::getTestCaseName); } // namespace -} // namespace CPULayerTestsDefinitions +} // namespace test +} // 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/single_layer_tests/ctc_greedy_decoder_seq_len.cpp index 46757e4d63d4e4..96e6d7fea65c60 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/ctc_greedy_decoder_seq_len.cpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/ctc_greedy_decoder_seq_len.cpp @@ -4,20 +4,13 @@ #include -#include -#include -#include -#include -#include - +#include "common_test_utils/ov_tensor_utils.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" #include "test_utils/cpu_test_utils.hpp" -using namespace InferenceEngine; using namespace CPUTestUtils; -using namespace ov::test; - -namespace CPULayerTestsDefinitions { +namespace ov { +namespace test { using CtcGreedyDecoderSeqLenParams = std::tuple(ctcGreedyDecoderSeqLen)}; - function = std::make_shared(results, params, "CTCGreedyDecoderSeqLenCPU"); + ov::ResultVector results{std::make_shared(ctcGreedyDecoderSeqLen)}; + function = std::make_shared(results, params, "CTCGreedyDecoderSeqLenCPU"); }; - void generate_inputs(const std::vector& targetInputStaticShapes) override { + void generate_inputs(const std::vector& targetInputStaticShapes) override { inputs.clear(); const auto& funcInputs = function->inputs(); const auto& dataShape = targetInputStaticShapes[0]; @@ -207,4 +200,5 @@ INSTANTIATE_TEST_SUITE_P(smoke_CtcGreedyDecoderSeqLenCPU, CTCGreedyDecoderSeqLenLayerCPUTest::getTestCaseName); } // namespace -} // namespace CPULayerTestsDefinitions +} // namespace test +} // namespace ov diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/ctc_loss.cpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/ctc_loss.cpp index 8a310a82ec5254..014c2388fef125 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/ctc_loss.cpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/ctc_loss.cpp @@ -4,34 +4,29 @@ #include -#include -#include -#include -#include -#include - +#include "common_test_utils/ov_tensor_utils.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" #include "test_utils/cpu_test_utils.hpp" -using namespace InferenceEngine; using namespace CPUTestUtils; -using namespace ov::test; - -namespace CPULayerTestsDefinitions { +namespace ov { +namespace test { // N,T,C -using CTCLossShapeParams = std::pair, std::vector>>; - -using CTCLossLayerCPUTestParams = std::tuple; - -class CTCLossLayerCPUTest : public testing::WithParamInterface, virtual public SubgraphBaseTest, public CPUTestsBase { +using CTCLossShapeParams = std::pair, std::vector>>; + +using CTCLossLayerCPUTestParams = std::tuple; + +class CTCLossLayerCPUTest : public testing::WithParamInterface, + virtual public SubgraphBaseTest, + public CPUTestsBase { public: static std::string getTestCaseName(const testing::TestParamInfo& obj) { CTCLossShapeParams shapes; @@ -39,19 +34,20 @@ class CTCLossLayerCPUTest : public testing::WithParamInterface& staticShapes : shapes.second) { - for (ngraph::Shape& shape : staticShapes) { + for (std::vector& staticShapes : shapes.second) { + for (ov::Shape& shape : staticShapes) { size_t N = shape[0]; size_t T = shape[1]; size_t C = shape[2]; @@ -90,10 +87,12 @@ class CTCLossLayerCPUTest : public testing::WithParamInterface types{fPrecision, iPrecision, iPrecision, iPrecision}; + std::vector types{fPrecision, iPrecision, iPrecision, iPrecision}; std::vector partialShapes{inputDynamicShapesValues, shapeN, shapeNT, shapeN}; ov::ParameterVector params; @@ -101,23 +100,29 @@ class CTCLossLayerCPUTest : public testing::WithParamInterface(types[i], partialShapes[i]); params.push_back(param_node); } - auto bankNode = ngraph::op::Constant::create(ngraph::element::i64, ngraph::Shape{ }, {blank}); - - auto ctcLoss = std::make_shared(params[0], params[1], params[2], - params[3], bankNode, preprocessCollapseRepeated, ctcMergeRepeated, unique); - ngraph::ResultVector results{std::make_shared(ctcLoss)}; - function = std::make_shared(results, params, "CTCLossLayerCPUTest"); + auto bankNode = ov::op::v0::Constant::create(ov::element::i64, ov::Shape{}, {blank}); + + auto ctcLoss = std::make_shared(params[0], + params[1], + params[2], + params[3], + bankNode, + preprocessCollapseRepeated, + ctcMergeRepeated, + unique); + ov::ResultVector results{std::make_shared(ctcLoss)}; + function = std::make_shared(results, params, "CTCLossLayerCPUTest"); }; - void generate_inputs(const std::vector& targetInputStaticShapes) override { + void generate_inputs(const std::vector& targetInputStaticShapes) override { inputs.clear(); const auto& funcInputs = function->inputs(); const auto& dataShape = targetInputStaticShapes[0]; const auto N = dataShape[0]; const auto T = dataShape[1]; const auto C = dataShape[2]; - ngraph::Shape shapeN{N}; - ngraph::Shape shapeNT{N, T}; + ov::Shape shapeN{N}; + ov::Shape shapeNT{N, T}; std::mt19937 gen(42); std::uniform_int_distribution dist(1, T); @@ -129,11 +134,7 @@ class CTCLossLayerCPUTest : public testing::WithParamInterface preprocessCollapseRepeated = {true, false}; - const std::vector ctcMergeRepeated = {true, false}; - const std::vector unique = {true, false}; - - const std::vector shapes = { - { - // dynamic undifined - { - {-1, -1, -1}, - }, - // target - { - {{3, 6, 8}, {2, 5, 6}, {5, 6, 10}} - } - }, - { - // dynamic lower/upper bound - { - {{1, 10}, {5, 10}, {6, 12}}, - }, - // target - { - {{1, 5, 6}, {10, 10, 12}, {5, 7, 8}} - } - }, - }; +const ov::element::TypeVector fPrecisions = {ov::element::f32}; + +const ov::element::TypeVector iPrecisions = {ov::element::i32, ov::element::i64}; + +const std::vector preprocessCollapseRepeated = {true, false}; +const std::vector ctcMergeRepeated = {true, false}; +const std::vector unique = {true, false}; + +const std::vector shapes = { + {// dynamic undifined + { + {-1, -1, -1}, + }, + // target + {{{3, 6, 8}, {2, 5, 6}, {5, 6, 10}}}}, + {// dynamic lower/upper bound + { + {{1, 10}, {5, 10}, {6, 12}}, + }, + // target + {{{1, 5, 6}, {10, 10, 12}, {5, 7, 8}}}}, +}; - const std::vector blanks = { - 0, 2, 5 - }; +const std::vector blanks = {0, 2, 5}; const auto basicCases = ::testing::Combine(::testing::ValuesIn(shapes), ::testing::ValuesIn(blanks), @@ -244,10 +230,8 @@ const auto basicCases = ::testing::Combine(::testing::ValuesIn(shapes), ::testing::ValuesIn(fPrecisions), ::testing::ValuesIn(iPrecisions)); -INSTANTIATE_TEST_SUITE_P(smoke_CTCLossCPU, - CTCLossLayerCPUTest, - basicCases, - CTCLossLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_CTCLossCPU, CTCLossLayerCPUTest, basicCases, CTCLossLayerCPUTest::getTestCaseName); } // namespace -} // namespace CPULayerTestsDefinitions +} // namespace test +} // namespace ov diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/cum_sum.cpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/cum_sum.cpp index 4f99471511f1ec..144e1485137031 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/cum_sum.cpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/cum_sum.cpp @@ -2,30 +2,25 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "test_utils/cpu_test_utils.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include "ov_models/builders.hpp" +#include "test_utils/cpu_test_utils.hpp" -using namespace ngraph; -using namespace InferenceEngine; using namespace CPUTestUtils; -using namespace ov; -using namespace test; - -namespace CPULayerTestsDefinitions { +namespace ov { +namespace test { -using cumSumParams = std::tuple< - ngraph::element::Type, // data precision - InputShape, // input shape - std::int64_t, // axis - bool, // exclusive - bool>; // reverse +using cumSumParams = std::tuple; // reverse class CumSumLayerCPUTest : public testing::WithParamInterface, - public SubgraphBaseTest, public CPUTestsBase { + public SubgraphBaseTest, + public CPUTestsBase { public: static std::string getTestCaseName(testing::TestParamInfo obj) { - ngraph::element::Type inputPrecision; + ov::element::Type inputPrecision; InputShape shapes; std::int64_t axis; bool exclusive; @@ -61,11 +56,12 @@ class CumSumLayerCPUTest : public testing::WithParamInterface, for (auto&& shape : inputDynamicShapes) { params.push_back(std::make_shared(inType, shape)); } - auto axisNode = ngraph::opset1::Constant::create(ngraph::element::i32, ngraph::Shape{}, std::vector{axis})->output(0); + auto axisNode = + ov::op::v0::Constant::create(ov::element::i32, ov::Shape{}, std::vector{axis})->output(0); auto cumSum = std::make_shared(params[0], axisNode, exclusive, reverse); - function = std::make_shared(ngraph::NodeVector{ cumSum }, params, "CumSumLayerCPUTest"); - functionRefs = ngraph::clone_function(*function); + function = std::make_shared(ov::NodeVector{cumSum}, params, "CumSumLayerCPUTest"); + functionRefs = ov::clone_model(*function); } }; @@ -74,118 +70,121 @@ TEST_P(CumSumLayerCPUTest, CompareWithRefs) { CheckPluginRelatedResults(compiledModel, "CumSum"); } -const ngraph::element::TypeVector inputPrecision = { - ngraph::element::i8, - ngraph::element::bf16, - ngraph::element::f32 -}; +const std::vector inputPrecision = {ov::element::i8, ov::element::bf16, ov::element::f32}; -const std::vector axes = { 0, 1, 2, 3, 4, 5, 6 }; -const std::vector negativeAxes = { -1, -2, -3, -4, -5, -6 }; +const std::vector axes = {0, 1, 2, 3, 4, 5, 6}; +const std::vector negativeAxes = {-1, -2, -3, -4, -5, -6}; -const std::vector exclusive = { true, false }; -const std::vector reverse = { true, false }; +const std::vector exclusive = {true, false}; +const std::vector reverse = {true, false}; const std::vector inShapes = { - {{-1}, - {{16}, {18}, {12}}}, + {{-1}, {{16}, {18}, {12}}}, - {{-1, -1}, - {{9, 15}, {18, 12}, {12, 12}}}, + {{-1, -1}, {{9, 15}, {18, 12}, {12, 12}}}, - {{-1, -1, -1}, - {{16, 10, 12}, {18, 12, 10}, {12, 18, 10}}}, + {{-1, -1, -1}, {{16, 10, 12}, {18, 12, 10}, {12, 18, 10}}}, - {{-1, -1, -1, -1}, - {{18, 20, 14, 12}, {19, 20, 14, 12}, {20, 22, 23, 25}}}, + {{-1, -1, -1, -1}, {{18, 20, 14, 12}, {19, 20, 14, 12}, {20, 22, 23, 25}}}, - {{-1, -1, -1, -1, -1}, - {{2, 4, 6, 2, 4}, {3, 5, 6, 3, 5}, {1, 4, 2, 6, 8}}}, + {{-1, -1, -1, -1, -1}, {{2, 4, 6, 2, 4}, {3, 5, 6, 3, 5}, {1, 4, 2, 6, 8}}}, - {{-1, -1, -1, -1, -1, -1}, - {{2, 4, 6, 2, 4, 2}, {3, 5, 6, 3, 5, 3}, {1, 4, 2, 6, 8, 1}}}, + {{-1, -1, -1, -1, -1, -1}, {{2, 4, 6, 2, 4, 2}, {3, 5, 6, 3, 5, 3}, {1, 4, 2, 6, 8, 1}}}, - {{{-1, -1, -1, -1, -1, -1, -1}}, - {{2, 4, 6, 2, 4, 2, 4}, {3, 5, 6, 3, 5, 3, 5}, {1, 4, 2, 6, 8, 1, 4}}}, + {{{-1, -1, -1, -1, -1, -1, -1}}, {{2, 4, 6, 2, 4, 2, 4}, {3, 5, 6, 3, 5, 3, 5}, {1, 4, 2, 6, 8, 1, 4}}}, {{{2, 5}, {3, 7}, {4, 8}, {5, 7}, {2, 5}, {3, 7}, {1, 2}}, {{2, 4, 6, 5, 4, 3, 1}, {3, 5, 6, 6, 5, 3, 1}, {5, 7, 4, 6, 3, 7, 2}}}, - {{{2, 5}, -1, {4, 8}, -1, -1, {3, 7}, -1}, - {{2, 4, 6, 5, 4, 3, 1}, {3, 5, 6, 6, 5, 3, 1}, {5, 7, 4, 6, 3, 7, 2}}} -}; - -const auto testCasesAxis_0 = ::testing::Combine( - ::testing::ValuesIn(inputPrecision), - ::testing::ValuesIn(inShapes), - ::testing::Values(axes[0]), - ::testing::ValuesIn(exclusive), - ::testing::ValuesIn(reverse) -); - -const auto testCasesAxis_1 = ::testing::Combine( - ::testing::ValuesIn(inputPrecision), - ::testing::ValuesIn(std::vector(inShapes.begin() + 1, inShapes.end())), - ::testing::Values(axes[1]), - ::testing::ValuesIn(exclusive), - ::testing::ValuesIn(reverse) -); - -const auto testCasesAxis_2 = ::testing::Combine( - ::testing::ValuesIn(inputPrecision), - ::testing::ValuesIn(std::vector(inShapes.begin() + 2, inShapes.end())), - ::testing::Values(axes[2]), - ::testing::ValuesIn(exclusive), - ::testing::ValuesIn(reverse) -); - -const auto testCasesAxis_3 = ::testing::Combine( - ::testing::ValuesIn(inputPrecision), - ::testing::ValuesIn(std::vector(inShapes.begin() + 3, inShapes.end())), - ::testing::Values(axes[3]), - ::testing::ValuesIn(exclusive), - ::testing::ValuesIn(reverse) -); - -const auto testCasesAxis_4 = ::testing::Combine( - ::testing::ValuesIn(inputPrecision), - ::testing::ValuesIn(std::vector(inShapes.begin() + 4, inShapes.end())), - ::testing::Values(axes[4]), - ::testing::ValuesIn(exclusive), - ::testing::ValuesIn(reverse) -); - -const auto testCasesAxis_5 = ::testing::Combine( - ::testing::ValuesIn(inputPrecision), - ::testing::ValuesIn(std::vector(inShapes.begin() + 5, inShapes.end())), - ::testing::Values(axes[5]), - ::testing::ValuesIn(exclusive), - ::testing::ValuesIn(reverse) -); - -const auto testCasesAxis_6 = ::testing::Combine( - ::testing::ValuesIn(inputPrecision), - ::testing::ValuesIn(std::vector(inShapes.begin() + 6, inShapes.end())), - ::testing::Values(axes[6]), - ::testing::ValuesIn(exclusive), - ::testing::ValuesIn(reverse) -); - -const auto testCasesAxis_negative = ::testing::Combine( - ::testing::ValuesIn(inputPrecision), - ::testing::ValuesIn(std::vector(inShapes.begin() + 6, inShapes.end())), - ::testing::ValuesIn(negativeAxes), - ::testing::ValuesIn(exclusive), - ::testing::ValuesIn(reverse) -); - -INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefsNumpy_axis_0, CumSumLayerCPUTest, testCasesAxis_0, CumSumLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefsNumpy_axis_1, CumSumLayerCPUTest, testCasesAxis_1, CumSumLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefsNumpy_axis_2, CumSumLayerCPUTest, testCasesAxis_2, CumSumLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefsNumpy_axis_3, CumSumLayerCPUTest, testCasesAxis_3, CumSumLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefsNumpy_axis_4, CumSumLayerCPUTest, testCasesAxis_4, CumSumLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefsNumpy_axis_5, CumSumLayerCPUTest, testCasesAxis_5, CumSumLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefsNumpy_axis_6, CumSumLayerCPUTest, testCasesAxis_6, CumSumLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefsNumpy_negative_axes, CumSumLayerCPUTest, testCasesAxis_negative, CumSumLayerCPUTest::getTestCaseName); - -} // namespace CPULayerTestsDefinitions + {{{2, 5}, -1, {4, 8}, -1, -1, {3, 7}, -1}, {{2, 4, 6, 5, 4, 3, 1}, {3, 5, 6, 6, 5, 3, 1}, {5, 7, 4, 6, 3, 7, 2}}}}; + +const auto testCasesAxis_0 = ::testing::Combine(::testing::ValuesIn(inputPrecision), + ::testing::ValuesIn(inShapes), + ::testing::Values(axes[0]), + ::testing::ValuesIn(exclusive), + ::testing::ValuesIn(reverse)); + +const auto testCasesAxis_1 = + ::testing::Combine(::testing::ValuesIn(inputPrecision), + ::testing::ValuesIn(std::vector(inShapes.begin() + 1, inShapes.end())), + ::testing::Values(axes[1]), + ::testing::ValuesIn(exclusive), + ::testing::ValuesIn(reverse)); + +const auto testCasesAxis_2 = + ::testing::Combine(::testing::ValuesIn(inputPrecision), + ::testing::ValuesIn(std::vector(inShapes.begin() + 2, inShapes.end())), + ::testing::Values(axes[2]), + ::testing::ValuesIn(exclusive), + ::testing::ValuesIn(reverse)); + +const auto testCasesAxis_3 = + ::testing::Combine(::testing::ValuesIn(inputPrecision), + ::testing::ValuesIn(std::vector(inShapes.begin() + 3, inShapes.end())), + ::testing::Values(axes[3]), + ::testing::ValuesIn(exclusive), + ::testing::ValuesIn(reverse)); + +const auto testCasesAxis_4 = + ::testing::Combine(::testing::ValuesIn(inputPrecision), + ::testing::ValuesIn(std::vector(inShapes.begin() + 4, inShapes.end())), + ::testing::Values(axes[4]), + ::testing::ValuesIn(exclusive), + ::testing::ValuesIn(reverse)); + +const auto testCasesAxis_5 = + ::testing::Combine(::testing::ValuesIn(inputPrecision), + ::testing::ValuesIn(std::vector(inShapes.begin() + 5, inShapes.end())), + ::testing::Values(axes[5]), + ::testing::ValuesIn(exclusive), + ::testing::ValuesIn(reverse)); + +const auto testCasesAxis_6 = + ::testing::Combine(::testing::ValuesIn(inputPrecision), + ::testing::ValuesIn(std::vector(inShapes.begin() + 6, inShapes.end())), + ::testing::Values(axes[6]), + ::testing::ValuesIn(exclusive), + ::testing::ValuesIn(reverse)); + +const auto testCasesAxis_negative = + ::testing::Combine(::testing::ValuesIn(inputPrecision), + ::testing::ValuesIn(std::vector(inShapes.begin() + 6, inShapes.end())), + ::testing::ValuesIn(negativeAxes), + ::testing::ValuesIn(exclusive), + ::testing::ValuesIn(reverse)); + +INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefsNumpy_axis_0, + CumSumLayerCPUTest, + testCasesAxis_0, + CumSumLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefsNumpy_axis_1, + CumSumLayerCPUTest, + testCasesAxis_1, + CumSumLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefsNumpy_axis_2, + CumSumLayerCPUTest, + testCasesAxis_2, + CumSumLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefsNumpy_axis_3, + CumSumLayerCPUTest, + testCasesAxis_3, + CumSumLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefsNumpy_axis_4, + CumSumLayerCPUTest, + testCasesAxis_4, + CumSumLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefsNumpy_axis_5, + CumSumLayerCPUTest, + testCasesAxis_5, + CumSumLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefsNumpy_axis_6, + CumSumLayerCPUTest, + testCasesAxis_6, + CumSumLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefsNumpy_negative_axes, + CumSumLayerCPUTest, + testCasesAxis_negative, + CumSumLayerCPUTest::getTestCaseName); + +} // namespace test +} // 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/single_layer_tests/custom_op_internal_dyn.cpp index f7fffe774d90f0..a45a23aa470618 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/custom_op_internal_dyn.cpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/custom_op_internal_dyn.cpp @@ -2,15 +2,12 @@ // SPDX-License-Identifier: Apache-2.0 // -#include -#include -#include -#include "ov_models/builders.hpp" -#include "ov_models/utils/ov_helpers.hpp" +#include "common_test_utils/ov_tensor_utils.hpp" +#include "openvino/op/op.hpp" +#include "shared_test_classes/base/ov_subgraph.hpp" -using namespace ov::test; - -namespace CPULayerTestsDefinitions { +namespace ov { +namespace test { /* This is a synthetic op that mimics the general behaviour of operations with internal dynamics, i.e. nodes where the the output shapes may only be defined after the actual computations. */ @@ -26,20 +23,19 @@ class CustomOp : public ov::op::Op { void validate_and_infer_types() override { const auto& inputs_count = input_values().size(); - OPENVINO_ASSERT(inputs_count == 1, - "Input count must be 1, Got: ", - inputs_count); + OPENVINO_ASSERT(inputs_count == 1, "Input count must be 1, Got: ", inputs_count); set_output_size(2); auto shape0 = get_input_partial_shape(0); - auto rank0 = shape0.rank(); + auto rank0 = shape0.rank(); - OPENVINO_ASSERT(rank0.compatible(3), - "The input must be 3D."); + OPENVINO_ASSERT(rank0.compatible(3), "The input must be 3D."); - //here we set undefined shapes since they can only be determined after the actual calculations + // here we set undefined shapes since they can only be determined after the actual calculations set_output_type(0, get_input_element_type(0), ov::PartialShape({ov::Dimension()})); - set_output_type(1, get_input_element_type(0), ov::PartialShape({ov::Dimension(), ov::Dimension(), ov::Dimension()})); + set_output_type(1, + get_input_element_type(0), + ov::PartialShape({ov::Dimension(), ov::Dimension(), ov::Dimension()})); } std::shared_ptr clone_with_new_inputs(const ov::OutputVector& new_args) const override { @@ -88,16 +84,16 @@ class CustomOpCPUTest : public SubgraphBaseTest { ov::ParameterVector inputParams; ov::OutputVector paramsOuts; for (auto&& shape : inputDynamicShapes) { - auto param = std::make_shared(ngraph::element::f32, shape); + auto param = std::make_shared(ov::element::f32, shape); inputParams.push_back(param); paramsOuts.push_back(param); } auto customOp = std::make_shared(paramsOuts); - auto shapeOf = std::make_shared(customOp->output(1)); + auto shapeOf = std::make_shared(customOp->output(1)); - ngraph::ResultVector results{std::make_shared(customOp->output(0)), - std::make_shared(shapeOf)}; - function = std::make_shared(results, inputParams, "customOpTest"); + ov::ResultVector results{std::make_shared(customOp->output(0)), + std::make_shared(shapeOf)}; + function = std::make_shared(results, inputParams, "customOpTest"); } void generate_inputs(const std::vector& targetInputStaticShapes) override { @@ -105,7 +101,8 @@ class CustomOpCPUTest : public SubgraphBaseTest { const auto& funcInputs = function->inputs(); for (size_t i = 0; i < funcInputs.size(); ++i) { const auto& funcInput = funcInputs[i]; - auto tensor = ov::test::utils::create_and_fill_tensor(funcInput.get_element_type(), targetInputStaticShapes[i]); + auto tensor = + ov::test::utils::create_and_fill_tensor(funcInput.get_element_type(), targetInputStaticShapes[i]); inputs.insert({funcInput.get_node_shared_ptr(), tensor}); } } @@ -126,4 +123,5 @@ class CustomOpCPUTest : public SubgraphBaseTest { TEST_F(CustomOpCPUTest, smoke_CustomOpInternalDynamismCPUTest) { run(); } -} // namespace CPULayerTestsDefinitions +} // namespace test +} // namespace ov diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/deformable_convolution.cpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/deformable_convolution.cpp index cf7b5d7eae4910..73b269b43569d9 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/deformable_convolution.cpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/deformable_convolution.cpp @@ -2,69 +2,65 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "test_utils/cpu_test_utils.hpp" -#include "ov_models/builders.hpp" -#include "ov_models/utils/ov_helpers.hpp" -#include +#include "common_test_utils/ov_tensor_utils.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" +#include "test_utils/cpu_test_utils.hpp" -using namespace InferenceEngine; using namespace CPUTestUtils; -using namespace ov::test; - -namespace CPULayerTestsDefinitions { -enum OffsetType {ZERO, NATURAL, REAL_POSITIVE, REAL_NEGATIVE, REAL_MISC}; - -typedef std::tuple< - bool, // with_bilinear_interpolation_pad - bool, // with_modulation - OffsetType // type of def. offsets - > DefConvSpecificParams; - -typedef std::tuple< - ngraph::op::PadType, // pad. type - std::vector, // pad. begin - std::vector, // pad. end - std::vector, // strides - std::vector // dilations - > AddSpatialParamsDyn; - -typedef std::tuple< - AddSpatialParamsDyn, - std::vector, - DefConvSpecificParams, - InferenceEngine::Precision, // Net precision - LayerTestsUtils::TargetDevice // Device name - > DefConvLayerTestParams; - -typedef std::tuple< - CPULayerTestsDefinitions::DefConvLayerTestParams, - CPUSpecificParams> DefConvLayerCPUTestParamsSet; +namespace ov { +namespace test { +enum OffsetType { ZERO, NATURAL, REAL_POSITIVE, REAL_NEGATIVE, REAL_MISC }; + +typedef std::tuple + DefConvSpecificParams; + +typedef std::tuple, // pad. begin + std::vector, // pad. end + std::vector, // strides + std::vector // dilations + > + AddSpatialParamsDyn; + +typedef std::tuple, + DefConvSpecificParams, + ov::element::Type, // Net precision + std::string // Device name + > + DefConvLayerTestParams; + +typedef std::tuple DefConvLayerCPUTestParamsSet; class DefConvLayerCPUTest : public testing::WithParamInterface, - virtual public SubgraphBaseTest, public CPUTestsBase { + virtual public SubgraphBaseTest, + public CPUTestsBase { public: OffsetType offsetType; static std::string getTestCaseName(testing::TestParamInfo obj) { - CPULayerTestsDefinitions::DefConvSpecificParams dcSpecificParams; + DefConvSpecificParams dcSpecificParams; std::vector inputShape; - InferenceEngine::Precision netPrecision; - CPULayerTestsDefinitions::DefConvLayerTestParams basicParamsSet; + ov::element::Type netPrecision; + DefConvLayerTestParams basicParamsSet; CPUSpecificParams cpuParams; std::tie(basicParamsSet, cpuParams) = obj.param; AddSpatialParamsDyn addSpParams; std::string td; std::tie(addSpParams, inputShape, dcSpecificParams, netPrecision, td) = basicParamsSet; - ngraph::op::PadType padType; - InferenceEngine::SizeVector stride, dilation; + ov::op::PadType padType; + std::vector stride, dilation; std::vector padBegin, padEnd; std::tie(padType, padBegin, padEnd, stride, dilation) = addSpParams; // gr * in_ch_per_gr / in_ch_per_gr size_t groups = inputShape[0].second[0][1] / inputShape[2].second[0][1]; // dg * ker_spat_shape[0] * ker_spat_shape[1] * 2 / (ker_spat_shape[0] * ker_spat_shape[1] * 2) - size_t deformableGroups = inputShape[1].second[0][1] / (inputShape[2].second[0][2] * inputShape[2].second[0][3] *2); + size_t deformableGroups = + inputShape[1].second[0][1] / (inputShape[2].second[0][2] * inputShape[2].second[0][3] * 2); bool withBilinearInterpolationPad, withModulation; OffsetType offType; @@ -85,7 +81,7 @@ class DefConvLayerCPUTest : public testing::WithParamInterface& targetInputStaticShapes) override { + void generate_inputs(const std::vector& targetInputStaticShapes) override { inputs.clear(); const auto& funcInputs = function->inputs(); auto inShape = targetInputStaticShapes[0]; @@ -114,9 +111,11 @@ class DefConvLayerCPUTest : public testing::WithParamInterface inputShape; - InferenceEngine::Precision netPrecision; - CPULayerTestsDefinitions::DefConvLayerTestParams basicParamsSet; + ov::element::Type netPrecision; + DefConvLayerTestParams basicParamsSet; CPUSpecificParams cpuParams; std::tie(basicParamsSet, cpuParams) = this->GetParam(); std::tie(inFmts, outFmts, priority, selectedType) = cpuParams; @@ -143,22 +142,21 @@ class DefConvLayerCPUTest : public testing::WithParamInterface stride, dilation; std::vector padBegin, padEnd; std::tie(padType, padBegin, padEnd, stride, dilation) = addSpParams; // gr * in_ch_per_gr / in_ch_per_gr size_t groups = inputShape[0].second[0].at(1) / inputShape[2].second[0].at(1); // dg * ker_spat_shape[0] * ker_spat_shape[1] * 2 / (ker_spat_shape[0] * ker_spat_shape[1] * 2) - size_t deformableGroups = inputShape[1].second[0].at(1) / - (inputShape[2].second[0].at(2) * inputShape[2].second[0].at(3) * 2); + size_t deformableGroups = + inputShape[1].second[0].at(1) / (inputShape[2].second[0].at(2) * inputShape[2].second[0].at(3) * 2); bool withBilinearInterpolationPad, withModulation; std::tie(withBilinearInterpolationPad, withModulation, offsetType) = dcSpecificParams; - auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); ov::ParameterVector inputParams; for (auto&& shape : inputDynamicShapes) { - inputParams.push_back(std::make_shared(ngPrc, shape)); + inputParams.push_back(std::make_shared(netPrecision, shape)); } auto data = inputParams[0]; data->set_friendly_name("a_data"); @@ -166,22 +164,40 @@ class DefConvLayerCPUTest : public testing::WithParamInterfaceset_friendly_name("b_offset_vals"); auto filter_vals = inputParams[2]; filter_vals->set_friendly_name("c_filter_vals"); - ngraph::ParameterVector parameters{data, offset_vals, filter_vals}; - std::shared_ptr deformable_conv; + ov::ParameterVector parameters{data, offset_vals, filter_vals}; + std::shared_ptr deformable_conv; if (withModulation) { auto modulation_scalars = inputParams[3]; 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, deformableGroups, - withBilinearInterpolationPad); + deformable_conv = std::make_shared(data, + offset_vals, + filter_vals, + modulation_scalars, + stride, + padBegin, + padEnd, + dilation, + padType, + groups, + deformableGroups, + withBilinearInterpolationPad); parameters.push_back(modulation_scalars); } else { - deformable_conv = std::make_shared(data, offset_vals, filter_vals, stride, padBegin, padEnd, dilation, - padType, groups, deformableGroups, withBilinearInterpolationPad); + deformable_conv = std::make_shared(data, + offset_vals, + filter_vals, + stride, + padBegin, + padEnd, + dilation, + padType, + groups, + deformableGroups, + withBilinearInterpolationPad); } - function = makeNgraphFunction(ngPrc, parameters, deformable_conv, "deformable_convolution"); + function = makeNgraphFunction(netPrecision, parameters, deformable_conv, "deformable_convolution"); } }; @@ -209,47 +225,26 @@ std::vector filterCPUInfoForDevice(bool enforceRef = false) { return resCPUParams; } -const std::vector netPrecisions = { - InferenceEngine::Precision::FP32 -}; - -const auto defConvSpecificParams_Smoke = ::testing::Combine( - ::testing::ValuesIn(std::vector { - true, - false - }), // with_bilinear_interpolation_pad - ::testing::ValuesIn(std::vector { - true, - false - }), // with_modulation - ::testing::ValuesIn(std::vector { - OffsetType::REAL_MISC, - }) // offset type -); - -const auto defConvSpecificParams = ::testing::Combine( - ::testing::ValuesIn(std::vector { - true, - false - }), // with_bilinear_interpolation_pad - ::testing::ValuesIn(std::vector { - true, - false - }), // with_modulation - ::testing::ValuesIn(std::vector { - OffsetType::NATURAL, - OffsetType::ZERO, - OffsetType::REAL_MISC, - OffsetType::REAL_POSITIVE, - OffsetType::REAL_NEGATIVE - }) // offset type -); - -std::vector padTypes = { - ngraph::op::PadType::EXPLICIT, - ngraph::op::PadType::VALID -}; -std::vector> getCartProduct(const std::vector> &v) { +const std::vector netPrecisions = {ov::element::f32}; + +const auto defConvSpecificParams_Smoke = + ::testing::Combine(::testing::ValuesIn(std::vector{true, false}), // with_bilinear_interpolation_pad + ::testing::ValuesIn(std::vector{true, false}), // with_modulation + ::testing::ValuesIn(std::vector{ + OffsetType::REAL_MISC, // offset type + })); + +const auto defConvSpecificParams = + ::testing::Combine(::testing::ValuesIn(std::vector{true, false}), // with_bilinear_interpolation_pad + ::testing::ValuesIn(std::vector{true, false}), // with_modulation + ::testing::ValuesIn(std::vector{OffsetType::NATURAL, // offset type + OffsetType::ZERO, + OffsetType::REAL_MISC, + OffsetType::REAL_POSITIVE, + OffsetType::REAL_NEGATIVE})); + +std::vector padTypes = {ov::op::PadType::EXPLICIT, ov::op::PadType::VALID}; +std::vector> getCartProduct(const std::vector>& v) { int outSize = 1; int n = v.size(); for (int i = 0; i < n; i++) { @@ -259,7 +254,7 @@ std::vector> getCartProduct(const std::vector cortege(n); int curResid = i, curInd = 0; - for (int j = v.size() - 1; j >= 0 ; j--) { + for (int j = v.size() - 1; j >= 0; j--) { curInd = curResid % v[j].size(); curResid = curResid / v[j].size(); cortege[j] = v[j][curInd]; @@ -268,12 +263,11 @@ std::vector> getCartProduct(const std::vector> buildStaticParams( - const std::vector> spatParams, - const std::vector> chParamsUncombined) { +std::vector> buildStaticParams(const std::vector> spatParams, + const std::vector> chParamsUncombined) { std::vector> chParams = getCartProduct(chParamsUncombined); std::vector> shapes; - for (std::vector &chPar : chParams) { + for (std::vector& chPar : chParams) { const size_t batch = spatParams[0][0]; const size_t inSpH = spatParams[1][0]; const size_t inSpW = spatParams[1][1]; @@ -287,339 +281,336 @@ std::vector> buildStaticParams( const size_t inChPerGr = chPar[2]; const size_t outChPerGr = chPar[3]; - std::vector inputShape = { - {batch, gr * inChPerGr, inSpH, inSpW}, - {batch, defGr * kerSpH * kerSpW * 2, offSpH, offSpW}, - {gr * outChPerGr, inChPerGr, kerSpH, kerSpW}, - {batch, defGr * kerSpH * kerSpW, offSpH, offSpW} - }; + std::vector inputShape = {{batch, gr * inChPerGr, inSpH, inSpW}, + {batch, defGr * kerSpH * kerSpW * 2, offSpH, offSpW}, + {gr * outChPerGr, inChPerGr, kerSpH, kerSpW}, + {batch, defGr * kerSpH * kerSpW, offSpH, offSpW}}; shapes.push_back(inputShape); } return shapes; } -const auto addSpParams = ::testing::Combine( - ::testing::ValuesIn(padTypes), // pad. type - ::testing::Values(std::vector({0, 0})), // pad. begin - ::testing::Values(std::vector({0, 0})), // pad. end - ::testing::Values(std::vector {1, 1}), // strides - ::testing::Values(std::vector {1, 1}) // dilations +const auto addSpParams = ::testing::Combine(::testing::ValuesIn(padTypes), // pad. type + ::testing::Values(std::vector({0, 0})), // pad. begin + ::testing::Values(std::vector({0, 0})), // pad. end + ::testing::Values(std::vector{1, 1}), // strides + ::testing::Values(std::vector{1, 1}) // dilations ); -const auto addSpParamsDilationUneven = ::testing::Combine( - ::testing::ValuesIn(padTypes), // pad. type - ::testing::Values(std::vector({0, 0})), // pad. begin - ::testing::Values(std::vector({0, 0})), // pad. end - ::testing::Values(std::vector {1, 1}), // strides - ::testing::Values(std::vector {2, 1}) // dilations -); +const auto addSpParamsDilationUneven = + ::testing::Combine(::testing::ValuesIn(padTypes), // pad. type + ::testing::Values(std::vector({0, 0})), // pad. begin + ::testing::Values(std::vector({0, 0})), // pad. end + ::testing::Values(std::vector{1, 1}), // strides + ::testing::Values(std::vector{2, 1})); // dilations const std::vector> spatParams1 = { - {1}, // batch - {34, 34}, // in. spat. shape - {32, 32}, // off. spat. shape - {3, 3} // ker. spat. shape + {1}, // batch + {34, 34}, // in. spat. shape + {32, 32}, // off. spat. shape + {3, 3} // ker. spat. shape }; const std::vector> spatParams2 = { - {1}, // batch - {3, 3}, // in. spat. shape - {2, 2}, // off. spat. shape - {2, 2} // ker. spat. shape + {1}, // batch + {3, 3}, // in. spat. shape + {2, 2}, // off. spat. shape + {2, 2} // ker. spat. shape }; const std::vector> spatParams3 = { - {1}, // batch - {5, 5}, // in. spat. shape - {4, 4}, // off. spat. shape - {2, 2} // ker. spat. shape + {1}, // batch + {5, 5}, // in. spat. shape + {4, 4}, // off. spat. shape + {2, 2} // ker. spat. shape }; const std::vector> spatParams4 = { - {1}, // batch - {3, 2}, // in. spat. shape - {2, 1}, // off. spat. shape - {2, 2} // ker. spat. shape + {1}, // batch + {3, 2}, // in. spat. shape + {2, 1}, // off. spat. shape + {2, 2} // ker. spat. shape }; const std::vector> spatParamsDilationUneven = { - {1}, // batch - {3, 2}, // in. spat. shape - {1, 1}, // off. spat. shape - {2, 2} // ker. spat. shape + {1}, // batch + {3, 2}, // in. spat. shape + {1, 1}, // off. spat. shape + {2, 2} // ker. spat. shape }; const std::vector> spatParams5_onnx2d = { - {1}, // batch - {4, 4}, // in. spat. shape - {3, 3}, // off. spat. shape - {2, 2} // ker. spat. shape + {1}, // batch + {4, 4}, // in. spat. shape + {3, 3}, // off. spat. shape + {2, 2} // ker. spat. shape }; const std::vector> channelParamsSingleGr = { - {1}, // gr. 2,4 - {1, 2}, // def. gr. 1,2 - {16, 32}, // in. ch. per gr. - {16, 32} // out. ch. per gr. + {1}, // gr. 2,4 + {1, 2}, // def. gr. 1,2 + {16, 32}, // in. ch. per gr. + {16, 32} // out. ch. per gr. }; const std::vector> channelParamsSingleGr2 = { - {1}, // gr. 2,4 - {1}, // def. gr. 1,2 - {3}, // in. ch. per gr. - {3} // out. ch. per gr. + {1}, // gr. 2,4 + {1}, // def. gr. 1,2 + {3}, // in. ch. per gr. + {3} // out. ch. per gr. }; const std::vector> channelParamsMulGr = { - {2, 4}, // gr. 2,4 - {1, 2}, // def. gr. 1,2 - {3, 7}, // in. ch. per gr. - {3, 7} // out. ch. per gr. + {2, 4}, // gr. 2,4 + {1, 2}, // def. gr. 1,2 + {3, 7}, // in. ch. per gr. + {3, 7} // out. ch. per gr. }; const std::vector> channelParams_onnx2d = { - {1}, // gr. 2,4 - {1}, // def. gr. 1,2 - {1}, // in. ch. per gr. - {1} // out. ch. per gr. + {1}, // gr. 2,4 + {1}, // def. gr. 1,2 + {1}, // in. ch. per gr. + {1} // out. ch. per gr. }; const std::vector> dynShapeChainRef = { - { - // gr == 2, dg == 1, in_ch_per_gr == 3, out_ch_per_gr == 3 - // {{dynamic shape}, {{static shape case1}, {static shape case2}, ...} - {{-1, -1, -1, -1}, {{1, 6, 3, 2}, {1, 6, 4, 3}, {1, 6, 5, 4}, {1, 6, 3, 2}}}, // input 0 - {{-1, -1, -1, -1}, {{1, 8, 2, 1}, {1, 8, 3, 2}, {1, 8, 4, 3}, {1, 8, 2, 1}}}, // input 1 - {{6, 3, 2, 2}, {{6, 3, 2, 2}, {6, 3, 2, 2}, {6, 3, 2, 2}, {6, 3, 2, 2}}}, // input 2 - {{-1, -1, -1, -1}, {{1, 4, 2, 1}, {1, 4, 3, 2}, {1, 4, 4, 3}, {1, 4, 2, 1}}} // input 3 - }, - { - {{{1, 5}, 6, {1, 10}, {1, 8}}, {{2, 6, 3, 2}, {1, 6, 4, 3}, {3, 6, 5, 4}, {2, 6, 3, 2}}}, - {{{1, 3}, 8, {1, 10}, {1, 8}}, {{2, 8, 2, 1}, {1, 8, 3, 2}, {3, 8, 4, 3}, {2, 8, 2, 1}}}, - {{6, 3, 2, 2}, {{6, 3, 2, 2}, {6, 3, 2, 2}, {6, 3, 2, 2}, {6, 3, 2, 2}}}, - {{{1, 3}, 4, {1, 10}, {1, 8}}, {{2, 4, 2, 1}, {1, 4, 3, 2}, {3, 4, 4, 3}, {2, 4, 2, 1}}} - }, - { - {{{1, 5}, {1, 6}, {1, 10}, {1, 8}}, {{2, 6, 3, 2}, {1, 6, 4, 3}, {3, 6, 5, 4}, {2, 6, 3, 2}}}, - {{{1, 3}, {1, 8}, {1, 10}, {1, 8}}, {{2, 8, 2, 1}, {1, 8, 3, 2}, {3, 8, 4, 3}, {2, 8, 2, 1}}}, - {{6, 3, 2, 2}, {{6, 3, 2, 2}, {6, 3, 2, 2}, {6, 3, 2, 2}, {6, 3, 2, 2}}}, - {{{1, 3}, {1, 5}, {1, 10}, {1, 8}}, {{2, 4, 2, 1}, {1, 4, 3, 2}, {3, 4, 4, 3}, {2, 4, 2, 1}}} - }, + { + // gr == 2, dg == 1, in_ch_per_gr == 3, out_ch_per_gr == 3 + // {{dynamic shape}, {{static shape case1}, {static shape case2}, ...} + {{-1, -1, -1, -1}, {{1, 6, 3, 2}, {1, 6, 4, 3}, {1, 6, 5, 4}, {1, 6, 3, 2}}}, // input 0 + {{-1, -1, -1, -1}, {{1, 8, 2, 1}, {1, 8, 3, 2}, {1, 8, 4, 3}, {1, 8, 2, 1}}}, // input 1 + {{6, 3, 2, 2}, {{6, 3, 2, 2}, {6, 3, 2, 2}, {6, 3, 2, 2}, {6, 3, 2, 2}}}, // input 2 + {{-1, -1, -1, -1}, {{1, 4, 2, 1}, {1, 4, 3, 2}, {1, 4, 4, 3}, {1, 4, 2, 1}}} // input 3 + }, + {{{{1, 5}, 6, {1, 10}, {1, 8}}, {{2, 6, 3, 2}, {1, 6, 4, 3}, {3, 6, 5, 4}, {2, 6, 3, 2}}}, + {{{1, 3}, 8, {1, 10}, {1, 8}}, {{2, 8, 2, 1}, {1, 8, 3, 2}, {3, 8, 4, 3}, {2, 8, 2, 1}}}, + {{6, 3, 2, 2}, {{6, 3, 2, 2}, {6, 3, 2, 2}, {6, 3, 2, 2}, {6, 3, 2, 2}}}, + {{{1, 3}, 4, {1, 10}, {1, 8}}, {{2, 4, 2, 1}, {1, 4, 3, 2}, {3, 4, 4, 3}, {2, 4, 2, 1}}}}, + {{{{1, 5}, {1, 6}, {1, 10}, {1, 8}}, {{2, 6, 3, 2}, {1, 6, 4, 3}, {3, 6, 5, 4}, {2, 6, 3, 2}}}, + {{{1, 3}, {1, 8}, {1, 10}, {1, 8}}, {{2, 8, 2, 1}, {1, 8, 3, 2}, {3, 8, 4, 3}, {2, 8, 2, 1}}}, + {{6, 3, 2, 2}, {{6, 3, 2, 2}, {6, 3, 2, 2}, {6, 3, 2, 2}, {6, 3, 2, 2}}}, + {{{1, 3}, {1, 5}, {1, 10}, {1, 8}}, {{2, 4, 2, 1}, {1, 4, 3, 2}, {3, 4, 4, 3}, {2, 4, 2, 1}}}}, }; const std::vector> dynShapeChainJIT = { - { - // gr == 1, dg == 1, in_ch_per_gr == 16, out_ch_per_gr == 16 - // {{dynamic shape}, {{static shape case1}, {static shape case2}, ...} - {{-1, -1, -1, -1}, {{1, 16, 3, 2}, {1, 16, 4, 3}, {1, 16, 5, 4}, {1, 16, 3, 2}}}, // input 0 - {{-1, 8, -1, -1}, {{1, 8, 2, 1}, {1, 8, 3, 2}, {1, 8, 4, 3}, {1, 8, 2, 1}}}, // input 1 - {{16, 16, 2, 2}, {{16, 16, 2, 2}, {16, 16, 2, 2}, {16, 16, 2, 2}, {16, 16, 2, 2}}}, // input 2 - {{-1, 4, -1, -1}, {{1, 4, 2, 1}, {1, 4, 3, 2}, {1, 4, 4, 3}, {1, 4, 2, 1}}} // input 3 - }, - { - {{{1, 5}, 16, {1, 10}, {1, 8}}, {{1, 16, 3, 2}, {1, 16, 4, 3}, {1, 16, 5, 4}, {1, 16, 3, 2}}}, // input 0 - {{{1, 5}, 8, {1, 10}, {1, 8}}, {{1, 8, 2, 1}, {1, 8, 3, 2}, {1, 8, 4, 3}, {1, 8, 2, 1}}}, // input 1 - {{16, 16, 2, 2}, {{16, 16, 2, 2}, {16, 16, 2, 2}, {16, 16, 2, 2}, {16, 16, 2, 2}}}, // input 2 - {{{1, 5}, 4, {1, 10}, {1, 8}}, {{1, 4, 2, 1}, {1, 4, 3, 2}, {1, 4, 4, 3}, {1, 4, 2, 1}}} // input 3 - }, - { - {{{1, 5}, {1, 16}, {1, 10}, {1, 8}}, {{1, 16, 3, 2}, {1, 16, 4, 3}, {1, 16, 5, 4}, {1, 16, 3, 2}}}, // input 0 - {{{1, 5}, {1, 8}, {1, 10}, {1, 8}}, {{1, 8, 2, 1}, {1, 8, 3, 2}, {1, 8, 4, 3}, {1, 8, 2, 1}}}, // input 1 - {{16, 16, 2, 2}, {{16, 16, 2, 2}, {16, 16, 2, 2}, {16, 16, 2, 2}, {16, 16, 2, 2}}}, // input 2 - {{{1, 5}, {1, 5}, {1, 10}, {1, 8}}, {{1, 4, 2, 1}, {1, 4, 3, 2}, {1, 4, 4, 3}, {1, 4, 2, 1}}} // input 3 - }, + { + // gr == 1, dg == 1, in_ch_per_gr == 16, out_ch_per_gr == 16 + // {{dynamic shape}, {{static shape case1}, {static shape case2}, ...} + {{-1, -1, -1, -1}, {{1, 16, 3, 2}, {1, 16, 4, 3}, {1, 16, 5, 4}, {1, 16, 3, 2}}}, // input 0 + {{-1, 8, -1, -1}, {{1, 8, 2, 1}, {1, 8, 3, 2}, {1, 8, 4, 3}, {1, 8, 2, 1}}}, // input 1 + {{16, 16, 2, 2}, {{16, 16, 2, 2}, {16, 16, 2, 2}, {16, 16, 2, 2}, {16, 16, 2, 2}}}, // input 2 + {{-1, 4, -1, -1}, {{1, 4, 2, 1}, {1, 4, 3, 2}, {1, 4, 4, 3}, {1, 4, 2, 1}}} // input 3 + }, + { + {{{1, 5}, 16, {1, 10}, {1, 8}}, {{1, 16, 3, 2}, {1, 16, 4, 3}, {1, 16, 5, 4}, {1, 16, 3, 2}}}, // input 0 + {{{1, 5}, 8, {1, 10}, {1, 8}}, {{1, 8, 2, 1}, {1, 8, 3, 2}, {1, 8, 4, 3}, {1, 8, 2, 1}}}, // input 1 + {{16, 16, 2, 2}, {{16, 16, 2, 2}, {16, 16, 2, 2}, {16, 16, 2, 2}, {16, 16, 2, 2}}}, // input 2 + {{{1, 5}, 4, {1, 10}, {1, 8}}, {{1, 4, 2, 1}, {1, 4, 3, 2}, {1, 4, 4, 3}, {1, 4, 2, 1}}} // input 3 + }, + { + {{{1, 5}, {1, 16}, {1, 10}, {1, 8}}, {{1, 16, 3, 2}, {1, 16, 4, 3}, {1, 16, 5, 4}, {1, 16, 3, 2}}}, // input 0 + {{{1, 5}, {1, 8}, {1, 10}, {1, 8}}, {{1, 8, 2, 1}, {1, 8, 3, 2}, {1, 8, 4, 3}, {1, 8, 2, 1}}}, // input 1 + {{16, 16, 2, 2}, {{16, 16, 2, 2}, {16, 16, 2, 2}, {16, 16, 2, 2}, {16, 16, 2, 2}}}, // input 2 + {{{1, 5}, {1, 5}, {1, 10}, {1, 8}}, {{1, 4, 2, 1}, {1, 4, 3, 2}, {1, 4, 4, 3}, {1, 4, 2, 1}}} // input 3 + }, }; // autopad params -const std::vector> dynShapeChainJITAutoPad = { - { - {{{1, 5}, {1, 16}, {1, 10}, {1, 10}}, {{1, 16, 3, 2}, {1, 16, 10, 10}, {1, 16, 3, 2}}}, // input 0 - {{{1, 5}, 8, {1, 10}, {1, 10}}, {{1, 8, 3, 2}, {1, 8, 10, 10}, {1, 8, 3, 2}}}, // input 1 - {{16, 16, 2, 2}, {{16, 16, 2, 2}, {16, 16, 2, 2}, {16, 16, 2, 2}}}, // input 2 - {{{1, 5}, 4, {1, 10}, {1, 10}}, {{1, 4, 3, 2}, {1, 4, 10, 10}, {1, 4, 3, 2}}} // input 3 - } -}; +const std::vector> dynShapeChainJITAutoPad = {{ + {{{1, 5}, {1, 16}, {1, 10}, {1, 10}}, {{1, 16, 3, 2}, {1, 16, 10, 10}, {1, 16, 3, 2}}}, // input 0 + {{{1, 5}, 8, {1, 10}, {1, 10}}, {{1, 8, 3, 2}, {1, 8, 10, 10}, {1, 8, 3, 2}}}, // input 1 + {{16, 16, 2, 2}, {{16, 16, 2, 2}, {16, 16, 2, 2}, {16, 16, 2, 2}}}, // input 2 + {{{1, 5}, 4, {1, 10}, {1, 10}}, {{1, 4, 3, 2}, {1, 4, 10, 10}, {1, 4, 3, 2}}} // input 3 +}}; const std::vector> autoPadSpatParams = { - {1}, // batch - {3, 2}, // in. spat. shape - {3, 2}, // off. spat. shape - {2, 2} // ker. spat. shape + {1}, // batch + {3, 2}, // in. spat. shape + {3, 2}, // off. spat. shape + {2, 2} // ker. spat. shape }; -std::vector padTypesAutoPad = { - ngraph::op::PadType::SAME_LOWER, - ngraph::op::PadType::SAME_UPPER -}; +std::vector padTypesAutoPad = {ov::op::PadType::SAME_LOWER, ov::op::PadType::SAME_UPPER}; -const auto autoPadAddSpParams = ::testing::Combine( - ::testing::ValuesIn(padTypesAutoPad), // pad. type - ::testing::Values(std::vector({0, 0})), // pad. begin - ignored - ::testing::Values(std::vector({0, 0})), // pad. end - ignored - ::testing::Values(std::vector {1, 1}), // strides - ::testing::Values(std::vector {1, 1}) // dilations -); +const auto autoPadAddSpParams = + ::testing::Combine(::testing::ValuesIn(padTypesAutoPad), // pad. type + ::testing::Values(std::vector({0, 0})), // pad. begin - ignored + ::testing::Values(std::vector({0, 0})), // pad. end - ignored + ::testing::Values(std::vector{1, 1}), // strides + ::testing::Values(std::vector{1, 1})); // dilations const auto params1_Smoke = ::testing::Combine( - ::testing::Combine( - addSpParams, - ::testing::ValuesIn(static_shapes_to_test_representation(buildStaticParams(spatParams1, channelParamsSingleGr))), - defConvSpecificParams_Smoke, - ::testing::ValuesIn(netPrecisions), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - ::testing::ValuesIn(filterCPUInfoForDevice())); + ::testing::Combine(addSpParams, + ::testing::ValuesIn( + static_shapes_to_test_representation(buildStaticParams(spatParams1, channelParamsSingleGr))), + defConvSpecificParams_Smoke, + ::testing::ValuesIn(netPrecisions), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::ValuesIn(filterCPUInfoForDevice())); const auto params2_Smoke = ::testing::Combine( - ::testing::Combine( - addSpParams, - ::testing::ValuesIn(static_shapes_to_test_representation(buildStaticParams(spatParams2, channelParamsSingleGr))), - defConvSpecificParams_Smoke, - ::testing::ValuesIn(netPrecisions), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - ::testing::ValuesIn(filterCPUInfoForDevice())); + ::testing::Combine(addSpParams, + ::testing::ValuesIn( + static_shapes_to_test_representation(buildStaticParams(spatParams2, channelParamsSingleGr))), + defConvSpecificParams_Smoke, + ::testing::ValuesIn(netPrecisions), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::ValuesIn(filterCPUInfoForDevice())); const auto params3_Smoke = ::testing::Combine( - ::testing::Combine( - addSpParams, - ::testing::ValuesIn(static_shapes_to_test_representation(buildStaticParams(spatParams3, channelParamsSingleGr))), - defConvSpecificParams_Smoke, - ::testing::ValuesIn(netPrecisions), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - ::testing::ValuesIn(filterCPUInfoForDevice())); + ::testing::Combine(addSpParams, + ::testing::ValuesIn( + static_shapes_to_test_representation(buildStaticParams(spatParams3, channelParamsSingleGr))), + defConvSpecificParams_Smoke, + ::testing::ValuesIn(netPrecisions), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::ValuesIn(filterCPUInfoForDevice())); const auto params4_Smoke = ::testing::Combine( - ::testing::Combine( - addSpParams, - ::testing::ValuesIn(static_shapes_to_test_representation(buildStaticParams(spatParams4, channelParamsSingleGr))), - defConvSpecificParams_Smoke, - ::testing::ValuesIn(netPrecisions), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - ::testing::ValuesIn(filterCPUInfoForDevice())); + ::testing::Combine(addSpParams, + ::testing::ValuesIn( + static_shapes_to_test_representation(buildStaticParams(spatParams4, channelParamsSingleGr))), + defConvSpecificParams_Smoke, + ::testing::ValuesIn(netPrecisions), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::ValuesIn(filterCPUInfoForDevice())); const auto params5_Smoke = ::testing::Combine( - ::testing::Combine( - addSpParams, - ::testing::ValuesIn(static_shapes_to_test_representation(buildStaticParams(spatParams4, channelParamsMulGr))), - defConvSpecificParams_Smoke, - ::testing::ValuesIn(netPrecisions), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - ::testing::ValuesIn(filterCPUInfoForDevice(true))); -const auto params6_Smoke = ::testing::Combine( - ::testing::Combine( - addSpParams, - ::testing::ValuesIn(dynShapeChainRef), - defConvSpecificParams_Smoke, - ::testing::ValuesIn(netPrecisions), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - ::testing::ValuesIn(filterCPUInfoForDevice(true))); -const auto params7_Smoke = ::testing::Combine( - ::testing::Combine( - addSpParams, - ::testing::ValuesIn(dynShapeChainJIT), - defConvSpecificParams_Smoke, - ::testing::ValuesIn(netPrecisions), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - ::testing::ValuesIn(filterCPUInfoForDevice(false))); -const auto params8_Smoke = ::testing::Combine( - ::testing::Combine( - autoPadAddSpParams, - ::testing::ValuesIn(static_shapes_to_test_representation(buildStaticParams(autoPadSpatParams, channelParamsSingleGr))), - defConvSpecificParams_Smoke, - ::testing::ValuesIn(netPrecisions), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - ::testing::ValuesIn(filterCPUInfoForDevice())); -const auto params9_Smoke = ::testing::Combine( - ::testing::Combine( - autoPadAddSpParams, - ::testing::ValuesIn(dynShapeChainJITAutoPad), - defConvSpecificParams_Smoke, - ::testing::ValuesIn(netPrecisions), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - ::testing::ValuesIn(filterCPUInfoForDevice(false))); - -INSTANTIATE_TEST_SUITE_P(smoke_DefConvLayoutTest1, DefConvLayerCPUTest, params1_Smoke, DefConvLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_SUITE_P(smoke_DefConvLayoutTest2, DefConvLayerCPUTest, params2_Smoke, DefConvLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_SUITE_P(smoke_DefConvLayoutTest3, DefConvLayerCPUTest, params3_Smoke, DefConvLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_SUITE_P(smoke_DefConvLayoutTest4, DefConvLayerCPUTest, params4_Smoke, DefConvLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_SUITE_P(smoke_DefConvLayoutTest5, DefConvLayerCPUTest, params5_Smoke, DefConvLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_SUITE_P(smoke_DefConvLayoutTest6, DefConvLayerCPUTest, params6_Smoke, DefConvLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_SUITE_P(smoke_DefConvLayoutTest7, DefConvLayerCPUTest, params7_Smoke, DefConvLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_SUITE_P(smoke_DefConvLayoutTest8, DefConvLayerCPUTest, params8_Smoke, DefConvLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_SUITE_P(smoke_DefConvLayoutTest9, DefConvLayerCPUTest, params9_Smoke, DefConvLayerCPUTest::getTestCaseName); - -const auto params1 = ::testing::Combine( - ::testing::Combine( - addSpParams, - ::testing::ValuesIn(static_shapes_to_test_representation(buildStaticParams(spatParams1, channelParamsSingleGr2))), - defConvSpecificParams, - ::testing::ValuesIn(netPrecisions), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - ::testing::ValuesIn(filterCPUInfoForDevice())); -const auto params2 = ::testing::Combine( - ::testing::Combine( - addSpParams, - ::testing::ValuesIn(static_shapes_to_test_representation(buildStaticParams(spatParams2, channelParamsSingleGr))), - defConvSpecificParams, - ::testing::ValuesIn(netPrecisions), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - ::testing::ValuesIn(filterCPUInfoForDevice())); -const auto params3 = ::testing::Combine( - ::testing::Combine( - addSpParams, - ::testing::ValuesIn(static_shapes_to_test_representation(buildStaticParams(spatParams3, channelParamsSingleGr))), - defConvSpecificParams, - ::testing::ValuesIn(netPrecisions), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - ::testing::ValuesIn(filterCPUInfoForDevice())); -const auto params4 = ::testing::Combine( - ::testing::Combine( - addSpParams, - ::testing::ValuesIn(static_shapes_to_test_representation(buildStaticParams(spatParams4, channelParamsSingleGr))), - defConvSpecificParams, - ::testing::ValuesIn(netPrecisions), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - ::testing::ValuesIn(filterCPUInfoForDevice())); + ::testing::Combine( + addSpParams, + ::testing::ValuesIn(static_shapes_to_test_representation(buildStaticParams(spatParams4, channelParamsMulGr))), + defConvSpecificParams_Smoke, + ::testing::ValuesIn(netPrecisions), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::ValuesIn(filterCPUInfoForDevice(true))); +const auto params6_Smoke = ::testing::Combine(::testing::Combine(addSpParams, + ::testing::ValuesIn(dynShapeChainRef), + defConvSpecificParams_Smoke, + ::testing::ValuesIn(netPrecisions), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::ValuesIn(filterCPUInfoForDevice(true))); +const auto params7_Smoke = ::testing::Combine(::testing::Combine(addSpParams, + ::testing::ValuesIn(dynShapeChainJIT), + defConvSpecificParams_Smoke, + ::testing::ValuesIn(netPrecisions), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::ValuesIn(filterCPUInfoForDevice(false))); +const auto params8_Smoke = + ::testing::Combine(::testing::Combine(autoPadAddSpParams, + ::testing::ValuesIn(static_shapes_to_test_representation( + buildStaticParams(autoPadSpatParams, channelParamsSingleGr))), + defConvSpecificParams_Smoke, + ::testing::ValuesIn(netPrecisions), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::ValuesIn(filterCPUInfoForDevice())); +const auto params9_Smoke = ::testing::Combine(::testing::Combine(autoPadAddSpParams, + ::testing::ValuesIn(dynShapeChainJITAutoPad), + defConvSpecificParams_Smoke, + ::testing::ValuesIn(netPrecisions), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::ValuesIn(filterCPUInfoForDevice(false))); + +INSTANTIATE_TEST_SUITE_P(smoke_DefConvLayoutTest1, + DefConvLayerCPUTest, + params1_Smoke, + DefConvLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_DefConvLayoutTest2, + DefConvLayerCPUTest, + params2_Smoke, + DefConvLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_DefConvLayoutTest3, + DefConvLayerCPUTest, + params3_Smoke, + DefConvLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_DefConvLayoutTest4, + DefConvLayerCPUTest, + params4_Smoke, + DefConvLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_DefConvLayoutTest5, + DefConvLayerCPUTest, + params5_Smoke, + DefConvLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_DefConvLayoutTest6, + DefConvLayerCPUTest, + params6_Smoke, + DefConvLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_DefConvLayoutTest7, + DefConvLayerCPUTest, + params7_Smoke, + DefConvLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_DefConvLayoutTest8, + DefConvLayerCPUTest, + params8_Smoke, + DefConvLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_DefConvLayoutTest9, + DefConvLayerCPUTest, + params9_Smoke, + DefConvLayerCPUTest::getTestCaseName); + +const auto params1 = ::testing::Combine(::testing::Combine(addSpParams, + ::testing::ValuesIn(static_shapes_to_test_representation( + buildStaticParams(spatParams1, channelParamsSingleGr2))), + defConvSpecificParams, + ::testing::ValuesIn(netPrecisions), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::ValuesIn(filterCPUInfoForDevice())); +const auto params2 = ::testing::Combine(::testing::Combine(addSpParams, + ::testing::ValuesIn(static_shapes_to_test_representation( + buildStaticParams(spatParams2, channelParamsSingleGr))), + defConvSpecificParams, + ::testing::ValuesIn(netPrecisions), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::ValuesIn(filterCPUInfoForDevice())); +const auto params3 = ::testing::Combine(::testing::Combine(addSpParams, + ::testing::ValuesIn(static_shapes_to_test_representation( + buildStaticParams(spatParams3, channelParamsSingleGr))), + defConvSpecificParams, + ::testing::ValuesIn(netPrecisions), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::ValuesIn(filterCPUInfoForDevice())); +const auto params4 = ::testing::Combine(::testing::Combine(addSpParams, + ::testing::ValuesIn(static_shapes_to_test_representation( + buildStaticParams(spatParams4, channelParamsSingleGr))), + defConvSpecificParams, + ::testing::ValuesIn(netPrecisions), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::ValuesIn(filterCPUInfoForDevice())); const auto params5 = ::testing::Combine( - ::testing::Combine( - addSpParams, - ::testing::ValuesIn(static_shapes_to_test_representation(buildStaticParams(spatParams4, channelParamsMulGr))), - defConvSpecificParams, - ::testing::ValuesIn(netPrecisions), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - ::testing::ValuesIn(filterCPUInfoForDevice(true))); -const auto params6 = ::testing::Combine( - ::testing::Combine( - addSpParams, - ::testing::ValuesIn(dynShapeChainRef), - defConvSpecificParams, - ::testing::ValuesIn(netPrecisions), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - ::testing::ValuesIn(filterCPUInfoForDevice(true))); -const auto params7 = ::testing::Combine( - ::testing::Combine( - addSpParams, - ::testing::ValuesIn(dynShapeChainJIT), - defConvSpecificParams, - ::testing::ValuesIn(netPrecisions), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - ::testing::ValuesIn(filterCPUInfoForDevice(false))); + ::testing::Combine( + addSpParams, + ::testing::ValuesIn(static_shapes_to_test_representation(buildStaticParams(spatParams4, channelParamsMulGr))), + defConvSpecificParams, + ::testing::ValuesIn(netPrecisions), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::ValuesIn(filterCPUInfoForDevice(true))); +const auto params6 = ::testing::Combine(::testing::Combine(addSpParams, + ::testing::ValuesIn(dynShapeChainRef), + defConvSpecificParams, + ::testing::ValuesIn(netPrecisions), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::ValuesIn(filterCPUInfoForDevice(true))); +const auto params7 = ::testing::Combine(::testing::Combine(addSpParams, + ::testing::ValuesIn(dynShapeChainJIT), + defConvSpecificParams, + ::testing::ValuesIn(netPrecisions), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::ValuesIn(filterCPUInfoForDevice(false))); // autopad cases -const auto params8 = ::testing::Combine( - ::testing::Combine( - autoPadAddSpParams, - ::testing::ValuesIn(static_shapes_to_test_representation(buildStaticParams(autoPadSpatParams, channelParamsSingleGr))), - defConvSpecificParams, - ::testing::ValuesIn(netPrecisions), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - ::testing::ValuesIn(filterCPUInfoForDevice())); -const auto params9 = ::testing::Combine( - ::testing::Combine( - autoPadAddSpParams, - ::testing::ValuesIn(dynShapeChainJITAutoPad), - defConvSpecificParams, - ::testing::ValuesIn(netPrecisions), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - ::testing::ValuesIn(filterCPUInfoForDevice(false))); -const auto params10 = ::testing::Combine( - ::testing::Combine( - addSpParamsDilationUneven, - ::testing::ValuesIn(static_shapes_to_test_representation(buildStaticParams(spatParamsDilationUneven, channelParamsSingleGr))), - defConvSpecificParams, - ::testing::ValuesIn(netPrecisions), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - ::testing::ValuesIn(filterCPUInfoForDevice(false))); -const auto params11 = ::testing::Combine( - ::testing::Combine( - addSpParams, - ::testing::ValuesIn(static_shapes_to_test_representation(buildStaticParams(spatParams5_onnx2d, channelParams_onnx2d))), - defConvSpecificParams, - ::testing::ValuesIn(netPrecisions), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - ::testing::ValuesIn(filterCPUInfoForDevice())); +const auto params8 = + ::testing::Combine(::testing::Combine(autoPadAddSpParams, + ::testing::ValuesIn(static_shapes_to_test_representation( + buildStaticParams(autoPadSpatParams, channelParamsSingleGr))), + defConvSpecificParams, + ::testing::ValuesIn(netPrecisions), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::ValuesIn(filterCPUInfoForDevice())); +const auto params9 = ::testing::Combine(::testing::Combine(autoPadAddSpParams, + ::testing::ValuesIn(dynShapeChainJITAutoPad), + defConvSpecificParams, + ::testing::ValuesIn(netPrecisions), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::ValuesIn(filterCPUInfoForDevice(false))); +const auto params10 = + ::testing::Combine(::testing::Combine(addSpParamsDilationUneven, + ::testing::ValuesIn(static_shapes_to_test_representation( + buildStaticParams(spatParamsDilationUneven, channelParamsSingleGr))), + defConvSpecificParams, + ::testing::ValuesIn(netPrecisions), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::ValuesIn(filterCPUInfoForDevice(false))); +const auto params11 = + ::testing::Combine(::testing::Combine(addSpParams, + ::testing::ValuesIn(static_shapes_to_test_representation( + buildStaticParams(spatParams5_onnx2d, channelParams_onnx2d))), + defConvSpecificParams, + ::testing::ValuesIn(netPrecisions), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::ValuesIn(filterCPUInfoForDevice())); INSTANTIATE_TEST_SUITE_P(DefConvLayoutTest1, DefConvLayerCPUTest, params1, DefConvLayerCPUTest::getTestCaseName); INSTANTIATE_TEST_SUITE_P(DefConvLayoutTest2, DefConvLayerCPUTest, params2, DefConvLayerCPUTest::getTestCaseName); @@ -634,37 +625,39 @@ INSTANTIATE_TEST_SUITE_P(DefConvLayoutTest10, DefConvLayerCPUTest, params10, Def INSTANTIATE_TEST_SUITE_P(DefConvLayoutTest11, DefConvLayerCPUTest, params11, DefConvLayerCPUTest::getTestCaseName); const std::vector> blockMultigroupChParam = { - {2}, // gr. - {1}, // def. gr. - {16}, // in. ch. per gr. - {16} // out. ch. per gr. + {2}, // gr. + {1}, // def. gr. + {16}, // in. ch. per gr. + {16} // out. ch. per gr. }; const std::vector> blockMultigroupSpatParam = { - {1}, // batch - {2, 2}, // in. spat. shape - {2, 2}, // off. spat. shape - {1, 1} // ker. spat. shape + {1}, // batch + {2, 2}, // in. spat. shape + {2, 2}, // off. spat. shape + {1, 1} // ker. spat. shape }; -const auto blockMultigroupAddParam = ::testing::Combine( - ::testing::Values(true), // with_bilinear_interpolation_pad - ::testing::Values(false), // with_modulation - ::testing::Values(OffsetType::ZERO) // offset type -); -const auto blockMultigroupKernelParam = ::testing::Combine( - ::testing::Values(ngraph::op::PadType::EXPLICIT), // pad. type - ::testing::Values(std::vector({0, 0})), // pad. begin - ::testing::Values(std::vector({0, 0})), // pad. end - ::testing::Values(std::vector {1, 1}), // strides - ::testing::Values(std::vector {1, 1}) // dilations +const auto blockMultigroupAddParam = ::testing::Combine(::testing::Values(true), // with_bilinear_interpolation_pad + ::testing::Values(false), // with_modulation + ::testing::Values(OffsetType::ZERO) // offset type ); -const auto blockMultigroupParam = ::testing::Combine( - ::testing::Combine( - blockMultigroupKernelParam, - ::testing::ValuesIn(static_shapes_to_test_representation(buildStaticParams(blockMultigroupSpatParam, blockMultigroupChParam))), - blockMultigroupAddParam, - ::testing::ValuesIn(netPrecisions), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - ::testing::ValuesIn(filterCPUInfoForDevice(true))); -INSTANTIATE_TEST_SUITE_P(blockMultigroupDefConvTest, DefConvLayerCPUTest, blockMultigroupParam, DefConvLayerCPUTest::getTestCaseName); -} // namespace -} // namespace CPULayerTestsDefinitions +const auto blockMultigroupKernelParam = + ::testing::Combine(::testing::Values(ov::op::PadType::EXPLICIT), // pad. type + ::testing::Values(std::vector({0, 0})), // pad. begin + ::testing::Values(std::vector({0, 0})), // pad. end + ::testing::Values(std::vector{1, 1}), // strides + ::testing::Values(std::vector{1, 1})); // dilations +const auto blockMultigroupParam = + ::testing::Combine(::testing::Combine(blockMultigroupKernelParam, + ::testing::ValuesIn(static_shapes_to_test_representation( + buildStaticParams(blockMultigroupSpatParam, blockMultigroupChParam))), + blockMultigroupAddParam, + ::testing::ValuesIn(netPrecisions), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::ValuesIn(filterCPUInfoForDevice(true))); +INSTANTIATE_TEST_SUITE_P(blockMultigroupDefConvTest, + DefConvLayerCPUTest, + blockMultigroupParam, + DefConvLayerCPUTest::getTestCaseName); +} // namespace +} // namespace test +} // 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/single_layer_tests/depth_to_space.cpp index 60a56a42b38b59..f39dd7c2f9d9d2 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/depth_to_space.cpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/depth_to_space.cpp @@ -3,33 +3,29 @@ // #include "shared_test_classes/single_layer/depth_to_space.hpp" + +#include "shared_test_classes/base/ov_subgraph.hpp" #include "test_utils/cpu_test_utils.hpp" #include "test_utils/filter_cpu_info.hpp" -#include "shared_test_classes/base/ov_subgraph.hpp" - -using namespace InferenceEngine; using namespace CPUTestUtils; -using namespace ngraph::opset3; -using namespace ov::test; - -namespace CPULayerTestsDefinitions { +namespace ov { +namespace test { -using DepthToSpaceLayerCPUTestParamSet = std::tuple< - InputShape, // Input shape - ElementType, // Input element type - DepthToSpace::DepthToSpaceMode, // Mode - std::size_t, // Block size - CPUSpecificParams ->; +using DepthToSpaceLayerCPUTestParamSet = std::tuple; class DepthToSpaceLayerCPUTest : public testing::WithParamInterface, - virtual public ov::test::SubgraphBaseTest, public CPUTestsBase { + virtual public ov::test::SubgraphBaseTest, + public CPUTestsBase { public: static std::string getTestCaseName(testing::TestParamInfo obj) { InputShape shapes; ElementType inType; - DepthToSpace::DepthToSpaceMode mode; + ov::op::v0::DepthToSpace::DepthToSpaceMode mode; std::size_t blockSize; CPUSpecificParams cpuParams; std::tie(shapes, inType, mode, blockSize, cpuParams) = obj.param; @@ -42,24 +38,25 @@ class DepthToSpaceLayerCPUTest : public testing::WithParamInterfaceGetParam(); @@ -88,127 +85,91 @@ TEST_P(DepthToSpaceLayerCPUTest, CompareWithRefs) { namespace { -const auto cpuParams_nChw16c = CPUSpecificParams {{nChw16c}, {nChw16c}, {}, {}}; -const auto cpuParams_nCdhw16c = CPUSpecificParams {{nCdhw16c}, {nCdhw16c}, {}, {}}; +const auto cpuParams_nChw16c = CPUSpecificParams{{nChw16c}, {nChw16c}, {}, {}}; +const auto cpuParams_nCdhw16c = CPUSpecificParams{{nCdhw16c}, {nCdhw16c}, {}, {}}; -const auto cpuParams_nChw8c = CPUSpecificParams {{nChw8c}, {nChw8c}, {}, {}}; -const auto cpuParams_nCdhw8c = CPUSpecificParams {{nCdhw8c}, {nCdhw8c}, {}, {}}; +const auto cpuParams_nChw8c = CPUSpecificParams{{nChw8c}, {nChw8c}, {}, {}}; +const auto cpuParams_nCdhw8c = CPUSpecificParams{{nCdhw8c}, {nCdhw8c}, {}, {}}; -const auto cpuParams_nhwc = CPUSpecificParams {{nhwc}, {nhwc}, {}, {}}; -const auto cpuParams_ndhwc = CPUSpecificParams {{ndhwc}, {ndhwc}, {}, {}}; +const auto cpuParams_nhwc = CPUSpecificParams{{nhwc}, {nhwc}, {}, {}}; +const auto cpuParams_ndhwc = CPUSpecificParams{{ndhwc}, {ndhwc}, {}, {}}; -const auto cpuParams_nchw = CPUSpecificParams {{nchw}, {nchw}, {}, {}}; -const auto cpuParams_ncdhw = CPUSpecificParams {{ncdhw}, {ncdhw}, {}, {}}; +const auto cpuParams_nchw = CPUSpecificParams{{nchw}, {nchw}, {}, {}}; +const auto cpuParams_ncdhw = CPUSpecificParams{{ncdhw}, {ncdhw}, {}, {}}; -const std::vector CPUParams4D = { - cpuParams_nhwc, - cpuParams_nchw -}; +const std::vector CPUParams4D = {cpuParams_nhwc, cpuParams_nchw}; -const std::vector CPUParamsBlocked4D = { - cpuParams_nChw16c, - cpuParams_nChw8c, - cpuParams_nhwc -}; +const std::vector CPUParamsBlocked4D = {cpuParams_nChw16c, cpuParams_nChw8c, cpuParams_nhwc}; -const std::vector CPUParams5D = { - cpuParams_ndhwc, - cpuParams_ncdhw -}; +const std::vector CPUParams5D = {cpuParams_ndhwc, cpuParams_ncdhw}; -const std::vector CPUParamsBlocked5D = { - cpuParams_nCdhw16c, - cpuParams_nCdhw8c, - cpuParams_ndhwc -}; +const std::vector CPUParamsBlocked5D = {cpuParams_nCdhw16c, cpuParams_nCdhw8c, cpuParams_ndhwc}; -const std::vector inputElementType = { - ElementType::f32, - ElementType::bf16, - ElementType::i8 -}; +const std::vector inputElementType = {ElementType::f32, ElementType::bf16, ElementType::i8}; -const std::vector depthToSpaceModes = { - DepthToSpace::DepthToSpaceMode::BLOCKS_FIRST, - DepthToSpace::DepthToSpaceMode::DEPTH_FIRST -}; +const std::vector depthToSpaceModes = { + ov::op::v0::DepthToSpace::DepthToSpaceMode::BLOCKS_FIRST, + ov::op::v0::DepthToSpace::DepthToSpaceMode::DEPTH_FIRST}; /* *========================* Static Shapes Tests *========================* */ namespace static_shapes { -const std::vector inputShapesBS2_4D = { - {1, 64, 1, 1}, - {1, 64, 1, 3}, - {1, 128, 3, 3}, - {2, 128, 1, 1}, - {1, 192, 2, 2}, - {2, 256, 2, 3}, - {1, 512, 2, 1} -}; - -const std::vector inputShapesBS3_4D = { - {1, 27, 1, 1}, - {1, 27, 2, 3}, - {1, 18, 2, 3}, - {3, 18, 1, 1}, - {2, 18, 3, 1} -}; - -INSTANTIATE_TEST_SUITE_P(smoke_CPUDepthToSpaceBS2_4D, DepthToSpaceLayerCPUTest, - testing::Combine( - testing::ValuesIn(static_shapes_to_test_representation(inputShapesBS2_4D)), - testing::ValuesIn(inputElementType), - testing::ValuesIn(depthToSpaceModes), - testing::Values(1, 2), - testing::ValuesIn(filterCPUInfoForDevice(CPUParamsBlocked4D))), +const std::vector inputShapesBS2_4D = + {{1, 64, 1, 1}, {1, 64, 1, 3}, {1, 128, 3, 3}, {2, 128, 1, 1}, {1, 192, 2, 2}, {2, 256, 2, 3}, {1, 512, 2, 1}}; + +const std::vector inputShapesBS3_4D = {{1, 27, 1, 1}, + {1, 27, 2, 3}, + {1, 18, 2, 3}, + {3, 18, 1, 1}, + {2, 18, 3, 1}}; + +INSTANTIATE_TEST_SUITE_P(smoke_CPUDepthToSpaceBS2_4D, + DepthToSpaceLayerCPUTest, + testing::Combine(testing::ValuesIn(static_shapes_to_test_representation(inputShapesBS2_4D)), + testing::ValuesIn(inputElementType), + testing::ValuesIn(depthToSpaceModes), + testing::Values(1, 2), + testing::ValuesIn(filterCPUInfoForDevice(CPUParamsBlocked4D))), DepthToSpaceLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_SUITE_P(smoke_CPUDepthToSpaceStaticBS3_4D, DepthToSpaceLayerCPUTest, - testing::Combine( - testing::ValuesIn(static_shapes_to_test_representation(inputShapesBS3_4D)), - testing::ValuesIn(inputElementType), - testing::ValuesIn(depthToSpaceModes), - testing::Values(1, 3), - testing::ValuesIn(filterCPUInfoForDevice(CPUParams4D))), +INSTANTIATE_TEST_SUITE_P(smoke_CPUDepthToSpaceStaticBS3_4D, + DepthToSpaceLayerCPUTest, + testing::Combine(testing::ValuesIn(static_shapes_to_test_representation(inputShapesBS3_4D)), + testing::ValuesIn(inputElementType), + testing::ValuesIn(depthToSpaceModes), + testing::Values(1, 3), + testing::ValuesIn(filterCPUInfoForDevice(CPUParams4D))), DepthToSpaceLayerCPUTest::getTestCaseName); -const std::vector inputShapesBS2_5D = { - {1, 128, 1, 1, 1}, - {1, 128, 2, 1, 2}, - {1, 256, 2, 1, 3}, - {2, 256, 3, 1, 1}, - {1, 384, 1, 2, 2}, - {2, 512, 1, 2, 1} -}; - -const std::vector inputShapesBS3_5D = { - {1, 54, 1, 1, 1}, - {1, 54, 2, 1, 2}, - {3, 54, 1, 1, 1}, - {2, 54, 3, 1, 2}, - {1, 54, 3, 2, 2} -}; - -INSTANTIATE_TEST_SUITE_P(smoke_CPUDepthToSpaceStaticBS2_5D, DepthToSpaceLayerCPUTest, - testing::Combine( - testing::ValuesIn(static_shapes_to_test_representation(inputShapesBS2_5D)), - testing::ValuesIn(inputElementType), - testing::ValuesIn(depthToSpaceModes), - testing::Values(1, 2), - testing::ValuesIn(filterCPUInfoForDevice(CPUParamsBlocked5D))), +const std::vector inputShapesBS2_5D = + {{1, 128, 1, 1, 1}, {1, 128, 2, 1, 2}, {1, 256, 2, 1, 3}, {2, 256, 3, 1, 1}, {1, 384, 1, 2, 2}, {2, 512, 1, 2, 1}}; + +const std::vector inputShapesBS3_5D = {{1, 54, 1, 1, 1}, + {1, 54, 2, 1, 2}, + {3, 54, 1, 1, 1}, + {2, 54, 3, 1, 2}, + {1, 54, 3, 2, 2}}; + +INSTANTIATE_TEST_SUITE_P(smoke_CPUDepthToSpaceStaticBS2_5D, + DepthToSpaceLayerCPUTest, + testing::Combine(testing::ValuesIn(static_shapes_to_test_representation(inputShapesBS2_5D)), + testing::ValuesIn(inputElementType), + testing::ValuesIn(depthToSpaceModes), + testing::Values(1, 2), + testing::ValuesIn(filterCPUInfoForDevice(CPUParamsBlocked5D))), DepthToSpaceLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_SUITE_P(smoke_CPUDepthToSpaceStaticBS3_5D, DepthToSpaceLayerCPUTest, - testing::Combine( - testing::ValuesIn(static_shapes_to_test_representation(inputShapesBS3_5D)), - testing::ValuesIn(inputElementType), - testing::ValuesIn(depthToSpaceModes), - testing::Values(1, 3), - testing::ValuesIn(filterCPUInfoForDevice(CPUParams5D))), +INSTANTIATE_TEST_SUITE_P(smoke_CPUDepthToSpaceStaticBS3_5D, + DepthToSpaceLayerCPUTest, + testing::Combine(testing::ValuesIn(static_shapes_to_test_representation(inputShapesBS3_5D)), + testing::ValuesIn(inputElementType), + testing::ValuesIn(depthToSpaceModes), + testing::Values(1, 3), + testing::ValuesIn(filterCPUInfoForDevice(CPUParams5D))), DepthToSpaceLayerCPUTest::getTestCaseName); -} // namespace static_shapes +} // namespace static_shapes /* *========================* *==================* *========================* */ /* *========================* Dynamic Shapes Tests *========================* */ @@ -226,11 +187,8 @@ const std::vector inputShapes4D = { }; const std::vector inputShapes5D = { - {{-1, -1, -1, -1, -1}, // dynamic - {{2, 216, 1, 1, 1}, - {1, 216, 3, 1, 2}, - {1, 432, 2, 3, 1}, - {2, 216, 1, 1, 1}}}, // target + {{-1, -1, -1, -1, -1}, // dynamic + {{2, 216, 1, 1, 1}, {1, 216, 3, 1, 2}, {1, 432, 2, 3, 1}, {2, 216, 1, 1, 1}}}, // target {{{1, 3}, {216, 432}, {1, 4}, {1, 4}, {1, 4}}, // dynamic {{3, 216, 2, 2, 2}, {1, 432, 1, 1, 1}, {3, 216, 2, 2, 2}}}, // target @@ -244,53 +202,54 @@ const std::vector inputShapesBlocked5D = { {{1, 256, 1, 1, 1}, {1, 256, 2, 1, 3}, {3, 256, 3, 1, 2}, {1, 256, 2, 1, 3}}}, // target }; -INSTANTIATE_TEST_SUITE_P(smoke_CPUDepthToSpaceDynamic4D, DepthToSpaceLayerCPUTest, - testing::Combine( - testing::ValuesIn(inputShapes4D), - testing::ValuesIn(inputElementType), - testing::ValuesIn(depthToSpaceModes), - testing::Values(1, 2, 3), - testing::ValuesIn(filterCPUInfoForDevice(CPUParams4D))), +INSTANTIATE_TEST_SUITE_P(smoke_CPUDepthToSpaceDynamic4D, + DepthToSpaceLayerCPUTest, + testing::Combine(testing::ValuesIn(inputShapes4D), + testing::ValuesIn(inputElementType), + testing::ValuesIn(depthToSpaceModes), + testing::Values(1, 2, 3), + testing::ValuesIn(filterCPUInfoForDevice(CPUParams4D))), + DepthToSpaceLayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_CPUDepthToSpaceDynamicBlocksFirstBlocked4D, + DepthToSpaceLayerCPUTest, + testing::Combine(testing::Values(inputShapes4D[1]), + testing::ValuesIn(inputElementType), + testing::Values(ov::op::v0::DepthToSpace::DepthToSpaceMode::BLOCKS_FIRST), + testing::Values(1, 2, 3), + testing::ValuesIn(filterCPUInfoForDevice(CPUParamsBlocked4D))), DepthToSpaceLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_SUITE_P(smoke_CPUDepthToSpaceDynamicBlocksFirstBlocked4D, DepthToSpaceLayerCPUTest, - testing::Combine( - testing::Values(inputShapes4D[1]), - testing::ValuesIn(inputElementType), - testing::Values(DepthToSpace::DepthToSpaceMode::BLOCKS_FIRST), - testing::Values(1, 2, 3), - testing::ValuesIn(filterCPUInfoForDevice(CPUParamsBlocked4D))), - DepthToSpaceLayerCPUTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_CPUDepthToSpaceDynamicDepthFirstBlocked4D, DepthToSpaceLayerCPUTest, - testing::Combine( - testing::Values(inputShapes4D[1]), - testing::ValuesIn(inputElementType), - testing::Values(DepthToSpace::DepthToSpaceMode::DEPTH_FIRST), - testing::Values(1, 2), - testing::ValuesIn(filterCPUInfoForDevice(CPUParamsBlocked4D))), +INSTANTIATE_TEST_SUITE_P(smoke_CPUDepthToSpaceDynamicDepthFirstBlocked4D, + DepthToSpaceLayerCPUTest, + testing::Combine(testing::Values(inputShapes4D[1]), + testing::ValuesIn(inputElementType), + testing::Values(ov::op::v0::DepthToSpace::DepthToSpaceMode::DEPTH_FIRST), + testing::Values(1, 2), + testing::ValuesIn(filterCPUInfoForDevice(CPUParamsBlocked4D))), DepthToSpaceLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_SUITE_P(smoke_CPUDepthToSpaceDynamic5D, DepthToSpaceLayerCPUTest, - testing::Combine( - testing::ValuesIn(inputShapes5D), - testing::ValuesIn(inputElementType), - testing::ValuesIn(depthToSpaceModes), - testing::Values(1, 2, 3), - testing::ValuesIn(filterCPUInfoForDevice(CPUParams5D))), +INSTANTIATE_TEST_SUITE_P(smoke_CPUDepthToSpaceDynamic5D, + DepthToSpaceLayerCPUTest, + testing::Combine(testing::ValuesIn(inputShapes5D), + testing::ValuesIn(inputElementType), + testing::ValuesIn(depthToSpaceModes), + testing::Values(1, 2, 3), + testing::ValuesIn(filterCPUInfoForDevice(CPUParams5D))), DepthToSpaceLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_SUITE_P(smoke_CPUDepthToSpaceDynamicCPUSpecific5D, DepthToSpaceLayerCPUTest, - testing::Combine( - testing::ValuesIn(inputShapesBlocked5D), - testing::ValuesIn(inputElementType), - testing::ValuesIn(depthToSpaceModes), - testing::Values(1, 2), - testing::ValuesIn(filterCPUInfoForDevice(CPUParamsBlocked5D))), +INSTANTIATE_TEST_SUITE_P(smoke_CPUDepthToSpaceDynamicCPUSpecific5D, + DepthToSpaceLayerCPUTest, + testing::Combine(testing::ValuesIn(inputShapesBlocked5D), + testing::ValuesIn(inputElementType), + testing::ValuesIn(depthToSpaceModes), + testing::Values(1, 2), + testing::ValuesIn(filterCPUInfoForDevice(CPUParamsBlocked5D))), DepthToSpaceLayerCPUTest::getTestCaseName); } // namespace dynamic_shapes /* *========================* *==================* *========================* */ -} // namespace -} // namespace CPULayerTestsDefinitions +} // namespace +} // namespace test +} // namespace ov diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/detection_output.cpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/detection_output.cpp index e42f7e6ee6f31b..0fd802163263f3 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/detection_output.cpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/detection_output.cpp @@ -4,83 +4,89 @@ #include "shared_test_classes/single_layer/detection_output.hpp" -#include "ov_models/builders.hpp" -#include -#include "test_utils/cpu_test_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" -using namespace InferenceEngine; using namespace CPUTestUtils; -using namespace ov; -using namespace test; - -namespace CPULayerTestsDefinitions { - -using namespace ov::test; - -enum { - idxLocation, - idxConfidence, - idxPriors, - idxArmConfidence, - idxArmLocation, - numInputs -}; - -using ParamsWhichSizeDependsDynamic = std::tuple< - bool, // varianceEncodedInTarget - bool, // shareLocation - bool, // normalized - size_t, // inputHeight - size_t, // inputWidth - ov::test::InputShape, // "Location" input - ov::test::InputShape, // "Confidence" input - ov::test::InputShape, // "Priors" input - ov::test::InputShape, // "ArmConfidence" input - ov::test::InputShape // "ArmLocation" input - >; - -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 DetectionOutputParamsDynamic = std::tuple< - DetectionOutputAttributes, - ParamsWhichSizeDependsDynamic, - size_t, // Number of batch - float, // objectnessScore - bool, // replace dynamic shapes to intervals - std::string // Device name - >; +namespace ov { +namespace test { + +enum { idxLocation, idxConfidence, idxPriors, idxArmConfidence, idxArmLocation, numInputs }; + +using ParamsWhichSizeDependsDynamic = std::tuple; + +using DetectionOutputAttributes = std::tuple, // keepTopK + std::string, // codeType + float, // nmsThreshold + float, // confidenceThreshold + bool, // clip_afterNms + bool, // clip_beforeNms + bool // decreaseLabelId + >; + +using DetectionOutputParamsDynamic = std::tuple; class DetectionOutputLayerCPUTest : public testing::WithParamInterface, - virtual public SubgraphBaseTest, public CPUTestsBase { + virtual public SubgraphBaseTest, + public CPUTestsBase { public: static std::string getTestCaseName(const testing::TestParamInfo& obj) { DetectionOutputAttributes commonAttrs; ParamsWhichSizeDependsDynamic specificAttrs; - ngraph::op::DetectionOutputAttrs attrs; + ov::op::v0::DetectionOutput::Attributes attrs; size_t batch; bool replaceDynamicShapesToIntervals; std::string targetDevice; - std::tie(commonAttrs, specificAttrs, batch, attrs.objectness_score, replaceDynamicShapesToIntervals, 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; + std::tie(commonAttrs, + specificAttrs, + batch, + attrs.objectness_score, + replaceDynamicShapesToIntervals, + 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; + 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].first.rank().get_length() == 0ul) { inShapes.resize(3); @@ -109,34 +115,8 @@ class DetectionOutputLayerCPUTest : public testing::WithParamInterface& targetInputStaticShapes) override { - inputs.clear(); - const auto& funcInputs = function->inputs(); - for (auto i = 0ul; i < funcInputs.size(); ++i) { - const auto &funcInput = funcInputs[i]; - InferenceEngine::Blob::Ptr blob; - int32_t resolution = 1; - uint32_t range = 1; - if (i == 2) { - if (attrs.normalized) { - resolution = 100; - } else { - range = 10; - } - } else if (i == 1 || i == 3) { - resolution = 1000; - } else { - resolution = 10; - } - - auto tensor = ov::test::utils::create_and_fill_tensor(funcInput.get_element_type(), targetInputStaticShapes[i], range, 0, resolution); - inputs.insert({funcInput.get_node_shared_ptr(), tensor}); - } - } - - void compare( - const std::vector& expectedTensors, - const std::vector& actualTensors) override { + void compare(const std::vector& expectedTensors, + const std::vector& actualTensors) override { ASSERT_EQ(expectedTensors.size(), actualTensors.size()); for (size_t i = 0; i < expectedTensors.size(); ++i) { @@ -146,7 +126,7 @@ class DetectionOutputLayerCPUTest : public testing::WithParamInterface(); - for (size_t i = 0; i < expected.get_size(); i+=7) { + for (size_t i = 0; i < expected.get_size(); i += 7) { if (expBuf[i] == -1) break; expSize += 7; @@ -154,7 +134,7 @@ class DetectionOutputLayerCPUTest : public testing::WithParamInterface(); - for (size_t i = 0; i < actual.get_size(); i+=7) { + for (size_t i = 0; i < actual.get_size(); i += 7) { if (actBuf[i] == -1) break; actSize += 7; @@ -171,14 +151,35 @@ class DetectionOutputLayerCPUTest : public testing::WithParamInterfaceGetParam(); - - 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; + std::tie(commonAttrs, + specificAttrs, + batch, + attrs.objectness_score, + replaceDynamicShapesToIntervals, + 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; + 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].first.rank().get_length() == 0) { inShapes.resize(3); @@ -195,7 +196,7 @@ class DetectionOutputLayerCPUTest : public testing::WithParamInterface(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); + 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"); - ngraph::ResultVector results{std::make_shared(detOut)}; - function = std::make_shared(results, params, "DetectionOutputDynamic"); + ov::ResultVector results{std::make_shared(detOut)}; + function = std::make_shared(results, params, "DetectionOutputDynamic"); } private: @@ -236,13 +242,12 @@ class DetectionOutputLayerCPUTest : public testing::WithParamInterface inShapes; }; @@ -255,7 +260,7 @@ namespace { const int numClasses = 11; const int backgroundLabelId = 0; const std::vector topK = {75}; -const std::vector> keepTopK = { {50}, {100} }; +const std::vector> keepTopK = {{50}, {100}}; const std::vector codeType = {"caffe.PriorBoxParameter.CORNER", "caffe.PriorBoxParameter.CENTER_SIZE"}; const float nmsThreshold = 0.5f; const float confidenceThreshold = 0.3f; @@ -265,290 +270,337 @@ const std::vector decreaseLabelId = {true, false}; const float objectnessScore = 0.4f; const std::vector numberBatch = {1, 2}; -const auto commonAttributes = ::testing::Combine( - ::testing::Values(numClasses), - ::testing::Values(backgroundLabelId), - ::testing::ValuesIn(topK), - ::testing::ValuesIn(keepTopK), - ::testing::ValuesIn(codeType), - ::testing::Values(nmsThreshold), - ::testing::Values(confidenceThreshold), - ::testing::ValuesIn(clipAfterNms), - ::testing::ValuesIn(clipBeforeNms), - ::testing::ValuesIn(decreaseLabelId) -); +const auto commonAttributes = ::testing::Combine(::testing::Values(numClasses), + ::testing::Values(backgroundLabelId), + ::testing::ValuesIn(topK), + ::testing::ValuesIn(keepTopK), + ::testing::ValuesIn(codeType), + ::testing::Values(nmsThreshold), + ::testing::Values(confidenceThreshold), + ::testing::ValuesIn(clipAfterNms), + ::testing::ValuesIn(clipBeforeNms), + ::testing::ValuesIn(decreaseLabelId)); /* =============== 3 inputs cases =============== */ const std::vector specificParams3InDynamic = { // dynamic input shapes - ParamsWhichSizeDependsDynamic { - true, true, true, 1, 1, - { - // input model dynamic shapes - {ov::Dimension::dynamic(), ov::Dimension::dynamic()}, - // input tensor shapes - {{1, 60}, {1, 120}} - }, - { - // input model dynamic shapes - {ov::Dimension::dynamic(), ov::Dimension::dynamic()}, - // input tensor shapes - {{1, 165}, {1, 330}} - }, - { - // input model dynamic shapes - {ov::Dimension::dynamic(), ov::Dimension::dynamic(), ov::Dimension::dynamic()}, - // input tensor shapes - {{1, 1, 60}, {1, 1, 120}} - }, - {}, - {} - }, - ParamsWhichSizeDependsDynamic { - true, false, true, 1, 1, + ParamsWhichSizeDependsDynamic{true, + true, + true, + 1, + 1, + {// input model dynamic shapes + {ov::Dimension::dynamic(), ov::Dimension::dynamic()}, + // input tensor shapes + {{1, 60}, {1, 120}}}, + {// input model dynamic shapes + {ov::Dimension::dynamic(), ov::Dimension::dynamic()}, + // input tensor shapes + {{1, 165}, {1, 330}}}, + {// input model dynamic shapes + {ov::Dimension::dynamic(), ov::Dimension::dynamic(), ov::Dimension::dynamic()}, + // input tensor shapes + {{1, 1, 60}, {1, 1, 120}}}, + {}, + {}}, + ParamsWhichSizeDependsDynamic{ + true, + false, + true, + 1, + 1, {{ov::Dimension::dynamic(), ov::Dimension::dynamic()}, {{1, 660}, {1, 1320}}}, {{ov::Dimension::dynamic(), ov::Dimension::dynamic()}, {{1, 165}, {1, 330}}}, {{ov::Dimension::dynamic(), ov::Dimension::dynamic(), ov::Dimension::dynamic()}, {{1, 1, 60}, {1, 1, 120}}}, {}, - {} - }, - ParamsWhichSizeDependsDynamic { - false, true, true, 1, 1, + {}}, + ParamsWhichSizeDependsDynamic{ + false, + true, + true, + 1, + 1, {{ov::Dimension::dynamic(), ov::Dimension::dynamic()}, {{1, 60}, {1, 120}}}, {{ov::Dimension::dynamic(), ov::Dimension::dynamic()}, {{1, 165}, {1, 330}}}, {{ov::Dimension::dynamic(), ov::Dimension::dynamic(), ov::Dimension::dynamic()}, {{1, 2, 60}, {1, 2, 120}}}, {}, - {} - }, - ParamsWhichSizeDependsDynamic { - false, false, true, 1, 1, + {}}, + ParamsWhichSizeDependsDynamic{ + false, + false, + true, + 1, + 1, {{ov::Dimension::dynamic(), ov::Dimension::dynamic()}, {{1, 660}, {1, 1320}}}, {{ov::Dimension::dynamic(), ov::Dimension::dynamic()}, {{1, 165}, {1, 330}}}, {{ov::Dimension::dynamic(), ov::Dimension::dynamic(), ov::Dimension::dynamic()}, {{1, 2, 60}, {1, 2, 120}}}, {}, - {} - }, - ParamsWhichSizeDependsDynamic { - true, true, false, 10, 10, + {}}, + ParamsWhichSizeDependsDynamic{ + true, + true, + false, + 10, + 10, {{ov::Dimension::dynamic(), ov::Dimension::dynamic()}, {{1, 60}, {1, 120}}}, {{ov::Dimension::dynamic(), ov::Dimension::dynamic()}, {{1, 165}, {1, 330}}}, {{ov::Dimension::dynamic(), ov::Dimension::dynamic(), ov::Dimension::dynamic()}, {{1, 1, 75}, {1, 1, 150}}}, {}, - {} - }, - ParamsWhichSizeDependsDynamic { - true, false, false, 10, 10, + {}}, + ParamsWhichSizeDependsDynamic{ + true, + false, + false, + 10, + 10, {{ov::Dimension::dynamic(), ov::Dimension::dynamic()}, {{1, 660}, {1, 1320}}}, {{ov::Dimension::dynamic(), ov::Dimension::dynamic()}, {{1, 165}, {1, 330}}}, {{ov::Dimension::dynamic(), ov::Dimension::dynamic(), ov::Dimension::dynamic()}, {{1, 1, 75}, {1, 1, 150}}}, {}, - {} - }, - ParamsWhichSizeDependsDynamic { - false, true, false, 10, 10, + {}}, + ParamsWhichSizeDependsDynamic{ + false, + true, + false, + 10, + 10, {{ov::Dimension::dynamic(), ov::Dimension::dynamic()}, {{1, 60}, {1, 120}}}, {{ov::Dimension::dynamic(), ov::Dimension::dynamic()}, {{1, 165}, {1, 330}}}, {{ov::Dimension::dynamic(), ov::Dimension::dynamic(), ov::Dimension::dynamic()}, {{1, 2, 75}, {1, 2, 150}}}, {}, - {} - }, - ParamsWhichSizeDependsDynamic { - false, false, false, 10, 10, + {}}, + ParamsWhichSizeDependsDynamic{ + false, + false, + false, + 10, + 10, {{ov::Dimension::dynamic(), ov::Dimension::dynamic()}, {{1, 660}, {1, 1320}}}, {{ov::Dimension::dynamic(), ov::Dimension::dynamic()}, {{1, 165}, {1, 330}}}, {{ov::Dimension::dynamic(), ov::Dimension::dynamic(), ov::Dimension::dynamic()}, {{1, 2, 75}, {1, 2, 150}}}, {}, - {} - }, + {}}, }; -const auto params3InputsDynamic = ::testing::Combine( - commonAttributes, - ::testing::ValuesIn(specificParams3InDynamic), - ::testing::ValuesIn(numberBatch), - ::testing::Values(0.0f), - ::testing::Values(false, true), - ::testing::Values(ov::test::utils::DEVICE_CPU) -); - -INSTANTIATE_TEST_SUITE_P( - smoke_CPUDetectionOutputDynamic3In, - DetectionOutputLayerCPUTest, - params3InputsDynamic, - DetectionOutputLayerCPUTest::getTestCaseName); +const auto params3InputsDynamic = ::testing::Combine(commonAttributes, + ::testing::ValuesIn(specificParams3InDynamic), + ::testing::ValuesIn(numberBatch), + ::testing::Values(0.0f), + ::testing::Values(false, true), + ::testing::Values(ov::test::utils::DEVICE_CPU)); + +INSTANTIATE_TEST_SUITE_P(smoke_CPUDetectionOutputDynamic3In, + DetectionOutputLayerCPUTest, + params3InputsDynamic, + DetectionOutputLayerCPUTest::getTestCaseName); //////////////////large tensor///////////////// // There are two major implemenation for DO node, sparsity and dense manner. -// This test config(shapes, threshold...) go to sparsity path in most machines(as long as L3 per core cache is smaller than 8M). +// This test config(shapes, threshold...) go to sparsity path in most machines(as long as L3 per core cache is smaller +// than 8M). const std::vector specificParams3InDynamicLargeTensor = { // dynamic input shapes - ParamsWhichSizeDependsDynamic { - true, true, true, 1, 1, - {{ov::Dimension::dynamic(), ov::Dimension::dynamic()}, {{1, 381360}, {1, 381360}}}, - {{ov::Dimension::dynamic(), ov::Dimension::dynamic()}, {{1, 1048740}, {1, 1048740}}}, - {{ov::Dimension::dynamic(), ov::Dimension::dynamic(), ov::Dimension::dynamic()}, {{1, 1, 381360}, {1, 1, 381360}}}, - {}, - {} - }, - ParamsWhichSizeDependsDynamic { - false, true, true, 1, 1, - {{ov::Dimension::dynamic(), ov::Dimension::dynamic()}, {{1, 381360}, {1, 381360}}}, - {{ov::Dimension::dynamic(), ov::Dimension::dynamic()}, {{1, 1048740}, {1, 1048740}}}, - {{ov::Dimension::dynamic(), ov::Dimension::dynamic(), ov::Dimension::dynamic()}, {{1, 1, 381360}, {1, 1, 381360}}}, - {}, - {} - }, + ParamsWhichSizeDependsDynamic{true, + true, + true, + 1, + 1, + {{ov::Dimension::dynamic(), ov::Dimension::dynamic()}, {{1, 381360}, {1, 381360}}}, + {{ov::Dimension::dynamic(), ov::Dimension::dynamic()}, {{1, 1048740}, {1, 1048740}}}, + {{ov::Dimension::dynamic(), ov::Dimension::dynamic(), ov::Dimension::dynamic()}, + {{1, 1, 381360}, {1, 1, 381360}}}, + {}, + {}}, + ParamsWhichSizeDependsDynamic{false, + true, + true, + 1, + 1, + {{ov::Dimension::dynamic(), ov::Dimension::dynamic()}, {{1, 381360}, {1, 381360}}}, + {{ov::Dimension::dynamic(), ov::Dimension::dynamic()}, {{1, 1048740}, {1, 1048740}}}, + {{ov::Dimension::dynamic(), ov::Dimension::dynamic(), ov::Dimension::dynamic()}, + {{1, 1, 381360}, {1, 1, 381360}}}, + {}, + {}}, }; const std::vector confThreshold = {0.032f, 0.88f}; -const auto commonAttributesLargeTensor = ::testing::Combine( - ::testing::Values(numClasses), - ::testing::Values(backgroundLabelId), - ::testing::ValuesIn(topK), - ::testing::ValuesIn(keepTopK), - ::testing::ValuesIn(codeType), - ::testing::Values(nmsThreshold), - ::testing::ValuesIn(confThreshold), - ::testing::ValuesIn(clipAfterNms), - ::testing::ValuesIn(clipBeforeNms), - ::testing::Values(false) -); - -const auto params3InputsDynamicLargeTensor = ::testing::Combine( - commonAttributesLargeTensor, - ::testing::ValuesIn(specificParams3InDynamicLargeTensor), - ::testing::ValuesIn(numberBatch), - ::testing::Values(0.0f), - ::testing::Values(false, true), - ::testing::Values(ov::test::utils::DEVICE_CPU) -); -INSTANTIATE_TEST_SUITE_P( - CPUDetectionOutputDynamic3InLargeTensor, - DetectionOutputLayerCPUTest, - params3InputsDynamicLargeTensor, - DetectionOutputLayerCPUTest::getTestCaseName); +const auto commonAttributesLargeTensor = ::testing::Combine(::testing::Values(numClasses), + ::testing::Values(backgroundLabelId), + ::testing::ValuesIn(topK), + ::testing::ValuesIn(keepTopK), + ::testing::ValuesIn(codeType), + ::testing::Values(nmsThreshold), + ::testing::ValuesIn(confThreshold), + ::testing::ValuesIn(clipAfterNms), + ::testing::ValuesIn(clipBeforeNms), + ::testing::Values(false)); + +const auto params3InputsDynamicLargeTensor = + ::testing::Combine(commonAttributesLargeTensor, + ::testing::ValuesIn(specificParams3InDynamicLargeTensor), + ::testing::ValuesIn(numberBatch), + ::testing::Values(0.0f), + ::testing::Values(false, true), + ::testing::Values(ov::test::utils::DEVICE_CPU)); +INSTANTIATE_TEST_SUITE_P(CPUDetectionOutputDynamic3InLargeTensor, + DetectionOutputLayerCPUTest, + params3InputsDynamicLargeTensor, + DetectionOutputLayerCPUTest::getTestCaseName); /* =============== 5 inputs cases =============== */ const std::vector specificParams5InDynamic = { // dynamic input shapes - ParamsWhichSizeDependsDynamic { - true, true, true, 1, 1, + ParamsWhichSizeDependsDynamic{ + true, + true, + true, + 1, + 1, {{ov::Dimension::dynamic(), ov::Dimension::dynamic()}, {{1, 60}, {1, 120}}}, {{ov::Dimension::dynamic(), ov::Dimension::dynamic()}, {{1, 165}, {1, 330}}}, {{ov::Dimension::dynamic(), ov::Dimension::dynamic(), ov::Dimension::dynamic()}, {{1, 1, 60}, {1, 1, 120}}}, {{ov::Dimension::dynamic(), ov::Dimension::dynamic()}, {{1, 30}, {1, 60}}}, {{ov::Dimension::dynamic(), ov::Dimension::dynamic()}, {{1, 60}, {1, 120}}}, }, - ParamsWhichSizeDependsDynamic { - true, false, true, 1, 1, + ParamsWhichSizeDependsDynamic{ + true, + false, + true, + 1, + 1, {{ov::Dimension::dynamic(), ov::Dimension::dynamic()}, {{1, 660}, {1, 1320}}}, {{ov::Dimension::dynamic(), ov::Dimension::dynamic()}, {{1, 165}, {1, 330}}}, {{ov::Dimension::dynamic(), ov::Dimension::dynamic(), ov::Dimension::dynamic()}, {{1, 1, 60}, {1, 1, 120}}}, {{ov::Dimension::dynamic(), ov::Dimension::dynamic()}, {{1, 30}, {1, 60}}}, {{ov::Dimension::dynamic(), ov::Dimension::dynamic()}, {{1, 660}, {1, 1320}}}, }, - ParamsWhichSizeDependsDynamic { - false, true, true, 1, 1, + ParamsWhichSizeDependsDynamic{ + false, + true, + true, + 1, + 1, {{ov::Dimension::dynamic(), ov::Dimension::dynamic()}, {{1, 60}, {1, 120}}}, {{ov::Dimension::dynamic(), ov::Dimension::dynamic()}, {{1, 165}, {1, 330}}}, {{ov::Dimension::dynamic(), ov::Dimension::dynamic(), ov::Dimension::dynamic()}, {{1, 2, 60}, {1, 2, 120}}}, {{ov::Dimension::dynamic(), ov::Dimension::dynamic()}, {{1, 30}, {1, 60}}}, - {{ov::Dimension::dynamic(), ov::Dimension::dynamic()}, {{1, 60}, {1, 120}}} - }, - ParamsWhichSizeDependsDynamic { - false, false, true, 1, 1, + {{ov::Dimension::dynamic(), ov::Dimension::dynamic()}, {{1, 60}, {1, 120}}}}, + ParamsWhichSizeDependsDynamic{ + false, + false, + true, + 1, + 1, {{ov::Dimension::dynamic(), ov::Dimension::dynamic()}, {{1, 660}, {1, 1320}}}, {{ov::Dimension::dynamic(), ov::Dimension::dynamic()}, {{1, 165}, {1, 330}}}, {{ov::Dimension::dynamic(), ov::Dimension::dynamic(), ov::Dimension::dynamic()}, {{1, 2, 60}, {1, 2, 120}}}, {{ov::Dimension::dynamic(), ov::Dimension::dynamic()}, {{1, 30}, {1, 60}}}, - {{ov::Dimension::dynamic(), ov::Dimension::dynamic()}, {{1, 660}, {1, 1320}}} - }, - - ParamsWhichSizeDependsDynamic { - true, true, false, 10, 10, + {{ov::Dimension::dynamic(), ov::Dimension::dynamic()}, {{1, 660}, {1, 1320}}}}, + + ParamsWhichSizeDependsDynamic{ + true, + true, + false, + 10, + 10, {{ov::Dimension::dynamic(), ov::Dimension::dynamic()}, {{1, 60}, {1, 120}}}, {{ov::Dimension::dynamic(), ov::Dimension::dynamic()}, {{1, 165}, {1, 330}}}, {{ov::Dimension::dynamic(), ov::Dimension::dynamic(), ov::Dimension::dynamic()}, {{1, 1, 75}, {1, 1, 150}}}, {{ov::Dimension::dynamic(), ov::Dimension::dynamic()}, {{1, 30}, {1, 60}}}, - {{ov::Dimension::dynamic(), ov::Dimension::dynamic()}, {{1, 60}, {1, 120}}} - }, - ParamsWhichSizeDependsDynamic { - true, false, false, 10, 10, + {{ov::Dimension::dynamic(), ov::Dimension::dynamic()}, {{1, 60}, {1, 120}}}}, + ParamsWhichSizeDependsDynamic{ + true, + false, + false, + 10, + 10, {{ov::Dimension::dynamic(), ov::Dimension::dynamic()}, {{1, 660}, {1, 1320}}}, {{ov::Dimension::dynamic(), ov::Dimension::dynamic()}, {{1, 165}, {1, 330}}}, {{ov::Dimension::dynamic(), ov::Dimension::dynamic(), ov::Dimension::dynamic()}, {{1, 1, 75}, {1, 1, 150}}}, {{ov::Dimension::dynamic(), ov::Dimension::dynamic()}, {{1, 30}, {1, 60}}}, - {{ov::Dimension::dynamic(), ov::Dimension::dynamic()}, {{1, 660}, {1, 1320}}} - }, - ParamsWhichSizeDependsDynamic { - false, true, false, 10, 10, + {{ov::Dimension::dynamic(), ov::Dimension::dynamic()}, {{1, 660}, {1, 1320}}}}, + ParamsWhichSizeDependsDynamic{ + false, + true, + false, + 10, + 10, {{ov::Dimension::dynamic(), ov::Dimension::dynamic()}, {{1, 60}, {1, 120}}}, {{ov::Dimension::dynamic(), ov::Dimension::dynamic()}, {{1, 165}, {1, 330}}}, {{ov::Dimension::dynamic(), ov::Dimension::dynamic(), ov::Dimension::dynamic()}, {{1, 2, 75}, {1, 2, 150}}}, {{ov::Dimension::dynamic(), ov::Dimension::dynamic()}, {{1, 30}, {1, 60}}}, - {{ov::Dimension::dynamic(), ov::Dimension::dynamic()}, {{1, 60}, {1, 120}}} - }, - ParamsWhichSizeDependsDynamic { - false, false, false, 10, 10, + {{ov::Dimension::dynamic(), ov::Dimension::dynamic()}, {{1, 60}, {1, 120}}}}, + ParamsWhichSizeDependsDynamic{ + false, + false, + false, + 10, + 10, {{ov::Dimension::dynamic(), ov::Dimension::dynamic()}, {{1, 660}, {1, 1320}}}, {{ov::Dimension::dynamic(), ov::Dimension::dynamic()}, {{1, 165}, {1, 330}}}, {{ov::Dimension::dynamic(), ov::Dimension::dynamic(), ov::Dimension::dynamic()}, {{1, 2, 75}, {1, 2, 150}}}, {{ov::Dimension::dynamic(), ov::Dimension::dynamic()}, {{1, 30}, {1, 60}}}, - {{ov::Dimension::dynamic(), ov::Dimension::dynamic()}, {{1, 660}, {1, 1320}}} - }, + {{ov::Dimension::dynamic(), ov::Dimension::dynamic()}, {{1, 660}, {1, 1320}}}}, }; -const auto params5InputsDynamic = ::testing::Combine( - commonAttributes, - ::testing::ValuesIn(specificParams5InDynamic), - ::testing::ValuesIn(numberBatch), - ::testing::Values(objectnessScore), - ::testing::Values(false, true), - ::testing::Values(ov::test::utils::DEVICE_CPU) -); - -INSTANTIATE_TEST_SUITE_P( - smoke_CPUDetectionOutputDynamic5In, - DetectionOutputLayerCPUTest, - params5InputsDynamic, - DetectionOutputLayerCPUTest::getTestCaseName); +const auto params5InputsDynamic = ::testing::Combine(commonAttributes, + ::testing::ValuesIn(specificParams5InDynamic), + ::testing::ValuesIn(numberBatch), + ::testing::Values(objectnessScore), + ::testing::Values(false, true), + ::testing::Values(ov::test::utils::DEVICE_CPU)); + +INSTANTIATE_TEST_SUITE_P(smoke_CPUDetectionOutputDynamic5In, + DetectionOutputLayerCPUTest, + params5InputsDynamic, + DetectionOutputLayerCPUTest::getTestCaseName); //////////////////large tensor///////////////// const std::vector specificParams5InDynamicLargeTensor = { // dynamic input shapes - ParamsWhichSizeDependsDynamic { - true, true, true, 1, 1, + ParamsWhichSizeDependsDynamic{ + true, + true, + true, + 1, + 1, {{ov::Dimension::dynamic(), ov::Dimension::dynamic()}, {{1, 381360}, {1, 381360}}}, {{ov::Dimension::dynamic(), ov::Dimension::dynamic()}, {{1, 1048740}, {1, 1048740}}}, - {{ov::Dimension::dynamic(), ov::Dimension::dynamic(), ov::Dimension::dynamic()}, {{1, 1, 381360}, {1, 1, 381360}}}, + {{ov::Dimension::dynamic(), ov::Dimension::dynamic(), ov::Dimension::dynamic()}, + {{1, 1, 381360}, {1, 1, 381360}}}, {{ov::Dimension::dynamic(), ov::Dimension::dynamic()}, {{1, 190680}, {1, 190680}}}, {{ov::Dimension::dynamic(), ov::Dimension::dynamic()}, {{1, 381360}, {1, 381360}}}, }, - ParamsWhichSizeDependsDynamic { - true, false, true, 1, 1, + ParamsWhichSizeDependsDynamic{ + true, + false, + true, + 1, + 1, {{ov::Dimension::dynamic(), ov::Dimension::dynamic()}, {{1, 4194960}, {1, 4194960}}}, {{ov::Dimension::dynamic(), ov::Dimension::dynamic()}, {{1, 1048740}, {1, 1048740}}}, - {{ov::Dimension::dynamic(), ov::Dimension::dynamic(), ov::Dimension::dynamic()}, {{1, 1, 381360}, {1, 1, 381360}}}, + {{ov::Dimension::dynamic(), ov::Dimension::dynamic(), ov::Dimension::dynamic()}, + {{1, 1, 381360}, {1, 1, 381360}}}, {{ov::Dimension::dynamic(), ov::Dimension::dynamic()}, {{1, 190680}, {1, 190680}}}, {{ov::Dimension::dynamic(), ov::Dimension::dynamic()}, {{1, 4194960}, {1, 4194960}}}, }, }; -const auto params5InputsDynamicLargeTensor = ::testing::Combine( - commonAttributesLargeTensor, - ::testing::ValuesIn(specificParams5InDynamicLargeTensor), - ::testing::ValuesIn(numberBatch), - ::testing::Values(objectnessScore), - ::testing::Values(false, true), - ::testing::Values(ov::test::utils::DEVICE_CPU) -); - -INSTANTIATE_TEST_SUITE_P( - CPUDetectionOutputDynamic5InLargeTensor, - DetectionOutputLayerCPUTest, - params5InputsDynamicLargeTensor, - DetectionOutputLayerCPUTest::getTestCaseName); +const auto params5InputsDynamicLargeTensor = + ::testing::Combine(commonAttributesLargeTensor, + ::testing::ValuesIn(specificParams5InDynamicLargeTensor), + ::testing::ValuesIn(numberBatch), + ::testing::Values(objectnessScore), + ::testing::Values(false, true), + ::testing::Values(ov::test::utils::DEVICE_CPU)); + +INSTANTIATE_TEST_SUITE_P(CPUDetectionOutputDynamic5InLargeTensor, + DetectionOutputLayerCPUTest, + params5InputsDynamicLargeTensor, + DetectionOutputLayerCPUTest::getTestCaseName); } // namespace -} // namespace CPULayerTestsDefinitions +} // namespace test +} // namespace ov diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/embedding_bag_offsets_sum.cpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/embedding_bag_offsets_sum.cpp index 8227678c0188f1..e84af61c1e7617 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/embedding_bag_offsets_sum.cpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/embedding_bag_offsets_sum.cpp @@ -2,41 +2,33 @@ // SPDX-License-Identifier: Apache-2.0 // -#include -#include -#include +#include "common_test_utils/node_builders/embedding_bag_offsets_sum.hpp" -#include -#include "ov_models/builders.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" -using namespace InferenceEngine; using namespace CPUTestUtils; -using namespace ov::test; - -namespace CPULayerTestsDefinitions { - -typedef std::tuple< - InputShape, // input_shapes - std::vector, // indices - std::vector, // offsets - size_t, // default_index - bool, // with_weights - bool // with_def_index - > embeddingBagOffsetsSumParams; - -typedef std::tuple< - embeddingBagOffsetsSumParams, - ElementType, // embedding table - ElementType, // indices - LayerTestsUtils::TargetDevice> embeddingBagOffsetsSumLayerTestParamsSet; - -class EmbeddingBagOffsetsSumLayerCPUTest : - public testing::WithParamInterface, - virtual public SubgraphBaseTest, - public CPUTestsBase { +namespace ov { +namespace test { + +typedef std::tuple, // indices + std::vector, // offsets + size_t, // default_index + bool, // with_weights + bool // with_def_index + > + embeddingBagOffsetsSumParams; + +typedef std::tuple + embeddingBagOffsetsSumLayerTestParamsSet; + +class EmbeddingBagOffsetsSumLayerCPUTest : public testing::WithParamInterface, + virtual public SubgraphBaseTest, + public CPUTestsBase { public: static std::string getTestCaseName(const testing::TestParamInfo& obj) { embeddingBagOffsetsSumParams params; @@ -77,22 +69,22 @@ class EmbeddingBagOffsetsSumLayerCPUTest : selectedType = makeSelectedTypeStr("ref", inType); targetDevice = ov::test::utils::DEVICE_CPU; - init_input_shapes({ inputShapes }); - - auto emb_table_node = std::make_shared(inType, inputShapes.first); - ngraph::ParameterVector params = {emb_table_node}; - - auto embBag = std::dynamic_pointer_cast(ngraph::builder::makeEmbeddingBagOffsetsSum( - inType, - indPrecision, - emb_table_node, - indices, - offsets, - defaultIndex, - withWeights, - withDefIndex)); - ngraph::ResultVector results{std::make_shared(embBag)}; - function = std::make_shared(results, params, "embeddingBagOffsetsSum"); + init_input_shapes({inputShapes}); + + auto emb_table_node = std::make_shared(inType, inputShapes.first); + ov::ParameterVector params = {emb_table_node}; + + auto embBag = std::dynamic_pointer_cast( + ov::test::utils::make_embedding_bag_offsets_sum(inType, + indPrecision, + emb_table_node, + indices, + offsets, + defaultIndex, + withWeights, + withDefIndex)); + ov::ResultVector results{std::make_shared(embBag)}; + function = std::make_shared(results, params, "embeddingBagOffsetsSum"); } }; @@ -103,65 +95,50 @@ TEST_P(EmbeddingBagOffsetsSumLayerCPUTest, CompareWithRefs) { namespace { -const std::vector netPrecisions = { - ElementType::f32, - ElementType::i32, - ElementType::u8 -}; +const std::vector netPrecisions = {ElementType::f32, ElementType::i32, ElementType::u8}; -const std::vector indPrecisions = { - ElementType::i64, - ElementType::i32 -}; +const std::vector indPrecisions = {ElementType::i64, ElementType::i32}; const std::vector input_shapes = { - // dynamic input shapes - { - // input model dynamic shapes - {ov::Dimension::dynamic(), ov::Dimension::dynamic()}, - // input tensor shapes - {{5, 6}, {10, 35}} - }, - { - // input model dynamic shapes - {ov::Dimension::dynamic(), ov::Dimension::dynamic(), ov::Dimension::dynamic()}, - // input tensor shapes - {{5, 4, 16}, {10, 12, 8}} - }, - { - // input model dynamic shapes with limits - {{5, 10}, {6, 35}, {4, 8}}, - // input tensor shapes - {{5, 6, 4}, {10, 35, 8}, {5, 6, 4}} - }, - // static shapes - {{5, 6}, {{5, 6}}}, - {{10, 35}, {{10, 35}}}, - {{5, 4, 16}, {{5, 4, 16}}}, + // dynamic input shapes + {// input model dynamic shapes + {ov::Dimension::dynamic(), ov::Dimension::dynamic()}, + // input tensor shapes + {{5, 6}, {10, 35}}}, + {// input model dynamic shapes + {ov::Dimension::dynamic(), ov::Dimension::dynamic(), ov::Dimension::dynamic()}, + // input tensor shapes + {{5, 4, 16}, {10, 12, 8}}}, + {// input model dynamic shapes with limits + {{5, 10}, {6, 35}, {4, 8}}, + // input tensor shapes + {{5, 6, 4}, {10, 35, 8}, {5, 6, 4}}}, + // static shapes + {{5, 6}, {{5, 6}}}, + {{10, 35}, {{10, 35}}}, + {{5, 4, 16}, {{5, 4, 16}}}, }; -const std::vector> indices = - {{0, 1, 2, 2, 3}, {4, 4, 3, 1, 0}, {1, 2, 1, 2, 1, 2, 1, 2, 1, 2}}; +const std::vector> indices = {{0, 1, 2, 2, 3}, {4, 4, 3, 1, 0}, {1, 2, 1, 2, 1, 2, 1, 2, 1, 2}}; const std::vector> offsets = {{0, 2}, {0, 0, 2, 2}, {2, 4}}; const std::vector default_index = {0, 4}; const std::vector with_weights = {false, true}; const std::vector with_default_index = {false, true}; -const auto embBagOffsetSumArgSet = ::testing::Combine( - ::testing::ValuesIn(input_shapes), - ::testing::ValuesIn(indices), - ::testing::ValuesIn(offsets), - ::testing::ValuesIn(default_index), - ::testing::ValuesIn(with_weights), - ::testing::ValuesIn(with_default_index) -); - -INSTANTIATE_TEST_SUITE_P(smoke, EmbeddingBagOffsetsSumLayerCPUTest, - ::testing::Combine( - embBagOffsetSumArgSet, - ::testing::ValuesIn(netPrecisions), - ::testing::ValuesIn(indPrecisions), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - EmbeddingBagOffsetsSumLayerCPUTest::getTestCaseName); +const auto embBagOffsetSumArgSet = ::testing::Combine(::testing::ValuesIn(input_shapes), + ::testing::ValuesIn(indices), + ::testing::ValuesIn(offsets), + ::testing::ValuesIn(default_index), + ::testing::ValuesIn(with_weights), + ::testing::ValuesIn(with_default_index)); + +INSTANTIATE_TEST_SUITE_P(smoke, + EmbeddingBagOffsetsSumLayerCPUTest, + ::testing::Combine(embBagOffsetSumArgSet, + ::testing::ValuesIn(netPrecisions), + ::testing::ValuesIn(indPrecisions), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + EmbeddingBagOffsetsSumLayerCPUTest::getTestCaseName); } // namespace -} // namespace CPULayerTestsDefinitions +} // namespace test +} // namespace ov diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/embedding_bag_packed_sum.cpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/embedding_bag_packed_sum.cpp index 17512416b655d1..6a01ce8f52dc97 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/embedding_bag_packed_sum.cpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/embedding_bag_packed_sum.cpp @@ -2,38 +2,30 @@ // SPDX-License-Identifier: Apache-2.0 // -#include -#include -#include +#include "common_test_utils/node_builders/embedding_bag_packed_sum.hpp" -#include -#include "ov_models/builders.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" -using namespace InferenceEngine; using namespace CPUTestUtils; -using namespace ov::test; - -namespace CPULayerTestsDefinitions { - -typedef std::tuple< - InputShape, // input_shapes - std::vector>, // indices - bool // with_weights - > embeddingBagPackedSumParams; - -typedef std::tuple< - embeddingBagPackedSumParams, - ElementType, // embedding table - ElementType, // indices - LayerTestsUtils::TargetDevice> embeddingBagPackedSumLayerTestParamsSet; - -class EmbeddingBagPackedSumLayerCPUTest : - public testing::WithParamInterface, - virtual public SubgraphBaseTest, - public CPUTestsBase { +namespace ov { +namespace test { + +typedef std::tuple>, // indices + bool // with_weights + > + embeddingBagPackedSumParams; + +typedef std::tuple + embeddingBagPackedSumLayerTestParamsSet; + +class EmbeddingBagPackedSumLayerCPUTest : public testing::WithParamInterface, + virtual public SubgraphBaseTest, + public CPUTestsBase { public: static std::string getTestCaseName(const testing::TestParamInfo& obj) { embeddingBagPackedSumParams params; @@ -70,19 +62,15 @@ class EmbeddingBagPackedSumLayerCPUTest : selectedType = makeSelectedTypeStr("ref", inType); targetDevice = ov::test::utils::DEVICE_CPU; - init_input_shapes({ inputShapes }); + init_input_shapes({inputShapes}); - auto emb_table_node = std::make_shared(inType, inputShapes.first); - ngraph::ParameterVector params = {emb_table_node}; + auto emb_table_node = std::make_shared(inType, inputShapes.first); + ov::ParameterVector params = {emb_table_node}; - auto embBag = std::dynamic_pointer_cast(ngraph::builder::makeEmbeddingBagPackedSum( - inType, - indPrecision, - emb_table_node, - indices, - withWeights)); - ngraph::ResultVector results{std::make_shared(embBag)}; - function = std::make_shared(results, params, "embeddingBagPackedSum"); + auto embBag = std::dynamic_pointer_cast( + ov::test::utils::make_embedding_bag_packed_sum(inType, indPrecision, emb_table_node, indices, withWeights)); + ov::ResultVector results{std::make_shared(embBag)}; + function = std::make_shared(results, params, "embeddingBagPackedSum"); } }; @@ -93,59 +81,46 @@ TEST_P(EmbeddingBagPackedSumLayerCPUTest, CompareWithRefs) { namespace { -const std::vector netPrecisions = { - ElementType::f32, - ElementType::i32, - ElementType::u8 -}; +const std::vector netPrecisions = {ElementType::f32, ElementType::i32, ElementType::u8}; -const std::vector indPrecisions = { - ElementType::i64, - ElementType::i32 -}; +const std::vector indPrecisions = {ElementType::i64, ElementType::i32}; const std::vector input_shapes = { - // dynamic input shapes - { - // input model dynamic shapes - {ov::Dimension::dynamic(), ov::Dimension::dynamic()}, - // input tensor shapes - {{{5, 6}}, {10, 35}} - }, - { - // input model dynamic shapes - {ov::Dimension::dynamic(), ov::Dimension::dynamic(), ov::Dimension::dynamic()}, - // input tensor shapes - {{5, 4, 16}, {10, 12, 8}} - }, - { - // input model dynamic shapes with limits - {{5, 10}, {6, 35}, {4, 8}}, - // input tensor shapes - {{5, 6, 4}, {10, 35, 8}, {5, 6, 4}} - }, - // static shapes - {{5, 6}, {{5, 6}}}, - {{10, 35}, {{10, 35}}}, - {{5, 4, 16}, {{5, 4, 16}}}, + // dynamic input shapes + {// input model dynamic shapes + {ov::Dimension::dynamic(), ov::Dimension::dynamic()}, + // input tensor shapes + {{{5, 6}}, {10, 35}}}, + {// input model dynamic shapes + {ov::Dimension::dynamic(), ov::Dimension::dynamic(), ov::Dimension::dynamic()}, + // input tensor shapes + {{5, 4, 16}, {10, 12, 8}}}, + {// input model dynamic shapes with limits + {{5, 10}, {6, 35}, {4, 8}}, + // input tensor shapes + {{5, 6, 4}, {10, 35, 8}, {5, 6, 4}}}, + // static shapes + {{5, 6}, {{5, 6}}}, + {{10, 35}, {{10, 35}}}, + {{5, 4, 16}, {{5, 4, 16}}}, }; -const std::vector>> indices = - {{{0, 1}, {2, 2}, {3, 4}}, {{4, 4, 3}, {1, 0, 2}}, {{1, 2, 1, 2}, {1, 2, 1, 2}}}; +const std::vector>> indices = {{{0, 1}, {2, 2}, {3, 4}}, + {{4, 4, 3}, {1, 0, 2}}, + {{1, 2, 1, 2}, {1, 2, 1, 2}}}; const std::vector with_weights = {false, true}; -const auto embBagPackedSumArgSet = ::testing::Combine( - ::testing::ValuesIn(input_shapes), - ::testing::ValuesIn(indices), - ::testing::ValuesIn(with_weights) -); - -INSTANTIATE_TEST_SUITE_P(smoke, EmbeddingBagPackedSumLayerCPUTest, - ::testing::Combine( - embBagPackedSumArgSet, - ::testing::ValuesIn(netPrecisions), - ::testing::ValuesIn(indPrecisions), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - EmbeddingBagPackedSumLayerCPUTest::getTestCaseName); +const auto embBagPackedSumArgSet = ::testing::Combine(::testing::ValuesIn(input_shapes), + ::testing::ValuesIn(indices), + ::testing::ValuesIn(with_weights)); + +INSTANTIATE_TEST_SUITE_P(smoke, + EmbeddingBagPackedSumLayerCPUTest, + ::testing::Combine(embBagPackedSumArgSet, + ::testing::ValuesIn(netPrecisions), + ::testing::ValuesIn(indPrecisions), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + EmbeddingBagPackedSumLayerCPUTest::getTestCaseName); } // namespace -} // namespace CPULayerTestsDefinitions +} // namespace test +} // namespace ov diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/embedding_segments_sum.cpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/embedding_segments_sum.cpp index 36bd193bbd08da..5b3cf8bcb917b3 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/embedding_segments_sum.cpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/embedding_segments_sum.cpp @@ -2,42 +2,34 @@ // SPDX-License-Identifier: Apache-2.0 // -#include -#include -#include +#include "common_test_utils/node_builders/embedding_segments_sum.hpp" -#include -#include "ov_models/builders.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" -using namespace InferenceEngine; using namespace CPUTestUtils; -using namespace ov::test; - -namespace CPULayerTestsDefinitions { - -typedef std::tuple< - InputShape, // input_shapes - 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, - ElementType, // embedding table - ElementType, // indices - LayerTestsUtils::TargetDevice> embeddingSegmentsSumLayerTestParamsSet; - -class EmbeddingSegmentsSumLayerCPUTest : - public testing::WithParamInterface, - virtual public SubgraphBaseTest, - public CPUTestsBase { +namespace ov { +namespace test { + +typedef std::tuple, // indices + std::vector, // segment_ids + size_t, // num_segments + size_t, // default_index + bool, // with_weights + bool // with_def_index + > + embeddingSegmentsSumParams; + +typedef std::tuple + embeddingSegmentsSumLayerTestParamsSet; + +class EmbeddingSegmentsSumLayerCPUTest : public testing::WithParamInterface, + virtual public SubgraphBaseTest, + public CPUTestsBase { public: static std::string getTestCaseName(const testing::TestParamInfo& obj) { embeddingSegmentsSumParams params; @@ -53,7 +45,7 @@ class EmbeddingSegmentsSumLayerCPUTest : std::ostringstream result; result << "IS=" << inputShapes << "_"; - result << "I" << ov::test::utils::vec2str(indices) << "_"; + result << "I" << ov::test::utils::vec2str(indices) << "_"; result << "SI" << ov::test::utils::vec2str(segmentIds) << "_"; result << "NS" << numSegments << "_"; result << "DI" << defaultIndex << "_"; @@ -80,23 +72,23 @@ class EmbeddingSegmentsSumLayerCPUTest : selectedType = makeSelectedTypeStr("ref", inType); targetDevice = ov::test::utils::DEVICE_CPU; - init_input_shapes({ inputShapes }); - - auto emb_table_node = std::make_shared(inType, inputShapes.first); - ngraph::ParameterVector params = {emb_table_node}; - - auto embBag = std::dynamic_pointer_cast(ngraph::builder::makeEmbeddingSegmentsSum( - inType, - indPrecision, - emb_table_node, - indices, - segmentIds, - numSegments, - defaultIndex, - withWeights, - withDefIndex)); - ngraph::ResultVector results{std::make_shared(embBag)}; - function = std::make_shared(results, params, "embeddingSegmentsSum"); + init_input_shapes({inputShapes}); + + auto emb_table_node = std::make_shared(inType, inputShapes.first); + ov::ParameterVector params = {emb_table_node}; + + auto embBag = std::dynamic_pointer_cast( + ov::test::utils::make_embedding_segments_sum(inType, + indPrecision, + emb_table_node, + indices, + segmentIds, + numSegments, + defaultIndex, + withWeights, + withDefIndex)); + ov::ResultVector results{std::make_shared(embBag)}; + function = std::make_shared(results, params, "embeddingSegmentsSum"); } }; @@ -106,67 +98,52 @@ TEST_P(EmbeddingSegmentsSumLayerCPUTest, CompareWithRefs) { } namespace { -const std::vector netPrecisions = { - ElementType::f32, - ElementType::i32, - ElementType::u8 -}; +const std::vector netPrecisions = {ElementType::f32, ElementType::i32, ElementType::u8}; -const std::vector indPrecisions = { - ElementType::i64, - ElementType::i32 -}; +const std::vector indPrecisions = {ElementType::i64, ElementType::i32}; const std::vector input_shapes = { // dynamic input shapes - { - // input model dynamic shapes - {ov::Dimension::dynamic(), ov::Dimension::dynamic()}, - // input tensor shapes - {{5, 6}, {10, 35}} - }, - { - // input model dynamic shapes - {ov::Dimension::dynamic(), ov::Dimension::dynamic(), ov::Dimension::dynamic()}, - // input tensor shapes - {{5, 4, 16}, {10, 12, 8}} - }, - { - // input model dynamic shapes with limits - {{5, 10}, {6, 35}, {4, 8}}, - // input tensor shapes - {{5, 6, 4}, {10, 35, 8}, {5, 6, 4}} - }, + {// input model dynamic shapes + {ov::Dimension::dynamic(), ov::Dimension::dynamic()}, + // input tensor shapes + {{5, 6}, {10, 35}}}, + {// input model dynamic shapes + {ov::Dimension::dynamic(), ov::Dimension::dynamic(), ov::Dimension::dynamic()}, + // input tensor shapes + {{5, 4, 16}, {10, 12, 8}}}, + {// input model dynamic shapes with limits + {{5, 10}, {6, 35}, {4, 8}}, + // input tensor shapes + {{5, 6, 4}, {10, 35, 8}, {5, 6, 4}}}, // static shapes {{5, 6}, {{5, 6}}}, {{10, 35}, {{10, 35}}}, {{5, 4, 16}, {{5, 4, 16}}}, }; -const std::vector> indices = - {{0, 1, 2, 2, 3}, {4, 4, 3, 1, 2}}; +const std::vector> indices = {{0, 1, 2, 2, 3}, {4, 4, 3, 1, 2}}; const std::vector> segment_ids = {{0, 1, 2, 3, 4}, {0, 0, 2, 2, 4}}; const std::vector num_segments = {5, 7}; const std::vector default_index = {0, 4}; const std::vector with_weights = {false, true}; const std::vector with_default_index = {false, true}; -const auto embSegmentsSumArgSet = ::testing::Combine( - ::testing::ValuesIn(input_shapes), - ::testing::ValuesIn(indices), - ::testing::ValuesIn(segment_ids), - ::testing::ValuesIn(num_segments), - ::testing::ValuesIn(default_index), - ::testing::ValuesIn(with_weights), - ::testing::ValuesIn(with_default_index) -); - -INSTANTIATE_TEST_SUITE_P(smoke, EmbeddingSegmentsSumLayerCPUTest, - ::testing::Combine( - embSegmentsSumArgSet, - ::testing::ValuesIn(netPrecisions), - ::testing::ValuesIn(indPrecisions), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - EmbeddingSegmentsSumLayerCPUTest::getTestCaseName); +const auto embSegmentsSumArgSet = ::testing::Combine(::testing::ValuesIn(input_shapes), + ::testing::ValuesIn(indices), + ::testing::ValuesIn(segment_ids), + ::testing::ValuesIn(num_segments), + ::testing::ValuesIn(default_index), + ::testing::ValuesIn(with_weights), + ::testing::ValuesIn(with_default_index)); + +INSTANTIATE_TEST_SUITE_P(smoke, + EmbeddingSegmentsSumLayerCPUTest, + ::testing::Combine(embSegmentsSumArgSet, + ::testing::ValuesIn(netPrecisions), + ::testing::ValuesIn(indPrecisions), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + EmbeddingSegmentsSumLayerCPUTest::getTestCaseName); } // namespace -} // namespace CPULayerTestsDefinitions +} // namespace test +} // namespace ov diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/extract_image_patches.cpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/extract_image_patches.cpp index fecd504bf6ba31..17df64a4f5d31a 100755 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/extract_image_patches.cpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/extract_image_patches.cpp @@ -4,23 +4,20 @@ #include "shared_test_classes/base/ov_subgraph.hpp" #include "test_utils/cpu_test_utils.hpp" -#include "shared_test_classes/base/layer_test_utils.hpp" -#include "ov_models/builders.hpp" using namespace CPUTestUtils; -using namespace ov::test; - -namespace CPULayerTestsDefinitions { -using extractImagePatchesParams = typename std::tuple< - InputShape, // input shape - ElementType, // Network precision - ov::Shape, // kernel size - ov::Strides, // strides - ov::Shape, // rates - ov::op::PadType>; // pad type +namespace ov { +namespace test { +using extractImagePatchesParams = typename std::tuple; // pad type class ExtractImagePatchesLayerCPUTest : public testing::WithParamInterface, - virtual public SubgraphBaseTest, public CPUTestsBase { + virtual public SubgraphBaseTest, + public CPUTestsBase { public: static std::string getTestCaseName(testing::TestParamInfo obj) { InputShape inputShapes; @@ -32,16 +29,19 @@ class ExtractImagePatchesLayerCPUTest : public testing::WithParamInterface inputShapes = { InputShape{{}, {{2, 3, 13, 37}}}, - InputShape{ - // dynamic - {-1, -1, -1, -1}, - // static - {{2, 3, 13, 37}, {6, 4, 14, 14}, {8, 12, 15, 16}, {2, 3, 13, 37}} - }, - InputShape{ - // dynamic - {{5, 15}, {6, 17}, {10, 15}, {13, 16}}, - // static - {{5, 17, 10, 15}, {15, 10, 12, 13}, {10, 10, 15, 16}, {5, 17, 10, 15}} - }, + InputShape{// dynamic + {-1, -1, -1, -1}, + // static + {{2, 3, 13, 37}, {6, 4, 14, 14}, {8, 12, 15, 16}, {2, 3, 13, 37}}}, + InputShape{// dynamic + {{5, 15}, {6, 17}, {10, 15}, {13, 16}}, + // static + {{5, 17, 10, 15}, {15, 10, 12, 13}, {10, 10, 15, 16}, {5, 17, 10, 15}}}, }; -const std::vector inputPrecisions = { - ElementType::i8, - ElementType::bf16, - ElementType::f32 -}; +const std::vector inputPrecisions = {ElementType::i8, ElementType::bf16, ElementType::f32}; -const std::vector kSizes = { - {1, 5}, - {3, 4}, - {3, 1} -}; +const std::vector kSizes = {{1, 5}, {3, 4}, {3, 1}}; -const std::vector strides = { - {1, 2}, - {2, 2}, - {2, 1} -}; +const std::vector strides = {{1, 2}, {2, 2}, {2, 1}}; -const std::vector rates = { - {1, 3}, - {3, 3}, - {3, 1} -}; +const std::vector rates = {{1, 3}, {3, 3}, {3, 1}}; -const std::vector autoPads = { - ov::op::PadType::VALID, - ov::op::PadType::SAME_UPPER, - ov::op::PadType::SAME_LOWER -}; +const std::vector autoPads = {ov::op::PadType::VALID, + ov::op::PadType::SAME_UPPER, + ov::op::PadType::SAME_LOWER}; -const auto params = ::testing::Combine( - ::testing::ValuesIn(inputShapes), - ::testing::ValuesIn(inputPrecisions), - ::testing::ValuesIn(kSizes), - ::testing::ValuesIn(strides), - ::testing::ValuesIn(rates), - ::testing::ValuesIn(autoPads)); +const auto params = ::testing::Combine(::testing::ValuesIn(inputShapes), + ::testing::ValuesIn(inputPrecisions), + ::testing::ValuesIn(kSizes), + ::testing::ValuesIn(strides), + ::testing::ValuesIn(rates), + ::testing::ValuesIn(autoPads)); -INSTANTIATE_TEST_SUITE_P(smoke_ExtractImagePatches_CPU, ExtractImagePatchesLayerCPUTest, params, ExtractImagePatchesLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_ExtractImagePatches_CPU, + ExtractImagePatchesLayerCPUTest, + params, + ExtractImagePatchesLayerCPUTest::getTestCaseName); -} // namespace -} // namespace CPULayerTestsDefinitions +} // namespace +} // namespace test +} // namespace ov diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/eye.cpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/eye.cpp index 22b8cb7a0de857..5dc2219e382ed5 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/eye.cpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/eye.cpp @@ -2,40 +2,34 @@ // SPDX-License-Identifier: Apache-2.0 // -#include -#include -#include "test_utils/cpu_test_utils.hpp" -#include "ov_models/builders.hpp" +#include "common_test_utils/ov_tensor_utils.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" +#include "test_utils/cpu_test_utils.hpp" -using namespace InferenceEngine; using namespace CPUTestUtils; -using namespace ov::test; - -namespace CPULayerTestsDefinitions { +namespace ov { +namespace test { namespace { - std::vector inputShape; - std::vector outBatchShape; - int rowNum, colNum; - int shift; +std::vector inputShape; +std::vector outBatchShape; +int rowNum, colNum; +int shift; } // namespace -using EyeLayerTestParams = std::tuple< - std::vector, // eye shape - std::vector, // output batch shape - std::vector, // eye params (rows, cols, diag_shift) - ElementType, // Net precision - TargetDevice>; // Device name +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 -using EyeLayerCPUTestParamsSet = std::tuple< - CPULayerTestsDefinitions::EyeLayerTestParams, - CPUSpecificParams>; +using EyeLayerCPUTestParamsSet = std::tuple; class EyeLayerCPUTest : public testing::WithParamInterface, - virtual public SubgraphBaseTest, public CPUTestsBase { + virtual public SubgraphBaseTest, + public CPUTestsBase { public: static std::string getTestCaseName(testing::TestParamInfo obj) { - CPULayerTestsDefinitions::EyeLayerTestParams basicParamsSet; + EyeLayerTestParams basicParamsSet; CPUSpecificParams cpuParams; std::tie(basicParamsSet, cpuParams) = obj.param; std::string td; @@ -63,9 +57,10 @@ class EyeLayerCPUTest : public testing::WithParamInterfaceGetParam(); std::tie(inFmts, outFmts, priority, selectedType) = cpuParams; @@ -79,11 +74,11 @@ class EyeLayerCPUTest : public testing::WithParamInterface createFunction() { + std::shared_ptr createFunction() { ov::ParameterVector inputParams; for (auto&& shape : inputDynamicShapes) { inputParams.push_back(std::make_shared(ov::element::i32, shape)); @@ -97,13 +92,14 @@ class EyeLayerCPUTest : public testing::WithParamInterfaceset_friendly_name("batchShape"); - auto eyelikeBatchShape = std::make_shared(rowsPar, colsPar, diagPar, batchShapePar, ngraph::element::i32); + auto eyelikeBatchShape = + std::make_shared(rowsPar, colsPar, diagPar, batchShapePar, ov::element::i32); eyelikeBatchShape->get_rt_info() = getCPUInfo(); - return makeNgraphFunction(ngraph::element::i32, inputParams, eyelikeBatchShape, "Eye"); + return makeNgraphFunction(ov::element::i32, inputParams, eyelikeBatchShape, "Eye"); } else { - auto eyelikePure = std::make_shared(rowsPar, colsPar, diagPar, ngraph::element::i32); + auto eyelikePure = std::make_shared(rowsPar, colsPar, diagPar, ov::element::i32); eyelikePure->get_rt_info() = getCPUInfo(); - return makeNgraphFunction(ngraph::element::i32, inputParams, eyelikePure, "Eye"); + return makeNgraphFunction(ov::element::i32, inputParams, eyelikePure, "Eye"); } } @@ -115,16 +111,19 @@ class EyeLayerCPUTest : public testing::WithParamInterface(); - // Spec: batch_shape - 1D tensor with non-negative values of type T_NUM defines leading batch dimensions of output shape + int* batchShapePtr = tensor.data(); + // Spec: batch_shape - 1D tensor with non-negative values of type T_NUM defines leading batch dimensions + // of output shape EXPECT_EQ(targetInputStaticShapes[i].size(), 1); EXPECT_EQ(targetInputStaticShapes[i][0], outBatchShape.size()); for (size_t j = 0; j < targetInputStaticShapes[i][0]; j++) { batchShapePtr[j] = outBatchShape[j]; } } else { - tensor = ov::test::utils::create_and_fill_tensor(funcInput.get_element_type(), targetInputStaticShapes[i], 1, - (i == 0 ? rowNum : (i == 1 ? colNum : shift))); + tensor = ov::test::utils::create_and_fill_tensor(funcInput.get_element_type(), + targetInputStaticShapes[i], + 1, + (i == 0 ? rowNum : (i == 1 ? colNum : shift))); } inputs.insert({funcInput.get_node_shared_ptr(), tensor}); } @@ -138,10 +137,11 @@ TEST_P(EyeLayerCPUTest, CompareWithRefs) { namespace { -const std::vector netPrecisions = { - ElementType::f32, ElementType::bf16, ElementType::i32, - ElementType::i8, ElementType::u8 -}; +const std::vector netPrecisions = {ElementType::f32, + ElementType::bf16, + ElementType::i32, + ElementType::i8, + ElementType::u8}; const std::vector> eyePars = { // rows, cols, diag_shift {3, 3, 0}, @@ -153,70 +153,64 @@ const std::vector> eyePars = { // rows, cols, diag_shift {4, 3, -1}, {3, 4, 10}, {4, 4, -2}, - {0, 0, 0} -}; + {0, 0, 0}}; // dummy parameter to prevent empty set of test cases const std::vector> emptyBatchShape = {{0}}; -const std::vector> batchShapes1D = { - {3}, {2}, {1}, {0} -}; -const std::vector> batchShapes2D = { - {3, 2}, {2, 1}, {0, 0} -}; +const std::vector> batchShapes1D = {{3}, {2}, {1}, {0}}; +const std::vector> batchShapes2D = {{3, 2}, {2, 1}, {0, 0}}; // Ticket: 85127 // const std::vector> batchShapes3D = { // {3, 2, 1}, {1, 1, 1} // }; -INSTANTIATE_TEST_SUITE_P(smoke_Eye2D_PureScalar_Test, EyeLayerCPUTest, - ::testing::Combine( - ::testing::Combine( - ::testing::ValuesIn(static_shapes_to_test_representation( - std::vector> {{{}, {}, {}}})), - ::testing::ValuesIn(emptyBatchShape), - ::testing::ValuesIn(eyePars), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - ::testing::Values(CPUSpecificParams{{}, {}, {}, {}})), +INSTANTIATE_TEST_SUITE_P(smoke_Eye2D_PureScalar_Test, + EyeLayerCPUTest, + ::testing::Combine(::testing::Combine(::testing::ValuesIn(static_shapes_to_test_representation( + std::vector>{{{}, {}, {}}})), + ::testing::ValuesIn(emptyBatchShape), + ::testing::ValuesIn(eyePars), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::Values(CPUSpecificParams{{}, {}, {}, {}})), EyeLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_SUITE_P(smoke_Eye2D_WithNonScalar_Test, EyeLayerCPUTest, - ::testing::Combine( - ::testing::Combine( - ::testing::ValuesIn(static_shapes_to_test_representation( - std::vector> {{{1}, {1}, {1}}})), - ::testing::ValuesIn(emptyBatchShape), - ::testing::ValuesIn(eyePars), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - ::testing::Values(CPUSpecificParams{{}, {}, {}, {}})), - EyeLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P( + smoke_Eye2D_WithNonScalar_Test, + EyeLayerCPUTest, + ::testing::Combine(::testing::Combine(::testing::ValuesIn(static_shapes_to_test_representation( + std::vector>{{{1}, {1}, {1}}})), + ::testing::ValuesIn(emptyBatchShape), + ::testing::ValuesIn(eyePars), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::Values(CPUSpecificParams{{}, {}, {}, {}})), + EyeLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_SUITE_P(smoke_Eye_1DBatch_Test, EyeLayerCPUTest, - ::testing::Combine( - ::testing::Combine( - ::testing::ValuesIn(static_shapes_to_test_representation( - std::vector> {{{}, {}, {}, {1}}})), - ::testing::ValuesIn(batchShapes1D), - ::testing::ValuesIn(eyePars), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - ::testing::Values(CPUSpecificParams{{}, {}, {}, {}})), - EyeLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P( + smoke_Eye_1DBatch_Test, + EyeLayerCPUTest, + ::testing::Combine(::testing::Combine(::testing::ValuesIn(static_shapes_to_test_representation( + std::vector>{{{}, {}, {}, {1}}})), + ::testing::ValuesIn(batchShapes1D), + ::testing::ValuesIn(eyePars), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::Values(CPUSpecificParams{{}, {}, {}, {}})), + EyeLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_SUITE_P(smoke_Eye_2DBatch_Test, EyeLayerCPUTest, - ::testing::Combine( - ::testing::Combine( - ::testing::ValuesIn(static_shapes_to_test_representation( - std::vector> {{{}, {}, {}, {2}}})), - ::testing::ValuesIn(batchShapes2D), - ::testing::ValuesIn(eyePars), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - ::testing::Values(CPUSpecificParams{{}, {}, {}, {}})), - EyeLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P( + smoke_Eye_2DBatch_Test, + EyeLayerCPUTest, + ::testing::Combine(::testing::Combine(::testing::ValuesIn(static_shapes_to_test_representation( + std::vector>{{{}, {}, {}, {2}}})), + ::testing::ValuesIn(batchShapes2D), + ::testing::ValuesIn(eyePars), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::Values(CPUSpecificParams{{}, {}, {}, {}})), + EyeLayerCPUTest::getTestCaseName); // Ticket: 85127 // INSTANTIATE_TEST_SUITE_P(smoke_Eye_3DBatch_Test, EyeLayerCPUTest, @@ -232,20 +226,20 @@ INSTANTIATE_TEST_SUITE_P(smoke_Eye_2DBatch_Test, EyeLayerCPUTest, // EyeLayerCPUTest::getTestCaseName); const std::vector> dynShapes = { - { - {{-1}, {{1}, {1}}}, // input 0 - {{-1}, {{1}, {1}}}, // input 1 - {{-1}, {{1}, {1}}} // input 2 - }, + { + {{-1}, {{1}, {1}}}, // input 0 + {{-1}, {{1}, {1}}}, // input 1 + {{-1}, {{1}, {1}}} // input 2 + }, }; const std::vector> dynShapesWith2DBatches = { - { - {{-1}, {{1}, {1}, {1}}}, // input 0 - {{-1}, {{1}, {1}, {1}}}, // input 1 - {{-1}, {{1}, {1}, {1}}}, // input 2 - {{2}, {{2}, {2}, {2}}} // input 3 - }, + { + {{-1}, {{1}, {1}, {1}}}, // input 0 + {{-1}, {{1}, {1}, {1}}}, // input 1 + {{-1}, {{1}, {1}, {1}}}, // input 2 + {{2}, {{2}, {2}, {2}}} // input 3 + }, }; // Ticket: 85127 @@ -258,26 +252,24 @@ const std::vector> dynShapesWith2DBatches = { // }, // }; -INSTANTIATE_TEST_SUITE_P(smoke_Eye_Dynamic_Test, EyeLayerCPUTest, - ::testing::Combine( - ::testing::Combine( - ::testing::ValuesIn(dynShapes), - ::testing::ValuesIn(emptyBatchShape), - ::testing::ValuesIn(eyePars), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - ::testing::Values(CPUSpecificParams{{}, {}, {}, {}})), +INSTANTIATE_TEST_SUITE_P(smoke_Eye_Dynamic_Test, + EyeLayerCPUTest, + ::testing::Combine(::testing::Combine(::testing::ValuesIn(dynShapes), + ::testing::ValuesIn(emptyBatchShape), + ::testing::ValuesIn(eyePars), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::Values(CPUSpecificParams{{}, {}, {}, {}})), EyeLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_SUITE_P(smoke_Eye_With2DBatchShape_Dynamic_Test, EyeLayerCPUTest, - ::testing::Combine( - ::testing::Combine( - ::testing::ValuesIn(dynShapesWith2DBatches), - ::testing::ValuesIn(batchShapes2D), - ::testing::ValuesIn(eyePars), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - ::testing::Values(CPUSpecificParams{{}, {}, {}, {}})), +INSTANTIATE_TEST_SUITE_P(smoke_Eye_With2DBatchShape_Dynamic_Test, + EyeLayerCPUTest, + ::testing::Combine(::testing::Combine(::testing::ValuesIn(dynShapesWith2DBatches), + ::testing::ValuesIn(batchShapes2D), + ::testing::ValuesIn(eyePars), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::Values(CPUSpecificParams{{}, {}, {}, {}})), EyeLayerCPUTest::getTestCaseName); // Ticket: 85127 @@ -291,5 +283,6 @@ INSTANTIATE_TEST_SUITE_P(smoke_Eye_With2DBatchShape_Dynamic_Test, EyeLayerCPUTes // ::testing::Values(ov::test::utils::DEVICE_CPU)), // ::testing::Values(CPUSpecificParams{{}, {}, {}, {}})), // EyeLayerCPUTest::getTestCaseName); -} // namespace -} // namespace CPULayerTestsDefinitions +} // namespace +} // namespace test +} // namespace ov diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/fake_quantize.cpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/fake_quantize.cpp index a3d96b81acbe56..760f2bcaed1d3c 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/fake_quantize.cpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/fake_quantize.cpp @@ -2,47 +2,45 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "test_utils/cpu_test_utils.hpp" +#include "common_test_utils/ov_tensor_utils.hpp" #include "ov_models/builders.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include +#include "test_utils/cpu_test_utils.hpp" -using namespace InferenceEngine; -using namespace ngraph; using namespace CPUTestUtils; -using namespace ov::test; - -namespace CPULayerTestsDefinitions { -using inputShapes = std::tuple>; // range input shapes +namespace ov { +namespace test { +using inputShapes = std::tuple>; // range input shapes -using fqSpecificParams = std::tuple, // output low - std::vector, // output high - size_t>; // levels +using fqSpecificParams = std::tuple, // output low + std::vector, // output high + size_t>; // levels using fqLayerTestParamsSet = std::tuple, std::vector>, // il and ih values - bool, // should be decomposed + inputShapes, // input shapes + ov::element::Type, // input type + std::pair, std::vector>, // il and ih values + bool, // should be decomposed CPUSpecificParams>; class FakeQuantizeLayerCPUTest : public testing::WithParamInterface, - virtual public SubgraphBaseTest, public CPUTestsBase { + virtual public SubgraphBaseTest, + public CPUTestsBase { public: static std::string getTestCaseName(testing::TestParamInfo obj) { fqSpecificParams fqParams; inputShapes testShapes; - Precision inPrec; + ov::element::Type inPrec; std::pair, std::vector> inputRangesValues; bool shouldBeDecomposed; CPUSpecificParams cpuParams; std::tie(fqParams, testShapes, inPrec, inputRangesValues, shouldBeDecomposed, cpuParams) = obj.param; InputShape shapes; - std::vector ranges; + std::vector ranges; std::tie(shapes, ranges) = testShapes; int64_t inDataLowBounds, inDataHighBounds; @@ -63,7 +61,7 @@ class FakeQuantizeLayerCPUTest : public testing::WithParamInterface, std::vector> inputRangesValues; bool shouldBeDecomposed; CPUSpecificParams cpuParams; @@ -96,7 +92,7 @@ class FakeQuantizeLayerCPUTest : public testing::WithParamInterface ranges; + std::vector ranges; std::tie(shapes, ranges) = testShapes; inputDynamicShapes.push_back(shapes.first); @@ -110,24 +106,23 @@ class FakeQuantizeLayerCPUTest : public testing::WithParamInterface(ngInPrec, shape)); + params.push_back(std::make_shared(inPrec, shape)); - auto il = builder::makeConstant(ngInPrec, ranges[0], rangesBounds[0], rangesBounds[0].empty()); - auto ih = builder::makeConstant(ngInPrec, ranges[1], rangesBounds[1], rangesBounds[1].empty()); - auto ol = builder::makeConstant(ngInPrec, ranges[2], rangesBounds[2], rangesBounds[2].empty()); - auto oh = builder::makeConstant(ngInPrec, ranges[3], rangesBounds[3], rangesBounds[3].empty()); - auto fq = std::make_shared(params[0], il, ih, ol, oh, levels); + auto il = ngraph::builder::makeConstant(inPrec, ranges[0], rangesBounds[0], rangesBounds[0].empty()); + auto ih = ngraph::builder::makeConstant(inPrec, ranges[1], rangesBounds[1], rangesBounds[1].empty()); + auto ol = ngraph::builder::makeConstant(inPrec, ranges[2], rangesBounds[2], rangesBounds[2].empty()); + auto oh = ngraph::builder::makeConstant(inPrec, ranges[3], rangesBounds[3], rangesBounds[3].empty()); + auto fq = std::make_shared(params[0], il, ih, ol, oh, levels); layerName = shouldBeDecomposed ? "" : "FakeQuantize"; if (selectedType.empty()) { - selectedType = getPrimitiveType() + "_" + inPrec.name(); + selectedType = getPrimitiveType() + "_" + inPrec.get_type_name(); } - function = makeNgraphFunction(ngInPrec, params, fq, "FakeQuantizeCPU"); + function = makeNgraphFunction(inPrec, params, fq, "FakeQuantizeCPU"); } void generate_inputs(const std::vector& targetInputStaticShapes) override { @@ -155,16 +150,13 @@ TEST_P(FakeQuantizeLayerCPUTest, CompareWithRefs) { CheckPluginRelatedResults(compiledModel, layerName); } - const std::vector levels = {16, 255, 256}; int64_t dataLowBounds{-10}, dataHighBounds{10}; -const std::vector, std::vector>> input_ranges = { - {{0.0f}, {5.f}}, - {{0.0f}, {}}, - {{-10.0f}, {-5.f}} -}; +const std::vector, std::vector>> input_ranges = {{{0.0f}, {5.f}}, + {{0.0f}, {}}, + {{-10.0f}, {-5.f}}}; const std::vector outputLow{5.0f}, outputHigh{25.0f}; @@ -177,121 +169,109 @@ const auto specificParams = ::testing::Combine(::testing::Values(dataLowBounds), namespace fqImpl { std::vector memForm4D_jit = { - CPUSpecificParams({nchw}, {nchw}, {}, {}), - CPUSpecificParams({nhwc}, {nhwc}, {}, {}), -// CPUSpecificParams({nChw16c}, {nChw16c}, {}, {}) comment out due to post ops optimizations in lpt plugin.cpp + CPUSpecificParams({nchw}, {nchw}, {}, {}), + CPUSpecificParams({nhwc}, {nhwc}, {}, {}), + // CPUSpecificParams({nChw16c}, {nChw16c}, {}, {}) comment out due to post ops optimizations in lpt + // plugin.cpp }; std::vector rangesShapes4D_jit = { - inputShapes{ - InputShape{{{4, 5, 6, 7}}, {{4, 5, 6, 7}}}, - {{1, 5, 1, 1}, {1, 5, 1, 1}, {1, 5, 1, 1}, {1, 5, 1, 1}} - }, - inputShapes{ - InputShape{{{4, 5, 6, 7}}, {{4, 5, 6, 7}}}, - {{1, 1, 1, 1}, {1, 1, 1, 1}, {1, 1, 1, 1}, {1, 1, 1, 1}} - }, - inputShapes{ - InputShape{{-1, -1, -1, -1}, {{4, 5, 6, 7}, {1, 12, 1, 1}, {4, 1, 8, 2}, {1, 16, 6, 1}, {4, 5, 6, 7}}}, - {{1, 1, 1, 1}, {1, 1, 1, 1}, {1, 1, 1, 1}, {1, 1, 1, 1}} - }, + inputShapes{InputShape{{{4, 5, 6, 7}}, {{4, 5, 6, 7}}}, {{1, 5, 1, 1}, {1, 5, 1, 1}, {1, 5, 1, 1}, {1, 5, 1, 1}}}, + inputShapes{InputShape{{{4, 5, 6, 7}}, {{4, 5, 6, 7}}}, {{1, 1, 1, 1}, {1, 1, 1, 1}, {1, 1, 1, 1}, {1, 1, 1, 1}}}, + inputShapes{InputShape{{-1, -1, -1, -1}, {{4, 5, 6, 7}, {1, 12, 1, 1}, {4, 1, 8, 2}, {1, 16, 6, 1}, {4, 5, 6, 7}}}, + {{1, 1, 1, 1}, {1, 1, 1, 1}, {1, 1, 1, 1}, {1, 1, 1, 1}}}, inputShapes{ InputShape{{-1, -1, -1, -1}, {{4, 16, 6, 7}, {1, 16, 1, 1}, {7, 16, 1, 2}, {1, 16, 6, 1}, {4, 16, 6, 7}}}, - {{1, 16, 1, 1}, {1, 16, 1, 1}, {1, 16, 1, 1}, {1, 16, 1, 1}} - }, + {{1, 16, 1, 1}, {1, 16, 1, 1}, {1, 16, 1, 1}, {1, 16, 1, 1}}}, }; #if defined(OPENVINO_ARCH_X86_64) const auto testParams4D_jit = ::testing::Combine(specificParams, ::testing::ValuesIn(rangesShapes4D_jit), - ::testing::Values(Precision::FP32), + ::testing::Values(ov::element::f32), ::testing::ValuesIn(input_ranges), ::testing::Values(false), ::testing::ValuesIn(filterCPUSpecificParams(memForm4D_jit))); -INSTANTIATE_TEST_SUITE_P(smoke_FakeQuantizeLayerCPUTest_4D_jit, FakeQuantizeLayerCPUTest, testParams4D_jit, FakeQuantizeLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_FakeQuantizeLayerCPUTest_4D_jit, + FakeQuantizeLayerCPUTest, + testParams4D_jit, + FakeQuantizeLayerCPUTest::getTestCaseName); #endif -std::vector memForm4D_ref = { - CPUSpecificParams({nchw}, {nchw}, {"ref_FP32"}, {"ref_FP32"}) -}; +std::vector memForm4D_ref = {CPUSpecificParams({nchw}, {nchw}, {"ref_FP32"}, {"ref_FP32"})}; std::vector rangesShapes4D_ref = { - inputShapes{ - InputShape{{{4, 5, 6, 7}}, {{4, 5, 6, 7}}}, - {{4, 1, 1, 1}, {4, 1, 1, 1}, {4, 1, 1, 1}, {4, 1, 1, 1}} - }, + inputShapes{InputShape{{{4, 5, 6, 7}}, {{4, 5, 6, 7}}}, {{4, 1, 1, 1}, {4, 1, 1, 1}, {4, 1, 1, 1}, {4, 1, 1, 1}}}, inputShapes{ InputShape{{-1, -1, -1, -1}, {{4, 16, 6, 7}, {4, 1, 1, 1}, {4, 16, 1, 2}, {4, 16, 6, 1}, {4, 16, 6, 7}}}, - {{4, 1, 1, 1}, {4, 1, 1, 1}, {4, 1, 1, 1}, {4, 1, 1, 1}} - }, + {{4, 1, 1, 1}, {4, 1, 1, 1}, {4, 1, 1, 1}, {4, 1, 1, 1}}}, }; const auto testParams4D_ref = ::testing::Combine(specificParams, ::testing::ValuesIn(rangesShapes4D_ref), - ::testing::Values(Precision::FP32), + ::testing::Values(ov::element::f32), ::testing::ValuesIn(input_ranges), ::testing::Values(false), ::testing::ValuesIn(memForm4D_ref)); -INSTANTIATE_TEST_SUITE_P(smoke_FakeQuantizeLayerCPUTest_4D_ref, FakeQuantizeLayerCPUTest, testParams4D_ref, FakeQuantizeLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_FakeQuantizeLayerCPUTest_4D_ref, + FakeQuantizeLayerCPUTest, + testParams4D_ref, + FakeQuantizeLayerCPUTest::getTestCaseName); #if defined(OPENVINO_ARCH_X86_64) std::vector memForm5D_jit = { - CPUSpecificParams({ncdhw}, {ncdhw}, {}, {}), - CPUSpecificParams({ndhwc}, {ndhwc}, {}, {}), -// CPUSpecificParams({nCdhw16c}, {nCdhw16c}, {}, {}) comment out due to post ops optimizations in lpt plugin.cpp + CPUSpecificParams({ncdhw}, {ncdhw}, {}, {}), + CPUSpecificParams({ndhwc}, {ndhwc}, {}, {}), + // CPUSpecificParams({nCdhw16c}, {nCdhw16c}, {}, {}) comment out due to post ops optimizations in lpt + // plugin.cpp }; std::vector rangesShapes5D_jit = { - inputShapes{ - InputShape{{3, 4, 5, 6, 7}, {{3, 4, 5, 6, 7}}}, - {{1, 4, 1, 1, 1}, {1, 4, 1, 1, 1}, {1, 4, 1, 1, 1}, {1, 4, 1, 1, 1}} - }, - inputShapes{ - InputShape{{3, 4, 5, 6, 7}, {{3, 4, 5, 6, 7}}}, - {{1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}} - }, - inputShapes{ - InputShape{{-1, -1, -1, -1, -1}, {{3, 4, 5, 6, 7}, {1, 12, 1, 1, 1}, {4, 1, 8, 2, 7}, {3, 4, 5, 6, 7}, {1, 16, 6, 5, 1}}}, - {{1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}} - }, - inputShapes{ - InputShape{{-1, -1, -1, -1, -1}, {{4, 16, 6, 7, 8}, {1, 16, 1, 1, 1}, {7, 16, 1, 2, 5}, {4, 16, 6, 7, 8}, {1, 16, 6, 1, 7}}}, - {{1, 16, 1, 1, 1}, {1, 16, 1, 1, 1}, {1, 16, 1, 1, 1}, {1, 16, 1, 1, 1}} - }, + inputShapes{InputShape{{3, 4, 5, 6, 7}, {{3, 4, 5, 6, 7}}}, + {{1, 4, 1, 1, 1}, {1, 4, 1, 1, 1}, {1, 4, 1, 1, 1}, {1, 4, 1, 1, 1}}}, + inputShapes{InputShape{{3, 4, 5, 6, 7}, {{3, 4, 5, 6, 7}}}, + {{1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}}}, + inputShapes{InputShape{{-1, -1, -1, -1, -1}, + {{3, 4, 5, 6, 7}, {1, 12, 1, 1, 1}, {4, 1, 8, 2, 7}, {3, 4, 5, 6, 7}, {1, 16, 6, 5, 1}}}, + {{1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}}}, + inputShapes{InputShape{{-1, -1, -1, -1, -1}, + {{4, 16, 6, 7, 8}, {1, 16, 1, 1, 1}, {7, 16, 1, 2, 5}, {4, 16, 6, 7, 8}, {1, 16, 6, 1, 7}}}, + {{1, 16, 1, 1, 1}, {1, 16, 1, 1, 1}, {1, 16, 1, 1, 1}, {1, 16, 1, 1, 1}}}, }; const auto testParams5D_jit = ::testing::Combine(specificParams, ::testing::ValuesIn(rangesShapes5D_jit), - ::testing::Values(Precision::FP32), + ::testing::Values(ov::element::f32), ::testing::ValuesIn(input_ranges), ::testing::Values(false), ::testing::ValuesIn(filterCPUSpecificParams(memForm5D_jit))); -INSTANTIATE_TEST_SUITE_P(smoke_FakeQuantizeLayerCPUTest_5D_jit, FakeQuantizeLayerCPUTest, testParams5D_jit, FakeQuantizeLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_FakeQuantizeLayerCPUTest_5D_jit, + FakeQuantizeLayerCPUTest, + testParams5D_jit, + FakeQuantizeLayerCPUTest::getTestCaseName); #endif -std::vector memForm5D_ref = { - CPUSpecificParams({ncdhw}, {ncdhw}, {"ref_FP32"}, {"ref_FP32"}) -}; +std::vector memForm5D_ref = {CPUSpecificParams({ncdhw}, {ncdhw}, {"ref_FP32"}, {"ref_FP32"})}; std::vector rangesShapes5D_ref = { - inputShapes{ - InputShape{{3, 4, 5, 6, 7}, {{3, 4, 5, 6, 7}}}, - {{3, 1, 1, 1, 1}, {3, 1, 1, 1, 1}, {3, 1, 1, 1, 1}, {3, 1, 1, 1, 1}} - }, - inputShapes{ - InputShape{{-1, -1, -1, -1, -1}, {{3, 16, 6, 7, 8}, {3, 16, 1, 1, 1}, {3, 16, 1, 2, 5}, {3, 16, 6, 1, 7}, {3, 16, 6, 7, 8}}}, - {{3, 1, 1, 1, 1}, {3, 1, 1, 1, 1}, {3, 1, 1, 1, 1}, {3, 1, 1, 1, 1}} - }, + inputShapes{InputShape{{3, 4, 5, 6, 7}, {{3, 4, 5, 6, 7}}}, + {{3, 1, 1, 1, 1}, {3, 1, 1, 1, 1}, {3, 1, 1, 1, 1}, {3, 1, 1, 1, 1}}}, + inputShapes{InputShape{{-1, -1, -1, -1, -1}, + {{3, 16, 6, 7, 8}, {3, 16, 1, 1, 1}, {3, 16, 1, 2, 5}, {3, 16, 6, 1, 7}, {3, 16, 6, 7, 8}}}, + {{3, 1, 1, 1, 1}, {3, 1, 1, 1, 1}, {3, 1, 1, 1, 1}, {3, 1, 1, 1, 1}}}, }; const auto testParams5D_ref = ::testing::Combine(specificParams, ::testing::ValuesIn(rangesShapes5D_ref), - ::testing::Values(Precision::FP32), + ::testing::Values(ov::element::f32), ::testing::ValuesIn(input_ranges), ::testing::Values(false), ::testing::ValuesIn(memForm5D_ref)); -INSTANTIATE_TEST_SUITE_P(smoke_FakeQuantizeLayerCPUTest_5D_ref, FakeQuantizeLayerCPUTest, testParams5D_ref, FakeQuantizeLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_FakeQuantizeLayerCPUTest_5D_ref, + FakeQuantizeLayerCPUTest, + testParams5D_ref, + FakeQuantizeLayerCPUTest::getTestCaseName); const auto specificParamsBin = ::testing::Combine(::testing::Values(dataLowBounds), ::testing::Values(dataHighBounds), @@ -299,107 +279,70 @@ const auto specificParamsBin = ::testing::Combine(::testing::Values(dataLowBound ::testing::Values(std::vector{1.0f}), ::testing::Values(2)); -const auto testParamsBin4D = ::testing::Combine(specificParamsBin, - ::testing::ValuesIn(rangesShapes4D_jit), - ::testing::Values(Precision::FP32), - ::testing::Values(std::pair, std::vector>{{3.0f}, {3.f}}), - ::testing::Values(false), - ::testing::Values(CPUSpecificParams())); +const auto testParamsBin4D = + ::testing::Combine(specificParamsBin, + ::testing::ValuesIn(rangesShapes4D_jit), + ::testing::Values(ov::element::f32), + ::testing::Values(std::pair, std::vector>{{3.0f}, {3.f}}), + ::testing::Values(false), + ::testing::Values(CPUSpecificParams())); -INSTANTIATE_TEST_SUITE_P(smoke_FakeQuantizeLayerCPUTest_4D_bin, FakeQuantizeLayerCPUTest, testParamsBin4D, FakeQuantizeLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_FakeQuantizeLayerCPUTest_4D_bin, + FakeQuantizeLayerCPUTest, + testParamsBin4D, + FakeQuantizeLayerCPUTest::getTestCaseName); -} // namespace fqImpl +} // namespace fqImpl namespace fqDecompos { std::vector decomposeShapes = { - inputShapes{ - InputShape{{4, 5, 6, 7}, {{4, 5, 6, 7}}}, - {{4, 5, 6, 7}, {4, 5, 6, 7}, {4, 5, 6, 7}, {4, 5, 6, 7}} - }, - inputShapes{ - InputShape{{4, 5, 6, 7}, {{4, 5, 6, 7}}}, - {{1, 5, 1, 1}, {1, 1, 6, 7}, {1, 1, 6, 7}, {1, 1, 6, 7}} - }, - inputShapes{ - InputShape{{4, 5, 6, 7}, {{4, 5, 6, 7}}}, - {{1, 1, 6, 7}, {1, 1, 6, 7}, {1, 1, 6, 7}, {1, 1, 6, 7}} - }, - inputShapes{ - InputShape{{4, 5, 6, 7}, {{4, 5, 6, 7}}}, - {{1, 1, 6, 7}, {1, 1, 6, 7}, {1, 1, 1, 1}, {1, 1, 1, 1}} - }, - inputShapes{ - InputShape{{4, 5, 6, 7}, {{4, 5, 6, 7}}}, - {{1, 1, 6, 1}, {1, 5, 6, 7}, {1, 1, 6, 1}, {1, 1, 6, 1}} - }, - inputShapes{ - InputShape{{4, 5, 6, 6}, {{4, 5, 6, 6}}}, - {{1, 1, 6, 6}, {1, 1, 6, 6}, {1, 5, 6, 1}, {1, 5, 1, 6}} - }, - inputShapes{ - InputShape{{4, 5, 6, 6}, {{4, 5, 6, 6}}}, - {{1, 5, 6, 1}, {1, 5, 6, 1}, {1, 5, 6, 1}, {1, 5, 1, 6}} - }, - inputShapes{ - InputShape{{3, 4, 5, 6, 7}, {{3, 4, 5, 6, 7}}}, - {{4, 5, 6, 7}, {4, 5, 6, 7}, {4, 5, 6, 7}, {4, 5, 6, 7}} - }, - inputShapes{ - InputShape{{3, 4, 5, 6, 7}, {{3, 4, 5, 6, 7}}}, - {{1, 5, 1, 1}, {1, 1, 6, 7}, {1, 1, 6, 7}, {1, 1, 6, 7}} - }, - inputShapes{ - InputShape{{3, 4, 5, 6, 7}, {{3, 4, 5, 6, 7}}}, - {{1, 1, 6, 7}, {1, 1, 6, 7}, {1, 1, 6, 7}, {1, 1, 6, 7}} - }, - inputShapes{ - InputShape{{3, 4, 5, 6, 7}, {{3, 4, 5, 6, 7}}}, - {{1, 1, 6, 7}, {1, 1, 6, 7}, {1, 1, 1, 1}, {1, 1, 1, 1}} - }, - inputShapes{ - InputShape{{3, 4, 5, 6, 7}, {{3, 4, 5, 6, 7}}}, - {{1, 1, 6, 1}, {1, 5, 6, 7}, {1, 1, 6, 1}, {1, 1, 6, 1}} - }, - inputShapes{ - InputShape{{2, 3, 4, 5, 6, 7}, {{2, 3, 4, 5, 6, 7}}}, - {{4, 5, 6, 7}, {4, 5, 6, 7}, {4, 5, 6, 7}, {4, 5, 6, 7}} - }, - inputShapes{ - InputShape{{2, 3, 4, 5, 6, 7}, {{2, 3, 4, 5, 6, 7}}}, - {{1, 5, 1, 1}, {1, 1, 6, 7}, {1, 1, 6, 7}, {1, 1, 6, 7}} - }, - inputShapes{ - InputShape{{2, 3, 4, 5, 6, 7}, {{2, 3, 4, 5, 6, 7}}}, - {{1, 1, 6, 7}, {1, 1, 6, 7}, {1, 1, 6, 7}, {1, 1, 6, 7}} - }, - inputShapes{ - InputShape{{2, 3, 4, 5, 6, 7}, {{2, 3, 4, 5, 6, 7}}}, - {{1, 1, 6, 7}, {1, 1, 6, 7}, {1, 1, 1, 1}, {1, 1, 1, 1}} - }, - inputShapes{ - InputShape{{2, 3, 4, 5, 6, 7}, {{2, 3, 4, 5, 6, 7}}}, - {{1, 1, 6, 1}, {1, 5, 6, 7}, {1, 1, 6, 1}, {1, 1, 6, 1}} - }, - inputShapes{ - InputShape{{-1, -1, -1, -1}, {{4, 5, 6, 7}, {1, 5, 6, 7}, {7, 5, 6, 7}, {4, 5, 6, 7}}}, - {{1, 1, 6, 1}, {1, 5, 6, 7}, {1, 1, 6, 1}, {1, 1, 6, 1}} - }, - inputShapes{ - InputShape{{-1, -1, -1, -1, -1}, {{8, 4, 5, 6, 7}, {1, 1, 5, 6, 7}, {1, 1, 1, 6, 7}, {8, 4, 5, 6, 7}}}, - {{1, 1, 6, 7}, {1, 1, 6, 7}, {1, 1, 1, 1}, {1, 1, 1, 1}} - }, + inputShapes{InputShape{{4, 5, 6, 7}, {{4, 5, 6, 7}}}, {{4, 5, 6, 7}, {4, 5, 6, 7}, {4, 5, 6, 7}, {4, 5, 6, 7}}}, + inputShapes{InputShape{{4, 5, 6, 7}, {{4, 5, 6, 7}}}, {{1, 5, 1, 1}, {1, 1, 6, 7}, {1, 1, 6, 7}, {1, 1, 6, 7}}}, + inputShapes{InputShape{{4, 5, 6, 7}, {{4, 5, 6, 7}}}, {{1, 1, 6, 7}, {1, 1, 6, 7}, {1, 1, 6, 7}, {1, 1, 6, 7}}}, + inputShapes{InputShape{{4, 5, 6, 7}, {{4, 5, 6, 7}}}, {{1, 1, 6, 7}, {1, 1, 6, 7}, {1, 1, 1, 1}, {1, 1, 1, 1}}}, + inputShapes{InputShape{{4, 5, 6, 7}, {{4, 5, 6, 7}}}, {{1, 1, 6, 1}, {1, 5, 6, 7}, {1, 1, 6, 1}, {1, 1, 6, 1}}}, + inputShapes{InputShape{{4, 5, 6, 6}, {{4, 5, 6, 6}}}, {{1, 1, 6, 6}, {1, 1, 6, 6}, {1, 5, 6, 1}, {1, 5, 1, 6}}}, + inputShapes{InputShape{{4, 5, 6, 6}, {{4, 5, 6, 6}}}, {{1, 5, 6, 1}, {1, 5, 6, 1}, {1, 5, 6, 1}, {1, 5, 1, 6}}}, + inputShapes{InputShape{{3, 4, 5, 6, 7}, {{3, 4, 5, 6, 7}}}, + {{4, 5, 6, 7}, {4, 5, 6, 7}, {4, 5, 6, 7}, {4, 5, 6, 7}}}, + inputShapes{InputShape{{3, 4, 5, 6, 7}, {{3, 4, 5, 6, 7}}}, + {{1, 5, 1, 1}, {1, 1, 6, 7}, {1, 1, 6, 7}, {1, 1, 6, 7}}}, + inputShapes{InputShape{{3, 4, 5, 6, 7}, {{3, 4, 5, 6, 7}}}, + {{1, 1, 6, 7}, {1, 1, 6, 7}, {1, 1, 6, 7}, {1, 1, 6, 7}}}, + inputShapes{InputShape{{3, 4, 5, 6, 7}, {{3, 4, 5, 6, 7}}}, + {{1, 1, 6, 7}, {1, 1, 6, 7}, {1, 1, 1, 1}, {1, 1, 1, 1}}}, + inputShapes{InputShape{{3, 4, 5, 6, 7}, {{3, 4, 5, 6, 7}}}, + {{1, 1, 6, 1}, {1, 5, 6, 7}, {1, 1, 6, 1}, {1, 1, 6, 1}}}, + inputShapes{InputShape{{2, 3, 4, 5, 6, 7}, {{2, 3, 4, 5, 6, 7}}}, + {{4, 5, 6, 7}, {4, 5, 6, 7}, {4, 5, 6, 7}, {4, 5, 6, 7}}}, + inputShapes{InputShape{{2, 3, 4, 5, 6, 7}, {{2, 3, 4, 5, 6, 7}}}, + {{1, 5, 1, 1}, {1, 1, 6, 7}, {1, 1, 6, 7}, {1, 1, 6, 7}}}, + inputShapes{InputShape{{2, 3, 4, 5, 6, 7}, {{2, 3, 4, 5, 6, 7}}}, + {{1, 1, 6, 7}, {1, 1, 6, 7}, {1, 1, 6, 7}, {1, 1, 6, 7}}}, + inputShapes{InputShape{{2, 3, 4, 5, 6, 7}, {{2, 3, 4, 5, 6, 7}}}, + {{1, 1, 6, 7}, {1, 1, 6, 7}, {1, 1, 1, 1}, {1, 1, 1, 1}}}, + inputShapes{InputShape{{2, 3, 4, 5, 6, 7}, {{2, 3, 4, 5, 6, 7}}}, + {{1, 1, 6, 1}, {1, 5, 6, 7}, {1, 1, 6, 1}, {1, 1, 6, 1}}}, + inputShapes{InputShape{{-1, -1, -1, -1}, {{4, 5, 6, 7}, {1, 5, 6, 7}, {7, 5, 6, 7}, {4, 5, 6, 7}}}, + {{1, 1, 6, 1}, {1, 5, 6, 7}, {1, 1, 6, 1}, {1, 1, 6, 1}}}, + inputShapes{InputShape{{-1, -1, -1, -1, -1}, {{8, 4, 5, 6, 7}, {1, 1, 5, 6, 7}, {1, 1, 1, 6, 7}, {8, 4, 5, 6, 7}}}, + {{1, 1, 6, 7}, {1, 1, 6, 7}, {1, 1, 1, 1}, {1, 1, 1, 1}}}, }; const auto testParams = ::testing::Combine(specificParams, ::testing::ValuesIn(decomposeShapes), - ::testing::Values(Precision::FP32), + ::testing::Values(ov::element::f32), ::testing::ValuesIn(input_ranges), ::testing::Values(true), ::testing::Values(CPUSpecificParams{})); -INSTANTIATE_TEST_SUITE_P(smoke_FakeQuantizeLayerCPUTest_Decompos, FakeQuantizeLayerCPUTest, testParams, FakeQuantizeLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_FakeQuantizeLayerCPUTest_Decompos, + FakeQuantizeLayerCPUTest, + testParams, + FakeQuantizeLayerCPUTest::getTestCaseName); -} // namespace fqDecompos +} // namespace fqDecompos -} // namespace CPULayerTestsDefinitions +} // namespace test +} // namespace ov diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/gather.cpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/gather.cpp index 9a171663653bca..214947c2549449 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/gather.cpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/gather.cpp @@ -2,27 +2,26 @@ // SPDX-License-Identifier: Apache-2.0 // +#include "common_test_utils/ov_tensor_utils.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include "ov_models/builders.hpp" #include "test_utils/cpu_test_utils.hpp" -#include using namespace CPUTestUtils; -using namespace ov::test; - -namespace CPULayerTestsDefinitions { - -typedef std::tuple< - std::vector, // Input shapes - std::tuple, // Axis and Batch dim - ElementType, // Network precision - bool, // Is const Axis - CPUSpecificParams, // CPU specific params - std::map // Additional config -> GatherLayerTestCPUParams; +namespace ov { +namespace test { + +typedef std::tuple, // Input shapes + std::tuple, // Axis and Batch dim + ElementType, // Network precision + bool, // Is const Axis + CPUSpecificParams, // CPU specific params + ov::AnyMap // Additional config + > + GatherLayerTestCPUParams; class GatherLayerTestCPU : public testing::WithParamInterface, - virtual public ov::test::SubgraphBaseTest, public CPUTestsBase { + virtual public ov::test::SubgraphBaseTest, + public CPUTestsBase { public: static std::string getTestCaseName(testing::TestParamInfo obj) { std::vector inputShapes; @@ -30,20 +29,22 @@ class GatherLayerTestCPU : public testing::WithParamInterface additionalConfig; + ov::AnyMap additionalConfig; std::tie(inputShapes, axisAndBatchDims, netPrecision, isAxisConstant, cpuParams, 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 << 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 << ov::test::utils::vec2str(inputShapes[j].second[i]) + << (j < inputShapes.size() - 1lu ? "_" : ""); } result << "}_"; } @@ -55,9 +56,9 @@ class GatherLayerTestCPU : public testing::WithParamInterfaceset_friendly_name("indices"); if (!isAxisConstant) { @@ -107,8 +107,11 @@ class GatherLayerTestCPU : public testing::WithParamInterface gatherNode; if (isAxisConstant) { - gatherNode = std::make_shared(params[0], params[1], - ov::op::v0::Constant::create(intInputsPrecision, ov::Shape({1}), { axis }), batchDims); + gatherNode = std::make_shared( + params[0], + params[1], + ov::op::v0::Constant::create(intInputsPrecision, ov::Shape({1}), {axis}), + batchDims); } else { gatherNode = std::make_shared(params[0], params[1], params[2], batchDims); } @@ -130,11 +133,17 @@ class GatherLayerTestCPU : public testing::WithParamInterfaceget_friendly_name() == "data") { const auto dataTypeSize = funcInput.get_element_type().size(); const uint32_t range = dataTypeSize == 4 ? 0x7FFFFFFF : dataTypeSize == 2 ? 0xFFFF : 0xFF; - tensor = ov::test::utils::create_and_fill_tensor( - funcInput.get_element_type(), targetInputStaticShapes[0], range, 0, 1); + tensor = ov::test::utils::create_and_fill_tensor(funcInput.get_element_type(), + targetInputStaticShapes[0], + range, + 0, + 1); } else if (funcInput.get_node()->get_friendly_name() == "indices") { - tensor = ov::test::utils::create_and_fill_tensor( - funcInput.get_element_type(), targetInputStaticShapes[1], axisDim * 2, -axisDim, 1); + tensor = ov::test::utils::create_and_fill_tensor(funcInput.get_element_type(), + targetInputStaticShapes[1], + axisDim * 2, + -axisDim, + 1); } else if (funcInput.get_node()->get_friendly_name() == "axis") { tensor = ov::test::utils::create_and_fill_tensor(funcInput.get_element_type(), {1}, 1, axis, 1); } @@ -145,16 +154,17 @@ class GatherLayerTestCPU : public testing::WithParamInterface, // Indices - int, // Axis - ElementType, // Network precision - CPUSpecificParams // CPU specific params -> GatherInPlaceLayerTestCPUParams; +typedef std::tuple, // Indices + int, // Axis + ElementType, // Network precision + CPUSpecificParams // CPU specific params + > + GatherInPlaceLayerTestCPUParams; class GatherInPlaceLayerTestCPU : public testing::WithParamInterface, - virtual public ov::test::SubgraphBaseTest, public CPUTestsBase { + virtual public ov::test::SubgraphBaseTest, + public CPUTestsBase { public: static std::string getTestCaseName(testing::TestParamInfo obj) { InputShape inputShapes; @@ -172,7 +182,8 @@ class GatherInPlaceLayerTestCPU : public testing::WithParamInterfaceGetParam(); std::tie(inFmts, outFmts, priority, selectedType) = cpuParams; targetDevice = ov::test::utils::DEVICE_CPU; - init_input_shapes({ inputShapes }); + init_input_shapes({inputShapes}); selectedType = makeSelectedTypeStr(selectedType, netPrecision); - ngraph::ParameterVector params { - std::make_shared(netPrecision, inputDynamicShapes[0]) - }; + ov::ParameterVector params{std::make_shared(netPrecision, inputDynamicShapes[0])}; params[0]->set_friendly_name("data"); - std::shared_ptr gatherNode = std::make_shared(params[0], + std::shared_ptr gatherNode = std::make_shared( + params[0], ov::op::v0::Constant::create(intInputsPrecision, ov::Shape({indices.size()}), indices), - ov::op::v0::Constant::create(intInputsPrecision, ov::Shape({1}), { axis }), batchDims); + ov::op::v0::Constant::create(intInputsPrecision, ov::Shape({1}), {axis}), + batchDims); function = makeNgraphFunction(netPrecision, params, gatherNode, "GatherCPU"); } @@ -223,24 +234,19 @@ TEST_P(GatherInPlaceLayerTestCPU, CompareWithRefs) { } namespace { -const std::vector netPrecisions = { - ElementType::f32, - ElementType::bf16, - ElementType::i8 -}; +const std::vector netPrecisions = {ElementType::f32, ElementType::bf16, ElementType::i8}; -std::vector> additionalConfig - = {{{InferenceEngine::PluginConfigParams::KEY_ENFORCE_BF16, InferenceEngine::PluginConfigParams::NO}}, - {{InferenceEngine::PluginConfigParams::KEY_ENFORCE_BF16, InferenceEngine::PluginConfigParams::YES}}}; +std::vector additionalConfig = {{{ov::hint::inference_precision(ov::element::f32)}}, + {{ov::hint::inference_precision(ov::element::bf16)}}}; std::vector isAxisConst{true, false}; const CPUSpecificParams cpuParamsRef{{}, {}, {"ref_any"}, "ref_any"}; std::vector getCPUInfo() { std::vector resCPUParams; - if (InferenceEngine::with_cpu_x86_avx512f()) { + if (ov::with_cpu_x86_avx512f()) { resCPUParams.push_back(CPUSpecificParams{{}, {}, {"jit_avx512"}, "jit_avx512"}); - } else if (InferenceEngine::with_cpu_x86_avx2()) { + } else if (ov::with_cpu_x86_avx2()) { resCPUParams.push_back(CPUSpecificParams{{}, {}, {"jit_avx2"}, "jit_avx2"}); } else { resCPUParams.push_back(CPUSpecificParams{{}, {}, {"ref"}, "ref"}); @@ -250,191 +256,159 @@ std::vector getCPUInfo() { ///// 1D ///// const std::vector> staticInputShapes1D = { - { { {}, { {1} } }, { {}, { {1} } } }, - { { {}, { {2} } }, { {}, { {2} } } }, - { { {}, { {3} } }, { {}, { {3} } } }, - { { {}, { {4} } }, { {}, { {4} } } }, - { { {}, { {5} } }, { {}, { {5} } } }, - { { {}, { {6} } }, { {}, { {6} } } }, - { { {}, { {7} } }, { {}, { {7} } } }, - { { {}, { {8} } }, { {}, { {8} } } }, - { { {}, { {9} } }, { {}, { {9} } } }, - { { {}, { {11} } }, { {}, { {11} } } }, - { { {}, { {13} } }, { {}, { {13} } } }, - { { {}, { {15} } }, { {}, { {15} } } }, - { { {}, { {16} } }, { {}, { {16} } } }, - { { {}, { {17} } }, { {}, { {17} } } }, - { { {}, { {19} } }, { {}, { {19} } } }, - { { {}, { {23} } }, { {}, { {23} } } }, - { { {}, { {24} } }, { {}, { {24} } } }, - { { {}, { {32} } }, { {}, { {32} } } }, - { { {}, { {33} } }, { {}, { {33} } } }, - { { {}, { {37} } }, { {}, { {37} } } }, - { { {}, { {41} } }, { {}, { {41} } } }, - { { {}, { {48} } }, { {}, { {48} } } }, - { { {}, { {51} } }, { {}, { {51} } } }, - { { {}, { {63} } }, { {}, { {63} } } }, - { { {}, { {64} } }, { {}, { {64} } } }, - { { {}, { {65} } }, { {}, { {65} } } } -}; - -INSTANTIATE_TEST_SUITE_P(smoke_static_1D, GatherLayerTestCPU, - ::testing::Combine( - ::testing::ValuesIn(staticInputShapes1D), - ::testing::Values(std::tuple{0, 0}), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(true), - ::testing::ValuesIn(getCPUInfo()), - ::testing::Values(additionalConfig[0])), - GatherLayerTestCPU::getTestCaseName); + {{{}, {{1}}}, {{}, {{1}}}}, {{{}, {{2}}}, {{}, {{2}}}}, {{{}, {{3}}}, {{}, {{3}}}}, + {{{}, {{4}}}, {{}, {{4}}}}, {{{}, {{5}}}, {{}, {{5}}}}, {{{}, {{6}}}, {{}, {{6}}}}, + {{{}, {{7}}}, {{}, {{7}}}}, {{{}, {{8}}}, {{}, {{8}}}}, {{{}, {{9}}}, {{}, {{9}}}}, + {{{}, {{11}}}, {{}, {{11}}}}, {{{}, {{13}}}, {{}, {{13}}}}, {{{}, {{15}}}, {{}, {{15}}}}, + {{{}, {{16}}}, {{}, {{16}}}}, {{{}, {{17}}}, {{}, {{17}}}}, {{{}, {{19}}}, {{}, {{19}}}}, + {{{}, {{23}}}, {{}, {{23}}}}, {{{}, {{24}}}, {{}, {{24}}}}, {{{}, {{32}}}, {{}, {{32}}}}, + {{{}, {{33}}}, {{}, {{33}}}}, {{{}, {{37}}}, {{}, {{37}}}}, {{{}, {{41}}}, {{}, {{41}}}}, + {{{}, {{48}}}, {{}, {{48}}}}, {{{}, {{51}}}, {{}, {{51}}}}, {{{}, {{63}}}, {{}, {{63}}}}, + {{{}, {{64}}}, {{}, {{64}}}}, {{{}, {{65}}}, {{}, {{65}}}}}; + +INSTANTIATE_TEST_SUITE_P(smoke_static_1D, + GatherLayerTestCPU, + ::testing::Combine(::testing::ValuesIn(staticInputShapes1D), + ::testing::Values(std::tuple{0, 0}), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(true), + ::testing::ValuesIn(getCPUInfo()), + ::testing::Values(additionalConfig[0])), + GatherLayerTestCPU::getTestCaseName); const std::vector> dynamicInputShapes1D = { - { { { ov::Dimension{1, 70} }, // Dynamic shape 0 - { {1}, {2}, {3}, {4}, {5}, {6}, {7}, {8}, {9}, {11}, {13}, {15}, {16}, {17}, {19}, {23}, {24}, {32}, {55}, {63}, {64}, {65} } }, // Target shapes - { { -1 }, // Dynamic shape 1 - { {1}, {2}, {3}, {4}, {5}, {6}, {7}, {8}, {9}, {11}, {13}, {15}, {16}, {17}, {19}, {23}, {24}, {32}, {55}, {63}, {64}, {65} } } } // Target shapes + {{{ov::Dimension{1, 70}}, // Dynamic shape 0 + {{1}, {2}, {3}, {4}, {5}, {6}, {7}, {8}, {9}, {11}, {13}, + {15}, {16}, {17}, {19}, {23}, {24}, {32}, {55}, {63}, {64}, {65}}}, // Target shapes + {{-1}, // Dynamic shape 1 + {{1}, {2}, {3}, {4}, {5}, {6}, {7}, {8}, {9}, {11}, {13}, + {15}, {16}, {17}, {19}, {23}, {24}, {32}, {55}, {63}, {64}, {65}}}} // Target shapes }; -INSTANTIATE_TEST_SUITE_P(smoke_dynamic_1D, GatherLayerTestCPU, - ::testing::Combine( - ::testing::ValuesIn(dynamicInputShapes1D), - ::testing::Values(std::tuple{0, 0}), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(true, false), - ::testing::ValuesIn(getCPUInfo()), - ::testing::Values(additionalConfig[0])), - GatherLayerTestCPU::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_dynamic_1D, + GatherLayerTestCPU, + ::testing::Combine(::testing::ValuesIn(dynamicInputShapes1D), + ::testing::Values(std::tuple{0, 0}), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(true, false), + ::testing::ValuesIn(getCPUInfo()), + ::testing::Values(additionalConfig[0])), + GatherLayerTestCPU::getTestCaseName); ///// 4D JIT ///// std::vector> get4DShapesJitStat(int maxBatchDims) { std::vector> result = {}; - if (InferenceEngine::with_cpu_x86_avx2()) { + if (ov::with_cpu_x86_avx2()) { if (maxBatchDims == 2) { - result = { - { { {}, { {18, 2, 2, 1} } }, // Static shapes - { {}, { {18, 2, 8} } } - }, - { { {}, { {17, 2, 2, 2} } }, // Static shapes - { {}, { {17, 2, 7} } } - }, - { { {}, { {16, 2, 2, 3} } }, // Static shapes - { {}, { {16, 2, 6} } } - }, - { { {}, { {15, 2, 2, 4} } }, // Static shapes - { {}, { {15, 2, 5} } } - }, - { { {}, { {14, 2, 2, 5} } }, // Static shapes - { {}, { {14, 2, 4} } } - }, - { { {}, { {13, 2, 2, 6} } }, // Static shapes - { {}, { {13, 2, 3} } } - }, - { { {}, { {12, 2, 2, 7} } }, // Static shapes - { {}, { {12, 2, 2} } } - }, - { { {}, { {11, 2, 2, 8} } }, // Static shapes - { {}, { {11, 2, 1} } } - } - }; + result = {{{{}, {{18, 2, 2, 1}}}, // Static shapes + {{}, {{18, 2, 8}}}}, + {{{}, {{17, 2, 2, 2}}}, // Static shapes + {{}, {{17, 2, 7}}}}, + {{{}, {{16, 2, 2, 3}}}, // Static shapes + {{}, {{16, 2, 6}}}}, + {{{}, {{15, 2, 2, 4}}}, // Static shapes + {{}, {{15, 2, 5}}}}, + {{{}, {{14, 2, 2, 5}}}, // Static shapes + {{}, {{14, 2, 4}}}}, + {{{}, {{13, 2, 2, 6}}}, // Static shapes + {{}, {{13, 2, 3}}}}, + {{{}, {{12, 2, 2, 7}}}, // Static shapes + {{}, {{12, 2, 2}}}}, + {{{}, {{11, 2, 2, 8}}}, // Static shapes + {{}, {{11, 2, 1}}}}}; } else if (maxBatchDims == 3) { - result = { - { { {}, { {18, 2, 8, 1} } }, // Static shapes - { {}, { {18, 2, 8} } } - }, - { { {}, { {17, 2, 7, 2} } }, // Static shapes - { {}, { {17, 2, 7} } } - }, - { { {}, { {16, 2, 6, 3} } }, // Static shapes - { {}, { {16, 2, 6} } } - }, - { { {}, { {15, 2, 5, 4} } }, // Static shapes - { {}, { {15, 2, 5} } } - }, - { { {}, { {14, 2, 4, 5} } }, // Static shapes - { {}, { {14, 2, 4} } } - }, - { { {}, { {13, 2, 3, 6} } }, // Static shapes - { {}, { {13, 2, 3} } } - }, - { { {}, { {12, 2, 2, 7} } }, // Static shapes - { {}, { {12, 2, 2} } } - }, - { { {}, { {11, 2, 1, 8} } }, // Static shapes - { {}, { {11, 2, 1} } } - } - }; + result = {{{{}, {{18, 2, 8, 1}}}, // Static shapes + {{}, {{18, 2, 8}}}}, + {{{}, {{17, 2, 7, 2}}}, // Static shapes + {{}, {{17, 2, 7}}}}, + {{{}, {{16, 2, 6, 3}}}, // Static shapes + {{}, {{16, 2, 6}}}}, + {{{}, {{15, 2, 5, 4}}}, // Static shapes + {{}, {{15, 2, 5}}}}, + {{{}, {{14, 2, 4, 5}}}, // Static shapes + {{}, {{14, 2, 4}}}}, + {{{}, {{13, 2, 3, 6}}}, // Static shapes + {{}, {{13, 2, 3}}}}, + {{{}, {{12, 2, 2, 7}}}, // Static shapes + {{}, {{12, 2, 2}}}}, + {{{}, {{11, 2, 1, 8}}}, // Static shapes + {{}, {{11, 2, 1}}}}}; } else { throw std::invalid_argument("Invalid test case. Not valid batch dims."); } - } // AVX2 - if (InferenceEngine::with_cpu_x86_avx512f()) { + } // AVX2 + if (ov::with_cpu_x86_avx512f()) { std::vector> tmp; if (maxBatchDims == 2) { - tmp = { - { { {}, { {19, 4, 2, 9} } }, // Static shapes - { {}, { {19, 4, 16} } } - }, - { { {}, { {20, 4, 2, 10} } }, // Static shapes - { {}, { {20, 4, 15} } }, - }, - { { {}, { {21, 4, 2, 11} } }, // Static shapes - { {}, { {21, 4, 14} } } - }, - { { {}, { {22, 4, 2, 12} } }, // Static shapes - { {}, { {22, 4, 13} } }, - }, - { { {}, { {23, 4, 2, 13} } }, // Static shapes - { {}, { {23, 4, 12} } }, - }, - { { {}, { {24, 4, 2, 14} } }, // Static shapes - { {}, { {24, 4, 11} } }, - }, - { { {}, { {25, 4, 2, 15} } }, // Static shapes - { {}, { {25, 4, 10} } }, - }, - { { {}, { {26, 4, 2, 16} } }, // Static shapes - { {}, { {26, 4, 9} } }, - } - }; + tmp = {{{{}, {{19, 4, 2, 9}}}, // Static shapes + {{}, {{19, 4, 16}}}}, + { + {{}, {{20, 4, 2, 10}}}, // Static shapes + {{}, {{20, 4, 15}}}, + }, + {{{}, {{21, 4, 2, 11}}}, // Static shapes + {{}, {{21, 4, 14}}}}, + { + {{}, {{22, 4, 2, 12}}}, // Static shapes + {{}, {{22, 4, 13}}}, + }, + { + {{}, {{23, 4, 2, 13}}}, // Static shapes + {{}, {{23, 4, 12}}}, + }, + { + {{}, {{24, 4, 2, 14}}}, // Static shapes + {{}, {{24, 4, 11}}}, + }, + { + {{}, {{25, 4, 2, 15}}}, // Static shapes + {{}, {{25, 4, 10}}}, + }, + { + {{}, {{26, 4, 2, 16}}}, // Static shapes + {{}, {{26, 4, 9}}}, + }}; } else if (maxBatchDims == 3) { - tmp = { - { { {}, { {19, 4, 16, 9} } }, // Static shapes - { {}, { {19, 4, 16} } } - }, - { { {}, { {20, 4, 15, 10} } }, // Static shapes - { {}, { {20, 4, 15} } }, - }, - { { {}, { {21, 4, 14, 11} } }, // Static shapes - { {}, { {21, 4, 14} } } - }, - { { {}, { {22, 4, 13, 12} } }, // Static shapes - { {}, { {22, 4, 13} } }, - }, - { { {}, { {23, 4, 12, 13} } }, // Static shapes - { {}, { {23, 4, 12} } }, - }, - { { {}, { {24, 4, 11, 14} } }, // Static shapes - { {}, { {24, 4, 11} } }, - }, - { { {}, { {25, 4, 10, 15} } }, // Static shapes - { {}, { {25, 4, 10} } }, - }, - { { {}, { {26, 4, 9, 16} } }, // Static shapes - { {}, { {26, 4, 9} } }, - } - }; + tmp = {{{{}, {{19, 4, 16, 9}}}, // Static shapes + {{}, {{19, 4, 16}}}}, + { + {{}, {{20, 4, 15, 10}}}, // Static shapes + {{}, {{20, 4, 15}}}, + }, + {{{}, {{21, 4, 14, 11}}}, // Static shapes + {{}, {{21, 4, 14}}}}, + { + {{}, {{22, 4, 13, 12}}}, // Static shapes + {{}, {{22, 4, 13}}}, + }, + { + {{}, {{23, 4, 12, 13}}}, // Static shapes + {{}, {{23, 4, 12}}}, + }, + { + {{}, {{24, 4, 11, 14}}}, // Static shapes + {{}, {{24, 4, 11}}}, + }, + { + {{}, {{25, 4, 10, 15}}}, // Static shapes + {{}, {{25, 4, 10}}}, + }, + { + {{}, {{26, 4, 9, 16}}}, // Static shapes + {{}, {{26, 4, 9}}}, + }}; } else { throw std::invalid_argument("Invalid test case. Not valid batch dims."); } result.insert(result.end(), tmp.begin(), tmp.end()); - } // AVX5 + } // AVX5 return result; } std::vector> get4DAxisBatchJitStat(ov::element::Type type, int maxBatchDims) { std::vector> result = {}; - if (InferenceEngine::with_cpu_x86_avx512f()) { + if (ov::with_cpu_x86_avx512f()) { if (type.size() == 4 || type.size() == 2 || type.size() == 1) { if (maxBatchDims == 2) return std::vector>{{3, 0}, {3, 1}, {3, 2}, {2, 0}, {2, 1}, {2, 2}}; @@ -443,7 +417,7 @@ std::vector> get4DAxisBatchJitStat(ov::element::Type type, else throw std::invalid_argument("Invalid test case. Not valid batch dims."); } - } else if (InferenceEngine::with_cpu_x86_avx2()) { + } else if (ov::with_cpu_x86_avx2()) { if (type.size() == 4) { if (maxBatchDims == 2) return std::vector>{{3, 0}, {3, 1}, {3, 2}, {2, 0}, {2, 1}, {2, 2}}; @@ -463,152 +437,151 @@ std::vector> get4DAxisBatchJitStat(ov::element::Type type, return {}; } -INSTANTIATE_TEST_SUITE_P(smoke_static_4D_jit32, GatherLayerTestCPU, - ::testing::Combine( - ::testing::ValuesIn(get4DShapesJitStat(2)), - ::testing::ValuesIn(get4DAxisBatchJitStat(ElementType::f32, 2)), - ::testing::Values(ElementType::f32), - ::testing::Values(true), - ::testing::ValuesIn(getCPUInfo()), - ::testing::ValuesIn(additionalConfig)), - GatherLayerTestCPU::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_static_4D_jit16, GatherLayerTestCPU, - ::testing::Combine( - ::testing::ValuesIn(get4DShapesJitStat(2)), - ::testing::ValuesIn(get4DAxisBatchJitStat(ElementType::bf16, 2)), - ::testing::Values(ElementType::bf16), - ::testing::Values(true), - ::testing::ValuesIn(getCPUInfo()), - ::testing::Values(additionalConfig[0])), - GatherLayerTestCPU::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_static_4D_jit8, GatherLayerTestCPU, - ::testing::Combine( - ::testing::ValuesIn(get4DShapesJitStat(2)), - ::testing::ValuesIn(get4DAxisBatchJitStat(ElementType::i8, 2)), - ::testing::Values(ElementType::i8), - ::testing::Values(true), - ::testing::ValuesIn(getCPUInfo()), - ::testing::Values(additionalConfig[0])), - GatherLayerTestCPU::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_static_4D_jit32, + GatherLayerTestCPU, + ::testing::Combine(::testing::ValuesIn(get4DShapesJitStat(2)), + ::testing::ValuesIn(get4DAxisBatchJitStat(ElementType::f32, 2)), + ::testing::Values(ElementType::f32), + ::testing::Values(true), + ::testing::ValuesIn(getCPUInfo()), + ::testing::ValuesIn(additionalConfig)), + GatherLayerTestCPU::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_static_4D_jit16, + GatherLayerTestCPU, + ::testing::Combine(::testing::ValuesIn(get4DShapesJitStat(2)), + ::testing::ValuesIn(get4DAxisBatchJitStat(ElementType::bf16, 2)), + ::testing::Values(ElementType::bf16), + ::testing::Values(true), + ::testing::ValuesIn(getCPUInfo()), + ::testing::Values(additionalConfig[0])), + GatherLayerTestCPU::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_static_4D_jit8, + GatherLayerTestCPU, + ::testing::Combine(::testing::ValuesIn(get4DShapesJitStat(2)), + ::testing::ValuesIn(get4DAxisBatchJitStat(ElementType::i8, 2)), + ::testing::Values(ElementType::i8), + ::testing::Values(true), + ::testing::ValuesIn(getCPUInfo()), + ::testing::Values(additionalConfig[0])), + GatherLayerTestCPU::getTestCaseName); // batchDims == indicesRank -INSTANTIATE_TEST_SUITE_P(smoke_static_4D_jit32_Bmax, GatherLayerTestCPU, - ::testing::Combine( - ::testing::ValuesIn(get4DShapesJitStat(3)), - ::testing::ValuesIn(get4DAxisBatchJitStat(ElementType::f32, 3)), - ::testing::Values(ElementType::f32), - ::testing::Values(true), - ::testing::ValuesIn(getCPUInfo()), - ::testing::ValuesIn(additionalConfig)), - GatherLayerTestCPU::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_static_4D_jit16_Bmax, GatherLayerTestCPU, - ::testing::Combine( - ::testing::ValuesIn(get4DShapesJitStat(3)), - ::testing::ValuesIn(get4DAxisBatchJitStat(ElementType::bf16, 3)), - ::testing::Values(ElementType::bf16), - ::testing::Values(true), - ::testing::ValuesIn(getCPUInfo()), - ::testing::Values(additionalConfig[0])), - GatherLayerTestCPU::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_static_4D_jit8_Bmax, GatherLayerTestCPU, - ::testing::Combine( - ::testing::ValuesIn(get4DShapesJitStat(3)), - ::testing::ValuesIn(get4DAxisBatchJitStat(ElementType::i8, 3)), - ::testing::Values(ElementType::i8), - ::testing::Values(true), - ::testing::ValuesIn(getCPUInfo()), - ::testing::Values(additionalConfig[0])), - GatherLayerTestCPU::getTestCaseName); - +INSTANTIATE_TEST_SUITE_P(smoke_static_4D_jit32_Bmax, + GatherLayerTestCPU, + ::testing::Combine(::testing::ValuesIn(get4DShapesJitStat(3)), + ::testing::ValuesIn(get4DAxisBatchJitStat(ElementType::f32, 3)), + ::testing::Values(ElementType::f32), + ::testing::Values(true), + ::testing::ValuesIn(getCPUInfo()), + ::testing::ValuesIn(additionalConfig)), + GatherLayerTestCPU::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_static_4D_jit16_Bmax, + GatherLayerTestCPU, + ::testing::Combine(::testing::ValuesIn(get4DShapesJitStat(3)), + ::testing::ValuesIn(get4DAxisBatchJitStat(ElementType::bf16, 3)), + ::testing::Values(ElementType::bf16), + ::testing::Values(true), + ::testing::ValuesIn(getCPUInfo()), + ::testing::Values(additionalConfig[0])), + GatherLayerTestCPU::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_static_4D_jit8_Bmax, + GatherLayerTestCPU, + ::testing::Combine(::testing::ValuesIn(get4DShapesJitStat(3)), + ::testing::ValuesIn(get4DAxisBatchJitStat(ElementType::i8, 3)), + ::testing::Values(ElementType::i8), + ::testing::Values(true), + ::testing::ValuesIn(getCPUInfo()), + ::testing::Values(additionalConfig[0])), + GatherLayerTestCPU::getTestCaseName); std::vector> get4DShapesJitDyn(int maxBatchDims) { std::vector> result = {}; - if (InferenceEngine::with_cpu_x86_avx2()) { + if (ov::with_cpu_x86_avx2()) { if (maxBatchDims == 2) { result = { - { { { ov::Dimension(5, 15), -1, -1, -1 }, // Dynamic shape 0 - { {8, 2, 2, 1}, {10, 2, 2, 2}, {8, 2, 2, 3}, {10, 2, 2, 4}} }, // Target shapes - { { ov::Dimension(4, 16), -1, -1 }, // Dynamic shape 1 - { {8, 2, 8}, {10, 2, 7}, {8, 2, 6}, {10, 2, 5} } } }, // Target shapes - { { { -1, -1, -1, -1 }, // Dynamic shape 0 - { {8, 2, 2, 5}, {10, 2, 2, 6}, {8, 2, 2, 7}, {10, 2, 2, 8}} }, // Target shapes - { { -1, -1, -1 }, // Dynamic shape 1 - { {8, 2, 4}, {10, 2, 3}, {8, 2, 2}, {10, 2, 1} } } }, // Target shapes - { { { ov::Dimension(5, 15), -1, -1, -1 }, // Dynamic shape 0 - { {10, 2, 2, 1}, {10, 2, 2, 2}, {10, 2, 2, 3}, {10, 2, 2, 4}} }, // Target shapes - { { 10, 2, 5 }, // Dynamic shape 1 - { {10, 2, 5}, {10, 2, 5}, {10, 2, 5}, {10, 2, 5} } } }, // Target shapes - { { { 8, 2, 2, 5 }, // Dynamic shape 0 - { {8, 2, 2, 5}, {8, 2, 2, 5}, {8, 2, 2, 5}, {8, 2, 2, 5}} }, // Target shapes - { { -1, -1, -1 }, // Dynamic shape 1 - { {8, 2, 4}, {8, 2, 3}, {8, 2, 2}, {8, 2, 1} } } } // Target shapes + {{{ov::Dimension(5, 15), -1, -1, -1}, // Dynamic shape 0 + {{8, 2, 2, 1}, {10, 2, 2, 2}, {8, 2, 2, 3}, {10, 2, 2, 4}}}, // Target shapes + {{ov::Dimension(4, 16), -1, -1}, // Dynamic shape 1 + {{8, 2, 8}, {10, 2, 7}, {8, 2, 6}, {10, 2, 5}}}}, // Target shapes + {{{-1, -1, -1, -1}, // Dynamic shape 0 + {{8, 2, 2, 5}, {10, 2, 2, 6}, {8, 2, 2, 7}, {10, 2, 2, 8}}}, // Target shapes + {{-1, -1, -1}, // Dynamic shape 1 + {{8, 2, 4}, {10, 2, 3}, {8, 2, 2}, {10, 2, 1}}}}, // Target shapes + {{{ov::Dimension(5, 15), -1, -1, -1}, // Dynamic shape 0 + {{10, 2, 2, 1}, {10, 2, 2, 2}, {10, 2, 2, 3}, {10, 2, 2, 4}}}, // Target shapes + {{10, 2, 5}, // Dynamic shape 1 + {{10, 2, 5}, {10, 2, 5}, {10, 2, 5}, {10, 2, 5}}}}, // Target shapes + {{{8, 2, 2, 5}, // Dynamic shape 0 + {{8, 2, 2, 5}, {8, 2, 2, 5}, {8, 2, 2, 5}, {8, 2, 2, 5}}}, // Target shapes + {{-1, -1, -1}, // Dynamic shape 1 + {{8, 2, 4}, {8, 2, 3}, {8, 2, 2}, {8, 2, 1}}}} // Target shapes }; } else if (maxBatchDims == 3) { result = { - { { { ov::Dimension(5, 15), -1, -1, -1 }, // Dynamic shape 0 - { {8, 2, 8, 1}, {10, 2, 8, 2}, {8, 2, 8, 3}, {10, 2, 5, 4}} }, // Target shapes - { { ov::Dimension(4, 16), -1, -1 }, // Dynamic shape 1 - { {8, 2, 8}, {10, 2, 8}, {8, 2, 8}, {10, 2, 5} } } }, // Target shapes - { { { -1, -1, -1, -1 }, // Dynamic shape 0 - { {8, 2, 4, 5}, {10, 2, 3, 6}, {8, 2, 2, 7}, {10, 2, 1, 8}} }, // Target shapes - { { -1, -1, -1 }, // Dynamic shape 1 - { {8, 2, 4}, {10, 2, 3}, {8, 2, 2}, {10, 2, 1} } } }, // Target shapes - { { { ov::Dimension(5, 15), -1, -1, -1 }, // Dynamic shape 0 - { {10, 2, 5, 1}, {10, 2, 5, 2}, {10, 2, 5, 3}, {10, 2, 5, 4}} }, // Target shapes - { { 10, 2, 5 }, // Dynamic shape 1 - { {10, 2, 5}, {10, 2, 5}, {10, 2, 5}, {10, 2, 5} } } }, // Target shapes - { { { 8, 2, 3, 5 }, // Dynamic shape 0 - { {8, 2, 3, 5}, {8, 2, 3, 5}, {8, 2, 3, 5}, {8, 2, 3, 5}} }, // Target shapes - { { -1, -1, -1 }, // Dynamic shape 1 - { {8, 2, 3}, {8, 2, 3}, {8, 2, 3}, {8, 2, 3} } } } // Target shapes + {{{ov::Dimension(5, 15), -1, -1, -1}, // Dynamic shape 0 + {{8, 2, 8, 1}, {10, 2, 8, 2}, {8, 2, 8, 3}, {10, 2, 5, 4}}}, // Target shapes + {{ov::Dimension(4, 16), -1, -1}, // Dynamic shape 1 + {{8, 2, 8}, {10, 2, 8}, {8, 2, 8}, {10, 2, 5}}}}, // Target shapes + {{{-1, -1, -1, -1}, // Dynamic shape 0 + {{8, 2, 4, 5}, {10, 2, 3, 6}, {8, 2, 2, 7}, {10, 2, 1, 8}}}, // Target shapes + {{-1, -1, -1}, // Dynamic shape 1 + {{8, 2, 4}, {10, 2, 3}, {8, 2, 2}, {10, 2, 1}}}}, // Target shapes + {{{ov::Dimension(5, 15), -1, -1, -1}, // Dynamic shape 0 + {{10, 2, 5, 1}, {10, 2, 5, 2}, {10, 2, 5, 3}, {10, 2, 5, 4}}}, // Target shapes + {{10, 2, 5}, // Dynamic shape 1 + {{10, 2, 5}, {10, 2, 5}, {10, 2, 5}, {10, 2, 5}}}}, // Target shapes + {{{8, 2, 3, 5}, // Dynamic shape 0 + {{8, 2, 3, 5}, {8, 2, 3, 5}, {8, 2, 3, 5}, {8, 2, 3, 5}}}, // Target shapes + {{-1, -1, -1}, // Dynamic shape 1 + {{8, 2, 3}, {8, 2, 3}, {8, 2, 3}, {8, 2, 3}}}} // Target shapes }; } else { throw std::invalid_argument("Invalid test case. Not valid batch dims."); } } - if (InferenceEngine::with_cpu_x86_avx512f()) { + if (ov::with_cpu_x86_avx512f()) { std::vector> tmp; if (maxBatchDims == 2) { tmp = { - { { { ov::Dimension(5, 15), -1, -1, -1 }, // Dynamic shape 0 - { {8, 2, 2, 9}, {10, 2, 2, 10}, {8, 2, 2, 11}, {10, 2, 2, 12}} }, // Target shapes - { { ov::Dimension(4, 16), -1, -1 }, // Dynamic shape 1 - { {8, 2, 16}, {10, 2, 15}, {8, 2, 14}, {10, 2, 13} } } }, // Target shapes - { { { -1, -1, -1, -1 }, // Dynamic shape 0 - { {8, 2, 2, 13}, {10, 2, 2, 14}, {8, 2, 2, 15}, {10, 2, 2, 16}} }, // Target shapes - { { -1, -1, -1 }, // Dynamic shape 1 - { {8, 2, 12}, {10, 2, 11}, {8, 2, 10}, {10, 2, 9} } } }, // Target shapes - { { { ov::Dimension(5, 15), -1, -1, -1 }, // Dynamic shape 0 - { {10, 2, 2, 9}, {10, 2, 2, 10}, {10, 2, 2, 11}, {10, 2, 2, 12}} }, // Target shapes - { { 10, 2, 16 }, // Dynamic shape 1 - { {10, 2, 16}, {10, 2, 16}, {10, 2, 16}, {10, 2, 16} } } }, // Target shapes - { { { 8, 2, 2, 15 }, // Dynamic shape 0 - { {8, 2, 2, 15}, {8, 2, 2, 15}, {8, 2, 2, 15}, {8, 2, 2, 15}} }, // Target shapes - { { -1, -1, -1 }, // Dynamic shape 1 - { {8, 2, 12}, {8, 2, 11}, {8, 2, 10}, {8, 2, 9} } } } // Target shapes + {{{ov::Dimension(5, 15), -1, -1, -1}, // Dynamic shape 0 + {{8, 2, 2, 9}, {10, 2, 2, 10}, {8, 2, 2, 11}, {10, 2, 2, 12}}}, // Target shapes + {{ov::Dimension(4, 16), -1, -1}, // Dynamic shape 1 + {{8, 2, 16}, {10, 2, 15}, {8, 2, 14}, {10, 2, 13}}}}, // Target shapes + {{{-1, -1, -1, -1}, // Dynamic shape 0 + {{8, 2, 2, 13}, {10, 2, 2, 14}, {8, 2, 2, 15}, {10, 2, 2, 16}}}, // Target shapes + {{-1, -1, -1}, // Dynamic shape 1 + {{8, 2, 12}, {10, 2, 11}, {8, 2, 10}, {10, 2, 9}}}}, // Target shapes + {{{ov::Dimension(5, 15), -1, -1, -1}, // Dynamic shape 0 + {{10, 2, 2, 9}, {10, 2, 2, 10}, {10, 2, 2, 11}, {10, 2, 2, 12}}}, // Target shapes + {{10, 2, 16}, // Dynamic shape 1 + {{10, 2, 16}, {10, 2, 16}, {10, 2, 16}, {10, 2, 16}}}}, // Target shapes + {{{8, 2, 2, 15}, // Dynamic shape 0 + {{8, 2, 2, 15}, {8, 2, 2, 15}, {8, 2, 2, 15}, {8, 2, 2, 15}}}, // Target shapes + {{-1, -1, -1}, // Dynamic shape 1 + {{8, 2, 12}, {8, 2, 11}, {8, 2, 10}, {8, 2, 9}}}} // Target shapes }; } else if (maxBatchDims == 3) { tmp = { - { { { ov::Dimension(5, 15), -1, -1, -1 }, // Dynamic shape 0 - { {8, 2, 16, 9}, {10, 2, 15, 10}, {8, 2, 14, 11}, {10, 2, 13, 12}} }, // Target shapes - { { ov::Dimension(4, 16), -1, -1 }, // Dynamic shape 1 - { {8, 2, 16}, {10, 2, 15}, {8, 2, 14}, {10, 2, 13} } } }, // Target shapes - { { { -1, -1, -1, -1 }, // Dynamic shape 0 - { {8, 2, 12, 13}, {10, 2, 11, 14}, {8, 2, 10, 15}, {10, 2, 9, 16}} }, // Target shapes - { { -1, -1, -1 }, // Dynamic shape 1 - { {8, 2, 12}, {10, 2, 11}, {8, 2, 10}, {10, 2, 9} } } }, // Target shapes - { { { ov::Dimension(5, 15), -1, -1, -1 }, // Dynamic shape 0 - { {10, 2, 16, 9}, {10, 2, 16, 10}, {10, 2, 16, 11}, {10, 2, 16, 12}} }, // Target shapes - { { 10, 2, 16 }, // Dynamic shape 1 - { {10, 2, 16}, {10, 2, 16}, {10, 2, 16}, {10, 2, 16} } } }, // Target shapes - { { { 8, 2, 11, 15 }, // Dynamic shape 0 - { {8, 2, 11, 15}, {8, 2, 11, 15}, {8, 2, 11, 15}, {8, 2, 11, 15}} }, // Target shapes - { { -1, -1, -1 }, // Dynamic shape 1 - { {8, 2, 11}, {8, 2, 11}, {8, 2, 11}, {8, 2, 11} } } } // Target shapes + {{{ov::Dimension(5, 15), -1, -1, -1}, // Dynamic shape 0 + {{8, 2, 16, 9}, {10, 2, 15, 10}, {8, 2, 14, 11}, {10, 2, 13, 12}}}, // Target shapes + {{ov::Dimension(4, 16), -1, -1}, // Dynamic shape 1 + {{8, 2, 16}, {10, 2, 15}, {8, 2, 14}, {10, 2, 13}}}}, // Target shapes + {{{-1, -1, -1, -1}, // Dynamic shape 0 + {{8, 2, 12, 13}, {10, 2, 11, 14}, {8, 2, 10, 15}, {10, 2, 9, 16}}}, // Target shapes + {{-1, -1, -1}, // Dynamic shape 1 + {{8, 2, 12}, {10, 2, 11}, {8, 2, 10}, {10, 2, 9}}}}, // Target shapes + {{{ov::Dimension(5, 15), -1, -1, -1}, // Dynamic shape 0 + {{10, 2, 16, 9}, {10, 2, 16, 10}, {10, 2, 16, 11}, {10, 2, 16, 12}}}, // Target shapes + {{10, 2, 16}, // Dynamic shape 1 + {{10, 2, 16}, {10, 2, 16}, {10, 2, 16}, {10, 2, 16}}}}, // Target shapes + {{{8, 2, 11, 15}, // Dynamic shape 0 + {{8, 2, 11, 15}, {8, 2, 11, 15}, {8, 2, 11, 15}, {8, 2, 11, 15}}}, // Target shapes + {{-1, -1, -1}, // Dynamic shape 1 + {{8, 2, 11}, {8, 2, 11}, {8, 2, 11}, {8, 2, 11}}}} // Target shapes }; } else { throw std::invalid_argument("Invalid test case. Not valid batch dims."); @@ -621,7 +594,7 @@ std::vector> get4DShapesJitDyn(int maxBatchDim std::vector> get4DAxisBatchJitDyn(ov::element::Type type, int maxBatchDims) { std::vector> result = {}; - if (InferenceEngine::with_cpu_x86_avx512f()) { + if (ov::with_cpu_x86_avx512f()) { if (type.size() == 4 || type.size() == 2 || type.size() == 1) { if (maxBatchDims == 2) return std::vector>{{3, 0}, {3, 1}, {3, 2}}; @@ -630,7 +603,7 @@ std::vector> get4DAxisBatchJitDyn(ov::element::Type type, i else throw std::invalid_argument("Invalid test case. Not valid batch dims."); } - } else if (InferenceEngine::with_cpu_x86_avx2()) { + } else if (ov::with_cpu_x86_avx2()) { if (type.size() == 4 || type.size() == 2 || type.size() == 1) { if (maxBatchDims == 2) return std::vector>{{3, 0}, {3, 1}, {3, 2}}; @@ -643,184 +616,167 @@ std::vector> get4DAxisBatchJitDyn(ov::element::Type type, i return {}; } -INSTANTIATE_TEST_SUITE_P(smoke_dynamic_4D_jit32, GatherLayerTestCPU, - ::testing::Combine( - ::testing::ValuesIn(get4DShapesJitDyn(2)), - ::testing::ValuesIn(get4DAxisBatchJitDyn(ElementType::f32, 2)), - ::testing::Values(ElementType::f32), - ::testing::ValuesIn(isAxisConst), - ::testing::ValuesIn(getCPUInfo()), - ::testing::ValuesIn(additionalConfig)), - GatherLayerTestCPU::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_dynamic_4D_jit16, GatherLayerTestCPU, - ::testing::Combine( - ::testing::ValuesIn(get4DShapesJitDyn(2)), - ::testing::ValuesIn(get4DAxisBatchJitDyn(ElementType::bf16, 2)), - ::testing::Values(ElementType::bf16), - ::testing::ValuesIn(isAxisConst), - ::testing::ValuesIn(getCPUInfo()), - ::testing::Values(additionalConfig[0])), - GatherLayerTestCPU::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_dynamic_4D_jit8, GatherLayerTestCPU, - ::testing::Combine( - ::testing::ValuesIn(get4DShapesJitDyn(2)), - ::testing::ValuesIn(get4DAxisBatchJitDyn(ElementType::i8, 2)), - ::testing::Values(ElementType::i8), - ::testing::ValuesIn(isAxisConst), - ::testing::ValuesIn(getCPUInfo()), - ::testing::Values(additionalConfig[0])), - GatherLayerTestCPU::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_dynamic_4D_jit32, + GatherLayerTestCPU, + ::testing::Combine(::testing::ValuesIn(get4DShapesJitDyn(2)), + ::testing::ValuesIn(get4DAxisBatchJitDyn(ElementType::f32, 2)), + ::testing::Values(ElementType::f32), + ::testing::ValuesIn(isAxisConst), + ::testing::ValuesIn(getCPUInfo()), + ::testing::ValuesIn(additionalConfig)), + GatherLayerTestCPU::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_dynamic_4D_jit16, + GatherLayerTestCPU, + ::testing::Combine(::testing::ValuesIn(get4DShapesJitDyn(2)), + ::testing::ValuesIn(get4DAxisBatchJitDyn(ElementType::bf16, 2)), + ::testing::Values(ElementType::bf16), + ::testing::ValuesIn(isAxisConst), + ::testing::ValuesIn(getCPUInfo()), + ::testing::Values(additionalConfig[0])), + GatherLayerTestCPU::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_dynamic_4D_jit8, + GatherLayerTestCPU, + ::testing::Combine(::testing::ValuesIn(get4DShapesJitDyn(2)), + ::testing::ValuesIn(get4DAxisBatchJitDyn(ElementType::i8, 2)), + ::testing::Values(ElementType::i8), + ::testing::ValuesIn(isAxisConst), + ::testing::ValuesIn(getCPUInfo()), + ::testing::Values(additionalConfig[0])), + GatherLayerTestCPU::getTestCaseName); // batchDims == indicesRank -INSTANTIATE_TEST_SUITE_P(smoke_dynamic_4D_jit32_Bmax, GatherLayerTestCPU, - ::testing::Combine( - ::testing::ValuesIn(get4DShapesJitDyn(3)), - ::testing::ValuesIn(get4DAxisBatchJitDyn(ElementType::f32, 3)), - ::testing::Values(ElementType::f32), - ::testing::ValuesIn(isAxisConst), - ::testing::ValuesIn(getCPUInfo()), - ::testing::ValuesIn(additionalConfig)), - GatherLayerTestCPU::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_dynamic_4D_jit16_Bmax, GatherLayerTestCPU, - ::testing::Combine( - ::testing::ValuesIn(get4DShapesJitDyn(3)), - ::testing::ValuesIn(get4DAxisBatchJitDyn(ElementType::bf16, 3)), - ::testing::Values(ElementType::bf16), - ::testing::ValuesIn(isAxisConst), - ::testing::ValuesIn(getCPUInfo()), - ::testing::Values(additionalConfig[0])), - GatherLayerTestCPU::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_dynamic_4D_jit8_Bmax, GatherLayerTestCPU, - ::testing::Combine( - ::testing::ValuesIn(get4DShapesJitDyn(3)), - ::testing::ValuesIn(get4DAxisBatchJitDyn(ElementType::i8, 3)), - ::testing::Values(ElementType::i8), - ::testing::ValuesIn(isAxisConst), - ::testing::ValuesIn(getCPUInfo()), - ::testing::Values(additionalConfig[0])), - GatherLayerTestCPU::getTestCaseName); - +INSTANTIATE_TEST_SUITE_P(smoke_dynamic_4D_jit32_Bmax, + GatherLayerTestCPU, + ::testing::Combine(::testing::ValuesIn(get4DShapesJitDyn(3)), + ::testing::ValuesIn(get4DAxisBatchJitDyn(ElementType::f32, 3)), + ::testing::Values(ElementType::f32), + ::testing::ValuesIn(isAxisConst), + ::testing::ValuesIn(getCPUInfo()), + ::testing::ValuesIn(additionalConfig)), + GatherLayerTestCPU::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_dynamic_4D_jit16_Bmax, + GatherLayerTestCPU, + ::testing::Combine(::testing::ValuesIn(get4DShapesJitDyn(3)), + ::testing::ValuesIn(get4DAxisBatchJitDyn(ElementType::bf16, 3)), + ::testing::Values(ElementType::bf16), + ::testing::ValuesIn(isAxisConst), + ::testing::ValuesIn(getCPUInfo()), + ::testing::Values(additionalConfig[0])), + GatherLayerTestCPU::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_dynamic_4D_jit8_Bmax, + GatherLayerTestCPU, + ::testing::Combine(::testing::ValuesIn(get4DShapesJitDyn(3)), + ::testing::ValuesIn(get4DAxisBatchJitDyn(ElementType::i8, 3)), + ::testing::Values(ElementType::i8), + ::testing::ValuesIn(isAxisConst), + ::testing::ValuesIn(getCPUInfo()), + ::testing::Values(additionalConfig[0])), + GatherLayerTestCPU::getTestCaseName); ///// 4D REFERENCE ///// std::vector> get4DShapesRefStat(bool maxBatchDims) { std::vector> result = {}; - if (InferenceEngine::with_cpu_x86_avx2()) { + if (ov::with_cpu_x86_avx2()) { if (!maxBatchDims) { - result = { - { { {}, { {10, 2, 9, 9} } }, // Static shapes - { {}, { {10, 2, 8} } } - }, - { { {}, { {11, 2, 9, 2} } }, // Static shapes - { {}, { {11, 2, 7} } } - }, - { { {}, { {12, 2, 9, 3} } }, // Static shapes - { {}, { {12, 2, 6} } } - }, - { { {}, { {13, 2, 9, 4} } }, // Static shapes - { {}, { {13, 2, 5} } } - }, - { { {}, { {14, 2, 9, 5} } }, // Static shapes - { {}, { {14, 2, 4} } } - }, - { { {}, { {15, 2, 9, 6} } }, // Static shapes - { {}, { {15, 2, 3} } } - }, - { { {}, { {16, 2, 9, 7} } }, // Static shapes - { {}, { {16, 2, 2} } } - }, - { { {}, { {17, 2, 9, 8} } }, // Static shapes - { {}, { {17, 2, 1} } } - } - }; + result = {{{{}, {{10, 2, 9, 9}}}, // Static shapes + {{}, {{10, 2, 8}}}}, + {{{}, {{11, 2, 9, 2}}}, // Static shapes + {{}, {{11, 2, 7}}}}, + {{{}, {{12, 2, 9, 3}}}, // Static shapes + {{}, {{12, 2, 6}}}}, + {{{}, {{13, 2, 9, 4}}}, // Static shapes + {{}, {{13, 2, 5}}}}, + {{{}, {{14, 2, 9, 5}}}, // Static shapes + {{}, {{14, 2, 4}}}}, + {{{}, {{15, 2, 9, 6}}}, // Static shapes + {{}, {{15, 2, 3}}}}, + {{{}, {{16, 2, 9, 7}}}, // Static shapes + {{}, {{16, 2, 2}}}}, + {{{}, {{17, 2, 9, 8}}}, // Static shapes + {{}, {{17, 2, 1}}}}}; } else { - result = { - { { {}, { {10, 8, 2, 39} } }, // Static shapes - { {}, { {10, 8} } } - }, - { { {}, { {11, 7, 2, 42} } }, // Static shapes - { {}, { {11, 7} } } - }, - { { {}, { {12, 6, 2, 43} } }, // Static shapes - { {}, { {12, 6} } } - }, - { { {}, { {13, 5, 2, 44} } }, // Static shapes - { {}, { {13, 5} } } - }, - { { {}, { {14, 4, 2, 45} } }, // Static shapes - { {}, { {14, 4} } } - }, - { { {}, { {15, 3, 2, 46} } }, // Static shapes - { {}, { {15, 3} } } - }, - { { {}, { {16, 2, 2, 47} } }, // Static shapes - { {}, { {16, 2} } } - }, - { { {}, { {17, 1, 2, 38} } }, // Static shapes - { {}, { {17, 1} } } - } - }; + result = {{{{}, {{10, 8, 2, 39}}}, // Static shapes + {{}, {{10, 8}}}}, + {{{}, {{11, 7, 2, 42}}}, // Static shapes + {{}, {{11, 7}}}}, + {{{}, {{12, 6, 2, 43}}}, // Static shapes + {{}, {{12, 6}}}}, + {{{}, {{13, 5, 2, 44}}}, // Static shapes + {{}, {{13, 5}}}}, + {{{}, {{14, 4, 2, 45}}}, // Static shapes + {{}, {{14, 4}}}}, + {{{}, {{15, 3, 2, 46}}}, // Static shapes + {{}, {{15, 3}}}}, + {{{}, {{16, 2, 2, 47}}}, // Static shapes + {{}, {{16, 2}}}}, + {{{}, {{17, 1, 2, 38}}}, // Static shapes + {{}, {{17, 1}}}}}; } } - if (InferenceEngine::with_cpu_x86_avx512f()) { + if (ov::with_cpu_x86_avx512f()) { std::vector> tmp; if (!maxBatchDims) { - tmp = { - { { {}, { {25, 4, 4, 17} } }, // Static shapes - { {}, { {25, 4, 16} } } - }, - { { {}, { {24, 4, 4, 18} } }, // Static shapes - { {}, { {24, 4, 15} } }, - }, - { { {}, { {23, 4, 4, 19} } }, // Static shapes - { {}, { {23, 4, 14} } } - }, - { { {}, { {22, 4, 4, 20} } }, // Static shapes - { {}, { {22, 4, 13} } }, - }, - { { {}, { {21, 4, 4, 21} } }, // Static shapes - { {}, { {21, 4, 12} } }, - }, - { { {}, { {20, 4, 4, 22} } }, // Static shapes - { {}, { {20, 4, 11} } }, - }, - { { {}, { {19, 4, 4, 23} } }, // Static shapes - { {}, { {19, 4, 10} } }, - }, - { { {}, { {18, 4, 4, 24} } }, // Static shapes - { {}, { {18, 4, 9} } }, - } - }; + tmp = {{{{}, {{25, 4, 4, 17}}}, // Static shapes + {{}, {{25, 4, 16}}}}, + { + {{}, {{24, 4, 4, 18}}}, // Static shapes + {{}, {{24, 4, 15}}}, + }, + {{{}, {{23, 4, 4, 19}}}, // Static shapes + {{}, {{23, 4, 14}}}}, + { + {{}, {{22, 4, 4, 20}}}, // Static shapes + {{}, {{22, 4, 13}}}, + }, + { + {{}, {{21, 4, 4, 21}}}, // Static shapes + {{}, {{21, 4, 12}}}, + }, + { + {{}, {{20, 4, 4, 22}}}, // Static shapes + {{}, {{20, 4, 11}}}, + }, + { + {{}, {{19, 4, 4, 23}}}, // Static shapes + {{}, {{19, 4, 10}}}, + }, + { + {{}, {{18, 4, 4, 24}}}, // Static shapes + {{}, {{18, 4, 9}}}, + }}; } else { - tmp = { - { { {}, { {25, 16, 4, 65} } }, // Static shapes - { {}, { {25, 16} } } - }, - { { {}, { {24, 15, 4, 66} } }, // Static shapes - { {}, { {24, 15} } }, - }, - { { {}, { {23, 14, 4, 67} } }, // Static shapes - { {}, { {23, 14} } } - }, - { { {}, { {22, 13, 4, 68} } }, // Static shapes - { {}, { {22, 13} } }, - }, - { { {}, { {21, 12, 4, 69} } }, // Static shapes - { {}, { {21, 12} } }, - }, - { { {}, { {20, 11, 4, 70} } }, // Static shapes - { {}, { {20, 11} } }, - }, - { { {}, { {19, 10, 4, 71} } }, // Static shapes - { {}, { {19, 10} } }, - }, - { { {}, { {18, 9, 4, 72} } }, // Static shapes - { {}, { {18, 9} } }, - } - }; + tmp = {{{{}, {{25, 16, 4, 65}}}, // Static shapes + {{}, {{25, 16}}}}, + { + {{}, {{24, 15, 4, 66}}}, // Static shapes + {{}, {{24, 15}}}, + }, + {{{}, {{23, 14, 4, 67}}}, // Static shapes + {{}, {{23, 14}}}}, + { + {{}, {{22, 13, 4, 68}}}, // Static shapes + {{}, {{22, 13}}}, + }, + { + {{}, {{21, 12, 4, 69}}}, // Static shapes + {{}, {{21, 12}}}, + }, + { + {{}, {{20, 11, 4, 70}}}, // Static shapes + {{}, {{20, 11}}}, + }, + { + {{}, {{19, 10, 4, 71}}}, // Static shapes + {{}, {{19, 10}}}, + }, + { + {{}, {{18, 9, 4, 72}}}, // Static shapes + {{}, {{18, 9}}}, + }}; } result.insert(result.end(), tmp.begin(), tmp.end()); } @@ -830,7 +786,7 @@ std::vector> get4DShapesRefStat(bool maxBatchD std::vector> get4DAxisBatchRefStat(ov::element::Type type, bool maxBatchDims) { std::vector> result = {}; - if (InferenceEngine::with_cpu_x86_avx512f()) { + if (ov::with_cpu_x86_avx512f()) { if (type.size() == 4) { if (!maxBatchDims) return std::vector>{{1, 0}, {1, 1}, {0, 0}}; @@ -842,7 +798,7 @@ std::vector> get4DAxisBatchRefStat(ov::element::Type type, else return std::vector>{{2, 2}}; } - } else if (InferenceEngine::with_cpu_x86_avx2()) { + } else if (ov::with_cpu_x86_avx2()) { if (type.size() == 4) { if (!maxBatchDims) return std::vector>{{1, 0}, {1, 1}, {0, 0}}; @@ -858,105 +814,106 @@ std::vector> get4DAxisBatchRefStat(ov::element::Type type, return {}; } -INSTANTIATE_TEST_SUITE_P(smoke_static_4D_ref32, GatherLayerTestCPU, - ::testing::Combine( - ::testing::ValuesIn(get4DShapesRefStat(false)), - ::testing::ValuesIn(get4DAxisBatchRefStat(ElementType::f32, false)), - ::testing::Values(ElementType::f32), - ::testing::Values(true), - ::testing::Values(cpuParamsRef), - ::testing::ValuesIn(additionalConfig)), - GatherLayerTestCPU::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_static_4D_ref16, GatherLayerTestCPU, - ::testing::Combine( - ::testing::ValuesIn(get4DShapesRefStat(false)), - ::testing::ValuesIn(get4DAxisBatchRefStat(ElementType::bf16, false)), - ::testing::Values(ElementType::bf16), - ::testing::Values(true), - ::testing::Values(cpuParamsRef), - ::testing::Values(additionalConfig[0])), - GatherLayerTestCPU::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_static_4D_ref8, GatherLayerTestCPU, - ::testing::Combine( - ::testing::ValuesIn(get4DShapesRefStat(false)), - ::testing::ValuesIn(get4DAxisBatchRefStat(ElementType::i8, false)), - ::testing::Values(ElementType::i8), - ::testing::Values(true), - ::testing::Values(cpuParamsRef), - ::testing::Values(additionalConfig[0])), - GatherLayerTestCPU::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_static_4D_ref32, + GatherLayerTestCPU, + ::testing::Combine(::testing::ValuesIn(get4DShapesRefStat(false)), + ::testing::ValuesIn(get4DAxisBatchRefStat(ElementType::f32, false)), + ::testing::Values(ElementType::f32), + ::testing::Values(true), + ::testing::Values(cpuParamsRef), + ::testing::ValuesIn(additionalConfig)), + GatherLayerTestCPU::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_static_4D_ref16, + GatherLayerTestCPU, + ::testing::Combine(::testing::ValuesIn(get4DShapesRefStat(false)), + ::testing::ValuesIn(get4DAxisBatchRefStat(ElementType::bf16, false)), + ::testing::Values(ElementType::bf16), + ::testing::Values(true), + ::testing::Values(cpuParamsRef), + ::testing::Values(additionalConfig[0])), + GatherLayerTestCPU::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_static_4D_ref8, + GatherLayerTestCPU, + ::testing::Combine(::testing::ValuesIn(get4DShapesRefStat(false)), + ::testing::ValuesIn(get4DAxisBatchRefStat(ElementType::i8, false)), + ::testing::Values(ElementType::i8), + ::testing::Values(true), + ::testing::Values(cpuParamsRef), + ::testing::Values(additionalConfig[0])), + GatherLayerTestCPU::getTestCaseName); // batchDims == indicesRank -INSTANTIATE_TEST_SUITE_P(smoke_static_4D_ref32_Bmax, GatherLayerTestCPU, - ::testing::Combine( - ::testing::ValuesIn(get4DShapesRefStat(true)), - ::testing::ValuesIn(get4DAxisBatchRefStat(ElementType::f32, true)), - ::testing::Values(ElementType::f32), - ::testing::Values(true), - ::testing::Values(cpuParamsRef), - ::testing::ValuesIn(additionalConfig)), - GatherLayerTestCPU::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_static_4D_ref16_Bmax, GatherLayerTestCPU, - ::testing::Combine( - ::testing::ValuesIn(get4DShapesRefStat(true)), - ::testing::ValuesIn(get4DAxisBatchRefStat(ElementType::bf16, true)), - ::testing::Values(ElementType::bf16), - ::testing::Values(true), - ::testing::Values(cpuParamsRef), - ::testing::Values(additionalConfig[0])), - GatherLayerTestCPU::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_static_4D_ref8_Bmax, GatherLayerTestCPU, - ::testing::Combine( - ::testing::ValuesIn(get4DShapesRefStat(true)), - ::testing::ValuesIn(get4DAxisBatchRefStat(ElementType::i8, true)), - ::testing::Values(ElementType::i8), - ::testing::Values(true), - ::testing::Values(cpuParamsRef), - ::testing::Values(additionalConfig[0])), - GatherLayerTestCPU::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_static_4D_ref32_Bmax, + GatherLayerTestCPU, + ::testing::Combine(::testing::ValuesIn(get4DShapesRefStat(true)), + ::testing::ValuesIn(get4DAxisBatchRefStat(ElementType::f32, true)), + ::testing::Values(ElementType::f32), + ::testing::Values(true), + ::testing::Values(cpuParamsRef), + ::testing::ValuesIn(additionalConfig)), + GatherLayerTestCPU::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_static_4D_ref16_Bmax, + GatherLayerTestCPU, + ::testing::Combine(::testing::ValuesIn(get4DShapesRefStat(true)), + ::testing::ValuesIn(get4DAxisBatchRefStat(ElementType::bf16, true)), + ::testing::Values(ElementType::bf16), + ::testing::Values(true), + ::testing::Values(cpuParamsRef), + ::testing::Values(additionalConfig[0])), + GatherLayerTestCPU::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_static_4D_ref8_Bmax, + GatherLayerTestCPU, + ::testing::Combine(::testing::ValuesIn(get4DShapesRefStat(true)), + ::testing::ValuesIn(get4DAxisBatchRefStat(ElementType::i8, true)), + ::testing::Values(ElementType::i8), + ::testing::Values(true), + ::testing::Values(cpuParamsRef), + ::testing::Values(additionalConfig[0])), + GatherLayerTestCPU::getTestCaseName); // InPlace const std::vector shapesInPlace4D_0 = { - { {}, { {5, 4, 4, 19} } }, - { {5, 4, -1, -1}, { {5, 4, 4, 19}, {5, 4, 4, 25}, {5, 4, 2, 19} } }, + {{}, {{5, 4, 4, 19}}}, + {{5, 4, -1, -1}, {{5, 4, 4, 19}, {5, 4, 4, 25}, {5, 4, 2, 19}}}, }; -INSTANTIATE_TEST_SUITE_P(smoke_inplace_4D_0, GatherInPlaceLayerTestCPU, - ::testing::Combine( - ::testing::ValuesIn(shapesInPlace4D_0), - ::testing::Values(std::vector{ 2 }), - ::testing::Values(0), - ::testing::Values(ElementType::f32), - ::testing::Values(CPUSpecificParams{{}, {}, {}, "unknown"})), - GatherInPlaceLayerTestCPU::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_inplace_4D_0, + GatherInPlaceLayerTestCPU, + ::testing::Combine(::testing::ValuesIn(shapesInPlace4D_0), + ::testing::Values(std::vector{2}), + ::testing::Values(0), + ::testing::Values(ElementType::f32), + ::testing::Values(CPUSpecificParams{{}, {}, {}, "unknown"})), + GatherInPlaceLayerTestCPU::getTestCaseName); const std::vector shapesInPlace4D_1 = { - { {}, { {1, 9, 4, 19} } }, - { {1, 9, -1, -1}, { {1, 9, 4, 19}, {1, 9, 4, 25}, {1, 9, 2, 19} } }, + {{}, {{1, 9, 4, 19}}}, + {{1, 9, -1, -1}, {{1, 9, 4, 19}, {1, 9, 4, 25}, {1, 9, 2, 19}}}, }; -INSTANTIATE_TEST_SUITE_P(smoke_inplace_4D_1, GatherInPlaceLayerTestCPU, - ::testing::Combine( - ::testing::ValuesIn(shapesInPlace4D_1), - ::testing::Values(std::vector{ -4 }, std::vector{ 5 }), - ::testing::Values(1), - ::testing::Values(ElementType::f32), - ::testing::Values(CPUSpecificParams{{}, {}, {}, "unknown"})), - GatherInPlaceLayerTestCPU::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_4D_out_of_range, GatherInPlaceLayerTestCPU, - ::testing::Combine( - ::testing::ValuesIn(shapesInPlace4D_1), - ::testing::Values(std::vector{ 10 }, std::vector{ -15 }), - ::testing::Values(1), - ::testing::Values(ElementType::f32), - ::testing::Values(CPUSpecificParams{{}, {}, {}, "ref_any"})), - GatherInPlaceLayerTestCPU::getTestCaseName); - -} // namespace -} // namespace CPULayerTestsDefinitions +INSTANTIATE_TEST_SUITE_P(smoke_inplace_4D_1, + GatherInPlaceLayerTestCPU, + ::testing::Combine(::testing::ValuesIn(shapesInPlace4D_1), + ::testing::Values(std::vector{-4}, std::vector{5}), + ::testing::Values(1), + ::testing::Values(ElementType::f32), + ::testing::Values(CPUSpecificParams{{}, {}, {}, "unknown"})), + GatherInPlaceLayerTestCPU::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_4D_out_of_range, + GatherInPlaceLayerTestCPU, + ::testing::Combine(::testing::ValuesIn(shapesInPlace4D_1), + ::testing::Values(std::vector{10}, std::vector{-15}), + ::testing::Values(1), + ::testing::Values(ElementType::f32), + ::testing::Values(CPUSpecificParams{{}, {}, {}, "ref_any"})), + GatherInPlaceLayerTestCPU::getTestCaseName); + +} // namespace +} // namespace test +} // namespace ov diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/gather_elements.cpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/gather_elements.cpp index 1edc0146f2328f..428a22f4051b46 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/gather_elements.cpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/gather_elements.cpp @@ -2,34 +2,26 @@ // SPDX-License-Identifier: Apache-2.0 // +#include "common_test_utils/ov_tensor_utils.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include "ov_models/builders.hpp" -#include #include "test_utils/cpu_test_utils.hpp" -using namespace ov::test; -using namespace ngraph; using namespace CPUTestUtils; -using namespace InferenceEngine; -using namespace ngraph::helpers; -namespace CPULayerTestsDefinitions { +namespace ov { +namespace test { +using GatherElementsParams = std::tuple, // Dynamic shape + Target static shapes + int, // Axis + ElementType, // Data precision + ElementType, // Indices precision + TargetDevice // Device name + >; -using GatherElementsParams = std::tuple< - std::vector, // Dynamic shape + Target static shapes - int, // Axis - ElementType, // Data precision - ElementType, // Indices precision - TargetDevice // Device name ->; - -using GatherElementsCPUTestParamSet = std::tuple< - GatherElementsParams, - CPUSpecificParams ->; +using GatherElementsCPUTestParamSet = std::tuple; class GatherElementsCPUTest : public testing::WithParamInterface, - virtual public ov::test::SubgraphBaseTest, public CPUTestsBase { + virtual public ov::test::SubgraphBaseTest, + public CPUTestsBase { public: static std::string getTestCaseNameCommon(const testing::TestParamInfo& obj) { std::vector shapes; @@ -57,7 +49,7 @@ class GatherElementsCPUTest : public testing::WithParamInterface &obj) { + static std::string getTestCaseName(const testing::TestParamInfo& obj) { GatherElementsParams basicParamsSet; CPUSpecificParams cpuParams; std::tie(basicParamsSet, cpuParams) = obj.param; @@ -70,14 +62,18 @@ class GatherElementsCPUTest : public testing::WithParamInterface& targetInputStaticShapes) override { + 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; - tensor = ov::test::utils::create_and_fill_tensor(funcInput.get_element_type(), targetInputStaticShapes[i], 15, 0, 32768); + tensor = ov::test::utils::create_and_fill_tensor(funcInput.get_element_type(), + targetInputStaticShapes[i], + 15, + 0, + 32768); inputs.insert({funcInput.get_node_shared_ptr(), tensor}); } @@ -98,13 +94,12 @@ class GatherElementsCPUTest : public testing::WithParamInterface(dPrecision, inputDynamicShapes[0]), - std::make_shared(iPrecision, inputDynamicShapes[1]), + ov::ParameterVector params = { + std::make_shared(dPrecision, inputDynamicShapes[0]), + std::make_shared(iPrecision, inputDynamicShapes[1]), }; - auto gather = std::make_shared( - params[0], params[1], axis); + auto gather = std::make_shared(params[0], params[1], axis); function = makeNgraphFunction(dPrecision, params, gather, "GatherElements"); } }; @@ -114,27 +109,24 @@ TEST_P(GatherElementsCPUTest, CompareWithRefs) { } namespace { -std::vector cpuParams_4D = { - CPUSpecificParams({nchw}, {nchw}, {}, {}) -}; +std::vector cpuParams_4D = {CPUSpecificParams({nchw}, {nchw}, {}, {})}; const std::vector> inDynamicShapeParams = { - {{{-1, -1, -1, -1}, {{2, 3, 5, 7}, {3, 4, 6, 8}}}, - {{-1, -1, -1, -1}, {{2, 3, 9, 7}, {3, 4, 4, 8}}}}, + {{{-1, -1, -1, -1}, {{2, 3, 5, 7}, {3, 4, 6, 8}}}, {{-1, -1, -1, -1}, {{2, 3, 9, 7}, {3, 4, 4, 8}}}}, {{{{1, 10}, {1, 10}, {1, 10}, {1, 10}}, {{3, 4, 6, 8}, {2, 3, 5, 7}}}, - {{{1, 10}, {1, 10}, {1, 10}, {1, 10}}, {{3, 4, 4, 8}, {2, 3, 9, 7}}}} -}; - -INSTANTIATE_TEST_SUITE_P(smoke_set1, GatherElementsCPUTest, - ::testing::Combine( - ::testing::Combine( - ::testing::ValuesIn(inDynamicShapeParams), // shape - ::testing::ValuesIn(std::vector({2, -2})), // Axis - ::testing::ValuesIn(std::vector({ElementType::bf16, ElementType::f32})), - ::testing::Values(ElementType::i32), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - ::testing::ValuesIn(filterCPUSpecificParams(cpuParams_4D))), - GatherElementsCPUTest::getTestCaseName); - -} // namespace -} // namespace CPULayerTestsDefinitions + {{{1, 10}, {1, 10}, {1, 10}, {1, 10}}, {{3, 4, 4, 8}, {2, 3, 9, 7}}}}}; + +INSTANTIATE_TEST_SUITE_P(smoke_set1, + GatherElementsCPUTest, + ::testing::Combine(::testing::Combine(::testing::ValuesIn(inDynamicShapeParams), // shape + ::testing::ValuesIn(std::vector({2, -2})), // Axis + ::testing::ValuesIn(std::vector( + {ElementType::bf16, ElementType::f32})), + ::testing::Values(ElementType::i32), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::ValuesIn(filterCPUSpecificParams(cpuParams_4D))), + GatherElementsCPUTest::getTestCaseName); + +} // namespace +} // namespace test +} // namespace ov diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/gather_nd.cpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/gather_nd.cpp index 01ba342722e2e6..ff74784ee773c0 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/gather_nd.cpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/gather_nd.cpp @@ -2,23 +2,17 @@ // SPDX-License-Identifier: Apache-2.0 // -#include #include "shared_test_classes/base/ov_subgraph.hpp" -#include "ov_models/builders.hpp" -using namespace InferenceEngine; -using namespace ov; -using namespace test; +namespace ov { +namespace test { -namespace CPULayerTestsDefinitions { - -using GatherNDLayerCPUTestParamSet = std::tuple< - InputShape, // Input shapes - std::pair>, // Indexes shape and values - ElementType, // Input element type - ElementType, // Indices element type - int // Batch dims ->; +using GatherNDLayerCPUTestParamSet = std::tuple>, // Indexes shape and values + ElementType, // Input element type + ElementType, // Indices element type + int // Batch dims + >; class GatherNDLayerCPUTest : public testing::WithParamInterface, virtual public SubgraphBaseTest { @@ -42,7 +36,7 @@ class GatherNDLayerCPUTest : public testing::WithParamInterface(dataElementType, shape)); } - auto indexes_node = ngraph::opset3::Constant::create(idxElementType, indexes.first, indexes.second); - auto gather_nd = std::make_shared(params[0], indexes_node, batchDims); - ngraph::ResultVector results{std::make_shared(gather_nd)}; - function = std::make_shared(results, params, "gatherND"); + auto indexes_node = ov::op::v0::Constant::create(idxElementType, indexes.first, indexes.second); + auto gather_nd = std::make_shared(params[0], indexes_node, batchDims); + ov::ResultVector results{std::make_shared(gather_nd)}; + function = std::make_shared(results, params, "gatherND"); } }; @@ -88,10 +82,10 @@ class GatherND8LayerCPUTest : public testing::WithParamInterface(dataElementType, shape)); } - auto indexes_node = ngraph::opset3::Constant::create(idxElementType, indexes.first, indexes.second); - auto gather_nd = std::make_shared(params[0], indexes_node, batchDims); - ngraph::ResultVector results{std::make_shared(gather_nd)}; - function = std::make_shared(results, params, "gatherND"); + auto indexes_node = ov::op::v0::Constant::create(idxElementType, indexes.first, indexes.second); + auto gather_nd = std::make_shared(params[0], indexes_node, batchDims); + ov::ResultVector results{std::make_shared(gather_nd)}; + function = std::make_shared(results, params, "gatherND"); } }; @@ -105,91 +99,100 @@ TEST_P(GatherND8LayerCPUTest, CompareWithRefs) { namespace { -const std::vector inputPrecisions = { - ElementType::f32, - ElementType::bf16, - ElementType::i8 -}; +const std::vector inputPrecisions = {ElementType::f32, ElementType::bf16, ElementType::i8}; -const std::vector indexesPrecisions = { - ElementType::i32 -}; +const std::vector indexesPrecisions = {ElementType::i32}; const std::vector inputShapesDynamicBD_0 = { - {{-1, -1, -1}, // dynamic - {{5, 10, 5}, {4, 12, 4}, {4, 12, 4}, {5, 5, 5}}}, // target + {{-1, -1, -1}, // dynamic + {{5, 10, 5}, {4, 12, 4}, {4, 12, 4}, {5, 5, 5}}}, // target - {{-1, 5, -1, -1}, // dynamic - {{8, 5, 5, 5}, {5, 5, 8, 4}, {4, 5, 4, 5}}}, // target + {{-1, 5, -1, -1}, // dynamic + {{8, 5, 5, 5}, {5, 5, 8, 4}, {4, 5, 4, 5}}}, // target - {{{4, 10}, {5, 10}, {5, 10}, {5, 10}, {5, 10}}, // dynamic - {{4, 5, 5, 5, 5}, {4, 5, 5, 8, 5}, {10, 8, 5, 5, 5}}}, // target + {{{4, 10}, {5, 10}, {5, 10}, {5, 10}, {5, 10}}, // dynamic + {{4, 5, 5, 5, 5}, {4, 5, 5, 8, 5}, {10, 8, 5, 5, 5}}}, // target }; const std::vector>> indexesShapesBD_0 = { - std::pair>{{2, 2}, {3, 3, 2, 1}}, - std::pair>{{1, 2, 3}, {0, 1, 1, 1, 0, 2}}, - std::pair>{{2, 1, 1, 2}, {0, 2, 1, 1}}, + std::pair>{{2, 2}, {3, 3, 2, 1}}, + std::pair>{{1, 2, 3}, {0, 1, 1, 1, 0, 2}}, + std::pair>{{2, 1, 1, 2}, {0, 2, 1, 1}}, }; -const auto subset_BD0 = ::testing::Combine( - ::testing::ValuesIn(inputShapesDynamicBD_0), - ::testing::ValuesIn(indexesShapesBD_0), - ::testing::ValuesIn(inputPrecisions), - ::testing::ValuesIn(indexesPrecisions), - ::testing::Values(0)); - -INSTANTIATE_TEST_SUITE_P(smoke_GatherND5DynamicBD_0, GatherNDLayerCPUTest, subset_BD0, GatherNDLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_SUITE_P(smoke_GatherND8DynamicBD_0, GatherND8LayerCPUTest, subset_BD0, GatherNDLayerCPUTest::getTestCaseName); +const auto subset_BD0 = ::testing::Combine(::testing::ValuesIn(inputShapesDynamicBD_0), + ::testing::ValuesIn(indexesShapesBD_0), + ::testing::ValuesIn(inputPrecisions), + ::testing::ValuesIn(indexesPrecisions), + ::testing::Values(0)); + +INSTANTIATE_TEST_SUITE_P(smoke_GatherND5DynamicBD_0, + GatherNDLayerCPUTest, + subset_BD0, + GatherNDLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_GatherND8DynamicBD_0, + GatherND8LayerCPUTest, + subset_BD0, + GatherNDLayerCPUTest::getTestCaseName); const std::vector inputShapesDynamicBD_1 = { - {{3, -1, -1}, // dynamic - {{3, 10, 5}, {3, 10, 5}, {3, 12, 8}, {3, 8, 8}}}, // target + {{3, -1, -1}, // dynamic + {{3, 10, 5}, {3, 10, 5}, {3, 12, 8}, {3, 8, 8}}}, // target - {{3, {5, 10}, {5, 10}, {5, 10}, {5, 10}}, // dynamic - {{3, 5, 5, 5, 5}, {3, 8, 10, 10, 10}, {3, 8, 6, 8, 7}}}, // target + {{3, {5, 10}, {5, 10}, {5, 10}, {5, 10}}, // dynamic + {{3, 5, 5, 5, 5}, {3, 8, 10, 10, 10}, {3, 8, 6, 8, 7}}}, // target }; const std::vector>> indexesShapesBD_1 = { - std::pair>{{3, 2}, {0, 1, 2, 1, 0, 0}}, - std::pair>{{3, 2, 2}, {0, 1, 1, 1, 0, 2, 0, 1, 1, 1, 0, 2}}, - std::pair>{{3, 1, 1, 2}, {0, 2, 1, 1, 0, 2}}, + std::pair>{{3, 2}, {0, 1, 2, 1, 0, 0}}, + std::pair>{{3, 2, 2}, {0, 1, 1, 1, 0, 2, 0, 1, 1, 1, 0, 2}}, + std::pair>{{3, 1, 1, 2}, {0, 2, 1, 1, 0, 2}}, }; -const auto subset_BD1 = ::testing::Combine( - ::testing::ValuesIn(inputShapesDynamicBD_1), - ::testing::ValuesIn(indexesShapesBD_1), - ::testing::ValuesIn(inputPrecisions), - ::testing::ValuesIn(indexesPrecisions), - ::testing::Values(0)); - -INSTANTIATE_TEST_SUITE_P(smoke_GatherND5DynamicBD_1, GatherNDLayerCPUTest, subset_BD1, GatherNDLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_SUITE_P(smoke_GatherND8DynamicBD_1, GatherND8LayerCPUTest, subset_BD1, GatherNDLayerCPUTest::getTestCaseName); +const auto subset_BD1 = ::testing::Combine(::testing::ValuesIn(inputShapesDynamicBD_1), + ::testing::ValuesIn(indexesShapesBD_1), + ::testing::ValuesIn(inputPrecisions), + ::testing::ValuesIn(indexesPrecisions), + ::testing::Values(0)); + +INSTANTIATE_TEST_SUITE_P(smoke_GatherND5DynamicBD_1, + GatherNDLayerCPUTest, + subset_BD1, + GatherNDLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_GatherND8DynamicBD_1, + GatherND8LayerCPUTest, + subset_BD1, + GatherNDLayerCPUTest::getTestCaseName); const std::vector inputShapesDynamicBD_2 = { - {{2, 2, -1, -1, -1}, // dynamic - {{2, 2, 5, 6, 5}, {2, 2, 2, 3, 3}, {2, 2, 2, 3, 3}, {2, 2, 7, 2, 3}}}, // target + {{2, 2, -1, -1, -1}, // dynamic + {{2, 2, 5, 6, 5}, {2, 2, 2, 3, 3}, {2, 2, 2, 3, 3}, {2, 2, 7, 2, 3}}}, // target - {{2, 2, {5, 10}, {5, 10}, {5, 10}}, // dynamic - {{2, 2, 5, 5, 5}, {2, 2, 10, 10, 5}, {2, 2, 7, 8, 7}}}, // target + {{2, 2, {5, 10}, {5, 10}, {5, 10}}, // dynamic + {{2, 2, 5, 5, 5}, {2, 2, 10, 10, 5}, {2, 2, 7, 8, 7}}}, // target }; const std::vector>> indexesShapesBD_2 = { - std::pair>{{2, 2, 3}, {0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0}}, - std::pair>{{2, 2, 2, 3}, {0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, - 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0}}, + std::pair>{{2, 2, 3}, {0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0}}, + std::pair>{{2, 2, 2, 3}, + {0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0}}, }; -const auto subset_BD2 = ::testing::Combine( - ::testing::ValuesIn(inputShapesDynamicBD_2), - ::testing::ValuesIn(indexesShapesBD_2), - ::testing::ValuesIn(inputPrecisions), - ::testing::ValuesIn(indexesPrecisions), - ::testing::Values(0)); - -INSTANTIATE_TEST_SUITE_P(smoke_GatherND5DynamicBD_2, GatherNDLayerCPUTest, subset_BD2, GatherNDLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_SUITE_P(smoke_GatherND8DynamicBD_2, GatherND8LayerCPUTest, subset_BD2, GatherNDLayerCPUTest::getTestCaseName); - +const auto subset_BD2 = ::testing::Combine(::testing::ValuesIn(inputShapesDynamicBD_2), + ::testing::ValuesIn(indexesShapesBD_2), + ::testing::ValuesIn(inputPrecisions), + ::testing::ValuesIn(indexesPrecisions), + ::testing::Values(0)); + +INSTANTIATE_TEST_SUITE_P(smoke_GatherND5DynamicBD_2, + GatherNDLayerCPUTest, + subset_BD2, + GatherNDLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_GatherND8DynamicBD_2, + GatherND8LayerCPUTest, + subset_BD2, + GatherNDLayerCPUTest::getTestCaseName); } // namespace -} // namespace CPULayerTestsDefinitions +} // namespace test +} // namespace ov diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/gather_tree.cpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/gather_tree.cpp index fbb67606ef2297..2fd23207b0174d 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/gather_tree.cpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/gather_tree.cpp @@ -2,39 +2,35 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "shared_test_classes/base/ov_subgraph.hpp" -#include "ov_models/builders.hpp" -#include "ov_models/utils/ov_helpers.hpp" #include "common_test_utils/ov_tensor_utils.hpp" +#include "ov_models/builders.hpp" +#include "shared_test_classes/base/ov_subgraph.hpp" #include "test_utils/cpu_test_utils.hpp" -namespace CPULayerTestsDefinitions { - -using namespace ov::test; using namespace CPUTestUtils; -using GatherTreeCPUTestParams = typename std::tuple< - InputShape, // Input tensors shape - ngraph::helpers::InputLayerType, // Secondary input type - ov::element::Type, // Network precision - InferenceEngine::Precision, // Input precision - InferenceEngine::Precision, // Output precision - InferenceEngine::Layout, // Input layout - InferenceEngine::Layout, // Output layout - std::string>; // Device name +namespace ov { +namespace test { + +using GatherTreeCPUTestParams = typename std::tuple; // Device name class GatherTreeLayerCPUTest : public testing::WithParamInterface, - virtual public ov::test::SubgraphBaseTest, public CPUTestsBase { + virtual public ov::test::SubgraphBaseTest, + public CPUTestsBase { public: - static std::string getTestCaseName(const testing::TestParamInfo &obj) { + static std::string getTestCaseName(const testing::TestParamInfo& obj) { InputShape inputShape; ov::element::Type netPrecision; - InferenceEngine::Precision inPrc, outPrc; - InferenceEngine::Layout inLayout, outLayout; - ngraph::helpers::InputLayerType secondaryInputType; + ov::element::Type inPrc, outPrc; + ov::test::utils::InputLayerType secondaryInputType; std::string targetName; - std::tie(inputShape, secondaryInputType, netPrecision, inPrc, outPrc, inLayout, outLayout, targetName) = obj.param; + std::tie(inputShape, secondaryInputType, netPrecision, inPrc, outPrc, targetName) = obj.param; std::ostringstream result; result << "IS=" << ov::test::utils::partialShape2str({inputShape.first}) << "_"; @@ -44,10 +40,8 @@ class GatherTreeLayerCPUTest : public testing::WithParamInterface(paramsIn.front(), inp2, inp3, inp4); + auto operationResult = std::make_shared(paramsIn.front(), inp2, inp3, inp4); - ngraph::ResultVector results{std::make_shared(operationResult)}; - function = std::make_shared(results, paramsIn, "GatherTree"); + ov::ResultVector results{std::make_shared(operationResult)}; + function = std::make_shared(results, paramsIn, "GatherTree"); } - void generate_inputs(const std::vector& targetInputStaticShapes) override { + void generate_inputs(const std::vector& targetInputStaticShapes) override { inputs.clear(); const auto maxBeamIndex = targetInputStaticShapes.front().at(2) - 1; const auto& funcInputs = function->inputs(); for (size_t i = 0; i < funcInputs.size(); ++i) { - auto tensor = - ov::test::utils::create_and_fill_tensor(funcInputs[i].get_element_type(), - targetInputStaticShapes[i], - maxBeamIndex, - (i == 2 || i == 3) ? maxBeamIndex / 2 : 0); + auto tensor = ov::test::utils::create_and_fill_tensor(funcInputs[i].get_element_type(), + targetInputStaticShapes[i], + maxBeamIndex, + (i == 2 || i == 3) ? maxBeamIndex / 2 : 0); inputs.insert({funcInputs[i].get_node_shared_ptr(), tensor}); } } @@ -136,62 +133,56 @@ TEST_P(GatherTreeLayerCPUTest, CompareWithRefs) { namespace { -const std::vector netPrecisions = { - ov::element::f32, - ov::element::i32 -}; - -const std::vector inputStaticShapes = {{{}, {{5, 1, 10}}}, {{}, {{1, 1, 10}}}, - {{}, {{20, 1, 10}}}, {{}, {{20, 20, 10}}}}; - -const std::vector inputDynamicShapesParameter = - {{{-1, 1, -1}, {{7, 1, 10}, {8, 1, 20}}}, {{-1, 1, {5, 10}}, {{2, 1, 7}, {5, 1, 8}}}, - {{-1, {1, 5}, 10}, {{20, 1, 10}, {17, 2, 10}}}, {{-1, -1, -1}, {{20, 20, 15}, {30, 30, 10}}}}; - -const std::vector inputDynamicShapesConstant = - {{{-1, 1, -1}, {{7, 1, 10}}}, {{-1, 1, {5, 10}}, {{2, 1, 7}}}, - {{-1, {1, 5}, 10}, {{20, 1, 10}}}, {{-1, -1, -1}, {{20, 20, 15}}}}; - -const std::vector secondaryInputTypes = { - ngraph::helpers::InputLayerType::CONSTANT, - ngraph::helpers::InputLayerType::PARAMETER -}; - -INSTANTIATE_TEST_SUITE_P(smoke_GatherTreeCPUStatic, GatherTreeLayerCPUTest, - ::testing::Combine( - ::testing::ValuesIn(inputStaticShapes), - ::testing::ValuesIn(secondaryInputTypes), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), - ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), - ::testing::Values(InferenceEngine::Layout::ANY), - ::testing::Values(InferenceEngine::Layout::ANY), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - GatherTreeLayerCPUTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_GatherTreeCPUDynamicParameter, GatherTreeLayerCPUTest, - ::testing::Combine( - ::testing::ValuesIn(inputDynamicShapesParameter), - ::testing::Values(ngraph::helpers::InputLayerType::PARAMETER), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), - ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), - ::testing::Values(InferenceEngine::Layout::ANY), - ::testing::Values(InferenceEngine::Layout::ANY), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - GatherTreeLayerCPUTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_GatherTreeCPUDynamicConstant, GatherTreeLayerCPUTest, - ::testing::Combine( - ::testing::ValuesIn(inputDynamicShapesConstant), - ::testing::Values(ngraph::helpers::InputLayerType::CONSTANT), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), - ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), - ::testing::Values(InferenceEngine::Layout::ANY), - ::testing::Values(InferenceEngine::Layout::ANY), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - GatherTreeLayerCPUTest::getTestCaseName); - -} // namespace -} // namespace CPULayerTestsDefinitions +const std::vector netPrecisions = {ov::element::f32, ov::element::i32}; + +const std::vector inputStaticShapes = {{{}, {{5, 1, 10}}}, + {{}, {{1, 1, 10}}}, + {{}, {{20, 1, 10}}}, + {{}, {{20, 20, 10}}}}; + +const std::vector inputDynamicShapesParameter = {{{-1, 1, -1}, {{7, 1, 10}, {8, 1, 20}}}, + {{-1, 1, {5, 10}}, {{2, 1, 7}, {5, 1, 8}}}, + {{-1, {1, 5}, 10}, {{20, 1, 10}, {17, 2, 10}}}, + {{-1, -1, -1}, {{20, 20, 15}, {30, 30, 10}}}}; + +const std::vector inputDynamicShapesConstant = {{{-1, 1, -1}, {{7, 1, 10}}}, + {{-1, 1, {5, 10}}, {{2, 1, 7}}}, + {{-1, {1, 5}, 10}, {{20, 1, 10}}}, + {{-1, -1, -1}, {{20, 20, 15}}}}; + +const std::vector secondaryInputTypes = {ov::test::utils::InputLayerType::CONSTANT, + ov::test::utils::InputLayerType::PARAMETER}; + +INSTANTIATE_TEST_SUITE_P(smoke_GatherTreeCPUStatic, + GatherTreeLayerCPUTest, + ::testing::Combine(::testing::ValuesIn(inputStaticShapes), + ::testing::ValuesIn(secondaryInputTypes), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(ov::element::undefined), + ::testing::Values(ov::element::undefined), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + GatherTreeLayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_GatherTreeCPUDynamicParameter, + GatherTreeLayerCPUTest, + ::testing::Combine(::testing::ValuesIn(inputDynamicShapesParameter), + ::testing::Values(ov::test::utils::InputLayerType::PARAMETER), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(ov::element::undefined), + ::testing::Values(ov::element::undefined), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + GatherTreeLayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_GatherTreeCPUDynamicConstant, + GatherTreeLayerCPUTest, + ::testing::Combine(::testing::ValuesIn(inputDynamicShapesConstant), + ::testing::Values(ov::test::utils::InputLayerType::CONSTANT), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(ov::element::undefined), + ::testing::Values(ov::element::undefined), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + GatherTreeLayerCPUTest::getTestCaseName); + +} // namespace +} // namespace test +} // namespace ov diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/grid_sample.cpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/grid_sample.cpp index 278c92ed3681a1..bdc1f88bec1bca 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/grid_sample.cpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/grid_sample.cpp @@ -2,60 +2,74 @@ // SPDX-License-Identifier: Apache-2.0 // +#include "common_test_utils/ov_tensor_utils.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include "ov_models/builders.hpp" #include "test_utils/cpu_test_utils.hpp" -#include using namespace CPUTestUtils; -using namespace ov::test; -using ov::op::v9::GridSample; - -namespace CPULayerTestsDefinitions { - -typedef std::tuple< - std::vector, // Input shapes - GridSample::InterpolationMode, // Interpolation mode - GridSample::PaddingMode, // Padding mode - bool, // Align corners - ElementType, // Data precision - ElementType, // Grid precision - CPUSpecificParams, // CPU specific params - std::map // Additional config -> GridSampleLayerTestCPUParams; + +namespace ov { +namespace test { + +typedef std::tuple, // Input shapes + ov::op::v9::GridSample::InterpolationMode, // Interpolation mode + ov::op::v9::GridSample::PaddingMode, // Padding mode + bool, // Align corners + ElementType, // Data precision + ElementType, // Grid precision + CPUSpecificParams, // CPU specific params + ov::AnyMap // Additional config + > + GridSampleLayerTestCPUParams; class GridSampleLayerTestCPU : public testing::WithParamInterface, - virtual public SubgraphBaseTest, public CPUTestsBase { + virtual public SubgraphBaseTest, + public CPUTestsBase { public: static std::string getTestCaseName(testing::TestParamInfo obj) { std::vector inputShapes; - GridSample::InterpolationMode interpolateMode; - GridSample::PaddingMode paddingMode; + ov::op::v9::GridSample::InterpolationMode interpolateMode; + ov::op::v9::GridSample::PaddingMode paddingMode; bool alignCorners; ElementType dataPrecision, gridPrecision; CPUSpecificParams cpuParams; - std::map additionalConfig; + ov::AnyMap additionalConfig; - std::tie(inputShapes, interpolateMode, paddingMode, alignCorners, dataPrecision, gridPrecision, cpuParams, additionalConfig) = obj.param; + std::tie(inputShapes, + interpolateMode, + paddingMode, + alignCorners, + dataPrecision, + gridPrecision, + cpuParams, + 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 << 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 << ov::test::utils::vec2str(inputShapes[j].second[i]) + << (j < inputShapes.size() - 1lu ? "_" : ""); } result << "}_"; } - result << "interpMode=" << (interpolateMode == GridSample::InterpolationMode::BILINEAR ? "BILINEAR" : - interpolateMode == GridSample::InterpolationMode::BICUBIC ? "BICUBIC" : "NEAREST") << "_"; - result << "padMode=" << (paddingMode == GridSample::PaddingMode::ZEROS ? "ZEROS" : - paddingMode == GridSample::PaddingMode::BORDER ? "BORDER" : "REFLECTION") << "_"; + result << "interpMode=" + << (interpolateMode == ov::op::v9::GridSample::InterpolationMode::BILINEAR ? "BILINEAR" + : interpolateMode == ov::op::v9::GridSample::InterpolationMode::BICUBIC ? "BICUBIC" + : "NEAREST") + << "_"; + result << "padMode=" + << (paddingMode == ov::op::v9::GridSample::PaddingMode::ZEROS ? "ZEROS" + : paddingMode == ov::op::v9::GridSample::PaddingMode::BORDER ? "BORDER" + : "REFLECTION") + << "_"; result << "alignCorners=" << (alignCorners ? "True" : "False") << "_"; result << "dataPrc=" << dataPrecision << "_"; result << "gridPrc=" << gridPrecision; @@ -63,9 +77,9 @@ class GridSampleLayerTestCPU : public testing::WithParamInterfaceset_friendly_name("grid"); - GridSample::Attributes attributes = {alignCorners, interpolateMode, paddingMode}; - auto gridSampleNode = std::make_shared(params[0], params[1], attributes); + ov::op::v9::GridSample::Attributes attributes = {alignCorners, interpolateMode, paddingMode}; + auto gridSampleNode = std::make_shared(params[0], params[1], attributes); function = makeNgraphFunction(dataPrecision, params, gridSampleNode, "GridSampleCPU"); } @@ -118,14 +139,23 @@ class GridSampleLayerTestCPU : public testing::WithParamInterfaceget_friendly_name() == "data") { - int32_t range = std::accumulate(targetInputStaticShapes[0].begin(), targetInputStaticShapes[0].end(), 1u, std::multiplies()); - tensor = utils::create_and_fill_tensor( - funcInput.get_element_type(), targetInputStaticShapes[0], range, -range / 2, 1); + int32_t range = std::accumulate(targetInputStaticShapes[0].begin(), + targetInputStaticShapes[0].end(), + 1u, + std::multiplies()); + tensor = utils::create_and_fill_tensor(funcInput.get_element_type(), + targetInputStaticShapes[0], + range, + -range / 2, + 1); } else if (funcInput.get_node()->get_friendly_name() == "grid") { int32_t range = std::max(targetInputStaticShapes[0][2], targetInputStaticShapes[0][3]) + 2; int32_t resolution = range / 2; - tensor = utils::create_and_fill_tensor( - funcInput.get_element_type(), targetInputStaticShapes[1], range, -1, resolution == 0 ? 1 : resolution); + tensor = utils::create_and_fill_tensor(funcInput.get_element_type(), + targetInputStaticShapes[1], + range, + -1, + resolution == 0 ? 1 : resolution); } inputs.insert({funcInput.get_node_shared_ptr(), tensor}); } @@ -139,31 +169,28 @@ TEST_P(GridSampleLayerTestCPU, CompareWithRefs) { namespace { -std::vector> additionalConfig - = {{{InferenceEngine::PluginConfigParams::KEY_ENFORCE_BF16, InferenceEngine::PluginConfigParams::NO}}, - {{InferenceEngine::PluginConfigParams::KEY_ENFORCE_BF16, InferenceEngine::PluginConfigParams::YES}}}; +std::vector additionalConfig = {{{ov::hint::inference_precision(ov::element::f32)}}, + {{ov::hint::inference_precision(ov::element::bf16)}}}; -std::vector interpolateMode { - GridSample::InterpolationMode::BILINEAR, - GridSample::InterpolationMode::BICUBIC, - GridSample::InterpolationMode::NEAREST }; +std::vector interpolateMode{ov::op::v9::GridSample::InterpolationMode::BILINEAR, + ov::op::v9::GridSample::InterpolationMode::BICUBIC, + ov::op::v9::GridSample::InterpolationMode::NEAREST}; -std::vector paddingMode { - GridSample::PaddingMode::ZEROS, - GridSample::PaddingMode::BORDER, - GridSample::PaddingMode::REFLECTION }; +std::vector paddingMode{ov::op::v9::GridSample::PaddingMode::ZEROS, + ov::op::v9::GridSample::PaddingMode::BORDER, + ov::op::v9::GridSample::PaddingMode::REFLECTION}; -std::vector alignCorners { true, false }; +std::vector alignCorners{true, false}; std::vector getCPUInfo() { std::vector resCPUParams; - if (InferenceEngine::with_cpu_x86_avx512f()) { + if (ov::with_cpu_x86_avx512f()) { resCPUParams.push_back(CPUSpecificParams{{}, {}, {"jit_avx512"}, "jit_avx512"}); - } else if (InferenceEngine::with_cpu_x86_avx2()) { + } else if (ov::with_cpu_x86_avx2()) { resCPUParams.push_back(CPUSpecificParams{{}, {}, {"jit_avx2"}, "jit_avx2"}); - } else if (InferenceEngine::with_cpu_x86_avx()) { + } else if (ov::with_cpu_x86_avx()) { resCPUParams.push_back(CPUSpecificParams{{}, {}, {"jit_avx"}, "jit_avx"}); - } else if (InferenceEngine::with_cpu_x86_sse42()) { + } else if (ov::with_cpu_x86_sse42()) { resCPUParams.push_back(CPUSpecificParams{{}, {}, {"jit_sse42"}, "jit_sse42"}); } return resCPUParams; @@ -171,198 +198,180 @@ std::vector getCPUInfo() { std::vector> getStaticShapes() { // SSE42 - std::vector> result = { - { { {}, { {1, 5, 1, 1} } }, // Static shapes - { {}, { {1, 1, 1, 2} } } - }, - { { {}, { {2, 4, 7, 1} } }, // Static shapes - { {}, { {2, 1, 2, 2} } } - }, - { { {}, { {3, 3, 3, 3} } }, // Static shapes - { {}, { {3, 3, 1, 2} } } - }, - { { {}, { {4, 2, 5, 4} } }, // Static shapes - { {}, { {4, 2, 2, 2} } } - }, - { { {}, { {5, 1, 5, 5} } }, // Static shapes - { {}, { {5, 1, 5, 2} } } - }, - { { {}, { {4, 2, 4, 6} } }, // Static shapes - { {}, { {4, 2, 3, 2} } } - }, - { { {}, { {3, 3, 5, 7} } }, // Static shapes - { {}, { {3, 7, 1, 2} } } - }, - { { {}, { {2, 4, 7, 7} } }, // Static shapes - { {}, { {2, 2, 4, 2} } } - }, - { { {}, { {2, 5, 8, 8} } }, // Static shapes - { {}, { {2, 3, 3, 2} } } - }, - { { {}, { {2, 6, 9, 8} } }, // Static shapes - { {}, { {2, 2, 5, 2} } } - } - }; + std::vector> result = {{{{}, {{1, 5, 1, 1}}}, // Static shapes + {{}, {{1, 1, 1, 2}}}}, + {{{}, {{2, 4, 7, 1}}}, // Static shapes + {{}, {{2, 1, 2, 2}}}}, + {{{}, {{3, 3, 3, 3}}}, // Static shapes + {{}, {{3, 3, 1, 2}}}}, + {{{}, {{4, 2, 5, 4}}}, // Static shapes + {{}, {{4, 2, 2, 2}}}}, + {{{}, {{5, 1, 5, 5}}}, // Static shapes + {{}, {{5, 1, 5, 2}}}}, + {{{}, {{4, 2, 4, 6}}}, // Static shapes + {{}, {{4, 2, 3, 2}}}}, + {{{}, {{3, 3, 5, 7}}}, // Static shapes + {{}, {{3, 7, 1, 2}}}}, + {{{}, {{2, 4, 7, 7}}}, // Static shapes + {{}, {{2, 2, 4, 2}}}}, + {{{}, {{2, 5, 8, 8}}}, // Static shapes + {{}, {{2, 3, 3, 2}}}}, + {{{}, {{2, 6, 9, 8}}}, // Static shapes + {{}, {{2, 2, 5, 2}}}}}; // AVX2, AVX - if (InferenceEngine::with_cpu_x86_avx2() || InferenceEngine::with_cpu_x86_avx()) { - std::vector> tmp = { - { { {}, { {1, 7, 5, 3} } }, // Static shapes - { {}, { {1, 1, 11, 2} } } - }, - { { {}, { {2, 6, 7, 2} } }, // Static shapes - { {}, { {2, 6, 2, 2} } } - }, - { { {}, { {3, 5, 6, 3} } }, // Static shapes - { {}, { {3, 1, 13, 2} } } - }, - { { {}, { {4, 4, 5, 6} } }, // Static shapes - { {}, { {4, 2, 7, 2} } } - }, - { { {}, { {5, 3, 4, 5} } }, // Static shapes - { {}, { {5, 3, 5, 2} } } - }, - { { {}, { {4, 2, 7, 6} } }, // Static shapes - { {}, { {4, 4, 4, 2} } } - }, - { { {}, { {3, 3, 9, 7} } }, // Static shapes - { {}, { {3, 1, 17, 2} } } - }, - { { {}, { {2, 4, 9, 8} } }, // Static shapes - { {}, { {2, 19, 1, 2} } } - } - }; + if (ov::with_cpu_x86_avx2() || ov::with_cpu_x86_avx()) { + std::vector> tmp = {{{{}, {{1, 7, 5, 3}}}, // Static shapes + {{}, {{1, 1, 11, 2}}}}, + {{{}, {{2, 6, 7, 2}}}, // Static shapes + {{}, {{2, 6, 2, 2}}}}, + {{{}, {{3, 5, 6, 3}}}, // Static shapes + {{}, {{3, 1, 13, 2}}}}, + {{{}, {{4, 4, 5, 6}}}, // Static shapes + {{}, {{4, 2, 7, 2}}}}, + {{{}, {{5, 3, 4, 5}}}, // Static shapes + {{}, {{5, 3, 5, 2}}}}, + {{{}, {{4, 2, 7, 6}}}, // Static shapes + {{}, {{4, 4, 4, 2}}}}, + {{{}, {{3, 3, 9, 7}}}, // Static shapes + {{}, {{3, 1, 17, 2}}}}, + {{{}, {{2, 4, 9, 8}}}, // Static shapes + {{}, {{2, 19, 1, 2}}}}}; result.insert(result.end(), tmp.begin(), tmp.end()); } // AVX512 - if (InferenceEngine::with_cpu_x86_avx512f()) { - std::vector> tmp = { - { { {}, { {1, 7, 2, 9} } }, // Static shapes - { {}, { {1, 4, 5, 2} } } - }, - { { {}, { {2, 6, 3, 10} } }, // Static shapes - { {}, { {2, 3, 7, 2} } }, - }, - { { {}, { {3, 5, 2, 11} } }, // Static shapes - { {}, { {3, 4, 6, 2} } } - }, - { { {}, { {4, 4, 4, 12} } }, // Static shapes - { {}, { {4, 5, 5, 2} } }, - }, - { { {}, { {5, 3, 2, 13} } }, // Static shapes - { {}, { {5, 1, 31, 2} } }, - }, - { { {}, { {4, 3, 5, 14} } }, // Static shapes - { {}, { {4, 4, 8, 2} } }, - }, - { { {}, { {3, 2, 2, 15} } }, // Static shapes - { {}, { {3, 33, 1, 2} } }, - }, - { { {}, { {2, 1, 6, 16} } }, // Static shapes - { {}, { {2, 8, 8, 2} } }, - }, - { { {}, { {2, 3, 7, 17} } }, // Static shapes - { {}, { {2, 9, 9, 2} } }, - } - }; + if (ov::with_cpu_x86_avx512f()) { + std::vector> tmp = {{{{}, {{1, 7, 2, 9}}}, // Static shapes + {{}, {{1, 4, 5, 2}}}}, + { + {{}, {{2, 6, 3, 10}}}, // Static shapes + {{}, {{2, 3, 7, 2}}}, + }, + {{{}, {{3, 5, 2, 11}}}, // Static shapes + {{}, {{3, 4, 6, 2}}}}, + { + {{}, {{4, 4, 4, 12}}}, // Static shapes + {{}, {{4, 5, 5, 2}}}, + }, + { + {{}, {{5, 3, 2, 13}}}, // Static shapes + {{}, {{5, 1, 31, 2}}}, + }, + { + {{}, {{4, 3, 5, 14}}}, // Static shapes + {{}, {{4, 4, 8, 2}}}, + }, + { + {{}, {{3, 2, 2, 15}}}, // Static shapes + {{}, {{3, 33, 1, 2}}}, + }, + { + {{}, {{2, 1, 6, 16}}}, // Static shapes + {{}, {{2, 8, 8, 2}}}, + }, + { + {{}, {{2, 3, 7, 17}}}, // Static shapes + {{}, {{2, 9, 9, 2}}}, + }}; result.insert(result.end(), tmp.begin(), tmp.end()); } return result; } -INSTANTIATE_TEST_SUITE_P(smoke_static, GridSampleLayerTestCPU, - ::testing::Combine( - ::testing::ValuesIn(getStaticShapes()), - ::testing::ValuesIn(interpolateMode), - ::testing::ValuesIn(paddingMode), - ::testing::ValuesIn(alignCorners), - ::testing::ValuesIn({ElementType::f32, ElementType::i32}), - ::testing::ValuesIn({ElementType::f32}), - ::testing::ValuesIn(getCPUInfo()), - ::testing::Values(additionalConfig[0])), - GridSampleLayerTestCPU::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(nightly_static_1, GridSampleLayerTestCPU, - ::testing::Combine( - ::testing::ValuesIn(getStaticShapes()), - ::testing::ValuesIn(interpolateMode), - ::testing::ValuesIn(paddingMode), - ::testing::ValuesIn(alignCorners), - ::testing::ValuesIn({ElementType::bf16, ElementType::i8}), - ::testing::ValuesIn({ElementType::f32, ElementType::bf16}), - ::testing::ValuesIn(getCPUInfo()), - ::testing::Values(additionalConfig[0])), - GridSampleLayerTestCPU::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(nightly_static_2, GridSampleLayerTestCPU, - ::testing::Combine( - ::testing::ValuesIn(getStaticShapes()), - ::testing::ValuesIn(interpolateMode), - ::testing::ValuesIn(paddingMode), - ::testing::ValuesIn(alignCorners), - ::testing::ValuesIn({ElementType::f32}), - ::testing::ValuesIn({ElementType::bf16}), - ::testing::ValuesIn(getCPUInfo()), - ::testing::Values(additionalConfig[0])), - GridSampleLayerTestCPU::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_static, + GridSampleLayerTestCPU, + ::testing::Combine(::testing::ValuesIn(getStaticShapes()), + ::testing::ValuesIn(interpolateMode), + ::testing::ValuesIn(paddingMode), + ::testing::ValuesIn(alignCorners), + ::testing::ValuesIn({ElementType::f32, ElementType::i32}), + ::testing::ValuesIn({ElementType::f32}), + ::testing::ValuesIn(getCPUInfo()), + ::testing::Values(additionalConfig[0])), + GridSampleLayerTestCPU::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(nightly_static_1, + GridSampleLayerTestCPU, + ::testing::Combine(::testing::ValuesIn(getStaticShapes()), + ::testing::ValuesIn(interpolateMode), + ::testing::ValuesIn(paddingMode), + ::testing::ValuesIn(alignCorners), + ::testing::ValuesIn({ElementType::bf16, ElementType::i8}), + ::testing::ValuesIn({ElementType::f32, ElementType::bf16}), + ::testing::ValuesIn(getCPUInfo()), + ::testing::Values(additionalConfig[0])), + GridSampleLayerTestCPU::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(nightly_static_2, + GridSampleLayerTestCPU, + ::testing::Combine(::testing::ValuesIn(getStaticShapes()), + ::testing::ValuesIn(interpolateMode), + ::testing::ValuesIn(paddingMode), + ::testing::ValuesIn(alignCorners), + ::testing::ValuesIn({ElementType::f32}), + ::testing::ValuesIn({ElementType::bf16}), + ::testing::ValuesIn(getCPUInfo()), + ::testing::Values(additionalConfig[0])), + GridSampleLayerTestCPU::getTestCaseName); const std::vector> dynamicInSapes = { - { { { ov::Dimension(1, 15), -1, -1, -1 }, // Dynamic shape 0 - { {1, 1, 1, 1}, {6, 3, 1, 2}, {4, 5, 3, 1}, {2, 7, 2, 2} } }, // Target shapes - { { ov::Dimension(1, 16), -1, -1, -1 }, // Dynamic shape 1 - { {1, 1, 1, 2}, {6, 2, 2, 2}, {4, 1, 3, 2}, {2, 1, 2, 2} } } }, // Target shapes - { { { -1, -1, -1, -1 }, // Dynamic shape 0 - { {1, 2, 1, 5}, {3, 4, 2, 3}, {5, 6, 7, 1}, {7, 8, 2, 4} } }, // Target shapes - { { -1, -1, -1, 2 }, // Dynamic shape 1 - { {1, 2, 4, 2}, {3, 1, 7, 2}, {5, 2, 3, 2}, {7, 1, 5, 2} } } }, // Target shapes - { { { ov::Dimension(2, 15), -1, -1, -1 }, // Dynamic shape 0 - { {8, 3, 3, 3}, {6, 5, 2, 5}, {4, 7, 1, 11}, {2, 9, 3, 4} } }, // Target shapes - { { -1, 3, 7, 2 }, // Dynamic shape 1 - { {8, 3, 7, 2}, {6, 3, 7, 2}, {4, 3, 7, 2}, {2, 3, 7, 2} } } }, // Target shapes - { { { 3, 4, 4, 5 }, // Dynamic shape 0 - { {3, 4, 4, 5}, {3, 4, 4, 5}, {3, 4, 4, 5}, {3, 4, 4, 5} } }, // Target shapes - { { -1, -1, -1, 2 }, // Dynamic shape 1 - { {3, 3, 4, 2}, {3, 1, 11, 2}, {3, 2, 5, 2}, {3, 3, 3, 2} } } }, // Target shapes - { { { -1, -1, -1, -1 }, // Dynamic shape 0 - { {1, 2, 1, 13}, {3, 4, 7, 2}, {5, 6, 3, 5}, {7, 8, 4, 4} } }, // Target shapes - { { -1, -1, -1, -1 }, // Dynamic shape 1 - { {1, 4, 4, 2}, {3, 3, 5, 2}, {5, 2, 7, 2}, {7, 1, 13, 2} } } }, // Target shapes - { { { -1, -1, -1, -1 }, // Dynamic shape 0 - { {2, 11, 1, 17}, {4, 9, 6, 3}, {6, 7, 7, 3}, {8, 3, 2, 11} } }, // Target shapes - { { -1, -1, -1, 2 }, // Dynamic shape 1 - { {2, 5, 4, 2}, {4, 1, 19, 2}, {6, 6, 3, 2}, {8, 1, 17, 2} } } }, // Target shapes - { { { 3, -1, -1, -1 }, // Dynamic shape 0 - { {3, 2, 1, 23}, {3, 4, 3, 8}, {3, 6, 5, 5}, {3, 8, 31, 1} } }, // Target shapes - { { -1, -1, -1, 2 }, // Dynamic shape 1 - { {3, 31, 1, 2}, {3, 6, 4, 2}, {3, 23, 1, 2}, {3, 11, 2, 2} } } }, // Target shapes - { { { -1, 3, -1, -1 }, // Dynamic shape 0 - { {8, 3, 8, 4}, {6, 3, 33, 1}, {4, 3, 8, 6}, {2, 3, 8, 8} } }, // Target shapes - { { -1, -1, -1, 2 }, // Dynamic shape 1 - { {8, 8, 8, 2}, {6, 8, 7, 2}, {4, 1, 33, 2}, {2, 4, 8, 2} } } } // Target shapes + {{{ov::Dimension(1, 15), -1, -1, -1}, // Dynamic shape 0 + {{1, 1, 1, 1}, {6, 3, 1, 2}, {4, 5, 3, 1}, {2, 7, 2, 2}}}, // Target shapes + {{ov::Dimension(1, 16), -1, -1, -1}, // Dynamic shape 1 + {{1, 1, 1, 2}, {6, 2, 2, 2}, {4, 1, 3, 2}, {2, 1, 2, 2}}}}, // Target shapes + {{{-1, -1, -1, -1}, // Dynamic shape 0 + {{1, 2, 1, 5}, {3, 4, 2, 3}, {5, 6, 7, 1}, {7, 8, 2, 4}}}, // Target shapes + {{-1, -1, -1, 2}, // Dynamic shape 1 + {{1, 2, 4, 2}, {3, 1, 7, 2}, {5, 2, 3, 2}, {7, 1, 5, 2}}}}, // Target shapes + {{{ov::Dimension(2, 15), -1, -1, -1}, // Dynamic shape 0 + {{8, 3, 3, 3}, {6, 5, 2, 5}, {4, 7, 1, 11}, {2, 9, 3, 4}}}, // Target shapes + {{-1, 3, 7, 2}, // Dynamic shape 1 + {{8, 3, 7, 2}, {6, 3, 7, 2}, {4, 3, 7, 2}, {2, 3, 7, 2}}}}, // Target shapes + {{{3, 4, 4, 5}, // Dynamic shape 0 + {{3, 4, 4, 5}, {3, 4, 4, 5}, {3, 4, 4, 5}, {3, 4, 4, 5}}}, // Target shapes + {{-1, -1, -1, 2}, // Dynamic shape 1 + {{3, 3, 4, 2}, {3, 1, 11, 2}, {3, 2, 5, 2}, {3, 3, 3, 2}}}}, // Target shapes + {{{-1, -1, -1, -1}, // Dynamic shape 0 + {{1, 2, 1, 13}, {3, 4, 7, 2}, {5, 6, 3, 5}, {7, 8, 4, 4}}}, // Target shapes + {{-1, -1, -1, -1}, // Dynamic shape 1 + {{1, 4, 4, 2}, {3, 3, 5, 2}, {5, 2, 7, 2}, {7, 1, 13, 2}}}}, // Target shapes + {{{-1, -1, -1, -1}, // Dynamic shape 0 + {{2, 11, 1, 17}, {4, 9, 6, 3}, {6, 7, 7, 3}, {8, 3, 2, 11}}}, // Target shapes + {{-1, -1, -1, 2}, // Dynamic shape 1 + {{2, 5, 4, 2}, {4, 1, 19, 2}, {6, 6, 3, 2}, {8, 1, 17, 2}}}}, // Target shapes + {{{3, -1, -1, -1}, // Dynamic shape 0 + {{3, 2, 1, 23}, {3, 4, 3, 8}, {3, 6, 5, 5}, {3, 8, 31, 1}}}, // Target shapes + {{-1, -1, -1, 2}, // Dynamic shape 1 + {{3, 31, 1, 2}, {3, 6, 4, 2}, {3, 23, 1, 2}, {3, 11, 2, 2}}}}, // Target shapes + {{{-1, 3, -1, -1}, // Dynamic shape 0 + {{8, 3, 8, 4}, {6, 3, 33, 1}, {4, 3, 8, 6}, {2, 3, 8, 8}}}, // Target shapes + {{-1, -1, -1, 2}, // Dynamic shape 1 + {{8, 8, 8, 2}, {6, 8, 7, 2}, {4, 1, 33, 2}, {2, 4, 8, 2}}}} // Target shapes }; -INSTANTIATE_TEST_SUITE_P(smoke_dynamic, GridSampleLayerTestCPU, - ::testing::Combine( - ::testing::ValuesIn(dynamicInSapes), - ::testing::ValuesIn(interpolateMode), - ::testing::ValuesIn(paddingMode), - ::testing::ValuesIn(alignCorners), - ::testing::Values(ElementType::f32), - ::testing::Values(ElementType::f32), - ::testing::ValuesIn(getCPUInfo()), - ::testing::Values(additionalConfig[0])), - GridSampleLayerTestCPU::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(nightly_dynamic, GridSampleLayerTestCPU, - ::testing::Combine( - ::testing::ValuesIn(dynamicInSapes), - ::testing::ValuesIn(interpolateMode), - ::testing::ValuesIn(paddingMode), - ::testing::ValuesIn(alignCorners), - ::testing::ValuesIn({ElementType::bf16, ElementType::i32}), - ::testing::ValuesIn({ElementType::bf16}), - ::testing::ValuesIn(getCPUInfo()), - ::testing::Values(additionalConfig[0])), - GridSampleLayerTestCPU::getTestCaseName); -} // namespace -} // namespace CPULayerTestsDefinitions +INSTANTIATE_TEST_SUITE_P(smoke_dynamic, + GridSampleLayerTestCPU, + ::testing::Combine(::testing::ValuesIn(dynamicInSapes), + ::testing::ValuesIn(interpolateMode), + ::testing::ValuesIn(paddingMode), + ::testing::ValuesIn(alignCorners), + ::testing::Values(ElementType::f32), + ::testing::Values(ElementType::f32), + ::testing::ValuesIn(getCPUInfo()), + ::testing::Values(additionalConfig[0])), + GridSampleLayerTestCPU::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(nightly_dynamic, + GridSampleLayerTestCPU, + ::testing::Combine(::testing::ValuesIn(dynamicInSapes), + ::testing::ValuesIn(interpolateMode), + ::testing::ValuesIn(paddingMode), + ::testing::ValuesIn(alignCorners), + ::testing::ValuesIn({ElementType::bf16, ElementType::i32}), + ::testing::ValuesIn({ElementType::bf16}), + ::testing::ValuesIn(getCPUInfo()), + ::testing::Values(additionalConfig[0])), + GridSampleLayerTestCPU::getTestCaseName); +} // namespace +} // namespace test +} // namespace ov diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/grn.cpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/grn.cpp index 5047d3a615f602..75c93393e69b2e 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/grn.cpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/grn.cpp @@ -2,41 +2,33 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "shared_test_classes/base/ov_subgraph.hpp" #include "ov_models/builders.hpp" +#include "shared_test_classes/base/ov_subgraph.hpp" #include "test_utils/cpu_test_utils.hpp" using namespace CPUTestUtils; -using namespace ov::test; +namespace ov { +namespace test { -namespace CPULayerTestsDefinitions { - -using GRNCPUTestParams = typename std::tuple< - ov::element::Type, // Network precision - InferenceEngine::Precision, // Input precision - InferenceEngine::Precision, // Output precision - InferenceEngine::Layout, // Input layout - InferenceEngine::Layout, // Output layout - InputShape, // Input shape - float, // Bias - std::string>; // Device name +using GRNCPUTestParams = typename std::tuple; // Device name class GRNLayerCPUTest : public testing::WithParamInterface, - virtual public SubgraphBaseTest, public CPUTestsBase { + virtual public SubgraphBaseTest, + public CPUTestsBase { public: static std::string getTestCaseName(testing::TestParamInfo obj) { ov::element::Type netPrecision; - InferenceEngine::Precision inPrc, outPrc; - InferenceEngine::Layout inLayout, outLayout; + ov::element::Type inPrc, outPrc; InputShape inputShape; float bias; std::string targetDevice; - std::tie(netPrecision, inPrc, outPrc, - inLayout, outLayout, - inputShape, - bias, - targetDevice) = obj.param; + std::tie(netPrecision, inPrc, outPrc, inputShape, bias, targetDevice) = obj.param; std::ostringstream result; result << "IS=" << ov::test::utils::partialShape2str({inputShape.first}) << "_"; @@ -45,11 +37,9 @@ class GRNLayerCPUTest : public testing::WithParamInterface, result << ov::test::utils::vec2str(item) << "_"; } result << "netPRC=" << netPrecision.get_type_name() << "_"; - result << "inPRC=" << inPrc.name() << "_"; - result << "outPRC=" << outPrc.name() << "_"; - result << "inL=" << inLayout << "_"; - result << "outL=" << outLayout << "_"; - result << "bias=" << bias << "_"; + result << "inPRC=" << inPrc.get_type_name() << "_"; + result << "outPRC=" << outPrc.get_type_name() << "_"; + result << "bias=" << bias << "_"; result << "trgDev=" << targetDevice; return result.str(); @@ -58,12 +48,11 @@ class GRNLayerCPUTest : public testing::WithParamInterface, protected: void SetUp() override { ov::element::Type netPrecision; - InferenceEngine::Precision inPrc, outPrc; - InferenceEngine::Layout inLayout, outLayout; + ov::element::Type inPrc, outPrc; InputShape inputShape; float bias; - std::tie(netPrecision, inPrc, outPrc, inLayout, outLayout, inputShape, bias, targetDevice) = GetParam(); + std::tie(netPrecision, inPrc, outPrc, inputShape, bias, targetDevice) = GetParam(); init_input_shapes({inputShape}); @@ -71,9 +60,9 @@ class GRNLayerCPUTest : public testing::WithParamInterface, for (auto&& shape : inputDynamicShapes) paramsIn.push_back(std::make_shared(netPrecision, shape)); - const auto grn = std::make_shared(paramsIn[0], bias); - const ngraph::ResultVector results{std::make_shared(grn)}; - function = std::make_shared(results, paramsIn, "Grn"); + const auto grn = std::make_shared(paramsIn[0], bias); + const ov::ResultVector results{std::make_shared(grn)}; + function = std::make_shared(results, paramsIn, "Grn"); } }; @@ -83,43 +72,36 @@ TEST_P(GRNLayerCPUTest, CompareWithRefs) { namespace { -const std::vector netPrecisions = { - ov::element::bf16, - ov::element::f16, - ov::element::f32 -}; +const std::vector netPrecisions = {ov::element::bf16, ov::element::f16, ov::element::f32}; const std::vector biases = {1e-6f, 0.33f, 1.1f, 2.25f, 100.25f}; const std::vector dataInputStaticShapes = {{{}, {{16, 24}}}, {{}, {{3, 16, 24}}}, {{}, {{1, 3, 30, 30}}}}; -const std::vector dataInputDynamicShapes = - {{{-1, -1}, {{5, 17}, {10, 3}}}, {{3, {10, 12}, -1}, {{3, 12, 25}, {3, 10, 10}}}, - {{2, -1, -1, {5, 10}}, {{2, 17, 20, 7}, {2, 10, 12, 5}}}}; - -INSTANTIATE_TEST_SUITE_P(smoke_GRNCPUStatic, GRNLayerCPUTest, - ::testing::Combine( - ::testing::ValuesIn(netPrecisions), - ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), - ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), - ::testing::Values(InferenceEngine::Layout::ANY), - ::testing::Values(InferenceEngine::Layout::ANY), - ::testing::ValuesIn(dataInputStaticShapes), - ::testing::ValuesIn(biases), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - GRNLayerCPUTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_GRNCPUDynamic, GRNLayerCPUTest, - ::testing::Combine( - ::testing::ValuesIn(netPrecisions), - ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), - ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), - ::testing::Values(InferenceEngine::Layout::ANY), - ::testing::Values(InferenceEngine::Layout::ANY), - ::testing::ValuesIn(dataInputDynamicShapes), - ::testing::ValuesIn(biases), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - GRNLayerCPUTest::getTestCaseName); - -} // namespace -} // namespace CPULayerTestsDefinitions +const std::vector dataInputDynamicShapes = {{{-1, -1}, {{5, 17}, {10, 3}}}, + {{3, {10, 12}, -1}, {{3, 12, 25}, {3, 10, 10}}}, + {{2, -1, -1, {5, 10}}, {{2, 17, 20, 7}, {2, 10, 12, 5}}}}; + +INSTANTIATE_TEST_SUITE_P(smoke_GRNCPUStatic, + GRNLayerCPUTest, + ::testing::Combine(::testing::ValuesIn(netPrecisions), + ::testing::Values(ov::element::undefined), + ::testing::Values(ov::element::undefined), + ::testing::ValuesIn(dataInputStaticShapes), + ::testing::ValuesIn(biases), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + GRNLayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_GRNCPUDynamic, + GRNLayerCPUTest, + ::testing::Combine(::testing::ValuesIn(netPrecisions), + ::testing::Values(ov::element::undefined), + ::testing::Values(ov::element::undefined), + ::testing::ValuesIn(dataInputDynamicShapes), + ::testing::ValuesIn(biases), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + GRNLayerCPUTest::getTestCaseName); + +} // namespace +} // namespace test +} // 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/single_layer_tests/group_convolution_backprop_data.cpp index cfdb4ee8bc06e9..f4220c8d2d4cf6 100755 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/group_convolution_backprop_data.cpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/group_convolution_backprop_data.cpp @@ -901,4 +901,4 @@ INSTANTIATE_TEST_SUITE_P(smoke_GroupDeconv_2D_AutoPadding_FP32, GroupDeconvoluti } // namespace -} // namespace CPULayerTestsDefinitions +} // namespace CPULayerTestsDefinitions \ No newline at end of file diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/gru_cell.cpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/gru_cell.cpp index 94768354adbc6d..495d97e6271940 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/gru_cell.cpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/gru_cell.cpp @@ -2,39 +2,46 @@ // SPDX-License-Identifier: Apache-2.0 // +#include "common_test_utils/node_builders/gru_cell.hpp" + #include "shared_test_classes/base/ov_subgraph.hpp" -#include "ov_models/builders.hpp" #include "test_utils/cpu_test_utils.hpp" using namespace CPUTestUtils; -using namespace ov::test; - -namespace CPULayerTestsDefinitions { - -using GRUCellCpuSpecificParams = typename std::tuple< - std::vector, // Shapes - bool, // Using decompose to sub-ops transformation - std::vector, // Activations - float, // Clip - bool, // Linear before reset - ElementType, // Network precision - CPUSpecificParams, // CPU specific params - std::map // Additional config ->; +namespace ov { +namespace test { + +using GRUCellCpuSpecificParams = typename std::tuple, // Shapes + bool, // Using decompose to sub-ops transformation + std::vector, // Activations + float, // Clip + bool, // Linear before reset + ElementType, // Network precision + CPUSpecificParams, // CPU specific params + ov::AnyMap // Additional config + >; class GRUCellCPUTest : public testing::WithParamInterface, - virtual public ov::test::SubgraphBaseTest, public CPUTestsBase { + virtual public ov::test::SubgraphBaseTest, + public CPUTestsBase { public: - static std::string getTestCaseName(const testing::TestParamInfo &obj) { + static std::string getTestCaseName(const testing::TestParamInfo& obj) { std::vector inputShapes; bool decompose, linearBeforeReset; std::vector activations; float clip = 0.f; ElementType netPrecision; CPUSpecificParams cpuParams; - std::map additionalConfig; + ov::AnyMap additionalConfig; - std::tie(inputShapes, decompose, activations, clip, linearBeforeReset, netPrecision, cpuParams, additionalConfig) = obj.param; + std::tie(inputShapes, + decompose, + activations, + clip, + linearBeforeReset, + netPrecision, + cpuParams, + additionalConfig) = obj.param; std::ostringstream result; result << "IS=("; @@ -50,7 +57,7 @@ class GRUCellCPUTest : public testing::WithParamInterface> additionalConfig - = {{{InferenceEngine::PluginConfigParams::KEY_ENFORCE_BF16, InferenceEngine::PluginConfigParams::NO}}, - {{InferenceEngine::PluginConfigParams::KEY_ENFORCE_BF16, InferenceEngine::PluginConfigParams::YES}}}; +std::vector additionalConfig = {{{ov::hint::inference_precision(ov::element::f32)}}, + {{ov::hint::inference_precision(ov::element::bf16)}}}; CPUSpecificParams cpuParams{{nc, nc}, {nc}, {"ref_any"}, "ref_any"}; @@ -126,64 +142,65 @@ std::vector> activations = {{"sigmoid", "tanh"}}; // oneDNN supports only zero clip std::vector clip = {0.f}; std::vector linearBeforeReset = {true, false}; -std::vector netPrecisions = { ElementType::f32 }; - -const std::vector> staticShapes = { - { { {}, { {1, 1} } }, // Static shapes - { {}, { {1, 1} } } }, - { { {}, { {1, 1} } }, // Static shapes - { {}, { {1, 10} } } }, - { { {}, { {1, 30} } }, // Static shapes - { {}, { {1, 10} } } }, - { { {}, { {1, 30} } }, // Static shapes - { {}, { {1, 1} } } }, - { { {}, { {3, 1} } }, // Static shapes - { {}, { {3, 1} } } }, - { { {}, { {5, 1} } }, // Static shapes - { {}, { {5, 1} } } }, - { { {}, { {5, 30} } }, // Static shapes - { {}, { {5, 10} } } } -}; - -INSTANTIATE_TEST_SUITE_P(smoke_static, GRUCellCPUTest, - ::testing::Combine(::testing::ValuesIn(staticShapes), - ::testing::ValuesIn(shouldDecompose), - ::testing::ValuesIn(activations), - ::testing::ValuesIn(clip), - ::testing::ValuesIn(linearBeforeReset), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(cpuParams), - ::testing::ValuesIn(additionalConfig)), - GRUCellCPUTest::getTestCaseName); +std::vector netPrecisions = {ElementType::f32}; + +const std::vector> staticShapes = {{{{}, {{1, 1}}}, // Static shapes + {{}, {{1, 1}}}}, + {{{}, {{1, 1}}}, // Static shapes + {{}, {{1, 10}}}}, + {{{}, {{1, 30}}}, // Static shapes + {{}, {{1, 10}}}}, + {{{}, {{1, 30}}}, // Static shapes + {{}, {{1, 1}}}}, + {{{}, {{3, 1}}}, // Static shapes + {{}, {{3, 1}}}}, + {{{}, {{5, 1}}}, // Static shapes + {{}, {{5, 1}}}}, + {{{}, {{5, 30}}}, // Static shapes + {{}, {{5, 10}}}}}; + +INSTANTIATE_TEST_SUITE_P(smoke_static, + GRUCellCPUTest, + ::testing::Combine(::testing::ValuesIn(staticShapes), + ::testing::ValuesIn(shouldDecompose), + ::testing::ValuesIn(activations), + ::testing::ValuesIn(clip), + ::testing::ValuesIn(linearBeforeReset), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(cpuParams), + ::testing::ValuesIn(additionalConfig)), + GRUCellCPUTest::getTestCaseName); const std::vector> dynamicShapes = { - { { { {-1}, 1 }, // Dynamic shape 0 - { {1, 1}, {3, 1}, {5, 1} } }, // Target shapes - { { {-1}, 1 }, // Dynamic shape 1 - { {1, 1}, {3, 1}, {5, 1} } } }, // Target shapes - { { { {1, 10}, 30 }, // Dynamic shape 0 - { {2, 30}, {5, 30}, {8, 30} } }, // Target shapes - { { {1, 10}, 10 }, // Dynamic shape 1 - { {2, 10}, {5, 10}, {8, 10} } } }, // Target shapes - { { { {1, 10}, {25, 35} }, // Dynamic shape 0 - { {2, 30}, {5, 30}, {8, 30} } }, // Target shapes - { { {1, 10}, -1 }, // Dynamic shape 1 - { {2, 10}, {5, 10}, {8, 10} } } }, // Target shapes - { { { {1, 10}, {25, 35} }, // Dynamic shape 0 - { {2, 30}, {5, 30}, {8, 30}, {2, 30}, {5, 30}, {8, 30} } }, // Target shapes - { { {1, 10}, -1 }, // Dynamic shape 1 - { {2, 10}, {5, 10}, {8, 10}, {2, 10}, {5, 10}, {8, 10} } } } // Target shapes + {{{{-1}, 1}, // Dynamic shape 0 + {{1, 1}, {3, 1}, {5, 1}}}, // Target shapes + {{{-1}, 1}, // Dynamic shape 1 + {{1, 1}, {3, 1}, {5, 1}}}}, // Target shapes + {{{{1, 10}, 30}, // Dynamic shape 0 + {{2, 30}, {5, 30}, {8, 30}}}, // Target shapes + {{{1, 10}, 10}, // Dynamic shape 1 + {{2, 10}, {5, 10}, {8, 10}}}}, // Target shapes + {{{{1, 10}, {25, 35}}, // Dynamic shape 0 + {{2, 30}, {5, 30}, {8, 30}}}, // Target shapes + {{{1, 10}, -1}, // Dynamic shape 1 + {{2, 10}, {5, 10}, {8, 10}}}}, // Target shapes + {{{{1, 10}, {25, 35}}, // Dynamic shape 0 + {{2, 30}, {5, 30}, {8, 30}, {2, 30}, {5, 30}, {8, 30}}}, // Target shapes + {{{1, 10}, -1}, // Dynamic shape 1 + {{2, 10}, {5, 10}, {8, 10}, {2, 10}, {5, 10}, {8, 10}}}} // Target shapes }; -INSTANTIATE_TEST_SUITE_P(smoke_dynamic, GRUCellCPUTest, - ::testing::Combine(::testing::ValuesIn(dynamicShapes), - ::testing::ValuesIn(shouldDecompose), - ::testing::ValuesIn(activations), - ::testing::ValuesIn(clip), - ::testing::ValuesIn(linearBeforeReset), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(cpuParams), - ::testing::ValuesIn(additionalConfig)), - GRUCellCPUTest::getTestCaseName); -} // namespace -} // namespace CPULayerTestsDefinitions +INSTANTIATE_TEST_SUITE_P(smoke_dynamic, + GRUCellCPUTest, + ::testing::Combine(::testing::ValuesIn(dynamicShapes), + ::testing::ValuesIn(shouldDecompose), + ::testing::ValuesIn(activations), + ::testing::ValuesIn(clip), + ::testing::ValuesIn(linearBeforeReset), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(cpuParams), + ::testing::ValuesIn(additionalConfig)), + GRUCellCPUTest::getTestCaseName); +} // namespace +} // namespace test +} // namespace ov diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/gru_sequence.cpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/gru_sequence.cpp index 60596e8bd697c7..9481f04b8ec9ce 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/gru_sequence.cpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/gru_sequence.cpp @@ -3,43 +3,51 @@ // #include "shared_test_classes/base/ov_subgraph.hpp" -#include "ov_models/builders.hpp" #include "test_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" using namespace CPUTestUtils; -using namespace ov::test; - -namespace CPULayerTestsDefinitions { - -using GRUSequenceCpuSpecificParams = typename std::tuple< - std::vector, // Shapes - ngraph::helpers::SequenceTestsMode, // Pure Sequence or TensorIterator - std::vector, // Activations - float, // Clip - bool, // Linear_before_reset - ov::op::RecurrentSequenceDirection, // Direction - ElementType, // Network precision - CPUSpecificParams, // CPU specific params - std::map // Additional config ->; +namespace ov { +namespace test { + +using GRUSequenceCpuSpecificParams = + typename std::tuple, // Shapes + ov::test::utils::SequenceTestsMode, // Pure Sequence or TensorIterator + std::vector, // Activations + float, // Clip + bool, // Linear_before_reset + ov::op::RecurrentSequenceDirection, // Direction + ElementType, // Network precision + CPUSpecificParams, // CPU specific params + ov::AnyMap // Additional config + >; class GRUSequenceCPUTest : public testing::WithParamInterface, - virtual public ov::test::SubgraphBaseTest, public CPUTestsBase { + virtual public ov::test::SubgraphBaseTest, + public CPUTestsBase { public: - static std::string getTestCaseName(const testing::TestParamInfo &obj) { + static std::string getTestCaseName(const testing::TestParamInfo& obj) { std::vector inputShapes; - ngraph::helpers::SequenceTestsMode seqMode; + ov::test::utils::SequenceTestsMode seqMode; std::vector activations; float clip; bool linearBeforeRest; ov::op::RecurrentSequenceDirection direction; ElementType netPrecision; CPUSpecificParams cpuParams; - std::map additionalConfig; - - std::tie(inputShapes, seqMode, activations, clip, linearBeforeRest, direction, netPrecision, cpuParams, additionalConfig) = obj.param; + ov::AnyMap additionalConfig; + + std::tie(inputShapes, + seqMode, + activations, + clip, + linearBeforeRest, + direction, + netPrecision, + cpuParams, + additionalConfig) = obj.param; std::ostringstream result; result << "IS=("; @@ -55,7 +63,7 @@ class GRUSequenceCPUTest : public testing::WithParamInterface(netPrecision, shape)); } - const size_t batchSize = inputDynamicShapes[0][0].is_static() ? inputDynamicShapes[0][0].get_length() : - inputDynamicShapes[1][0].is_static() ? inputDynamicShapes[1][0].get_length() : - inputDynamicShapes.size() > 2 && inputDynamicShapes[2][0].is_static() ? inputDynamicShapes[2][0].get_length() : - 1lu; + const size_t batchSize = inputDynamicShapes[0][0].is_static() ? inputDynamicShapes[0][0].get_length() + : inputDynamicShapes[1][0].is_static() ? inputDynamicShapes[1][0].get_length() + : inputDynamicShapes.size() > 2 && inputDynamicShapes[2][0].is_static() + ? inputDynamicShapes[2][0].get_length() + : 1lu; if (inputDynamicShapes.size() > 2) { if (!inputDynamicShapes[2].is_dynamic() && - seqMode != ngraph::helpers::SequenceTestsMode::CONVERT_TO_TI_MAX_SEQ_LEN_PARAM && - seqMode != ngraph::helpers::SequenceTestsMode::CONVERT_TO_TI_RAND_SEQ_LEN_PARAM) { + seqMode != ov::test::utils::SequenceTestsMode::CONVERT_TO_TI_MAX_SEQ_LEN_PARAM && + seqMode != ov::test::utils::SequenceTestsMode::CONVERT_TO_TI_RAND_SEQ_LEN_PARAM) { params.pop_back(); } else { params[2]->set_element_type(ElementType::i64); @@ -124,25 +142,27 @@ class GRUSequenceCPUTest : public testing::WithParamInterface WRB = {{numDirections, 3 * hiddenSize, inputSize}, {numDirections, 3 * hiddenSize, hiddenSize}, - {numDirections, (linearBeforeReset ? 4 : 3) * hiddenSize}, {batchSize}}; - auto gruSequenceOp = ngraph::builder::makeGRU(paramsOuts, - WRB, - hiddenSize, - activations, - {}, - {}, - clip, - linearBeforeReset, - true, - direction, - seqMode); + paramsOuts.push_back(param); + + std::vector WRB = {{numDirections, 3 * hiddenSize, inputSize}, + {numDirections, 3 * hiddenSize, hiddenSize}, + {numDirections, (linearBeforeReset ? 4 : 3) * hiddenSize}, + {batchSize}}; + auto gruSequenceOp = ov::test::utils::make_gru(paramsOuts, + WRB, + hiddenSize, + activations, + {}, + {}, + clip, + linearBeforeReset, + true, + direction, + seqMode); function = makeNgraphFunction(netPrecision, params, gruSequenceOp, "gruSequenceOp"); - if (seqMode != ngraph::helpers::SequenceTestsMode::PURE_SEQ) { + if (seqMode != ov::test::utils::SequenceTestsMode::PURE_SEQ) { ov::pass::Manager manager; if (direction == ov::op::RecurrentSequenceDirection::BIDIRECTIONAL) manager.register_pass(); @@ -180,180 +200,187 @@ TEST_P(GRUSequenceCPUTest, CompareWithRefs) { namespace { /* CPU PARAMS */ -std::vector> additionalConfig - = {{{InferenceEngine::PluginConfigParams::KEY_ENFORCE_BF16, InferenceEngine::PluginConfigParams::NO}}, - {{InferenceEngine::PluginConfigParams::KEY_ENFORCE_BF16, InferenceEngine::PluginConfigParams::YES}}}; +std::vector additionalConfig = {{{ov::hint::inference_precision(ov::element::f32)}}, + {{ov::hint::inference_precision(ov::element::bf16)}}}; CPUSpecificParams cpuParams{{ntc, tnc}, {ntc, tnc}, {"ref_any"}, "ref_any"}; -CPUSpecificParams cpuParamsBatchSizeOne{{tnc, tnc}, {tnc, tnc}, {"ref_any"}, "ref_any"};; +CPUSpecificParams cpuParamsBatchSizeOne{{tnc, tnc}, {tnc, tnc}, {"ref_any"}, "ref_any"}; -std::vector mode{ngraph::helpers::SequenceTestsMode::PURE_SEQ}; +std::vector mode{ov::test::utils::SequenceTestsMode::PURE_SEQ}; // output values increase rapidly without clip, so use only seq_lengths = 2 std::vector> activations = {{"sigmoid", "tanh"}}; std::vector linearBeforeReset = {true, false}; std::vector clip{0.f}; std::vector direction = {ov::op::RecurrentSequenceDirection::FORWARD}; -std::vector netPrecisions = { ElementType::f32 }; - -const std::vector> staticShapes = { - { { {}, { {10, 2, 10} } }, // #0. Static shapes - { {}, { {10, 1, 1} } }, - { {}, { {10} } } }, - { { {}, { {10, 2, 10} } }, // #1. Static shapes - { {}, { {10, 1, 10} } }, - { {}, { {10} } } }, - { { {}, { {1, 2, 10} } }, // #2. Static shapes - { {}, { {1, 1, 1} } }, - { {}, { {1} } } }, - { { {}, { {1, 2, 10} } }, // #3. Static shapes - { {}, { {1, 1, 10} } }, - { {}, { {1} } } }, - { { {}, { {10, 2, 10} } }, // #4. Static shapes - { {}, { {10, 1, 1} } } }, - { { {}, { {10, 2, 10} } }, // #5. Static shapes - { {}, { {10, 1, 10} } } } -}; - -INSTANTIATE_TEST_SUITE_P(smoke_static, GRUSequenceCPUTest, - ::testing::Combine(::testing::ValuesIn(std::vector>{staticShapes[0], staticShapes[1]}), - ::testing::ValuesIn(mode), - ::testing::ValuesIn(activations), - ::testing::ValuesIn(clip), - ::testing::ValuesIn(linearBeforeReset), - ::testing::ValuesIn(direction), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(cpuParams), - ::testing::Values(std::map{})), - GRUSequenceCPUTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_static_BatchSizeOne, GRUSequenceCPUTest, - ::testing::Combine(::testing::ValuesIn(std::vector>{staticShapes[3]}), - ::testing::ValuesIn(mode), - ::testing::ValuesIn(activations), - ::testing::ValuesIn(clip), - ::testing::ValuesIn(linearBeforeReset), - ::testing::ValuesIn(direction), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(cpuParamsBatchSizeOne), - ::testing::Values(std::map{})), - GRUSequenceCPUTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(nightly_static_bf16, GRUSequenceCPUTest, - ::testing::Combine(::testing::ValuesIn(std::vector>{staticShapes[4], staticShapes[5]}), - ::testing::ValuesIn(mode), - ::testing::ValuesIn(activations), - ::testing::ValuesIn(clip), - ::testing::ValuesIn(linearBeforeReset), - ::testing::ValuesIn(direction), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(cpuParams), - ::testing::Values(additionalConfig[1])), - GRUSequenceCPUTest::getTestCaseName); +std::vector netPrecisions = {ElementType::f32}; + +const std::vector> staticShapes = {{{{}, {{10, 2, 10}}}, // #0. Static shapes + {{}, {{10, 1, 1}}}, + {{}, {{10}}}}, + {{{}, {{10, 2, 10}}}, // #1. Static shapes + {{}, {{10, 1, 10}}}, + {{}, {{10}}}}, + {{{}, {{1, 2, 10}}}, // #2. Static shapes + {{}, {{1, 1, 1}}}, + {{}, {{1}}}}, + {{{}, {{1, 2, 10}}}, // #3. Static shapes + {{}, {{1, 1, 10}}}, + {{}, {{1}}}}, + {{{}, {{10, 2, 10}}}, // #4. Static shapes + {{}, {{10, 1, 1}}}}, + {{{}, {{10, 2, 10}}}, // #5. Static shapes + {{}, {{10, 1, 10}}}}}; + +INSTANTIATE_TEST_SUITE_P(smoke_static, + GRUSequenceCPUTest, + ::testing::Combine(::testing::ValuesIn(std::vector>{staticShapes[0], + staticShapes[1]}), + ::testing::ValuesIn(mode), + ::testing::ValuesIn(activations), + ::testing::ValuesIn(clip), + ::testing::ValuesIn(linearBeforeReset), + ::testing::ValuesIn(direction), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(cpuParams), + ::testing::Values(ov::AnyMap{})), + GRUSequenceCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_static_BatchSizeOne, + GRUSequenceCPUTest, + ::testing::Combine(::testing::ValuesIn(std::vector>{staticShapes[3]}), + ::testing::ValuesIn(mode), + ::testing::ValuesIn(activations), + ::testing::ValuesIn(clip), + ::testing::ValuesIn(linearBeforeReset), + ::testing::ValuesIn(direction), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(cpuParamsBatchSizeOne), + ::testing::Values(ov::AnyMap{})), + GRUSequenceCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(nightly_static_bf16, + GRUSequenceCPUTest, + ::testing::Combine(::testing::ValuesIn(std::vector>{staticShapes[4], + staticShapes[5]}), + ::testing::ValuesIn(mode), + ::testing::ValuesIn(activations), + ::testing::ValuesIn(clip), + ::testing::ValuesIn(linearBeforeReset), + ::testing::ValuesIn(direction), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(cpuParams), + ::testing::Values(additionalConfig[1])), + GRUSequenceCPUTest::getTestCaseName); const std::vector> dynamicShapes = { - { { {-1, {1, 5}, 10}, // #0. Dynamic shape 0 - { {10, 2, 10}, {8, 3, 10}, {5, 4, 10} } }, // Target shapes - { {{0, 15}, 1, 1}, // Dynamic shape 1 - { {10, 1, 1}, {8, 1, 1}, {5, 1, 1} } }, // Target shapes - { {{0, 12}}, // Dynamic shape 2 - { {10}, {8}, {5} } } }, // Target shapes - { { {{0, 11}, -1, 10}, // #1. Dynamic shape 0 - { {10, 2, 10}, {3, 4, 10}, {5, 5, 10} } }, // Target shapes - { {-1, 1, 10}, // Dynamic shape 1 - { {10, 1, 10}, {3, 1, 10}, {5, 1, 10} } }, // Target shapes - { {-1}, // Dynamic shape 2 - { {10}, {3}, {5} } } }, // Target shapes - { { {{0, 11}, -1, {7, 11}}, // #2. Dynamic shape 0 - { {10, 2, 10}, {3, 4, 10}, {5, 5, 10} } }, // Target shapes - { {-1, 1, {8, 12}}, // Dynamic shape 1 - { {10, 1, 10}, {3, 1, 10}, {5, 1, 10} } }, // Target shapes - { {-1}, // Dynamic shape 2 - { {10}, {3}, {5} } } }, // Target shapes - { { {-1, {0, 7}, 10}, // #3. Dynamic shape 0 - { {1, 2, 10}, {1, 3, 10}, {1, 6, 10} } }, // Target shapes - { {-1, 1, 1}, // Dynamic shape 1 - { {1, 1, 1}, {1, 1, 1}, {1, 1, 1} } }, // Target shapes - { {-1}, // Dynamic shape 2 - { {1}, {1}, {1} } } }, // Target shapes - { { {1, -1, 10}, // #4. Dynamic shape 0 - { {1, 2, 10}, {1, 4, 10}, {1, 8, 10} } }, // Target shapes - { {1, 1, 10}, // Dynamic shape 1 - { {1, 1, 10}, {1, 1, 10}, {1, 1, 10} } }, // Target shapes - { {-1}, // Dynamic shape 2 - { {1}, {1}, {1} } } }, // Target shapes - { { {-1, -1, -1}, // #5. Dynamic shape 0 - { {1, 2, 10}, {1, 4, 10}, {1, 8, 10} } }, // Target shapes - { {-1, -1, -1}, // Dynamic shape 1 - { {1, 1, 10}, {1, 1, 10}, {1, 1, 10} } }, // Target shapes - { {-1}, // Dynamic shape 2 - { {1}, {1}, {1} } } }, // Target shapes - { { {2, {1, 5}, 10}, // #6. Dynamic shape 0 - { {2, 2, 10}, {2, 3, 10}, {2, 4, 10} } }, // Target shapes - { {2, 1, 1}, // Dynamic shape 1 - { {2, 1, 1}, {2, 1, 1}, {2, 1, 1} } }, // Target shapes - { {-1}, // Dynamic shape 2 - { {2}, {2}, {2} } }}, // Target shapes - { { {5, -1, 10}, // #7. Dynamic shape 0 - { {5, 2, 10}, {5, 4, 10}, {5, 5, 10} } }, // Target shapes - { {5, 1, 10}, // Dynamic shape 1 - { {5, 1, 10}, {5, 1, 10}, {5, 1, 10} } }, // Target shapes - { {-1}, // Dynamic shape 2 - { {5}, {5}, {5} } }}, // Target shapes - { { {{0, 11}, -1, {7, 11}}, // #8. Dynamic shape 0 - { {10, 2, 10}, {3, 4, 10}, {5, 5, 10}, {10, 2, 10}, {5, 5, 10} } }, // Target shapes - { {-1, 1, {8, 12}}, // Dynamic shape 1 - { {10, 1, 10}, {3, 1, 10}, {5, 1, 10}, {10, 1, 10}, {5, 1, 10} } }, // Target shapes - { {-1}, // Dynamic shape 2 - { {10}, {3}, {5}, {10}, {5} } } } // Target shapes + {{{-1, {1, 5}, 10}, // #0. Dynamic shape 0 + {{10, 2, 10}, {8, 3, 10}, {5, 4, 10}}}, // Target shapes + {{{0, 15}, 1, 1}, // Dynamic shape 1 + {{10, 1, 1}, {8, 1, 1}, {5, 1, 1}}}, // Target shapes + {{{0, 12}}, // Dynamic shape 2 + {{10}, {8}, {5}}}}, // Target shapes + {{{{0, 11}, -1, 10}, // #1. Dynamic shape 0 + {{10, 2, 10}, {3, 4, 10}, {5, 5, 10}}}, // Target shapes + {{-1, 1, 10}, // Dynamic shape 1 + {{10, 1, 10}, {3, 1, 10}, {5, 1, 10}}}, // Target shapes + {{-1}, // Dynamic shape 2 + {{10}, {3}, {5}}}}, // Target shapes + {{{{0, 11}, -1, {7, 11}}, // #2. Dynamic shape 0 + {{10, 2, 10}, {3, 4, 10}, {5, 5, 10}}}, // Target shapes + {{-1, 1, {8, 12}}, // Dynamic shape 1 + {{10, 1, 10}, {3, 1, 10}, {5, 1, 10}}}, // Target shapes + {{-1}, // Dynamic shape 2 + {{10}, {3}, {5}}}}, // Target shapes + {{{-1, {0, 7}, 10}, // #3. Dynamic shape 0 + {{1, 2, 10}, {1, 3, 10}, {1, 6, 10}}}, // Target shapes + {{-1, 1, 1}, // Dynamic shape 1 + {{1, 1, 1}, {1, 1, 1}, {1, 1, 1}}}, // Target shapes + {{-1}, // Dynamic shape 2 + {{1}, {1}, {1}}}}, // Target shapes + {{{1, -1, 10}, // #4. Dynamic shape 0 + {{1, 2, 10}, {1, 4, 10}, {1, 8, 10}}}, // Target shapes + {{1, 1, 10}, // Dynamic shape 1 + {{1, 1, 10}, {1, 1, 10}, {1, 1, 10}}}, // Target shapes + {{-1}, // Dynamic shape 2 + {{1}, {1}, {1}}}}, // Target shapes + {{{-1, -1, -1}, // #5. Dynamic shape 0 + {{1, 2, 10}, {1, 4, 10}, {1, 8, 10}}}, // Target shapes + {{-1, -1, -1}, // Dynamic shape 1 + {{1, 1, 10}, {1, 1, 10}, {1, 1, 10}}}, // Target shapes + {{-1}, // Dynamic shape 2 + {{1}, {1}, {1}}}}, // Target shapes + {{{2, {1, 5}, 10}, // #6. Dynamic shape 0 + {{2, 2, 10}, {2, 3, 10}, {2, 4, 10}}}, // Target shapes + {{2, 1, 1}, // Dynamic shape 1 + {{2, 1, 1}, {2, 1, 1}, {2, 1, 1}}}, // Target shapes + {{-1}, // Dynamic shape 2 + {{2}, {2}, {2}}}}, // Target shapes + {{{5, -1, 10}, // #7. Dynamic shape 0 + {{5, 2, 10}, {5, 4, 10}, {5, 5, 10}}}, // Target shapes + {{5, 1, 10}, // Dynamic shape 1 + {{5, 1, 10}, {5, 1, 10}, {5, 1, 10}}}, // Target shapes + {{-1}, // Dynamic shape 2 + {{5}, {5}, {5}}}}, // Target shapes + {{{{0, 11}, -1, {7, 11}}, // #8. Dynamic shape 0 + {{10, 2, 10}, {3, 4, 10}, {5, 5, 10}, {10, 2, 10}, {5, 5, 10}}}, // Target shapes + {{-1, 1, {8, 12}}, // Dynamic shape 1 + {{10, 1, 10}, {3, 1, 10}, {5, 1, 10}, {10, 1, 10}, {5, 1, 10}}}, // Target shapes + {{-1}, // Dynamic shape 2 + {{10}, {3}, {5}, {10}, {5}}}} // Target shapes }; -INSTANTIATE_TEST_SUITE_P(smoke_dynamic, GRUSequenceCPUTest, - ::testing::Combine(::testing::ValuesIn({dynamicShapes[0], dynamicShapes[1], dynamicShapes[2]}), - ::testing::ValuesIn(mode), - ::testing::ValuesIn(activations), - ::testing::ValuesIn(clip), - ::testing::ValuesIn(linearBeforeReset), - ::testing::ValuesIn(direction), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(cpuParams), - ::testing::Values(std::map{})), - GRUSequenceCPUTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_dynamic_BatchSizeOne, GRUSequenceCPUTest, - ::testing::Combine(::testing::ValuesIn({dynamicShapes[4]}), - ::testing::ValuesIn(mode), - ::testing::ValuesIn(activations), - ::testing::ValuesIn(clip), - ::testing::ValuesIn(linearBeforeReset), - ::testing::ValuesIn(direction), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(cpuParamsBatchSizeOne), - ::testing::Values(std::map{})), - GRUSequenceCPUTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(nightly_dynamic, GRUSequenceCPUTest, - ::testing::Combine(::testing::ValuesIn({dynamicShapes[5], dynamicShapes[8]}), - ::testing::ValuesIn(mode), - ::testing::ValuesIn(activations), - ::testing::ValuesIn(clip), - ::testing::ValuesIn(linearBeforeReset), - ::testing::ValuesIn(direction), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(cpuParams), - ::testing::Values(std::map{})), - GRUSequenceCPUTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(nightly_dynamic_bf16, GRUSequenceCPUTest, - ::testing::Combine(::testing::ValuesIn({dynamicShapes[6], dynamicShapes[7]}), - ::testing::ValuesIn(mode), - ::testing::ValuesIn(activations), - ::testing::ValuesIn(clip), - ::testing::ValuesIn(linearBeforeReset), - ::testing::ValuesIn(direction), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(cpuParams), - ::testing::Values(additionalConfig[1])), - GRUSequenceCPUTest::getTestCaseName); -} // namespace -} // namespace CPULayerTestsDefinitions +INSTANTIATE_TEST_SUITE_P(smoke_dynamic, + GRUSequenceCPUTest, + ::testing::Combine(::testing::ValuesIn({dynamicShapes[0], dynamicShapes[1], dynamicShapes[2]}), + ::testing::ValuesIn(mode), + ::testing::ValuesIn(activations), + ::testing::ValuesIn(clip), + ::testing::ValuesIn(linearBeforeReset), + ::testing::ValuesIn(direction), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(cpuParams), + ::testing::Values(ov::AnyMap{})), + GRUSequenceCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_dynamic_BatchSizeOne, + GRUSequenceCPUTest, + ::testing::Combine(::testing::ValuesIn({dynamicShapes[4]}), + ::testing::ValuesIn(mode), + ::testing::ValuesIn(activations), + ::testing::ValuesIn(clip), + ::testing::ValuesIn(linearBeforeReset), + ::testing::ValuesIn(direction), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(cpuParamsBatchSizeOne), + ::testing::Values(ov::AnyMap{})), + GRUSequenceCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(nightly_dynamic, + GRUSequenceCPUTest, + ::testing::Combine(::testing::ValuesIn({dynamicShapes[5], dynamicShapes[8]}), + ::testing::ValuesIn(mode), + ::testing::ValuesIn(activations), + ::testing::ValuesIn(clip), + ::testing::ValuesIn(linearBeforeReset), + ::testing::ValuesIn(direction), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(cpuParams), + ::testing::Values(ov::AnyMap{})), + GRUSequenceCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(nightly_dynamic_bf16, + GRUSequenceCPUTest, + ::testing::Combine(::testing::ValuesIn({dynamicShapes[6], dynamicShapes[7]}), + ::testing::ValuesIn(mode), + ::testing::ValuesIn(activations), + ::testing::ValuesIn(clip), + ::testing::ValuesIn(linearBeforeReset), + ::testing::ValuesIn(direction), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(cpuParams), + ::testing::Values(additionalConfig[1])), + GRUSequenceCPUTest::getTestCaseName); +} // namespace +} // namespace test +} // namespace ov diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/arm/conversion.cpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/arm/conversion.cpp index e7e8c25dee812c..fb3a2854c0f6b2 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/arm/conversion.cpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/arm/conversion.cpp @@ -6,12 +6,10 @@ #include "shared_test_classes/single_layer/conversion.hpp" #include "test_utils/cpu_test_utils.hpp" -using namespace InferenceEngine; using namespace CPUTestUtils; -using namespace ngraph::helpers; -using namespace ov::test; -namespace CPULayerTestsDefinitions { +namespace ov { +namespace test { namespace Conversion { INSTANTIATE_TEST_SUITE_P(smoke_ConvertCPULayerTest_7D_Dynamic, ConvertCPULayerTest, @@ -31,4 +29,5 @@ INSTANTIATE_TEST_SUITE_P(smoke_ConvertCPULayerTest_7D_Static, ConvertCPULayerTes ConvertCPULayerTest::getTestCaseName); } // namespace Conversion -} // namespace CPULayerTestsDefinitions \ No newline at end of file +} // namespace test +} // namespace ov \ No newline at end of file diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/arm/eltwise.cpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/arm/eltwise.cpp index b71716831db8a4..823f4a7686af9c 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/arm/eltwise.cpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/arm/eltwise.cpp @@ -7,12 +7,10 @@ #include "test_utils/cpu_test_utils.hpp" #include "test_utils/fusing_test_utils.hpp" -using namespace InferenceEngine; using namespace CPUTestUtils; -using namespace ngraph::helpers; -using namespace ov::test; -namespace CPULayerTestsDefinitions { +namespace ov { +namespace test { namespace Eltwise { namespace { @@ -45,9 +43,9 @@ const auto params_4D_bitwise = ::testing::Combine( ::testing::Combine( ::testing::ValuesIn(bitwise_in_shapes_4D), ::testing::ValuesIn({ - ngraph::helpers::EltwiseTypes::BITWISE_AND, - ngraph::helpers::EltwiseTypes::BITWISE_OR, - ngraph::helpers::EltwiseTypes::BITWISE_XOR + ov::test::utils::EltwiseTypes::BITWISE_AND, + ov::test::utils::EltwiseTypes::BITWISE_OR, + ov::test::utils::EltwiseTypes::BITWISE_XOR }), ::testing::ValuesIn(secondaryInputTypes()), ::testing::ValuesIn({ ov::test::utils::OpType::VECTOR }), @@ -69,9 +67,9 @@ const auto params_4D_bitwise_i32 = ::testing::Combine( ::testing::Combine( ::testing::ValuesIn(bitwise_in_shapes_4D), ::testing::ValuesIn({ - ngraph::helpers::EltwiseTypes::BITWISE_AND, - ngraph::helpers::EltwiseTypes::BITWISE_OR, - ngraph::helpers::EltwiseTypes::BITWISE_XOR + ov::test::utils::EltwiseTypes::BITWISE_AND, + ov::test::utils::EltwiseTypes::BITWISE_OR, + ov::test::utils::EltwiseTypes::BITWISE_XOR }), ::testing::ValuesIn(secondaryInputTypes()), ::testing::ValuesIn({ ov::test::utils::OpType::VECTOR }), @@ -93,8 +91,8 @@ INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_4D_Bitwise_i32, EltwiseLayerCPUTe const auto params_4D_bitwise_NOT = ::testing::Combine( ::testing::Combine( ::testing::ValuesIn(bitwise_in_shapes_4D), - ::testing::ValuesIn({ ngraph::helpers::EltwiseTypes::BITWISE_NOT }), - ::testing::ValuesIn({ ngraph::helpers::InputLayerType::CONSTANT }), + ::testing::ValuesIn({ ov::test::utils::EltwiseTypes::BITWISE_NOT }), + ::testing::ValuesIn({ ov::test::utils::InputLayerType::CONSTANT }), ::testing::ValuesIn({ ov::test::utils::OpType::VECTOR }), ::testing::ValuesIn({ ov::element::Type_t::i8, ov::element::Type_t::u8, ov::element::Type_t::i32 }), ::testing::Values(ov::element::Type_t::undefined), @@ -113,8 +111,8 @@ INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_4D_Bitwise_NOT, EltwiseLayerCPUTe const auto params_4D_bitwise_NOT_i32 = ::testing::Combine( ::testing::Combine( ::testing::ValuesIn(bitwise_in_shapes_4D), - ::testing::ValuesIn({ ngraph::helpers::EltwiseTypes::BITWISE_NOT }), - ::testing::ValuesIn({ ngraph::helpers::InputLayerType::CONSTANT }), + ::testing::ValuesIn({ ov::test::utils::EltwiseTypes::BITWISE_NOT }), + ::testing::ValuesIn({ ov::test::utils::InputLayerType::CONSTANT }), ::testing::ValuesIn({ ov::test::utils::OpType::VECTOR }), ::testing::ValuesIn({ ov::element::Type_t::i16 }), ::testing::Values(ov::element::Type_t::undefined), @@ -130,6 +128,7 @@ const auto params_4D_bitwise_NOT_i32 = ::testing::Combine( INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_4D_Bitwise_NOT_i32, EltwiseLayerCPUTest, params_4D_bitwise_NOT_i32, EltwiseLayerCPUTest::getTestCaseName); -} // namespace -} // namespace Eltwise -} // namespace CPULayerTestsDefinitions +} // namespace +} // namespace Eltwise +} // namespace test +} // namespace ov diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/common/activation.cpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/common/activation.cpp index 08e27dba864e5f..0defef891fd6f3 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/common/activation.cpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/common/activation.cpp @@ -6,12 +6,10 @@ #include "shared_test_classes/single_layer/activation.hpp" #include "test_utils/cpu_test_utils.hpp" -using namespace InferenceEngine; using namespace CPUTestUtils; -using namespace ngraph::helpers; -using namespace ov::test; -namespace CPULayerTestsDefinitions { +namespace ov { +namespace test { namespace Activation { /* ============= Activation (1D) ============= */ @@ -20,8 +18,8 @@ const auto basicCases3D = ::testing::Combine( ::testing::Values(activationShapes()), ::testing::ValuesIn(ov::test::utils::combineParams(activationTypes())), ::testing::ValuesIn(netPrc()), - ::testing::Values(Precision::FP32), - ::testing::Values(Precision::FP32), + ::testing::Values(ov::element::f32), + ::testing::Values(ov::element::f32), ::testing::ValuesIn(filterCPUSpecificParams(cpuParams3D())) ); @@ -33,8 +31,8 @@ const auto basicCases4D = ::testing::Combine( ::testing::Values(activationShapes()), ::testing::ValuesIn(ov::test::utils::combineParams(activationTypes())), ::testing::ValuesIn(netPrc()), - ::testing::Values(Precision::FP32), - ::testing::Values(Precision::FP32), + ::testing::Values(ov::element::f32), + ::testing::Values(ov::element::f32), ::testing::ValuesIn(filterCPUSpecificParams(cpuParams4D())) ); @@ -46,8 +44,8 @@ const auto basicCases5D = ::testing::Combine( ::testing::Values(activationShapes()), ::testing::ValuesIn(ov::test::utils::combineParams(activationTypes())), ::testing::ValuesIn(netPrc()), - ::testing::Values(Precision::FP32), - ::testing::Values(Precision::FP32), + ::testing::Values(ov::element::f32), + ::testing::Values(ov::element::f32), ::testing::ValuesIn(filterCPUSpecificParams(cpuParams5D())) ); @@ -58,12 +56,13 @@ const auto dynamicMathBasicCases = ::testing::Combine( ::testing::Values(activationShapes()), ::testing::ValuesIn(ov::test::utils::combineParams(activationTypesDynamicMath())), ::testing::ValuesIn(netPrecisions()), - ::testing::Values(Precision::FP32), - ::testing::Values(Precision::FP32), + ::testing::Values(ov::element::f32), + ::testing::Values(ov::element::f32), ::testing::ValuesIn(cpuParamsDynamicMath()) ); INSTANTIATE_TEST_SUITE_P(smoke_Activation5D_dynamicMath_CPU, ActivationLayerCPUTest, dynamicMathBasicCases, ActivationLayerCPUTest::getTestCaseName); } // namespace Activation -} // namespace CPULayerTestsDefinitions +} // namespace test +} // namespace ov diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/common/conversion.cpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/common/conversion.cpp index 4a29a6d542cdcc..e7123986ffa363 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/common/conversion.cpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/common/conversion.cpp @@ -6,12 +6,10 @@ #include "shared_test_classes/single_layer/conversion.hpp" #include "test_utils/cpu_test_utils.hpp" -using namespace InferenceEngine; using namespace CPUTestUtils; -using namespace ngraph::helpers; -using namespace ov::test; -namespace CPULayerTestsDefinitions { +namespace ov { +namespace test { namespace Conversion { static std::string expectedPrimitiveType() { @@ -51,4 +49,5 @@ INSTANTIATE_TEST_SUITE_P(smoke_ConvertCPULayerTest_4D_Static, ConvertCPULayerTes ConvertCPULayerTest::getTestCaseName); } // namespace Conversion -} // namespace CPULayerTestsDefinitions \ No newline at end of file +} // namespace test +} // namespace ov \ No newline at end of file diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/common/convolution.cpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/common/convolution.cpp new file mode 100644 index 00000000000000..a3fcccdbe2d143 --- /dev/null +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/common/convolution.cpp @@ -0,0 +1,546 @@ +// Copyright (C) 2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "single_layer_tests/classes/convolution.hpp" +#include "shared_test_classes/single_layer/convolution.hpp" +#include "test_utils/cpu_test_utils.hpp" +#include "test_utils/filter_cpu_info.hpp" + +using namespace InferenceEngine; +using namespace CPUTestUtils; +using namespace ngraph::helpers; +using namespace ov::test; + +namespace CPULayerTestsDefinitions { +namespace Convolution { + +/* ============= Convolution (Gemm 1D) ============= */ +INSTANTIATE_TEST_SUITE_P(smoke_Conv_1D_GEMM_FP32, ConvolutionLayerCPUTest, + ::testing::Combine( + ::testing::Combine( + convParams_ExplicitPadding_GEMM_1D(), + ::testing::Values(ElementType::f32), + ::testing::Values(ElementType::undefined), + ::testing::Values(ElementType::undefined), + ::testing::ValuesIn(inShapesGemm1D()), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::ValuesIn(filterCPUInfo(CPUParams_GEMM_1D())), + ::testing::ValuesIn(fusingParamsSetWithEmpty()), + ::testing::Values(cpuEmptyPluginConfig)), + ConvolutionLayerCPUTest::getTestCaseName); + +std::vector inputShapesPlain2Blocked3d = { + {{}, {{ 1, 1, 7, 7, 7 }}}, + {{}, {{ 1, 2, 7, 7, 7 }}}, + {{}, {{ 1, 3, 7, 7, 7 }}}, + { + //dynamic shapes + { -1, 1, -1, {1, 200}, -1 }, + { //target static shapes + { 2, 1, 7, 7, 7 }, + { 1, 1, 9, 9, 9 } + } + }, + { + //dynamic shapes + { -1, 3, -1, {1, 200}, -1 }, + { //target static shapes + { 2, 3, 7, 7, 7 }, + { 1, 3, 9, 9, 9 } + } + } +}; + +INSTANTIATE_TEST_SUITE_P(smoke_Conv_2D_GEMM_FP32, ConvolutionLayerCPUTest, + ::testing::Combine( + ::testing::Combine( + convParams_ExplicitPadding_GEMM_2D(), + ::testing::Values(ElementType::f32), + ::testing::Values(ElementType::undefined), + ::testing::Values(ElementType::undefined), + ::testing::ValuesIn(inShapesGemm2D_cache()), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::ValuesIn(filterCPUInfo(CPUParams_GEMM_2D())), + ::testing::Values(emptyFusingSpec), + ::testing::Values(cpuEmptyPluginConfig)), + ConvolutionLayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_Conv_2D_GEMM_I8, ConvolutionLayerCPUTest, + ::testing::Combine( + ::testing::Combine( + convParams_ExplicitPadding_GEMM_2D(), + ::testing::Values(ElementType::f32), + ::testing::Values(ElementType::i8), + ::testing::Values(ElementType::undefined), + ::testing::ValuesIn(inShapesGemm2D()), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::ValuesIn(filterCPUInfo(CPUParams_GEMM_2D())), + ::testing::Values(fusingSum), + ::testing::Values(cpuEmptyPluginConfig)), + ConvolutionLayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(Conv_2D_GEMM_FP32_dilated_empty_fusing, ConvolutionLayerCPUTest, + ::testing::Combine( + ::testing::Combine( + convParams_ExplicitPadding_GEMM_2D_dilated(), + ::testing::Values(ElementType::f32), + ::testing::Values(ElementType::undefined), + ::testing::Values(ElementType::undefined), + ::testing::ValuesIn(inShapesGemm2D()), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::ValuesIn(filterCPUInfo(CPUParams_GEMM_2D())), + ::testing::Values(emptyFusingSpec), + ::testing::Values(cpuEmptyPluginConfig)), + ConvolutionLayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(Conv_2D_GEMM_I8_dilated, ConvolutionLayerCPUTest, + ::testing::Combine( + ::testing::Combine( + convParams_ExplicitPadding_GEMM_2D_dilated(), + ::testing::Values(ElementType::f32), + ::testing::Values(ElementType::i8), + ::testing::Values(ElementType::undefined), + ::testing::ValuesIn(inShapesGemm2D()), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::ValuesIn(filterCPUInfo(CPUParams_GEMM_2D())), + ::testing::Values(fusingSum), + ::testing::Values(cpuEmptyPluginConfig)), + ConvolutionLayerCPUTest::getTestCaseName); + +/* ============= Convolution (2D) ============= */ +INSTANTIATE_TEST_SUITE_P(smoke_Conv_2D_FP32_empty_fusing, ConvolutionLayerCPUTest, + ::testing::Combine( + ::testing::Combine( + convParams_ExplicitPadding_2D(), + ::testing::Values(ElementType::f32), + ::testing::Values(ElementType::undefined), + ::testing::Values(ElementType::undefined), + ::testing::ValuesIn(inputShapes2d_cache()), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::ValuesIn(filterCPUInfo(CPUParams_2D())), + ::testing::Values(emptyFusingSpec), + ::testing::Values(cpuEmptyPluginConfig)), + ConvolutionLayerCPUTest::getTestCaseName); + +const std::vector fusingParamsSet_dynBatch{ + emptyFusingSpec, + fusingSum, + fusingAddPerChannel, + fusingReluScaleShift +}; + +INSTANTIATE_TEST_SUITE_P(smoke_Conv_2D_FP32_dynBatch, ConvolutionLayerCPUTest, + ::testing::Combine( + ::testing::Combine( + convParams_ExplicitPadding_2D(), + ::testing::Values(ElementType::f32), + ::testing::Values(ElementType::undefined), + ::testing::Values(ElementType::undefined), + ::testing::ValuesIn(inputShapes2d_dynBatch()), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::ValuesIn(filterCPUInfo(CPUParams_2D())), + ::testing::ValuesIn(fusingParamsSet_dynBatch), + ::testing::Values(cpuEmptyPluginConfig)), + ConvolutionLayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_Conv_2D_I8, ConvolutionLayerCPUTest, + ::testing::Combine( + ::testing::Combine( + convParams_ExplicitPadding_2D(), + ::testing::Values(ElementType::f32), + ::testing::Values(ElementType::i8), + ::testing::Values(ElementType::undefined), + ::testing::ValuesIn(inputShapes2d()), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::ValuesIn(filterCPUInfo(CPUParams_2D())), + ::testing::Values(fusingSum), + ::testing::Values(cpuEmptyPluginConfig)), + ConvolutionLayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(Conv_2D_FP32_dilated_empty_fusing, ConvolutionLayerCPUTest, + ::testing::Combine( + ::testing::Combine( + convParams_ExplicitPadding_2D_dilated(), + ::testing::Values(ElementType::f32), + ::testing::Values(ElementType::undefined), + ::testing::Values(ElementType::undefined), + ::testing::ValuesIn(inputShapes2d()), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::ValuesIn(filterCPUInfo(CPUParams_2D())), + ::testing::Values(emptyFusingSpec), + ::testing::Values(cpuEmptyPluginConfig)), + ConvolutionLayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(Conv_2D_I8_dilated, ConvolutionLayerCPUTest, + ::testing::Combine( + ::testing::Combine( + convParams_ExplicitPadding_2D_dilated(), + ::testing::Values(ElementType::f32), + ::testing::Values(ElementType::i8), + ::testing::Values(ElementType::undefined), + ::testing::ValuesIn(inputShapes2d()), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::ValuesIn(filterCPUInfo(CPUParams_2D())), + ::testing::Values(fusingSum), + ::testing::Values(cpuEmptyPluginConfig)), + ConvolutionLayerCPUTest::getTestCaseName); + +const std::vector CPUParams_2D_plain_to_blocked = { + conv_sse42_plain_to_blocked_2D, + conv_avx2_plain_to_blocked_2D, + conv_avx512_plain_to_blocked_2D, +}; + +INSTANTIATE_TEST_SUITE_P(smoke_Conv_2D_PlainToBlocked_FP32, ConvolutionLayerCPUTest, + ::testing::Combine( + ::testing::Combine( + convParams_ExplicitPadding_2D(), + ::testing::Values(ElementType::f32), + ::testing::Values(ElementType::undefined), + ::testing::Values(ElementType::undefined), + ::testing::ValuesIn(inputShapesPlain2Blocked2d()), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::ValuesIn(filterCPUInfo(CPUParams_2D_plain_to_blocked)), + ::testing::Values(emptyFusingSpec), + ::testing::Values(cpuEmptyPluginConfig)), + ConvolutionLayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(Conv_PlainToBlocked_2D_FP32_dilated, ConvolutionLayerCPUTest, + ::testing::Combine( + ::testing::Combine( + convParams_ExplicitPadding_2D_dilated(), + ::testing::Values(ElementType::f32), + ::testing::Values(ElementType::undefined), + ::testing::Values(ElementType::undefined), + ::testing::ValuesIn(inputShapesPlain2Blocked2d()), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::ValuesIn(filterCPUInfo(CPUParams_2D_plain_to_blocked)), + ::testing::Values(emptyFusingSpec), + ::testing::Values(cpuEmptyPluginConfig)), + ConvolutionLayerCPUTest::getTestCaseName); + +/* ============= Reorder + Convolution ============= */ +const auto convParams_Reorder_2D = ::testing::Combine( + ::testing::Values(SizeVector{1, 1}), + ::testing::Values(SizeVector{2, 2}), + ::testing::Values(std::vector{0, 0}), + ::testing::Values(std::vector{0, 0}), + ::testing::Values(SizeVector{1, 1}), + ::testing::Values(64), + ::testing::Values(ngraph::op::PadType::EXPLICIT) +); + +std::vector inputShapes_Reorder_2D = { + { + // dynamic shape + { -1, 32, -1, -1 }, + // target static shapes + { + { 1, 32, 39, 40 }, + { 2, 32, 20, 20 }, + { 1, 32, 39, 40 }, + { 2, 32, 20, 20 } + } + } +}; + +const std::vector fusingParamsSet_reorder{ + emptyFusingSpec, + fusingReluScaleShift, + fusingAddPerChannel +}; + +INSTANTIATE_TEST_SUITE_P(smoke_reorder_Conv_2D, ConvolutionLayerCPUTest, + ::testing::Combine( + ::testing::Combine( + convParams_Reorder_2D, + ::testing::Values(ElementType::f32), + ::testing::Values(ElementType::undefined), + ::testing::Values(ElementType::undefined), + ::testing::ValuesIn(inputShapes_Reorder_2D), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::ValuesIn(filterCPUInfo({conv_avx512_2D_1x1})), + ::testing::ValuesIn(fusingParamsSet_reorder), + ::testing::Values(cpuEmptyPluginConfig)), + ConvolutionLayerCPUTest::getTestCaseName); + +/* ============= Convolution (3D) ============= */ +const std::vector CPUParams_3D = { + //conv_sse42_3D, // not supported jit_sse42 for 3d + conv_avx2_3D, + conv_avx512_3D, + conv_avx2_3D_nspc, + conv_avx2_3D_nspc_brgconv, + conv_avx512_3D_nspc, + conv_avx512_3D_nspc_brgconv +}; + +INSTANTIATE_TEST_SUITE_P(smoke_Conv_3D_FP32, ConvolutionLayerCPUTest, + ::testing::Combine( + ::testing::Combine( + convParams_ExplicitPadding_3D(), + ::testing::Values(ElementType::f32), + ::testing::Values(ElementType::undefined), + ::testing::Values(ElementType::undefined), + ::testing::ValuesIn(inputShapes3d()), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::ValuesIn(filterCPUInfo(CPUParams_3D)), + ::testing::Values(emptyFusingSpec), + ::testing::Values(cpuEmptyPluginConfig)), + ConvolutionLayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_Conv_3D_FP32_fusingScaleShiftAndFakeQuantizePerChannel, ConvolutionLayerCPUTest, + ::testing::Combine( + ::testing::Combine( + convParams_ExplicitPadding_3D(), + ::testing::Values(ElementType::f32), + ::testing::Values(ElementType::undefined), + ::testing::Values(ElementType::undefined), + ::testing::ValuesIn(inputShapes3d()), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::ValuesIn(filterCPUInfo(CPUParams_3D)), + ::testing::Values(fusingScaleShiftAndFakeQuantizePerChannel), + ::testing::Values(cpuEmptyPluginConfig)), + ConvolutionLayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_Conv_3D_I8, ConvolutionLayerCPUTest, + ::testing::Combine( + ::testing::Combine( + convParams_ExplicitPadding_3D(), + ::testing::Values(ElementType::f32), + ::testing::Values(ElementType::i8), + ::testing::Values(ElementType::undefined), + ::testing::ValuesIn(inputShapes3d()), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::ValuesIn(filterCPUInfo(CPUParams_3D)), + ::testing::Values(fusingSum), + ::testing::Values(cpuEmptyPluginConfig)), + ConvolutionLayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(Conv_3D_FP32_dilated, ConvolutionLayerCPUTest, + ::testing::Combine( + ::testing::Combine( + convParams_ExplicitPadding_3D_dilated(), + ::testing::Values(ElementType::f32), + ::testing::Values(ElementType::undefined), + ::testing::Values(ElementType::undefined), + ::testing::ValuesIn(inputShapes3d()), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::ValuesIn(filterCPUInfo(CPUParams_3D)), + ::testing::Values(emptyFusingSpec), + ::testing::Values(cpuEmptyPluginConfig)), + ConvolutionLayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(Conv_3D_I8_dilated, ConvolutionLayerCPUTest, + ::testing::Combine( + ::testing::Combine( + convParams_ExplicitPadding_3D_dilated(), + ::testing::Values(ElementType::f32), + ::testing::Values(ElementType::i8), + ::testing::Values(ElementType::undefined), + ::testing::ValuesIn(inputShapes3d()), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::ValuesIn(filterCPUInfo(CPUParams_3D)), + ::testing::Values(fusingSum), + ::testing::Values(cpuEmptyPluginConfig)), + ConvolutionLayerCPUTest::getTestCaseName); + +const std::vector CPUParams_3D_plain_to_blocked = { + conv_avx2_plain_to_blocked_3D, + conv_avx512_plain_to_blocked_3D, +}; + +INSTANTIATE_TEST_SUITE_P(smoke_Conv_3D_PlainToBlocked_FP32, ConvolutionLayerCPUTest, + ::testing::Combine( + ::testing::Combine( + convParams_ExplicitPadding_3D(), + ::testing::Values(ElementType::f32), + ::testing::Values(ElementType::undefined), + ::testing::Values(ElementType::undefined), + ::testing::ValuesIn(inputShapesPlain2Blocked3d), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::ValuesIn(filterCPUInfo(CPUParams_3D_plain_to_blocked)), + ::testing::Values(emptyFusingSpec), + ::testing::Values(cpuEmptyPluginConfig)), + ConvolutionLayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_Conv_3D_PlainToBlocked_BF16, ConvolutionLayerCPUTest, + ::testing::Combine( + ::testing::Combine( + convParams_ExplicitPadding_3D(), + ::testing::Values(ElementType::f32), + ::testing::Values(ElementType::undefined), + ::testing::Values(ElementType::undefined), + ::testing::ValuesIn(inputShapesPlain2Blocked3d), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::ValuesIn(filterCPUInfo({conv_avx512_plain_to_blocked_3D})), + ::testing::Values(emptyFusingSpec), + ::testing::Values(cpuEmptyPluginConfig)), + ConvolutionLayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(Conv_PlainToBlocked_3D_FP32_dilated, ConvolutionLayerCPUTest, + ::testing::Combine( + ::testing::Combine( + convParams_ExplicitPadding_3D_dilated(), + ::testing::Values(ElementType::f32), + ::testing::Values(ElementType::undefined), + ::testing::Values(ElementType::undefined), + ::testing::ValuesIn(inputShapesPlain2Blocked3d), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::ValuesIn(filterCPUInfo(CPUParams_3D_plain_to_blocked)), + ::testing::Values(emptyFusingSpec), + ::testing::Values(cpuEmptyPluginConfig)), + ConvolutionLayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(Conv_PlainToBlocked_3D_BF16_dilated, ConvolutionLayerCPUTest, + ::testing::Combine( + ::testing::Combine( + convParams_ExplicitPadding_3D_dilated(), + ::testing::Values(ElementType::f32), + ::testing::Values(ElementType::undefined), + ::testing::Values(ElementType::undefined), + ::testing::ValuesIn(inputShapesPlain2Blocked3d), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::ValuesIn(filterCPUInfo({conv_avx512_plain_to_blocked_3D})), + ::testing::Values(emptyFusingSpec), + ::testing::Values(cpuEmptyPluginConfig)), + ConvolutionLayerCPUTest::getTestCaseName); + +/* ============= Kernel_1x1 (1D) ============= */ + +INSTANTIATE_TEST_SUITE_P(smoke_Conv_1D_1x1_FP32_empty_fusing, ConvolutionLayerCPUTest, + ::testing::Combine( + ::testing::Combine( + convParams_ExplicitPadding_1x1_1D(), + ::testing::Values(ElementType::f32), + ::testing::Values(ElementType::undefined), + ::testing::Values(ElementType::undefined), + ::testing::ValuesIn(inputShapes1d()), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::ValuesIn(filterCPUInfo(CPUParams_1x1_1D())), + ::testing::Values(emptyFusingSpec), + ::testing::Values(cpuEmptyPluginConfig)), + ConvolutionLayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_Conv_1D_1x1_I8, ConvolutionLayerCPUTest, + ::testing::Combine( + ::testing::Combine( + convParams_ExplicitPadding_1x1_1D(), + ::testing::Values(ElementType::f32), + ::testing::Values(ElementType::i8), + ::testing::Values(ElementType::undefined), + ::testing::ValuesIn(inputShapes1d()), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::ValuesIn(filterCPUInfo(CPUParams_1x1_1D())), + ::testing::Values(fusingSum), + ::testing::Values(cpuEmptyPluginConfig)), + ConvolutionLayerCPUTest::getTestCaseName); + +/* ============= Kernel_1x1 (2D) ============= */ + +INSTANTIATE_TEST_SUITE_P(smoke_Conv_2D_1x1_FP32_empty_fusing, ConvolutionLayerCPUTest, + ::testing::Combine( + ::testing::Combine( + convParams_ExplicitPadding_1x1_2D(), + ::testing::Values(ElementType::f32), + ::testing::Values(ElementType::undefined), + ::testing::Values(ElementType::undefined), + ::testing::ValuesIn(inputShapes2d()), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::ValuesIn(filterCPUInfo(CPUParams_1x1_2D())), + ::testing::Values(emptyFusingSpec), + ::testing::Values(cpuEmptyPluginConfig)), + ConvolutionLayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_Conv_2D_1x1_I8, ConvolutionLayerCPUTest, + ::testing::Combine( + ::testing::Combine( + convParams_ExplicitPadding_1x1_2D(), + ::testing::Values(ElementType::f32), + ::testing::Values(ElementType::i8), + ::testing::Values(ElementType::undefined), + ::testing::ValuesIn(inputShapes2d()), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::ValuesIn(filterCPUInfo(CPUParams_1x1_2D())), + ::testing::Values(fusingSum), + ::testing::Values(cpuEmptyPluginConfig)), + ConvolutionLayerCPUTest::getTestCaseName); + +/* ============= Convolution auto padding tests ============= */ + +const auto convParams_AutoPadding_2D = ::testing::Combine( + ::testing::Values(kernels2d().front()), + ::testing::ValuesIn(strides2d()), + ::testing::ValuesIn(padBegins2d()), + ::testing::ValuesIn(padEnds2d()), + ::testing::ValuesIn(dilations2d()), + ::testing::ValuesIn(numOutChannels()), + ::testing::Values(ngraph::op::PadType::SAME_UPPER, ngraph::op::PadType::SAME_LOWER) +); + +INSTANTIATE_TEST_SUITE_P(smoke_Conv_2D_AutoPad_FP32, ConvolutionLayerCPUTest, + ::testing::Combine( + ::testing::Combine( + convParams_AutoPadding_2D, + ::testing::Values(ElementType::f32), + ::testing::Values(ElementType::undefined), + ::testing::Values(ElementType::undefined), + ::testing::ValuesIn(inputShapes2d()), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::ValuesIn(filterCPUInfo(CPUParams_2D())), + ::testing::Values(emptyFusingSpec), + ::testing::Values(cpuEmptyPluginConfig)), + ConvolutionLayerCPUTest::getTestCaseName); + +/* ============= Large Filter Test ============= */ +namespace { + +const size_t outChannels = 80; + +const SizeVector kernel = { 251 }; +const SizeVector stride = { 10 }; +const std::vector padBegins = { 0 }; +const std::vector padEnds = { 0 }; +const SizeVector dilations = { 1 }; + +const auto convParams_1D = ::testing::Combine( + ::testing::Values(kernel), + ::testing::Values(stride), + ::testing::Values(padBegins), + ::testing::Values(padEnds), + ::testing::Values(dilations), + ::testing::Values(outChannels), + ::testing::Values(ngraph::op::PadType::EXPLICIT) +); + +std::vector inShapes = { + {{}, {{ 1, 1, 600 }}}, + { + //dynamic shape + { -1, 1, -1 }, + { //target static shapes + { 1, 1, 600 }, + { 10, 1, 700 }, + { 1, 1, 600 } + } + } +}; + +INSTANTIATE_TEST_SUITE_P(smoke_Conv_Large_Filter, ConvolutionLayerCPUTest, + ::testing::Combine( + ::testing::Combine( + convParams_1D, + ::testing::Values(ElementType::f32), + ::testing::Values(ElementType::f32), + ::testing::Values(ElementType::undefined), + ::testing::ValuesIn(inShapes), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::Values(CPUSpecificParams{{}, {}, {}, CPUTestsBase::any_type}), + ::testing::Values(emptyFusingSpec), + ::testing::Values(cpuEmptyPluginConfig)), + ConvolutionLayerCPUTest::getTestCaseName); + +} // namespace +} // namespace Convolution +} // namespace CPULayerTestsDefinitions \ No newline at end of file diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/common/eltwise.cpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/common/eltwise.cpp index bf61d07e289d25..4268d252697103 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/common/eltwise.cpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/common/eltwise.cpp @@ -7,12 +7,10 @@ #include "test_utils/cpu_test_utils.hpp" #include "test_utils/fusing_test_utils.hpp" -using namespace InferenceEngine; using namespace CPUTestUtils; -using namespace ngraph::helpers; -using namespace ov::test; -namespace CPULayerTestsDefinitions { +namespace ov { +namespace test { namespace Eltwise { const auto params_4D = ::testing::Combine( @@ -86,8 +84,8 @@ INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_5D, EltwiseLayerCPUTest, params_5 const auto params_4D_1D_constant_mode = ::testing::Combine( ::testing::Combine( ::testing::ValuesIn(static_shapes_to_test_representation(inShapes_4D_1D())), - ::testing::Values(ngraph::helpers::EltwiseTypes::ADD, ngraph::helpers::EltwiseTypes::MULTIPLY), - ::testing::Values(ngraph::helpers::InputLayerType::CONSTANT), + ::testing::Values(ov::test::utils::EltwiseTypes::ADD, ov::test::utils::EltwiseTypes::MULTIPLY), + ::testing::Values(ov::test::utils::InputLayerType::CONSTANT), ::testing::ValuesIn(opTypes()), ::testing::ValuesIn(netType()), ::testing::Values(ov::element::undefined), @@ -103,8 +101,8 @@ INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_4D_1D_Constant, EltwiseLayerCPUTe const auto params_4D_1D_parameter_mode = ::testing::Combine( ::testing::Combine( ::testing::ValuesIn(static_shapes_to_test_representation(inShapes_4D_1D())), - ::testing::Values(ngraph::helpers::EltwiseTypes::ADD, ngraph::helpers::EltwiseTypes::MULTIPLY), - ::testing::Values(ngraph::helpers::InputLayerType::PARAMETER), + ::testing::Values(ov::test::utils::EltwiseTypes::ADD, ov::test::utils::EltwiseTypes::MULTIPLY), + ::testing::Values(ov::test::utils::InputLayerType::PARAMETER), ::testing::ValuesIn(opTypes()), ::testing::ValuesIn(netType()), ::testing::Values(ov::element::undefined), @@ -120,8 +118,8 @@ INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_4D_1D_Parameter, EltwiseLayerCPUT const auto params_5D_1D_constant = ::testing::Combine( ::testing::Combine( ::testing::ValuesIn(static_shapes_to_test_representation(inShapes_5D_1D())), - ::testing::Values(ngraph::helpers::EltwiseTypes::ADD, ngraph::helpers::EltwiseTypes::MULTIPLY), - ::testing::Values(ngraph::helpers::InputLayerType::CONSTANT), + ::testing::Values(ov::test::utils::EltwiseTypes::ADD, ov::test::utils::EltwiseTypes::MULTIPLY), + ::testing::Values(ov::test::utils::InputLayerType::CONSTANT), ::testing::ValuesIn(opTypes()), ::testing::ValuesIn(netType()), ::testing::Values(ov::element::undefined), @@ -137,8 +135,8 @@ INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_5D_1D_Constant, EltwiseLayerCPUTe const auto params_5D_1D_parameter = ::testing::Combine( ::testing::Combine( ::testing::ValuesIn(static_shapes_to_test_representation(inShapes_5D_1D())), - ::testing::Values(ngraph::helpers::EltwiseTypes::ADD, ngraph::helpers::EltwiseTypes::MULTIPLY), - ::testing::Values(ngraph::helpers::InputLayerType::PARAMETER), + ::testing::Values(ov::test::utils::EltwiseTypes::ADD, ov::test::utils::EltwiseTypes::MULTIPLY), + ::testing::Values(ov::test::utils::InputLayerType::PARAMETER), ::testing::ValuesIn(opTypes()), ::testing::ValuesIn(netType()), ::testing::Values(ov::element::undefined), @@ -155,7 +153,7 @@ const auto params_4D_dyn_const = ::testing::Combine( ::testing::Combine( ::testing::ValuesIn(inShapes_4D_dyn_const()), ::testing::ValuesIn(eltwiseOpTypesBinInp()), - ::testing::Values(ngraph::helpers::InputLayerType::CONSTANT), + ::testing::Values(ov::test::utils::InputLayerType::CONSTANT), ::testing::ValuesIn(opTypes()), ::testing::ValuesIn(netType()), ::testing::Values(ov::element::undefined), @@ -172,7 +170,7 @@ const auto params_4D_dyn_param = ::testing::Combine( ::testing::Combine( ::testing::Values(inShapes_4D_dyn_param()), ::testing::ValuesIn(eltwiseOpTypesBinDyn()), - ::testing::Values(ngraph::helpers::InputLayerType::PARAMETER), + ::testing::Values(ov::test::utils::InputLayerType::PARAMETER), ::testing::ValuesIn(opTypes()), ::testing::ValuesIn(netType()), ::testing::Values(ov::element::undefined), @@ -189,7 +187,7 @@ const auto params_5D_dyn_const = ::testing::Combine( ::testing::Combine( ::testing::Values(inShapes_5D_dyn_const()), ::testing::ValuesIn(eltwiseOpTypesBinInp()), - ::testing::Values(ngraph::helpers::InputLayerType::CONSTANT), + ::testing::Values(ov::test::utils::InputLayerType::CONSTANT), ::testing::ValuesIn(opTypes()), ::testing::ValuesIn(netType()), ::testing::Values(ov::element::undefined), @@ -206,7 +204,7 @@ const auto params_5D_dyn_param = ::testing::Combine( ::testing::Combine( ::testing::Values(inShapes_5D_dyn_param()), ::testing::ValuesIn(eltwiseOpTypesBinDyn()), - ::testing::Values(ngraph::helpers::InputLayerType::PARAMETER), + ::testing::Values(ov::test::utils::InputLayerType::PARAMETER), ::testing::ValuesIn(opTypes()), ::testing::ValuesIn(netType()), ::testing::Values(ov::element::undefined), @@ -219,5 +217,6 @@ const auto params_5D_dyn_param = ::testing::Combine( INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_5D_MemOrder_dyn_param, EltwiseLayerCPUTest, params_5D_dyn_param, EltwiseLayerCPUTest::getTestCaseName); -} // namespace Eltwise -} // namespace CPULayerTestsDefinitions +} // namespace Eltwise +} // namespace test +} // namespace ov diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/common/matmul.cpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/common/matmul.cpp index a1eaf7ac28db09..ba9be6b8a916db 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/common/matmul.cpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/common/matmul.cpp @@ -8,12 +8,10 @@ #include "test_utils/filter_cpu_info.hpp" #include "test_utils/fusing_test_utils.hpp" -using namespace InferenceEngine; using namespace CPUTestUtils; -using namespace ngraph::helpers; -using namespace ov::test; -namespace CPULayerTestsDefinitions { +namespace ov { +namespace test { namespace MatMul { /* ============= MatMul ============= */ namespace matmul { @@ -291,7 +289,7 @@ const auto matMulParams = ::testing::Combine(::testing::ValuesIn(IS), ::testing::ValuesIn(netPRCs()), ::testing::Values(ElementType::undefined), ::testing::Values(ElementType::undefined), - ::testing::Values(helpers::InputLayerType::PARAMETER), + ::testing::Values(utils::InputLayerType::PARAMETER), ::testing::Values(ov::test::utils::DEVICE_CPU), ::testing::ValuesIn(additionalConfig())); @@ -306,7 +304,7 @@ const auto matMulParamsDynamic = ::testing::Combine(::testing::ValuesIn(IS_Dynam ::testing::ValuesIn(netPRCs()), ::testing::Values(ElementType::undefined), ::testing::Values(ElementType::undefined), - ::testing::Values(helpers::InputLayerType::PARAMETER), + ::testing::Values(utils::InputLayerType::PARAMETER), ::testing::Values(ov::test::utils::DEVICE_CPU), ::testing::ValuesIn(additionalConfig())); @@ -321,7 +319,7 @@ const auto matMulParamsDynamic_nightly = ::testing::Combine(::testing::ValuesIn( ::testing::ValuesIn(netPRCs()), ::testing::Values(ElementType::undefined), ::testing::Values(ElementType::undefined), - ::testing::Values(helpers::InputLayerType::PARAMETER), + ::testing::Values(utils::InputLayerType::PARAMETER), ::testing::Values(ov::test::utils::DEVICE_CPU), ::testing::ValuesIn(additionalConfig())); @@ -332,6 +330,7 @@ const auto testParamsDynamic_nightly = ::testing::Combine(matMulParamsDynamic_ni INSTANTIATE_TEST_SUITE_P(nightly_MM_Dynamic, MatMulLayerCPUTest, testParamsDynamic_nightly, MatMulLayerCPUTest::getTestCaseName); -} // namespace matmul -} // namespace MatMul -} // namespace CPULayerTestsDefinitions \ No newline at end of file +} // namespace matmul +} // namespace MatMul +} // namespace test +} // namespace ov \ No newline at end of file diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/common/multinomial.cpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/common/multinomial.cpp new file mode 100644 index 00000000000000..911b0085a39f5e --- /dev/null +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/common/multinomial.cpp @@ -0,0 +1,131 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "single_op_tests/multinomial.hpp" + +#include +#include + +namespace { + +using ov::test::MultinomialLayerTest; + +std::vector> global_op_seed = {{1ul, 2ul}, {0ul, 0ul}}; + +std::vector probs_4x4_f32 = {0.00001f, + 0.001f, + 0.1f, + 10.0f, + 0.001f, + 0.00001f, + 10.0f, + 0.1f, + 0.1f, + 10.0f, + 0.00001f, + 0.001f, + 10.0f, + 0.1f, + 0.001f, + 0.00001f}; + +std::vector probs_2x3_f16 = {ov::float16(0.001f), + ov::float16(0.1f), + ov::float16(10.0f), + ov::float16(10.0f), + ov::float16(0.001f), + ov::float16(0.1f)}; + +std::vector probs_1x3_bf16 = {ov::bfloat16(0.1f), ov::bfloat16(1.0f), ov::bfloat16(10.0f)}; + +std::vector probs_4x4_f32_log = + {3.0f, 6.0f, 10.0f, 0.0f, 3.0f, 0.0f, 10.0f, 6.0f, 6.0f, 10.0f, 0.0f, 3.0f, 10.0f, 6.0f, 3.0f, 0.0f}; + +std::vector probs_2x3_f16_log = {ov::float16(3.0f), + ov::float16(6.0f), + ov::float16(10.0f), + ov::float16(10.0f), + ov::float16(3.0f), + ov::float16(6.0f)}; + +std::vector probs_1x3_bf16_log = {ov::bfloat16(3.0f), ov::bfloat16(6.0f), ov::bfloat16(10.0f)}; + +std::vector num_samples_scalar_i32 = {1}; +std::vector num_samples_1x1_i64 = {2}; +std::vector num_samples_scalar_i64 = {3}; + +const std::vector probs = {ov::Tensor(ov::element::f32, {4, 4}, probs_4x4_f32.data()), + ov::Tensor(ov::element::f16, {2, 3}, probs_2x3_f16.data()), + ov::Tensor(ov::element::bf16, {1, 3}, probs_1x3_bf16.data())}; + +const std::vector probs_log = {ov::Tensor(ov::element::f32, {4, 4}, probs_4x4_f32_log.data()), + ov::Tensor(ov::element::f16, {2, 3}, probs_2x3_f16_log.data()), + ov::Tensor(ov::element::bf16, {1, 3}, probs_1x3_bf16_log.data())}; + +const std::vector num_samples = {ov::Tensor(ov::element::i32, {}, num_samples_scalar_i32.data()), + ov::Tensor(ov::element::i64, {1}, num_samples_1x1_i64.data()), + ov::Tensor(ov::element::i64, {}, num_samples_scalar_i64.data())}; + +const std::vector convert_type = {ov::test::ElementType::i32}; + +const std::vector with_replacement = { + // true, + false}; + +const auto params_static = ::testing::Combine(::testing::Values("static"), + ::testing::ValuesIn(probs), + ::testing::ValuesIn(num_samples), + ::testing::ValuesIn(convert_type), + ::testing::ValuesIn(with_replacement), + ::testing::Values(false), // log_probs + ::testing::ValuesIn(global_op_seed), + ::testing::Values(ov::test::utils::DEVICE_CPU)); + +const auto params_static_log = ::testing::Combine(::testing::Values("static"), + ::testing::ValuesIn(probs_log), + ::testing::ValuesIn(num_samples), + ::testing::ValuesIn(convert_type), + ::testing::ValuesIn(with_replacement), + ::testing::Values(true), // log_probs + ::testing::ValuesIn(global_op_seed), + ::testing::Values(ov::test::utils::DEVICE_CPU)); + +const auto params_dynamic = ::testing::Combine(::testing::Values("dynamic"), + ::testing::ValuesIn(probs), + ::testing::ValuesIn(num_samples), + ::testing::ValuesIn(convert_type), + ::testing::ValuesIn(with_replacement), + ::testing::Values(false), // log_probs + ::testing::ValuesIn(global_op_seed), + ::testing::Values(ov::test::utils::DEVICE_CPU)); + +const auto params_dynamic_log = ::testing::Combine(::testing::Values("dynamic"), + ::testing::ValuesIn(probs_log), + ::testing::ValuesIn(num_samples), + ::testing::ValuesIn(convert_type), + ::testing::ValuesIn(with_replacement), + ::testing::Values(true), // log_probs + ::testing::ValuesIn(global_op_seed), + ::testing::Values(ov::test::utils::DEVICE_CPU)); + +INSTANTIATE_TEST_SUITE_P(smoke_MultinomialStatic, + MultinomialLayerTest, + params_static, + MultinomialLayerTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_MultinomialStaticLog, + MultinomialLayerTest, + params_static_log, + MultinomialLayerTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_MultinomialDynamic, + MultinomialLayerTest, + params_dynamic, + MultinomialLayerTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_MultinomialDynamicLog, + MultinomialLayerTest, + params_dynamic_log, + MultinomialLayerTest::getTestCaseName); +} // namespace diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/common/mvn.cpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/common/mvn.cpp index c0f05b261d33a0..6d2cf965aaa340 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/common/mvn.cpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/common/mvn.cpp @@ -7,12 +7,10 @@ #include "test_utils/cpu_test_utils.hpp" #include "test_utils/fusing_test_utils.hpp" -using namespace InferenceEngine; using namespace CPUTestUtils; -using namespace ngraph::helpers; -using namespace ov::test; -namespace CPULayerTestsDefinitions { +namespace ov { +namespace test { namespace MVN { const std::vector normalizeVariance = { @@ -210,5 +208,6 @@ const auto Mvn5DStatic = ::testing::Combine( INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_Mvn5D_Static, MvnLayerCPUTest, Mvn5DStatic, MvnLayerCPUTest::getTestCaseName); -} // namespace MVN -} // namespace CPULayerTestsDefinitions \ No newline at end of file +} // namespace MVN +} // namespace test +} // namespace ov \ No newline at end of file diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/common/nms_rotated.cpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/common/nms_rotated.cpp index 7888a88a60221d..12c10e0087f2f8 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/common/nms_rotated.cpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/common/nms_rotated.cpp @@ -5,8 +5,9 @@ #include "single_op_tests/nms_rotated.hpp" using namespace LayerTestsDefinitions; -using namespace ov::test; +namespace ov { +namespace test { static const std::vector> input_shapes = { { @@ -93,3 +94,6 @@ INSTANTIATE_TEST_SUITE_P(nightly_, NmsRotatedOpTest, ::testing::Values(empty_plugin_config), ::testing::Values(utils::DEVICE_CPU)), NmsRotatedOpTest::getTestCaseName); + +} // namespace test +} // namespace ov \ No newline at end of file diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/common/pooling.cpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/common/pooling.cpp index e15408a6085b9d..c4c0121461830c 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/common/pooling.cpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/common/pooling.cpp @@ -7,12 +7,10 @@ #include "test_utils/cpu_test_utils.hpp" #include "test_utils/fusing_test_utils.hpp" -using namespace InferenceEngine; using namespace CPUTestUtils; -using namespace ngraph::helpers; -using namespace ov::test; -namespace CPULayerTestsDefinitions { +namespace ov { +namespace test { namespace Pooling { static CPUSpecificParams expectedCpuConfig() { @@ -24,9 +22,9 @@ static CPUSpecificParams expectedCpuConfig() { } const std::vector vecCpuConfigs = {expectedCpuConfig()}; -const std::vector paramsAvg3D_RefOnly = { - LayerTestsDefinitions::poolSpecificParams{ ngraph::helpers::PoolingTypes::AVG, {2}, {2}, {2}, {2}, - expectedAvgRoundingType(), ngraph::op::PadType::EXPLICIT, false }, +const std::vector paramsAvg3D_RefOnly = { + poolSpecificParams{ ov::test::utils::PoolingTypes::AVG, {2}, {2}, {2}, {2}, + expectedAvgRoundingType(), ov::op::PadType::EXPLICIT, false }, }; INSTANTIATE_TEST_SUITE_P(smoke_MaxPool_CPU_3D, PoolingLayerCPUTest, @@ -59,9 +57,9 @@ INSTANTIATE_TEST_SUITE_P(smoke_AvgPool_CPU_3D_NotOptimized, PoolingLayerCPUTest, ::testing::Values(emptyFusingSpec)), PoolingLayerCPUTest::getTestCaseName); -const std::vector paramsAvg4D_RefOnly = { - LayerTestsDefinitions::poolSpecificParams{ ngraph::helpers::PoolingTypes::AVG, {2, 2}, {2, 2}, {2, 2}, {2, 2}, - expectedAvgRoundingType(), ngraph::op::PadType::EXPLICIT, false }, +const std::vector paramsAvg4D_RefOnly = { + poolSpecificParams{ ov::test::utils::PoolingTypes::AVG, {2, 2}, {2, 2}, {2, 2}, {2, 2}, + expectedAvgRoundingType(), ov::op::PadType::EXPLICIT, false }, }; INSTANTIATE_TEST_SUITE_P(smoke_MaxPool_CPU_4D, PoolingLayerCPUTest, @@ -112,21 +110,21 @@ INSTANTIATE_TEST_SUITE_P(smoke_AvgPool_CPU_Large, PoolingLayerCPUTest, ::testing::Values(emptyFusingSpec)), PoolingLayerCPUTest::getTestCaseName); -const std::vector paramsMaxV85D_ref = { - LayerTestsDefinitions::maxPoolV8SpecificParams{ {2, 2, 2}, {1, 1, 1}, {2, 2, 2}, {0, 0, 0}, {0, 0, 0}, - ngraph::element::Type_t::i32, 0, - ngraph::op::RoundingType::CEIL, ngraph::op::PadType::SAME_UPPER }, - LayerTestsDefinitions::maxPoolV8SpecificParams{ {2, 2, 2}, {1, 1, 1}, {2, 2, 2}, {1, 1, 1}, {1, 1, 1}, - ngraph::element::Type_t::i32, 0, - ngraph::op::RoundingType::CEIL, ngraph::op::PadType::EXPLICIT }, - LayerTestsDefinitions::maxPoolV8SpecificParams{ {2, 3, 4}, {2, 2, 2}, {2, 1, 1}, {1, 1, 1}, {1, 2, 2}, - ngraph::element::Type_t::i32, 0, - ngraph::op::RoundingType::CEIL, ngraph::op::PadType::EXPLICIT }, +const std::vector paramsMaxV85D_ref = { + maxPoolV8SpecificParams{ {2, 2, 2}, {1, 1, 1}, {2, 2, 2}, {0, 0, 0}, {0, 0, 0}, + ov::element::Type_t::i32, 0, + ov::op::RoundingType::CEIL, ov::op::PadType::SAME_UPPER }, + maxPoolV8SpecificParams{ {2, 2, 2}, {1, 1, 1}, {2, 2, 2}, {1, 1, 1}, {1, 1, 1}, + ov::element::Type_t::i32, 0, + ov::op::RoundingType::CEIL, ov::op::PadType::EXPLICIT }, + maxPoolV8SpecificParams{ {2, 3, 4}, {2, 2, 2}, {2, 1, 1}, {1, 1, 1}, {1, 2, 2}, + ov::element::Type_t::i32, 0, + ov::op::RoundingType::CEIL, ov::op::PadType::EXPLICIT }, }; -const std::vector paramsAvg5D_RefOnly = { - LayerTestsDefinitions::poolSpecificParams{ ngraph::helpers::PoolingTypes::AVG, {2, 2, 2}, {2, 2, 2}, {2, 2, 2}, {2, 2, 2}, - expectedAvgRoundingType(), ngraph::op::PadType::EXPLICIT, false }, +const std::vector paramsAvg5D_RefOnly = { + poolSpecificParams{ ov::test::utils::PoolingTypes::AVG, {2, 2, 2}, {2, 2, 2}, {2, 2, 2}, {2, 2, 2}, + expectedAvgRoundingType(), ov::op::PadType::EXPLICIT, false }, }; //FIXME: 5D cases are temporarly disabled on ARM because ACL support check in Pooling::getSupportedDescriptors() can't check layout @@ -177,5 +175,6 @@ INSTANTIATE_TEST_SUITE_P(smoke_AvgPool_CPU_5D_NotOptimized, PoolingLayerCPUTest, ::testing::Values(emptyFusingSpec)), PoolingLayerCPUTest::getTestCaseName); #endif -} // namespace Pooling -} // namespace CPULayerTestsDefinitions \ No newline at end of file +} // namespace Pooling +} // namespace test +} // namespace ov \ No newline at end of file diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/common/random_uniform.cpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/common/random_uniform.cpp index f319fb6ada2719..61101375bb5598 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/common/random_uniform.cpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/common/random_uniform.cpp @@ -5,9 +5,9 @@ #include "single_layer_tests/classes/random_uniform.hpp" using namespace CPUTestUtils; -using namespace ov::test; -namespace CPULayerTestsDefinitions { +namespace ov { +namespace test { namespace RandomUniform { static const std::vector shape_prc = { @@ -64,5 +64,6 @@ INSTANTIATE_TEST_SUITE_P(smoke_ParamConst, RandomUniformLayerTestCPU, ::testing::Values(empty_plugin_config)), RandomUniformLayerTestCPU::getTestCaseName); -} // namespace RandomUniform -} // namespace CPULayerTestsDefinitions +} // namespace RandomUniform +} // namespace test +} // namespace ov diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/common/reduce.cpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/common/reduce.cpp index 22c49156eba333..3de2c8e4f2bbdc 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/common/reduce.cpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/common/reduce.cpp @@ -7,12 +7,10 @@ #include "test_utils/cpu_test_utils.hpp" #include "test_utils/fusing_test_utils.hpp" -using namespace InferenceEngine; using namespace CPUTestUtils; -using namespace ngraph::helpers; -using namespace ov::test; -namespace CPULayerTestsDefinitions { +namespace ov { +namespace test { namespace Reduce { std::vector> inputShapes = { @@ -161,5 +159,6 @@ INSTANTIATE_TEST_SUITE_P( ReduceCPULayerTest::getTestCaseName ); -} // namespace Reduce -} // namespace CPULayerTestsDefinitions \ No newline at end of file +} // namespace Reduce +} // namespace test +} // namespace ov \ No newline at end of file diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/common/softmax.cpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/common/softmax.cpp index 03655fd40a536d..6a17df004e92ce 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/common/softmax.cpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/common/softmax.cpp @@ -5,12 +5,10 @@ #include "single_layer_tests/classes/softmax.hpp" #include "test_utils/cpu_test_utils.hpp" -using namespace InferenceEngine; using namespace CPUTestUtils; -using namespace ngraph::helpers; -using namespace ov::test; -namespace CPULayerTestsDefinitions { +namespace ov { +namespace test { namespace SoftMax { const auto notOptimizedCPUSpec = CPUSpecificParams{{}, {}, {"ref_any"}, "ref_any"}; @@ -146,5 +144,6 @@ INSTANTIATE_TEST_SUITE_P(smoke_SoftMax_Unsupported_CPU, SoftMaxLayerCPUTest, UnsupportedParams, SoftMaxLayerCPUTest::getTestCaseName); -} // namespace SoftMax -} // namespace CPULayerTestsDefinitions \ No newline at end of file +} // namespace SoftMax +} // namespace test +} // namespace ov \ No newline at end of file diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/common/transpose.cpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/common/transpose.cpp index c1260a923b09a1..23ef684f1076f2 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/common/transpose.cpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/common/transpose.cpp @@ -6,14 +6,12 @@ #include "shared_test_classes/single_layer/transpose.hpp" #include "test_utils/cpu_test_utils.hpp" -using namespace InferenceEngine; using namespace CPUTestUtils; -using namespace ngraph::helpers; -using namespace ov::test; -namespace CPULayerTestsDefinitions { +namespace ov { +namespace test { namespace Transpose { -std::vector> additional_config = { +std::vector additional_config = { {{ov::hint::inference_precision.name(), ov::element::f32.to_string()}}, {{ov::hint::inference_precision.name(), ov::element::f16.to_string()}} }; @@ -21,9 +19,9 @@ std::vector> additional_config = { const auto cpuParams_nhwc = CPUSpecificParams {{nhwc}, {}, {}, {}}; const auto cpuParams_nchw = CPUSpecificParams {{nchw}, {}, {}, {}}; -const std::vector netPrecisions = { - Precision::I8, - Precision::FP32 +const std::vector netPrecisions = { + ov::element::i8, + ov::element::f32 }; const std::vector> inputOrderPerChannels4D = { @@ -97,5 +95,6 @@ INSTANTIATE_TEST_SUITE_P(smoke_dynamicShapes4D_PermutePerChannels, TransposeLaye ::testing::Values(CPUSpecificParams{})), TransposeLayerCPUTest::getTestCaseName); -} // namespace Transpose -} // namespace CPULayerTestsDefinitions \ No newline at end of file +} // namespace Transpose +} // namespace test +} // namespace ov \ No newline at end of file diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/x64/activation.cpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/x64/activation.cpp index 84b5b401de171c..89d8a7c0250294 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/x64/activation.cpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/x64/activation.cpp @@ -6,19 +6,18 @@ #include "shared_test_classes/single_layer/activation.hpp" #include "test_utils/cpu_test_utils.hpp" -using namespace InferenceEngine; using namespace CPUTestUtils; -using namespace ngraph::helpers; -using namespace ov::test; +using namespace ov::test::utils; -namespace CPULayerTestsDefinitions { +namespace ov { +namespace test { namespace Activation { namespace { -const std::vector& netPrc() { - static const std::vector netPrc { - Precision::FP32, - Precision::BF16, +const std::vector& netPrc() { + static const std::vector netPrc { + ov::element::f32, + ov::element::bf16, }; return netPrc; @@ -46,8 +45,8 @@ const auto blockedCases3D = ::testing::Combine( ::testing::Values(activationShapes()), ::testing::ValuesIn(ov::test::utils::combineParams(activationTypesBlocked())), ::testing::ValuesIn(netPrc()), - ::testing::Values(Precision::FP32), - ::testing::Values(Precision::FP32), + ::testing::Values(ov::element::f32), + ::testing::Values(ov::element::f32), ::testing::ValuesIn(filterCPUSpecificParams(cpuParams3Dblocked())) ); @@ -67,8 +66,8 @@ const auto basicCases4D = ::testing::Combine( ::testing::Values(activationShapes()), ::testing::ValuesIn(ov::test::utils::combineParams(activationTypes())), ::testing::ValuesIn(netPrc()), - ::testing::Values(Precision::FP32), - ::testing::Values(Precision::FP32), + ::testing::Values(ov::element::f32), + ::testing::Values(ov::element::f32), ::testing::ValuesIn(filterCPUSpecificParams(cpuParams4Dblocked())) ); @@ -88,13 +87,14 @@ const auto basicCases5D = ::testing::Combine( ::testing::Values(activationShapes()), ::testing::ValuesIn(ov::test::utils::combineParams(activationTypes())), ::testing::ValuesIn(netPrc()), - ::testing::Values(Precision::FP32), - ::testing::Values(Precision::FP32), + ::testing::Values(ov::element::f32), + ::testing::Values(ov::element::f32), ::testing::ValuesIn(filterCPUSpecificParams(cpuParams5Dblocked())) ); INSTANTIATE_TEST_SUITE_P(smoke_Activation5D_Eltwise_CPU_Blocked, ActivationLayerCPUTest, basicCases5D, ActivationLayerCPUTest::getTestCaseName); -} // namespace -} // namespace Activation -} // namespace CPULayerTestsDefinitions +} // namespace +} // namespace Activation +} // namespace test +} // namespace ov diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/x64/conversion.cpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/x64/conversion.cpp index 9206eca36d7352..258b0ef53a361e 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/x64/conversion.cpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/x64/conversion.cpp @@ -6,12 +6,10 @@ #include "shared_test_classes/single_layer/conversion.hpp" #include "test_utils/cpu_test_utils.hpp" -using namespace InferenceEngine; using namespace CPUTestUtils; -using namespace ngraph::helpers; -using namespace ov::test; -namespace CPULayerTestsDefinitions { +namespace ov { +namespace test { namespace Conversion { namespace { @@ -36,9 +34,9 @@ std::vector memForm4D_static_blocked = { CPUSpecificParams({nChw16c}, {nChw16c}, {}, {}) }; -const std::vector precisions_floating_point = { - Precision::FP32, - Precision::BF16 +const std::vector precisions_floating_point = { + ov::element::f32, + ov::element::bf16 }; INSTANTIATE_TEST_SUITE_P(smoke_ConvertCPULayerTest_Blocked, ConvertCPULayerTest, @@ -53,7 +51,7 @@ INSTANTIATE_TEST_SUITE_P(smoke_ConvertCPULayerTest_BOOL_Static, ConvertCPULayerT ::testing::Combine( ::testing::ValuesIn(inShapes_4D_static()), ::testing::ValuesIn(precisions_floating_point), - ::testing::Values(Precision::BOOL), + ::testing::Values(ov::element::boolean), ::testing::Values(CPUSpecificParams({nchw}, {nchw}, {}, {}))), ConvertCPULayerTest::getTestCaseName); @@ -61,10 +59,11 @@ INSTANTIATE_TEST_SUITE_P(smoke_ConvertCPULayerTest_BOOL_Dynamic, ConvertCPULayer ::testing::Combine( ::testing::ValuesIn(inShapes_4D_dynamic()), ::testing::ValuesIn(precisions_floating_point), - ::testing::Values(Precision::BOOL), + ::testing::Values(ov::element::boolean), ::testing::Values(CPUSpecificParams({nchw}, {nchw}, {}, "ref"))), ConvertCPULayerTest::getTestCaseName); } // namespace } // namespace Conversion -} // namespace CPULayerTestsDefinitions \ No newline at end of file +} // namespace test +} // namespace ov \ No newline at end of file diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/x64/convolution.cpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/x64/convolution.cpp new file mode 100644 index 00000000000000..7bf4274e6efd84 --- /dev/null +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/x64/convolution.cpp @@ -0,0 +1,669 @@ +// Copyright (C) 2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "single_layer_tests/classes/convolution.hpp" +#include "shared_test_classes/single_layer/convolution.hpp" +#include "test_utils/cpu_test_utils.hpp" +#include "test_utils/filter_cpu_info.hpp" + +using namespace InferenceEngine; +using namespace CPUTestUtils; +using namespace ngraph::helpers; +using namespace ov::test; + +namespace CPULayerTestsDefinitions { +namespace Convolution { +namespace { + +std::vector filterCPUInfoForDevice_BF16(std::vector allParams) { + std::vector specificParams; + bool with_bf16 = with_cpu_x86_bfloat16(); + std::copy_if(allParams.begin(), allParams.end(), std::back_inserter(specificParams), [with_bf16](const CPUSpecificParams& item) { + const auto &selected = std::get<3>(item); + // when no bf16 hardware brgconv will not work + if (!with_bf16 && selected.find("brgconv") != std::string::npos) { + return false; + } + return true; + }); + + return filterCPUInfoForDevice(specificParams); +} + +const std::vector fusingParamsSetWithoutEmpty{ + // eltwise + fusingRelu, + fusingPRelu1DScaleShift, + // depthwise + fusingReluScaleShift, + // fake quantize + fusingFakeQuantizePerTensorRelu, + fusingFakeQuantizePerChannelRelu, + // sum + fusingSumEluFQ, + fusingSum, + // bias + fusingAddPerChannel +}; + +const std::vector fusingParamsSetBF16{ + emptyFusingSpec, + // eltwise + fusingRelu, + // depthwise + fusingPRelu1DScaleShift, + // sum + fusingSum, + // bias + fusingAddPerChannel +}; + +/* ============= Convolution (Gemm 1D) ============= */ +INSTANTIATE_TEST_SUITE_P(smoke_Conv_1D_GEMM_FP32, ConvolutionLayerCPUTest, + ::testing::Combine( + ::testing::Combine( + convParams_ExplicitPadding_GEMM_1D(), + ::testing::Values(ElementType::f32), + ::testing::Values(ElementType::undefined), + ::testing::Values(ElementType::undefined), + ::testing::ValuesIn(inShapesGemm1D()), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::ValuesIn(filterCPUInfo(CPUParams_GEMM_1D())), + ::testing::ValuesIn(fusingParamsSetWithEmpty()), + ::testing::Values(cpuEmptyPluginConfig)), + ConvolutionLayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_Conv_1D_GEMM_FP32_ImproperPriorityList, ConvolutionLayerCPUTest, + ::testing::Combine( + ::testing::Combine( + convParams_ExplicitPadding_GEMM_1D(), + ::testing::Values(ElementType::f32), + ::testing::Values(ElementType::undefined), + ::testing::Values(ElementType::undefined), + ::testing::ValuesIn(inShapesGemm1D()), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::ValuesIn(filterCPUInfo({conv_gemm_1D})), + ::testing::Values(emptyFusingSpec), + ::testing::Values(cpuEmptyPluginConfig)), + ConvolutionLayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_Conv_1D_GEMM_BF16, ConvolutionLayerCPUTest, + ::testing::Combine( + ::testing::Combine( + convParams_ExplicitPadding_GEMM_1D(), + ::testing::Values(ElementType::f32), + ::testing::Values(ElementType::undefined), + ::testing::Values(ElementType::undefined), + ::testing::ValuesIn(inShapesGemm1D()), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::ValuesIn(filterCPUInfo({conv_gemm_1D})), // todo: [AV] what about conv_gemm_1D_nspc? + ::testing::ValuesIn(fusingParamsSetBF16), + ::testing::Values(cpuBF16PluginConfig)), + ConvolutionLayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_Conv_1D_GEMM_I8, ConvolutionLayerCPUTest, + ::testing::Combine( + ::testing::Combine( + convParams_ExplicitPadding_GEMM_1D(), + ::testing::Values(ElementType::f32), + ::testing::Values(ElementType::i8), + ::testing::Values(ElementType::undefined), + ::testing::ValuesIn(inShapesGemm1D()), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::ValuesIn(filterCPUInfo(CPUParams_GEMM_1D())), + ::testing::Values(fusingSum), + ::testing::Values(cpuEmptyPluginConfig)), + ConvolutionLayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_Conv_2D_GEMM_BF16, ConvolutionLayerCPUTest, + ::testing::Combine( + ::testing::Combine( + convParams_ExplicitPadding_GEMM_2D(), + ::testing::Values(ElementType::f32), + ::testing::Values(ElementType::undefined), + ::testing::Values(ElementType::undefined), + ::testing::ValuesIn(inShapesGemm2D()), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::ValuesIn(filterCPUInfo(CPUParams_GEMM_2D())), + ::testing::ValuesIn(fusingParamsSetBF16), + ::testing::Values(cpuBF16PluginConfig)), + ConvolutionLayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(Conv_2D_GEMM_BF16_dilated, ConvolutionLayerCPUTest, + ::testing::Combine( + ::testing::Combine( + convParams_ExplicitPadding_GEMM_2D_dilated(), + ::testing::Values(ElementType::f32), + ::testing::Values(ElementType::undefined), + ::testing::Values(ElementType::undefined), + ::testing::ValuesIn(inShapesGemm2D()), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::ValuesIn(filterCPUInfo(CPUParams_GEMM_2D())), + ::testing::ValuesIn(fusingParamsSetBF16), + ::testing::Values(cpuBF16PluginConfig)), + ConvolutionLayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_Conv_2D_GEMM_FP32_fusing, ConvolutionLayerCPUTest, + ::testing::Combine( + ::testing::Combine( + convParams_ExplicitPadding_GEMM_2D(), + ::testing::Values(ElementType::f32), + ::testing::Values(ElementType::undefined), + ::testing::Values(ElementType::undefined), + ::testing::ValuesIn(inShapesGemm2D_cache()), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::ValuesIn(filterCPUInfo(CPUParams_GEMM_2D())), + ::testing::ValuesIn(fusingParamsSetWithoutEmpty), + ::testing::Values(cpuEmptyPluginConfig)), + ConvolutionLayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(Conv_2D_GEMM_FP32_dilated_fusing, ConvolutionLayerCPUTest, + ::testing::Combine( + ::testing::Combine( + convParams_ExplicitPadding_GEMM_2D_dilated(), + ::testing::Values(ElementType::f32), + ::testing::Values(ElementType::undefined), + ::testing::Values(ElementType::undefined), + ::testing::ValuesIn(inShapesGemm2D()), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::ValuesIn(filterCPUInfo(CPUParams_GEMM_2D())), + ::testing::ValuesIn(fusingParamsSetWithoutEmpty), + ::testing::Values(cpuEmptyPluginConfig)), + ConvolutionLayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_Conv_2D_FP32_fusing, ConvolutionLayerCPUTest, + ::testing::Combine( + ::testing::Combine( + convParams_ExplicitPadding_2D(), + ::testing::Values(ElementType::f32), + ::testing::Values(ElementType::undefined), + ::testing::Values(ElementType::undefined), + ::testing::ValuesIn(inputShapes2d_cache()), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::ValuesIn(filterCPUInfo(CPUParams_2D())), + ::testing::ValuesIn(fusingParamsSetWithoutEmpty), + ::testing::Values(cpuEmptyPluginConfig)), + ConvolutionLayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(Conv_2D_FP32_dilated_fusing, ConvolutionLayerCPUTest, + ::testing::Combine( + ::testing::Combine( + convParams_ExplicitPadding_2D_dilated(), + ::testing::Values(ElementType::f32), + ::testing::Values(ElementType::undefined), + ::testing::Values(ElementType::undefined), + ::testing::ValuesIn(inputShapes2d()), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::ValuesIn(filterCPUInfo(CPUParams_2D())), + ::testing::ValuesIn(fusingParamsSetWithoutEmpty), + ::testing::Values(cpuEmptyPluginConfig)), + ConvolutionLayerCPUTest::getTestCaseName); + +/* ============= Kernel_1x1 (1D) ============= */ +INSTANTIATE_TEST_SUITE_P(smoke_Conv_1D_1x1_FP32_fusing, ConvolutionLayerCPUTest, + ::testing::Combine( + ::testing::Combine( + convParams_ExplicitPadding_1x1_1D(), + ::testing::Values(ElementType::f32), + ::testing::Values(ElementType::undefined), + ::testing::Values(ElementType::undefined), + ::testing::ValuesIn(inputShapes1d()), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::ValuesIn(filterCPUInfo(CPUParams_1x1_1D())), + ::testing::ValuesIn(fusingParamsSetWithoutEmpty), + ::testing::Values(cpuEmptyPluginConfig)), + ConvolutionLayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_Conv_2D_1x1_FP32_fusing, ConvolutionLayerCPUTest, + ::testing::Combine( + ::testing::Combine( + convParams_ExplicitPadding_1x1_2D(), + ::testing::Values(ElementType::f32), + ::testing::Values(ElementType::undefined), + ::testing::Values(ElementType::undefined), + ::testing::ValuesIn(inputShapes2d()), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::ValuesIn(filterCPUInfo(CPUParams_1x1_2D())), + ::testing::ValuesIn(fusingParamsSetWithoutEmpty), + ::testing::Values(cpuEmptyPluginConfig)), + ConvolutionLayerCPUTest::getTestCaseName); + +/* ============= Convolution (1D) ============= */ +const auto convParams_ExplicitPadding_1D = ::testing::Combine( + ::testing::ValuesIn(kernels1d()), + ::testing::ValuesIn(strides1d()), + ::testing::ValuesIn(padBegins1d()), + ::testing::ValuesIn(padEnds1d()), + ::testing::ValuesIn(dilations1d()), + ::testing::ValuesIn(numOutChannels()), + ::testing::Values(ngraph::op::PadType::EXPLICIT) +); + +const std::vector CPUParams_1D = { + conv_sse42_1D, + conv_avx2_1D, + conv_avx512_1D, + conv_sse42_1D_nspc, + conv_avx2_1D_nspc, + conv_avx2_1D_nspc_brgconv, + conv_avx512_1D_nspc, + conv_avx512_1D_nspc_brgconv +}; + +INSTANTIATE_TEST_SUITE_P(smoke_Conv_1D_FP32, ConvolutionLayerCPUTest, + ::testing::Combine( + ::testing::Combine( + convParams_ExplicitPadding_1D, + ::testing::Values(ElementType::f32), + ::testing::Values(ElementType::undefined), + ::testing::Values(ElementType::undefined), + ::testing::ValuesIn(inputShapes1d()), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::ValuesIn(filterCPUInfo(CPUParams_1D)), + ::testing::ValuesIn(fusingParamsSetWithEmpty()), + ::testing::Values(cpuEmptyPluginConfig)), + ConvolutionLayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_Conv_1D_BF16, ConvolutionLayerCPUTest, + ::testing::Combine( + ::testing::Combine( + convParams_ExplicitPadding_1D, + ::testing::Values(ElementType::f32), + ::testing::Values(ElementType::undefined), + ::testing::Values(ElementType::undefined), + ::testing::ValuesIn(inputShapes1d()), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::ValuesIn(filterCPUInfoForDevice_BF16({conv_avx512_1D, + conv_avx512_1D_nspc_brgconv, conv_avx512_1D_nspc_brgconv_amx})), // todo: [AV] what about conv_avx512_1D_nspc? + ::testing::ValuesIn(fusingParamsSetBF16), + ::testing::Values(cpuBF16PluginConfig)), + ConvolutionLayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_Conv_1D_I8, ConvolutionLayerCPUTest, + ::testing::Combine( + ::testing::Combine( + convParams_ExplicitPadding_1D, + ::testing::Values(ElementType::f32), + ::testing::Values(ElementType::i8), + ::testing::Values(ElementType::undefined), + ::testing::ValuesIn(inputShapes1d()), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::ValuesIn(filterCPUInfo(CPUParams_1D)), + ::testing::Values(fusingSum), + ::testing::Values(cpuEmptyPluginConfig)), + ConvolutionLayerCPUTest::getTestCaseName); + +const std::vector CPUParams_1D_plain_to_blocked = { + conv_sse42_plain_to_blocked_1D, + conv_avx2_plain_to_blocked_1D, + conv_avx512_plain_to_blocked_1D, +}; + +std::vector inputShapesPlain2Blocked1d = { + {{}, {{1, 1, 7}}}, + {{}, {{1, 2, 7}}}, + {{}, {{1, 3, 7}}}, + { + //dynamic shapes + {-1, 1, {1, 200}}, + { //target static shapes + {2, 1, 7}, + {1, 1, 9} + } + }, + { + //dynamic shapes + {-1, 3, {1, 200}}, + { //target static shapes + {2, 3, 7}, + {1, 3, 9} + } + } +}; + +INSTANTIATE_TEST_SUITE_P(smoke_Conv_1D_PlainToBlocked_FP32, ConvolutionLayerCPUTest, + ::testing::Combine( + ::testing::Combine( + convParams_ExplicitPadding_1D, + ::testing::Values(ElementType::f32), + ::testing::Values(ElementType::undefined), + ::testing::Values(ElementType::undefined), + ::testing::ValuesIn(inputShapesPlain2Blocked1d), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::ValuesIn(filterCPUInfo(CPUParams_1D_plain_to_blocked)), + ::testing::Values(emptyFusingSpec), + ::testing::Values(cpuEmptyPluginConfig)), + ConvolutionLayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_Conv_1D_PlainToBlocked_BF16, ConvolutionLayerCPUTest, + ::testing::Combine( + ::testing::Combine( + convParams_ExplicitPadding_1D, + ::testing::Values(ElementType::f32), + ::testing::Values(ElementType::undefined), + ::testing::Values(ElementType::undefined), + ::testing::ValuesIn(inputShapesPlain2Blocked1d), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::ValuesIn(filterCPUInfo({conv_avx512_plain_to_blocked_1D})), + ::testing::Values(emptyFusingSpec), + ::testing::Values(cpuEmptyPluginConfig)), + ConvolutionLayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_Conv_2D_BF16, ConvolutionLayerCPUTest, + ::testing::Combine( + ::testing::Combine( + convParams_ExplicitPadding_2D(), + ::testing::Values(ElementType::f32), + ::testing::Values(ElementType::undefined), + ::testing::Values(ElementType::undefined), + ::testing::ValuesIn(inputShapes2d()), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::ValuesIn(filterCPUInfoForDevice_BF16({conv_avx512_2D, conv_avx512_2D_nspc, + conv_avx512_2D_nspc_brgconv, conv_avx512_2D_nspc_brgconv_amx})), + ::testing::ValuesIn(fusingParamsSetBF16), + ::testing::Values(cpuBF16PluginConfig)), + ConvolutionLayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(Conv_2D_BF16_dilated, ConvolutionLayerCPUTest, + ::testing::Combine( + ::testing::Combine( + convParams_ExplicitPadding_2D_dilated(), + ::testing::Values(ElementType::f32), + ::testing::Values(ElementType::undefined), + ::testing::Values(ElementType::undefined), + ::testing::ValuesIn(inputShapes2d()), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::ValuesIn(filterCPUInfoForDevice_BF16({conv_avx512_2D, conv_avx512_2D_nspc, + conv_avx512_2D_nspc_brgconv, conv_avx512_2D_nspc_brgconv_amx})), + ::testing::ValuesIn(fusingParamsSetBF16), + ::testing::Values(cpuBF16PluginConfig)), + ConvolutionLayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_Conv_2D_PlainToBlocked_BF16, ConvolutionLayerCPUTest, + ::testing::Combine( + ::testing::Combine( + convParams_ExplicitPadding_2D(), + ::testing::Values(ElementType::f32), + ::testing::Values(ElementType::undefined), + ::testing::Values(ElementType::undefined), + ::testing::ValuesIn(inputShapesPlain2Blocked2d()), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::ValuesIn(filterCPUInfo({conv_avx512_plain_to_blocked_2D})), + ::testing::Values(emptyFusingSpec), + ::testing::Values(cpuEmptyPluginConfig)), + ConvolutionLayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(Conv_PlainToBlocked_2D_BF16_dilated, ConvolutionLayerCPUTest, + ::testing::Combine( + ::testing::Combine( + convParams_ExplicitPadding_2D_dilated(), + ::testing::Values(ElementType::f32), + ::testing::Values(ElementType::undefined), + ::testing::Values(ElementType::undefined), + ::testing::ValuesIn(inputShapesPlain2Blocked2d()), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::ValuesIn(filterCPUInfo({conv_avx512_plain_to_blocked_2D})), + ::testing::Values(emptyFusingSpec), + ::testing::Values(cpuEmptyPluginConfig)), + ConvolutionLayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_Conv_1D_1x1_BF16, ConvolutionLayerCPUTest, + ::testing::Combine( + ::testing::Combine( + convParams_ExplicitPadding_1x1_1D(), + ::testing::Values(ElementType::f32), + ::testing::Values(ElementType::undefined), + ::testing::Values(ElementType::undefined), + ::testing::ValuesIn(inputShapes1d()), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::ValuesIn(filterCPUInfoForDevice_BF16({conv_avx512_1D_1x1, conv_avx512_2D_1x1_nspc, + conv_avx512_1D_1x1_nspc_brgconv, conv_avx512_1D_1x1_nspc_brgconv_amx})), + ::testing::ValuesIn(fusingParamsSetBF16), + ::testing::Values(cpuBF16PluginConfig)), + ConvolutionLayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_Conv_2D_1x1_BF16, ConvolutionLayerCPUTest, + ::testing::Combine( + ::testing::Combine( + convParams_ExplicitPadding_1x1_2D(), + ::testing::Values(ElementType::f32), + ::testing::Values(ElementType::undefined), + ::testing::Values(ElementType::undefined), + ::testing::ValuesIn(inputShapes2d()), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::ValuesIn(filterCPUInfoForDevice_BF16({conv_avx512_2D_1x1, conv_avx512_2D_1x1_nspc, + conv_avx512_2D_1x1_nspc_brgconv, conv_avx512_2D_1x1_nspc_brgconv_amx})), + ::testing::ValuesIn(fusingParamsSetBF16), + ::testing::Values(cpuBF16PluginConfig)), + ConvolutionLayerCPUTest::getTestCaseName); + +/* ============= Jit Planar ============= */ +/* ============= Convolution planar params (2D) ============= */ +const std::vector CPUParams_Jit_Planar_2D = { + // sse42 is not supported + conv_avx2_planar_2D, + conv_avx512_planar_2D, +}; + +const auto convParams_Planar_ExplicitPadding_2D = ::testing::Combine( + ::testing::ValuesIn(kernels2d()), + ::testing::Values(SizeVector{1, 1}), + ::testing::ValuesIn(padBegins2d()), + ::testing::ValuesIn(padEnds2d()), + ::testing::ValuesIn(dilations2d()), + ::testing::Values(1), + ::testing::Values(ngraph::op::PadType::EXPLICIT) +); + +const auto convParams_Planar_ExplicitPadding_2D_dilated = ::testing::Combine( + ::testing::ValuesIn(kernels2d()), + ::testing::Values(SizeVector{1, 1}), + ::testing::ValuesIn(padBegins2d()), + ::testing::ValuesIn(padEnds2d()), + ::testing::Values(SizeVector{2, 2}), + ::testing::Values(1), + ::testing::Values(ngraph::op::PadType::EXPLICIT) +); + +INSTANTIATE_TEST_SUITE_P(smoke_Conv_2D_Jit_Planar_FP32, ConvolutionLayerCPUTest, + ::testing::Combine( + ::testing::Combine( + convParams_Planar_ExplicitPadding_2D, + ::testing::Values(ElementType::f32), + ::testing::Values(ElementType::undefined), + ::testing::Values(ElementType::undefined), + ::testing::ValuesIn(inputShapes2d()), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::ValuesIn(filterCPUInfo(CPUParams_Jit_Planar_2D)), + ::testing::Values(emptyFusingSpec, fusingRelu), + ::testing::Values(cpuEmptyPluginConfig)), + ConvolutionLayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(Conv_2D_Jit_Planar_FP32_dilated, ConvolutionLayerCPUTest, + ::testing::Combine( + ::testing::Combine( + convParams_Planar_ExplicitPadding_2D_dilated, + ::testing::Values(ElementType::f32), + ::testing::Values(ElementType::undefined), + ::testing::Values(ElementType::undefined), + ::testing::ValuesIn(inputShapes2d()), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::ValuesIn(filterCPUInfo(CPUParams_Jit_Planar_2D)), + ::testing::Values(emptyFusingSpec, fusingRelu), + ::testing::Values(cpuEmptyPluginConfig)), + ConvolutionLayerCPUTest::getTestCaseName); + +/* ============= Convolution (GEMM 3D) ============= */ +INSTANTIATE_TEST_SUITE_P(smoke_Conv_3D_GEMM_FP32, ConvolutionLayerCPUTest, + ::testing::Combine( + ::testing::Combine( + convParams_ExplicitPadding_GEMM_3D(), + ::testing::Values(ElementType::f32), + ::testing::Values(ElementType::undefined), + ::testing::Values(ElementType::undefined), + ::testing::ValuesIn(inShapesGemm3D()), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::ValuesIn(filterCPUInfo(CPUParams_GEMM_3D())), + ::testing::Values(emptyFusingSpec), + ::testing::Values(cpuEmptyPluginConfig)), + ConvolutionLayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_Conv_3D_GEMM_I8, ConvolutionLayerCPUTest, + ::testing::Combine( + ::testing::Combine( + convParams_ExplicitPadding_GEMM_3D(), + ::testing::Values(ElementType::f32), + ::testing::Values(ElementType::i8), + ::testing::Values(ElementType::undefined), + ::testing::ValuesIn(inShapesGemm3D()), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::ValuesIn(filterCPUInfo(CPUParams_GEMM_3D())), + ::testing::Values(fusingSum), + ::testing::Values(cpuEmptyPluginConfig)), + ConvolutionLayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(Conv_3D_GEMM_FP32_dilated, ConvolutionLayerCPUTest, + ::testing::Combine( + ::testing::Combine( + convParams_ExplicitPadding_GEMM_3D_dilated(), + ::testing::Values(ElementType::f32), + ::testing::Values(ElementType::undefined), + ::testing::Values(ElementType::undefined), + ::testing::ValuesIn(inShapesGemm3D()), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::ValuesIn(filterCPUInfo(CPUParams_GEMM_3D())), + ::testing::Values(emptyFusingSpec), + ::testing::Values(cpuEmptyPluginConfig)), + ConvolutionLayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(Conv_3D_GEMM_I8_dilated, ConvolutionLayerCPUTest, + ::testing::Combine( + ::testing::Combine( + convParams_ExplicitPadding_GEMM_3D_dilated(), + ::testing::Values(ElementType::f32), + ::testing::Values(ElementType::i8), + ::testing::Values(ElementType::undefined), + ::testing::ValuesIn(inShapesGemm3D()), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::ValuesIn(filterCPUInfo(CPUParams_GEMM_3D())), + ::testing::Values(fusingSum), + ::testing::Values(cpuEmptyPluginConfig)), + ConvolutionLayerCPUTest::getTestCaseName); + +/* ============= Convolution planar params (3D) ============= */ +const std::vector CPUParams_Jit_Planar_3D = { + // sse42 is not supported + conv_avx2_planar_3D, + conv_avx512_planar_3D, +}; + +const auto convParams_Planar_ExplicitPadding_3D = ::testing::Combine( + ::testing::ValuesIn(kernels3d()), + ::testing::Values(SizeVector{1, 1, 1}), + ::testing::ValuesIn(padBegins3d()), + ::testing::ValuesIn(padEnds3d()), + ::testing::ValuesIn(dilations3d()), + ::testing::Values(1), + ::testing::Values(ngraph::op::PadType::EXPLICIT) +); + +const auto convParams_Planar_ExplicitPadding_3D_dilated = ::testing::Combine( + ::testing::ValuesIn(kernels3d()), + ::testing::Values(SizeVector{1, 1, 1}), + ::testing::ValuesIn(padBegins3d()), + ::testing::ValuesIn(padEnds3d()), + ::testing::Values(SizeVector{2, 2, 2}), + ::testing::Values(1), + ::testing::Values(ngraph::op::PadType::EXPLICIT) +); + +INSTANTIATE_TEST_SUITE_P(smoke_Conv_3D_GEMM_BF16, ConvolutionLayerCPUTest, + ::testing::Combine( + ::testing::Combine( + convParams_ExplicitPadding_GEMM_3D(), + ::testing::Values(ElementType::f32), + ::testing::Values(ElementType::undefined), + ::testing::Values(ElementType::undefined), + ::testing::ValuesIn(inShapesGemm3D()), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::ValuesIn(filterCPUInfo(CPUParams_GEMM_3D())), + ::testing::ValuesIn(fusingParamsSetBF16), + ::testing::Values(cpuBF16PluginConfig)), + ConvolutionLayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(Conv_3D_GEMM_BF16_dilated, ConvolutionLayerCPUTest, + ::testing::Combine( + ::testing::Combine( + convParams_ExplicitPadding_GEMM_3D_dilated(), + ::testing::Values(ElementType::f32), + ::testing::Values(ElementType::undefined), + ::testing::Values(ElementType::undefined), + ::testing::ValuesIn(inShapesGemm3D()), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::ValuesIn(filterCPUInfo(CPUParams_GEMM_3D())), + ::testing::ValuesIn(fusingParamsSetBF16), + ::testing::Values(cpuBF16PluginConfig)), + ConvolutionLayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_Conv_3D_BF16, ConvolutionLayerCPUTest, + ::testing::Combine( + ::testing::Combine( + convParams_ExplicitPadding_3D(), + ::testing::Values(ElementType::f32), + ::testing::Values(ElementType::undefined), + ::testing::Values(ElementType::undefined), + ::testing::ValuesIn(inputShapes3d()), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::ValuesIn(filterCPUInfoForDevice_BF16({conv_avx512_3D, conv_avx512_3D_nspc, + conv_avx512_3D_nspc_brgconv, conv_avx512_3D_nspc_brgconv_amx})), + ::testing::ValuesIn(fusingParamsSetBF16), + ::testing::Values(cpuBF16PluginConfig)), + ConvolutionLayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(Conv_3D_BF16_dilated, ConvolutionLayerCPUTest, + ::testing::Combine( + ::testing::Combine( + convParams_ExplicitPadding_3D_dilated(), + ::testing::Values(ElementType::f32), + ::testing::Values(ElementType::undefined), + ::testing::Values(ElementType::undefined), + ::testing::ValuesIn(inputShapes3d()), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::ValuesIn(filterCPUInfoForDevice_BF16({conv_avx512_3D, conv_avx512_3D_nspc, + conv_avx512_3D_nspc_brgconv, conv_avx512_3D_nspc_brgconv_amx})), + ::testing::ValuesIn(fusingParamsSetBF16), + ::testing::Values(cpuBF16PluginConfig)), + ConvolutionLayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_Conv_3D_Jit_Planar_FP32, ConvolutionLayerCPUTest, + ::testing::Combine( + ::testing::Combine( + convParams_Planar_ExplicitPadding_3D, + ::testing::Values(ElementType::f32), + ::testing::Values(ElementType::undefined), + ::testing::Values(ElementType::undefined), + ::testing::ValuesIn(inputShapes3d()), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::ValuesIn(filterCPUInfo(CPUParams_Jit_Planar_3D)), + ::testing::Values(emptyFusingSpec, fusingRelu), + ::testing::Values(cpuEmptyPluginConfig)), + ConvolutionLayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(Conv_3D_Jit_Planar_FP32_dilated, ConvolutionLayerCPUTest, + ::testing::Combine( + ::testing::Combine( + convParams_Planar_ExplicitPadding_3D_dilated, + ::testing::Values(ElementType::f32), + ::testing::Values(ElementType::undefined), + ::testing::Values(ElementType::undefined), + ::testing::ValuesIn(inputShapes3d()), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::ValuesIn(filterCPUInfo(CPUParams_Jit_Planar_3D)), + ::testing::Values(emptyFusingSpec, fusingRelu), + ::testing::Values(cpuEmptyPluginConfig)), + ConvolutionLayerCPUTest::getTestCaseName); + +} // namespace +} // namespace Convolution +} // namespace CPULayerTestsDefinitions \ No newline at end of file diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/x64/eltwise.cpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/x64/eltwise.cpp index 3136cfc3f606a3..9d44fb111d9eca 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/x64/eltwise.cpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/x64/eltwise.cpp @@ -9,13 +9,10 @@ #include #include -using namespace InferenceEngine; using namespace CPUTestUtils; -using namespace ngraph::helpers; -using namespace ov::test; - -namespace CPULayerTestsDefinitions { +namespace ov { +namespace test { namespace Eltwise { namespace { @@ -114,8 +111,8 @@ const std::vector>& inShapes_5D_Blocked_Planar() { return inShapes_5D_Blocked_Planar; } -const std::vector>& inShapes_5D_Planar_Blocked() { - static const std::vector> inShapes_5D_Planar_Blocked = { +const std::vector>& inShapes_5D_Planar_Blocked() { + static const std::vector> inShapes_5D_Planar_Blocked = { {{2, 1, 31, 1, 3}, {2, 17, 31, 4, 3}}, {{2, 1, 1, 3, 4}, {2, 17, 5, 3, 1}}, }; @@ -177,7 +174,7 @@ const auto params_4D_fusing = ::testing::Combine( ::testing::Combine( ::testing::ValuesIn(static_shapes_to_test_representation(inShapes_4D_fusing())), ::testing::ValuesIn(eltwiseOpTypesBinInp()), - ::testing::Values(ngraph::helpers::InputLayerType::PARAMETER), + ::testing::Values(ov::test::utils::InputLayerType::PARAMETER), ::testing::ValuesIn(opTypes()), ::testing::Values(ElementType::f32), ::testing::Values(ov::element::undefined), @@ -194,7 +191,7 @@ const auto params_4D_fusing_blocked_blocked = ::testing::Combine( ::testing::Combine( ::testing::ValuesIn(static_shapes_to_test_representation(inShapes_4D_fusing())), ::testing::ValuesIn(eltwiseOpTypesBinInp()), - ::testing::Values(ngraph::helpers::InputLayerType::PARAMETER), + ::testing::Values(ov::test::utils::InputLayerType::PARAMETER), ::testing::ValuesIn(opTypes()), ::testing::Values(ElementType::f32), ::testing::Values(ov::element::undefined), @@ -212,7 +209,7 @@ const auto params_4D_blocked_blocked_fusing = ::testing::Combine( ::testing::Combine( ::testing::ValuesIn(static_shapes_to_test_representation(inShapes_4D_fusing())), ::testing::ValuesIn(eltwiseOpTypesBinInp()), - ::testing::Values(ngraph::helpers::InputLayerType::PARAMETER), + ::testing::Values(ov::test::utils::InputLayerType::PARAMETER), ::testing::ValuesIn(opTypes()), ::testing::Values(ElementType::f32), ::testing::Values(ov::element::undefined), @@ -286,7 +283,7 @@ const auto params_4D_Blocked_Planar = ::testing::Combine( ::testing::Combine( ::testing::ValuesIn(static_shapes_to_test_representation(inShapes_4D_Blocked_Planar())), ::testing::ValuesIn(eltwiseOpTypesBinInp()), - ::testing::Values(ngraph::helpers::InputLayerType::CONSTANT), + ::testing::Values(ov::test::utils::InputLayerType::CONSTANT), ::testing::ValuesIn(opTypes()), ::testing::ValuesIn(netType()), ::testing::Values(ov::element::undefined), @@ -303,7 +300,7 @@ const auto params_4D_Planar_Blocked = ::testing::Combine( ::testing::Combine( ::testing::ValuesIn(static_shapes_to_test_representation(inShapes_4D_Planar_Blocked())), ::testing::ValuesIn(eltwiseOpTypesBinInp()), - ::testing::Values(ngraph::helpers::InputLayerType::CONSTANT), + ::testing::Values(ov::test::utils::InputLayerType::CONSTANT), ::testing::ValuesIn(opTypes()), ::testing::ValuesIn(netType()), ::testing::Values(ov::element::undefined), @@ -320,7 +317,7 @@ const auto params_5D_Blocked_Planar = ::testing::Combine( ::testing::Combine( ::testing::ValuesIn(static_shapes_to_test_representation(inShapes_5D_Blocked_Planar())), ::testing::ValuesIn(eltwiseOpTypesBinInp()), - ::testing::Values(ngraph::helpers::InputLayerType::CONSTANT), + ::testing::Values(ov::test::utils::InputLayerType::CONSTANT), ::testing::ValuesIn(opTypes()), ::testing::ValuesIn(netType()), ::testing::Values(ov::element::undefined), @@ -337,7 +334,7 @@ const auto params_5D_Planar_Blocked = ::testing::Combine( ::testing::Combine( ::testing::ValuesIn(static_shapes_to_test_representation(inShapes_5D_Planar_Blocked())), ::testing::ValuesIn(eltwiseOpTypesBinInp()), - ::testing::Values(ngraph::helpers::InputLayerType::CONSTANT), + ::testing::Values(ov::test::utils::InputLayerType::CONSTANT), ::testing::ValuesIn(opTypes()), ::testing::ValuesIn(netType()), ::testing::Values(ov::element::undefined), @@ -353,8 +350,8 @@ INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_5D_Planar_Blocked_x64, EltwiseLay const auto params_4D_1D_constant_mode = ::testing::Combine( ::testing::Combine( ::testing::ValuesIn(static_shapes_to_test_representation(inShapes_4D_1D())), - ::testing::Values(ngraph::helpers::EltwiseTypes::ADD, ngraph::helpers::EltwiseTypes::MULTIPLY), - ::testing::Values(ngraph::helpers::InputLayerType::CONSTANT), + ::testing::Values(ov::test::utils::EltwiseTypes::ADD, ov::test::utils::EltwiseTypes::MULTIPLY), + ::testing::Values(ov::test::utils::InputLayerType::CONSTANT), ::testing::ValuesIn(opTypes()), ::testing::ValuesIn(netType()), ::testing::Values(ov::element::undefined), @@ -370,8 +367,8 @@ INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_4D_1D_Constant_x64, EltwiseLayerC const auto params_4D_1D_parameter_mode = ::testing::Combine( ::testing::Combine( ::testing::ValuesIn(static_shapes_to_test_representation(inShapes_4D_1D())), - ::testing::Values(ngraph::helpers::EltwiseTypes::ADD, ngraph::helpers::EltwiseTypes::MULTIPLY), - ::testing::Values(ngraph::helpers::InputLayerType::PARAMETER), + ::testing::Values(ov::test::utils::EltwiseTypes::ADD, ov::test::utils::EltwiseTypes::MULTIPLY), + ::testing::Values(ov::test::utils::InputLayerType::PARAMETER), ::testing::ValuesIn(opTypes()), ::testing::ValuesIn(netType()), ::testing::Values(ov::element::undefined), @@ -387,8 +384,8 @@ INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_4D_1D_Parameter_x64, EltwiseLayer const auto params_5D_1D_constant = ::testing::Combine( ::testing::Combine( ::testing::ValuesIn(static_shapes_to_test_representation(inShapes_5D_1D())), - ::testing::Values(ngraph::helpers::EltwiseTypes::ADD, ngraph::helpers::EltwiseTypes::MULTIPLY), - ::testing::Values(ngraph::helpers::InputLayerType::CONSTANT), + ::testing::Values(ov::test::utils::EltwiseTypes::ADD, ov::test::utils::EltwiseTypes::MULTIPLY), + ::testing::Values(ov::test::utils::InputLayerType::CONSTANT), ::testing::ValuesIn(opTypes()), ::testing::ValuesIn(netType()), ::testing::Values(ov::element::undefined), @@ -404,8 +401,8 @@ INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_5D_1D_Constant_x64, EltwiseLayerC const auto params_5D_1D_parameter = ::testing::Combine( ::testing::Combine( ::testing::ValuesIn(static_shapes_to_test_representation(inShapes_5D_1D())), - ::testing::Values(ngraph::helpers::EltwiseTypes::ADD, ngraph::helpers::EltwiseTypes::MULTIPLY), - ::testing::Values(ngraph::helpers::InputLayerType::PARAMETER), + ::testing::Values(ov::test::utils::EltwiseTypes::ADD, ov::test::utils::EltwiseTypes::MULTIPLY), + ::testing::Values(ov::test::utils::InputLayerType::PARAMETER), ::testing::ValuesIn(opTypes()), ::testing::ValuesIn(netType()), ::testing::Values(ov::element::undefined), @@ -424,7 +421,7 @@ const auto params_4D_dyn_const = ::testing::Combine( ::testing::Combine( ::testing::ValuesIn(inShapes_4D_dyn_const()), ::testing::ValuesIn(eltwiseOpTypesBinInp()), - ::testing::Values(ngraph::helpers::InputLayerType::CONSTANT), + ::testing::Values(ov::test::utils::InputLayerType::CONSTANT), ::testing::ValuesIn(opTypes()), ::testing::ValuesIn(netType()), ::testing::Values(ov::element::undefined), @@ -441,7 +438,7 @@ const auto params_4D_blocked_blocked_dyn_const = ::testing::Combine( ::testing::Combine( ::testing::ValuesIn(inShapes_4D_dyn_const()), ::testing::ValuesIn(eltwiseOpTypesBinInp()), - ::testing::Values(ngraph::helpers::InputLayerType::CONSTANT), + ::testing::Values(ov::test::utils::InputLayerType::CONSTANT), ::testing::ValuesIn(opTypes()), ::testing::ValuesIn(netType()), ::testing::Values(ov::element::undefined), @@ -459,7 +456,7 @@ const auto params_4D_dyn_param = ::testing::Combine( ::testing::Combine( ::testing::Values(inShapes_4D_dyn_param()), ::testing::ValuesIn(eltwiseOpTypesBinDyn()), - ::testing::Values(ngraph::helpers::InputLayerType::PARAMETER), + ::testing::Values(ov::test::utils::InputLayerType::PARAMETER), ::testing::ValuesIn(opTypes()), ::testing::ValuesIn(netType()), ::testing::Values(ov::element::undefined), @@ -476,7 +473,7 @@ const auto params_4D_blocked_blocked_dyn_param = ::testing::Combine( ::testing::Combine( ::testing::Values(inShapes_4D_dyn_param()), ::testing::ValuesIn(eltwiseOpTypesBinDyn()), - ::testing::Values(ngraph::helpers::InputLayerType::PARAMETER), + ::testing::Values(ov::test::utils::InputLayerType::PARAMETER), ::testing::ValuesIn(opTypes()), ::testing::ValuesIn(netType()), ::testing::Values(ov::element::undefined), @@ -494,7 +491,7 @@ const auto params_4D_dyn_param_fusing = ::testing::Combine( ::testing::Combine( ::testing::Values(inShapes_4D_dyn_param_fusing()), ::testing::ValuesIn(eltwiseOpTypesBinDyn()), - ::testing::Values(ngraph::helpers::InputLayerType::PARAMETER), + ::testing::Values(ov::test::utils::InputLayerType::PARAMETER), ::testing::ValuesIn(opTypes()), ::testing::Values(ElementType::f32), ::testing::Values(ov::element::undefined), @@ -511,7 +508,7 @@ const auto params_4D_dyn_param_fusing_Blocked_Blocked = ::testing::Combine( ::testing::Combine( ::testing::Values(inShapes_4D_dyn_param_fusing()), ::testing::ValuesIn(eltwiseOpTypesBinDyn()), - ::testing::Values(ngraph::helpers::InputLayerType::PARAMETER), + ::testing::Values(ov::test::utils::InputLayerType::PARAMETER), ::testing::ValuesIn(opTypes()), ::testing::Values(ElementType::f32), ::testing::Values(ov::element::undefined), @@ -529,7 +526,7 @@ const auto params_4D_blocked_blocked_dyn_param_fusing = ::testing::Combine( ::testing::Combine( ::testing::Values(inShapes_4D_dyn_param_fusing()), ::testing::ValuesIn(eltwiseOpTypesBinDyn()), - ::testing::Values(ngraph::helpers::InputLayerType::PARAMETER), + ::testing::Values(ov::test::utils::InputLayerType::PARAMETER), ::testing::ValuesIn(opTypes()), ::testing::Values(ElementType::f32), ::testing::Values(ov::element::undefined), @@ -549,7 +546,7 @@ const auto params_5D_dyn_const_Blocked_Blocked = ::testing::Combine( ::testing::Combine( ::testing::Values(inShapes_5D_dyn_const()), ::testing::ValuesIn(eltwiseOpTypesBinInp()), - ::testing::Values(ngraph::helpers::InputLayerType::CONSTANT), + ::testing::Values(ov::test::utils::InputLayerType::CONSTANT), ::testing::ValuesIn(opTypes()), ::testing::ValuesIn(netType()), ::testing::Values(ov::element::undefined), @@ -567,7 +564,7 @@ const auto params_5D_dyn_param_Blocked_Blocked = ::testing::Combine( ::testing::Combine( ::testing::Values(inShapes_5D_dyn_param()), ::testing::ValuesIn(eltwiseOpTypesBinDyn()), - ::testing::Values(ngraph::helpers::InputLayerType::PARAMETER), + ::testing::Values(ov::test::utils::InputLayerType::PARAMETER), ::testing::ValuesIn(opTypes()), ::testing::ValuesIn(netType()), ::testing::Values(ov::element::undefined), @@ -611,9 +608,9 @@ const auto params_4D_bitwise = ::testing::Combine( ::testing::Combine( ::testing::ValuesIn(bitwise_in_shapes_4D), ::testing::ValuesIn({ - ngraph::helpers::EltwiseTypes::BITWISE_AND, - ngraph::helpers::EltwiseTypes::BITWISE_OR, - ngraph::helpers::EltwiseTypes::BITWISE_XOR + ov::test::utils::EltwiseTypes::BITWISE_AND, + ov::test::utils::EltwiseTypes::BITWISE_OR, + ov::test::utils::EltwiseTypes::BITWISE_XOR }), ::testing::ValuesIn(secondaryInputTypes()), ::testing::ValuesIn({ ov::test::utils::OpType::VECTOR }), @@ -636,9 +633,9 @@ const auto params_4D_bitwise_i32 = ::testing::Combine( ::testing::Combine( ::testing::ValuesIn(bitwise_in_shapes_4D), ::testing::ValuesIn({ - ngraph::helpers::EltwiseTypes::BITWISE_AND, - ngraph::helpers::EltwiseTypes::BITWISE_OR, - ngraph::helpers::EltwiseTypes::BITWISE_XOR + ov::test::utils::EltwiseTypes::BITWISE_AND, + ov::test::utils::EltwiseTypes::BITWISE_OR, + ov::test::utils::EltwiseTypes::BITWISE_XOR }), ::testing::ValuesIn(secondaryInputTypes()), ::testing::ValuesIn({ ov::test::utils::OpType::VECTOR }), @@ -660,8 +657,8 @@ INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_4D_Bitwise_i32, EltwiseLayerCPUTe const auto params_4D_bitwise_NOT = ::testing::Combine( ::testing::Combine( ::testing::ValuesIn(bitwise_in_shapes_4D), - ::testing::ValuesIn({ ngraph::helpers::EltwiseTypes::BITWISE_NOT }), - ::testing::ValuesIn({ ngraph::helpers::InputLayerType::CONSTANT }), + ::testing::ValuesIn({ ov::test::utils::EltwiseTypes::BITWISE_NOT }), + ::testing::ValuesIn({ ov::test::utils::InputLayerType::CONSTANT }), ::testing::ValuesIn({ ov::test::utils::OpType::VECTOR }), ::testing::ValuesIn({ ov::element::Type_t::i8, ov::element::Type_t::u8, ov::element::Type_t::i32 }), ::testing::Values(ov::element::Type_t::undefined), @@ -681,8 +678,8 @@ INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_4D_Bitwise_NOT, EltwiseLayerCPUTe const auto params_4D_bitwise_NOT_i32 = ::testing::Combine( ::testing::Combine( ::testing::ValuesIn(bitwise_in_shapes_4D), - ::testing::ValuesIn({ ngraph::helpers::EltwiseTypes::BITWISE_NOT }), - ::testing::ValuesIn({ ngraph::helpers::InputLayerType::CONSTANT }), + ::testing::ValuesIn({ ov::test::utils::EltwiseTypes::BITWISE_NOT }), + ::testing::ValuesIn({ ov::test::utils::InputLayerType::CONSTANT }), ::testing::ValuesIn({ ov::test::utils::OpType::VECTOR }), ::testing::ValuesIn({ ov::element::Type_t::i16 }), ::testing::Values(ov::element::Type_t::undefined), @@ -698,6 +695,7 @@ const auto params_4D_bitwise_NOT_i32 = ::testing::Combine( INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_4D_Bitwise_NOT_i32, EltwiseLayerCPUTest, params_4D_bitwise_NOT_i32, EltwiseLayerCPUTest::getTestCaseName); -} // namespace -} // namespace Eltwise -} // namespace CPULayerTestsDefinitions \ No newline at end of file +} // namespace +} // namespace Eltwise +} // namespace test +} // namespace ov \ No newline at end of file diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/x64/matmul.cpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/x64/matmul.cpp index bc357d158f2b57..14d18faa55d879 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/x64/matmul.cpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/x64/matmul.cpp @@ -7,15 +7,11 @@ #include "test_utils/cpu_test_utils.hpp" #include "test_utils/filter_cpu_info.hpp" #include "test_utils/fusing_test_utils.hpp" -#include "ov_models/builders.hpp" -#include -using namespace InferenceEngine; using namespace CPUTestUtils; -using namespace ngraph::helpers; -using namespace ov::test; -namespace CPULayerTestsDefinitions { +namespace ov { +namespace test { namespace MatMul { namespace { const std::vector IS_x64 = { @@ -55,7 +51,7 @@ const auto matMulParams_x64 = ::testing::Combine(::testing::ValuesIn(IS_x64), ::testing::ValuesIn(netPRCs()), ::testing::Values(ElementType::undefined), ::testing::Values(ElementType::undefined), - ::testing::Values(helpers::InputLayerType::PARAMETER), + ::testing::Values(utils::InputLayerType::PARAMETER), ::testing::Values(ov::test::utils::DEVICE_CPU), ::testing::ValuesIn(additionalConfig())); @@ -70,7 +66,7 @@ const auto testParams2D_smoke = ::testing::Combine(::testing::Combine(::testing: ::testing::Values(ElementType::f32), ::testing::Values(ElementType::undefined), ::testing::Values(ElementType::undefined), - ::testing::Values(helpers::InputLayerType::CONSTANT), + ::testing::Values(utils::InputLayerType::CONSTANT), ::testing::Values(ov::test::utils::DEVICE_CPU), ::testing::Values(emptyAdditionalConfig())), ::testing::Values(MatMulNodeType::FullyConnected), @@ -81,7 +77,7 @@ const auto testParams2DBF16_smoke = ::testing::Combine(::testing::Combine(::test ::testing::ValuesIn(netPRCs()), ::testing::Values(ElementType::undefined), ::testing::Values(ElementType::undefined), - ::testing::Values(helpers::InputLayerType::CONSTANT), + ::testing::Values(utils::InputLayerType::CONSTANT), ::testing::Values(ov::test::utils::DEVICE_CPU), ::testing::ValuesIn(additionalConfig())), ::testing::Values(MatMulNodeType::FullyConnected), @@ -95,24 +91,24 @@ const auto testParams2D_nightly = ::testing::Combine(::testing::Combine(::testin ::testing::Values(ElementType::f32), ::testing::Values(ElementType::undefined), ::testing::Values(ElementType::undefined), - ::testing::Values(helpers::InputLayerType::CONSTANT), + ::testing::Values(utils::InputLayerType::CONSTANT), ::testing::Values(ov::test::utils::DEVICE_CPU), ::testing::Values((emptyAdditionalConfig()))), ::testing::Values(MatMulNodeType::FullyConnected), ::testing::ValuesIn(fusingParamsSet2D_nightly), ::testing::ValuesIn(filterCPUInfo(filterSpecificParams()))); -std::vector> filterAdditionalConfig_Brgemm() { +std::vector filterAdditionalConfig_Brgemm() { #ifndef OV_CPU_WITH_MLAS // FP32 precision is covered by MLAS - std::vector> additionalConfig = { - std::map{/* empty config */} + std::vector additionalConfig = { + ov::AnyMap{/* empty config */} }; #else - std::vector> additionalConfig = {}; + std::vector additionalConfig = {}; #endif if (with_cpu_x86_bfloat16()) { - additionalConfig.push_back({{PluginConfigParams::KEY_ENFORCE_BF16, PluginConfigParams::YES}}); + additionalConfig.push_back({ov::hint::inference_precision(ov::element::bf16)}); } return additionalConfig; @@ -202,7 +198,7 @@ const auto fullyConnectedParams2D_Brgemm_smoke = ::testing::Combine(::testing::V ::testing::Values(ElementType::f32), ::testing::Values(ElementType::undefined), ::testing::Values(ElementType::undefined), - ::testing::Values(helpers::InputLayerType::CONSTANT), + ::testing::Values(utils::InputLayerType::CONSTANT), ::testing::Values(ov::test::utils::DEVICE_CPU), ::testing::ValuesIn(filterAdditionalConfig_Brgemm())); @@ -231,7 +227,7 @@ const auto matMulBrgemmParams_smoke = ::testing::Combine(::testing::ValuesIn(IS_ ::testing::Values(ElementType::f32), ::testing::Values(ElementType::undefined), ::testing::Values(ElementType::undefined), - ::testing::Values(helpers::InputLayerType::PARAMETER), + ::testing::Values(utils::InputLayerType::PARAMETER), ::testing::Values(ov::test::utils::DEVICE_CPU), ::testing::ValuesIn(filterAdditionalConfig_Brgemm())); @@ -260,7 +256,7 @@ const auto matMulBrgemmParams_nightly = ::testing::Combine(::testing::ValuesIn(I ::testing::Values(ElementType::f32), ::testing::Values(ElementType::undefined), ::testing::Values(ElementType::undefined), - ::testing::Values(helpers::InputLayerType::PARAMETER), + ::testing::Values(utils::InputLayerType::PARAMETER), ::testing::Values(ov::test::utils::DEVICE_CPU), ::testing::ValuesIn(filterAdditionalConfig_Brgemm())); @@ -334,7 +330,7 @@ const auto matMulBrgemmParamsDynamic = ::testing::Combine(::testing::ValuesIn(IS ::testing::Values(ElementType::f32), ::testing::Values(ElementType::undefined), ::testing::Values(ElementType::undefined), - ::testing::Values(helpers::InputLayerType::PARAMETER), + ::testing::Values(utils::InputLayerType::PARAMETER), ::testing::Values(ov::test::utils::DEVICE_CPU), ::testing::ValuesIn(filterAdditionalConfig_Brgemm())); @@ -398,7 +394,7 @@ const auto matMulParamsDynamicFusing = ::testing::Combine(::testing::ValuesIn(IS ::testing::ValuesIn(netPRCs()), ::testing::Values(ElementType::undefined), ::testing::Values(ElementType::undefined), - ::testing::Values(helpers::InputLayerType::PARAMETER), + ::testing::Values(utils::InputLayerType::PARAMETER), ::testing::Values(ov::test::utils::DEVICE_CPU), ::testing::ValuesIn(additionalConfig())); @@ -413,7 +409,7 @@ const auto matMulParamsBrgemmDynamicFusing = ::testing::Combine(::testing::Value ::testing::Values(ElementType::f32), ::testing::Values(ElementType::undefined), ::testing::Values(ElementType::undefined), - ::testing::Values(helpers::InputLayerType::PARAMETER), + ::testing::Values(utils::InputLayerType::PARAMETER), ::testing::Values(ov::test::utils::DEVICE_CPU), ::testing::ValuesIn(filterAdditionalConfig_Brgemm())); @@ -424,10 +420,10 @@ const auto testParamsBrgemmDynamicFusing = ::testing::Combine(matMulParamsBrgemm INSTANTIATE_TEST_SUITE_P(smoke_MM_Brgemm_Dynamic_Fusing, MatMulLayerCPUTest, testParamsBrgemmDynamicFusing, MatMulLayerCPUTest::getTestCaseName); -std::vector> filterAdditionalConfig_BrgemmAmx() { - std::vector> additionalConfig; +std::vector filterAdditionalConfig_BrgemmAmx() { + std::vector additionalConfig; if (with_cpu_x86_bfloat16()) { - additionalConfig.push_back({{PluginConfigParams::KEY_ENFORCE_BF16, PluginConfigParams::YES}}); + additionalConfig.push_back({ov::hint::inference_precision(ov::element::bf16)}); } return additionalConfig; @@ -460,7 +456,7 @@ const auto matMulBrgemmAmxParams_smoke = ::testing::Combine(::testing::ValuesIn( ::testing::Values(ElementType::f32), ::testing::Values(ElementType::undefined), ::testing::Values(ElementType::undefined), - ::testing::Values(helpers::InputLayerType::PARAMETER), + ::testing::Values(utils::InputLayerType::PARAMETER), ::testing::Values(ov::test::utils::DEVICE_CPU), ::testing::ValuesIn(filterAdditionalConfig_BrgemmAmx())); @@ -482,7 +478,7 @@ const auto matMulBrgemmAmxParams_nightly = ::testing::Combine(::testing::ValuesI ::testing::Values(ElementType::f32), ::testing::Values(ElementType::undefined), ::testing::Values(ElementType::undefined), - ::testing::Values(helpers::InputLayerType::PARAMETER), + ::testing::Values(utils::InputLayerType::PARAMETER), ::testing::Values(ov::test::utils::DEVICE_CPU), ::testing::ValuesIn(filterAdditionalConfig_BrgemmAmx())); @@ -497,7 +493,7 @@ const auto matMulBrgemmAmxParamsDynamic = ::testing::Combine(::testing::ValuesIn ::testing::Values(ElementType::f32), ::testing::Values(ElementType::undefined), ::testing::Values(ElementType::undefined), - ::testing::Values(helpers::InputLayerType::PARAMETER), + ::testing::Values(utils::InputLayerType::PARAMETER), ::testing::Values(ov::test::utils::DEVICE_CPU), ::testing::ValuesIn(filterAdditionalConfig_BrgemmAmx())); @@ -544,7 +540,7 @@ const auto fullyConnectedParams2D_Brgconv1x1_smoke = ::testing::Combine(::testin ::testing::Values(ElementType::f32), ::testing::Values(ElementType::undefined), ::testing::Values(ElementType::undefined), - ::testing::Values(helpers::InputLayerType::CONSTANT), + ::testing::Values(utils::InputLayerType::CONSTANT), ::testing::Values(ov::test::utils::DEVICE_CPU), ::testing::Values(emptyAdditionalConfig())); @@ -597,7 +593,7 @@ const auto fullyConnectedParams3D_Brgconv1x1_smoke = ::testing::Combine(::testin ::testing::Values(ElementType::f32), ::testing::Values(ElementType::undefined), ::testing::Values(ElementType::undefined), - ::testing::Values(helpers::InputLayerType::CONSTANT), + ::testing::Values(utils::InputLayerType::CONSTANT), ::testing::Values(ov::test::utils::DEVICE_CPU), ::testing::Values(emptyAdditionalConfig())); @@ -612,7 +608,7 @@ const auto fullyConnectedParams2D_Brgemm_Amx_smoke = ::testing::Combine(::testin ::testing::Values(ElementType::f32), ::testing::Values(ElementType::undefined), ::testing::Values(ElementType::undefined), - ::testing::Values(helpers::InputLayerType::CONSTANT), + ::testing::Values(utils::InputLayerType::CONSTANT), ::testing::Values(ov::test::utils::DEVICE_CPU), ::testing::ValuesIn(filterAdditionalConfig_BrgemmAmx())); @@ -650,7 +646,7 @@ const auto fullyConnectedParams2D_Brgemm_nightly = ::testing::Combine(::testing: ::testing::Values(ElementType::f32), ::testing::Values(ElementType::undefined), ::testing::Values(ElementType::undefined), - ::testing::Values(helpers::InputLayerType::CONSTANT), + ::testing::Values(utils::InputLayerType::CONSTANT), ::testing::Values(ov::test::utils::DEVICE_CPU), ::testing::ValuesIn(filterAdditionalConfig_Brgemm())); @@ -665,7 +661,7 @@ const auto fullyConnectedParams2D_Brgemm_Amx_nightly = ::testing::Combine(::test ::testing::Values(ElementType::f32), ::testing::Values(ElementType::undefined), ::testing::Values(ElementType::undefined), - ::testing::Values(helpers::InputLayerType::CONSTANT), + ::testing::Values(utils::InputLayerType::CONSTANT), ::testing::Values(ov::test::utils::DEVICE_CPU), ::testing::ValuesIn(filterAdditionalConfig_BrgemmAmx())); @@ -680,7 +676,7 @@ const auto testParams2DBF16_nightly = ::testing::Combine(::testing::Combine(::te ::testing::ValuesIn(netPRCs()), ::testing::Values(ElementType::undefined), ::testing::Values(ElementType::undefined), - ::testing::Values(helpers::InputLayerType::CONSTANT), + ::testing::Values(utils::InputLayerType::CONSTANT), ::testing::Values(ov::test::utils::DEVICE_CPU), ::testing::ValuesIn(additionalConfig())), ::testing::Values(MatMulNodeType::FullyConnected), @@ -711,7 +707,7 @@ const auto fullyConnectedParams3DBF16_smoke = ::testing::Combine(::testing::Valu ::testing::ValuesIn(netPRCs()), ::testing::Values(ElementType::undefined), ::testing::Values(ElementType::undefined), - ::testing::Values(helpers::InputLayerType::CONSTANT), + ::testing::Values(utils::InputLayerType::CONSTANT), ::testing::Values(ov::test::utils::DEVICE_CPU), ::testing::ValuesIn(additionalConfig())); @@ -726,7 +722,7 @@ const auto fullyConnectedParams3D_smoke = ::testing::Combine(::testing::ValuesIn ::testing::Values(ElementType::f32), ::testing::Values(ElementType::undefined), ::testing::Values(ElementType::undefined), - ::testing::Values(helpers::InputLayerType::CONSTANT), + ::testing::Values(utils::InputLayerType::CONSTANT), ::testing::Values(ov::test::utils::DEVICE_CPU), ::testing::Values(emptyAdditionalConfig())); @@ -775,7 +771,7 @@ const auto fullyConnectedParams3D_nightly = ::testing::Combine(::testing::Values ::testing::Values(ElementType::f32), ::testing::Values(ElementType::undefined), ::testing::Values(ElementType::undefined), - ::testing::Values(helpers::InputLayerType::CONSTANT), + ::testing::Values(utils::InputLayerType::CONSTANT), ::testing::Values(ov::test::utils::DEVICE_CPU), ::testing::Values(emptyAdditionalConfig())); @@ -783,7 +779,7 @@ const auto fullyConnectedParams3DBF16_nightly = ::testing::Combine(::testing::Va ::testing::ValuesIn(netPRCs()), ::testing::Values(ElementType::undefined), ::testing::Values(ElementType::undefined), - ::testing::Values(helpers::InputLayerType::CONSTANT), + ::testing::Values(utils::InputLayerType::CONSTANT), ::testing::Values(ov::test::utils::DEVICE_CPU), ::testing::ValuesIn(additionalConfig())); @@ -800,6 +796,7 @@ const auto testParams3D_nightly = ::testing::Combine(fullyConnectedParams3D_nigh ::testing::ValuesIn(filterCPUInfo(filterSpecificParams()))); INSTANTIATE_TEST_SUITE_P(nightly_FC_3D, MatMulLayerCPUTest, testParams3D_nightly, MatMulLayerCPUTest::getTestCaseName); -} // namespace -} // namespace MatMul -} // namespace CPULayerTestsDefinitions \ No newline at end of file +} // namespace +} // namespace MatMul +} // namespace test +} // namespace ov \ No newline at end of file diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/x64/mlas/matmul.cpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/x64/mlas/matmul.cpp index 3be916593f0b7b..1d918f031f3696 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/x64/mlas/matmul.cpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/x64/mlas/matmul.cpp @@ -7,12 +7,10 @@ #include "test_utils/cpu_test_utils.hpp" #include "test_utils/fusing_test_utils.hpp" -using namespace InferenceEngine; using namespace CPUTestUtils; -using namespace ngraph::helpers; -using namespace ov::test; -namespace CPULayerTestsDefinitions { +namespace ov { +namespace test { namespace MatMul { namespace { #ifdef OV_CPU_WITH_MLAS @@ -33,7 +31,7 @@ const auto testParams3D_MLAS_smoke = ::testing::Combine(::testing::Combine(::tes ::testing::Values(ElementType::f32), ::testing::Values(ElementType::undefined), ::testing::Values(ElementType::undefined), - ::testing::Values(helpers::InputLayerType::CONSTANT), + ::testing::Values(ov::test::utils::InputLayerType::CONSTANT), ::testing::Values(ov::test::utils::DEVICE_CPU), ::testing::Values(emptyAdditionalConfig())), ::testing::Values(MatMulNodeType::FullyConnected), @@ -48,7 +46,7 @@ const auto testParams2D_MLAS_nightly = ::testing::Combine(::testing::Combine(::t ::testing::Values(ElementType::f32), ::testing::Values(ElementType::undefined), ::testing::Values(ElementType::undefined), - ::testing::Values(helpers::InputLayerType::CONSTANT), + ::testing::Values(ov::test::utils::InputLayerType::CONSTANT), ::testing::Values(ov::test::utils::DEVICE_CPU), ::testing::Values(emptyAdditionalConfig())), ::testing::Values(MatMulNodeType::FullyConnected), @@ -67,7 +65,7 @@ const auto testParams2D_MLAS_smoke = ::testing::Combine(::testing::Combine(::tes ::testing::Values(ElementType::f32), ::testing::Values(ElementType::undefined), ::testing::Values(ElementType::undefined), - ::testing::Values(helpers::InputLayerType::CONSTANT), + ::testing::Values(ov::test::utils::InputLayerType::CONSTANT), ::testing::Values(ov::test::utils::DEVICE_CPU), ::testing::Values(emptyAdditionalConfig())), ::testing::Values(MatMulNodeType::FullyConnected), @@ -75,6 +73,7 @@ const auto testParams2D_MLAS_smoke = ::testing::Combine(::testing::Combine(::tes ::testing::ValuesIn(filterSpecificParams_MLAS())); INSTANTIATE_TEST_SUITE_P(smoke_FC_2D_MLAS, MatMulLayerCPUTest, testParams2D_MLAS_smoke, MatMulLayerCPUTest::getTestCaseName); #endif -} // namespace -} // namespace MatMul -} // namespace CPULayerTestsDefinitions \ No newline at end of file +} // namespace +} // namespace MatMul +} // namespace test +} // namespace ov \ No newline at end of file diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/x64/mvn.cpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/x64/mvn.cpp index 7e45470c395d48..f5726bed8740d4 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/x64/mvn.cpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/x64/mvn.cpp @@ -6,16 +6,12 @@ #include "shared_test_classes/single_layer/mvn.hpp" #include "test_utils/cpu_test_utils.hpp" #include "test_utils/fusing_test_utils.hpp" -#include -#include +#include "common_test_utils/ov_tensor_utils.hpp" -using namespace InferenceEngine; using namespace CPUTestUtils; -using namespace ngraph::helpers; -using namespace ov::test; - -namespace CPULayerTestsDefinitions { +namespace ov { +namespace test { namespace MVN { namespace { @@ -219,6 +215,7 @@ const auto MvnSmallSpatial = ::testing::Combine( INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_MvnSmallSpatial, MvnLayerCPUTest, MvnSmallSpatial, MvnLayerCPUTest::getTestCaseName); -} // namespace -} // namespace MVN -} // namespace CPULayerTestsDefinitions \ No newline at end of file +} // namespace +} // namespace MVN +} // namespace test +} // namespace ov \ No newline at end of file diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/x64/pooling.cpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/x64/pooling.cpp index 89406d9c6a43b1..15f43df6ed663d 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/x64/pooling.cpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/x64/pooling.cpp @@ -7,16 +7,11 @@ #include "test_utils/cpu_test_utils.hpp" #include "test_utils/filter_cpu_info.hpp" #include "test_utils/fusing_test_utils.hpp" -#include -#include -using namespace InferenceEngine; using namespace CPUTestUtils; -using namespace ngraph::helpers; -using namespace ov::test; - -namespace CPULayerTestsDefinitions { +namespace ov { +namespace test { namespace Pooling { namespace { @@ -27,16 +22,16 @@ const auto sse42 = CPUSpecificParams{{}, {}, {"jit_sse42"}, "jit_sse42"}; const std::vector vecCpuConfigs = {sse42, avx, avx512}; -const std::vector paramsMaxV84D_ref = { - LayerTestsDefinitions::maxPoolV8SpecificParams{ {2, 2}, {2, 2}, {2, 2}, {0, 0}, {0, 0}, - ngraph::element::Type_t::i32, 0, - ngraph::op::RoundingType::CEIL, ngraph::op::PadType::SAME_UPPER }, - LayerTestsDefinitions::maxPoolV8SpecificParams{ {4, 2}, {2, 2}, {1, 2}, {0, 0}, {0, 0}, - ngraph::element::Type_t::i32, 0, - ngraph::op::RoundingType::CEIL, ngraph::op::PadType::EXPLICIT }, - LayerTestsDefinitions::maxPoolV8SpecificParams{ {4, 2}, {2, 1}, {2, 2}, {0, 0}, {0, 0}, - ngraph::element::Type_t::i32, 0, - ngraph::op::RoundingType::CEIL, ngraph::op::PadType::EXPLICIT }, +const std::vector paramsMaxV84D_ref = { + maxPoolV8SpecificParams{ {2, 2}, {2, 2}, {2, 2}, {0, 0}, {0, 0}, + ov::element::Type_t::i32, 0, + ov::op::RoundingType::CEIL, ov::op::PadType::SAME_UPPER }, + maxPoolV8SpecificParams{ {4, 2}, {2, 2}, {1, 2}, {0, 0}, {0, 0}, + ov::element::Type_t::i32, 0, + ov::op::RoundingType::CEIL, ov::op::PadType::EXPLICIT }, + maxPoolV8SpecificParams{ {4, 2}, {2, 1}, {2, 2}, {0, 0}, {0, 0}, + ov::element::Type_t::i32, 0, + ov::op::RoundingType::CEIL, ov::op::PadType::EXPLICIT }, }; INSTANTIATE_TEST_SUITE_P(smoke_MaxPoolV8_CPU_4D_ref, MaxPoolingV8LayerCPUTest, @@ -144,6 +139,7 @@ INSTANTIATE_TEST_SUITE_P(smoke_AvgPool_CPU_5D_I8, PoolingLayerCPUTest, ::testing::ValuesIn(filterCPUInfoForDevice(vecCpuConfigsFusing_5D)), ::testing::ValuesIn(fusingParamsSet)), PoolingLayerCPUTest::getTestCaseName); -} // namespace -} // namespace Pooling -} // namespace CPULayerTestsDefinitions \ No newline at end of file +} // namespace +} // namespace Pooling +} // namespace test +} // namespace ov \ No newline at end of file diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/x64/random_uniform.cpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/x64/random_uniform.cpp index 8fec42f382464d..bb6c6282c1fc9a 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/x64/random_uniform.cpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/x64/random_uniform.cpp @@ -5,9 +5,9 @@ #include "single_layer_tests/classes/random_uniform.hpp" using namespace CPUTestUtils; -using namespace ov::test; -namespace CPULayerTestsDefinitions { +namespace ov { +namespace test { namespace RandomUniform { static const std::vector output_prc_nightly = { @@ -42,5 +42,6 @@ INSTANTIATE_TEST_SUITE_P(nightly_Param, RandomUniformLayerTestCPU, ::testing::Values(empty_plugin_config)), RandomUniformLayerTestCPU::getTestCaseName); -} // namespace RandomUniform -} // namespace CPULayerTestsDefinitions +} // namespace RandomUniform +} // namespace test +} // namespace ov diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/x64/reduce.cpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/x64/reduce.cpp index 4291894af8e68b..657adbae683995 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/x64/reduce.cpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/x64/reduce.cpp @@ -8,13 +8,10 @@ #include "test_utils/fusing_test_utils.hpp" #include "ov_lpt_models/common/builders.hpp" -using namespace InferenceEngine; using namespace CPUTestUtils; -using namespace ngraph::helpers; -using namespace ov::test; - -namespace CPULayerTestsDefinitions { +namespace ov { +namespace test { namespace Reduce { namespace { @@ -100,15 +97,13 @@ std::vector cpuParams_NHWC_4D = { CPUSpecificParams({nhwc}, {nhwc}, {}, {}) }; -const std::vector reductionLogicalTypes = { - ngraph::helpers::ReductionType::LogicalOr, - ngraph::helpers::ReductionType::LogicalAnd -}; +const std::vector reductionLogicalTypes = {ov::test::utils::ReductionType::LogicalOr, + ov::test::utils::ReductionType::LogicalAnd}; -const std::vector reductionTypesFusing = { - ngraph::helpers::ReductionType::Mean, - ngraph::helpers::ReductionType::Max, - ngraph::helpers::ReductionType::L2, +const std::vector reductionTypesFusing = { + ov::test::utils::ReductionType::Mean, + ov::test::utils::ReductionType::Max, + ov::test::utils::ReductionType::L2, }; // This custom subgraph is used to test post-ops fusing case with U8/I8 precision on output, @@ -116,7 +111,7 @@ const std::vector reductionTypesFusing = { const auto fusingFakeQuantizeTranspose = fusingSpecificParams{std::make_shared(std::vector{ {[](postNodeConfig& cfg){ auto localPrc = cfg.input->get_element_type(); - ngraph::Shape newShape(cfg.input->get_output_partial_shape(0).size(), 1); + ov::Shape newShape(cfg.input->get_output_partial_shape(0).size(), 1); const auto fakeQuantize = ngraph::builder::makeFakeQuantize(cfg.input, localPrc, 256, newShape); std::vector order(newShape.size()); std::iota(order.begin(), order.end(), 0); @@ -138,7 +133,7 @@ const std::vector fusingParamsSet { }; // Exclude cases of fusingFakeQuantizePerChannelRelu, where FQ for non-1 channel fallbacks -// to decomposed ngraph reference implementation, so such fusing tests are N/A +// to decomposed reference implementation, so such fusing tests are N/A const std::vector fusingParamsSet_KeepNoDims { /* activations */ fusingSwish, @@ -619,6 +614,7 @@ INSTANTIATE_TEST_SUITE_P( ReduceCPULayerTest::getTestCaseName ); -} // namespace -} // namespace Reduce -} // namespace CPULayerTestsDefinitions \ No newline at end of file +} // namespace +} // namespace Reduce +} // namespace test +} // namespace ov \ No newline at end of file diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/x64/scaled_attn.cpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/x64/scaled_attn.cpp index a4b993c58a7117..9fe53cdbed6d46 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/x64/scaled_attn.cpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/x64/scaled_attn.cpp @@ -5,12 +5,10 @@ #include "single_layer_tests/classes/scaled_attn.hpp" #include "test_utils/cpu_test_utils.hpp" -using namespace InferenceEngine; using namespace CPUTestUtils; -using namespace ngraph::helpers; -using namespace ov::test; -namespace CPULayerTestsDefinitions { +namespace ov { +namespace test { namespace ScaledAttn { const auto cpuSpec = CPUSpecificParams{{}, {}, {"ref_any"}, "ref_any"}; @@ -75,5 +73,6 @@ INSTANTIATE_TEST_SUITE_P(smoke_ScaledAttn_CPU, params, ScaledAttnLayerCPUTest::getTestCaseName); -} // namespace ScaledAttn -} // namespace CPULayerTestsDefinitions \ No newline at end of file +} // namespace ScaledAttn +} // namespace test +} // namespace ov \ No newline at end of file diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/x64/transpose.cpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/x64/transpose.cpp index e577a8f7a5e6bd..db5f673a6a2eea 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/x64/transpose.cpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/x64/transpose.cpp @@ -6,16 +6,13 @@ #include "shared_test_classes/single_layer/transpose.hpp" #include "test_utils/cpu_test_utils.hpp" -using namespace InferenceEngine; using namespace CPUTestUtils; -using namespace ngraph::helpers; -using namespace ov::test; - -namespace CPULayerTestsDefinitions { +namespace ov { +namespace test { namespace Transpose { namespace { -std::map additional_config; +ov::AnyMap additional_config; const auto cpuParams_ndhwc = CPUSpecificParams {{ndhwc}, {}, {}, {}}; const auto cpuParams_ncdhw = CPUSpecificParams {{ncdhw}, {}, {}, {}}; @@ -27,10 +24,10 @@ const auto cpuParams_nChw8c = CPUSpecificParams {{nChw8c}, {}, {}, {}}; const auto cpuParams_nCdhw8c = CPUSpecificParams {{nCdhw8c}, {}, {}, {}}; const auto cpuParams_nspc = CPUSpecificParams {{acdb}, {}, {}, {}}; -const std::vector netPrecisions = { - Precision::I8, - Precision::BF16, - Precision::FP32 +const std::vector netPrecisions = { + ov::element::i8, + ov::element::bf16, + ov::element::f32 }; const std::vector CPUParams4D_blocked = { @@ -62,7 +59,7 @@ INSTANTIATE_TEST_SUITE_P(smoke_dynamicShapes4D_Transpose, TransposeLayerCPUTest, ::testing::Combine( ::testing::ValuesIn(dynamicInputShapes4D()), ::testing::ValuesIn(inputOrder4D()), - ::testing::Values(Precision::BF16), + ::testing::Values(ov::element::bf16), ::testing::Values(ov::test::utils::DEVICE_CPU), ::testing::Values(additional_config), ::testing::ValuesIn({CPUSpecificParams{}, cpuParams_nspc})), @@ -142,7 +139,7 @@ INSTANTIATE_TEST_SUITE_P(smoke_dynamicShapes5D_Transpose, TransposeLayerCPUTest, ::testing::Combine( ::testing::ValuesIn(dynamicInputShapes5D), ::testing::ValuesIn(inputOrder5D), - ::testing::Values(Precision::BF16), + ::testing::Values(ov::element::bf16), ::testing::Values(ov::test::utils::DEVICE_CPU), ::testing::Values(additional_config), ::testing::Values(CPUSpecificParams{})), @@ -177,6 +174,7 @@ INSTANTIATE_TEST_SUITE_P(smoke_dynamicShapes5D_PermutePerChannels, TransposeLaye ::testing::Values(additional_config), ::testing::Values(CPUSpecificParams{})), TransposeLayerCPUTest::getTestCaseName); -} // namespace -} // namespace Transpose -} // namespace CPULayerTestsDefinitions \ No newline at end of file +} // namespace +} // namespace Transpose +} // namespace test +} // namespace ov \ No newline at end of file diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/interpolate.cpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/interpolate.cpp index bcf1bb5cc1a2e7..1105165476fa69 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/interpolate.cpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/interpolate.cpp @@ -2,41 +2,40 @@ // SPDX-License-Identifier: Apache-2.0 // +#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 "ov_models/builders.hpp" #include "test_utils/cpu_test_utils.hpp" #include "test_utils/fusing_test_utils.hpp" -#include -#include "openvino/core/preprocess/pre_post_process.hpp" -#include +#include "transformations/op_conversions/convert_interpolate11_downgrade.hpp" -using namespace ov::test; using namespace CPUTestUtils; -using ngraph::helpers::operator<<; -namespace CPULayerTestsDefinitions { +namespace ov { +namespace test { -using InterpolateSpecificParams = std::tuple, // PadBegin - std::vector, // PadEnd - double>; // Cube coef +using InterpolateSpecificParams = + std::tuple, // PadBegin + std::vector, // PadEnd + double>; // Cube coef -using ShapeParams = std::tuple>, // scales or sizes values - std::vector>; // axes + ov::test::utils::InputLayerType, // input type + std::vector>, // scales or sizes values + std::vector>; // axes using InterpolateLayerCPUTestParamsSet = std::tuple>; + ov::AnyMap>; class InterpolateLayerCPUTest : public testing::WithParamInterface, virtual public SubgraphBaseTest, public CpuTestWithFusing { @@ -47,7 +46,7 @@ class InterpolateLayerCPUTest : public testing::WithParamInterface additionalConfig; + ov::AnyMap additionalConfig; std::tie(specificParams, shapeParams, prec, cpuParams, fusingParams, additionalConfig) = obj.param; ov::op::v11::Interpolate::InterpolateMode mode; @@ -61,11 +60,12 @@ class InterpolateLayerCPUTest : public testing::WithParamInterface> shapeDataForInput; std::vector axes; std::tie(shapeCalcMode, inputShapes, shapeInputType, shapeDataForInput, axes) = shapeParams; + using ov::test::utils::operator<<; std::ostringstream result; result << "ShapeCalcMode=" << shapeCalcMode << "_"; result << "IS="; @@ -99,7 +99,7 @@ class InterpolateLayerCPUTest : public testing::WithParamInterface filterCPUInfoForDevice3D() { return resCPUParams; } -std::vector> filterAdditionalConfig3D() { +std::vector filterAdditionalConfig3D() { return { {} }; @@ -362,14 +360,14 @@ const std::vector shapeParams3D = { ShapeParams{ ov::op::v11::Interpolate::ShapeCalcMode::SCALES, InputShape{{-1, {2, 20}, -1}, {{1, 3, 4}, {2, 4, 6}, {1, 3, 4}}}, - ngraph::helpers::InputLayerType::PARAMETER, + ov::test::utils::InputLayerType::PARAMETER, {{1.f, 1.f, 1.25f}, {1.f, 1.f, 1.25f}, {1.f, 1.f, 1.5f}}, defaultAxes3D.front() }, ShapeParams{ ov::op::v11::Interpolate::ShapeCalcMode::SIZES, InputShape{{-1, {2, 20}, -1}, {{1, 3, 4}, {2, 4, 6}, {1, 3, 4}}}, - ngraph::helpers::InputLayerType::PARAMETER, + ov::test::utils::InputLayerType::PARAMETER, {{1, 3, 6}, {2, 4, 8}, {1, 3, 6}}, defaultAxes3D.front() } @@ -414,7 +412,7 @@ INSTANTIATE_TEST_SUITE_P(InterpolateNN_Layout_Test_3D, InterpolateLayerCPUTest, #if defined(OPENVINO_ARCH_X86) || defined(OPENVINO_ARCH_X86_64) const std::vector interpolateFusingParamsSet3D_fixed_C() { std::vector fuseParams; - if (InferenceEngine::with_cpu_x86_avx2()) { + if (ov::with_cpu_x86_avx2()) { fuseParams.push_back(fusingFakeQuantizePerChannelRelu); fuseParams.push_back(fusingMultiplyPerChannel); } @@ -426,14 +424,14 @@ const std::vector shapeParams3D_fixed_C = { ShapeParams{ ov::op::v11::Interpolate::ShapeCalcMode::SCALES, InputShape{{}, {{1, 3, 4}}}, - ngraph::helpers::InputLayerType::CONSTANT, + ov::test::utils::InputLayerType::CONSTANT, {{1.f, 1.f, 1.25f}}, defaultAxes3D.front() }, ShapeParams{ ov::op::v11::Interpolate::ShapeCalcMode::SIZES, InputShape{{-1, 3, -1}, {{1, 3, 4}, {1, 3, 6}}}, - ngraph::helpers::InputLayerType::CONSTANT, + ov::test::utils::InputLayerType::CONSTANT, {{1, 3, 8}}, defaultAxes3D.front() } @@ -539,14 +537,14 @@ INSTANTIATE_TEST_SUITE_P(InterpolateCubic_Layout3D_Test, InterpolateLayerCPUTest // 4D std::vector filterCPUInfoForDevice() { std::vector resCPUParams; - if (InferenceEngine::with_cpu_x86_avx512f()) { + if (ov::with_cpu_x86_avx512f()) { resCPUParams.push_back(CPUSpecificParams{{nChw16c, x, x, x}, {nChw16c}, {"jit_avx512"}, "jit_avx512"}); resCPUParams.push_back(CPUSpecificParams{{nhwc, x, x, x}, {nhwc}, {"jit_avx512"}, "jit_avx512"}); - } else if (InferenceEngine::with_cpu_x86_avx2()) { + } else if (ov::with_cpu_x86_avx2()) { resCPUParams.push_back(CPUSpecificParams{{nChw8c, x, x, x}, {nChw8c}, {"jit_avx2"}, "jit_avx2"}); resCPUParams.push_back(CPUSpecificParams{{nhwc, x, x, x}, {nhwc}, {"jit_avx2"}, "jit_avx2"}); resCPUParams.push_back(CPUSpecificParams{{nchw, x, x, x}, {nchw}, {"jit_avx2"}, "jit_avx2"}); - } else if (InferenceEngine::with_cpu_x86_sse42()) { + } else if (ov::with_cpu_x86_sse42()) { resCPUParams.push_back(CPUSpecificParams{{nChw8c, x, x, x}, {nChw8c}, {"jit_sse42"}, "jit_sse42"}); resCPUParams.push_back(CPUSpecificParams{{nhwc, x, x, x}, {nhwc}, {"jit_sse42"}, "jit_sse42"}); } else { @@ -568,28 +566,28 @@ const std::vector shapeParams4D_Smoke = { ShapeParams{ ov::op::v11::Interpolate::ShapeCalcMode::SCALES, InputShape{{}, {{1, 11, 4, 4}}}, - ngraph::helpers::InputLayerType::CONSTANT, + ov::test::utils::InputLayerType::CONSTANT, {{1.f, 1.f, 1.25f, 1.5f}}, defaultAxes4D.front() }, ShapeParams{ ov::op::v11::Interpolate::ShapeCalcMode::SIZES, InputShape{{}, {{1, 11, 4, 4}}}, - ngraph::helpers::InputLayerType::CONSTANT, + ov::test::utils::InputLayerType::CONSTANT, {{1, 11, 5, 6}}, defaultAxes4D.front() }, ShapeParams{ ov::op::v11::Interpolate::ShapeCalcMode::SCALES, InputShape{{-1, {2, 20}, -1, -1}, {{1, 11, 4, 4}, {2, 7, 6, 5}, {1, 11, 4, 4}}}, - ngraph::helpers::InputLayerType::PARAMETER, + ov::test::utils::InputLayerType::PARAMETER, {{1.f, 1.f, 1.25f, 1.5f}, {1.f, 1.f, 1.25f, 1.25f}, {1.f, 1.f, 1.25f, 1.5f}}, defaultAxes4D.front() }, ShapeParams{ ov::op::v11::Interpolate::ShapeCalcMode::SIZES, InputShape{{-1, {2, 20}, -1, -1}, {{1, 11, 4, 4}, {2, 7, 6, 5}, {1, 11, 4, 4}}}, - ngraph::helpers::InputLayerType::PARAMETER, + ov::test::utils::InputLayerType::PARAMETER, {{1, 11, 6, 7}, {2, 7, 8, 7}, {1, 11, 6, 7}}, defaultAxes4D.front() } @@ -599,14 +597,14 @@ const std::vector shapeParams4D_Full = { ShapeParams{ ov::op::v11::Interpolate::ShapeCalcMode::SCALES, InputShape{{-1, {2, 20}, -1, -1}, {{1, 11, 4, 4}, {2, 7, 6, 5}, {1, 11, 4, 4}}}, - ngraph::helpers::InputLayerType::CONSTANT, + ov::test::utils::InputLayerType::CONSTANT, {{1.f, 1.f, 1.25f, 1.5f}}, defaultAxes4D.front() }, ShapeParams{ ov::op::v11::Interpolate::ShapeCalcMode::SIZES, InputShape{{-1, {2, 20}, -1, -1}, {{1, 11, 4, 4}, {1, 11, 5, 5}, {1, 11, 4, 4}}}, - ngraph::helpers::InputLayerType::CONSTANT, + ov::test::utils::InputLayerType::CONSTANT, {{1, 11, 5, 6}}, defaultAxes4D.front() } @@ -660,14 +658,14 @@ const std::vector shapeParams4D_fixed_C = { ShapeParams{ ov::op::v11::Interpolate::ShapeCalcMode::SCALES, InputShape{{}, {{1, 11, 4, 4}}}, - ngraph::helpers::InputLayerType::CONSTANT, + ov::test::utils::InputLayerType::CONSTANT, {{1.f, 1.f, 1.25f, 1.5f}}, defaultAxes4D.front() }, ShapeParams{ ov::op::v11::Interpolate::ShapeCalcMode::SIZES, InputShape{{-1, 16, -1, -1}, {{1, 16, 4, 4}, {1, 16, 6, 5}}}, - ngraph::helpers::InputLayerType::CONSTANT, + ov::test::utils::InputLayerType::CONSTANT, {{1, 16, 6, 7}}, defaultAxes4D.front() } @@ -811,14 +809,14 @@ INSTANTIATE_TEST_SUITE_P(InterpolateCubic_Layout_Test, InterpolateLayerCPUTest, ////////////////////////5D///////////////////////////// std::vector filterCPUInfoForDevice5D() { std::vector resCPUParams; - if (InferenceEngine::with_cpu_x86_avx512f()) { + if (ov::with_cpu_x86_avx512f()) { resCPUParams.push_back(CPUSpecificParams{{nCdhw16c, x, x, x}, {nCdhw16c}, {"jit_avx512"}, "jit_avx512"}); resCPUParams.push_back(CPUSpecificParams{{ndhwc, x, x, x}, {ndhwc}, {"jit_avx512"}, "jit_avx512"}); - } else if (InferenceEngine::with_cpu_x86_avx2()) { + } else if (ov::with_cpu_x86_avx2()) { resCPUParams.push_back(CPUSpecificParams{{nCdhw8c, x, x, x}, {nCdhw8c}, {"jit_avx2"}, "jit_avx2"}); resCPUParams.push_back(CPUSpecificParams{{ndhwc, x, x, x}, {ndhwc}, {"jit_avx2"}, "jit_avx2"}); resCPUParams.push_back(CPUSpecificParams{{ncdhw, x, x, x}, {ncdhw}, {"jit_avx2"}, "jit_avx2"}); - } else if (InferenceEngine::with_cpu_x86_sse42()) { + } else if (ov::with_cpu_x86_sse42()) { resCPUParams.push_back(CPUSpecificParams{{nCdhw8c, x, x, x}, {nCdhw8c}, {"jit_sse42"}, "jit_sse42"}); resCPUParams.push_back(CPUSpecificParams{{ndhwc, x, x, x}, {ndhwc}, {"jit_sse42"}, "jit_sse42"}); } else { @@ -839,28 +837,28 @@ const std::vector shapeParams5D_Smoke = { ShapeParams{ ov::op::v11::Interpolate::ShapeCalcMode::SCALES, InputShape{{}, {{1, 11, 4, 4, 4}}}, - ngraph::helpers::InputLayerType::CONSTANT, + ov::test::utils::InputLayerType::CONSTANT, {{1.f, 1.f, 1.25f, 1.5f, 0.5f}}, defaultAxes5D.front() }, ShapeParams{ ov::op::v11::Interpolate::ShapeCalcMode::SIZES, InputShape{{}, {{1, 11, 4, 4, 4}}}, - ngraph::helpers::InputLayerType::CONSTANT, + ov::test::utils::InputLayerType::CONSTANT, {{1, 11, 5, 6, 2}}, defaultAxes5D.front() }, ShapeParams{ ov::op::v11::Interpolate::ShapeCalcMode::SCALES, InputShape{{-1, {2, 20}, -1, -1, -1}, {{1, 11, 4, 4, 4}, {2, 7, 6, 5, 8}, {1, 11, 4, 4, 4}}}, - ngraph::helpers::InputLayerType::PARAMETER, + ov::test::utils::InputLayerType::PARAMETER, {{1.f, 1.f, 1.25f, 1.5f, 0.5f}, {1.f, 1.f, 1.25f, 1.25f, 1.25f}, {1.f, 1.f, 1.25f, 1.5f, 0.5f}}, defaultAxes5D.front() }, ShapeParams{ ov::op::v11::Interpolate::ShapeCalcMode::SIZES, InputShape{{-1, {2, 20}, -1, -1, -1}, {{1, 11, 4, 4, 4}, {2, 7, 6, 5, 8}, {1, 11, 4, 4, 4}}}, - ngraph::helpers::InputLayerType::PARAMETER, + ov::test::utils::InputLayerType::PARAMETER, {{1, 11, 6, 7, 2}, {2, 7, 8, 7, 4}, {1, 11, 6, 7, 2}}, defaultAxes5D.front() }, @@ -870,14 +868,14 @@ const std::vector shapeParams5D_Full = { ShapeParams{ ov::op::v11::Interpolate::ShapeCalcMode::SCALES, InputShape{{-1, {2, 20}, -1, -1, -1}, {{1, 11, 4, 4, 4}, {2, 7, 6, 5, 8}, {1, 11, 4, 4, 4}}}, - ngraph::helpers::InputLayerType::CONSTANT, + ov::test::utils::InputLayerType::CONSTANT, {{1.f, 1.f, 1.25f, 1.5f, 0.5f}}, defaultAxes5D.front() }, ShapeParams{ ov::op::v11::Interpolate::ShapeCalcMode::SIZES, InputShape{{-1, {2, 20}, -1, -1, -1}, {{1, 11, 4, 4, 4}, {1, 11, 5, 5, 8}, {1, 11, 4, 4, 4}}}, - ngraph::helpers::InputLayerType::CONSTANT, + ov::test::utils::InputLayerType::CONSTANT, {{1, 11, 5, 6, 4}}, defaultAxes5D.front() } @@ -963,14 +961,14 @@ const std::vector shapeParams4D_corner = { ShapeParams{ ov::op::v11::Interpolate::ShapeCalcMode::SCALES, InputShape{{1, 11, 4, 4}, {{1, 11, 4, 4}, {1, 11, 4, 4}}}, - ngraph::helpers::InputLayerType::PARAMETER, + ov::test::utils::InputLayerType::PARAMETER, {{1.f, 1.f, 1.25f, 1.5f}, {1.f, 1.f, 1.25f, 1.25f}}, defaultAxes4D.front() }, ShapeParams{ ov::op::v11::Interpolate::ShapeCalcMode::SIZES, InputShape{{1, 11, 4, 4}, {{1, 11, 4, 4}, {1, 11, 4, 4}}}, - ngraph::helpers::InputLayerType::PARAMETER, + ov::test::utils::InputLayerType::PARAMETER, {{1, 11, 6, 7}, {1, 11, 8, 7}}, defaultAxes4D.front() } @@ -1016,56 +1014,56 @@ const std::vector shapeParams4D_Pillow_Smoke = { ShapeParams{ ov::op::v11::Interpolate::ShapeCalcMode::SCALES, InputShape{{}, {{1, 3, 4, 4}}}, - ngraph::helpers::InputLayerType::CONSTANT, + ov::test::utils::InputLayerType::CONSTANT, {{2.0f, 4.0f}}, defaultAxes4D_pillow.front() }, ShapeParams{ ov::op::v11::Interpolate::ShapeCalcMode::SCALES, InputShape{{}, {{2, 4, 16, 16}}}, - ngraph::helpers::InputLayerType::CONSTANT, + ov::test::utils::InputLayerType::CONSTANT, {{0.25f, 0.5f}}, defaultAxes4D_pillow.front() }, ShapeParams{ ov::op::v11::Interpolate::ShapeCalcMode::SIZES, InputShape{{}, {{1, 3, 4, 4}}}, - ngraph::helpers::InputLayerType::CONSTANT, + ov::test::utils::InputLayerType::CONSTANT, {{5, 6}}, defaultAxes4D_pillow.front() }, ShapeParams{ ov::op::v11::Interpolate::ShapeCalcMode::SIZES, InputShape{{}, {{2, 4, 16, 16}}}, - ngraph::helpers::InputLayerType::CONSTANT, + ov::test::utils::InputLayerType::CONSTANT, {{2, 8}}, defaultAxes4D_pillow.front() }, ShapeParams{ ov::op::v11::Interpolate::ShapeCalcMode::SCALES, InputShape{{-1, {2, 20}, -1, -1}, {{1, 11, 4, 4}, {2, 7, 6, 5}, {1, 11, 4, 4}}}, - ngraph::helpers::InputLayerType::PARAMETER, + ov::test::utils::InputLayerType::PARAMETER, {{1.25f, 1.5f}, {0.5f, 0.75f}, {1.25f, 1.5f}}, defaultAxes4D_pillow.front() }, ShapeParams{ ov::op::v11::Interpolate::ShapeCalcMode::SCALES, InputShape{{-1, {2, 20}, -1, -1}, {{1, 11, 4, 4}, {2, 7, 6, 5}, {1, 11, 4, 4}}}, - ngraph::helpers::InputLayerType::CONSTANT, + ov::test::utils::InputLayerType::CONSTANT, {{1.25f, 0.75f}}, defaultAxes4D_pillow.front() }, ShapeParams{ ov::op::v11::Interpolate::ShapeCalcMode::SIZES, InputShape{{-1, {2, 20}, -1, -1}, {{1, 17, 4, 4}, {2, 3, 10, 12}, {1, 17, 4, 4}}}, - ngraph::helpers::InputLayerType::PARAMETER, + ov::test::utils::InputLayerType::PARAMETER, {{6, 8}, {5, 4}, {6, 8}}, defaultAxes4D_pillow.front() }, ShapeParams{ ov::op::v11::Interpolate::ShapeCalcMode::SIZES, InputShape{{-1, {2, 20}, -1, -1}, {{1, 17, 4, 4}, {2, 3, 10, 12}, {1, 17, 4, 4}}}, - ngraph::helpers::InputLayerType::CONSTANT, + ov::test::utils::InputLayerType::CONSTANT, {{6, 8}}, defaultAxes4D_pillow.front() }, @@ -1073,7 +1071,7 @@ const std::vector shapeParams4D_Pillow_Smoke = { ShapeParams{ ov::op::v11::Interpolate::ShapeCalcMode::SIZES, InputShape{{-1, {2, 20}, -1, -1}, {{1, 17, 4, 4}, {2, 3, 10, 12}, {1, 17, 4, 4}}}, - ngraph::helpers::InputLayerType::PARAMETER, + ov::test::utils::InputLayerType::PARAMETER, {{4, 4}, {10, 20}, {10, 4}}, defaultAxes4D_pillow.front() } @@ -1081,20 +1079,18 @@ const std::vector shapeParams4D_Pillow_Smoke = { std::vector filterCPUInfoForDevice_pillow() { std::vector resCPUParams; - if (InferenceEngine::with_cpu_x86_avx512f()) { + if (ov::with_cpu_x86_avx512f()) { resCPUParams.push_back(CPUSpecificParams{{nhwc, x, x}, {nhwc}, {"jit_avx512"}, "jit_avx512"}); - } else if (InferenceEngine::with_cpu_x86_avx2()) { + } else if (ov::with_cpu_x86_avx2()) { resCPUParams.push_back(CPUSpecificParams{{nhwc, x, x}, {nhwc}, {"jit_avx2"}, "jit_avx2"}); - } else if (InferenceEngine::with_cpu_x86_sse42()) { + } else if (ov::with_cpu_x86_sse42()) { resCPUParams.push_back(CPUSpecificParams{{nhwc, x, x}, {nhwc}, {"jit_sse42"}, "jit_sse42"}); } resCPUParams.push_back(CPUSpecificParams{{nchw, x, x}, {nchw}, {"ref"}, "ref"}); return resCPUParams; } -std::vector> filterPillowAdditionalConfig() { - return { - {{InferenceEngine::PluginConfigParams::KEY_PERF_COUNT, InferenceEngine::PluginConfigParams::NO}} - }; +std::vector filterPillowAdditionalConfig() { + return {{}}; } const auto interpolateCasesBilinearPillow_Smoke = ::testing::Combine( @@ -1144,28 +1140,28 @@ const std::vector shapeParams4D_Pillow_Smoke_nchw_as_nhwc = { ShapeParams{ ov::op::v11::Interpolate::ShapeCalcMode::SCALES, InputShape{{}, {{1, 4, 4, 3}}}, - ngraph::helpers::InputLayerType::CONSTANT, + ov::test::utils::InputLayerType::CONSTANT, {{2.0f, 4.0f}}, defaultAxes4D_pillow_nchw_as_nhwc.front() }, ShapeParams{ ov::op::v11::Interpolate::ShapeCalcMode::SIZES, InputShape{{}, {{2, 16, 16, 4}}}, - ngraph::helpers::InputLayerType::CONSTANT, + ov::test::utils::InputLayerType::CONSTANT, {{2, 8}}, defaultAxes4D_pillow_nchw_as_nhwc.front() }, ShapeParams{ ov::op::v11::Interpolate::ShapeCalcMode::SCALES, InputShape{{-1, -1, -1, {2, 20}}, {{1, 4, 4, 11}, {2, 6, 5, 7}, {1, 4, 4, 11}}}, - ngraph::helpers::InputLayerType::CONSTANT, + ov::test::utils::InputLayerType::CONSTANT, {{1.25f, 0.75f}}, defaultAxes4D_pillow_nchw_as_nhwc.front() }, ShapeParams{ ov::op::v11::Interpolate::ShapeCalcMode::SIZES, InputShape{{-1, -1, -1, {2, 20}}, {{1, 4, 4, 17}, {2, 10, 12, 3}, {1, 4, 4, 17}}}, - ngraph::helpers::InputLayerType::CONSTANT, + ov::test::utils::InputLayerType::CONSTANT, {{6, 8}}, defaultAxes4D_pillow_nchw_as_nhwc.front() } @@ -1177,11 +1173,11 @@ const std::vector> pads4D_nchw_as_nhwc = { std::vector filterCPUInfoForDevice_pillow_nchw_as_nhwc() { std::vector resCPUParams; - if (InferenceEngine::with_cpu_x86_avx512f()) { + if (ov::with_cpu_x86_avx512f()) { resCPUParams.push_back(CPUSpecificParams{{nchw, x, x}, {nchw}, {"jit_avx512"}, "jit_avx512"}); - } else if (InferenceEngine::with_cpu_x86_avx2()) { + } else if (ov::with_cpu_x86_avx2()) { resCPUParams.push_back(CPUSpecificParams{{nchw, x, x}, {nchw}, {"jit_avx2"}, "jit_avx2"}); - } else if (InferenceEngine::with_cpu_x86_sse42()) { + } else if (ov::with_cpu_x86_sse42()) { resCPUParams.push_back(CPUSpecificParams{{nchw, x, x}, {nchw}, {"jit_sse42"}, "jit_sse42"}); } return resCPUParams; @@ -1225,5 +1221,6 @@ INSTANTIATE_TEST_SUITE_P(smoke_InterpolateBicubicPillow_LayoutAlign_Test, Interp ::testing::ValuesIn(filterPillowAdditionalConfig())), InterpolateLayerCPUTest::getTestCaseName); -} // namespace -} // namespace CPULayerTestsDefinitions +} // namespace +} // namespace test +} // namespace ov diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/log_softmax.cpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/log_softmax.cpp index 4ba51e71dec1e2..8a5fe083cb1537 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/log_softmax.cpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/log_softmax.cpp @@ -3,20 +3,16 @@ // #include "test_utils/cpu_test_utils.hpp" -#include "ov_models/builders.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -using namespace ngraph; -using namespace InferenceEngine; using namespace CPUTestUtils; -using namespace ov::test; -namespace CPULayerTestsDefinitions { +namespace ov { +namespace test { -using logSoftmaxLayerTestParams = std::tuple< - std::vector, // inputShape - Precision, // netPrecision - int64_t>; // axis +using logSoftmaxLayerTestParams = std::tuple, // inputShape + ov::element::Type, // netPrecision + int64_t>; // axis class LogSoftmaxLayerCPUTest : public testing::WithParamInterface, @@ -25,7 +21,7 @@ class LogSoftmaxLayerCPUTest public: static std::string getTestCaseName(testing::TestParamInfo obj) { std::vector inputShapes; - Precision netPrecision; + ov::element::Type netPrecision; int64_t axis; std::tie(inputShapes, netPrecision, axis) = obj.param; @@ -44,7 +40,7 @@ class LogSoftmaxLayerCPUTest result << ov::test::utils::vec2str(item) << "_"; } } - result << "netPRC=" << netPrecision.name(); + result << "netPRC=" << netPrecision.to_string(); result << "Axis=" << axis; return result.str(); } @@ -54,20 +50,20 @@ class LogSoftmaxLayerCPUTest targetDevice = ov::test::utils::DEVICE_CPU; std::vector inputShapes; - Precision netPrecision; + ov::element::Type netPrecision; int64_t axis; std::tie(inputShapes, netPrecision, axis) = this->GetParam(); - auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); + auto ngPrc = netPrecision; inType = outType = ngPrc; - selectedType = std::string("unknown_") + netPrecision.name(); + selectedType = std::string("unknown_") + netPrecision.to_string(); init_input_shapes(inputShapes); ov::ParameterVector params{std::make_shared(ngPrc, inputDynamicShapes.front())}; - const auto logSoftmax = std::make_shared(params[0], axis); - const ngraph::ResultVector results{std::make_shared(logSoftmax)}; - function = std::make_shared(results, params, "logSoftmax"); + const auto logSoftmax = std::make_shared(params[0], axis); + const ov::ResultVector results{std::make_shared(logSoftmax)}; + function = std::make_shared(results, params, "logSoftmax"); } }; @@ -77,8 +73,8 @@ TEST_P(LogSoftmaxLayerCPUTest, CompareWithRefs) { } namespace { -const std::vector netPrecisions = { - Precision::FP32 +const std::vector netPrecisions = { + ov::element::f32 }; const std::vector> inputShapes2D = { @@ -120,4 +116,5 @@ INSTANTIATE_TEST_SUITE_P(smoke_LogSoftmax4D_dynamic, LogSoftmaxLayerCPUTest, par LogSoftmaxLayerCPUTest::getTestCaseName); } // namespace -} // namespace CPULayerTestsDefinitions +} // namespace test +} // namespace ov diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/loop.cpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/loop.cpp index 00d887206696ae..88492cbe5f968c 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/loop.cpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/loop.cpp @@ -2,17 +2,15 @@ // SPDX-License-Identifier: Apache-2.0 // -#include +#include "shared_test_classes/single_layer/loop.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" #include "ov_models/builders.hpp" -#include +#include "common_test_utils/ov_tensor_utils.hpp" -using namespace InferenceEngine; -using namespace ov; -using namespace test; -using namespace ngraph::helpers; +using namespace ov::test::utils; -namespace CPULayerTestsDefinitions { +namespace ov { +namespace test { enum LOOP_IN_TYPE { INVARIANT, @@ -101,39 +99,39 @@ class LoopLayerCPUTest : public testing::WithParamInterface, } // Set up the cell body, a function from (Xi, Yi) -> (Zo) // Body parameters - const std::vector body_params_shapes(shapes.size(), ngraph::PartialShape::dynamic()); - ngraph::ParameterVector body_params; + const std::vector body_params_shapes(shapes.size(), ov::PartialShape::dynamic()); + ov::ParameterVector body_params; for (const auto &pshape : body_params_shapes) { - body_params.emplace_back(std::make_shared(netType, pshape)); + body_params.emplace_back(std::make_shared(netType, pshape)); } - auto body_condition_const = std::make_shared(ngraph::element::boolean, ngraph::Shape{1}, true); - auto exec_condition = std::make_shared(ngraph::element::boolean, ngraph::Shape{1}, exec_cond); - std::shared_ptr trip_count_input; + auto body_condition_const = std::make_shared(ov::element::boolean, ov::Shape{1}, true); + auto exec_condition = std::make_shared(ov::element::boolean, ov::Shape{1}, exec_cond); + std::shared_ptr trip_count_input; int shift = 0; if (trip_count_type == InputLayerType::PARAMETER) { for (auto& target : targetStaticShapes) - target.insert(target.begin(), ngraph::Shape{}); - trip_count_input = std::make_shared(ngraph::element::i64, ngraph::Shape{1}); + target.insert(target.begin(), ov::Shape{}); + trip_count_input = std::make_shared(ov::element::i64, ov::Shape{1}); trip_count_input->set_friendly_name("trip_count"); - params.insert(params.begin(), ov::as_type_ptr(trip_count_input)); + params.insert(params.begin(), ov::as_type_ptr(trip_count_input)); shift++; } else { - trip_count_input = std::make_shared(ngraph::element::i64, ngraph::Shape{1}, trip_count); + trip_count_input = std::make_shared(ov::element::i64, ov::Shape{1}, trip_count); } // Body - std::shared_ptr Zo = body_params[0]; + std::shared_ptr Zo = body_params[0]; for (size_t i = 1; i < body_params.size(); ++i) { - Zo = std::make_shared(body_params[i], Zo); + Zo = std::make_shared(body_params[i], Zo); } - auto body = std::make_shared(ngraph::OutputVector{body_condition_const, Zo}, + auto body = std::make_shared(ov::OutputVector{body_condition_const, Zo}, body_params); - auto loop = std::make_shared(trip_count_input, exec_condition); + auto loop = std::make_shared(trip_count_input, exec_condition); loop->set_function(body); - loop->set_special_body_ports(ngraph::opset5::Loop::SpecialBodyPorts{-1, 0}); + loop->set_special_body_ports(ov::op::v5::Loop::SpecialBodyPorts{-1, 0}); for (size_t i = 0; i < body_params.size(); ++i) { if (types[i] == LOOP_IN_TYPE::INVARIANT) { @@ -152,10 +150,10 @@ class LoopLayerCPUTest : public testing::WithParamInterface, // 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(ngraph::ResultVector{result0, result1, result2}, params, "loop"); + 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"); } }; @@ -177,45 +175,45 @@ class LoopWhileLayerCPUTest : public LoopLayerCPUTest { targetDevice = ov::test::utils::DEVICE_CPU; init_input_shapes(shapes); for (auto& target : targetStaticShapes) - target.insert(target.begin(), ngraph::Shape{}); + target.insert(target.begin(), ov::Shape{}); ov::ParameterVector params; for (auto&& shape : inputDynamicShapes) { params.push_back(std::make_shared(inType, shape)); } // Body parameters - const std::vector body_params_shapes(shapes.size(), ngraph::PartialShape::dynamic()); - ngraph::ParameterVector body_params = { std::make_shared(ngraph::element::i64, ngraph::Shape{}) }; + const std::vector body_params_shapes(shapes.size(), ov::PartialShape::dynamic()); + ov::ParameterVector body_params = { std::make_shared(ov::element::i64, ov::Shape{}) }; for (const auto &pshape : body_params_shapes) { - body_params.emplace_back(std::make_shared(inType, pshape)); + body_params.emplace_back(std::make_shared(inType, pshape)); } - auto exec_condition = std::make_shared(ngraph::element::boolean, ngraph::Shape{}, exec_cond); - auto trip_count_input = std::make_shared(ngraph::element::i64, ngraph::Shape{}); + auto exec_condition = std::make_shared(ov::element::boolean, ov::Shape{}, exec_cond); + auto trip_count_input = std::make_shared(ov::element::i64, ov::Shape{}); trip_count_input->set_friendly_name("trip_count"); params.insert(params.begin(), trip_count_input); // Body - auto const_body_cond = std::make_shared(ngraph::element::i64, ngraph::Shape{}, 10); - auto const_body_step = std::make_shared(ngraph::element::i64, ngraph::Shape{}, 2); - auto less = std::make_shared(body_params[0], const_body_cond); - auto exec_idx = std::make_shared(body_params[0], const_body_step); + auto const_body_cond = std::make_shared(ov::element::i64, ov::Shape{}, 10); + auto const_body_step = std::make_shared(ov::element::i64, ov::Shape{}, 2); + auto less = std::make_shared(body_params[0], const_body_cond); + auto exec_idx = std::make_shared(body_params[0], const_body_step); - auto node_const = std::make_shared(inType, ngraph::Shape{}, 2); - auto node = std::make_shared(body_params[1], node_const); + auto node_const = std::make_shared(inType, ov::Shape{}, 2); + auto node = std::make_shared(body_params[1], node_const); - // reference ngraph function is resized by input static shapes in tests but + // reference model is resized by input static shapes in tests but // loop with pad in body has different input shape in each infer request so tests don't support it. // Alternative - eltwise instead of pad // const std::vector begin(inputDynamicShapes[0].rank().get_length(), 1); // const std::vector end(inputDynamicShapes[0].rank().get_length(), 0); // auto node = ngraph::builder::makePad(body_params[1], begin, end, .0f, PadMode::CONSTANT); - auto body = std::make_shared(ngraph::OutputVector{less, exec_idx, node}, body_params); + auto body = std::make_shared(ov::OutputVector{less, exec_idx, node}, body_params); - auto loop = std::make_shared(params[0], exec_condition); + auto loop = std::make_shared(params[0], exec_condition); loop->set_function(body); - loop->set_special_body_ports(ngraph::opset5::Loop::SpecialBodyPorts{-1, 0}); + loop->set_special_body_ports(ov::op::v5::Loop::SpecialBodyPorts{-1, 0}); loop->set_merged_input(body_params[0], params[0], exec_idx); loop->set_merged_input(body_params[1], params[1], node); @@ -223,9 +221,9 @@ class LoopWhileLayerCPUTest : public LoopLayerCPUTest { auto out0 = loop->get_iter_value(exec_idx, -1); auto out1 = loop->get_iter_value(node, -1); - auto result0 = std::make_shared(out0); - auto result1 = std::make_shared(out1); - function = std::make_shared(ngraph::ResultVector{ result0, result1 }, params, "loop"); + auto result0 = std::make_shared(out0); + auto result1 = std::make_shared(out1); + function = std::make_shared(ov::ResultVector{ result0, result1 }, params, "loop"); } }; @@ -256,25 +254,25 @@ class LoopForDiffShapesLayerCPUTest : public LoopLayerCPUTest { } // Set up the cell body, a function from (Xi, Yi) -> (Zo) // Body parameters - const std::vector body_params_shapes(shapes.size(), ngraph::PartialShape::dynamic()); - ngraph::ParameterVector body_params; + const std::vector body_params_shapes(shapes.size(), ov::PartialShape::dynamic()); + ov::ParameterVector body_params; for (const auto &pshape : body_params_shapes) { - body_params.emplace_back(std::make_shared(inType, pshape)); + body_params.emplace_back(std::make_shared(inType, pshape)); } - auto body_condition_const = std::make_shared(ngraph::element::boolean, ngraph::Shape{1}, true); - auto exec_condition = std::make_shared(ngraph::element::boolean, ngraph::Shape{1}, exec_cond); - std::shared_ptr trip_count_input; + auto body_condition_const = std::make_shared(ov::element::boolean, ov::Shape{1}, true); + auto exec_condition = std::make_shared(ov::element::boolean, ov::Shape{1}, exec_cond); + std::shared_ptr trip_count_input; int shift = 0; if (trip_count_type == InputLayerType::PARAMETER) { for (auto& target : targetStaticShapes) - target.insert(target.begin(), ngraph::Shape{}); - trip_count_input = std::make_shared(ngraph::element::i64, ngraph::Shape{1}); + target.insert(target.begin(), ov::Shape{}); + trip_count_input = std::make_shared(ov::element::i64, ov::Shape{1}); trip_count_input->set_friendly_name("trip_count"); - params.insert(params.begin(), ov::as_type_ptr(trip_count_input)); + params.insert(params.begin(), ov::as_type_ptr(trip_count_input)); shift++; } else { - trip_count_input = std::make_shared(ngraph::element::i64, ngraph::Shape{1}, trip_count); + trip_count_input = std::make_shared(ov::element::i64, ov::Shape{1}, trip_count); } // Body @@ -288,11 +286,11 @@ class LoopForDiffShapesLayerCPUTest : public LoopLayerCPUTest { auto constant = ngraph::builder::makeConstant(inType, std::vector{1}, std::vector{0.5}); auto eltwise = std::make_shared(body_params[0], constant); - auto body = std::make_shared(ngraph::OutputVector{body_condition_const, s, eltwise}, body_params); + auto body = std::make_shared(ov::OutputVector{body_condition_const, s, eltwise}, body_params); - auto loop = std::make_shared(trip_count_input, exec_condition); + auto loop = std::make_shared(trip_count_input, exec_condition); loop->set_function(body); - loop->set_special_body_ports(ngraph::opset5::Loop::SpecialBodyPorts{-1, 0}); + loop->set_special_body_ports(ov::op::v5::Loop::SpecialBodyPorts{-1, 0}); loop->set_merged_input(body_params[0], params[shift], eltwise); @@ -303,10 +301,10 @@ class LoopForDiffShapesLayerCPUTest : public LoopLayerCPUTest { // start=0, stride=1, part_size=1, end=-1, axis=1 auto out2 = loop->get_concatenated_slices(s, 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(ngraph::ResultVector{result0, result1, result2}, params, "loop"); + 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"); } }; @@ -333,36 +331,36 @@ class LoopForConcatLayerCPUTest : public LoopLayerCPUTest { params.push_back(std::make_shared(inType, shape)); } // Body parameters - const std::vector body_params_shapes(shapes.size(), ngraph::PartialShape::dynamic()); + const std::vector body_params_shapes(shapes.size(), ov::PartialShape::dynamic()); ov::ParameterVector body_params; for (auto&& shape : inputDynamicShapes) { body_params.push_back(std::make_shared(inType, shape)); } - auto body_condition_const = std::make_shared(ngraph::element::boolean, ngraph::Shape{1}, true); - auto exec_condition = std::make_shared(ngraph::element::boolean, ngraph::Shape{1}, exec_cond); - std::shared_ptr trip_count_input; + auto body_condition_const = std::make_shared(ov::element::boolean, ov::Shape{1}, true); + auto exec_condition = std::make_shared(ov::element::boolean, ov::Shape{1}, exec_cond); + std::shared_ptr trip_count_input; int shift = 0; if (trip_count_type == InputLayerType::PARAMETER) { for (auto& target : targetStaticShapes) - target.insert(target.begin(), ngraph::Shape{}); - trip_count_input = std::make_shared(ngraph::element::i64, ngraph::Shape{1}); + target.insert(target.begin(), ov::Shape{}); + trip_count_input = std::make_shared(ov::element::i64, ov::Shape{1}); trip_count_input->set_friendly_name("trip_count"); - params.insert(params.begin(), ov::as_type_ptr(trip_count_input)); + params.insert(params.begin(), ov::as_type_ptr(trip_count_input)); shift++; } else { - trip_count_input = std::make_shared(ngraph::element::i64, ngraph::Shape{1}, trip_count); + trip_count_input = std::make_shared(ov::element::i64, ov::Shape{1}, trip_count); } // Body auto constant = ngraph::builder::makeConstant(inType, std::vector{1}, std::vector{10}); - auto add = std::make_shared(body_params[0], constant); + auto add = std::make_shared(body_params[0], constant); auto concat = std::make_shared(ov::NodeVector{body_params[1], add}, 0); - auto body = std::make_shared(ngraph::OutputVector{body_condition_const, concat}, body_params); + auto body = std::make_shared(ov::OutputVector{body_condition_const, concat}, body_params); - auto loop = std::make_shared(trip_count_input, exec_condition); + auto loop = std::make_shared(trip_count_input, exec_condition); loop->set_function(body); - loop->set_special_body_ports(ngraph::opset5::Loop::SpecialBodyPorts{-1, 0}); + loop->set_special_body_ports(ov::op::v5::Loop::SpecialBodyPorts{-1, 0}); loop->set_invariant_input(body_params[0], params[shift]); loop->set_merged_input(body_params[1], params[shift + 1], concat); @@ -370,9 +368,9 @@ class LoopForConcatLayerCPUTest : public LoopLayerCPUTest { auto out0 = loop->get_iter_value(body_condition_const, -1); auto out1 = loop->get_iter_value(concat, -1); - auto result0 = std::make_shared(out0); - auto result1 = std::make_shared(out1); - function = std::make_shared(ngraph::ResultVector{result0, result1}, params, "loop"); + auto result0 = std::make_shared(out0); + auto result1 = std::make_shared(out1); + function = std::make_shared(ov::ResultVector{result0, result1}, params, "loop"); } }; @@ -669,4 +667,5 @@ INSTANTIATE_TEST_SUITE_P(smoke_LoopForConcat, LoopForConcatLayerCPUTest, LoopLayerCPUTest::getTestCaseName); } // namespace -} // namespace CPULayerTestsDefinitions +} // namespace test +} // namespace ov diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/lrn.cpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/lrn.cpp index 2d47fe19f18a8d..2e0e5b9541338e 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/lrn.cpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/lrn.cpp @@ -2,17 +2,14 @@ // SPDX-License-Identifier: Apache-2.0 // -#include -#include "test_utils/cpu_test_utils.hpp" - +#include "common_test_utils/ov_tensor_utils.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include "ov_models/builders.hpp" +#include "test_utils/cpu_test_utils.hpp" -using namespace ngraph; using namespace CPUTestUtils; -using namespace ov::test; -namespace CPULayerTestsDefinitions { +namespace ov { +namespace test { using LRNParams = std::tuple< ElementType, // data precision InputShape, // data shape @@ -59,8 +56,8 @@ class LRNLayerCPUTest : public testing::WithParamInterface, public ov for (auto&& shape : inputDynamicShapes) { params.push_back(std::make_shared(inputPrecision, shape)); } - auto axesNode = ngraph::opset1::Constant::create(ngraph::element::i32, { axes.size() }, axes); - auto lrn = std::make_shared(params[0], axesNode, alpha, beta, bias, size); + auto axesNode = ov::op::v0::Constant::create(ov::element::i32, { axes.size() }, axes); + auto lrn = std::make_shared(params[0], axesNode, alpha, beta, bias, size); function = makeNgraphFunction(inputPrecision, params, lrn, "LRN"); } }; @@ -71,7 +68,7 @@ TEST_P(LRNLayerCPUTest, CompareWithRefs) { } const std::vector inputPrecisions = { - ngraph::element::f32, + ov::element::f32, }; const std::vector> axes = { @@ -120,4 +117,5 @@ const auto testCases = ::testing::Combine( INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs, LRNLayerCPUTest, testCases, LRNLayerCPUTest::getTestCaseName); -} // namespace CPULayerTestsDefinitions +} // namespace test +} // namespace ov diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/lstm_cell.cpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/lstm_cell.cpp index b03a7a35e53666..83a0126444f36a 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/lstm_cell.cpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/lstm_cell.cpp @@ -2,14 +2,15 @@ // SPDX-License-Identifier: Apache-2.0 // +#include "common_test_utils/node_builders/lstm_cell.hpp" + #include "shared_test_classes/base/ov_subgraph.hpp" -#include "ov_models/builders.hpp" #include "test_utils/cpu_test_utils.hpp" using namespace CPUTestUtils; -using namespace ov::test; -namespace CPULayerTestsDefinitions { +namespace ov { +namespace test { using LSTMCellCpuSpecificParams = typename std::tuple< std::vector, // Shapes @@ -18,7 +19,7 @@ using LSTMCellCpuSpecificParams = typename std::tuple< float, // clip ElementType, // Network precision CPUSpecificParams, // CPU specific params - std::map // Additional config + ov::AnyMap // Additional config >; class LSTMCellLayerCPUTest : public testing::WithParamInterface, @@ -31,7 +32,7 @@ class LSTMCellLayerCPUTest : public testing::WithParamInterface additionalConfig; + ov::AnyMap additionalConfig; std::tie(inputShapes, decompose, activations, clip, netPrecision, cpuParams, additionalConfig) = obj.param; @@ -57,8 +58,7 @@ class LSTMCellLayerCPUTest : public testing::WithParamInterface> additionalConfig - = {{{InferenceEngine::PluginConfigParams::KEY_ENFORCE_BF16, InferenceEngine::PluginConfigParams::YES}}, - {{InferenceEngine::PluginConfigParams::KEY_ENFORCE_BF16, InferenceEngine::PluginConfigParams::NO}}}; +std::vector additionalConfig = {{{ov::hint::inference_precision(ov::element::bf16)}}, + {{ov::hint::inference_precision(ov::element::f32)}}}; CPUSpecificParams cpuParams{{nc, nc, nc}, {nc}, {"ref_any"}, "ref_any"}; @@ -201,4 +201,5 @@ INSTANTIATE_TEST_SUITE_P(smoke_dynamic, LSTMCellLayerCPUTest, ::testing::ValuesIn(additionalConfig)), LSTMCellLayerCPUTest::getTestCaseName); } // namespace -} // namespace CPULayerTestsDefinitions +} // namespace test +} // namespace ov diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/lstm_sequence.cpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/lstm_sequence.cpp index 206c29731b7353..d484942d899559 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/lstm_sequence.cpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/lstm_sequence.cpp @@ -2,41 +2,42 @@ // SPDX-License-Identifier: Apache-2.0 // -#include +#include "common_test_utils/node_builders/lstm_cell.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include "ov_models/builders.hpp" #include "test_utils/cpu_test_utils.hpp" #include "transformations/op_conversions/bidirectional_sequences_decomposition.hpp" #include "transformations/op_conversions/convert_sequences_to_tensor_iterator.hpp" +#include + using namespace CPUTestUtils; -using namespace ov::test; -namespace CPULayerTestsDefinitions { +namespace ov { +namespace test { -using LSTMSequenceCpuSpecificParams = typename std::tuple< - std::vector, // Shapes - ngraph::helpers::SequenceTestsMode, // Pure Sequence or TensorIterator - std::vector, // Activations - float, // Clip - ngraph::op::RecurrentSequenceDirection, // Direction - ElementType, // Network precision - CPUSpecificParams, // CPU specific params - std::map // Additional config ->; +using LSTMSequenceCpuSpecificParams = + typename std::tuple, // Shapes + ov::test::utils::SequenceTestsMode, // Pure Sequence or TensorIterator + std::vector, // Activations + float, // Clip + ov::op::RecurrentSequenceDirection, // Direction + ElementType, // Network precision + CPUSpecificParams, // CPU specific params + ov::AnyMap // Additional config + >; class LSTMSequenceCPUTest : public testing::WithParamInterface, virtual public ov::test::SubgraphBaseTest, public CPUTestsBase { public: static std::string getTestCaseName(const testing::TestParamInfo &obj) { std::vector inputShapes; - ngraph::helpers::SequenceTestsMode seqMode; + ov::test::utils::SequenceTestsMode seqMode; std::vector activations; float clip; ov::op::RecurrentSequenceDirection direction; ElementType netPrecision; CPUSpecificParams cpuParams; - std::map additionalConfig; + ov::AnyMap additionalConfig; std::tie(inputShapes, seqMode, activations, clip, direction, netPrecision, cpuParams, additionalConfig) = obj.param; @@ -62,9 +63,8 @@ class LSTMSequenceCPUTest : public testing::WithParamInterface(); manager.register_pass(); manager.run_passes(function); @@ -188,15 +189,14 @@ TEST_P(LSTMSequenceCPUTest, CompareWithRefs) { namespace { /* CPU PARAMS */ -std::vector> additionalConfig - = {{{InferenceEngine::PluginConfigParams::KEY_ENFORCE_BF16, InferenceEngine::PluginConfigParams::NO}}, - {{InferenceEngine::PluginConfigParams::KEY_ENFORCE_BF16, InferenceEngine::PluginConfigParams::YES}}}; +std::vector additionalConfig = {{{ov::hint::inference_precision(ov::element::f32)}}, + {{ov::hint::inference_precision(ov::element::bf16)}}}; CPUSpecificParams cpuParams{{ntc, tnc, tnc}, {ntc, tnc, tnc}, {"ref_any"}, "ref_any"}; // CPUSpecificParams cpuParamsBatchSizeOne{{tnc, ntc, ntc}, {tnc, ntc, ntc}, {"ref_any"}, "ref_any"}; CPUSpecificParams cpuParamsBatchSizeOne{{tnc, tnc, tnc}, {tnc, tnc, tnc}, {"ref_any"}, "ref_any"}; -std::vector mode{ngraph::helpers::SequenceTestsMode::PURE_SEQ}; +std::vector mode{ov::test::utils::SequenceTestsMode::PURE_SEQ}; // oneDNN supports only sigmoid-tanh-tanh std::vector> activations = {{"sigmoid", "tanh", "tanh"}}; // oneDNN supports only zero clip @@ -236,7 +236,7 @@ INSTANTIATE_TEST_SUITE_P(smoke_static, LSTMSequenceCPUTest, ::testing::ValuesIn(direction), ::testing::ValuesIn(netPrecisions), ::testing::Values(cpuParams), - ::testing::Values(std::map{})), + ::testing::Values(ov::AnyMap{})), LSTMSequenceCPUTest::getTestCaseName); INSTANTIATE_TEST_SUITE_P(smoke_static_BatchSizeOne, LSTMSequenceCPUTest, @@ -247,7 +247,7 @@ INSTANTIATE_TEST_SUITE_P(smoke_static_BatchSizeOne, LSTMSequenceCPUTest, ::testing::ValuesIn(direction), ::testing::ValuesIn(netPrecisions), ::testing::Values(cpuParamsBatchSizeOne), - ::testing::Values(std::map{})), + ::testing::Values(ov::AnyMap{})), LSTMSequenceCPUTest::getTestCaseName); INSTANTIATE_TEST_SUITE_P(nightly_static_bf16, LSTMSequenceCPUTest, @@ -345,7 +345,7 @@ namespace dynamicShapesBatchSwitch { const int seq_length = 1; const int hidden_size = 1024; const int num_directions = 1; - const ngraph::helpers::SequenceTestsMode mode = ngraph::helpers::SequenceTestsMode::PURE_SEQ; + const ov::test::utils::SequenceTestsMode mode = ov::test::utils::SequenceTestsMode::PURE_SEQ; CPUSpecificParams cpuParams{{ntc, tnc, tnc}, {ntc, tnc, tnc}, {"ref_any"}, "ref_any"}; const std::vector shapes = { @@ -396,7 +396,7 @@ INSTANTIATE_TEST_SUITE_P(smoke_dynamic_batch, LSTMSequenceCPUTest, ::testing::Values(ov::op::RecurrentSequenceDirection::FORWARD), ::testing::ValuesIn(netPrecisions), ::testing::Values(dynamicShapesBatchSwitch::cpuParams), - ::testing::Values(std::map{{"_dynamic_batch_test", "yes"}})), + ::testing::Values(ov::AnyMap{{"_dynamic_batch_test", "yes"}})), LSTMSequenceCPUTest::getTestCaseName); INSTANTIATE_TEST_SUITE_P(smoke_dynamic, LSTMSequenceCPUTest, @@ -407,7 +407,7 @@ INSTANTIATE_TEST_SUITE_P(smoke_dynamic, LSTMSequenceCPUTest, ::testing::ValuesIn(direction), ::testing::ValuesIn(netPrecisions), ::testing::Values(cpuParams), - ::testing::Values(std::map{})), + ::testing::Values(ov::AnyMap{})), LSTMSequenceCPUTest::getTestCaseName); INSTANTIATE_TEST_SUITE_P(smoke_dynamic_BatchSizeOne, LSTMSequenceCPUTest, @@ -418,7 +418,7 @@ INSTANTIATE_TEST_SUITE_P(smoke_dynamic_BatchSizeOne, LSTMSequenceCPUTest, ::testing::ValuesIn(direction), ::testing::ValuesIn(netPrecisions), ::testing::Values(cpuParamsBatchSizeOne), - ::testing::Values(std::map{})), + ::testing::Values(ov::AnyMap{})), LSTMSequenceCPUTest::getTestCaseName); INSTANTIATE_TEST_SUITE_P(nightly_dynamic, LSTMSequenceCPUTest, @@ -429,7 +429,7 @@ INSTANTIATE_TEST_SUITE_P(nightly_dynamic, LSTMSequenceCPUTest, ::testing::ValuesIn(direction), ::testing::ValuesIn(netPrecisions), ::testing::Values(cpuParams), - ::testing::Values(std::map{})), + ::testing::Values(ov::AnyMap{})), LSTMSequenceCPUTest::getTestCaseName); INSTANTIATE_TEST_SUITE_P(nightly_dynamic_bf16, LSTMSequenceCPUTest, @@ -453,5 +453,6 @@ INSTANTIATE_TEST_SUITE_P(nightly_dynamic_bf16_BatchSizeOne, LSTMSequenceCPUTest, ::testing::Values(cpuParamsBatchSizeOne), ::testing::Values(additionalConfig[1])), LSTMSequenceCPUTest::getTestCaseName); -} // namespace -} // namespace CPULayerTestsDefinitions +} // namespace +} // namespace test +} // namespace ov diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/matmul_sparse.cpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/matmul_sparse.cpp index ef99871333e9f9..8f602c697f59b7 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/matmul_sparse.cpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/matmul_sparse.cpp @@ -2,23 +2,20 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "shared_test_classes/single_layer/mat_mul.hpp" -#include "shared_test_classes/base/ov_subgraph.hpp" -#include "ie_precision.hpp" -#include "test_utils/fusing_test_utils.hpp" +#include "common_test_utils/ov_tensor_utils.hpp" +#include "cpu/cpu_config.hpp" +#include "openvino/runtime/intel_cpu/properties.hpp" #include "ov_models/builders.hpp" -#include -#include +#include "ov_ops/type_relaxed.hpp" +#include "shared_test_classes/base/ov_subgraph.hpp" #include "shared_test_classes/base/utils/generate_inputs.hpp" -#include "cpu/cpu_config.hpp" -#include "common_test_utils/ov_tensor_utils.hpp" +#include "shared_test_classes/single_layer/mat_mul.hpp" +#include "test_utils/fusing_test_utils.hpp" -using namespace ngraph; -using namespace InferenceEngine; using namespace CPUTestUtils; -using namespace ov::test; -namespace CPULayerTestsDefinitions { +namespace ov { +namespace test { struct ShapeRelatedParams { std::vector inputShapes; @@ -32,7 +29,7 @@ typedef std::tuple< ElementType, // Output precision fusingSpecificParams, CPUSpecificParams, - std::map, // Additional config + ov::AnyMap, // Additional config float // Weights sparse rate > MatMulSparseParamSet; @@ -44,7 +41,7 @@ class MatMulSparseCPUTest : public testing::WithParamInterface additionalConfig; + ov::AnyMap additionalConfig; float weiSparseRate; std::tie(shapeRelatedParams, inType, weiType, outType, fusingParams, cpuParams, additionalConfig, weiSparseRate) = obj.param; @@ -76,7 +73,7 @@ class MatMulSparseCPUTest : public testing::WithParamInterface SparseRate80 = {{CPUConfigParams::KEY_CPU_SPARSE_WEIGHTS_DECOMPRESSION_RATE, "0.8"}}; +const ov::AnyMap emptyConfig = {}; +const ov::AnyMap SparseRate50 = {{ov::intel_cpu::sparse_weights_decompression_rate(0.5)}}; +const ov::AnyMap SparseRate80 = {{ov::intel_cpu::sparse_weights_decompression_rate(0.8)}}; const std::vector IS2D_sparse_smoke = { {static_shapes_to_test_representation({{64, 64}, {64, 64}}), {false, true}}, @@ -340,4 +334,5 @@ INSTANTIATE_TEST_SUITE_P(smoke_FC_3D_I8_sparse, MatMulSparseCPUTest, testParams3 } // namespace -} // namespace CPULayerTestsDefinitions +} // namespace test +} // namespace ov diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/non_max_suppression.cpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/non_max_suppression.cpp index 07b1e9c3405603..dfc7a48bf2559c 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/non_max_suppression.cpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/non_max_suppression.cpp @@ -2,20 +2,16 @@ // SPDX-License-Identifier: Apache-2.0 // -#include -#include - -#include "shared_test_classes/base/ov_subgraph.hpp" +#include "common_test_utils/ov_tensor_utils.hpp" #include "ov_models/builders.hpp" -#include -#include "test_utils/cpu_test_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" -using namespace ov::test; -using namespace ngraph; using namespace CPUTestUtils; -namespace CPULayerTestsDefinitions { +namespace ov { +namespace test { enum { BATCHES, @@ -42,7 +38,7 @@ using NmsParams = std::tuple, virtual p InputShapeParams inShapeParams; InputPrecisions inPrecisions; int32_t maxOutBoxesPerClass; - ngraph::helpers::InputLayerType maxOutBoxesType; + ov::test::utils::InputLayerType maxOutBoxesType; ThresholdValues thrValues; float iouThr, scoreThr, softNmsSigma; ov::op::v9::NonMaxSuppression::BoxEncodingType boxEncoding; @@ -82,6 +78,7 @@ class NmsLayerCPUTest : public testing::WithParamInterface, virtual p std::tie(numBatches, numBoxes, numClasses) = ts; result << "(nB=" << numBatches << "_nBox=" << numBoxes << "_nC=" << numClasses << ")_"; } + using ov::operator<<; result << "paramsPrec=" << paramsPrec << "_maxBoxPrec=" << maxBoxPrec << "_thrPrec=" << thrPrec << "_"; result << "maxOutBoxesPerClass=" << maxOutBoxesPerClass << "_"; result << "iouThr=" << iouThr << "_scoreThr=" << scoreThr << "_softNmsSigma=" << softNmsSigma << "_"; @@ -113,7 +110,7 @@ class NmsLayerCPUTest : public testing::WithParamInterface, virtual p InputShapeParams inShapeParams; InputPrecisions inPrecisions; ThresholdValues thrValues; - ngraph::helpers::InputLayerType maxOutBoxesType; + ov::test::utils::InputLayerType maxOutBoxesType; float iouThr, scoreThr, softNmsSigma; ov::op::v9::NonMaxSuppression::BoxEncodingType boxEncoding; bool sortResDescend; @@ -129,24 +126,24 @@ class NmsLayerCPUTest : public testing::WithParamInterface, virtual p std::tie(bounds, targetInDims) = inShapeParams; if (!bounds.empty()) { - inputDynamicShapes = std::vector{{bounds[BATCHES], bounds[BOXES], 4}, {bounds[BATCHES], bounds[CLASSES], bounds[BOXES]}}; + inputDynamicShapes = std::vector{{bounds[BATCHES], bounds[BOXES], 4}, {bounds[BATCHES], bounds[CLASSES], bounds[BOXES]}}; } else { size_t batches, boxes, classes; std::tie(batches, boxes, classes) = targetInDims.front(); ov::Dimension numBatches(batches), numBoxes(boxes), numClasses(classes); - inputDynamicShapes = std::vector{{numBatches, numBoxes, 4}, {numBatches, numClasses, numBoxes}}; + inputDynamicShapes = std::vector{{numBatches, numBoxes, 4}, {numBatches, numClasses, numBoxes}}; } for (const auto &ts : targetInDims) { size_t numBatches, numBoxes, numClasses; std::tie(numBatches, numBoxes, numClasses) = ts; - targetStaticShapes.push_back(std::vector{{numBatches, numBoxes, 4}, {numBatches, numClasses, numBoxes}}); - if (maxOutBoxesType == ngraph::helpers::InputLayerType::PARAMETER) { - targetStaticShapes.back().push_back(ngraph::Shape{1}); + targetStaticShapes.push_back(std::vector{{numBatches, numBoxes, 4}, {numBatches, numClasses, numBoxes}}); + if (maxOutBoxesType == ov::test::utils::InputLayerType::PARAMETER) { + targetStaticShapes.back().push_back(ov::Shape{1}); } } - std::shared_ptr maxOutBoxesPerClassNode; + std::shared_ptr maxOutBoxesPerClassNode; ov::ParameterVector params; for (auto&& shape : inputDynamicShapes) { params.push_back(std::make_shared(paramsPrec, shape)); @@ -154,18 +151,18 @@ class NmsLayerCPUTest : public testing::WithParamInterface, virtual p params[0]->set_friendly_name("param_1"); params[1]->set_friendly_name("param_2"); - if (maxOutBoxesType == ngraph::helpers::InputLayerType::PARAMETER) { - inputDynamicShapes.push_back(ngraph::PartialShape{1}); - params.push_back(std::make_shared(ElementType::i32, inputDynamicShapes.back())); + if (maxOutBoxesType == ov::test::utils::InputLayerType::PARAMETER) { + inputDynamicShapes.push_back(ov::PartialShape{1}); + params.push_back(std::make_shared(ElementType::i32, inputDynamicShapes.back())); params[1]->set_friendly_name("param_3"); maxOutBoxesPerClassNode = params.back(); } else { - maxOutBoxesPerClassNode = builder::makeConstant(maxBoxPrec, ngraph::Shape{}, std::vector{maxOutBoxesPerClass}); + maxOutBoxesPerClassNode = ngraph::builder::makeConstant(maxBoxPrec, ov::Shape{}, std::vector{maxOutBoxesPerClass}); } - auto iouThrNode = builder::makeConstant(thrPrec, ngraph::Shape{}, std::vector{iouThr})->output(0); - auto scoreThrNode = builder::makeConstant(thrPrec, ngraph::Shape{}, std::vector{scoreThr})->output(0); - auto softNmsSigmaNode = builder::makeConstant(thrPrec, ngraph::Shape{}, std::vector{softNmsSigma})->output(0); + auto iouThrNode = ngraph::builder::makeConstant(thrPrec, ov::Shape{}, std::vector{iouThr})->output(0); + auto scoreThrNode = ngraph::builder::makeConstant(thrPrec, ov::Shape{}, std::vector{scoreThr})->output(0); + auto softNmsSigmaNode = ngraph::builder::makeConstant(thrPrec, ov::Shape{}, std::vector{softNmsSigma})->output(0); auto nms = std::make_shared(params[0], params[1], maxOutBoxesPerClassNode, iouThrNode, scoreThrNode, softNmsSigmaNode, boxEncoding, sortResDescend, outType); @@ -419,7 +416,7 @@ const std::vector encodType = {o ov::op::v9::NonMaxSuppression::BoxEncodingType::CORNER}; const std::vector sortResDesc = {true, false}; const std::vector outType = {ElementType::i32, ElementType::i64}; -const std::vector maxBoxInputTypes = {ngraph::helpers::InputLayerType::PARAMETER, ngraph::helpers::InputLayerType::CONSTANT}; +const std::vector maxBoxInputTypes = {ov::test::utils::InputLayerType::PARAMETER, ov::test::utils::InputLayerType::CONSTANT}; const auto nmsParams = ::testing::Combine(::testing::ValuesIn(inShapeParams), ::testing::Combine(::testing::Values(ElementType::f32), @@ -438,4 +435,5 @@ const auto nmsParams = ::testing::Combine(::testing::ValuesIn(inShapeParams), INSTANTIATE_TEST_SUITE_P(smoke_NmsLayerCPUTest, NmsLayerCPUTest, nmsParams, NmsLayerCPUTest::getTestCaseName); -} // namespace CPULayerTestsDefinitions +} // namespace test +} // namespace ov diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/nonzero.cpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/nonzero.cpp index ecce08dedb2690..6a52efb79f0917 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/nonzero.cpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/nonzero.cpp @@ -2,18 +2,14 @@ // SPDX-License-Identifier: Apache-2.0 // +#include "common_test_utils/ov_tensor_utils.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" #include "test_utils/cpu_test_utils.hpp" -#include "ov_models/builders.hpp" -#include "ov_models/utils/ov_helpers.hpp" -#include - -using namespace InferenceEngine; using namespace CPUTestUtils; -using namespace ov::test; -namespace CPULayerTestsDefinitions { +namespace ov { +namespace test { typedef std::tuple< InputShape, // Input shape definition @@ -87,7 +83,7 @@ class NonZeroLayerCPUTest : public testing::WithParamInterface(netType, shape)); } - auto nonZero = std::make_shared(inputParams[0]); + auto nonZero = std::make_shared(inputParams[0]); // I8 was used as a special placeholder during calculating of primitive type if input was U8, // real runtime precision is still U8 selectedType = makeSelectedTypeStr("ref", netType == ElementType::u8 ? ElementType::i8 : netType); @@ -199,7 +195,7 @@ std::vector inShapesDynamic = { } } }; -std::vector inShapesStatic = { +std::vector inShapesStatic = { { 100 }, { 4, 100 }, { 4, 2, 100 }, @@ -227,4 +223,5 @@ INSTANTIATE_TEST_SUITE_P(smoke_NonZeroDynamicCPUTest, NonZeroLayerCPUTest, } // namespace -} // namespace CPULayerTestsDefinitions +} // namespace test +} // namespace ov diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/normalize.cpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/normalize.cpp index b80b2175603f03..6593dd0c759370 100755 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/normalize.cpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/normalize.cpp @@ -4,26 +4,21 @@ #include "shared_test_classes/single_layer/normalize_l2.hpp" #include "test_utils/fusing_test_utils.hpp" -#include "ov_models/builders.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include +#include "common_test_utils/ov_tensor_utils.hpp" -using namespace ngraph; -using namespace InferenceEngine; using namespace CPUTestUtils; -using namespace LayerTestsDefinitions; -using namespace ov::test; -namespace CPULayerTestsDefinitions { +namespace ov { +namespace test { -using NormalizeL2LayerCPUTestParamSet = std::tuple< - InputShape, // input shape - ElementType, // input element type - std::vector, // axes - float, // eps - ngraph::op::EpsMode, // eps_mode - CPUSpecificParams, - fusingSpecificParams>; +using NormalizeL2LayerCPUTestParamSet = std::tuple, // axes + float, // eps + ov::op::EpsMode, // eps_mode + CPUSpecificParams, + fusingSpecificParams>; class NormalizeL2LayerCPUTest : public testing::WithParamInterface, virtual public SubgraphBaseTest, public CpuTestWithFusing { @@ -33,7 +28,7 @@ class NormalizeL2LayerCPUTest : public testing::WithParamInterface axes; float eps; - ngraph::op::EpsMode epsMode; + ov::op::EpsMode epsMode; CPUSpecificParams cpuParams; fusingSpecificParams fusingParams; std::tie(shapes, inType, axes, eps, epsMode, cpuParams, fusingParams) = obj.param; @@ -60,7 +55,7 @@ class NormalizeL2LayerCPUTest : public testing::WithParamInterface axes; float eps; - ngraph::op::EpsMode epsMode; + ov::op::EpsMode epsMode; CPUSpecificParams cpuParams; fusingSpecificParams fusingParams; std::tie(shapes, inType, axes, eps, epsMode, cpuParams, fusingParams) = this->GetParam(); @@ -88,7 +83,7 @@ class NormalizeL2LayerCPUTest : public testing::WithParamInterface& targetInputStaticShapes) override { + void generate_inputs(const std::vector& targetInputStaticShapes) override { inputs.clear(); const auto& funcInputs = function->inputs(); for (size_t i = 0; i < funcInputs.size(); ++i) { @@ -329,6 +324,7 @@ INSTANTIATE_TEST_SUITE_P(smoke_Dynamic_4D_FusingPerChannel, NormalizeL2LayerCPUT ::testing::ValuesIn(fusingParamsSetPerChannel)), NormalizeL2LayerCPUTest::getTestCaseName); -} // namespace +} // namespace -} // namespace CPULayerTestsDefinitions +} // namespace test +} // namespace ov diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/one_hot.cpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/one_hot.cpp index 60d9a417454782..25e4e7011be40e 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/one_hot.cpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/one_hot.cpp @@ -7,21 +7,20 @@ #include "test_utils/cpu_test_utils.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -using namespace InferenceEngine; using namespace CPUTestUtils; -using namespace ov::test; -namespace CPULayerTestsDefinitions { +namespace ov { +namespace test { -using oneHotCPUTestParams = std::tuple< - InputShape, // Input shape - int, // axis to extend - std::pair, // secondary input type && need to generate depth - size_t, // depth - float, // on_value - float, // off_value - InferenceEngine::Precision, // Output precision - CPUSpecificParams>; +using oneHotCPUTestParams = + std::tuple, // secondary input type && need to generate depth + size_t, // depth + float, // on_value + float, // off_value + ov::element::Type, // Output precision + CPUSpecificParams>; class OneHotLayerCPUTest : public testing::WithParamInterface, virtual public SubgraphBaseTest, public CPUTestsBase { @@ -29,10 +28,10 @@ class OneHotLayerCPUTest : public testing::WithParamInterface& obj) { InputShape inputShape; int axis; - std::pair inputType; + std::pair inputType; size_t depth; float onValue, offValue; - InferenceEngine::Precision outPrc; + ov::element::Type outPrc; CPUSpecificParams cpuParams; std::tie(inputShape, axis, inputType, depth, onValue, offValue, outPrc, cpuParams) = obj.param; @@ -45,20 +44,20 @@ class OneHotLayerCPUTest : public testing::WithParamInterfaceget_parameters().size() == 2) { generateDepth(); functionRefs = createFunction(true); @@ -125,22 +122,22 @@ class OneHotLayerCPUTest : public testing::WithParamInterface createFunction(bool depthConst) { - ov::ParameterVector params{std::make_shared(ngraph::element::i32, inputDynamicShapes.front())}; + std::shared_ptr createFunction(bool depthConst) { + ov::ParameterVector params{std::make_shared(ov::element::i32, inputDynamicShapes.front())}; params.front()->set_friendly_name("ParamsIndices"); std::shared_ptr depth; if (depthConst) { - depth = ngraph::op::Constant::create(ngraph::element::i32, ngraph::Shape{ }, {Depth}); + depth = ov::op::v0::Constant::create(ov::element::i32, ov::Shape{ }, {Depth}); } else { - auto depthParam = std::make_shared(ngraph::element::i32, ngraph::Shape{ }); + auto depthParam = std::make_shared(ov::element::i32, ov::Shape{ }); depthParam->set_friendly_name("ParamDepth"); params.push_back(depthParam); depth = depthParam; } - auto on_value_const = std::make_shared(outType, ngraph::Shape{ }, OnValue); - auto off_value_const = std::make_shared(outType, ngraph::Shape{ }, OffValue); - auto oneHot = std::make_shared(params[0], depth, on_value_const, off_value_const, Axis); - return makeNgraphFunction(ngraph::element::i32, params, oneHot, "OneHot"); + auto on_value_const = std::make_shared(outType, ov::Shape{ }, OnValue); + auto off_value_const = std::make_shared(outType, ov::Shape{ }, OffValue); + auto oneHot = std::make_shared(params[0], depth, on_value_const, off_value_const, Axis); + return makeNgraphFunction(ov::element::i32, params, oneHot, "OneHot"); } void generateDepth() { testing::internal::Random random(time(nullptr)); @@ -159,21 +156,21 @@ TEST_P(OneHotLayerCPUTest, CompareWithRefs) { } namespace { -const std::vector outPrc = { - Precision::FP32, - Precision::BF16, - Precision::I8 - // Precision::U8 // Precision cannot be wrapped to constant one hot +const std::vector outPrc = { + ov::element::f32, + ov::element::bf16, + ov::element::i8 + // ov::element::u8 // Precision cannot be wrapped to constant one hot }; -std::vector> secondaryInputTypesStaticCase = { - {ngraph::helpers::InputLayerType::CONSTANT, true}, - {ngraph::helpers::InputLayerType::CONSTANT, false} +std::vector> secondaryInputTypesStaticCase = { + {utils::InputLayerType::CONSTANT, true}, + {utils::InputLayerType::CONSTANT, false} }; -std::vector> secondaryInputTypesDynamicCase = { - {ngraph::helpers::InputLayerType::CONSTANT, true}, - {ngraph::helpers::InputLayerType::CONSTANT, false}, - {ngraph::helpers::InputLayerType::PARAMETER, true} +std::vector> secondaryInputTypesDynamicCase = { + {utils::InputLayerType::CONSTANT, true}, + {utils::InputLayerType::CONSTANT, false}, + {utils::InputLayerType::PARAMETER, true} }; const std::vector staticInputShapes0D = { @@ -328,5 +325,6 @@ const auto testCase_5d_dynamic = ::testing::Combine( ); INSTANTIATE_TEST_SUITE_P(smoke_OneHotCPU_5D_Dynamic, OneHotLayerCPUTest, testCase_5d_dynamic, OneHotLayerCPUTest::getTestCaseName); -} // namespace -} // namespace CPULayerTestsDefinitions +} // namespace +} // namespace test +} // namespace ov diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/pad.cpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/pad.cpp index 227933e2a3fe2d..a6c06628262a64 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/pad.cpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/pad.cpp @@ -2,21 +2,21 @@ // SPDX-License-Identifier: Apache-2.0 // -#include -#include "test_utils/cpu_test_utils.hpp" +#include "shared_test_classes/single_layer/pad.hpp" + +#include "common_test_utils/ov_tensor_utils.hpp" +#include "openvino/op/pad.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include -#include +#include "test_utils/cpu_test_utils.hpp" -using namespace InferenceEngine; using namespace CPUTestUtils; -using namespace ov::test; -namespace CPULayerTestsDefinitions { +namespace ov { +namespace test { using PadLayerCPUTestParamSet = std::tuple< InputShape, // Input shape - ngraph::helpers::InputLayerType, // Secondary input types + ov::test::utils::InputLayerType, // Secondary input types ElementType, // Input element type std::vector, // padsBegin std::vector, // padsEnd @@ -30,7 +30,7 @@ class PadLayerCPUTest : public testing::WithParamInterface obj) { InputShape shapes; - ngraph::helpers::InputLayerType secondaryInputType; + ov::test::utils::InputLayerType secondaryInputType; ElementType elementType; std::vector padsBegin, padsEnd; ov::op::PadMode padMode; @@ -79,7 +79,7 @@ class PadLayerCPUTest : public testing::WithParamInterface(dataType, shape)); } std::shared_ptr pad; - if (secondaryInputType == ngraph::helpers::InputLayerType::PARAMETER) { + if (secondaryInputType == ov::test::utils::InputLayerType::PARAMETER) { ov::Shape inShape = {padsBegin.size()}; auto beginNode = std::make_shared(ElementType::i64, inShape); @@ -155,13 +155,13 @@ const std::vector inputPrecisions = { ElementType::i8 }; -const std::vector inputLayerTypes = { - ngraph::helpers::InputLayerType::CONSTANT, - ngraph::helpers::InputLayerType::PARAMETER +const std::vector inputLayerTypes = { + ov::test::utils::InputLayerType::CONSTANT, + ov::test::utils::InputLayerType::PARAMETER }; -const std::vector inputLayerTypesBlocked = { - ngraph::helpers::InputLayerType::CONSTANT, +const std::vector inputLayerTypesBlocked = { + ov::test::utils::InputLayerType::CONSTANT, }; const std::vector argPadValue = {0.f, 2.5f}; @@ -747,5 +747,6 @@ INSTANTIATE_TEST_SUITE_P( /* *======================* *=====================* *======================* */ } // namespace -} // namespace CPULayerTestsDefinitions +} // namespace test +} // namespace ov diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/prior_box.cpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/prior_box.cpp index 13142ae4f395f1..76cc3498f8389d 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/prior_box.cpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/prior_box.cpp @@ -2,21 +2,16 @@ // SPDX-License-Identifier: Apache-2.0 // -#include -#include -#include - -#include +#include "openvino/core/partial_shape.hpp" #include "ov_models/builders.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" -using namespace InferenceEngine; using namespace CPUTestUtils; -using namespace ov::test; -namespace CPULayerTestsDefinitions { +namespace ov { +namespace test { using priorBoxSpecificParams = std::tuple< std::vector, // min_size @@ -32,16 +27,14 @@ using priorBoxSpecificParams = std::tuple< std::vector, // variance bool>; // scale_all_sizes -typedef std::tuple< - priorBoxSpecificParams, - ov::test::ElementType, // net precision - ov::test::ElementType, // Input precision - ov::test::ElementType, // Output precision - InferenceEngine::Layout, // Input layout - InferenceEngine::Layout, // Output layout - ov::test::InputShape, // input shape - ov::test::InputShape, // image shape - std::string> priorBoxLayerParams; +typedef std::tuple + priorBoxLayerParams; class PriorBoxLayerCPUTest : public testing::WithParamInterface, virtual public SubgraphBaseTest, public CPUTestsBase { @@ -49,19 +42,18 @@ class PriorBoxLayerCPUTest : public testing::WithParamInterface& obj) { ov::test::ElementType netPrecision; ov::test::ElementType inPrc, outPrc; - InferenceEngine::Layout inLayout, outLayout; ov::test::InputShape inputShapes; ov::test::InputShape imageShapes; std::string targetDevice; priorBoxSpecificParams specParams; std::tie(specParams, netPrecision, - inPrc, outPrc, inLayout, outLayout, + inPrc, outPrc, inputShapes, imageShapes, targetDevice) = obj.param; - ngraph::op::PriorBoxAttrs attributes; + ov::op::v0::PriorBox::Attributes attributes; std::tie( attributes.min_size, attributes.max_size, @@ -83,8 +75,6 @@ class PriorBoxLayerCPUTest : public testing::WithParamInterface(netPrecision, shape)); } - auto shape_of_1 = std::make_shared(params[0]); - auto shape_of_2 = std::make_shared(params[1]); - auto priorBox = std::make_shared( + 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); - ngraph::ResultVector results{std::make_shared(priorBox)}; - function = std::make_shared (results, params, "priorBox"); + ov::ResultVector results{std::make_shared(priorBox)}; + function = std::make_shared (results, params, "priorBox"); } }; @@ -219,12 +205,11 @@ INSTANTIATE_TEST_SUITE_P(smoke_PriorBox, PriorBoxLayerCPUTest, ::testing::ValuesIn(netPrecisions), ::testing::Values(ov::test::ElementType::undefined), ::testing::Values(ov::test::ElementType::undefined), - ::testing::Values(InferenceEngine::Layout::ANY), - ::testing::Values(InferenceEngine::Layout::ANY), ::testing::ValuesIn(inputShape), ::testing::ValuesIn(imageShape), ::testing::Values(ov::test::utils::DEVICE_CPU)), PriorBoxLayerCPUTest::getTestCaseName); } // namespace -} // namespace CPULayerTestsDefinitions +} // namespace test +} // namespace ov diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/prior_box_clustered.cpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/prior_box_clustered.cpp index 06fe498f62b551..5aa4df776dd752 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/prior_box_clustered.cpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/prior_box_clustered.cpp @@ -2,21 +2,15 @@ // SPDX-License-Identifier: Apache-2.0 // -#include -#include -#include - -#include -#include "ov_models/builders.hpp" +#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" -using namespace InferenceEngine; using namespace CPUTestUtils; -using namespace ov::test; -namespace CPULayerTestsDefinitions { +namespace ov { +namespace test { typedef std::tuple< std::vector, // widths @@ -28,16 +22,14 @@ typedef std::tuple< float, // offset std::vector> priorBoxClusteredSpecificParams; -typedef std::tuple< - priorBoxClusteredSpecificParams, - ov::test::ElementType, // net precision - ov::test::ElementType, // Input precision - ov::test::ElementType, // Output precision - InferenceEngine::Layout, // Input layout - InferenceEngine::Layout, // Output layout - ov::test::InputShape, // input shape - ov::test::InputShape, // image shape - std::string> priorBoxClusteredLayerParams; +typedef std::tuple + priorBoxClusteredLayerParams; class PriorBoxClusteredLayerCPUTest : public testing::WithParamInterface, virtual public SubgraphBaseTest, public CPUTestsBase { @@ -45,18 +37,12 @@ class PriorBoxClusteredLayerCPUTest : public testing::WithParamInterface& obj) { ov::test::ElementType netPrecision; ov::test::ElementType inPrc, outPrc; - InferenceEngine::Layout inLayout, outLayout; ov::test::InputShape inputShapes, imageShapes; std::string targetDevice; priorBoxClusteredSpecificParams specParams; - std::tie(specParams, - netPrecision, - inPrc, outPrc, inLayout, outLayout, - inputShapes, - imageShapes, - targetDevice) = obj.param; - - ngraph::op::PriorBoxClusteredAttrs attributes; + std::tie(specParams, netPrecision, inPrc, outPrc, inputShapes, imageShapes, targetDevice) = obj.param; + + ov::op::v0::PriorBoxClustered::Attributes attributes; std::tie( attributes.widths, attributes.heights, @@ -75,8 +61,6 @@ class PriorBoxClusteredLayerCPUTest : public testing::WithParamInterface(netPrecision, shape)); } - auto shape_of_1 = std::make_shared(params[0]); - auto shape_of_2 = std::make_shared(params[1]); - auto priorBoxClustered = std::make_shared( + 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); - ngraph::ResultVector results{ std::make_shared(priorBoxClustered) }; - function = std::make_shared(results, params, "priorBoxClustered"); + ov::ResultVector results{ std::make_shared(priorBoxClustered) }; + function = std::make_shared(results, params, "priorBoxClustered"); } }; @@ -217,8 +196,6 @@ INSTANTIATE_TEST_SUITE_P(smoke_PriorBoxClustered, PriorBoxClusteredLayerCPUTest, ::testing::ValuesIn(netPrecisions), ::testing::Values(ov::test::ElementType::undefined), ::testing::Values(ov::test::ElementType::undefined), - ::testing::Values(InferenceEngine::Layout::ANY), - ::testing::Values(InferenceEngine::Layout::ANY), ::testing::ValuesIn(inputShapes), ::testing::ValuesIn(imageShapes), ::testing::Values(ov::test::utils::DEVICE_CPU)), @@ -226,4 +203,5 @@ INSTANTIATE_TEST_SUITE_P(smoke_PriorBoxClustered, PriorBoxClusteredLayerCPUTest, ); } // namespace -} // namespace CPULayerTestsDefinitions +} // namespace test +} // namespace ov diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/proposal.cpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/proposal.cpp index 03240dcfdebafb..2e08c459cf0039 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/proposal.cpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/proposal.cpp @@ -2,17 +2,14 @@ // SPDX-License-Identifier: Apache-2.0 // -#include +#include "common_test_utils/ov_tensor_utils.hpp" #include "test_utils/cpu_test_utils.hpp" -#include "ov_models/builders.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -using namespace ngraph; -using namespace InferenceEngine; using namespace CPUTestUtils; -using namespace ov::test; -namespace CPULayerTestsDefinitions { +namespace ov { +namespace test { namespace proposalTypes { @@ -51,10 +48,9 @@ using proposalSpecificParams = std::tuple< ratio_type, scale_type>; -using proposalLayerTestCPUParams = std::tuple< - std::vector, // Input shapes - proposalSpecificParams, // Node attributes - Precision>; // Network precision +using proposalLayerTestCPUParams = std::tuple, // Input shapes + proposalSpecificParams, // Node attributes + ov::element::Type>; // Network precision class ProposalLayerCPUTest : public testing::WithParamInterface, public SubgraphBaseTest, public CPUTestsBase { @@ -62,7 +58,7 @@ class ProposalLayerCPUTest : public testing::WithParamInterface obj) { std::vector inputShapes; proposalSpecificParams proposalParams; - Precision netPrecision; + ov::element::Type netPrecision; std::tie(inputShapes, proposalParams, netPrecision) = obj.param; base_size_type base_size; @@ -103,7 +99,7 @@ class ProposalLayerCPUTest : public testing::WithParamInterface(ngPrc, shape)); + params.push_back(std::make_shared(netPrecision, shape)); } - ngraph::op::ProposalAttrs attrs; + ov::op::v0::Proposal::Attributes attrs; attrs.base_size = base_size; attrs.pre_nms_topn = pre_nms_topn; attrs.post_nms_topn = post_nms_topn; @@ -161,14 +156,14 @@ class ProposalLayerCPUTest : public testing::WithParamInterface(params[0], params[1], params[2], attrs); + auto proposal = std::make_shared(params[0], params[1], params[2], attrs); - ngraph::ResultVector results{ - std::make_shared(proposal->output(0)), - std::make_shared(proposal->output(1)) + ov::ResultVector results{ + std::make_shared(proposal->output(0)), + std::make_shared(proposal->output(1)) }; - function = std::make_shared(results, params, "Proposal"); + function = std::make_shared(results, params, "Proposal"); } void generate_inputs(const std::vector& targetInputStaticShapes) override { inputs.clear(); @@ -199,8 +194,8 @@ TEST_P(ProposalLayerCPUTest, CompareWithRefs) { namespace { -const std::vector netPrecision = { - Precision::FP32 +const std::vector netPrecision = { + ov::element::f32 }; std::vector> staticInputShapesCase1 = { @@ -338,4 +333,5 @@ INSTANTIATE_TEST_SUITE_P(smoke_Proposal_Dynamic_Test_Case2, ProposalLayerCPUTest ProposalLayerCPUTest::getTestCaseName); } // namespace -} // namespace CPULayerTestsDefinitions +} // namespace test +} // namespace ov diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/rdft.cpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/rdft.cpp index b80dfc66cf691c..18471afff43294 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/rdft.cpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/rdft.cpp @@ -3,32 +3,29 @@ // #include "shared_test_classes/base/ov_subgraph.hpp" -#include "ov_models/builders.hpp" #include "test_utils/cpu_test_utils.hpp" -#include -#include +#include "common_test_utils/ov_tensor_utils.hpp" using namespace CPUTestUtils; -using namespace ov::test; -using namespace ov; -namespace CPULayerTestsDefinitions { +namespace ov { +namespace test { -std::vector precisions{element::f32}; +std::vector precisions{ov::element::f32}; using RDFTTestCPUParams = std::tuple, std::vector>, // axes std::vector>, // signal sizes - bool, // inverse - bool, // const axes if true - bool, // const signal sizes if true + bool, // inverse + bool, // const axes if true + bool, // const signal sizes if true CPUSpecificParams>; -class RDFTTestCPU : public testing::WithParamInterface>, +class RDFTTestCPU : public testing::WithParamInterface>, virtual public test::SubgraphBaseTest, public CPUTestsBase { public: - static std::string getTestCaseName(testing::TestParamInfo> obj) { - element::Type precision; + static std::string getTestCaseName(testing::TestParamInfo> obj) { + ov::element::Type precision; RDFTTestCPUParams params; std::vector shapes; std::vector> axes; @@ -76,7 +73,7 @@ class RDFTTestCPU : public testing::WithParamInterface shapes; bool inverse; @@ -113,14 +110,14 @@ class RDFTTestCPU : public testing::WithParamInterface(precision, *inputShapeIt++); + auto param = std::make_shared(precision, *inputShapeIt++); inputs.push_back(param); std::shared_ptr axesNode; if (constAxes) { - axesNode = opset9::Constant::create(element::i64, Shape{axes[0].size()}, axes[0]); + axesNode = ov::op::v0::Constant::create(element::i64, Shape{axes[0].size()}, axes[0]); } else { ASSERT_NE(inputShapeIt, inputDynamicShapes.end()); - auto param = std::make_shared(element::i64, *inputShapeIt++); + auto param = std::make_shared(element::i64, *inputShapeIt++); axesNode = param; inputs.push_back(param); } @@ -129,23 +126,23 @@ class RDFTTestCPU : public testing::WithParamInterface 0) { std::shared_ptr signalSizesNode; if (constSignalSizes) { - signalSizesNode = opset9::Constant::create(element::i64, Shape{signalSizes[0].size()}, signalSizes[0]); + signalSizesNode = ov::op::v0::Constant::create(element::i64, Shape{signalSizes[0].size()}, signalSizes[0]); } else { ASSERT_NE(inputShapeIt, inputDynamicShapes.end()); - auto param = std::make_shared(element::i64, *inputShapeIt); + auto param = std::make_shared(element::i64, *inputShapeIt); signalSizesNode = param; inputs.push_back(param); } if (inverse) { - rdft = std::make_shared(param, axesNode, signalSizesNode); + rdft = std::make_shared(param, axesNode, signalSizesNode); } else { - rdft = std::make_shared(param, axesNode, signalSizesNode); + rdft = std::make_shared(param, axesNode, signalSizesNode); } } else { if (inverse) { - rdft = std::make_shared(param, axesNode); + rdft = std::make_shared(param, axesNode); } else { - rdft = std::make_shared(param, axesNode); + rdft = std::make_shared(param, axesNode); } } function = std::make_shared(rdft, inputs); @@ -191,11 +188,11 @@ TEST_P(RDFTTestCPU, CompareWithRefs) { namespace { CPUSpecificParams getCPUSpecificParams() { - if (InferenceEngine::with_cpu_x86_avx512_core()) { + if (ov::with_cpu_x86_avx512_core()) { return CPUSpecificParams{{}, {}, {"jit_avx512"}, "jit_avx512"}; - } else if (InferenceEngine::with_cpu_x86_avx2()) { + } else if (ov::with_cpu_x86_avx2()) { return CPUSpecificParams{{}, {}, {"jit_avx2"}, "jit_avx2"}; - } else if (InferenceEngine::with_cpu_x86_sse42()) { + } else if (ov::with_cpu_x86_sse42()) { return CPUSpecificParams{{}, {}, {"jit_sse42"}, "jit_sse42"}; } else { return CPUSpecificParams{{}, {}, {"ref"}, "ref"}; @@ -206,7 +203,7 @@ CPUSpecificParams getCPUSpecificParams() { auto cpuParams = getCPUSpecificParams(); std::vector getParams1D() { - if (InferenceEngine::with_cpu_x86_avx512_core()) { + if (ov::with_cpu_x86_avx512_core()) { return { {static_shapes_to_test_representation({Shape{14}}), {{0}}, {}, false, true, true, cpuParams}, {static_shapes_to_test_representation({Shape{13}}), {{0}}, {}, false, true, true, cpuParams}, @@ -243,7 +240,7 @@ std::vector getParams1D() { {static_shapes_to_test_representation({Shape{25, 2}}), {{0}}, {{32}}, true, true, true, cpuParams}, {static_shapes_to_test_representation({Shape{24, 2}}), {{0}}, {{16}}, true, true, true, cpuParams}, }; - } else if (InferenceEngine::with_cpu_x86_avx2()) { + } else if (ov::with_cpu_x86_avx2()) { return { {static_shapes_to_test_representation({Shape{6}}), {{0}}, {}, false, true, true, cpuParams}, {static_shapes_to_test_representation({Shape{5}}), {{0}}, {}, false, true, true, cpuParams}, @@ -312,13 +309,13 @@ std::vector getParams1D() { return {}; } -INSTANTIATE_TEST_SUITE_P(smoke_RDFT_CPU_1D, RDFTTestCPU, - ::testing::Combine(::testing::ValuesIn(precisions), - ::testing::ValuesIn(getParams1D())), +INSTANTIATE_TEST_SUITE_P(smoke_RDFT_CPU_1D, + RDFTTestCPU, + ::testing::Combine(::testing::ValuesIn(precisions), ::testing::ValuesIn(getParams1D())), RDFTTestCPU::getTestCaseName); std::vector getParams2D() { - if (InferenceEngine::with_cpu_x86_avx512_core()) { + if (ov::with_cpu_x86_avx512_core()) { return { {static_shapes_to_test_representation({{46, 10}}), {{0}}, {}, false, true, true, cpuParams}, {static_shapes_to_test_representation({{45, 10}}), {{0}}, {}, false, true, true, cpuParams}, @@ -360,7 +357,7 @@ std::vector getParams2D() { {static_shapes_to_test_representation({{32, 513, 2}}), {{0, 1}}, {{32, 600}}, true, true, true, cpuParams}, {static_shapes_to_test_representation({{72, 1025, 2}}), {{0, 1}}, {{72, 100}}, true, true, true, cpuParams}, }; - } else if (InferenceEngine::with_cpu_x86_avx2()) { + } else if (ov::with_cpu_x86_avx2()) { return { {static_shapes_to_test_representation({{38, 16}}), {{0}}, {}, false, true, true, cpuParams}, {static_shapes_to_test_representation({{37, 8}}), {{0}}, {}, false, true, true, cpuParams}, @@ -460,14 +457,14 @@ std::vector getParams2D() { return {}; } -INSTANTIATE_TEST_SUITE_P(smoke_RDFT_CPU_2D, RDFTTestCPU, - ::testing::Combine(::testing::ValuesIn(precisions), - ::testing::ValuesIn(getParams2D())), +INSTANTIATE_TEST_SUITE_P(smoke_RDFT_CPU_2D, + RDFTTestCPU, + ::testing::Combine(::testing::ValuesIn(precisions), ::testing::ValuesIn(getParams2D())), RDFTTestCPU::getTestCaseName); std::vector getParams4D() { std::vector params; - if (InferenceEngine::with_cpu_x86_avx512_core()) { + if (ov::with_cpu_x86_avx512_core()) { params = { {static_shapes_to_test_representation({{10, 46, 128, 65}}), {{1}}, {}, false, true, true, cpuParams}, {static_shapes_to_test_representation({{10, 46, 128, 65}}), {{0, 1}}, {}, false, true, true, cpuParams}, @@ -488,7 +485,7 @@ std::vector getParams4D() { // TODO: FIXME //{static_shapes_to_test_representation({{46, 10, 128, 65, 2}}), {{0, 1, 2, 3}, {12, 15, 130, 40}, true, true, true, cpuParams}, }; - } else if (InferenceEngine::with_cpu_x86_avx2()) { + } else if (ov::with_cpu_x86_avx2()) { params = { {static_shapes_to_test_representation({{9, 16, 32, 126}}), {{1}}, {}, false, true, true, cpuParams}, {static_shapes_to_test_representation({{9, 16, 32, 126}}), {{1, 0}}, {}, false, true, true, cpuParams}, @@ -593,10 +590,11 @@ std::vector getParams4D() { return params; } -INSTANTIATE_TEST_SUITE_P(smoke_RDFT_CPU_4D, RDFTTestCPU, - ::testing::Combine(::testing::ValuesIn(precisions), - ::testing::ValuesIn(getParams4D())), +INSTANTIATE_TEST_SUITE_P(smoke_RDFT_CPU_4D, + RDFTTestCPU, + ::testing::Combine(::testing::ValuesIn(precisions), ::testing::ValuesIn(getParams4D())), RDFTTestCPU::getTestCaseName); -} // namespace -} // namespace CPULayerTestsDefinitions +} // namespace +} // namespace test +} // namespace ov diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/region_yolo.cpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/region_yolo.cpp index 2dc172b24f0d7d..9fb1b65ab95392 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/region_yolo.cpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/region_yolo.cpp @@ -2,15 +2,13 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "ov_models/builders.hpp" #include "test_utils/cpu_test_utils.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -using namespace InferenceEngine; using namespace CPUTestUtils; -namespace CPULayerTestsDefinitions { -using namespace ov::test; +namespace ov { +namespace test { struct regionYoloAttributes { size_t classes; @@ -21,15 +19,13 @@ struct regionYoloAttributes { int end_axis; }; -using regionYoloParamsTuple = std::tuple< - InputShape, // Input Shape - regionYoloAttributes, // Params - std::vector, // mask - ov::test::ElementType, // Network input precision - ov::test::ElementType, // Network output precision - std::map, // Additional network configuration - std::string>; // Device name - +using regionYoloParamsTuple = std::tuple, // mask + ov::test::ElementType, // Network input precision + ov::test::ElementType, // Network output precision + ov::AnyMap, // Additional network configuration + std::string>; // Device name class RegionYoloCPULayerTest : public testing::WithParamInterface, virtual public ov::test::SubgraphBaseTest, public CPUTestsBase { @@ -41,7 +37,7 @@ class RegionYoloCPULayerTest : public testing::WithParamInterface additionalConfig; + ov::AnyMap additionalConfig; std::tie(inputShape, attributes, mask, inpPrecision, outPrecision, additionalConfig, targetName) = obj.param; @@ -65,7 +61,7 @@ class RegionYoloCPULayerTest : public testing::WithParamInterface mask; ov::test::ElementType inPrc; ov::test::ElementType outPrc; - std::map additionalConfig; + ov::AnyMap additionalConfig; std::tie(inputShape, attributes, mask, inPrc, outPrc, additionalConfig, targetDevice) = this->GetParam(); @@ -78,14 +74,19 @@ class RegionYoloCPULayerTest : public testing::WithParamInterface(inPrc, shape)); } - const auto region_yolo = std::make_shared(paramRegionYolo[0], - attributes.coordinates, attributes.classes, attributes.num_regions, - attributes.do_softmax, mask, attributes.start_axis, attributes.end_axis); + const auto region_yolo = std::make_shared(paramRegionYolo[0], + attributes.coordinates, + attributes.classes, + attributes.num_regions, + attributes.do_softmax, + mask, + attributes.start_axis, + attributes.end_axis); function = makeNgraphFunction(inPrc, paramRegionYolo, region_yolo, "RegionYolo"); } @@ -99,15 +100,15 @@ TEST_P(RegionYoloCPULayerTest, CompareWithRefs) { namespace { const std::vector inpOutPrc = {ov::test::ElementType::bf16, ov::test::ElementType::f32}; -const std::map additional_config; +const ov::AnyMap additional_config; /* *======================* Static Shapes *======================* */ -const std::vector inShapes_caffe = { +const std::vector inShapes_caffe = { {1, 125, 13, 13} }; -const std::vector inShapes_mxnet = { +const std::vector inShapes_mxnet = { {1, 75, 52, 52}, {1, 75, 32, 32}, {1, 75, 26, 26}, @@ -119,7 +120,7 @@ const std::vector inShapes_mxnet = { {1, 303, 28, 28}, }; -const std::vector inShapes_v3 = { +const std::vector inShapes_v3 = { {1, 255, 52, 52}, {1, 255, 26, 26}, {1, 255, 13, 13} @@ -225,5 +226,6 @@ INSTANTIATE_TEST_SUITE_P(smoke_TestsRegionYoloMxnetCPUStatic, RegionYoloCPULayer INSTANTIATE_TEST_SUITE_P(smoke_TestsRegionYoloMxnetCPUDynamic, RegionYoloCPULayerTest, testCase_yolov3_mxnet_dynamic, RegionYoloCPULayerTest::getTestCaseName); INSTANTIATE_TEST_SUITE_P(smoke_TestsRegionYoloCaffeCPUStatic, RegionYoloCPULayerTest, testCase_yolov2_caffe, RegionYoloCPULayerTest::getTestCaseName); INSTANTIATE_TEST_SUITE_P(smoke_TestsRegionYoloCaffeCPUDynamic, RegionYoloCPULayerTest, testCase_yolov2_caffe_dynamic, RegionYoloCPULayerTest::getTestCaseName); -} // namespace -} // namespace CPULayerTestsDefinitions +} // namespace +} // namespace test +} // namespace ov diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/reorg_yolo.cpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/reorg_yolo.cpp index ae6d5e5b7e85ab..91d97d9e679b40 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/reorg_yolo.cpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/reorg_yolo.cpp @@ -2,17 +2,14 @@ // SPDX-License-Identifier: Apache-2.0 // -#include -#include "ov_models/builders.hpp" +#include "common_test_utils/ov_tensor_utils.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" #include "test_utils/cpu_test_utils.hpp" -using namespace InferenceEngine; using namespace CPUTestUtils; -using namespace ngraph::opset3; -using namespace ov::test; -namespace CPULayerTestsDefinitions { +namespace ov { +namespace test { using ReorgYoloCPUParamsTuple = typename std::tuple(ngraph::element::f32, inputDynamicShapes[0]); - auto reorg_yolo = std::make_shared(param, stride); - function = std::make_shared(std::make_shared(reorg_yolo), - ngraph::ParameterVector{param}, - "ReorgYolo"); + auto param = std::make_shared(ov::element::f32, inputDynamicShapes[0]); + auto reorg_yolo = std::make_shared(param, stride); + function = std::make_shared(std::make_shared(reorg_yolo), + ov::ParameterVector{param}, + "ReorgYolo"); } }; @@ -87,4 +84,5 @@ INSTANTIATE_TEST_SUITE_P(smoke_TestsReorgYolo_stride3_DynamicShape, testCase_stride3_Dynamic, ReorgYoloLayerCPUTest::getTestCaseName); -}; // namespace CPULayerTestsDefinitions +} // namespace test +} // namespace ov diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/reverse_sequence.cpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/reverse_sequence.cpp index d78a8780f774cf..b23d0fba525839 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/reverse_sequence.cpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/reverse_sequence.cpp @@ -2,24 +2,24 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "shared_test_classes/base/ov_subgraph.hpp" +#include "common_test_utils/ov_tensor_utils.hpp" #include "ov_models/builders.hpp" +#include "shared_test_classes/base/ov_subgraph.hpp" #include "test_utils/cpu_test_utils.hpp" -#include "common_test_utils/ov_tensor_utils.hpp" using namespace CPUTestUtils; -using namespace ov::test; -namespace CPULayerTestsDefinitions { +namespace ov { +namespace test { -using ReverseSequenceCPUTestParams = typename std::tuple< - int64_t, // Index of the batch dimension - int64_t, // Index of the sequence dimension - InputShape, // Input shape - InputShape, // 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 +using ReverseSequenceCPUTestParams = + typename std::tuple; // Device name class ReverseSequenceLayerCPUTest : public testing::WithParamInterface, virtual public SubgraphBaseTest, public CPUTestsBase { @@ -27,11 +27,11 @@ class ReverseSequenceLayerCPUTest : public testing::WithParamInterface obj) { int64_t batchAxisIndex; int64_t seqAxisIndex; - InferenceEngine::Precision netPrecision; + ov::element::Type netPrecision; std::string targetName; InputShape dataInputShape; InputShape seqLengthsShape; - ngraph::helpers::InputLayerType secondaryInputType; + utils::InputLayerType secondaryInputType; std::tie(batchAxisIndex, seqAxisIndex, dataInputShape, seqLengthsShape, secondaryInputType, netPrecision, targetName) = obj.param; @@ -49,7 +49,7 @@ class ReverseSequenceLayerCPUTest : public testing::WithParamInterface(paramsIn.front(), seqLengthsInput, batchAxisIndex, seqAxisIndex); + const ov::ResultVector results{std::make_shared(reverse)}; + function = std::make_shared(results, paramsIn, "ReverseSequence"); } void generate_inputs(const std::vector& targetInputStaticShapes) override { @@ -118,9 +117,9 @@ TEST_P(ReverseSequenceLayerCPUTest, CompareWithRefs) { namespace { -const std::vector netPrecisions = { - InferenceEngine::Precision::FP32, - InferenceEngine::Precision::I32 +const std::vector netPrecisions = { + ov::element::f32, + ov::element::i32 }; const int64_t batchAxisIndex = 0L; @@ -147,9 +146,9 @@ const std::vector dataInputDynamicShapes5D = const std::vector seqLengthsDynamicShapes = {{{-1}, {{7}, {10}}}}; -const std::vector secondaryInputTypes = { - ngraph::helpers::InputLayerType::CONSTANT, - ngraph::helpers::InputLayerType::PARAMETER +const std::vector secondaryInputTypes = { + utils::InputLayerType::CONSTANT, + utils::InputLayerType::PARAMETER }; INSTANTIATE_TEST_SUITE_P(smoke_ReverseSequenceCPUStatic3D, ReverseSequenceLayerCPUTest, @@ -191,7 +190,7 @@ INSTANTIATE_TEST_SUITE_P(smoke_ReverseSequenceCPUDynamic3D, ReverseSequenceLayer ::testing::ValuesIn(seqAxisIndices), ::testing::ValuesIn(dataInputDynamicShapes3D), ::testing::ValuesIn(seqLengthsDynamicShapes), - ::testing::Values(ngraph::helpers::InputLayerType::PARAMETER), + ::testing::Values(utils::InputLayerType::PARAMETER), ::testing::ValuesIn(netPrecisions), ::testing::Values(ov::test::utils::DEVICE_CPU)), ReverseSequenceLayerCPUTest::getTestCaseName); @@ -202,7 +201,7 @@ INSTANTIATE_TEST_SUITE_P(smoke_ReverseSequenceCPUDynamic4D, ReverseSequenceLayer ::testing::ValuesIn(seqAxisIndices), ::testing::ValuesIn(dataInputDynamicShapes4D), ::testing::ValuesIn(seqLengthsDynamicShapes), - ::testing::Values(ngraph::helpers::InputLayerType::PARAMETER), + ::testing::Values(utils::InputLayerType::PARAMETER), ::testing::ValuesIn(netPrecisions), ::testing::Values(ov::test::utils::DEVICE_CPU)), ReverseSequenceLayerCPUTest::getTestCaseName); @@ -213,10 +212,11 @@ INSTANTIATE_TEST_SUITE_P(smoke_ReverseSequenceCPUDynamic5D, ReverseSequenceLayer ::testing::ValuesIn(seqAxisIndices), ::testing::ValuesIn(dataInputDynamicShapes5D), ::testing::ValuesIn(seqLengthsDynamicShapes), - ::testing::Values(ngraph::helpers::InputLayerType::PARAMETER), + ::testing::Values(utils::InputLayerType::PARAMETER), ::testing::ValuesIn(netPrecisions), ::testing::Values(ov::test::utils::DEVICE_CPU)), ReverseSequenceLayerCPUTest::getTestCaseName); -} // namespace -} // namespace CPULayerTestsDefinitions +} // namespace +} // namespace test +} // namespace ov diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/rnn_cell.cpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/rnn_cell.cpp index af94855c414e1d..e8d9bb2359417e 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/rnn_cell.cpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/rnn_cell.cpp @@ -2,23 +2,22 @@ // SPDX-License-Identifier: Apache-2.0 // +#include "common_test_utils/node_builders/rnn_cell.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include "ov_models/builders.hpp" #include "test_utils/cpu_test_utils.hpp" using namespace CPUTestUtils; -using namespace ov::test; -namespace CPULayerTestsDefinitions { +namespace ov { +namespace test { -using RNNCellCPUParams = typename std::tuple< - std::vector, // Shapes - std::vector, // Activations - float, // Clip - ElementType, // Network precision - CPUSpecificParams, // CPU specific params - std::map // Additional config ->; +using RNNCellCPUParams = typename std::tuple, // Shapes + std::vector, // Activations + float, // Clip + ElementType, // Network precision + CPUSpecificParams, // CPU specific params + ov::AnyMap // Additional config + >; class RNNCellCPUTest : public testing::WithParamInterface, virtual public ov::test::SubgraphBaseTest, public CPUTestsBase { @@ -29,7 +28,7 @@ class RNNCellCPUTest : public testing::WithParamInterface, float clip = 0.f; ElementType netPrecision; CPUSpecificParams cpuParams; - std::map additionalConfig; + ov::AnyMap additionalConfig; std::tie(inputShapes, activations, clip, netPrecision, cpuParams, additionalConfig) = obj.param; @@ -53,9 +52,8 @@ class RNNCellCPUTest : public testing::WithParamInterface, if (!additionalConfig.empty()) { result << "_PluginConf"; - for (auto &item : additionalConfig) { - if (item.second == InferenceEngine::PluginConfigParams::YES) - result << "_" << item.first << "=" << item.second; + for (auto& item : additionalConfig) { + result << "_" << item.first << "=" << item.second.as(); } } @@ -69,7 +67,7 @@ class RNNCellCPUTest : public testing::WithParamInterface, float clip = 0.f; ElementType netPrecision; CPUSpecificParams cpuParams; - std::map additionalConfig; + ov::AnyMap additionalConfig; std::tie(inputShapes, activations, clip, netPrecision, cpuParams, additionalConfig) = this->GetParam(); std::tie(inFmts, outFmts, priority, selectedType) = cpuParams; @@ -82,7 +80,8 @@ class RNNCellCPUTest : public testing::WithParamInterface, configuration.insert(additionalConfig.begin(), additionalConfig.end()); - if (additionalConfig[InferenceEngine::PluginConfigParams::KEY_ENFORCE_BF16] == InferenceEngine::PluginConfigParams::YES) { + auto it = additionalConfig.find(ov::hint::inference_precision.name()); + if (it != additionalConfig.end() && it->second.as() == ov::element::bf16) { selectedType = makeSelectedTypeStr(selectedType, ElementType::bf16); } else { selectedType = makeSelectedTypeStr(selectedType, netPrecision); @@ -96,7 +95,7 @@ class RNNCellCPUTest : public testing::WithParamInterface, paramsOuts.push_back(param); } std::vector WRB = {{hiddenSize, inputSize}, {hiddenSize, hiddenSize}, {hiddenSize}}; - auto rnnCellOp = ngraph::builder::makeRNN(paramsOuts, WRB, hiddenSize, activations, {}, {}, clip); + auto rnnCellOp = utils::make_rnn(paramsOuts, WRB, hiddenSize, activations, {}, {}, clip); function = makeNgraphFunction(netPrecision, params, rnnCellOp, "RNNCellCPU"); } @@ -109,10 +108,8 @@ TEST_P(RNNCellCPUTest, CompareWithRefs) { namespace { /* CPU PARAMS */ -std::vector> additionalConfig = { - {{InferenceEngine::PluginConfigParams::KEY_ENFORCE_BF16, InferenceEngine::PluginConfigParams::NO}}, - {{InferenceEngine::PluginConfigParams::KEY_ENFORCE_BF16, InferenceEngine::PluginConfigParams::YES}} -}; +std::vector additionalConfig = {{ov::hint::inference_precision(ov::element::f32)}, + {ov::hint::inference_precision(ov::element::bf16)}}; CPUSpecificParams cpuParams{{nc, nc}, {nc}, {"ref_any"}, "ref_any"}; std::vector> activations = {{"relu"}, {"sigmoid"}, {"tanh"}}; @@ -167,5 +164,6 @@ INSTANTIATE_TEST_SUITE_P(smoke_dynamic, RNNCellCPUTest, ::testing::Values(cpuParams), ::testing::ValuesIn(additionalConfig)), RNNCellCPUTest::getTestCaseName); -} // namespace -} // namespace CPULayerTestsDefinitions +} // namespace +} // namespace test +} // namespace ov diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/rnn_sequence.cpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/rnn_sequence.cpp index e3c05700d7243b..41bed3e3b5d171 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/rnn_sequence.cpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/rnn_sequence.cpp @@ -3,25 +3,26 @@ // #include "shared_test_classes/base/ov_subgraph.hpp" -#include "ov_models/builders.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 "transformations/op_conversions/bidirectional_sequences_decomposition.hpp" #include "transformations/op_conversions/convert_sequences_to_tensor_iterator.hpp" using namespace CPUTestUtils; -using namespace ov::test; -namespace CPULayerTestsDefinitions { +namespace ov { +namespace test { using RNNSequenceCpuSpecificParams = typename std::tuple< std::vector, // Shapes - ngraph::helpers::SequenceTestsMode, // Pure Sequence or TensorIterator + ov::test::utils::SequenceTestsMode, // Pure Sequence or TensorIterator std::vector, // Activations float, // Clip ov::op::RecurrentSequenceDirection, // Direction ElementType, // Network precision CPUSpecificParams, // CPU specific params - std::map // Additional config + ov::AnyMap // Additional config >; class RNNSequenceCPUTest : public testing::WithParamInterface, @@ -29,13 +30,13 @@ class RNNSequenceCPUTest : public testing::WithParamInterface &obj) { std::vector inputShapes; - ngraph::helpers::SequenceTestsMode seqMode; + ov::test::utils::SequenceTestsMode seqMode; std::vector activations; float clip; ov::op::RecurrentSequenceDirection direction; ElementType netPrecision; CPUSpecificParams cpuParams; - std::map additionalConfig; + ov::AnyMap additionalConfig; std::tie(inputShapes, seqMode, activations, clip, direction, netPrecision, cpuParams, additionalConfig) = obj.param; @@ -61,9 +62,8 @@ class RNNSequenceCPUTest : public testing::WithParamInterface(); manager.register_pass(); @@ -180,14 +173,13 @@ TEST_P(RNNSequenceCPUTest, CompareWithRefs) { namespace { /* CPU PARAMS */ -std::vector> additionalConfig - = {{{InferenceEngine::PluginConfigParams::KEY_ENFORCE_BF16, InferenceEngine::PluginConfigParams::NO}}, - {{InferenceEngine::PluginConfigParams::KEY_ENFORCE_BF16, InferenceEngine::PluginConfigParams::YES}}}; +std::vector additionalConfig = {{ov::hint::inference_precision(ov::element::f32)}, + {ov::hint::inference_precision(ov::element::bf16)}}; CPUSpecificParams cpuParams{{ntc, tnc}, {ntc, tnc}, {"ref_any"}, "ref_any"}; CPUSpecificParams cpuParamsBatchSizeOne{{tnc, ntc}, {tnc, tnc}, {"ref_any"}, "ref_any"}; -std::vector mode{ngraph::helpers::SequenceTestsMode::PURE_SEQ}; +std::vector mode{ov::test::utils::SequenceTestsMode::PURE_SEQ}; // output values increase rapidly without clip, so use only seq_lengths = 2 std::vector seq_lengths_zero_clip{ 2 }; std::vector> activations = {{"relu"}, {"sigmoid"}, {"tanh"}}; @@ -221,7 +213,7 @@ INSTANTIATE_TEST_SUITE_P(smoke_static, RNNSequenceCPUTest, ::testing::ValuesIn(direction), ::testing::ValuesIn(netPrecisions), ::testing::Values(cpuParams), - ::testing::Values(std::map{})), + ::testing::Values(ov::AnyMap{})), RNNSequenceCPUTest::getTestCaseName); INSTANTIATE_TEST_SUITE_P(smoke_static_BatchSizeOne, RNNSequenceCPUTest, @@ -232,7 +224,7 @@ INSTANTIATE_TEST_SUITE_P(smoke_static_BatchSizeOne, RNNSequenceCPUTest, ::testing::ValuesIn(direction), ::testing::ValuesIn(netPrecisions), ::testing::Values(cpuParamsBatchSizeOne), - ::testing::Values(std::map{})), + ::testing::Values(ov::AnyMap{})), RNNSequenceCPUTest::getTestCaseName); const std::vector> dynamicShapes = { @@ -300,7 +292,7 @@ INSTANTIATE_TEST_SUITE_P(smoke_dynamic, RNNSequenceCPUTest, ::testing::ValuesIn(direction), ::testing::ValuesIn(netPrecisions), ::testing::Values(cpuParams), - ::testing::Values(std::map{})), + ::testing::Values(ov::AnyMap{})), RNNSequenceCPUTest::getTestCaseName); INSTANTIATE_TEST_SUITE_P(smoke_dynamic_BatchSizeOne, RNNSequenceCPUTest, @@ -311,7 +303,7 @@ INSTANTIATE_TEST_SUITE_P(smoke_dynamic_BatchSizeOne, RNNSequenceCPUTest, ::testing::ValuesIn(direction), ::testing::ValuesIn(netPrecisions), ::testing::Values(cpuParamsBatchSizeOne), - ::testing::Values(std::map{})), + ::testing::Values(ov::AnyMap{})), RNNSequenceCPUTest::getTestCaseName); INSTANTIATE_TEST_SUITE_P(nightly_dynamic, RNNSequenceCPUTest, @@ -322,7 +314,7 @@ INSTANTIATE_TEST_SUITE_P(nightly_dynamic, RNNSequenceCPUTest, ::testing::ValuesIn(direction), ::testing::ValuesIn(netPrecisions), ::testing::Values(cpuParams), - ::testing::Values(std::map{})), + ::testing::Values(ov::AnyMap{})), RNNSequenceCPUTest::getTestCaseName); INSTANTIATE_TEST_SUITE_P(nightly_dynamic_bf16, RNNSequenceCPUTest, @@ -335,5 +327,6 @@ INSTANTIATE_TEST_SUITE_P(nightly_dynamic_bf16, RNNSequenceCPUTest, ::testing::Values(cpuParams), ::testing::Values(additionalConfig[1])), RNNSequenceCPUTest::getTestCaseName); -} // namespace -} // namespace CPULayerTestsDefinitions +} // namespace +} // namespace test +} // namespace ov diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/roi_pooling.cpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/roi_pooling.cpp index 5b96e040c7db6d..b8da94cf0824c9 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/roi_pooling.cpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/roi_pooling.cpp @@ -1,38 +1,35 @@ // Copyright (C) 2018-2023 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // -#include +#include "shared_test_classes/single_layer/roi_pooling.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" #include "common_test_utils/file_utils.hpp" -#include +#include "common_test_utils/ov_tensor_utils.hpp" #include "common_test_utils/data_utils.hpp" -#include "ie_common.h" #include "test_utils/cpu_test_utils.hpp" #include "utils/bfloat16.hpp" -using namespace InferenceEngine; using namespace CPUTestUtils; -using namespace ov::test; -namespace CPULayerTestsDefinitions { +namespace ov { +namespace test { enum ProposalGenerationMode { RANDOM, ULTIMATE_RIGHT_BORDER }; using roiPoolingShapes = std::vector; -using roiPoolingParams = std::tuple< - roiPoolingShapes, // Input shapes - std::vector, // Pooled shape {pooled_h, pooled_w} - float, // Spatial scale - ngraph::helpers::ROIPoolingTypes, // ROIPooling method - InferenceEngine::Precision, // Net precision - LayerTestsUtils::TargetDevice>; // Device name +using roiPoolingParams = std::tuple, // Pooled shape {pooled_h, pooled_w} + float, // Spatial scale + utils::ROIPoolingTypes, // ROIPooling method + ov::element::Type, // Net precision + LayerTestsUtils::TargetDevice>; // Device name using ROIPoolingCPUTestParamsSet = std::tuple>; + ov::AnyMap>; class ROIPoolingCPULayerTest : public testing::WithParamInterface, public ov::test::SubgraphBaseTest, @@ -42,20 +39,20 @@ class ROIPoolingCPULayerTest : public testing::WithParamInterface additionalConfig; + ov::AnyMap additionalConfig; std::tie(basicParamsSet, cpuParams, propMode, additionalConfig) = obj.param; roiPoolingShapes inputShapes; std::vector poolShape; float spatial_scale; - ngraph::helpers::ROIPoolingTypes pool_method; - InferenceEngine::Precision netPrecision; + utils::ROIPoolingTypes pool_method; + ov::element::Type netPrecision; std::string targetDevice; std::tie(inputShapes, poolShape, spatial_scale, pool_method, netPrecision, targetDevice) = basicParamsSet; std::ostringstream result; - result << "netPRC=" << netPrecision.name() << "_"; + result << "netPRC=" << netPrecision.to_string() << "_"; for (const auto& shape : inputShapes) { result << ov::test::utils::partialShape2str({ shape.first }) << "_"; } @@ -74,19 +71,18 @@ class ROIPoolingCPULayerTest : public testing::WithParamInterface(roi_pooling)}; + ov::ResultVector results{std::make_shared(roi_pooling)}; - function = makeNgraphFunction(ngPrc, params, roi_pooling, "ROIPooling"); - functionRefs = ngraph::clone_function(*function); + function = makeNgraphFunction(netPrecision, params, roi_pooling, "ROIPooling"); + functionRefs = ov::clone_model(*function); } }; @@ -226,11 +222,8 @@ TEST_P(ROIPoolingCPULayerTest, CompareWithRefs) { namespace { -std::vector> additionalConfig{ - {{PluginConfigParams::KEY_ENFORCE_BF16, PluginConfigParams::NO}}, - {{PluginConfigParams::KEY_ENFORCE_BF16, PluginConfigParams::YES}} -}; - +std::vector additionalConfig = {{ov::hint::inference_precision(ov::element::f32)}, + {ov::hint::inference_precision(ov::element::bf16)}}; /* have to select particular implementation type, since currently * nodes always choose the best one */ std::vector selectCPUInfoForDevice() { @@ -329,21 +322,21 @@ const std::vector> pooledShapes_bilinear = { {6, 6} }; -const std::vector netPRCs = {InferenceEngine::Precision::FP32, InferenceEngine::Precision::BF16}; +const std::vector netPRCs = {ov::element::f32, ov::element::bf16}; const std::vector spatial_scales = {0.625f, 1.f}; const auto test_ROIPooling_max = ::testing::Combine(::testing::ValuesIn(inShapes), ::testing::ValuesIn(pooledShapes_max), ::testing::ValuesIn(spatial_scales), - ::testing::Values(ngraph::helpers::ROIPoolingTypes::ROI_MAX), + ::testing::Values(utils::ROIPoolingTypes::ROI_MAX), ::testing::ValuesIn(netPRCs), ::testing::Values(ov::test::utils::DEVICE_CPU)); const auto test_ROIPooling_bilinear = ::testing::Combine(::testing::ValuesIn(inShapes), ::testing::ValuesIn(pooledShapes_bilinear), ::testing::Values(spatial_scales[1]), - ::testing::Values(ngraph::helpers::ROIPoolingTypes::ROI_BILINEAR), + ::testing::Values(utils::ROIPoolingTypes::ROI_BILINEAR), ::testing::ValuesIn(netPRCs), ::testing::Values(ov::test::utils::DEVICE_CPU)); @@ -363,18 +356,19 @@ INSTANTIATE_TEST_SUITE_P(smoke_ROIPoolingCPU_bilinear, ::testing::ValuesIn(additionalConfig)), ROIPoolingCPULayerTest::getTestCaseName); -INSTANTIATE_TEST_SUITE_P(smoke_ROIPoolingCPU_bilinear_ultimateRightBorderProposal, - ROIPoolingCPULayerTest, - ::testing::Combine(::testing::Combine(::testing::Values(roiPoolingShapes{{{}, {{1, 1, 50, 50}}}, {{}, {{1, 5}}}}), - ::testing::Values(std::vector { 4, 4 }), - ::testing::Values(spatial_scales[1]), - ::testing::Values(ngraph::helpers::ROIPoolingTypes::ROI_BILINEAR), - ::testing::Values(InferenceEngine::Precision::FP32), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - ::testing::ValuesIn(selectCPUInfoForDevice()), - ::testing::Values(ProposalGenerationMode::ULTIMATE_RIGHT_BORDER), - ::testing::Values(std::map{ - {{PluginConfigParams::KEY_ENFORCE_BF16, PluginConfigParams::NO}}})), - ROIPoolingCPULayerTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P( + smoke_ROIPoolingCPU_bilinear_ultimateRightBorderProposal, + ROIPoolingCPULayerTest, + ::testing::Combine(::testing::Combine(::testing::Values(roiPoolingShapes{{{}, {{1, 1, 50, 50}}}, {{}, {{1, 5}}}}), + ::testing::Values(std::vector{4, 4}), + ::testing::Values(spatial_scales[1]), + ::testing::Values(utils::ROIPoolingTypes::ROI_BILINEAR), + ::testing::Values(ov::element::f32), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::ValuesIn(selectCPUInfoForDevice()), + ::testing::Values(ProposalGenerationMode::ULTIMATE_RIGHT_BORDER), + ::testing::Values(ov::AnyMap{{ov::hint::inference_precision(ov::element::f32)}})), + ROIPoolingCPULayerTest::getTestCaseName); } // namespace -} // namespace CPULayerTestsDefinitions +} // namespace test +} // namespace ov diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/roialign.cpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/roialign.cpp index 707f0b2a8f3b69..4798df6aea5751 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/roialign.cpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/roialign.cpp @@ -3,17 +3,13 @@ // #include "test_utils/cpu_test_utils.hpp" -#include - +#include "common_test_utils/ov_tensor_utils.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include "ov_models/builders.hpp" -#include "ov_models/utils/ov_helpers.hpp" -using namespace InferenceEngine; using namespace CPUTestUtils; -using namespace ov::test; -namespace CPULayerTestsDefinitions { +namespace ov { +namespace test { using ROIAlignShapes = std::vector; using ROIAlignSpecificParams = std::tuple< @@ -33,14 +29,14 @@ using ROIAlignLayerTestParams = std::tuple< >; using ROIAlignLayerCPUTestParamsSet = std::tuple< - CPULayerTestsDefinitions::ROIAlignLayerTestParams, + ROIAlignLayerTestParams, CPUSpecificParams>; class ROIAlignLayerCPUTest : public testing::WithParamInterface, public SubgraphBaseTest, public CPUTestsBase { public: static std::string getTestCaseName(testing::TestParamInfo obj) { - CPULayerTestsDefinitions::ROIAlignLayerTestParams basicParamsSet; + ROIAlignLayerTestParams basicParamsSet; CPUSpecificParams cpuParams; std::tie(basicParamsSet, cpuParams) = obj.param; std::string td; @@ -82,7 +78,7 @@ class ROIAlignLayerCPUTest : public testing::WithParamInterface& targetInputStaticShapes) override { + void generate_inputs(const std::vector& targetInputStaticShapes) override { inputs.clear(); const auto& funcInputs = function->inputs(); @@ -104,10 +100,10 @@ class ROIAlignLayerCPUTest : public testing::WithParamInterface(coordsTensor.data()); for (size_t i = 0; i < coordsTensor.get_size(); i += 4) { - coordsTensorData[i] = static_cast(ngraph::bfloat16(1.f).to_bits()); - coordsTensorData[i + 1] = static_cast(ngraph::bfloat16(1.f).to_bits()); - coordsTensorData[i + 2] = static_cast(ngraph::bfloat16(19.f).to_bits()); - coordsTensorData[i + 3] = static_cast(ngraph::bfloat16(19.f).to_bits()); + coordsTensorData[i] = static_cast(ov::bfloat16(1.f).to_bits()); + coordsTensorData[i + 1] = static_cast(ov::bfloat16(1.f).to_bits()); + coordsTensorData[i + 2] = static_cast(ov::bfloat16(19.f).to_bits()); + coordsTensorData[i + 3] = static_cast(ov::bfloat16(19.f).to_bits()); } } else { OPENVINO_THROW("roi align. Unsupported precision: ", coordsET); @@ -127,12 +123,12 @@ class ROIAlignLayerCPUTest : public testing::WithParamInterfaceGetParam(); std::tie(inFmts, outFmts, priority, selectedType) = cpuParams; - CPULayerTestsDefinitions::ROIAlignSpecificParams roiAlignParams; + ROIAlignSpecificParams roiAlignParams; ElementType inputPrecision; std::tie(roiAlignParams, inputPrecision, targetDevice) = basicParamsSet; @@ -151,19 +147,26 @@ class ROIAlignLayerCPUTest : public testing::WithParamInterface(inputPrecision, shape)); } - auto int_param = std::make_shared(ngraph::element::i32, inputDynamicShapes[2]); - auto pooling_mode = ngraph::EnumNames::as_enum(mode); - auto aligned_mode = ngraph::EnumNames::as_enum(alignedMode); - - auto roialign = std::make_shared(float_params[0], float_params[1], int_param, pooledH, pooledW, - samplingRatio, spatialScale, pooling_mode, aligned_mode); + auto int_param = std::make_shared(ov::element::i32, inputDynamicShapes[2]); + auto pooling_mode = ov::EnumNames::as_enum(mode); + auto aligned_mode = ov::EnumNames::as_enum(alignedMode); + + auto roialign = std::make_shared(float_params[0], + float_params[1], + int_param, + pooledH, + pooledW, + samplingRatio, + spatialScale, + pooling_mode, + aligned_mode); selectedType = makeSelectedTypeStr(selectedType, inputPrecision); if (inputPrecision == ElementType::bf16) { rel_threshold = 1e-2; } - ngraph::ParameterVector params{ float_params[0], float_params[1], int_param }; + ov::ParameterVector params{ float_params[0], float_params[1], int_param }; function = makeNgraphFunction(inputPrecision, params, roialign, "ROIAlign"); } }; @@ -178,15 +181,15 @@ namespace { /* CPU PARAMS */ std::vector filterCPUInfoForDevice() { std::vector resCPUParams; - if (InferenceEngine::with_cpu_x86_avx512f()) { + if (ov::with_cpu_x86_avx512f()) { resCPUParams.push_back(CPUSpecificParams{{nchw, nc, x}, {nchw}, {"jit_avx512"}, {"jit_avx512"}}); resCPUParams.push_back(CPUSpecificParams{{nhwc, nc, x}, {nhwc}, {"jit_avx512"}, {"jit_avx512"}}); resCPUParams.push_back(CPUSpecificParams{{nChw16c, nc, x}, {nChw16c}, {"jit_avx512"}, {"jit_avx512"}}); - } else if (InferenceEngine::with_cpu_x86_avx2()) { + } else if (ov::with_cpu_x86_avx2()) { resCPUParams.push_back(CPUSpecificParams{{nchw, nc, x}, {nchw}, {"jit_avx2"}, {"jit_avx2"}}); resCPUParams.push_back(CPUSpecificParams{{nhwc, nc, x}, {nhwc}, {"jit_avx2"}, {"jit_avx2"}}); resCPUParams.push_back(CPUSpecificParams{{nChw8c, nc, x}, {nChw8c}, {"jit_avx2"}, {"jit_avx2"}}); - } else if (InferenceEngine::with_cpu_x86_sse42()) { + } else if (ov::with_cpu_x86_sse42()) { resCPUParams.push_back(CPUSpecificParams{{nchw, nc, x}, {nchw}, {"jit_sse42"}, {"jit_sse42"}}); resCPUParams.push_back(CPUSpecificParams{{nhwc, nc, x}, {nhwc}, {"jit_sse42"}, {"jit_sse42"}}); resCPUParams.push_back(CPUSpecificParams{{nChw8c, nc, x}, {nChw8c}, {"jit_sse42"}, {"jit_sse42"}}); @@ -265,5 +268,6 @@ INSTANTIATE_TEST_SUITE_P(smoke_ROIAlignLayoutTest, ROIAlignLayerCPUTest, ::testing::Values(ov::test::utils::DEVICE_CPU)), ::testing::ValuesIn(filterCPUInfoForDevice())), ROIAlignLayerCPUTest::getTestCaseName); -} // namespace -} // namespace CPULayerTestsDefinitions +} // namespace +} // namespace test +} // namespace ov diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/roll.cpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/roll.cpp index c66384281982ef..eae2668ff5c16c 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/roll.cpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/roll.cpp @@ -7,9 +7,9 @@ #include "test_utils/cpu_test_utils.hpp" using namespace CPUTestUtils; -using namespace ov::test; -namespace CPULayerTestsDefinitions { +namespace ov { +namespace test { using RollCPUTestParams = typename std::tuple< InputShape, // Input shape @@ -58,12 +58,14 @@ class RollLayerCPUTest : public testing::WithParamInterface, for (auto&& shape : inputDynamicShapes) { paramsIn.push_back(std::make_shared(inputPrecision, shape)); } - auto shiftNode = std::make_shared(ngraph::element::Type_t::i64, ngraph::Shape{shift.size()}, shift)->output(0); - auto axesNode = std::make_shared(ngraph::element::Type_t::i64, ngraph::Shape{axes.size()}, axes)->output(0); - - const auto roll = std::make_shared(paramsIn[0], shiftNode, axesNode); - const ngraph::ResultVector results{std::make_shared(roll)}; - function = std::make_shared(results, paramsIn, "roll"); + auto shiftNode = + std::make_shared(ov::element::i64, ov::Shape{shift.size()}, shift)->output(0); + auto axesNode = + std::make_shared(ov::element::i64, ov::Shape{axes.size()}, axes)->output(0); + + const auto roll = std::make_shared(paramsIn[0], shiftNode, axesNode); + const ov::ResultVector results{std::make_shared(roll)}; + function = std::make_shared(results, paramsIn, "roll"); } }; @@ -146,5 +148,6 @@ INSTANTIATE_TEST_SUITE_P(smoke_RollCPU_5DRepeatingAxesNegativeShift, RollLayerCP ::testing::Values(ov::test::utils::DEVICE_CPU)), RollLayerCPUTest::getTestCaseName); -} // namespace -} // namespace CPULayerTestsDefinitions +} // namespace +} // namespace test +} // namespace ov diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/scatter_ND_update.cpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/scatter_ND_update.cpp index f6905ebd4146b9..54866ac5762532 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/scatter_ND_update.cpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/scatter_ND_update.cpp @@ -2,17 +2,13 @@ // SPDX-License-Identifier: Apache-2.0 // -#include -#include "test_utils/cpu_test_utils.hpp" +#include "common_test_utils/ov_tensor_utils.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include "ov_models/builders.hpp" +#include "test_utils/cpu_test_utils.hpp" -using namespace ngraph; -using namespace InferenceEngine; using namespace CPUTestUtils; -using namespace ov::test; - -namespace CPULayerTestsDefinitions { +namespace ov { +namespace test { using ScatterNDUpdateShapes = std::vector; using IndicesValues = std::vector; @@ -21,12 +17,13 @@ struct ScatterNDUpdateLayerParams { IndicesValues indicesValues; }; -using scatterUpdateParams = std::tuple< - ScatterNDUpdateLayerParams, - ElementType, // input precision - ElementType>; // indices precision +using scatterUpdateParams = std::tuple; // indices precision -class ScatterNDUpdateLayerCPUTest : public testing::WithParamInterface, public SubgraphBaseTest, public CPUTestsBase { +class ScatterNDUpdateLayerCPUTest : public testing::WithParamInterface, + public SubgraphBaseTest, + public CPUTestsBase { public: static std::string getTestCaseName(testing::TestParamInfo obj) { ScatterNDUpdateLayerParams scatterParams; @@ -39,7 +36,7 @@ class ScatterNDUpdateLayerCPUTest : public testing::WithParamInterface(inputPrecision, shape)); } auto indicesParam = std::make_shared(idxPrecision, inputDynamicShapes[1]); @@ -110,9 +107,9 @@ class ScatterNDUpdateLayerCPUTest : public testing::WithParamInterfaceset_friendly_name("Param_2"); dataParams[1]->set_friendly_name("Param_3"); - auto scatter = std::make_shared(dataParams[0], indicesParam, dataParams[1]); + auto scatter = std::make_shared(dataParams[0], indicesParam, dataParams[1]); - ngraph::ParameterVector allParams{ dataParams[0], indicesParam, dataParams[1] }; + ov::ParameterVector allParams{dataParams[0], indicesParam, dataParams[1]}; function = makeNgraphFunction(inputPrecision, allParams, scatter, "ScatterNDUpdateLayerCPUTest"); } }; @@ -129,40 +126,26 @@ const std::vector scatterParams = { {{2, 2, 1}, {{2, 2, 1}, {2, 2, 1}, {2, 2, 1}}}, {{-1, -1, -1, -1, -1, -1}, {{2, 2, 9, 10, 9, 10}, {2, 2, 1, 11, 2, 5}, {2, 2, 15, 8, 1, 7}}}, }, - IndicesValues{ 5, 6, 2, 8 } - }, - ScatterNDUpdateLayerParams{ - ScatterNDUpdateShapes{ - {{-1, -1, -1, -1}, {{ 10, 9, 9, 11 }, { 7, 5, 3, 12 }, { 3, 4, 9, 8 }}}, - {{2, 3}, {{2, 3}, {2, 3}, {2, 3}}}, - {{-1, -1}, {{2, 11}, {2, 12}, {2, 8}}} - }, - IndicesValues{ 0, 1, 1, 2, 2, 2 } - }, + IndicesValues{5, 6, 2, 8}}, + ScatterNDUpdateLayerParams{ScatterNDUpdateShapes{{{-1, -1, -1, -1}, {{10, 9, 9, 11}, {7, 5, 3, 12}, {3, 4, 9, 8}}}, + {{2, 3}, {{2, 3}, {2, 3}, {2, 3}}}, + {{-1, -1}, {{2, 11}, {2, 12}, {2, 8}}}}, + IndicesValues{0, 1, 1, 2, 2, 2}}, ScatterNDUpdateLayerParams{ - ScatterNDUpdateShapes{ - {{{3, 10}, -1, {3, 9}, -1}, {{ 10, 9, 9, 11 }, { 7, 5, 3, 12 }, { 3, 4, 9, 8 }}}, - {{2, 3}, {{2, 3}, {2, 3}, {2, 3}}}, - {{{2, 4}, -1}, {{2, 11}, {2, 12}, {2, 8}}} - }, - IndicesValues{ 0, 1, 1, 2, 2, 2 } - }, + ScatterNDUpdateShapes{{{{3, 10}, -1, {3, 9}, -1}, {{10, 9, 9, 11}, {7, 5, 3, 12}, {3, 4, 9, 8}}}, + {{2, 3}, {{2, 3}, {2, 3}, {2, 3}}}, + {{{2, 4}, -1}, {{2, 11}, {2, 12}, {2, 8}}}}, + IndicesValues{0, 1, 1, 2, 2, 2}}, ScatterNDUpdateLayerParams{ - ScatterNDUpdateShapes{ - {{{3, 10}, {4, 11}, {3, 9}, {8, 15}}, {{ 10, 9, 9, 11 }, { 7, 5, 3, 12 }, { 3, 4, 9, 8 }}}, - {{2, 3}, {{2, 3}, {2, 3}, {2, 3}}}, - {{{2, 4}, -1}, {{2, 11}, {2, 12}, {2, 8}}} - }, - IndicesValues{ 0, 1, 1, 2, 2, 2 } - }, + ScatterNDUpdateShapes{{{{3, 10}, {4, 11}, {3, 9}, {8, 15}}, {{10, 9, 9, 11}, {7, 5, 3, 12}, {3, 4, 9, 8}}}, + {{2, 3}, {{2, 3}, {2, 3}, {2, 3}}}, + {{{2, 4}, -1}, {{2, 11}, {2, 12}, {2, 8}}}}, + IndicesValues{0, 1, 1, 2, 2, 2}}, ScatterNDUpdateLayerParams{ - ScatterNDUpdateShapes{ - {{{3, 10}, {4, 11}, {3, 9}, {8, 15}}, {{ 10, 9, 9, 11 }, { 7, 5, 3, 12 }, { 3, 4, 9, 8 }}}, - {{2, 3}, {{2, 3}, {2, 3}, {2, 3}}}, - {{{2, 4}, -1}, {{2, 11}, {2, 12}, {2, 8}}} - }, - IndicesValues{ -1, -1, -1, -2, -2, -2 } - }, + ScatterNDUpdateShapes{{{{3, 10}, {4, 11}, {3, 9}, {8, 15}}, {{10, 9, 9, 11}, {7, 5, 3, 12}, {3, 4, 9, 8}}}, + {{2, 3}, {{2, 3}, {2, 3}, {2, 3}}}, + {{{2, 4}, -1}, {{2, 11}, {2, 12}, {2, 8}}}}, + IndicesValues{-1, -1, -1, -2, -2, -2}}, }; const std::vector inputPrecisions = { @@ -175,10 +158,11 @@ const std::vector constantPrecisions = { ElementType::i64, }; -INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs, ScatterNDUpdateLayerCPUTest, - ::testing::Combine( - ::testing::ValuesIn(scatterParams), - ::testing::ValuesIn(inputPrecisions), - ::testing::ValuesIn(constantPrecisions)), - ScatterNDUpdateLayerCPUTest::getTestCaseName); -} // namespace CPULayerTestsDefinitions +INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs, + ScatterNDUpdateLayerCPUTest, + ::testing::Combine(::testing::ValuesIn(scatterParams), + ::testing::ValuesIn(inputPrecisions), + ::testing::ValuesIn(constantPrecisions)), + ScatterNDUpdateLayerCPUTest::getTestCaseName); +} // namespace test +} // 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/single_layer_tests/scatter_elements_update.cpp index bdbee3447f0c0b..08828a4c0be972 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/scatter_elements_update.cpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/scatter_elements_update.cpp @@ -2,17 +2,13 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "test_utils/cpu_test_utils.hpp" -#include +#include "common_test_utils/ov_tensor_utils.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include "ov_models/builders.hpp" +#include "test_utils/cpu_test_utils.hpp" -using namespace ngraph; -using namespace InferenceEngine; using namespace CPUTestUtils; -using namespace ov::test; - -namespace CPULayerTestsDefinitions { +namespace ov { +namespace test { using ScatterElementsUpdateShapes = std::vector; using IndicesValues = std::vector; @@ -21,13 +17,14 @@ struct ScatterElementsUpdateLayerParams { IndicesValues indicesValues; }; -using scatterUpdateParams = std::tuple< - ScatterElementsUpdateLayerParams, - std::int64_t, // axis - ElementType, // input precision - ElementType>; // indices precision +using scatterUpdateParams = std::tuple; // indices precision -class ScatterElementsUpdateLayerCPUTest : public testing::WithParamInterface, public SubgraphBaseTest, public CPUTestsBase { +class ScatterElementsUpdateLayerCPUTest : public testing::WithParamInterface, + public SubgraphBaseTest, + public CPUTestsBase { public: static std::string getTestCaseName(testing::TestParamInfo obj) { ScatterElementsUpdateLayerParams scatterParams; @@ -41,7 +38,7 @@ class ScatterElementsUpdateLayerCPUTest : public testing::WithParamInterface(inputPrecision, shape)); } auto indicesParam = std::make_shared(idxPrecision, inputDynamicShapes[1]); @@ -114,10 +111,11 @@ class ScatterElementsUpdateLayerCPUTest : public testing::WithParamInterfaceset_friendly_name("Param_2"); dataParams[1]->set_friendly_name("Param_3"); - auto axisNode = ngraph::opset3::Constant::create(idxPrecision, {}, { axis }); - auto scatter = std::make_shared(dataParams[0], indicesParam, dataParams[1], axisNode); + auto axisNode = ov::op::v0::Constant::create(idxPrecision, {}, {axis}); + auto scatter = + std::make_shared(dataParams[0], indicesParam, dataParams[1], axisNode); - ngraph::ParameterVector allParams{ dataParams[0], indicesParam, dataParams[1] }; + ov::ParameterVector allParams{dataParams[0], indicesParam, dataParams[1]}; function = makeNgraphFunction(inputPrecision, allParams, scatter, "ScatterElementsUpdateLayerCPUTest"); } }; @@ -127,7 +125,7 @@ TEST_P(ScatterElementsUpdateLayerCPUTest, CompareWithRefs) { CheckPluginRelatedResults(compiledModel, "ScatterUpdate"); } -const std::vector axes = { -3, -2, -1, 0, 1, 2 }; +const std::vector axes = {-3, -2, -1, 0, 1, 2}; const std::vector scatterParams = { ScatterElementsUpdateLayerParams{ @@ -167,11 +165,12 @@ const std::vector constantPrecisions = { ElementType::i64, }; -INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs, ScatterElementsUpdateLayerCPUTest, - ::testing::Combine( - ::testing::ValuesIn(scatterParams), - ::testing::ValuesIn(axes), - ::testing::ValuesIn(inputPrecisions), - ::testing::ValuesIn(constantPrecisions)), - ScatterElementsUpdateLayerCPUTest::getTestCaseName); -} // namespace CPULayerTestsDefinitions +INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs, + ScatterElementsUpdateLayerCPUTest, + ::testing::Combine(::testing::ValuesIn(scatterParams), + ::testing::ValuesIn(axes), + ::testing::ValuesIn(inputPrecisions), + ::testing::ValuesIn(constantPrecisions)), + ScatterElementsUpdateLayerCPUTest::getTestCaseName); +} // namespace test +} // namespace ov diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/scatter_update.cpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/scatter_update.cpp index 858a27a94109c1..3c43939e654bf2 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/scatter_update.cpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/scatter_update.cpp @@ -2,32 +2,31 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "test_utils/cpu_test_utils.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include "ov_models/builders.hpp" +#include "test_utils/cpu_test_utils.hpp" -using namespace ngraph; -using namespace InferenceEngine; using namespace CPUTestUtils; -using namespace ov::test; -namespace CPULayerTestsDefinitions { +namespace ov { +namespace test { + using ScatterUpdateShapes = std::vector; using IndicesDescription = std::pair>; using Axis = std::int64_t; struct ScatterUpdateLayerParams { - ScatterUpdateShapes inputShapes; // shapes for "data" and "updates" inputs - IndicesDescription indicesDescriprion; // indices shapes and values + ScatterUpdateShapes inputShapes; // shapes for "data" and "updates" inputs + IndicesDescription indicesDescriprion; // indices shapes and values Axis axis; }; -using scatterUpdateParams = std::tuple< - ScatterUpdateLayerParams, - ElementType, // input precision - ElementType>; // indices precision +using scatterUpdateParams = std::tuple; // indices precision -class ScatterUpdateLayerCPUTest : public testing::WithParamInterface, public SubgraphBaseTest, public CPUTestsBase { +class ScatterUpdateLayerCPUTest : public testing::WithParamInterface, + public SubgraphBaseTest, + public CPUTestsBase { public: static std::string getTestCaseName(testing::TestParamInfo obj) { ScatterUpdateLayerParams scatterParams; @@ -41,7 +40,7 @@ class ScatterUpdateLayerCPUTest : public testing::WithParamInterface scatterParams = { + ScatterUpdateLayerParams{ScatterUpdateShapes{{{-1, -1, -1, -1}, {{4, 12, 3, 11}, {7, 11, 2, 3}, {3, 9, 4, 10}}}, + {{-1, -1, -1, -1}, {{4, 8, 3, 11}, {7, 8, 2, 3}, {3, 8, 4, 10}}}}, + IndicesDescription{{8}, {0, 2, 4, 6, 1, 3, 5, 7}}, + Axis{1}}, + ScatterUpdateLayerParams{ScatterUpdateShapes{{{-1, -1, -1, -1}, {{4, 12, 3, 11}, {7, 9, 1, 12}, {3, 2, 1, 9}}}, + {{-1, -1, -1, -1}, {{4, 12, 3, 8}, {7, 9, 1, 8}, {3, 2, 1, 8}}}}, + IndicesDescription{{8}, {0, 2, 4, 6, 1, 3, 5, 7}}, + Axis{3}}, ScatterUpdateLayerParams{ - ScatterUpdateShapes{ - {{-1, -1, -1, -1}, {{4, 12, 3, 11}, {7, 11, 2, 3}, {3, 9, 4, 10}}}, - {{-1, -1, -1, -1}, {{4, 8, 3, 11}, {7, 8, 2, 3}, {3, 8, 4, 10}}} - }, - IndicesDescription{{8}, {0, 2, 4, 6, 1, 3, 5, 7}}, - Axis{1} - }, + ScatterUpdateShapes{{{-1, -1, -1, -1, -1}, {{5, 9, 10, 3, 4}, {7, 8, 11, 2, 2}, {11, 3, 12, 2, 2}}}, + {{-1, -1, -1, -1, -1, -1}, {{5, 9, 4, 2, 3, 4}, {7, 8, 4, 2, 2, 2}, {11, 3, 4, 2, 2, 2}}}}, + IndicesDescription{{4, 2}, {0, 2, 4, 6, 1, 3, 5, 7}}, + Axis{2}}, ScatterUpdateLayerParams{ - ScatterUpdateShapes{ - {{-1, -1, -1, -1}, {{4, 12, 3, 11}, {7, 9, 1, 12}, {3, 2, 1, 9}}}, - {{-1, -1, -1, -1}, {{4, 12, 3, 8}, {7, 9, 1, 8}, {3, 2, 1, 8}}} - }, - IndicesDescription{{8}, {0, 2, 4, 6, 1, 3, 5, 7}}, - Axis{3} - }, - ScatterUpdateLayerParams{ - ScatterUpdateShapes{ - {{-1, -1, -1, -1, -1}, {{5, 9, 10, 3, 4}, {7, 8, 11, 2, 2}, {11, 3, 12, 2, 2}}}, - {{-1, -1, -1, -1, -1, -1}, {{5, 9, 4, 2, 3, 4}, {7, 8, 4, 2, 2, 2}, {11, 3, 4, 2, 2, 2}}} - }, - IndicesDescription{{ 4, 2 }, { 0, 2, 4, 6, 1, 3, 5, 7 }}, - Axis{2} - }, - ScatterUpdateLayerParams{ - ScatterUpdateShapes{ - {{-1, -1, -1, -1, -1}, {{8, 9, 10, 3, 4}, {11, 3, 4, 3, 4}, {12, 9, 11, 2, 2}}}, - {{-1, -1, -1, -1, -1, -1}, {{4, 2, 9, 10, 3, 4}, {4, 2, 3, 4, 3, 4}, {4, 2, 9, 11, 2, 2}}} - }, - IndicesDescription{{ 4, 2 }, { 0, 2, 4, 6, 1, 3, 5, 7 }}, - Axis{0} - }, + ScatterUpdateShapes{{{-1, -1, -1, -1, -1}, {{8, 9, 10, 3, 4}, {11, 3, 4, 3, 4}, {12, 9, 11, 2, 2}}}, + {{-1, -1, -1, -1, -1, -1}, {{4, 2, 9, 10, 3, 4}, {4, 2, 3, 4, 3, 4}, {4, 2, 9, 11, 2, 2}}}}, + IndicesDescription{{4, 2}, {0, 2, 4, 6, 1, 3, 5, 7}}, + Axis{0}}, ScatterUpdateLayerParams{ ScatterUpdateShapes{ {{{8, 12}, {3, 9}, {4, 11}, {2, 3}, {2, 4}}, {{8, 9, 10, 3, 4}, {11, 3, 4, 3, 4}, {12, 9, 11, 2, 2}}}, - {{4, 2, {3, 9}, {4, 11}, {2, 3}, {2, 4}}, {{4, 2, 9, 10, 3, 4}, {4, 2, 3, 4, 3, 4}, {4, 2, 9, 11, 2, 2}}} - }, - IndicesDescription{{ 4, 2 }, { 0, 2, 4, 6, 1, 3, 5, 7 }}, - Axis{0} - }, + {{4, 2, {3, 9}, {4, 11}, {2, 3}, {2, 4}}, {{4, 2, 9, 10, 3, 4}, {4, 2, 3, 4, 3, 4}, {4, 2, 9, 11, 2, 2}}}}, + IndicesDescription{{4, 2}, {0, 2, 4, 6, 1, 3, 5, 7}}, + Axis{0}}, }; const std::vector inputPrecisions = { @@ -140,10 +124,11 @@ const std::vector constantPrecisions = { ElementType::i64, }; -INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs, ScatterUpdateLayerCPUTest, - ::testing::Combine( - ::testing::ValuesIn(scatterParams), - ::testing::ValuesIn(inputPrecisions), - ::testing::ValuesIn(constantPrecisions)), - ScatterUpdateLayerCPUTest::getTestCaseName); -} // namespace CPULayerTestsDefinitions +INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs, + ScatterUpdateLayerCPUTest, + ::testing::Combine(::testing::ValuesIn(scatterParams), + ::testing::ValuesIn(inputPrecisions), + ::testing::ValuesIn(constantPrecisions)), + ScatterUpdateLayerCPUTest::getTestCaseName); +} // namespace test +} // namespace ov diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/select.cpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/select.cpp index 84b6a9d19adbdb..f66768c314c36e 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/select.cpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/select.cpp @@ -2,58 +2,55 @@ // SPDX-License-Identifier: Apache-2.0 // -#include +#include "common_test_utils/ov_tensor_utils.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" #include "test_utils/fusing_test_utils.hpp" -#include "ov_models/builders.hpp" -using namespace InferenceEngine; using namespace CPUTestUtils; -using namespace ov::test; +namespace ov { +namespace test { -namespace CPULayerTestsDefinitions { - -using selectParams = std::tuple, // input shapes - ElementType, // Then/Else precision - ngraph::op::AutoBroadcastSpec, // broadcast +using selectParams = std::tuple, // input shapes + ElementType, // Then/Else precision + ov::op::AutoBroadcastSpec, // broadcast fusingSpecificParams>; class SelectLayerCPUTest : public testing::WithParamInterface, virtual public SubgraphBaseTest, public CpuTestWithFusing { public: - static std::string getTestCaseName(testing::TestParamInfo obj) { - std::vector shapes; - ElementType precision; - ngraph::op::AutoBroadcastSpec broadcast; - fusingSpecificParams fusingParams; - std::tie(shapes, precision, broadcast, fusingParams) = obj.param; - - std::ostringstream result; - result << "Condition_prc_" << ElementType::boolean << "_Then_Else_prc_" << precision << "_"; - result << "IS=("; - for (const auto& shape : shapes) { - result << shape.first << "_"; - } - result << ")_TS=("; - for (const auto& shape : shapes) { - for (const auto& item : shape.second) { - result << ov::test::utils::vec2str(item) << "_"; - } - } - result << "Broadcast=" << broadcast.m_type; - result << CpuTestWithFusing::getTestCaseName(fusingParams); - - return result.str(); - } + static std::string getTestCaseName(testing::TestParamInfo obj) { + std::vector shapes; + ElementType precision; + ov::op::AutoBroadcastSpec broadcast; + fusingSpecificParams fusingParams; + std::tie(shapes, precision, broadcast, fusingParams) = obj.param; + + std::ostringstream result; + result << "Condition_prc_" << ElementType::boolean << "_Then_Else_prc_" << precision << "_"; + result << "IS=("; + for (const auto& shape : shapes) { + result << shape.first << "_"; + } + result << ")_TS=("; + for (const auto& shape : shapes) { + for (const auto& item : shape.second) { + result << ov::test::utils::vec2str(item) << "_"; + } + } + result << "Broadcast=" << broadcast.m_type; + result << CpuTestWithFusing::getTestCaseName(fusingParams); + + return result.str(); + } protected: - void SetUp() override { + void SetUp() override { abs_threshold = 0; targetDevice = ov::test::utils::DEVICE_CPU; std::vector shapes; ElementType precision; - ngraph::op::AutoBroadcastSpec broadcast; + ov::op::AutoBroadcastSpec broadcast; fusingSpecificParams fusingParams; std::tie(shapes, precision, broadcast, fusingParams) = this->GetParam(); init_input_shapes(shapes); @@ -69,14 +66,26 @@ class SelectLayerCPUTest : public testing::WithParamInterface, auto select = std::make_shared(parameters[0], parameters[1], parameters[2], broadcast); function = makeNgraphFunction(precision, parameters, select, "Eltwise"); - } + } - void generate_inputs(const std::vector& targetInputStaticShapes) override { + void generate_inputs(const std::vector& targetInputStaticShapes) override { inputs.clear(); const auto& modelInputs = function->inputs(); - auto condTensor = ov::test::utils::create_and_fill_tensor(modelInputs[0].get_element_type(), targetInputStaticShapes[0], 3, -1, 2); - auto thenTensor = ov::test::utils::create_and_fill_tensor(modelInputs[1].get_element_type(), targetInputStaticShapes[1], 10, -10, 2); - auto elseTensor = ov::test::utils::create_and_fill_tensor(modelInputs[2].get_element_type(), targetInputStaticShapes[2], 10, 0, 2); + auto condTensor = ov::test::utils::create_and_fill_tensor(modelInputs[0].get_element_type(), + targetInputStaticShapes[0], + 3, + -1, + 2); + auto thenTensor = ov::test::utils::create_and_fill_tensor(modelInputs[1].get_element_type(), + targetInputStaticShapes[1], + 10, + -10, + 2); + auto elseTensor = ov::test::utils::create_and_fill_tensor(modelInputs[2].get_element_type(), + targetInputStaticShapes[2], + 10, + 0, + 2); inputs.insert({modelInputs[0].get_node_shared_ptr(), condTensor}); inputs.insert({modelInputs[1].get_node_shared_ptr(), thenTensor}); inputs.insert({modelInputs[2].get_node_shared_ptr(), elseTensor}); @@ -88,12 +97,7 @@ TEST_P(SelectLayerCPUTest, CompareWithRefs) { CheckPluginRelatedResults(compiledModel, std::set{"Eltwise", "Subgraph"}); } -const std::vector precisions = { - ElementType::f32, - ElementType::i32, - ElementType::bf16, - ElementType::i8 -}; +const std::vector precisions = {ElementType::f32, ElementType::i32, ElementType::bf16, ElementType::i8}; const std::vector fusingParamsSet{ emptyFusingSpec, @@ -104,106 +108,68 @@ const std::vector fusingParamsSet{ const std::vector> inShapesDynamicNumpy = { { // Condition - { - {-1, -1, -1, -1}, - {{5, 1, 2, 1}, {1, 1, 1, 1}, {5, 9, 8, 7}} - }, + {{-1, -1, -1, -1}, {{5, 1, 2, 1}, {1, 1, 1, 1}, {5, 9, 8, 7}}}, // Then - { - {-1, -1, -1, -1, -1}, - {{8, 1, 9, 1, 1}, {1, 1, 1, 1, 1}, {21, 5, 9, 8, 7}} - }, + {{-1, -1, -1, -1, -1}, {{8, 1, 9, 1, 1}, {1, 1, 1, 1, 1}, {21, 5, 9, 8, 7}}}, // Else - { - {-1, -1, -1, -1}, - {{5, 1, 2, 1}, {1, 1, 1, 1}, {1, 1, 1, 1}} - }, + {{-1, -1, -1, -1}, {{5, 1, 2, 1}, {1, 1, 1, 1}, {1, 1, 1, 1}}}, }, { // Condition - { - {-1, -1}, - {{8, 1}, {10, 5}, {8, 7}} - }, + {{-1, -1}, {{8, 1}, {10, 5}, {8, 7}}}, // Then - { - {-1, -1, -1, -1, -1}, - {{2, 1, 1, 8, 1}, {7, 8, 3, 10, 5}, {1, 1, 1, 8, 1}} - }, + {{-1, -1, -1, -1, -1}, {{2, 1, 1, 8, 1}, {7, 8, 3, 10, 5}, {1, 1, 1, 8, 1}}}, // Else - { - {-1, -1, -1}, - {{9, 1, 1}, {3, 10, 5}, {1, 1, 7}} - }, + {{-1, -1, -1}, {{9, 1, 1}, {3, 10, 5}, {1, 1, 7}}}, }, { // Condition - { - {{2, 8}, {3, 7}, {1, 10}, {1, 6}, {1, 10}}, - {{5, 4, 1, 1, 1}, {8, 5, 5, 5, 1}, {2, 3, 4, 5, 6}} - }, + {{{2, 8}, {3, 7}, {1, 10}, {1, 6}, {1, 10}}, {{5, 4, 1, 1, 1}, {8, 5, 5, 5, 1}, {2, 3, 4, 5, 6}}}, // Then - { - {-1, -1, -1, -1, -1}, - {{5, 1, 8, 1, 1}, {8, 1, 1, 1, 8}, {2, 3, 4, 5, 6}} - }, + {{-1, -1, -1, -1, -1}, {{5, 1, 8, 1, 1}, {8, 1, 1, 1, 8}, {2, 3, 4, 5, 6}}}, // Else - { - {{1, 5}, {1, 11}, {5, 5}, {1, 8}}, - {{1, 1, 5, 1}, {5, 5, 5, 8}, {3, 4, 5, 6}} - }, + {{{1, 5}, {1, 11}, {5, 5}, {1, 8}}, {{1, 1, 5, 1}, {5, 5, 5, 8}, {3, 4, 5, 6}}}, }, { // Condition - { - {{1, 10}}, - {{4}, {10}, {1}} - }, + {{{1, 10}}, {{4}, {10}, {1}}}, // Then - { - {{1, 15}, {2, 7}, {1, 6}, {5, 12}, {1, 20}}, - {{8, 5, 6, 6, 1}, {15, 7, 6, 10, 10}, {2, 5, 4, 5, 3}} - }, + {{{1, 15}, {2, 7}, {1, 6}, {5, 12}, {1, 20}}, {{8, 5, 6, 6, 1}, {15, 7, 6, 10, 10}, {2, 5, 4, 5, 3}}}, // Else - { - {{2, 10}, {1, 16}}, - {{6, 4}, {10, 10}, {5, 1}} - }, + {{{2, 10}, {1, 16}}, {{6, 4}, {10, 10}, {5, 1}}}, }, }; const auto numpyCases = ::testing::Combine(::testing::ValuesIn(inShapesDynamicNumpy), ::testing::ValuesIn(precisions), - ::testing::Values(ngraph::op::AutoBroadcastType::NUMPY), + ::testing::Values(ov::op::AutoBroadcastType::NUMPY), ::testing::ValuesIn(fusingParamsSet)); -INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefsNumpy_dynamic, SelectLayerCPUTest, numpyCases, SelectLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefsNumpy_dynamic, + SelectLayerCPUTest, + numpyCases, + SelectLayerCPUTest::getTestCaseName); const std::vector> inShapesDynamicNone = { { // Condition - { - {{1, 10}, -1, {10, 20}, {1, 5}}, - {{3, 16, 15, 5}, {1, 16, 10, 1}, {10, 16, 20, 5}} - }, + {{{1, 10}, -1, {10, 20}, {1, 5}}, {{3, 16, 15, 5}, {1, 16, 10, 1}, {10, 16, 20, 5}}}, // Then - { - {-1, {16, 16}, -1, -1}, - {{3, 16, 15, 5}, {1, 16, 10, 1}, {10, 16, 20, 5}} - }, + {{-1, {16, 16}, -1, -1}, {{3, 16, 15, 5}, {1, 16, 10, 1}, {10, 16, 20, 5}}}, // Else - { - {-1, -1, -1, -1}, - {{3, 16, 15, 5}, {1, 16, 10, 1}, {10, 16, 20, 5}} - }, + {{-1, -1, -1, -1}, {{3, 16, 15, 5}, {1, 16, 10, 1}, {10, 16, 20, 5}}}, }, }; const auto noneCases = ::testing::Combine(::testing::ValuesIn(inShapesDynamicNone), ::testing::ValuesIn(precisions), - ::testing::Values(ngraph::op::AutoBroadcastType::NONE), + ::testing::Values(ov::op::AutoBroadcastType::NONE), ::testing::ValuesIn(fusingParamsSet)); -INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefsNone_dynamic, SelectLayerCPUTest, noneCases, SelectLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefsNone_dynamic, + SelectLayerCPUTest, + noneCases, + SelectLayerCPUTest::getTestCaseName); -} // namespace CPULayerTestsDefinitions +} // namespace test +} // namespace ov diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/shape_ops.cpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/shape_ops.cpp index a4be376f857f41..196281d1572380 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/shape_ops.cpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/shape_ops.cpp @@ -2,39 +2,32 @@ // SPDX-License-Identifier: Apache-2.0 // +#include "common_test_utils/ov_tensor_utils.hpp" +#include "ov_models/builders.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" #include "test_utils/cpu_test_utils.hpp" -#include "ov_models/builders.hpp" -#include -using namespace ngraph; -using namespace InferenceEngine; using namespace CPUTestUtils; -using namespace ov::test; -namespace CPULayerTestsDefinitions { +namespace ov { +namespace test { -enum class shapeNodeType { - Reshape, - Squeeze, - Unsqueeze, - ReshapeWithNonZero -}; +enum class shapeNodeType { Reshape, Squeeze, Unsqueeze, ReshapeWithNonZero }; inline std::ostream& operator<<(std::ostream& os, shapeNodeType type) { switch (type) { - case shapeNodeType::Reshape: - os << "Reshape"; - break; - case shapeNodeType::Squeeze: - os << "Squeeze"; - break; - case shapeNodeType::Unsqueeze: - os << "Unsqueeze"; - break; - case shapeNodeType::ReshapeWithNonZero: - os << "ReshapeWithNonZero"; - break; + case shapeNodeType::Reshape: + os << "Reshape"; + break; + case shapeNodeType::Squeeze: + os << "Squeeze"; + break; + case shapeNodeType::Unsqueeze: + os << "Unsqueeze"; + break; + case shapeNodeType::ReshapeWithNonZero: + os << "ReshapeWithNonZero"; + break; } return os; } @@ -44,21 +37,22 @@ struct inputDescription { std::vector> data; }; -using shapeOpsParams = std::tuple< - inputDescription, // input shapes - ngraph::helpers::InputLayerType, // second input type - shapeNodeType, // node type - Precision, // precision - ngraph::element::Type_t, // second input precision - bool>; // special zero +using shapeOpsParams = std::tuple; // special zero -class ShapeOpsCPUTest : public testing::WithParamInterface, virtual public SubgraphBaseTest, public CPUTestsBase { +class ShapeOpsCPUTest : public testing::WithParamInterface, + virtual public SubgraphBaseTest, + public CPUTestsBase { public: static std::string getTestCaseName(testing::TestParamInfo obj) { inputDescription inpDesc; - ngraph::helpers::InputLayerType secondType; + ov::test::utils::InputLayerType secondType; shapeNodeType nodeType; - Precision prc; + ov::element::Type prc; bool specialZero; element::Type_t tmpSecondInPrc; std::tie(inpDesc, secondType, nodeType, prc, tmpSecondInPrc, specialZero) = obj.param; @@ -66,7 +60,7 @@ class ShapeOpsCPUTest : public testing::WithParamInterface, virt std::ostringstream result; result << nodeType << "_"; result << "IS="; - result << ov::test::utils::partialShape2str({inpDesc.inputShape.first}) << "_"; + result << ov::test::utils::partialShape2str({inpDesc.inputShape.first}) << "_"; result << "TS=("; for (const auto& shape : inpDesc.inputShape.second) { result << ov::test::utils::vec2str(shape) << "_"; @@ -91,33 +85,38 @@ class ShapeOpsCPUTest : public testing::WithParamInterface, virt const auto& funcInput = funcInputs[i]; ov::runtime::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]}; \ - auto inputData = tensor.data::value_type>(); \ - ASSERT_TRUE(idx < data.size()); \ - for (size_t j = 0lu; j < data[idx].size(); ++j) { \ - inputData[j] = data[idx][j]; \ - } \ - break; \ - } +#define RESHAPE_TEST_CASE(INT_TYPE) \ + case ov::element::Type_t::INT_TYPE: { \ + tensor = ov::runtime::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) { \ + inputData[j] = data[idx][j]; \ + } \ + break; \ + } switch (secondInPrc) { RESHAPE_TEST_CASE(i64) RESHAPE_TEST_CASE(i32) - default: - FAIL() << "We shouldn't get here."; + default: + FAIL() << "We shouldn't get here."; #undef RESHAPE_TEST_CASE } } else { if (isWithNonZero) { // fill tensor with all zero, so the NonZero op will create 0 shape as the input of reshape op - tensor = utils::create_and_fill_tensor(funcInput.get_element_type(), targetInputStaticShapes[i], 1, 0); + tensor = + utils::create_and_fill_tensor(funcInput.get_element_type(), targetInputStaticShapes[i], 1, 0); } else { if (funcInput.get_element_type().is_real()) { - tensor = utils::create_and_fill_tensor( - funcInput.get_element_type(), targetInputStaticShapes[i], 10, 0, 1000); + tensor = utils::create_and_fill_tensor(funcInput.get_element_type(), + targetInputStaticShapes[i], + 10, + 0, + 1000); } else { - tensor = utils::create_and_fill_tensor(funcInput.get_element_type(), targetInputStaticShapes[i]); + tensor = + utils::create_and_fill_tensor(funcInput.get_element_type(), targetInputStaticShapes[i]); } } } @@ -135,9 +134,9 @@ class ShapeOpsCPUTest : public testing::WithParamInterface, virt targetDevice = ov::test::utils::DEVICE_CPU; inputDescription inpDesc; - ngraph::helpers::InputLayerType secondType; + ov::test::utils::InputLayerType secondType; shapeNodeType nodeType; - Precision prc; + ov::element::Type prc; bool specialZero; std::tie(inpDesc, secondType, nodeType, prc, secondInPrc, specialZero) = this->GetParam(); @@ -147,23 +146,22 @@ class ShapeOpsCPUTest : public testing::WithParamInterface, virt // so the input of reshape is i32. selectedType = std::string("unknown_I32"); } else { - selectedType = std::string("unknown_") + prc.name(); + selectedType = std::string("unknown_") + prc.get_type_name(); } data = inpDesc.data; - - std::vector inputShapes = - {inpDesc.inputShape, InputShape{{static_cast(inpDesc.data[0].size())}, - std::vector(inpDesc.inputShape.second.size(), {inpDesc.data[0].size()})}}; + std::vector inputShapes = { + inpDesc.inputShape, + InputShape{{static_cast(inpDesc.data[0].size())}, + std::vector(inpDesc.inputShape.second.size(), {inpDesc.data[0].size()})}}; init_input_shapes(inputShapes); - auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(prc); - ov::ParameterVector inputs{std::make_shared(ngPrc, inputDynamicShapes.front())}; + ov::ParameterVector inputs{std::make_shared(prc, inputDynamicShapes.front())}; auto dataInput = inputs.front(); dataInput->set_friendly_name("param_1"); - std::shared_ptr secondaryInput; - if (secondType == ngraph::helpers::InputLayerType::PARAMETER) { + std::shared_ptr secondaryInput; + if (secondType == ov::test::utils::InputLayerType::PARAMETER) { auto param = std::make_shared(secondInPrc, inputDynamicShapes.back()); param->set_friendly_name("param_2"); secondaryInput = param; @@ -172,28 +170,28 @@ class ShapeOpsCPUTest : public testing::WithParamInterface, virt secondaryInput = ngraph::builder::makeConstant(secondInPrc, {inpDesc.data[0].size()}, inpDesc.data[0]); } - std::shared_ptr shapeOps; + std::shared_ptr shapeOps; switch (nodeType) { - case shapeNodeType::Reshape: { - shapeOps = std::make_shared(dataInput, secondaryInput, specialZero); - break; - } - case shapeNodeType::Squeeze: { - shapeOps = std::make_shared(dataInput, secondaryInput); - break; - } - case shapeNodeType::Unsqueeze: { - shapeOps = std::make_shared(dataInput, secondaryInput); - break; - } - case shapeNodeType::ReshapeWithNonZero: { - auto nonZero = std::make_shared(dataInput); - shapeOps = std::make_shared(nonZero, secondaryInput, specialZero); - break; - } + case shapeNodeType::Reshape: { + shapeOps = std::make_shared(dataInput, secondaryInput, specialZero); + break; + } + case shapeNodeType::Squeeze: { + shapeOps = std::make_shared(dataInput, secondaryInput); + break; + } + case shapeNodeType::Unsqueeze: { + shapeOps = std::make_shared(dataInput, secondaryInput); + break; + } + case shapeNodeType::ReshapeWithNonZero: { + auto nonZero = std::make_shared(dataInput); + shapeOps = std::make_shared(nonZero, secondaryInput, specialZero); + break; + } } - function = makeNgraphFunction(ngPrc, inputs, shapeOps, "ShapeOpsCPUTest"); + function = makeNgraphFunction(prc, inputs, shapeOps, "ShapeOpsCPUTest"); } private: @@ -211,92 +209,123 @@ TEST_P(ShapeOpsCPUTest, CompareWithRefs) { namespace reshapeTest { const std::vector secondInPrcs{ov::element::Type_t::i64, ov::element::Type_t::i32}; -inputDescription noBounds{{{-1, -1, -1, -1}, - {ngraph::Shape{2, 5, 7, 3}, ngraph::Shape{10, 6, 10, 5}, ngraph::Shape{10, 6, 10, 5}, ngraph::Shape{1, 2, 5, 5}}}, - {std::vector{1, -1, 0}, std::vector{-1, 60, 2}, std::vector{10, 30, 10}, std::vector{5, 10, -1}}}; +inputDescription noBounds{ + {{-1, -1, -1, -1}, + {ov::Shape{2, 5, 7, 3}, ov::Shape{10, 6, 10, 5}, ov::Shape{10, 6, 10, 5}, ov::Shape{1, 2, 5, 5}}}, + {std::vector{1, -1, 0}, + std::vector{-1, 60, 2}, + std::vector{10, 30, 10}, + std::vector{5, 10, -1}}}; const auto params = ::testing::Combine(::testing::Values(noBounds), - ::testing::Values(ngraph::helpers::InputLayerType::PARAMETER), + ::testing::Values(ov::test::utils::InputLayerType::PARAMETER), ::testing::Values(shapeNodeType::Reshape), - ::testing::Values(Precision::FP32), + ::testing::Values(ov::element::f32), ::testing::ValuesIn(secondInPrcs), ::testing::Values(true)); INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_dynamic, ShapeOpsCPUTest, params, ShapeOpsCPUTest::getTestCaseName); -inputDescription noBounds_const{{{{1, 10}, {2, 6}, {1, 15}, {3, 11}}, - {ngraph::Shape{2, 5, 7, 3}, ngraph::Shape{10, 6, 10, 5}, ngraph::Shape{1, 2, 5, 5}}}, - {std::vector{2, -1, 0}}}; +inputDescription noBounds_const{ + {{{1, 10}, {2, 6}, {1, 15}, {3, 11}}, {ov::Shape{2, 5, 7, 3}, ov::Shape{10, 6, 10, 5}, ov::Shape{1, 2, 5, 5}}}, + {std::vector{2, -1, 0}}}; const auto params_const = ::testing::Combine(::testing::Values(noBounds_const), - ::testing::Values(ngraph::helpers::InputLayerType::CONSTANT), + ::testing::Values(ov::test::utils::InputLayerType::CONSTANT), ::testing::Values(shapeNodeType::Reshape), - ::testing::Values(Precision::FP32), + ::testing::Values(ov::element::f32), ::testing::ValuesIn(secondInPrcs), ::testing::Values(true)); -INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_dynamic_const, ShapeOpsCPUTest, params_const, ShapeOpsCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_dynamic_const, + ShapeOpsCPUTest, + params_const, + ShapeOpsCPUTest::getTestCaseName); -inputDescription shape_dynBatch{{{{1, 10}, 5, 7, 3}, - {ngraph::Shape{2, 5, 7, 3}, ngraph::Shape{10, 5, 7, 3}, ngraph::Shape{1, 5, 7, 3}}}, - {std::vector{-1, 15, 7}}}; +inputDescription shape_dynBatch{ + {{{1, 10}, 5, 7, 3}, {ov::Shape{2, 5, 7, 3}, ov::Shape{10, 5, 7, 3}, ov::Shape{1, 5, 7, 3}}}, + {std::vector{-1, 15, 7}}}; const auto params_dynBatch = ::testing::Combine(::testing::Values(shape_dynBatch), - ::testing::Values(ngraph::helpers::InputLayerType::CONSTANT), + ::testing::Values(ov::test::utils::InputLayerType::CONSTANT), ::testing::Values(shapeNodeType::Reshape), - ::testing::Values(Precision::FP32), + ::testing::Values(ov::element::f32), ::testing::ValuesIn(secondInPrcs), ::testing::Values(true)); -INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_dynBatch, ShapeOpsCPUTest, params_dynBatch, ShapeOpsCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_dynBatch, + ShapeOpsCPUTest, + params_dynBatch, + ShapeOpsCPUTest::getTestCaseName); // test cases about NonZero connect with reshape // the output shape of NonZero is {4. 0} // the output shapes of reshapes are {1, 0 ,4} {4, 0, 1} {2, 0, 2} -inputDescription shape_NonZero{{{-1, -1, -1, -1}, - {ngraph::Shape{4, 5, 7, 3}, ngraph::Shape{6, 3, 4, 8}, ngraph::Shape{2, 2, 3, 9}}}, - {std::vector{-1, 0, 4}, std::vector{0, 0, -1}, std::vector{2, 0, 2}}}; +inputDescription shape_NonZero{ + {{-1, -1, -1, -1}, {ov::Shape{4, 5, 7, 3}, ov::Shape{6, 3, 4, 8}, ov::Shape{2, 2, 3, 9}}}, + {std::vector{-1, 0, 4}, std::vector{0, 0, -1}, std::vector{2, 0, 2}}}; const auto params_NonZero = ::testing::Combine(::testing::Values(shape_NonZero), - ::testing::Values(ngraph::helpers::InputLayerType::PARAMETER), - ::testing::Values(shapeNodeType::ReshapeWithNonZero), - ::testing::Values(Precision::FP32), - ::testing::ValuesIn(secondInPrcs), - ::testing::Values(true)); + ::testing::Values(ov::test::utils::InputLayerType::PARAMETER), + ::testing::Values(shapeNodeType::ReshapeWithNonZero), + ::testing::Values(ov::element::f32), + ::testing::ValuesIn(secondInPrcs), + ::testing::Values(true)); -INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_NonZero, ShapeOpsCPUTest, params_NonZero, ShapeOpsCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_NonZero, + ShapeOpsCPUTest, + params_NonZero, + ShapeOpsCPUTest::getTestCaseName); // test cases about reshape with empty tensor -inputDescription shape_EmptyTensor{{{-1, 2, 2}, - {ngraph::Shape{0, 2, 2}, ngraph::Shape{2, 2, 2}}}, - {std::vector{0, 4}, std::vector{2, 4}}}; +inputDescription shape_EmptyTensor{{{-1, 2, 2}, {ov::Shape{0, 2, 2}, ov::Shape{2, 2, 2}}}, + {std::vector{0, 4}, std::vector{2, 4}}}; const auto params_EmptyTensor = ::testing::Combine(::testing::Values(shape_EmptyTensor), - ::testing::Values(ngraph::helpers::InputLayerType::PARAMETER), - ::testing::Values(shapeNodeType::Reshape), - ::testing::Values(Precision::FP32), - ::testing::ValuesIn(secondInPrcs), - ::testing::Values(false)); - -INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_EmptyTensor, ShapeOpsCPUTest, params_EmptyTensor, ShapeOpsCPUTest::getTestCaseName); - -} // namespace reshapeTest + ::testing::Values(ov::test::utils::InputLayerType::PARAMETER), + ::testing::Values(shapeNodeType::Reshape), + ::testing::Values(ov::element::f32), + ::testing::ValuesIn(secondInPrcs), + ::testing::Values(false)); + +INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_EmptyTensor, + ShapeOpsCPUTest, + params_EmptyTensor, + ShapeOpsCPUTest::getTestCaseName); + +// test cases about NeedShapeInfer return right result +inputDescription shape_NeedShapeInfer{ + {{-1, -1}, {ov::Shape{640, 80}, ov::Shape{640, 80}, ov::Shape{1280, 40}, ov::Shape{1280, 40}}}, + {std::vector{320, 160}, std::vector{640, 80}, std::vector{320, 160}, std::vector{640, 80}}}; + +const auto params_NeedShapeInfer = ::testing::Combine(::testing::Values(shape_NeedShapeInfer), + ::testing::Values(ov::test::utils::InputLayerType::PARAMETER), + ::testing::Values(shapeNodeType::Reshape), + ::testing::Values(ov::element::f32), + ::testing::ValuesIn(secondInPrcs), + ::testing::Values(false)); + +INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_NeedShapeInfer, + ShapeOpsCPUTest, + params_NeedShapeInfer, + ShapeOpsCPUTest::getTestCaseName); + +} // namespace reshapeTest namespace squeezeTest { const std::vector secondInPrcs{ov::element::Type_t::i64, ov::element::Type_t::i32}; -inputDescription noBounds{{{-1, -1, -1, -1, -1, -1}, - { - ngraph::Shape{2, 5, 1, 7, 3, 1}, - ngraph::Shape{10, 1, 1, 6, 10, 5}, - ngraph::Shape{10, 6, 10, 5, 1, 1}, - ngraph::Shape{1, 1, 5, 1, 5} - }}, - {std::vector{2, 5}, std::vector{1, 2}, std::vector{4, 5}, std::vector{0, 1}}}; +inputDescription noBounds{ + {{-1, -1, -1, -1, -1, -1}, + {ov::Shape{2, 5, 1, 7, 3, 1}, + ov::Shape{10, 1, 1, 6, 10, 5}, + ov::Shape{10, 6, 10, 5, 1, 1}, + ov::Shape{1, 1, 5, 1, 5}}}, + {std::vector{2, 5}, std::vector{1, 2}, std::vector{4, 5}, std::vector{0, 1}}}; const auto params = ::testing::Combine(::testing::Values(noBounds), - ::testing::Values(ngraph::helpers::InputLayerType::PARAMETER), + ::testing::Values(ov::test::utils::InputLayerType::PARAMETER), ::testing::Values(shapeNodeType::Squeeze), - ::testing::Values(Precision::FP32), + ::testing::Values(ov::element::f32), ::testing::ValuesIn(secondInPrcs), ::testing::Values(true)); @@ -304,31 +333,35 @@ const auto params = ::testing::Combine(::testing::Values(noBounds), // enable after CPU plug-in will support dynamic rank // INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_dynamic, ShapeOpsCPUTest, params, ShapeOpsCPUTest::getTestCaseName); -inputDescription noBounds_const{{{{1, 10}, {1, 15}, {2, 6}, {1, 15}, {3, 11}, {1, 15}}, - {ngraph::Shape{2, 1, 5, 7, 3, 1}, ngraph::Shape{10, 1, 6, 10, 5, 1}, ngraph::Shape{1, 1, 2, 5, 5, 1}}}, - {std::vector{1, 5}}}; +inputDescription noBounds_const{ + {{{1, 10}, {1, 15}, {2, 6}, {1, 15}, {3, 11}, {1, 15}}, + {ov::Shape{2, 1, 5, 7, 3, 1}, ov::Shape{10, 1, 6, 10, 5, 1}, ov::Shape{1, 1, 2, 5, 5, 1}}}, + {std::vector{1, 5}}}; const auto params_const = ::testing::Combine(::testing::Values(noBounds_const), - ::testing::Values(ngraph::helpers::InputLayerType::CONSTANT), + ::testing::Values(ov::test::utils::InputLayerType::CONSTANT), ::testing::Values(shapeNodeType::Squeeze), - ::testing::Values(Precision::FP32), + ::testing::Values(ov::element::f32), ::testing::ValuesIn(secondInPrcs), ::testing::Values(true)); -INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_dynamic_const, ShapeOpsCPUTest, params_const, ShapeOpsCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_dynamic_const, + ShapeOpsCPUTest, + params_const, + ShapeOpsCPUTest::getTestCaseName); -} // namespace squeezeTest +} // namespace squeezeTest namespace unsqueezeTest { const std::vector secondInPrcs{ov::element::Type_t::i64, ov::element::Type_t::i32}; -inputDescription noBounds{{{-1, -1, -1, -1}, - {ngraph::Shape{2, 5, 7, 3}, ngraph::Shape{10, 6, 10, 5}, ngraph::Shape{10, 6, 10, 5}, ngraph::Shape{5, 1, 5}}}, - {std::vector{2, 5}, std::vector{1, 2}, std::vector{4, 5}, std::vector{0, 1}}}; +inputDescription noBounds{ + {{-1, -1, -1, -1}, {ov::Shape{2, 5, 7, 3}, ov::Shape{10, 6, 10, 5}, ov::Shape{10, 6, 10, 5}, ov::Shape{5, 1, 5}}}, + {std::vector{2, 5}, std::vector{1, 2}, std::vector{4, 5}, std::vector{0, 1}}}; const auto params = ::testing::Combine(::testing::Values(noBounds), - ::testing::Values(ngraph::helpers::InputLayerType::PARAMETER), + ::testing::Values(ov::test::utils::InputLayerType::PARAMETER), ::testing::Values(shapeNodeType::Unsqueeze), - ::testing::Values(Precision::FP32), + ::testing::Values(ov::element::f32), ::testing::ValuesIn(secondInPrcs), ::testing::Values(true)); @@ -336,19 +369,23 @@ const auto params = ::testing::Combine(::testing::Values(noBounds), // enable after CPU plug-in will support dynamic rank // INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_dynamic, ShapeOpsCPUTest, params, ShapeOpsCPUTest::getTestCaseName); -inputDescription noBounds_const{{{{1, 10}, {1, 15}, {2, 20}, {3, 7}}, - {ngraph::Shape{2, 5, 7, 3}, ngraph::Shape{10, 6, 10, 5}, ngraph::Shape{1, 2, 5, 5}}}, - {std::vector{1, 3}}}; +inputDescription noBounds_const{ + {{{1, 10}, {1, 15}, {2, 20}, {3, 7}}, {ov::Shape{2, 5, 7, 3}, ov::Shape{10, 6, 10, 5}, ov::Shape{1, 2, 5, 5}}}, + {std::vector{1, 3}}}; const auto params_const = ::testing::Combine(::testing::Values(noBounds_const), - ::testing::Values(ngraph::helpers::InputLayerType::CONSTANT), + ::testing::Values(ov::test::utils::InputLayerType::CONSTANT), ::testing::Values(shapeNodeType::Unsqueeze), - ::testing::Values(Precision::FP32), + ::testing::Values(ov::element::f32), ::testing::ValuesIn(secondInPrcs), ::testing::Values(true)); -INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_dynamic_const, ShapeOpsCPUTest, params_const, ShapeOpsCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_dynamic_const, + ShapeOpsCPUTest, + params_const, + ShapeOpsCPUTest::getTestCaseName); -} // namespace unsqueezeTest +} // namespace unsqueezeTest -} // namespace CPULayerTestsDefinitions +} // namespace test +} // namespace ov diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/shapeof.cpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/shapeof.cpp index 3daef205663526..8759fda78154c3 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/shapeof.cpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/shapeof.cpp @@ -2,34 +2,31 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "test_utils/cpu_test_utils.hpp" - #include "ov_models/builders.hpp" #include "ov_models/utils/ov_helpers.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" +#include "test_utils/cpu_test_utils.hpp" -using namespace InferenceEngine; using namespace CPUTestUtils; using InputShape = ov::test::InputShape; using ElementType = ov::element::Type_t; -namespace CPULayerTestsDefinitions { -typedef std::tuple< - InputShape, - ElementType // Net precision -> ShapeOfLayerTestParams; +namespace ov { +namespace test { +typedef std::tuple + ShapeOfLayerTestParams; -typedef std::tuple< - ShapeOfLayerTestParams, - CPUSpecificParams -> ShapeOfLayerCPUTestParamsSet; +typedef std::tuple ShapeOfLayerCPUTestParamsSet; class ShapeOfLayerCPUTest : public testing::WithParamInterface, - virtual public ov::test::SubgraphBaseTest, public CPUTestsBase { + virtual public ov::test::SubgraphBaseTest, + public CPUTestsBase { public: static std::string getTestCaseName(testing::TestParamInfo obj) { - CPULayerTestsDefinitions::ShapeOfLayerTestParams basicParamsSet; + ShapeOfLayerTestParams basicParamsSet; CPUSpecificParams cpuParams; std::tie(basicParamsSet, cpuParams) = obj.param; ElementType netPr; @@ -50,11 +47,12 @@ class ShapeOfLayerCPUTest : public testing::WithParamInterfaceGetParam(); std::tie(inFmts, outFmts, priority, selectedType) = cpuParams; @@ -72,7 +70,7 @@ class ShapeOfLayerCPUTest : public testing::WithParamInterface(inType, shape)); - auto shapeOf = std::make_shared(params.front(), ngraph::element::i32); + auto shapeOf = std::make_shared(params.front(), ov::element::i32); function = makeNgraphFunction(netPrecision, params, shapeOf, "ShapeOf"); } @@ -85,69 +83,41 @@ TEST_P(ShapeOfLayerCPUTest, CompareWithRefs) { namespace { -const std::vector netPrecisions = { - ElementType::f32, - ElementType::bf16, - ElementType::i32, - ElementType::i8 -}; +const std::vector netPrecisions = {ElementType::f32, ElementType::bf16, ElementType::i32, ElementType::i8}; -std::vector inShapesDynamic3d = { - { - {-1, -1, -1}, - { - { 8, 16, 4 }, - { 8, 16, 3 }, - { 8, 16, 2 } - } - } -}; +std::vector inShapesDynamic3d = {{{-1, -1, -1}, {{8, 16, 4}, {8, 16, 3}, {8, 16, 2}}}}; std::vector inShapesDynamic4d = { - { - {-1, -1, -1, -1}, - { - { 8, 16, 3, 4 }, - { 8, 16, 3, 3 }, - { 8, 16, 3, 2 } - } - }, + {{-1, -1, -1, -1}, {{8, 16, 3, 4}, {8, 16, 3, 3}, {8, 16, 3, 2}}}, }; std::vector inShapesDynamic5d = { - { - { -1, -1, -1, -1, -1 }, - { - { 8, 16, 3, 2, 4 }, - { 8, 16, 3, 2, 3 }, - { 8, 16, 3, 2, 2 } - } - } -}; -const auto params5dDynamic = ::testing::Combine( - ::testing::Combine( - ::testing::ValuesIn(inShapesDynamic5d), - ::testing::ValuesIn(netPrecisions)), - ::testing::Values(emptyCPUSpec)); - -const auto params4dDynamic = ::testing::Combine( - ::testing::Combine( - ::testing::ValuesIn(inShapesDynamic4d), - ::testing::ValuesIn(netPrecisions)), - ::testing::Values(emptyCPUSpec)); - -const auto params3dDynamic = ::testing::Combine( - ::testing::Combine( - ::testing::ValuesIn(inShapesDynamic3d), - ::testing::ValuesIn(netPrecisions)), - ::testing::Values(emptyCPUSpec)); + {{-1, -1, -1, -1, -1}, {{8, 16, 3, 2, 4}, {8, 16, 3, 2, 3}, {8, 16, 3, 2, 2}}}}; +const auto params5dDynamic = + ::testing::Combine(::testing::Combine(::testing::ValuesIn(inShapesDynamic5d), ::testing::ValuesIn(netPrecisions)), + ::testing::Values(emptyCPUSpec)); + +const auto params4dDynamic = + ::testing::Combine(::testing::Combine(::testing::ValuesIn(inShapesDynamic4d), ::testing::ValuesIn(netPrecisions)), + ::testing::Values(emptyCPUSpec)); + +const auto params3dDynamic = + ::testing::Combine(::testing::Combine(::testing::ValuesIn(inShapesDynamic3d), ::testing::ValuesIn(netPrecisions)), + ::testing::Values(emptyCPUSpec)); // We don't check static case, because of constant folding -INSTANTIATE_TEST_SUITE_P(smoke_ShapeOf3dDynamicLayoutTest, ShapeOfLayerCPUTest, - params3dDynamic, ShapeOfLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_SUITE_P(smoke_ShapeOf4dDynamicLayoutTest, ShapeOfLayerCPUTest, - params4dDynamic, ShapeOfLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_SUITE_P(smoke_ShapeOf5dDynamicLayoutTest, ShapeOfLayerCPUTest, - params5dDynamic, ShapeOfLayerCPUTest::getTestCaseName); -} // namespace -} // namespace CPULayerTestsDefinitions +INSTANTIATE_TEST_SUITE_P(smoke_ShapeOf3dDynamicLayoutTest, + ShapeOfLayerCPUTest, + params3dDynamic, + ShapeOfLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_ShapeOf4dDynamicLayoutTest, + ShapeOfLayerCPUTest, + params4dDynamic, + ShapeOfLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_ShapeOf5dDynamicLayoutTest, + ShapeOfLayerCPUTest, + params5dDynamic, + ShapeOfLayerCPUTest::getTestCaseName); +} // namespace +} // namespace test +} // namespace ov diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/shuffle_channels.cpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/shuffle_channels.cpp index 385cee23a7fb1d..3518e6fc543a22 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/shuffle_channels.cpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/shuffle_channels.cpp @@ -3,26 +3,23 @@ // #include "shared_test_classes/single_layer/shuffle_channels.hpp" -#include "test_utils/cpu_test_utils.hpp" -#include "ov_models/builders.hpp" + #include "ov_models/utils/ov_helpers.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" +#include "test_utils/cpu_test_utils.hpp" -using namespace InferenceEngine; using namespace CPUTestUtils; -using namespace ngraph::opset3; -using namespace ov::test; +namespace ov { +namespace test { -namespace CPULayerTestsDefinitions { - -using ShuffleChannelsLayerCPUTestParamsSet = std::tuple< - InputShape, // Input shape - ElementType, // Input element type - LayerTestsDefinitions::shuffleChannelsSpecificParams, - CPUSpecificParams>; +using ShuffleChannelsLayerCPUTestParamsSet = std::tuple; class ShuffleChannelsLayerCPUTest : public testing::WithParamInterface, - virtual public SubgraphBaseTest, public CPUTestsBase { + virtual public SubgraphBaseTest, + public CPUTestsBase { public: static std::string getTestCaseName(testing::TestParamInfo obj) { InputShape shapes; @@ -141,118 +138,106 @@ std::vector filterCPUInfoForDevice5DBlock() { } /* ========== */ -const std::vector inputElementType = { - ElementType::f32, - ElementType::bf16, - ElementType::i8 -}; +const std::vector inputElementType = {ElementType::f32, ElementType::bf16, ElementType::i8}; -const auto shuffleChannelsParams4D = ::testing::Combine( - ::testing::ValuesIn(std::vector{-4, -2, 0, 1, 3}), - ::testing::ValuesIn(std::vector{1, 2, 4}) -); +const auto shuffleChannelsParams4D = ::testing::Combine(::testing::ValuesIn(std::vector{-4, -2, 0, 1, 3}), + ::testing::ValuesIn(std::vector{1, 2, 4})); -const auto shuffleChannelsParams5D = ::testing::Combine( - ::testing::ValuesIn(std::vector{-5, -3, -1, 0, 1, 3}), - ::testing::ValuesIn(std::vector{1, 2, 3}) -); +const auto shuffleChannelsParams5D = ::testing::Combine(::testing::ValuesIn(std::vector{-5, -3, -1, 0, 1, 3}), + ::testing::ValuesIn(std::vector{1, 2, 3})); -const auto shuffleChannelsParams4DBlock = ::testing::Combine( - ::testing::ValuesIn(std::vector{-4, -2, -1, 0, 2, 3}), - ::testing::ValuesIn(std::vector{1, 2, 4}) -); +const auto shuffleChannelsParams4DBlock = ::testing::Combine(::testing::ValuesIn(std::vector{-4, -2, -1, 0, 2, 3}), + ::testing::ValuesIn(std::vector{1, 2, 4})); -const auto shuffleChannelsParams5DBlock = ::testing::Combine( - ::testing::ValuesIn(std::vector{-5, -2, -1, 0, 2, 3, 4}), - ::testing::ValuesIn(std::vector{1, 2, 3}) -); +const auto shuffleChannelsParams5DBlock = + ::testing::Combine(::testing::ValuesIn(std::vector{-5, -2, -1, 0, 2, 3, 4}), + ::testing::ValuesIn(std::vector{1, 2, 3})); const std::vector inputShapesDynamic4D = { - {{-1, -1, -1, -1}, - {{8, 4, 4, 4}, {8, 16, 8, 4}, {8, 4, 4, 4}}}, + {{-1, -1, -1, -1}, {{8, 4, 4, 4}, {8, 16, 8, 4}, {8, 4, 4, 4}}}, - {{-1, 8, -1, -1}, - {{8, 8, 8, 8}, {8, 8, 4, 16}, {8, 8, 8, 8}}}, + {{-1, 8, -1, -1}, {{8, 8, 8, 8}, {8, 8, 4, 16}, {8, 8, 8, 8}}}, - {{{4, 32}, {4, 32}, {4, 32}, {4, 32}}, - {{4, 12, 8, 8}, {8, 32, 12, 4}, {4, 12, 8, 8}}}, + {{{4, 32}, {4, 32}, {4, 32}, {4, 32}}, {{4, 12, 8, 8}, {8, 32, 12, 4}, {4, 12, 8, 8}}}, }; const std::vector inputShapesDynamic5D = { - {{-1, -1, -1, -1, -1}, - {{6, 6, 6, 6, 6}, {12, 6, 12, 12, 12}, {6, 6, 6, 6, 6}}}, + {{-1, -1, -1, -1, -1}, {{6, 6, 6, 6, 6}, {12, 6, 12, 12, 12}, {6, 6, 6, 6, 6}}}, - {{-1, 18, -1, -1, -1}, - {{6, 18, 12, 6, 12}, {6, 18, 6, 6, 6}, {6, 18, 12, 6, 12}}}, + {{-1, 18, -1, -1, -1}, {{6, 18, 12, 6, 12}, {6, 18, 6, 6, 6}, {6, 18, 12, 6, 12}}}, - {{{6, 24}, {6, 24}, {6, 24}, {6, 24}, {6, 24}}, - {{24, 12, 6, 6, 6}, {12, 24, 6, 12, 12}, {24, 12, 6, 6, 6}}}, + {{{6, 24}, {6, 24}, {6, 24}, {6, 24}, {6, 24}}, {{24, 12, 6, 6, 6}, {12, 24, 6, 12, 12}, {24, 12, 6, 6, 6}}}, }; -INSTANTIATE_TEST_SUITE_P(smoke_ShuffleChannelsStatic4D, ShuffleChannelsLayerCPUTest, - ::testing::Combine( - ::testing::ValuesIn(static_shapes_to_test_representation({{16, 24, 32, 40}})), - ::testing::ValuesIn(inputElementType), - shuffleChannelsParams4D, - ::testing::ValuesIn(filterCPUInfoForDevice4D())), - ShuffleChannelsLayerCPUTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_ShuffleChannelsDynamic4D, ShuffleChannelsLayerCPUTest, - ::testing::Combine( - ::testing::ValuesIn(inputShapesDynamic4D), - ::testing::ValuesIn(inputElementType), - shuffleChannelsParams4D, - ::testing::ValuesIn(filterCPUInfoForDevice4D())), - ShuffleChannelsLayerCPUTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_ShuffleChannelsStatic5D, ShuffleChannelsLayerCPUTest, - ::testing::Combine( - ::testing::ValuesIn(static_shapes_to_test_representation({{6, 24, 12, 12, 6}})), - ::testing::ValuesIn(inputElementType), - shuffleChannelsParams5D, - ::testing::ValuesIn(filterCPUInfoForDevice5D())), - ShuffleChannelsLayerCPUTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_ShuffleChannelsDynamic5D, ShuffleChannelsLayerCPUTest, - ::testing::Combine( - ::testing::ValuesIn(inputShapesDynamic5D), - ::testing::ValuesIn(inputElementType), - shuffleChannelsParams5D, - ::testing::ValuesIn(filterCPUInfoForDevice5D())), - ShuffleChannelsLayerCPUTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_ShuffleChannelsStatic4DBlock, ShuffleChannelsLayerCPUTest, - ::testing::Combine( - ::testing::ValuesIn(static_shapes_to_test_representation({{40, 32, 24, 16}})), - ::testing::ValuesIn(inputElementType), - shuffleChannelsParams4DBlock, - ::testing::ValuesIn(filterCPUInfoForDevice4DBlock())), +INSTANTIATE_TEST_SUITE_P( + smoke_ShuffleChannelsStatic4D, + ShuffleChannelsLayerCPUTest, + ::testing::Combine(::testing::ValuesIn(static_shapes_to_test_representation({{16, 24, 32, 40}})), + ::testing::ValuesIn(inputElementType), + shuffleChannelsParams4D, + ::testing::ValuesIn(filterCPUInfoForDevice4D())), + ShuffleChannelsLayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_ShuffleChannelsDynamic4D, + ShuffleChannelsLayerCPUTest, + ::testing::Combine(::testing::ValuesIn(inputShapesDynamic4D), + ::testing::ValuesIn(inputElementType), + shuffleChannelsParams4D, + ::testing::ValuesIn(filterCPUInfoForDevice4D())), ShuffleChannelsLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_SUITE_P(smoke_ShuffleChannelsDynamic4DBlock, ShuffleChannelsLayerCPUTest, - ::testing::Combine( - ::testing::ValuesIn(inputShapesDynamic4D), - ::testing::ValuesIn(inputElementType), - shuffleChannelsParams4DBlock, - ::testing::ValuesIn(filterCPUInfoForDevice4DBlock())), +INSTANTIATE_TEST_SUITE_P( + smoke_ShuffleChannelsStatic5D, + ShuffleChannelsLayerCPUTest, + ::testing::Combine(::testing::ValuesIn(static_shapes_to_test_representation({{6, 24, 12, 12, 6}})), + ::testing::ValuesIn(inputElementType), + shuffleChannelsParams5D, + ::testing::ValuesIn(filterCPUInfoForDevice5D())), + ShuffleChannelsLayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_ShuffleChannelsDynamic5D, + ShuffleChannelsLayerCPUTest, + ::testing::Combine(::testing::ValuesIn(inputShapesDynamic5D), + ::testing::ValuesIn(inputElementType), + shuffleChannelsParams5D, + ::testing::ValuesIn(filterCPUInfoForDevice5D())), ShuffleChannelsLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_SUITE_P(smoke_ShuffleChannelsStatic5DBlock, ShuffleChannelsLayerCPUTest, - ::testing::Combine( - ::testing::ValuesIn(static_shapes_to_test_representation({{18, 12, 18, 12, 30}})), - ::testing::ValuesIn(inputElementType), - shuffleChannelsParams5DBlock, - ::testing::ValuesIn(filterCPUInfoForDevice5DBlock())), +INSTANTIATE_TEST_SUITE_P( + smoke_ShuffleChannelsStatic4DBlock, + ShuffleChannelsLayerCPUTest, + ::testing::Combine(::testing::ValuesIn(static_shapes_to_test_representation({{40, 32, 24, 16}})), + ::testing::ValuesIn(inputElementType), + shuffleChannelsParams4DBlock, + ::testing::ValuesIn(filterCPUInfoForDevice4DBlock())), + ShuffleChannelsLayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_ShuffleChannelsDynamic4DBlock, + ShuffleChannelsLayerCPUTest, + ::testing::Combine(::testing::ValuesIn(inputShapesDynamic4D), + ::testing::ValuesIn(inputElementType), + shuffleChannelsParams4DBlock, + ::testing::ValuesIn(filterCPUInfoForDevice4DBlock())), ShuffleChannelsLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_SUITE_P(smoke_ShuffleChannelsDynamic5DBlock, ShuffleChannelsLayerCPUTest, - ::testing::Combine( - ::testing::ValuesIn(inputShapesDynamic5D), - ::testing::ValuesIn(inputElementType), - shuffleChannelsParams5DBlock, - ::testing::ValuesIn(filterCPUInfoForDevice5DBlock())), +INSTANTIATE_TEST_SUITE_P( + smoke_ShuffleChannelsStatic5DBlock, + ShuffleChannelsLayerCPUTest, + ::testing::Combine(::testing::ValuesIn(static_shapes_to_test_representation({{18, 12, 18, 12, 30}})), + ::testing::ValuesIn(inputElementType), + shuffleChannelsParams5DBlock, + ::testing::ValuesIn(filterCPUInfoForDevice5DBlock())), + ShuffleChannelsLayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_ShuffleChannelsDynamic5DBlock, + ShuffleChannelsLayerCPUTest, + ::testing::Combine(::testing::ValuesIn(inputShapesDynamic5D), + ::testing::ValuesIn(inputElementType), + shuffleChannelsParams5DBlock, + ::testing::ValuesIn(filterCPUInfoForDevice5DBlock())), ShuffleChannelsLayerCPUTest::getTestCaseName); -} // namespace +} // namespace -} // namespace CPULayerTestsDefinitions +} // namespace test +} // namespace ov diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/slice.cpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/slice.cpp index 02907dba518f40..45b68a6c8379e6 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/slice.cpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/slice.cpp @@ -2,38 +2,37 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "ov_models/builders.hpp" -#include "test_utils/cpu_test_utils.hpp" -#include "shared_test_classes/base/ov_subgraph.hpp" #include +#include "shared_test_classes/base/ov_subgraph.hpp" +#include "test_utils/cpu_test_utils.hpp" + using namespace CPUTestUtils; using namespace ov::test; -namespace CPULayerTestsDefinitions { - struct Slice8SpecificParams { - std::vector start; - std::vector stop; - std::vector step; - std::vector axes; + std::vector start; + std::vector stop; + std::vector step; + std::vector axes; }; -typedef std::tuple< - std::vector, // Parameters shapes - Slice8SpecificParams, // Slice-8 specific parameters - ngraph::helpers::InputLayerType, // Secondary input types - ElementType, // Network precision - CPUSpecificParams // CPU specific parameters -> Slice8LayerTestCPUParam; +typedef std::tuple, // Parameters shapes + Slice8SpecificParams, // Slice-8 specific parameters + ov::test::utils::InputLayerType, // Secondary input types + ElementType, // Network precision + CPUSpecificParams // CPU specific parameters + > + Slice8LayerTestCPUParam; class Slice8LayerCPUTest : public testing::WithParamInterface, - virtual public SubgraphBaseTest, public CPUTestsBase { + virtual public SubgraphBaseTest, + public CPUTestsBase { public: static std::string getTestCaseName(testing::TestParamInfo obj) { std::vector shapes; Slice8SpecificParams params; - ngraph::helpers::InputLayerType secondaryInputType; + ov::test::utils::InputLayerType secondaryInputType; ElementType netPrecision; CPUSpecificParams cpuParams; std::tie(shapes, params, secondaryInputType, netPrecision, cpuParams) = obj.param; @@ -49,10 +48,10 @@ class Slice8LayerCPUTest : public testing::WithParamInterface& targetInputStaticShapes) override { - std::vector inputValues = {sliceParams.start.data(), sliceParams.stop.data(), sliceParams.step.data(), sliceParams.axes.data()}; + void generate_inputs(const std::vector& targetInputStaticShapes) override { + std::vector inputValues = {sliceParams.start.data(), + sliceParams.stop.data(), + sliceParams.step.data(), + sliceParams.axes.data()}; inputs.clear(); const auto& funcInputs = function->inputs(); @@ -71,16 +73,20 @@ class Slice8LayerCPUTest : public testing::WithParamInterface shapes; - ngraph::helpers::InputLayerType secondaryInputType; + ov::test::utils::InputLayerType secondaryInputType; ElementType netPrecision; CPUSpecificParams cpuParams; std::tie(shapes, sliceParams, secondaryInputType, netPrecision, cpuParams) = this->GetParam(); @@ -102,42 +108,50 @@ class Slice8LayerCPUTest : public testing::WithParamInterface(netPrecision, shape)); } - std::shared_ptr sliceNode; - if (secondaryInputType == ngraph::helpers::InputLayerType::PARAMETER) { + std::shared_ptr sliceNode; + if (secondaryInputType == ov::test::utils::InputLayerType::PARAMETER) { // Slice start, stop, step, axes are parameters. - auto startNode = std::make_shared(ov::element::i64, ov::Shape{sliceParams.start.size()}); - auto stopdNode = std::make_shared(ov::element::i64, ov::Shape{sliceParams.stop.size()}); - auto stepNode = std::make_shared(ov::element::i64, ov::Shape{sliceParams.step.size()}); - - params.push_back(std::dynamic_pointer_cast(startNode)); - params.push_back(std::dynamic_pointer_cast(stopdNode)); - params.push_back(std::dynamic_pointer_cast(stepNode)); + auto startNode = + std::make_shared(ov::element::i64, ov::Shape{sliceParams.start.size()}); + auto stopdNode = + std::make_shared(ov::element::i64, ov::Shape{sliceParams.stop.size()}); + auto stepNode = + std::make_shared(ov::element::i64, ov::Shape{sliceParams.step.size()}); + + params.push_back(std::dynamic_pointer_cast(startNode)); + params.push_back(std::dynamic_pointer_cast(stopdNode)); + params.push_back(std::dynamic_pointer_cast(stepNode)); if (!sliceParams.axes.empty()) { // With axes parameter - auto axesNode = std::make_shared(ov::element::i64, ov::Shape{sliceParams.axes.size()}); - params.push_back(std::dynamic_pointer_cast(axesNode)); + auto axesNode = + std::make_shared(ov::element::i64, ov::Shape{sliceParams.axes.size()}); + params.push_back(std::dynamic_pointer_cast(axesNode)); sliceNode = std::make_shared(params[0], startNode, stopdNode, stepNode, axesNode); } else { - //without axes parameter + // without axes parameter sliceNode = std::make_shared(params[0], startNode, stopdNode, stepNode); } - } else if (secondaryInputType == ngraph::helpers::InputLayerType::CONSTANT) { + } else if (secondaryInputType == ov::test::utils::InputLayerType::CONSTANT) { // Slice start, stop, step, axes are const. ov::Shape constShape = {sliceParams.start.size()}; - auto beginNode = std::make_shared(ov::element::i64, constShape, sliceParams.start.data()); - auto endNode = std::make_shared(ov::element::i64, constShape, sliceParams.stop.data()); - auto strideNode = std::make_shared(ov::element::i64, constShape, sliceParams.step.data()); + auto beginNode = + std::make_shared(ov::element::i64, constShape, sliceParams.start.data()); + auto endNode = + std::make_shared(ov::element::i64, constShape, sliceParams.stop.data()); + auto strideNode = + std::make_shared(ov::element::i64, constShape, sliceParams.step.data()); if (!sliceParams.axes.empty()) { // With axes parameter - auto axesNode = std::make_shared(ov::element::i64, constShape, sliceParams.axes.data()); + auto axesNode = + std::make_shared(ov::element::i64, constShape, sliceParams.axes.data()); sliceNode = std::make_shared(params[0], beginNode, endNode, strideNode, axesNode); } else { - //without axes parameter + // without axes parameter sliceNode = std::make_shared(params[0], beginNode, endNode, strideNode); } } else { // Not supported others. - OPENVINO_THROW("Slice8LayerCPUTest: Unsupported ngraph::helpers::InputLayerType , value: ", + OPENVINO_THROW("Slice8LayerCPUTest: Unsupported ov::test::utils::InputLayerType , value: ", secondaryInputType); } @@ -153,437 +167,378 @@ TEST_P(Slice8LayerCPUTest, CompareWithRefs) { namespace { -const std::vector inputLayerTypes = { - ngraph::helpers::InputLayerType::CONSTANT, - ngraph::helpers::InputLayerType::PARAMETER -}; - -const auto cpuParams_nChw16c = CPUSpecificParams {{nChw16c}, {nChw16c}, {}, {}}; -const auto cpuParams_nCdhw16c = CPUSpecificParams {{nCdhw16c}, {nCdhw16c}, {}, {}}; - -const auto cpuParams_nChw8c = CPUSpecificParams {{nChw8c}, {nChw8c}, {}, {}}; -const auto cpuParams_nCdhw8c = CPUSpecificParams {{nCdhw8c}, {nCdhw8c}, {}, {}}; - -const auto cpuParams_nhwc = CPUSpecificParams {{nhwc}, {nhwc}, {}, {}}; -const auto cpuParams_ndhwc = CPUSpecificParams {{ndhwc}, {ndhwc}, {}, {}}; - -const auto cpuParams_nchw = CPUSpecificParams {{nchw}, {nchw}, {}, {}}; -const auto cpuParams_ncdhw = CPUSpecificParams {{ncdhw}, {ncdhw}, {}, {}}; - -const std::vector inputPrecisions = { - ElementType::f32, - ElementType::bf16, - ElementType::i8 -}; - -const std::vector> inputShapesDynamic2D = { - { - { // Origin dynamic shape - {-1, -1}, - { // Dynamic shapes instances - {32, 20}, {16, 16}, {24, 16} - } - } - }, - { - { // Origin dynamic shape - {-1, 16}, - { // Dynamic shapes instances - {16, 16}, {20, 16}, {32, 16} - } - } - }, - { - { // Origin dynamic shape - { {16, 32}, {16, 32} }, - { // Dynamic shapes instances - {16, 32}, {32, 16}, {24, 24} - } - } - } -}; - -const std::vector paramsPlain2D = { - Slice8SpecificParams{ { 0, 10 }, { 16, 16 }, { 1, 1 }, { 0, 1 } }, - Slice8SpecificParams{ { 2, 5 }, { 16, 8 }, { 1, 1 }, { } }, - Slice8SpecificParams{ { 2, 5 }, { 16, 16 }, { 1, 2 }, { 0, 1 } }, - Slice8SpecificParams{ { 0, 0 }, { 16, 16 }, { 1, 2 }, { 1, 0} }, - Slice8SpecificParams{ { 0 }, { 16 }, { 2 }, { 0 } }, - Slice8SpecificParams{ { 0 }, { 16 }, { 1 }, { 1 } } -}; - -INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_Plain_Static_2D, Slice8LayerCPUTest, - ::testing::Combine( - ::testing::Values(static_shapes_to_test_representation({{32, 20}})), - ::testing::ValuesIn(paramsPlain2D), - ::testing::Values(ngraph::helpers::InputLayerType::CONSTANT), - ::testing::ValuesIn(inputPrecisions), - ::testing::Values(emptyCPUSpec)), - Slice8LayerCPUTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_Plain_Dynamic_2D, Slice8LayerCPUTest, - ::testing::Combine( - ::testing::ValuesIn(inputShapesDynamic2D), - ::testing::ValuesIn(paramsPlain2D), - ::testing::Values(ngraph::helpers::InputLayerType::CONSTANT), - ::testing::ValuesIn(inputPrecisions), - ::testing::Values(emptyCPUSpec)), - Slice8LayerCPUTest::getTestCaseName); +const std::vector inputLayerTypes = {ov::test::utils::InputLayerType::CONSTANT, + ov::test::utils::InputLayerType::PARAMETER}; + +const auto cpuParams_nChw16c = CPUSpecificParams{{nChw16c}, {nChw16c}, {}, {}}; +const auto cpuParams_nCdhw16c = CPUSpecificParams{{nCdhw16c}, {nCdhw16c}, {}, {}}; + +const auto cpuParams_nChw8c = CPUSpecificParams{{nChw8c}, {nChw8c}, {}, {}}; +const auto cpuParams_nCdhw8c = CPUSpecificParams{{nCdhw8c}, {nCdhw8c}, {}, {}}; + +const auto cpuParams_nhwc = CPUSpecificParams{{nhwc}, {nhwc}, {}, {}}; +const auto cpuParams_ndhwc = CPUSpecificParams{{ndhwc}, {ndhwc}, {}, {}}; + +const auto cpuParams_nchw = CPUSpecificParams{{nchw}, {nchw}, {}, {}}; +const auto cpuParams_ncdhw = CPUSpecificParams{{ncdhw}, {ncdhw}, {}, {}}; + +const std::vector inputPrecisions = {ElementType::f32, ElementType::bf16, ElementType::i8}; + +const std::vector> inputShapesDynamic2D = {{{// Origin dynamic shape + {-1, -1}, + {// Dynamic shapes instances + {32, 20}, + {16, 16}, + {24, 16}}}}, + {{// Origin dynamic shape + {-1, 16}, + {// Dynamic shapes instances + {16, 16}, + {20, 16}, + {32, 16}}}}, + {{// Origin dynamic shape + {{16, 32}, {16, 32}}, + {// Dynamic shapes instances + {16, 32}, + {32, 16}, + {24, 24}}}}}; + +const std::vector paramsPlain2D = {Slice8SpecificParams{{0, 10}, {16, 16}, {1, 1}, {0, 1}}, + Slice8SpecificParams{{2, 5}, {16, 8}, {1, 1}, {}}, + Slice8SpecificParams{{2, 5}, {16, 16}, {1, 2}, {0, 1}}, + Slice8SpecificParams{{0, 0}, {16, 16}, {1, 2}, {1, 0}}, + Slice8SpecificParams{{0}, {16}, {2}, {0}}, + Slice8SpecificParams{{0}, {16}, {1}, {1}}}; + +INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_Plain_Static_2D, + Slice8LayerCPUTest, + ::testing::Combine(::testing::Values(static_shapes_to_test_representation({{32, 20}})), + ::testing::ValuesIn(paramsPlain2D), + ::testing::Values(ov::test::utils::InputLayerType::CONSTANT), + ::testing::ValuesIn(inputPrecisions), + ::testing::Values(emptyCPUSpec)), + Slice8LayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_Plain_Dynamic_2D, + Slice8LayerCPUTest, + ::testing::Combine(::testing::ValuesIn(inputShapesDynamic2D), + ::testing::ValuesIn(paramsPlain2D), + ::testing::Values(ov::test::utils::InputLayerType::CONSTANT), + ::testing::ValuesIn(inputPrecisions), + ::testing::Values(emptyCPUSpec)), + Slice8LayerCPUTest::getTestCaseName); const std::vector testCasesCommon4D = { - Slice8SpecificParams{ { 0, 2, 5, 4 }, { 1, 4, 28, 27 }, { 1, 1, 1, 1 }, { } }, - Slice8SpecificParams{ { 0, 1, 0, 0 }, { 20, 3, 32, 1 }, { 1, 1, 1, 1 }, { 3, 1, 2, 0 } }, - Slice8SpecificParams{ { 0, 0, 10, 0 }, { 1, 3, 20, 20 }, { 1, 1, 1, 1 }, { } }, - Slice8SpecificParams{ { 0, 0, 20, 20 }, { 1, 5, 26, 25 }, { 1, 1, 2, 1 }, { 0, 1, 3, 2 } }, - Slice8SpecificParams{ { 0, 0, 0, 20 }, { 1, 2, 30, 30 }, { 1, 1, 2, 1 }, { } }, - Slice8SpecificParams{ { 0, 0, 2, 10 }, { 1, 3, 32, 20 }, { 1, 1, 1, 1 }, { 0, 1, 2, 3 } }, - Slice8SpecificParams{ { 0, 1, 0, 10 }, { 1, 5, 32, 30 }, { 1, 1, 1, 1 }, { } }, - Slice8SpecificParams{ { 0, 1, 2, 10 }, { 1, 5, 32, 18 }, { 1, 1, 1, 2 }, { 0, 1, 2, 3 } }, - Slice8SpecificParams{ { 0, 0, 2, 10 }, { 1, 8, 32, 18 }, { 1, 2, 1, 2 }, { } }, - Slice8SpecificParams{ { 0, 0, 10 }, { 2, 32, 18 }, { 1, 1, 1 }, { 1, 2, 3 } }, - Slice8SpecificParams{ { 0, 10 }, { 2, 32 }, { 1, 1 }, { 1, 3 } } -}; - -const std::vector> inputShapesStatic4D = { - {{ 1, 5, 32, 32 }}, {{ 2, 5, 32, 48 }} -}; - -const std::vector> inputShapesDynamic4D = { - { - { // Origin dynamic shape - {-1, -1, -1, -1}, - { // Dynamic shapes instances - { 1, 5, 32, 32 }, { 2, 5, 32, 32 }, { 1, 5, 64, 64 } - } - } - }, - { - { // Origin dynamic shape - {-1, 5, -1, -1}, - { // Dynamic shapes instances - { 1, 5, 32, 32 }, { 2, 5, 32, 32 }, { 3, 5, 32, 36 } - } - } - }, - { - { // Origin dynamic shape - {{1, 5}, 5, {32, 64}, {32, 64}}, - { // Dynamic shapes instances - { 2, 5, 32, 32 }, { 1, 5, 48, 32 }, { 5, 5, 32, 32 } - } - } - } -}; + Slice8SpecificParams{{0, 2, 5, 4}, {1, 4, 28, 27}, {1, 1, 1, 1}, {}}, + Slice8SpecificParams{{0, 1, 0, 0}, {20, 3, 32, 1}, {1, 1, 1, 1}, {3, 1, 2, 0}}, + Slice8SpecificParams{{0, 0, 10, 0}, {1, 3, 20, 20}, {1, 1, 1, 1}, {}}, + Slice8SpecificParams{{0, 0, 20, 20}, {1, 5, 26, 25}, {1, 1, 2, 1}, {0, 1, 3, 2}}, + Slice8SpecificParams{{0, 0, 0, 20}, {1, 2, 30, 30}, {1, 1, 2, 1}, {}}, + Slice8SpecificParams{{0, 0, 2, 10}, {1, 3, 32, 20}, {1, 1, 1, 1}, {0, 1, 2, 3}}, + Slice8SpecificParams{{0, 1, 0, 10}, {1, 5, 32, 30}, {1, 1, 1, 1}, {}}, + Slice8SpecificParams{{0, 1, 2, 10}, {1, 5, 32, 18}, {1, 1, 1, 2}, {0, 1, 2, 3}}, + Slice8SpecificParams{{0, 0, 2, 10}, {1, 8, 32, 18}, {1, 2, 1, 2}, {}}, + Slice8SpecificParams{{0, 0, 10}, {2, 32, 18}, {1, 1, 1}, {1, 2, 3}}, + Slice8SpecificParams{{0, 10}, {2, 32}, {1, 1}, {1, 3}}}; + +const std::vector> inputShapesStatic4D = {{{1, 5, 32, 32}}, {{2, 5, 32, 48}}}; + +const std::vector> inputShapesDynamic4D = {{{// Origin dynamic shape + {-1, -1, -1, -1}, + {// Dynamic shapes instances + {1, 5, 32, 32}, + {2, 5, 32, 32}, + {1, 5, 64, 64}}}}, + {{// Origin dynamic shape + {-1, 5, -1, -1}, + {// Dynamic shapes instances + {1, 5, 32, 32}, + {2, 5, 32, 32}, + {3, 5, 32, 36}}}}, + {{// Origin dynamic shape + {{1, 5}, 5, {32, 64}, {32, 64}}, + {// Dynamic shapes instances + {2, 5, 32, 32}, + {1, 5, 48, 32}, + {5, 5, 32, 32}}}}}; const std::vector CPUParamsCommon4D = { - cpuParams_nchw, - cpuParams_nhwc, + cpuParams_nchw, + cpuParams_nhwc, }; -INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_Common_Static_4D, Slice8LayerCPUTest, - ::testing::Combine( - ::testing::ValuesIn(static_shapes_to_test_representation(inputShapesStatic4D)), - ::testing::ValuesIn(testCasesCommon4D), - ::testing::Values(ngraph::helpers::InputLayerType::CONSTANT), - ::testing::ValuesIn(inputPrecisions), - ::testing::ValuesIn(CPUParamsCommon4D)), - Slice8LayerCPUTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_Common_Dynamic_4D, Slice8LayerCPUTest, - ::testing::Combine( - ::testing::ValuesIn(inputShapesDynamic4D), - ::testing::ValuesIn(testCasesCommon4D), - ::testing::ValuesIn(inputLayerTypes), - ::testing::ValuesIn(inputPrecisions), - ::testing::ValuesIn(CPUParamsCommon4D)), - Slice8LayerCPUTest::getTestCaseName); - +INSTANTIATE_TEST_SUITE_P( + smoke_CompareWithRefs_Common_Static_4D, + Slice8LayerCPUTest, + ::testing::Combine(::testing::ValuesIn(static_shapes_to_test_representation(inputShapesStatic4D)), + ::testing::ValuesIn(testCasesCommon4D), + ::testing::Values(ov::test::utils::InputLayerType::CONSTANT), + ::testing::ValuesIn(inputPrecisions), + ::testing::ValuesIn(CPUParamsCommon4D)), + Slice8LayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_Common_Dynamic_4D, + Slice8LayerCPUTest, + ::testing::Combine(::testing::ValuesIn(inputShapesDynamic4D), + ::testing::ValuesIn(testCasesCommon4D), + ::testing::ValuesIn(inputLayerTypes), + ::testing::ValuesIn(inputPrecisions), + ::testing::ValuesIn(CPUParamsCommon4D)), + Slice8LayerCPUTest::getTestCaseName); const std::vector testCasesBlocked4DSubset1 = { - Slice8SpecificParams{ { 0, 0, 0, 0 }, { 1, 32, 32, 32 }, { 1, 1, 1, 1 }, { } }, - Slice8SpecificParams{ { 0, 0, 16, 0 }, { 1, 32, 32, 32 }, { 1, 1, 1, 1 }, { 0, 3, 2, 1 } }, - Slice8SpecificParams{ { 0, 0, 0 }, { 32, 32, 16 }, { 1, 1, 1 }, { } }, - Slice8SpecificParams{ { 0, 0, 0 }, { 16, 32, 32 }, { 1, 1, 1 }, { 1, 3, 2 } }, + Slice8SpecificParams{{0, 0, 0, 0}, {1, 32, 32, 32}, {1, 1, 1, 1}, {}}, + Slice8SpecificParams{{0, 0, 16, 0}, {1, 32, 32, 32}, {1, 1, 1, 1}, {0, 3, 2, 1}}, + Slice8SpecificParams{{0, 0, 0}, {32, 32, 16}, {1, 1, 1}, {}}, + Slice8SpecificParams{{0, 0, 0}, {16, 32, 32}, {1, 1, 1}, {1, 3, 2}}, }; const std::vector testCasesBlocked4DSubset2 = { - Slice8SpecificParams{ { 0, 0, 5, 4 }, { 1, 16, 28, 27 }, { 1, 1, 1, 1 }, { 0, 1, 2, 3 } }, - Slice8SpecificParams{ { 0, 16, 0, 0 }, { 1, 32, 10, 10 }, { 1, 1, 1, 1 }, { } }, - Slice8SpecificParams{ { 0, 0, 10, 0 }, { 16, 1, 20, 10 }, { 1, 1, 1, 1 }, { 1, 0, 2, 3 } }, - Slice8SpecificParams{ { 0, 0, 20, 20 }, { 1, 32, 25, 25 }, { 1, 1, 1, 1 }, { 0, 1, 3, 2 } }, - Slice8SpecificParams{ { 0, 16, 0, 20 }, { 32, 32, 1, 30 }, { 1, 1, 1, 2 }, { 2, 1, 0, 3 } }, - Slice8SpecificParams{ { 0, 16, 2, 10 }, { 1, 32, 32, 20 }, { 1, 1, 2, 1 }, { 0, 1, 2, 3 } }, - Slice8SpecificParams{ { 0, 16, 0, 0 }, { 2, 64, 32, 20 }, { 1, 1, 1, 1 }, { 0, 1, 2, 3 } }, - Slice8SpecificParams{ { 0, 32, 0, 0 }, { 2, 50, 32, 20 }, { 1, 1, 1, 1 }, { } }, - Slice8SpecificParams{ { 0, 0, 0, 0 }, { 32, 12, 2, 20 }, { 1, 1, 1, 1 }, { 0, 3, 2, 1 } }, - Slice8SpecificParams{ { 0, -16, 0, 10 }, { 2, 100, 32, 20 }, { 1, 1, 1, 1 }, { } }, - Slice8SpecificParams{ { 0, -16, 0, 0 }, { 2, -4, 32, 20 }, { 1, 1, 1, 1 }, { } }, - Slice8SpecificParams{ { 0, -32, 0, 0 }, { 2, -12, 32, 20 }, { 1, 1, 1, 1 }, { } } -}; - -const std::vector> inputShapesBlockedStatic4DSubset1 = { - {{ 1, 32, 32, 32 }}, {{ 1, 32, 32, 64 }} -}; - -const std::vector> inputShapesBlockedStatic4DSubset2 = { - {{ 1, 64, 32, 32 }}, {{ 1, 64, 32, 64 }} -}; - -const std::vector> inputShapesBlockedDynamic4DSubset1 = { - { - { // Origin dynamic shape - {-1, 32, -1, -1}, - { // Dynamic shapes instances - { 1, 32, 32, 32 }, { 2, 32, 32, 32 }, { 3, 32, 32, 48 } - } - } - }, - { - { // Origin dynamic shape - {{1, 5}, 32, {32, 64}, {32, 64}}, - { // Dynamic shapes instances - { 2, 32, 32, 32 }, { 1, 32, 48, 32 }, { 5, 32, 32, 48 } - } - } - } -}; - -const std::vector> inputShapesBlockedDynamic4DSubset2 = { - { - { // Origin dynamic shape - {-1, 64, -1, -1}, - { // Dynamic shapes instances - { 1, 64, 64, 32 }, { 2, 64, 32, 32 }, { 3, 64, 32, 48 } - } - } - }, - { - { // Origin dynamic shape - {{1, 5}, 64, {32, 64}, {32, 64}}, - { // Dynamic shapes instances - { 2, 64, 32, 32 }, { 1, 64, 48, 32 }, { 1, 64, 64, 64 } - } - } - } -}; + Slice8SpecificParams{{0, 0, 5, 4}, {1, 16, 28, 27}, {1, 1, 1, 1}, {0, 1, 2, 3}}, + Slice8SpecificParams{{0, 16, 0, 0}, {1, 32, 10, 10}, {1, 1, 1, 1}, {}}, + Slice8SpecificParams{{0, 0, 10, 0}, {16, 1, 20, 10}, {1, 1, 1, 1}, {1, 0, 2, 3}}, + Slice8SpecificParams{{0, 0, 20, 20}, {1, 32, 25, 25}, {1, 1, 1, 1}, {0, 1, 3, 2}}, + Slice8SpecificParams{{0, 16, 0, 20}, {32, 32, 1, 30}, {1, 1, 1, 2}, {2, 1, 0, 3}}, + Slice8SpecificParams{{0, 16, 2, 10}, {1, 32, 32, 20}, {1, 1, 2, 1}, {0, 1, 2, 3}}, + Slice8SpecificParams{{0, 16, 0, 0}, {2, 64, 32, 20}, {1, 1, 1, 1}, {0, 1, 2, 3}}, + Slice8SpecificParams{{0, 32, 0, 0}, {2, 50, 32, 20}, {1, 1, 1, 1}, {}}, + Slice8SpecificParams{{0, 0, 0, 0}, {32, 12, 2, 20}, {1, 1, 1, 1}, {0, 3, 2, 1}}, + Slice8SpecificParams{{0, -16, 0, 10}, {2, 100, 32, 20}, {1, 1, 1, 1}, {}}, + Slice8SpecificParams{{0, -16, 0, 0}, {2, -4, 32, 20}, {1, 1, 1, 1}, {}}, + Slice8SpecificParams{{0, -32, 0, 0}, {2, -12, 32, 20}, {1, 1, 1, 1}, {}}}; + +const std::vector> inputShapesBlockedStatic4DSubset1 = {{{1, 32, 32, 32}}, {{1, 32, 32, 64}}}; + +const std::vector> inputShapesBlockedStatic4DSubset2 = {{{1, 64, 32, 32}}, {{1, 64, 32, 64}}}; + +const std::vector> inputShapesBlockedDynamic4DSubset1 = {{{// Origin dynamic shape + {-1, 32, -1, -1}, + {// Dynamic shapes instances + {1, 32, 32, 32}, + {2, 32, 32, 32}, + {3, 32, 32, 48}}}}, + {{// Origin dynamic shape + {{1, 5}, 32, {32, 64}, {32, 64}}, + {// Dynamic shapes instances + {2, 32, 32, 32}, + {1, 32, 48, 32}, + {5, 32, 32, 48}}}}}; + +const std::vector> inputShapesBlockedDynamic4DSubset2 = {{{// Origin dynamic shape + {-1, 64, -1, -1}, + {// Dynamic shapes instances + {1, 64, 64, 32}, + {2, 64, 32, 32}, + {3, 64, 32, 48}}}}, + {{// Origin dynamic shape + {{1, 5}, 64, {32, 64}, {32, 64}}, + {// Dynamic shapes instances + {2, 64, 32, 32}, + {1, 64, 48, 32}, + {1, 64, 64, 64}}}}}; const std::vector CPUParamsBlocked4D = { - cpuParams_nChw16c, - cpuParams_nChw8c, + cpuParams_nChw16c, + cpuParams_nChw8c, }; -INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_Common_Static_4D_Subset1, Slice8LayerCPUTest, - ::testing::Combine( - ::testing::ValuesIn(static_shapes_to_test_representation(inputShapesBlockedStatic4DSubset1)), - ::testing::ValuesIn(testCasesBlocked4DSubset1), - ::testing::Values(ngraph::helpers::InputLayerType::CONSTANT), - ::testing::ValuesIn(inputPrecisions), - ::testing::ValuesIn(CPUParamsBlocked4D)), +INSTANTIATE_TEST_SUITE_P( + smoke_CompareWithRefs_Common_Static_4D_Subset1, + Slice8LayerCPUTest, + ::testing::Combine(::testing::ValuesIn(static_shapes_to_test_representation(inputShapesBlockedStatic4DSubset1)), + ::testing::ValuesIn(testCasesBlocked4DSubset1), + ::testing::Values(ov::test::utils::InputLayerType::CONSTANT), + ::testing::ValuesIn(inputPrecisions), + ::testing::ValuesIn(CPUParamsBlocked4D)), + Slice8LayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_Common_Dynamic_4D_Subset1, + Slice8LayerCPUTest, + ::testing::Combine(::testing::ValuesIn(inputShapesBlockedDynamic4DSubset1), + ::testing::ValuesIn(testCasesBlocked4DSubset1), + ::testing::Values(ov::test::utils::InputLayerType::CONSTANT), + ::testing::ValuesIn(inputPrecisions), + ::testing::ValuesIn(CPUParamsBlocked4D)), Slice8LayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_Common_Dynamic_4D_Subset1, Slice8LayerCPUTest, - ::testing::Combine( - ::testing::ValuesIn(inputShapesBlockedDynamic4DSubset1), - ::testing::ValuesIn(testCasesBlocked4DSubset1), - ::testing::Values(ngraph::helpers::InputLayerType::CONSTANT), - ::testing::ValuesIn(inputPrecisions), - ::testing::ValuesIn(CPUParamsBlocked4D)), +INSTANTIATE_TEST_SUITE_P( + smoke_CompareWithRefs_Common_Static_4D_Subset2, + Slice8LayerCPUTest, + ::testing::Combine(::testing::ValuesIn(static_shapes_to_test_representation(inputShapesBlockedStatic4DSubset2)), + ::testing::ValuesIn(testCasesBlocked4DSubset2), + ::testing::Values(ov::test::utils::InputLayerType::CONSTANT), + ::testing::ValuesIn(inputPrecisions), + ::testing::ValuesIn(CPUParamsBlocked4D)), + Slice8LayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_Common_Dynamic_4D_Subset2, + Slice8LayerCPUTest, + ::testing::Combine(::testing::ValuesIn(inputShapesBlockedDynamic4DSubset2), + ::testing::ValuesIn(testCasesBlocked4DSubset2), + ::testing::Values(ov::test::utils::InputLayerType::CONSTANT), + ::testing::ValuesIn(inputPrecisions), + ::testing::ValuesIn(CPUParamsBlocked4D)), Slice8LayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_Common_Static_4D_Subset2, Slice8LayerCPUTest, - ::testing::Combine( - ::testing::ValuesIn(static_shapes_to_test_representation(inputShapesBlockedStatic4DSubset2)), - ::testing::ValuesIn(testCasesBlocked4DSubset2), - ::testing::Values(ngraph::helpers::InputLayerType::CONSTANT), - ::testing::ValuesIn(inputPrecisions), - ::testing::ValuesIn(CPUParamsBlocked4D)), - Slice8LayerCPUTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_Common_Dynamic_4D_Subset2, Slice8LayerCPUTest, - ::testing::Combine( - ::testing::ValuesIn(inputShapesBlockedDynamic4DSubset2), - ::testing::ValuesIn(testCasesBlocked4DSubset2), - ::testing::Values(ngraph::helpers::InputLayerType::CONSTANT), - ::testing::ValuesIn(inputPrecisions), - ::testing::ValuesIn(CPUParamsBlocked4D)), - Slice8LayerCPUTest::getTestCaseName); - - const std::vector testCasesCommon5D = { - Slice8SpecificParams{ { 0, 2, 0, 5, 4 }, { 1, 4, 5, 28, 27 }, { 1, 1, 1, 1, 1 }, { 0, 1, 2, 3, 4 } }, - Slice8SpecificParams{ { 0, 0, 10, 0, 0 }, { 1, 5, 20, 32, 20 }, { 1, 1, 1, 1, 1 }, { } }, - Slice8SpecificParams{ { 0, 1, 10, 0, 0 }, { 20, 3, 20, 32, 1 }, { 1, 1, 1, 1, 1 }, { 4, 1, 2, 3, 0 } }, - Slice8SpecificParams{ { 0, 20, 0, 0, 20 }, { 1, 30, 20, 5, 26 }, { 1, 1, 1, 2, 2 }, { 0, 3, 2, 1, 4 } }, - Slice8SpecificParams{ { 0, 0, 10, 0, 20 }, { 1, 2, 20, 30, 30 }, { 1, 1, 2, 1, 1 }, { } }, - Slice8SpecificParams{ { 0, 0, 2, 10, 0 }, { 1, 5, 10, 32, 20 }, { 1, 1, 1, 1, 1 }, { 0, 1, 2, 3, 4 } }, - Slice8SpecificParams{ { 0, 1, 0, 10, 0 }, { 1, 5, 20, 32, 32 }, { 1, 1, 1, 1, 1 }, { } }, - Slice8SpecificParams{ { 0, 0, 0, 0, 0 }, { 1, 5, 10, 16, 16 }, { 1, 1, 2, 1, 1 }, { 0, 1, 2, 3, 4 } } -}; - -const std::vector> inputShapesStatic5D = { - {{ 1, 5, 20, 32, 32 }}, {{ 2, 5, 32, 32, 32 }} -}; - -const std::vector> inputShapesDynamic5D = { - { - { // Origin dynamic shape - {-1, -1, -1, -1, -1}, - { // Dynamic shapes instances - { 1, 5, 32, 32, 32 }, { 1, 5, 32, 32, 48 }, { 1, 5, 64, 64, 64 }, { 1, 10, 32, 32, 32 } - } - } - }, - { - { // Origin dynamic shape - {-1, 5, -1, -1, -1}, - { // Dynamic shapes instances - { 1, 5, 32, 32, 48 }, { 1, 5, 32, 48, 32 }, { 1, 5, 48, 32, 32 } - } - } - }, - { - { // Origin dynamic shape - {{1, 5}, 5, {32, 64}, {32, 64}, {32, 64}}, - { // Dynamic shapes instances - { 2, 5, 32, 32, 32 }, { 1, 5, 48, 32, 32 }, { 5, 5, 32, 32, 48 } - } - } - } -}; + Slice8SpecificParams{{0, 2, 0, 5, 4}, {1, 4, 5, 28, 27}, {1, 1, 1, 1, 1}, {0, 1, 2, 3, 4}}, + Slice8SpecificParams{{0, 0, 10, 0, 0}, {1, 5, 20, 32, 20}, {1, 1, 1, 1, 1}, {}}, + Slice8SpecificParams{{0, 1, 10, 0, 0}, {20, 3, 20, 32, 1}, {1, 1, 1, 1, 1}, {4, 1, 2, 3, 0}}, + Slice8SpecificParams{{0, 20, 0, 0, 20}, {1, 30, 20, 5, 26}, {1, 1, 1, 2, 2}, {0, 3, 2, 1, 4}}, + Slice8SpecificParams{{0, 0, 10, 0, 20}, {1, 2, 20, 30, 30}, {1, 1, 2, 1, 1}, {}}, + Slice8SpecificParams{{0, 0, 2, 10, 0}, {1, 5, 10, 32, 20}, {1, 1, 1, 1, 1}, {0, 1, 2, 3, 4}}, + Slice8SpecificParams{{0, 1, 0, 10, 0}, {1, 5, 20, 32, 32}, {1, 1, 1, 1, 1}, {}}, + Slice8SpecificParams{{0, 0, 0, 0, 0}, {1, 5, 10, 16, 16}, {1, 1, 2, 1, 1}, {0, 1, 2, 3, 4}}}; + +const std::vector> inputShapesStatic5D = {{{1, 5, 20, 32, 32}}, {{2, 5, 32, 32, 32}}}; + +const std::vector> inputShapesDynamic5D = {{{// Origin dynamic shape + {-1, -1, -1, -1, -1}, + {// Dynamic shapes instances + {1, 5, 32, 32, 32}, + {1, 5, 32, 32, 48}, + {1, 5, 64, 64, 64}, + {1, 10, 32, 32, 32}}}}, + {{// Origin dynamic shape + {-1, 5, -1, -1, -1}, + {// Dynamic shapes instances + {1, 5, 32, 32, 48}, + {1, 5, 32, 48, 32}, + {1, 5, 48, 32, 32}}}}, + {{// Origin dynamic shape + {{1, 5}, 5, {32, 64}, {32, 64}, {32, 64}}, + {// Dynamic shapes instances + {2, 5, 32, 32, 32}, + {1, 5, 48, 32, 32}, + {5, 5, 32, 32, 48}}}}}; const std::vector CPUParamsCommon5D = { - cpuParams_ncdhw, - cpuParams_ndhwc, + cpuParams_ncdhw, + cpuParams_ndhwc, }; -INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_Common_Static_5D, Slice8LayerCPUTest, - ::testing::Combine( - ::testing::ValuesIn(static_shapes_to_test_representation(inputShapesStatic5D)), - ::testing::ValuesIn(testCasesCommon5D), - ::testing::Values(ngraph::helpers::InputLayerType::CONSTANT), - ::testing::ValuesIn(inputPrecisions), - ::testing::ValuesIn(CPUParamsCommon5D)), - Slice8LayerCPUTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_Common_Dynamic_5D, Slice8LayerCPUTest, - ::testing::Combine( - ::testing::ValuesIn(inputShapesDynamic5D), - ::testing::ValuesIn(testCasesCommon5D), - ::testing::ValuesIn(inputLayerTypes), - ::testing::ValuesIn(inputPrecisions), - ::testing::ValuesIn(CPUParamsCommon5D)), +INSTANTIATE_TEST_SUITE_P( + smoke_CompareWithRefs_Common_Static_5D, + Slice8LayerCPUTest, + ::testing::Combine(::testing::ValuesIn(static_shapes_to_test_representation(inputShapesStatic5D)), + ::testing::ValuesIn(testCasesCommon5D), + ::testing::Values(ov::test::utils::InputLayerType::CONSTANT), + ::testing::ValuesIn(inputPrecisions), + ::testing::ValuesIn(CPUParamsCommon5D)), + Slice8LayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_Common_Dynamic_5D, + Slice8LayerCPUTest, + ::testing::Combine(::testing::ValuesIn(inputShapesDynamic5D), + ::testing::ValuesIn(testCasesCommon5D), + ::testing::ValuesIn(inputLayerTypes), + ::testing::ValuesIn(inputPrecisions), + ::testing::ValuesIn(CPUParamsCommon5D)), Slice8LayerCPUTest::getTestCaseName); const std::vector testCasesBlocked5DSubset1 = { - Slice8SpecificParams{ { 0, 0, 0, 5, 4 }, { 1, 16, 5, 28, 27 }, { 1, 1, 1, 1, 1 }, { 0, 1, 2, 3, 4 } }, - Slice8SpecificParams{ { 0, 0, 10, 0, 0 }, { 1, 16, 20, 32, 20 }, { 1, 1, 1, 1, 1 }, { } }, - Slice8SpecificParams{ { 0, 0, 0, 20, 20 }, { 16, 1, 20, 26, 30 }, { 1, 1, 1, 2, 2 }, { 1, 0, 2, 4, 3 } }, - Slice8SpecificParams{ { 0, 0, 10, 0, 20 }, { 1, 16, 20, 30, 30 }, { 1, 1, 2, 1, 1 }, { } }, - Slice8SpecificParams{ { 0, 0, 2, 10, 0 }, { 1, 16, 10, 32, 20 }, { 1, 1, 1, 1, 1 }, { } }, - Slice8SpecificParams{ { 0, 0, 0, 10, 0 }, { 1, 8, 20, 32, 32 }, { 1, 1, 1, 1, 1 }, { } }, - Slice8SpecificParams{ { 0, 0, 0, 0, 0 }, { 1, 16, 10, 16, 16 }, { 1, 1, 2, 1, 1 }, { 0, 1, 2, 3, 4 } }, + Slice8SpecificParams{{0, 0, 0, 5, 4}, {1, 16, 5, 28, 27}, {1, 1, 1, 1, 1}, {0, 1, 2, 3, 4}}, + Slice8SpecificParams{{0, 0, 10, 0, 0}, {1, 16, 20, 32, 20}, {1, 1, 1, 1, 1}, {}}, + Slice8SpecificParams{{0, 0, 0, 20, 20}, {16, 1, 20, 26, 30}, {1, 1, 1, 2, 2}, {1, 0, 2, 4, 3}}, + Slice8SpecificParams{{0, 0, 10, 0, 20}, {1, 16, 20, 30, 30}, {1, 1, 2, 1, 1}, {}}, + Slice8SpecificParams{{0, 0, 2, 10, 0}, {1, 16, 10, 32, 20}, {1, 1, 1, 1, 1}, {}}, + Slice8SpecificParams{{0, 0, 0, 10, 0}, {1, 8, 20, 32, 32}, {1, 1, 1, 1, 1}, {}}, + Slice8SpecificParams{{0, 0, 0, 0, 0}, {1, 16, 10, 16, 16}, {1, 1, 2, 1, 1}, {0, 1, 2, 3, 4}}, }; const std::vector testCasesBlocked5DSubset2 = { - Slice8SpecificParams{ { 0, 0, 0, 5, 4 }, { 1, 16, 5, 28, 27 }, { 1, 1, 1, 1, 1 }, { 0, 1, 2, 3, 4 } }, - Slice8SpecificParams{ { 0, 0, 5, 4 }, { 16, 5, 28, 27 }, { 1, 1, 1, 1 }, { 1, 2, 3, 4 } }, - Slice8SpecificParams{ { 0, 0, 10, 0, 0 }, { 1, 16, 20, 32, 20 }, { 1, 1, 1, 1, 1 }, { 0, 1, 2, 3, 4 } }, - Slice8SpecificParams{ { 0, 0, 0, 20, 20 }, { 1, 20, 16, 30, 26 }, { 1, 1, 1, 2, 2 }, { 0, 2, 1, 3, 4 } }, - Slice8SpecificParams{ { 0, 0, 10, 0, 20 }, { 1, 16, 20, 30, 30 }, { 1, 1, 2, 1, 1 }, { 0, 1, 2, 3, 4 } }, - Slice8SpecificParams{ { 0, 0, 2, 10, 0 }, { 1, 16, 10, 32, 20 }, { 1, 1, 1, 1, 1 }, { 0, 1, 2, 3, 4 } }, - Slice8SpecificParams{ { 0, 0, 0, 10, 0 }, { 1, 8, 20, 32, 32 }, { 1, 1, 1, 1, 1 }, { 0, 1, 2, 3, 4 } }, - Slice8SpecificParams{ { 0, 0, 0, 0, 0 }, { 10, 16, 1, 16, 16 }, { 2, 1, 1, 1, 1 }, { 2, 1, 0, 3, 4 } }, - Slice8SpecificParams{ { 0, 0, 0, 0, 0 }, { 1, 25, 20, 10, 10 }, { 1, 1, 1, 1, 1 }, { } }, - Slice8SpecificParams{ { 0, 16, 0, 0, 0 }, { 1, 25, 20, 10, 10 }, { 1, 1, 1, 1, 1 }, { 0, 1, 2, 3, 4 } }, - Slice8SpecificParams{ { 0, 16, 0, 0, 0 }, { 1, 64, 20, 10, 10 }, { 1, 1, 1, 1, 1 }, { 0, 1, 2, 3, 4 } }, + Slice8SpecificParams{{0, 0, 0, 5, 4}, {1, 16, 5, 28, 27}, {1, 1, 1, 1, 1}, {0, 1, 2, 3, 4}}, + Slice8SpecificParams{{0, 0, 5, 4}, {16, 5, 28, 27}, {1, 1, 1, 1}, {1, 2, 3, 4}}, + Slice8SpecificParams{{0, 0, 10, 0, 0}, {1, 16, 20, 32, 20}, {1, 1, 1, 1, 1}, {0, 1, 2, 3, 4}}, + Slice8SpecificParams{{0, 0, 0, 20, 20}, {1, 20, 16, 30, 26}, {1, 1, 1, 2, 2}, {0, 2, 1, 3, 4}}, + Slice8SpecificParams{{0, 0, 10, 0, 20}, {1, 16, 20, 30, 30}, {1, 1, 2, 1, 1}, {0, 1, 2, 3, 4}}, + Slice8SpecificParams{{0, 0, 2, 10, 0}, {1, 16, 10, 32, 20}, {1, 1, 1, 1, 1}, {0, 1, 2, 3, 4}}, + Slice8SpecificParams{{0, 0, 0, 10, 0}, {1, 8, 20, 32, 32}, {1, 1, 1, 1, 1}, {0, 1, 2, 3, 4}}, + Slice8SpecificParams{{0, 0, 0, 0, 0}, {10, 16, 1, 16, 16}, {2, 1, 1, 1, 1}, {2, 1, 0, 3, 4}}, + Slice8SpecificParams{{0, 0, 0, 0, 0}, {1, 25, 20, 10, 10}, {1, 1, 1, 1, 1}, {}}, + Slice8SpecificParams{{0, 16, 0, 0, 0}, {1, 25, 20, 10, 10}, {1, 1, 1, 1, 1}, {0, 1, 2, 3, 4}}, + Slice8SpecificParams{{0, 16, 0, 0, 0}, {1, 64, 20, 10, 10}, {1, 1, 1, 1, 1}, {0, 1, 2, 3, 4}}, }; -const std::vector> inputShapesBlockedStatic5DSubset1 = { - {{ 1, 16, 32, 32, 32 }}, {{ 2, 16, 32, 32, 32 }}, {{ 2, 32, 32, 32, 32 }} -}; +const std::vector> inputShapesBlockedStatic5DSubset1 = {{{1, 16, 32, 32, 32}}, + {{2, 16, 32, 32, 32}}, + {{2, 32, 32, 32, 32}}}; -const std::vector> inputShapesBlockedStatic5DSubset2 = { - {{ 1, 64, 32, 32, 32 }}, {{ 2, 64, 32, 64, 32 }}, {{ 2, 64, 32, 32, 32 }} -}; +const std::vector> inputShapesBlockedStatic5DSubset2 = {{{1, 64, 32, 32, 32}}, + {{2, 64, 32, 64, 32}}, + {{2, 64, 32, 32, 32}}}; const std::vector> inputShapesBlockedDynamic5DSubset1 = { - { - { // Origin dynamic shape - {-1, 16, -1, -1, -1}, - { // Dynamic shapes instances - { 1, 16, 32, 32, 32 }, { 2, 16, 32, 32, 32 }, { 2, 16, 32, 32, 32 } - } - } - }, - { - { // Origin dynamic shape - {{1, 5}, 16, {16, 32}, {16, 32}, {16, 32}}, - { // Dynamic shapes instances - { 1, 16, 32, 32, 32 }, { 2, 16, 32, 32, 32 }, { 1, 16, 20, 32, 32 } - } - } - } -}; + {{// Origin dynamic shape + {-1, 16, -1, -1, -1}, + {// Dynamic shapes instances + {1, 16, 32, 32, 32}, + {2, 16, 32, 32, 32}, + {2, 16, 32, 32, 32}}}}, + {{// Origin dynamic shape + {{1, 5}, 16, {16, 32}, {16, 32}, {16, 32}}, + {// Dynamic shapes instances + {1, 16, 32, 32, 32}, + {2, 16, 32, 32, 32}, + {1, 16, 20, 32, 32}}}}}; const std::vector> inputShapesBlockedDynamic5DSubset2 = { { - { // Origin dynamic shape - {-1, 64, -1, -1, -1}, - { // Dynamic shapes instances - { 1, 64, 64, 32, 32 }, { 2, 64, 32, 32, 32 }, { 3, 64, 32, 48, 32 } - } - }, + {// Origin dynamic shape + {-1, 64, -1, -1, -1}, + {// Dynamic shapes instances + {1, 64, 64, 32, 32}, + {2, 64, 32, 32, 32}, + {3, 64, 32, 48, 32}}}, }, - { - { // Origin dynamic shape - {{1, 5}, 64, {16, 32}, {16, 32}, {16, 32}}, - { // Dynamic shapes instances - { 1, 64, 32, 32, 32 }, { 2, 64, 32, 32, 32 }, { 1, 64, 20, 32, 32 } - } - } - } -}; + {{// Origin dynamic shape + {{1, 5}, 64, {16, 32}, {16, 32}, {16, 32}}, + {// Dynamic shapes instances + {1, 64, 32, 32, 32}, + {2, 64, 32, 32, 32}, + {1, 64, 20, 32, 32}}}}}; const std::vector CPUParamsBlocked5D = { - cpuParams_nCdhw16c, - cpuParams_nCdhw8c, + cpuParams_nCdhw16c, + cpuParams_nCdhw8c, }; -INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_Common_Static_5D_Subset1, Slice8LayerCPUTest, - ::testing::Combine( - ::testing::ValuesIn(static_shapes_to_test_representation(inputShapesBlockedStatic5DSubset1)), - ::testing::ValuesIn(testCasesBlocked5DSubset1), - ::testing::Values(ngraph::helpers::InputLayerType::CONSTANT), - ::testing::ValuesIn(inputPrecisions), - ::testing::ValuesIn(CPUParamsBlocked5D)), - Slice8LayerCPUTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_Common_Dynamic_5D_Subset1, Slice8LayerCPUTest, - ::testing::Combine( - ::testing::ValuesIn(inputShapesBlockedDynamic5DSubset1), - ::testing::ValuesIn(testCasesBlocked5DSubset1), - ::testing::Values(ngraph::helpers::InputLayerType::CONSTANT), - ::testing::ValuesIn(inputPrecisions), - ::testing::ValuesIn(CPUParamsBlocked5D)), - Slice8LayerCPUTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_Common_Static_5D_Subset2, Slice8LayerCPUTest, - ::testing::Combine( - ::testing::ValuesIn(static_shapes_to_test_representation(inputShapesBlockedStatic4DSubset2)), - ::testing::ValuesIn(testCasesBlocked4DSubset2), - ::testing::Values(ngraph::helpers::InputLayerType::CONSTANT), - ::testing::ValuesIn(inputPrecisions), - ::testing::ValuesIn(CPUParamsBlocked4D)), +INSTANTIATE_TEST_SUITE_P( + smoke_CompareWithRefs_Common_Static_5D_Subset1, + Slice8LayerCPUTest, + ::testing::Combine(::testing::ValuesIn(static_shapes_to_test_representation(inputShapesBlockedStatic5DSubset1)), + ::testing::ValuesIn(testCasesBlocked5DSubset1), + ::testing::Values(ov::test::utils::InputLayerType::CONSTANT), + ::testing::ValuesIn(inputPrecisions), + ::testing::ValuesIn(CPUParamsBlocked5D)), + Slice8LayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_Common_Dynamic_5D_Subset1, + Slice8LayerCPUTest, + ::testing::Combine(::testing::ValuesIn(inputShapesBlockedDynamic5DSubset1), + ::testing::ValuesIn(testCasesBlocked5DSubset1), + ::testing::Values(ov::test::utils::InputLayerType::CONSTANT), + ::testing::ValuesIn(inputPrecisions), + ::testing::ValuesIn(CPUParamsBlocked5D)), Slice8LayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_Common_Dynamic_5D_Subset2, Slice8LayerCPUTest, - ::testing::Combine( - ::testing::ValuesIn(inputShapesBlockedDynamic5DSubset2), - ::testing::ValuesIn(testCasesBlocked5DSubset2), - ::testing::Values(ngraph::helpers::InputLayerType::CONSTANT), - ::testing::ValuesIn(inputPrecisions), - ::testing::ValuesIn(CPUParamsBlocked5D)), +INSTANTIATE_TEST_SUITE_P( + smoke_CompareWithRefs_Common_Static_5D_Subset2, + Slice8LayerCPUTest, + ::testing::Combine(::testing::ValuesIn(static_shapes_to_test_representation(inputShapesBlockedStatic4DSubset2)), + ::testing::ValuesIn(testCasesBlocked4DSubset2), + ::testing::Values(ov::test::utils::InputLayerType::CONSTANT), + ::testing::ValuesIn(inputPrecisions), + ::testing::ValuesIn(CPUParamsBlocked4D)), + Slice8LayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_Common_Dynamic_5D_Subset2, + Slice8LayerCPUTest, + ::testing::Combine(::testing::ValuesIn(inputShapesBlockedDynamic5DSubset2), + ::testing::ValuesIn(testCasesBlocked5DSubset2), + ::testing::Values(ov::test::utils::InputLayerType::CONSTANT), + ::testing::ValuesIn(inputPrecisions), + ::testing::ValuesIn(CPUParamsBlocked5D)), Slice8LayerCPUTest::getTestCaseName); /* Descriptors check */ @@ -597,44 +552,29 @@ TEST_P(Slice8LayerDescriptorCPUTest, DescriptorsCheck) { } const std::vector testCasesDescriptors = { - Slice8SpecificParams{ { 0, -4, 0, 0 }, { 0, 2147483647, 0, 0 }, { 1, 1, 1, 1 }, { 0, 1, 2, 3 } }, - Slice8SpecificParams{ { 0, 5, 0, 0 }, { 1, 20, 28, 27 }, { 1, 1, 1, 1 }, { 0, 1, 2, 3 } }, - Slice8SpecificParams{ { 0, 0, 0, 0 }, { 1, 2147483647, 32, 32 }, { 1, 2, 1, 1 }, { 0, 1, 2, 3 } } -}; - -const std::vector> inputShapesDescriptors = { - { - { {}, - { // Static shapes - { 1, 16, 32, 32 } - } - } - }, - { - { {}, - { // Static shapes - { 1, 17, 32, 32 } - } - } - }, - { - { // Origin dynamic shapes - {1, -1, 32, 32}, - { // Dynamic shapes instances - { 1, 16, 32, 32 }, { 1, 32, 32, 32 } - } - } - } -}; - -INSTANTIATE_TEST_SUITE_P(smoke_Slice8LayerDescriptorCPUTest, Slice8LayerDescriptorCPUTest, - ::testing::Combine( - ::testing::ValuesIn(inputShapesDescriptors), - ::testing::ValuesIn(testCasesDescriptors), - ::testing::Values(ngraph::helpers::InputLayerType::CONSTANT), - ::testing::Values(ElementType::f32), - ::testing::Values(cpuParams_nChw8c)), + Slice8SpecificParams{{0, -4, 0, 0}, {0, 2147483647, 0, 0}, {1, 1, 1, 1}, {0, 1, 2, 3}}, + Slice8SpecificParams{{0, 5, 0, 0}, {1, 20, 28, 27}, {1, 1, 1, 1}, {0, 1, 2, 3}}, + Slice8SpecificParams{{0, 0, 0, 0}, {1, 2147483647, 32, 32}, {1, 2, 1, 1}, {0, 1, 2, 3}}}; + +const std::vector> inputShapesDescriptors = {{{{}, + {// Static shapes + {1, 16, 32, 32}}}}, + {{{}, + {// Static shapes + {1, 17, 32, 32}}}}, + {{// Origin dynamic shapes + {1, -1, 32, 32}, + {// Dynamic shapes instances + {1, 16, 32, 32}, + {1, 32, 32, 32}}}}}; + +INSTANTIATE_TEST_SUITE_P(smoke_Slice8LayerDescriptorCPUTest, + Slice8LayerDescriptorCPUTest, + ::testing::Combine(::testing::ValuesIn(inputShapesDescriptors), + ::testing::ValuesIn(testCasesDescriptors), + ::testing::Values(ov::test::utils::InputLayerType::CONSTANT), + ::testing::Values(ElementType::f32), + ::testing::Values(cpuParams_nChw8c)), Slice8LayerDescriptorCPUTest::getTestCaseName); -} // namespace -} // namespace CPULayerTestsDefinitions +} // namespace \ No newline at end of file diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/space_to_batch.cpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/space_to_batch.cpp index 616474d3a4c299..710302cba87a54 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/space_to_batch.cpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/space_to_batch.cpp @@ -2,42 +2,41 @@ // SPDX-License-Identifier: Apache-2.0 // -#include -#include "shared_test_classes/base/ov_subgraph.hpp" +#include "common_test_utils/ov_tensor_utils.hpp" #include "ov_models/builders.hpp" +#include "shared_test_classes/base/ov_subgraph.hpp" #include "test_utils/cpu_test_utils.hpp" -using namespace InferenceEngine; using namespace CPUTestUtils; -using namespace ov::test; -namespace CPULayerTestsDefinitions { +namespace ov { +namespace test { namespace { - std::vector blockShape, padsBegin, padsEnd; - ov::Shape paramShape; +std::vector blockShape, padsBegin, padsEnd; +ov::Shape paramShape; } // namespace -using SpaceToBatchLayerTestCPUParams = std::tuple< - std::vector, // Input shapes - std::vector, // block shape - std::vector, // pads begin - std::vector, // pads end - Precision , // Network precision - CPUSpecificParams>; +using SpaceToBatchLayerTestCPUParams = std::tuple, // Input shapes + std::vector, // block shape + std::vector, // pads begin + std::vector, // pads end + ov::element::Type, // Network type + CPUSpecificParams>; class SpaceToBatchCPULayerTest : public testing::WithParamInterface, - virtual public SubgraphBaseTest, public CPUTestsBase { + virtual public SubgraphBaseTest, + public CPUTestsBase { public: - static std::string getTestCaseName(const testing::TestParamInfo &obj) { + static std::string getTestCaseName(const testing::TestParamInfo& obj) { std::vector inputShapes; - Precision netPrecision; + ov::element::Type netPrecision; CPUSpecificParams cpuParams; std::tie(inputShapes, blockShape, padsBegin, padsEnd, netPrecision, cpuParams) = obj.param; std::ostringstream result; if (inputShapes.front().first.size() != 0) { result << "IS=("; - for (const auto &shape : inputShapes) { + for (const auto& shape : inputShapes) { result << ov::test::utils::partialShape2str({shape.first}) << "_"; } result.seekp(-1, result.cur); @@ -52,7 +51,7 @@ class SpaceToBatchCPULayerTest : public testing::WithParamInterface(); + auto* dataPtr = tensor.data(); for (size_t j = 0; j < blockShape.size(); j++) { dataPtr[j] = blockShape[j]; } } else if (i == 2U) { tensor = ov::Tensor(funcInput.get_element_type(), paramShape); - auto *dataPtr = tensor.data(); + auto* dataPtr = tensor.data(); for (size_t j = 0; j < padsBegin.size(); j++) { dataPtr[j] = padsBegin[j]; } } else if (i == 3U) { tensor = ov::Tensor(funcInput.get_element_type(), paramShape); - auto *dataPtr = tensor.data(); + auto* dataPtr = tensor.data(); for (size_t j = 0; j < padsEnd.size(); j++) { dataPtr[j] = padsEnd[j]; } @@ -92,21 +95,20 @@ class SpaceToBatchCPULayerTest : public testing::WithParamInterface inputShapes; - Precision netPrecision; + ov::element::Type netPrecision; CPUSpecificParams cpuParams; std::tie(inputShapes, blockShape, padsBegin, padsEnd, netPrecision, cpuParams) = this->GetParam(); std::tie(inFmts, outFmts, priority, selectedType) = cpuParams; - auto ngPrec = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); const std::vector inputShapesVec{inputShapes}; init_input_shapes(inputShapesVec); - if (strcmp(netPrecision.name(), "U8") == 0) - selectedType = std::string("ref_any_") + "I8"; + if (strcmp(netPrecision.get_type_name().c_str(), "u8") == 0) + selectedType = std::string("ref_any_") + "i8"; else - selectedType = std::string("ref_any_") + netPrecision.name(); + selectedType = std::string("ref_any_") + netPrecision.get_type_name(); - ov::ParameterVector params{std::make_shared(ngPrec, inputDynamicShapes.front())}; + ov::ParameterVector params{std::make_shared(netPrecision, inputDynamicShapes.front())}; paramShape = {params[0]->get_partial_shape().size()}; std::shared_ptr in2, in3, in4; @@ -132,17 +134,15 @@ TEST_P(SpaceToBatchCPULayerTest, CompareWithRefs) { namespace { -const std::vector netPrecision = { - Precision::U8, - Precision::I8, - Precision::I32, - Precision::FP32, - Precision::BF16 -}; +const std::vector netPrecision = {ov::element::u8, + ov::element::i8, + ov::element::i32, + ov::element::f32, + ov::element::bf16}; const std::vector> blockShape4D1 = {{1, 2, 1, 2}, {1, 1, 2, 2}, {1, 2, 2, 2}}; const std::vector> padsBegin4D1 = {{0, 0, 0, 1}, {0, 0, 2, 1}, {0, 0, 4, 3}}; -const std::vector> padsEnd4D1 = {{0, 0, 0, 1}, {0, 0, 4, 1}, {0, 0, 2, 3}}; +const std::vector> padsEnd4D1 = {{0, 0, 0, 1}, {0, 0, 4, 1}, {0, 0, 2, 3}}; std::vector> staticInputShapes4D1 = { {{1, 16, 8, 12}, {4}, {4}, {4}}, @@ -150,233 +150,212 @@ std::vector> staticInputShapes4D1 = { }; std::vector> dynamicInputShapes4D1 = { - { - {{-1, -1, -1, -1}, {{1, 6, 4, 8}, {2, 4, 8, 10}, {1, 8, 4, 10}}}, - {{4}, {{4}, {4}, {4}}}, - {{4}, {{4}, {4}, {4}}}, - {{4}, {{4}, {4}, {4}}} - }, - { - {{{1, 4}, {2, 16}, 6, -1}, {{4, 8, 6, 4}, {1, 6, 6, 8}, {2, 12, 6, 4}}}, - {{4}, {{4}, {4}, {4}}}, - {{4}, {{4}, {4}, {4}}}, - {{4}, {{4}, {4}, {4}}} - } -}; + {{{-1, -1, -1, -1}, {{1, 6, 4, 8}, {2, 4, 8, 10}, {1, 8, 4, 10}}}, + {{4}, {{4}, {4}, {4}}}, + {{4}, {{4}, {4}, {4}}}, + {{4}, {{4}, {4}, {4}}}}, + {{{{1, 4}, {2, 16}, 6, -1}, {{4, 8, 6, 4}, {1, 6, 6, 8}, {2, 12, 6, 4}}}, + {{4}, {{4}, {4}, {4}}}, + {{4}, {{4}, {4}, {4}}}, + {{4}, {{4}, {4}, {4}}}}}; std::vector> dynamicInputShapes4D1Blocked = { - { - {{-1, 16, -1, -1}, {{1, 16, 4, 6}, {2, 16, 6, 6}, {4, 16, 4, 8}}}, - {{4}, {{4}, {4}, {4}}}, - {{4}, {{4}, {4}, {4}}}, - {{4}, {{4}, {4}, {4}}} - } -}; + {{{-1, 16, -1, -1}, {{1, 16, 4, 6}, {2, 16, 6, 6}, {4, 16, 4, 8}}}, + {{4}, {{4}, {4}, {4}}}, + {{4}, {{4}, {4}, {4}}}, + {{4}, {{4}, {4}, {4}}}}}; - -const std::vector> blockShape4D2 = { {1, 2, 4, 3}, {1, 4, 4, 1}}; +const std::vector> blockShape4D2 = {{1, 2, 4, 3}, {1, 4, 4, 1}}; const std::vector> padsBegin4D2 = {{0, 0, 0, 0}, {0, 0, 4, 3}}; -const std::vector> padsEnd4D2 = {{0, 0, 4, 0}, {0, 0, 4, 3}}; +const std::vector> padsEnd4D2 = {{0, 0, 4, 0}, {0, 0, 4, 3}}; std::vector> staticInputShapes4D2 = { - {{1, 16, 12, 12}, {4}, {4}, {4}}, - {{1, 32, 12, 15}, {4}, {4}, {4}}, + {{1, 16, 12, 12}, {4}, {4}, {4}}, + {{1, 32, 12, 15}, {4}, {4}, {4}}, }; std::vector> dynamicInputShapes4D2 = { - { - {{-1, -1, -1, -1}, {{1, 4, 8, 9}, {2, 8, 12, 9}, {6, 12, 4, 12}}}, - {{4}, {{4}, {4}, {4}}}, - {{4}, {{4}, {4}, {4}}}, - {{4}, {{4}, {4}, {4}}} - }, - { - {{2, {4, 16}, -1, -1}, {{2, 8, 4, 9}, {2, 4, 8, 6}, {2, 12, 12, 3}}}, - {{4}, {{4}, {4}, {4}}}, - {{4}, {{4}, {4}, {4}}}, - {{4}, {{4}, {4}, {4}}} - } -}; + {{{-1, -1, -1, -1}, {{1, 4, 8, 9}, {2, 8, 12, 9}, {6, 12, 4, 12}}}, + {{4}, {{4}, {4}, {4}}}, + {{4}, {{4}, {4}, {4}}}, + {{4}, {{4}, {4}, {4}}}}, + {{{2, {4, 16}, -1, -1}, {{2, 8, 4, 9}, {2, 4, 8, 6}, {2, 12, 12, 3}}}, + {{4}, {{4}, {4}, {4}}}, + {{4}, {{4}, {4}, {4}}}, + {{4}, {{4}, {4}, {4}}}}}; std::vector> dynamicInputShapes4D2Blocked = { - { - {{-1, 16, -1, -1}, {{2, 16, 4, 15}, {2, 16, 8, 12}, {3, 16, 12, 9}}}, - {{4}, {{4}, {4}, {4}}}, - {{4}, {{4}, {4}, {4}}}, - {{4}, {{4}, {4}, {4}}} - } -}; - -const std::vector cpuParamsWithBlock_4D = { - CPUSpecificParams({nChw16c}, {nChw16c}, {}, {}), - CPUSpecificParams({nChw8c}, {nChw8c}, {}, {}), - CPUSpecificParams({nhwc}, {nhwc}, {}, {}), - CPUSpecificParams({nchw}, {nchw}, {}, {}) -}; - -const std::vector cpuParams_4D = { - CPUSpecificParams({nhwc}, {nhwc}, {}, {}), - CPUSpecificParams({nchw}, {nchw}, {}, {}) -}; - -const auto staticSpaceToBatchParamsSet4D1 = ::testing::Combine( - ::testing::ValuesIn(static_shapes_to_test_representation(staticInputShapes4D1)), - ::testing::ValuesIn(blockShape4D1), - ::testing::ValuesIn(padsBegin4D1), - ::testing::ValuesIn(padsEnd4D1), - ::testing::ValuesIn(netPrecision), - ::testing::ValuesIn(cpuParams_4D)); - -const auto dynamicSpaceToBatchParamsSet4D1 = ::testing::Combine( - ::testing::ValuesIn(dynamicInputShapes4D1), - ::testing::ValuesIn(blockShape4D1), - ::testing::ValuesIn(padsBegin4D1), - ::testing::ValuesIn(padsEnd4D1), - ::testing::ValuesIn(netPrecision), - ::testing::ValuesIn(cpuParams_4D)); - -const auto dynamicSpaceToBatchParamsWithBlockedSet4D1 = ::testing::Combine( - ::testing::ValuesIn(dynamicInputShapes4D1Blocked), - ::testing::ValuesIn(blockShape4D1), - ::testing::ValuesIn(padsBegin4D1), - ::testing::ValuesIn(padsEnd4D1), - ::testing::ValuesIn(netPrecision), - ::testing::ValuesIn(cpuParamsWithBlock_4D)); - -const auto staticSpaceToBatchParamsSet4D2 = ::testing::Combine( - ::testing::ValuesIn(static_shapes_to_test_representation(staticInputShapes4D2)), - ::testing::ValuesIn(blockShape4D2), - ::testing::ValuesIn(padsBegin4D2), - ::testing::ValuesIn(padsEnd4D2), - ::testing::ValuesIn(netPrecision), - ::testing::ValuesIn(cpuParams_4D)); - -const auto dynamicSpaceToBatchParamsSet4D2 = ::testing::Combine( - ::testing::ValuesIn(dynamicInputShapes4D2), - ::testing::ValuesIn(blockShape4D2), - ::testing::ValuesIn(padsBegin4D2), - ::testing::ValuesIn(padsEnd4D2), - ::testing::ValuesIn(netPrecision), - ::testing::ValuesIn(cpuParams_4D)); - -const auto dynamicSpaceToBatchParamsWithBlockedSet4D2 = ::testing::Combine( - ::testing::ValuesIn(dynamicInputShapes4D2Blocked), - ::testing::ValuesIn(blockShape4D2), - ::testing::ValuesIn(padsBegin4D2), - ::testing::ValuesIn(padsEnd4D2), - ::testing::ValuesIn(netPrecision), - ::testing::ValuesIn(cpuParamsWithBlock_4D)); - -INSTANTIATE_TEST_SUITE_P(smoke_StaticSpaceToBatchCPULayerTestCase1_4D, SpaceToBatchCPULayerTest, - staticSpaceToBatchParamsSet4D1, SpaceToBatchCPULayerTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_DynamicSpaceToBatchCPULayerTestCase1_4D, SpaceToBatchCPULayerTest, - dynamicSpaceToBatchParamsSet4D1, SpaceToBatchCPULayerTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_DynamicSpaceToBatchCPULayerTestCaseWithBlocked1_4D, SpaceToBatchCPULayerTest, - dynamicSpaceToBatchParamsWithBlockedSet4D1, SpaceToBatchCPULayerTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_StaticSpaceToBatchCPULayerTestCase2_4D, SpaceToBatchCPULayerTest, - staticSpaceToBatchParamsSet4D2, SpaceToBatchCPULayerTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_DynamicSpaceToBatchCPULayerTestCase2_4D, SpaceToBatchCPULayerTest, - dynamicSpaceToBatchParamsSet4D2, SpaceToBatchCPULayerTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_DynamicSpaceToBatchCPULayerTestCaseWithBlocked2_4D, SpaceToBatchCPULayerTest, - dynamicSpaceToBatchParamsWithBlockedSet4D2, SpaceToBatchCPULayerTest::getTestCaseName); - -std::vector> staticInputShapes4DPE = { - {{1, 2, 9, 1}, {4}, {4}, {4}} -}; -INSTANTIATE_TEST_SUITE_P(smoke_StaticSpaceToBatch_4D_parallel_block_edge, SpaceToBatchCPULayerTest, - ::testing::Combine( - ::testing::ValuesIn(static_shapes_to_test_representation(staticInputShapes4DPE)), - ::testing::Values(std::vector{1, 4, 3, 1}), - ::testing::Values(std::vector{0, 1, 2, 0}), - ::testing::Values(std::vector{0, 1, 4, 0}), - ::testing::Values(Precision::FP32), - ::testing::Values(CPUSpecificParams{})), - SpaceToBatchCPULayerTest::getTestCaseName); + {{{-1, 16, -1, -1}, {{2, 16, 4, 15}, {2, 16, 8, 12}, {3, 16, 12, 9}}}, + {{4}, {{4}, {4}, {4}}}, + {{4}, {{4}, {4}, {4}}}, + {{4}, {{4}, {4}, {4}}}}}; + +const std::vector cpuParamsWithBlock_4D = {CPUSpecificParams({nChw16c}, {nChw16c}, {}, {}), + CPUSpecificParams({nChw8c}, {nChw8c}, {}, {}), + CPUSpecificParams({nhwc}, {nhwc}, {}, {}), + CPUSpecificParams({nchw}, {nchw}, {}, {})}; + +const std::vector cpuParams_4D = {CPUSpecificParams({nhwc}, {nhwc}, {}, {}), + CPUSpecificParams({nchw}, {nchw}, {}, {})}; + +const auto staticSpaceToBatchParamsSet4D1 = + ::testing::Combine(::testing::ValuesIn(static_shapes_to_test_representation(staticInputShapes4D1)), + ::testing::ValuesIn(blockShape4D1), + ::testing::ValuesIn(padsBegin4D1), + ::testing::ValuesIn(padsEnd4D1), + ::testing::ValuesIn(netPrecision), + ::testing::ValuesIn(cpuParams_4D)); + +const auto dynamicSpaceToBatchParamsSet4D1 = ::testing::Combine(::testing::ValuesIn(dynamicInputShapes4D1), + ::testing::ValuesIn(blockShape4D1), + ::testing::ValuesIn(padsBegin4D1), + ::testing::ValuesIn(padsEnd4D1), + ::testing::ValuesIn(netPrecision), + ::testing::ValuesIn(cpuParams_4D)); + +const auto dynamicSpaceToBatchParamsWithBlockedSet4D1 = + ::testing::Combine(::testing::ValuesIn(dynamicInputShapes4D1Blocked), + ::testing::ValuesIn(blockShape4D1), + ::testing::ValuesIn(padsBegin4D1), + ::testing::ValuesIn(padsEnd4D1), + ::testing::ValuesIn(netPrecision), + ::testing::ValuesIn(cpuParamsWithBlock_4D)); + +const auto staticSpaceToBatchParamsSet4D2 = + ::testing::Combine(::testing::ValuesIn(static_shapes_to_test_representation(staticInputShapes4D2)), + ::testing::ValuesIn(blockShape4D2), + ::testing::ValuesIn(padsBegin4D2), + ::testing::ValuesIn(padsEnd4D2), + ::testing::ValuesIn(netPrecision), + ::testing::ValuesIn(cpuParams_4D)); + +const auto dynamicSpaceToBatchParamsSet4D2 = ::testing::Combine(::testing::ValuesIn(dynamicInputShapes4D2), + ::testing::ValuesIn(blockShape4D2), + ::testing::ValuesIn(padsBegin4D2), + ::testing::ValuesIn(padsEnd4D2), + ::testing::ValuesIn(netPrecision), + ::testing::ValuesIn(cpuParams_4D)); + +const auto dynamicSpaceToBatchParamsWithBlockedSet4D2 = + ::testing::Combine(::testing::ValuesIn(dynamicInputShapes4D2Blocked), + ::testing::ValuesIn(blockShape4D2), + ::testing::ValuesIn(padsBegin4D2), + ::testing::ValuesIn(padsEnd4D2), + ::testing::ValuesIn(netPrecision), + ::testing::ValuesIn(cpuParamsWithBlock_4D)); + +INSTANTIATE_TEST_SUITE_P(smoke_StaticSpaceToBatchCPULayerTestCase1_4D, + SpaceToBatchCPULayerTest, + staticSpaceToBatchParamsSet4D1, + SpaceToBatchCPULayerTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_DynamicSpaceToBatchCPULayerTestCase1_4D, + SpaceToBatchCPULayerTest, + dynamicSpaceToBatchParamsSet4D1, + SpaceToBatchCPULayerTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_DynamicSpaceToBatchCPULayerTestCaseWithBlocked1_4D, + SpaceToBatchCPULayerTest, + dynamicSpaceToBatchParamsWithBlockedSet4D1, + SpaceToBatchCPULayerTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_StaticSpaceToBatchCPULayerTestCase2_4D, + SpaceToBatchCPULayerTest, + staticSpaceToBatchParamsSet4D2, + SpaceToBatchCPULayerTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_DynamicSpaceToBatchCPULayerTestCase2_4D, + SpaceToBatchCPULayerTest, + dynamicSpaceToBatchParamsSet4D2, + SpaceToBatchCPULayerTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_DynamicSpaceToBatchCPULayerTestCaseWithBlocked2_4D, + SpaceToBatchCPULayerTest, + dynamicSpaceToBatchParamsWithBlockedSet4D2, + SpaceToBatchCPULayerTest::getTestCaseName); + +std::vector> staticInputShapes4DPE = {{{1, 2, 9, 1}, {4}, {4}, {4}}}; +INSTANTIATE_TEST_SUITE_P( + smoke_StaticSpaceToBatch_4D_parallel_block_edge, + SpaceToBatchCPULayerTest, + ::testing::Combine(::testing::ValuesIn(static_shapes_to_test_representation(staticInputShapes4DPE)), + ::testing::Values(std::vector{1, 4, 3, 1}), + ::testing::Values(std::vector{0, 1, 2, 0}), + ::testing::Values(std::vector{0, 1, 4, 0}), + ::testing::Values(ov::element::f32), + ::testing::Values(CPUSpecificParams{})), + SpaceToBatchCPULayerTest::getTestCaseName); const std::vector> blockShape5D = {{1, 1, 2, 2, 1}, {1, 2, 4, 1, 3}}; const std::vector> padsBegin5D = {{0, 0, 0, 0, 0}, {0, 0, 4, 0, 0}, {0, 0, 0, 2, 3}}; -const std::vector> padsEnd5D = {{0, 0, 0, 0, 0}, {0, 0, 0, 4, 3}, {0, 0, 4, 2, 3}}; +const std::vector> padsEnd5D = {{0, 0, 0, 0, 0}, {0, 0, 0, 4, 3}, {0, 0, 4, 2, 3}}; -std::vector> staticInputShapes5D = { - {{2, 16, 4, 6, 12}, {5}, {5}, {5}}, - {{1, 32, 8, 8, 6}, {5}, {5}, {5}}, - {{1, 16, 4, 12, 12}, {5}, {5}, {5}} -}; +std::vector> staticInputShapes5D = {{{2, 16, 4, 6, 12}, {5}, {5}, {5}}, + {{1, 32, 8, 8, 6}, {5}, {5}, {5}}, + {{1, 16, 4, 12, 12}, {5}, {5}, {5}}}; std::vector> dynamicInputShapes5D = { - { - {{-1, -1, -1, -1, -1}, {{2, 2, 12, 4, 15}, {4, 4, 8, 6, 9}, {3, 6, 4, 2, 12}}}, - {{5}, {{5}, {5}, {5}}}, - {{5}, {{5}, {5}, {5}}}, - {{5}, {{5}, {5}, {5}}} - }, - { - {{{1, 10}, {2, 20}, {4, 50}, -1, -1}, {{3, 12, 8, 6, 9}, {5, 10, 4, 8, 15}, {6, 8, 20, 4, 12}}}, - {{5}, {{5}, {5}, {5}}}, - {{5}, {{5}, {5}, {5}}}, - {{5}, {{5}, {5}, {5}}} - } -}; + {{{-1, -1, -1, -1, -1}, {{2, 2, 12, 4, 15}, {4, 4, 8, 6, 9}, {3, 6, 4, 2, 12}}}, + {{5}, {{5}, {5}, {5}}}, + {{5}, {{5}, {5}, {5}}}, + {{5}, {{5}, {5}, {5}}}}, + {{{{1, 10}, {2, 20}, {4, 50}, -1, -1}, {{3, 12, 8, 6, 9}, {5, 10, 4, 8, 15}, {6, 8, 20, 4, 12}}}, + {{5}, {{5}, {5}, {5}}}, + {{5}, {{5}, {5}, {5}}}, + {{5}, {{5}, {5}, {5}}}}}; std::vector> dynamicInputShapes5DBlocked = { - { - {{-1, 16, -1, -1, -1}, {{2, 16, 4, 6, 9}, {5, 16, 16, 4, 6}, {7, 16, 8, 2, 3}}}, - {{5}, {{5}, {5}, {5}}}, - {{5}, {{5}, {5}, {5}}}, - {{5}, {{5}, {5}, {5}}} - } -}; - -const std::vector cpuParamsWithBlock_5D = { - CPUSpecificParams({nCdhw16c}, {nCdhw16c}, {}, {}), - CPUSpecificParams({nCdhw8c}, {nCdhw8c}, {}, {}), - CPUSpecificParams({ndhwc}, {ndhwc}, {}, {}), - CPUSpecificParams({ncdhw}, {ncdhw}, {}, {}) -}; - -const std::vector cpuParams_5D = { - CPUSpecificParams({ndhwc}, {ndhwc}, {}, {}), - CPUSpecificParams({ncdhw}, {ncdhw}, {}, {}) -}; - -const auto staticSpaceToBatchParamsSet5D = ::testing::Combine( - ::testing::ValuesIn(static_shapes_to_test_representation(staticInputShapes5D)), - ::testing::ValuesIn(blockShape5D), - ::testing::ValuesIn(padsBegin5D), - ::testing::ValuesIn(padsEnd5D), - ::testing::ValuesIn(netPrecision), - ::testing::ValuesIn(cpuParamsWithBlock_5D)); - -const auto dynamicSpaceToBatchParamsSet5D = ::testing::Combine( - ::testing::ValuesIn(dynamicInputShapes5D), - ::testing::ValuesIn(blockShape5D), - ::testing::ValuesIn(padsBegin5D), - ::testing::ValuesIn(padsEnd5D), - ::testing::ValuesIn(netPrecision), - ::testing::ValuesIn(cpuParams_5D)); - -const auto dynamicSpaceToBatchParamsWithBlockedSet5D = ::testing::Combine( - ::testing::ValuesIn(dynamicInputShapes5DBlocked), - ::testing::ValuesIn(blockShape5D), - ::testing::ValuesIn(padsBegin5D), - ::testing::ValuesIn(padsEnd5D), - ::testing::ValuesIn(netPrecision), - ::testing::ValuesIn(cpuParamsWithBlock_5D)); - -INSTANTIATE_TEST_SUITE_P(smoke_StaticSpaceToBatchCPULayerTestCase_5D, SpaceToBatchCPULayerTest, - staticSpaceToBatchParamsSet5D, SpaceToBatchCPULayerTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_DynamicSpaceToBatchCPULayerTestCase_5D, SpaceToBatchCPULayerTest, - dynamicSpaceToBatchParamsSet5D, SpaceToBatchCPULayerTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_DynamicSpaceToBatchCPULayerTestCaseWithBlocked_5D, SpaceToBatchCPULayerTest, - dynamicSpaceToBatchParamsWithBlockedSet5D, SpaceToBatchCPULayerTest::getTestCaseName); - + {{{-1, 16, -1, -1, -1}, {{2, 16, 4, 6, 9}, {5, 16, 16, 4, 6}, {7, 16, 8, 2, 3}}}, + {{5}, {{5}, {5}, {5}}}, + {{5}, {{5}, {5}, {5}}}, + {{5}, {{5}, {5}, {5}}}}}; + +const std::vector cpuParamsWithBlock_5D = {CPUSpecificParams({nCdhw16c}, {nCdhw16c}, {}, {}), + CPUSpecificParams({nCdhw8c}, {nCdhw8c}, {}, {}), + CPUSpecificParams({ndhwc}, {ndhwc}, {}, {}), + CPUSpecificParams({ncdhw}, {ncdhw}, {}, {})}; + +const std::vector cpuParams_5D = {CPUSpecificParams({ndhwc}, {ndhwc}, {}, {}), + CPUSpecificParams({ncdhw}, {ncdhw}, {}, {})}; + +const auto staticSpaceToBatchParamsSet5D = + ::testing::Combine(::testing::ValuesIn(static_shapes_to_test_representation(staticInputShapes5D)), + ::testing::ValuesIn(blockShape5D), + ::testing::ValuesIn(padsBegin5D), + ::testing::ValuesIn(padsEnd5D), + ::testing::ValuesIn(netPrecision), + ::testing::ValuesIn(cpuParamsWithBlock_5D)); + +const auto dynamicSpaceToBatchParamsSet5D = ::testing::Combine(::testing::ValuesIn(dynamicInputShapes5D), + ::testing::ValuesIn(blockShape5D), + ::testing::ValuesIn(padsBegin5D), + ::testing::ValuesIn(padsEnd5D), + ::testing::ValuesIn(netPrecision), + ::testing::ValuesIn(cpuParams_5D)); + +const auto dynamicSpaceToBatchParamsWithBlockedSet5D = + ::testing::Combine(::testing::ValuesIn(dynamicInputShapes5DBlocked), + ::testing::ValuesIn(blockShape5D), + ::testing::ValuesIn(padsBegin5D), + ::testing::ValuesIn(padsEnd5D), + ::testing::ValuesIn(netPrecision), + ::testing::ValuesIn(cpuParamsWithBlock_5D)); + +INSTANTIATE_TEST_SUITE_P(smoke_StaticSpaceToBatchCPULayerTestCase_5D, + SpaceToBatchCPULayerTest, + staticSpaceToBatchParamsSet5D, + SpaceToBatchCPULayerTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_DynamicSpaceToBatchCPULayerTestCase_5D, + SpaceToBatchCPULayerTest, + dynamicSpaceToBatchParamsSet5D, + SpaceToBatchCPULayerTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_DynamicSpaceToBatchCPULayerTestCaseWithBlocked_5D, + SpaceToBatchCPULayerTest, + dynamicSpaceToBatchParamsWithBlockedSet5D, + SpaceToBatchCPULayerTest::getTestCaseName); } // namespace -} // namespace CPULayerTestsDefinitions +} // namespace test +} // namespace ov diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/space_to_depth.cpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/space_to_depth.cpp index 5b3b4ea1632ab9..a9923fae3d89fa 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/space_to_depth.cpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/space_to_depth.cpp @@ -2,34 +2,27 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "shared_test_classes/single_layer/space_to_depth.hpp" +#include "shared_test_classes/base/ov_subgraph.hpp" #include "test_utils/cpu_test_utils.hpp" #include "test_utils/filter_cpu_info.hpp" -#include "shared_test_classes/base/ov_subgraph.hpp" - -using namespace InferenceEngine; using namespace CPUTestUtils; -using namespace ngraph::opset3; using namespace ov::test; -namespace CPULayerTestsDefinitions { - -using SpaceToDepthLayerCPUTestParamSet = std::tuple< - InputShape, // Input shape - ElementType, // Input element type - SpaceToDepth::SpaceToDepthMode, // Mode - std::size_t, // Block size - CPUSpecificParams ->; +using SpaceToDepthLayerCPUTestParamSet = std::tuple; class SpaceToDepthLayerCPUTest : public testing::WithParamInterface, - virtual public ov::test::SubgraphBaseTest, public CPUTestsBase { + virtual public ov::test::SubgraphBaseTest, + public CPUTestsBase { public: static std::string getTestCaseName(testing::TestParamInfo obj) { InputShape shapes; ElementType inType; - SpaceToDepth::SpaceToDepthMode mode; + ov::op::v0::SpaceToDepth::SpaceToDepthMode mode; std::size_t blockSize; CPUSpecificParams cpuParams; std::tie(shapes, inType, mode, blockSize, cpuParams) = obj.param; @@ -42,25 +35,26 @@ class SpaceToDepthLayerCPUTest : public testing::WithParamInterfaceGetParam(); @@ -69,7 +63,7 @@ class SpaceToDepthLayerCPUTest : public testing::WithParamInterface(inType, shape)); } - auto d2s = std::make_shared (params[0], mode, blockSize); + auto d2s = std::make_shared(params[0], mode, blockSize); function = makeNgraphFunction(inType, params, d2s, "SpaceToDepthCPU"); } }; @@ -89,110 +83,89 @@ TEST_P(SpaceToDepthLayerCPUTest, CompareWithRefs) { namespace { -const auto cpuParams_nChw16c = CPUSpecificParams {{nChw16c}, {nChw16c}, {}, {}}; -const auto cpuParams_nCdhw16c = CPUSpecificParams {{nCdhw16c}, {nCdhw16c}, {}, {}}; +const auto cpuParams_nChw16c = CPUSpecificParams{{nChw16c}, {nChw16c}, {}, {}}; +const auto cpuParams_nCdhw16c = CPUSpecificParams{{nCdhw16c}, {nCdhw16c}, {}, {}}; -const auto cpuParams_nChw8c = CPUSpecificParams {{nChw8c}, {nChw8c}, {}, {}}; -const auto cpuParams_nCdhw8c = CPUSpecificParams {{nCdhw8c}, {nCdhw8c}, {}, {}}; +const auto cpuParams_nChw8c = CPUSpecificParams{{nChw8c}, {nChw8c}, {}, {}}; +const auto cpuParams_nCdhw8c = CPUSpecificParams{{nCdhw8c}, {nCdhw8c}, {}, {}}; -const auto cpuParams_nhwc = CPUSpecificParams {{nhwc}, {nhwc}, {}, {}}; -const auto cpuParams_ndhwc = CPUSpecificParams {{ndhwc}, {ndhwc}, {}, {}}; +const auto cpuParams_nhwc = CPUSpecificParams{{nhwc}, {nhwc}, {}, {}}; +const auto cpuParams_ndhwc = CPUSpecificParams{{ndhwc}, {ndhwc}, {}, {}}; -const auto cpuParams_nchw = CPUSpecificParams {{nchw}, {nchw}, {}, {}}; -const auto cpuParams_ncdhw = CPUSpecificParams {{ncdhw}, {ncdhw}, {}, {}}; +const auto cpuParams_nchw = CPUSpecificParams{{nchw}, {nchw}, {}, {}}; +const auto cpuParams_ncdhw = CPUSpecificParams{{ncdhw}, {ncdhw}, {}, {}}; -const std::vector CPUParams4D = { - cpuParams_nhwc, - cpuParams_nchw -}; +const std::vector CPUParams4D = {cpuParams_nhwc, cpuParams_nchw}; -const std::vector CPUParamsBlocked4D = { - cpuParams_nChw16c, - cpuParams_nChw8c, - cpuParams_nhwc -}; +const std::vector CPUParamsBlocked4D = {cpuParams_nChw16c, cpuParams_nChw8c, cpuParams_nhwc}; -const std::vector CPUParams5D = { - cpuParams_ndhwc, - cpuParams_ncdhw -}; +const std::vector CPUParams5D = {cpuParams_ndhwc, cpuParams_ncdhw}; -const std::vector CPUParamsBlocked5D = { - cpuParams_nCdhw16c, - cpuParams_nCdhw8c, - cpuParams_ndhwc -}; +const std::vector CPUParamsBlocked5D = {cpuParams_nCdhw16c, cpuParams_nCdhw8c, cpuParams_ndhwc}; -const std::vector inputElementType = { - ElementType::f32, - ElementType::bf16, - ElementType::i8 -}; +const std::vector inputElementType = {ElementType::f32, ElementType::bf16, ElementType::i8}; -const std::vector SpaceToDepthModes = { - SpaceToDepth::SpaceToDepthMode::BLOCKS_FIRST, - SpaceToDepth::SpaceToDepthMode::DEPTH_FIRST -}; +const std::vector SpaceToDepthModes = { + ov::op::v0::SpaceToDepth::SpaceToDepthMode::BLOCKS_FIRST, + ov::op::v0::SpaceToDepth::SpaceToDepthMode::DEPTH_FIRST}; /* *========================* Static Shapes Tests *========================* */ namespace static_shapes { -const std::vector inputShapesBS2_4D = {{1, 16, 2, 2}, {1, 16, 4, 2}, - {1, 32, 6, 8}, {2, 32, 4, 6}, - {2, 48, 4, 4}, {2, 64, 8, 2}}; +const std::vector inputShapesBS2_4D = + {{1, 16, 2, 2}, {1, 16, 4, 2}, {1, 32, 6, 8}, {2, 32, 4, 6}, {2, 48, 4, 4}, {2, 64, 8, 2}}; -const std::vector inputShapesBS3_4D = { - {1, 2, 3, 3}, {1, 3, 3, 6}, {1, 5, 6, 3}, {2, 5, 9, 3}, {3, 5, 6, 6}}; +const std::vector inputShapesBS3_4D = {{1, 2, 3, 3}, {1, 3, 3, 6}, {1, 5, 6, 3}, {2, 5, 9, 3}, {3, 5, 6, 6}}; -INSTANTIATE_TEST_SUITE_P(smoke_CPUSpaceToDepthBS2_4D, SpaceToDepthLayerCPUTest, - testing::Combine( - testing::ValuesIn(static_shapes_to_test_representation(inputShapesBS2_4D)), - testing::ValuesIn(inputElementType), - testing::ValuesIn(SpaceToDepthModes), - testing::Values(1, 2), - testing::ValuesIn(filterCPUInfoForDevice(CPUParamsBlocked4D))), +INSTANTIATE_TEST_SUITE_P(smoke_CPUSpaceToDepthBS2_4D, + SpaceToDepthLayerCPUTest, + testing::Combine(testing::ValuesIn(static_shapes_to_test_representation(inputShapesBS2_4D)), + testing::ValuesIn(inputElementType), + testing::ValuesIn(SpaceToDepthModes), + testing::Values(1, 2), + testing::ValuesIn(filterCPUInfoForDevice(CPUParamsBlocked4D))), SpaceToDepthLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_SUITE_P(smoke_CPUSpaceToDepthStaticBS3_4D, SpaceToDepthLayerCPUTest, - testing::Combine( - testing::ValuesIn(static_shapes_to_test_representation(inputShapesBS3_4D)), - testing::ValuesIn(inputElementType), - testing::ValuesIn(SpaceToDepthModes), - testing::Values(1, 3), - testing::ValuesIn(filterCPUInfoForDevice(CPUParams4D))), +INSTANTIATE_TEST_SUITE_P(smoke_CPUSpaceToDepthStaticBS3_4D, + SpaceToDepthLayerCPUTest, + testing::Combine(testing::ValuesIn(static_shapes_to_test_representation(inputShapesBS3_4D)), + testing::ValuesIn(inputElementType), + testing::ValuesIn(SpaceToDepthModes), + testing::Values(1, 3), + testing::ValuesIn(filterCPUInfoForDevice(CPUParams4D))), SpaceToDepthLayerCPUTest::getTestCaseName); -const std::vector inputShapesBS2_5D = { - {1, 16, 2, 2, 2}, {1, 16, 4, 4, 2}, {1, 32, 2, 6, 2}, {2, 32, 4, 2, 2}, {1, 48, 6, 2, 2}, {2, 64, 2, 2, 6} -}; - -const std::vector inputShapesBS3_5D = { - {1, 2, 3, 3, 3}, {1, 2, 3, 6, 9}, {1, 5, 6, 3, 3}, {2, 5, 3, 9, 3}, {3, 5, 3, 3, 6} -}; - -INSTANTIATE_TEST_SUITE_P(smoke_CPUSpaceToDepthStaticBS2_5D, SpaceToDepthLayerCPUTest, - testing::Combine( - testing::ValuesIn(static_shapes_to_test_representation(inputShapesBS2_5D)), - testing::ValuesIn(inputElementType), - testing::ValuesIn(SpaceToDepthModes), - testing::Values(1, 2), - testing::ValuesIn(filterCPUInfoForDevice(CPUParamsBlocked5D))), +const std::vector inputShapesBS2_5D = + {{1, 16, 2, 2, 2}, {1, 16, 4, 4, 2}, {1, 32, 2, 6, 2}, {2, 32, 4, 2, 2}, {1, 48, 6, 2, 2}, {2, 64, 2, 2, 6}}; + +const std::vector inputShapesBS3_5D = {{1, 2, 3, 3, 3}, + {1, 2, 3, 6, 9}, + {1, 5, 6, 3, 3}, + {2, 5, 3, 9, 3}, + {3, 5, 3, 3, 6}}; + +INSTANTIATE_TEST_SUITE_P(smoke_CPUSpaceToDepthStaticBS2_5D, + SpaceToDepthLayerCPUTest, + testing::Combine(testing::ValuesIn(static_shapes_to_test_representation(inputShapesBS2_5D)), + testing::ValuesIn(inputElementType), + testing::ValuesIn(SpaceToDepthModes), + testing::Values(1, 2), + testing::ValuesIn(filterCPUInfoForDevice(CPUParamsBlocked5D))), SpaceToDepthLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_SUITE_P(smoke_CPUSpaceToDepthStaticBS3_5D, SpaceToDepthLayerCPUTest, - testing::Combine( - testing::ValuesIn(static_shapes_to_test_representation(inputShapesBS3_5D)), - testing::ValuesIn(inputElementType), - testing::ValuesIn(SpaceToDepthModes), - testing::Values(1, 3), - testing::ValuesIn(filterCPUInfoForDevice(CPUParams5D))), +INSTANTIATE_TEST_SUITE_P(smoke_CPUSpaceToDepthStaticBS3_5D, + SpaceToDepthLayerCPUTest, + testing::Combine(testing::ValuesIn(static_shapes_to_test_representation(inputShapesBS3_5D)), + testing::ValuesIn(inputElementType), + testing::ValuesIn(SpaceToDepthModes), + testing::Values(1, 3), + testing::ValuesIn(filterCPUInfoForDevice(CPUParams5D))), SpaceToDepthLayerCPUTest::getTestCaseName); -} // namespace static_shapes +} // namespace static_shapes /* *========================* *==================* *========================* */ - /* *========================* Dynamic Shapes Tests *========================* */ namespace dynamic_shapes { @@ -223,52 +196,51 @@ const std::vector inputShapesBlocked5D = { {{1, 32, 4, 16, 10}, {1, 32, 18, 6, 14}, {3, 32, 2, 14, 12}, {1, 32, 18, 6, 14}}}, // target }; -INSTANTIATE_TEST_SUITE_P(smoke_CPUSpaceToDepthDynamic4D, SpaceToDepthLayerCPUTest, - testing::Combine( - testing::ValuesIn(inputShapes4D), - testing::ValuesIn(inputElementType), - testing::ValuesIn(SpaceToDepthModes), - testing::Values(1, 2, 3), - testing::ValuesIn(filterCPUInfoForDevice(CPUParams4D))), +INSTANTIATE_TEST_SUITE_P(smoke_CPUSpaceToDepthDynamic4D, + SpaceToDepthLayerCPUTest, + testing::Combine(testing::ValuesIn(inputShapes4D), + testing::ValuesIn(inputElementType), + testing::ValuesIn(SpaceToDepthModes), + testing::Values(1, 2, 3), + testing::ValuesIn(filterCPUInfoForDevice(CPUParams4D))), + SpaceToDepthLayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_CPUSpaceToDepthDynamicBlocksFirstBlocked4D, + SpaceToDepthLayerCPUTest, + testing::Combine(testing::Values(inputShapes4D[1]), + testing::ValuesIn(inputElementType), + testing::Values(ov::op::v0::SpaceToDepth::SpaceToDepthMode::BLOCKS_FIRST), + testing::Values(1, 2, 3), + testing::ValuesIn(filterCPUInfoForDevice(CPUParamsBlocked4D))), SpaceToDepthLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_SUITE_P(smoke_CPUSpaceToDepthDynamicBlocksFirstBlocked4D, SpaceToDepthLayerCPUTest, - testing::Combine( - testing::Values(inputShapes4D[1]), - testing::ValuesIn(inputElementType), - testing::Values(SpaceToDepth::SpaceToDepthMode::BLOCKS_FIRST), - testing::Values(1, 2, 3), - testing::ValuesIn(filterCPUInfoForDevice(CPUParamsBlocked4D))), - SpaceToDepthLayerCPUTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_CPUSpaceToDepthDynamicDepthFirstBlocked4D, SpaceToDepthLayerCPUTest, - testing::Combine( - testing::Values(inputShapes4D[1]), - testing::ValuesIn(inputElementType), - testing::Values(SpaceToDepth::SpaceToDepthMode::DEPTH_FIRST), - testing::Values(1, 2), - testing::ValuesIn(filterCPUInfoForDevice(CPUParamsBlocked4D))), +INSTANTIATE_TEST_SUITE_P(smoke_CPUSpaceToDepthDynamicDepthFirstBlocked4D, + SpaceToDepthLayerCPUTest, + testing::Combine(testing::Values(inputShapes4D[1]), + testing::ValuesIn(inputElementType), + testing::Values(ov::op::v0::SpaceToDepth::SpaceToDepthMode::DEPTH_FIRST), + testing::Values(1, 2), + testing::ValuesIn(filterCPUInfoForDevice(CPUParamsBlocked4D))), SpaceToDepthLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_SUITE_P(smoke_CPUSpaceToDepthDynamic5D, SpaceToDepthLayerCPUTest, - testing::Combine( - testing::ValuesIn(inputShapes5D), - testing::ValuesIn(inputElementType), - testing::ValuesIn(SpaceToDepthModes), - testing::Values(1, 2, 3), - testing::ValuesIn(filterCPUInfoForDevice(CPUParams5D))), +INSTANTIATE_TEST_SUITE_P(smoke_CPUSpaceToDepthDynamic5D, + SpaceToDepthLayerCPUTest, + testing::Combine(testing::ValuesIn(inputShapes5D), + testing::ValuesIn(inputElementType), + testing::ValuesIn(SpaceToDepthModes), + testing::Values(1, 2, 3), + testing::ValuesIn(filterCPUInfoForDevice(CPUParams5D))), SpaceToDepthLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_SUITE_P(smoke_CPUSpaceToDepthDynamicCPUSpecific5D, SpaceToDepthLayerCPUTest, - testing::Combine( - testing::ValuesIn(inputShapesBlocked5D), - testing::ValuesIn(inputElementType), - testing::ValuesIn(SpaceToDepthModes), - testing::Values(1, 2), - testing::ValuesIn(filterCPUInfoForDevice(CPUParamsBlocked5D))), +INSTANTIATE_TEST_SUITE_P(smoke_CPUSpaceToDepthDynamicCPUSpecific5D, + SpaceToDepthLayerCPUTest, + testing::Combine(testing::ValuesIn(inputShapesBlocked5D), + testing::ValuesIn(inputElementType), + testing::ValuesIn(SpaceToDepthModes), + testing::Values(1, 2), + testing::ValuesIn(filterCPUInfoForDevice(CPUParamsBlocked5D))), SpaceToDepthLayerCPUTest::getTestCaseName); -} // namespace dynamic_shapes +} // namespace dynamic_shapes /* *========================* *==================* *========================* */ -} // namespace -} // namespace CPULayerTestsDefinitions +} // namespace diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/split.cpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/split.cpp index 47417778ff1156..ac2b9cef88ec44 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/split.cpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/split.cpp @@ -3,25 +3,22 @@ // #include "shared_test_classes/base/ov_subgraph.hpp" -#include "ov_models/builders.hpp" #include "test_utils/cpu_test_utils.hpp" using namespace ov::test; using namespace CPUTestUtils; -namespace CPULayerTestsDefinitions { - -typedef std::tuple< - size_t, // Num splits - int64_t, // Axis - ElementType, // Net precision - InputShape, // Input shapes - std::vector, // Used outputs indices - CPUSpecificParams -> splitCPUTestParams; +typedef std::tuple, // Used outputs indices + CPUSpecificParams> + splitCPUTestParams; class SplitLayerCPUTest : public testing::WithParamInterface, - virtual public SubgraphBaseTest, public CPUTestsBase { + virtual public SubgraphBaseTest, + public CPUTestsBase { public: static std::string getTestCaseName(testing::TestParamInfo obj) { size_t numSplits; @@ -75,21 +72,22 @@ class SplitLayerCPUTest : public testing::WithParamInterface for (auto&& shape : inputDynamicShapes) params.push_back(std::make_shared(netPrecision, shape)); - auto split_axis_op = std::make_shared(ov::element::Type_t::i64, ov::Shape{}, std::vector{axis}); + auto split_axis_op = + std::make_shared(ov::element::Type_t::i64, ov::Shape{}, std::vector{axis}); auto split = std::make_shared(params[0], split_axis_op, numSplits); - ngraph::ResultVector results; + ov::ResultVector results; for (size_t i = 0; i < outIndices.size(); i++) { - // This WA is necessary because result nodes connected to the same output of the split node (or any node) are deduplicated - // on the CNNNetwork level. It might not be needed when the CPU plugin moves completely to nGraph. - // This is still a single layer test since the Relu nodes are added only as a WA. + // This WA is necessary because result nodes connected to the same output of the split node (or any node) + // are deduplicated on the CNNNetwork level. It might not be needed when the CPU plugin moves completely to + // model. This is still a single layer test since the Relu nodes are added only as a WA. - auto fakeEltwise = std::make_shared(split->output(outIndices[i])); - results.push_back(std::make_shared(fakeEltwise)); + auto fakeEltwise = std::make_shared(split->output(outIndices[i])); + results.push_back(std::make_shared(fakeEltwise)); } split->get_rt_info() = getCPUInfo(); - function = std::make_shared(results, params, "split"); + function = std::make_shared(results, params, "split"); } }; @@ -124,477 +122,360 @@ const auto blocked16_4D_ref = CPUSpecificParams{{nChw16c}, {nChw16c}, {}, "ref"} const auto blocked16_5D_ref = CPUSpecificParams{{nCdhw16c}, {nCdhw16c}, {}, "ref"}; // List of precisions natively supported by onednn. -const std::vector netPrecisions = { - ElementType::i8, - ElementType::i32, - ElementType::f32, - ElementType::bf16 -}; +const std::vector netPrecisions = {ElementType::i8, ElementType::i32, ElementType::f32, ElementType::bf16}; const std::vector> outIndices3 = {{0, 1, 2}, {0, 1, 1, 0, 2}, {0, 0, 0, 2}}; const std::vector> outIndices4 = {{0, 1, 2, 3}, {0, 1, 1, 0, 2, 3}, {0, 0, 0, 2, 3}}; const std::vector inputShapes4D_Nspc2NcspSpecial = { - { {}, {{3, 8, 11, 9}} }, - { - // dynamic - {-1, -1, -1, -1}, - // target - { - {1, 4, 5, 7}, - {3, 8, 5, 9}, - {5, 16, 1, 8} - } - }, - { - // dynamic - {{1, 5}, {1, 64}, {1, 25}, {2, 10}}, - // target - { - {2, 8, 5, 7}, - {1, 4, 10, 2}, - {3, 16, 5, 9} - } - }, - { - // dynamic - {{1, 5}, 8, 5, 7}, - // target - { - {2, 8, 5, 7}, - {1, 8, 5, 7}, - {2, 8, 5, 7}, - } - }, + {{}, {{3, 8, 11, 9}}}, + {// dynamic + {-1, -1, -1, -1}, + // target + {{1, 4, 5, 7}, {3, 8, 5, 9}, {5, 16, 1, 8}}}, + {// dynamic + {{1, 5}, {1, 64}, {1, 25}, {2, 10}}, + // target + {{2, 8, 5, 7}, {1, 4, 10, 2}, {3, 16, 5, 9}}}, + {// dynamic + {{1, 5}, 8, 5, 7}, + // target + { + {2, 8, 5, 7}, + {1, 8, 5, 7}, + {2, 8, 5, 7}, + }}, }; -INSTANTIATE_TEST_SUITE_P(smoke_Split4D_CPU_Nspc2NcspSpecial, SplitLayerCPUTest, - ::testing::Combine( - ::testing::Values(4), - ::testing::Values(1), - ::testing::ValuesIn(netPrecisions), - ::testing::ValuesIn(inputShapes4D_Nspc2NcspSpecial), - ::testing::ValuesIn(outIndices4), - ::testing::Values(perChannelsToPlanar_4D)), - SplitLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_Split4D_CPU_Nspc2NcspSpecial, + SplitLayerCPUTest, + ::testing::Combine(::testing::Values(4), + ::testing::Values(1), + ::testing::ValuesIn(netPrecisions), + ::testing::ValuesIn(inputShapes4D_Nspc2NcspSpecial), + ::testing::ValuesIn(outIndices4), + ::testing::Values(perChannelsToPlanar_4D)), + SplitLayerCPUTest::getTestCaseName); const std::vector inputShapes5D_Nspc2NcspSpecial = { - { {}, {{3, 9, 5, 9, 11}} }, - { - // dynamic - {-1, -1, -1, -1, -1}, - // target - { - {1, 12, 5, 7, 5}, - {3, 6, 8, 9, 1}, - {5, 9, 1, 8, 2} - } - }, - { - // dynamic - {{1, 5}, {1, 64}, {1, 25}, {2, 10}, {1, 64}}, - // target - { - {2, 6, 5, 7, 7}, - {1, 3, 10, 2, 11}, - {3, 9, 4, 9, 8} - } - }, + {{}, {{3, 9, 5, 9, 11}}}, + {// dynamic + {-1, -1, -1, -1, -1}, + // target + {{1, 12, 5, 7, 5}, {3, 6, 8, 9, 1}, {5, 9, 1, 8, 2}}}, + {// dynamic + {{1, 5}, {1, 64}, {1, 25}, {2, 10}, {1, 64}}, + // target + {{2, 6, 5, 7, 7}, {1, 3, 10, 2, 11}, {3, 9, 4, 9, 8}}}, }; -INSTANTIATE_TEST_SUITE_P(smoke_Split5D_CPU_Nspc2NcspSpecial, SplitLayerCPUTest, - ::testing::Combine( - ::testing::Values(3), - ::testing::Values(1), - ::testing::ValuesIn(netPrecisions), - ::testing::ValuesIn(inputShapes5D_Nspc2NcspSpecial), - ::testing::ValuesIn(outIndices3), - ::testing::Values(perChannelsToPlanar_5D)), - SplitLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_Split5D_CPU_Nspc2NcspSpecial, + SplitLayerCPUTest, + ::testing::Combine(::testing::Values(3), + ::testing::Values(1), + ::testing::ValuesIn(netPrecisions), + ::testing::ValuesIn(inputShapes5D_Nspc2NcspSpecial), + ::testing::ValuesIn(outIndices3), + ::testing::Values(perChannelsToPlanar_5D)), + SplitLayerCPUTest::getTestCaseName); const std::vector inputShapes4D_planar = { - { {}, {{3, 24, 24, 9}} }, - { - // dynamic - {-1, -1, -1, -1}, - // target - { - {1, 15, 12, 9}, - {3, 1, 9, 12}, - {5, 5, 6, 6} - } - }, - { - // dynamic - {{1, 5}, {1, 64}, {1, 48}, {2, 48}}, - // target - { - {2, 5, 6, 9}, - {1, 7, 12, 6}, - {3, 11, 9, 3} - } - }, - { - // dynamic - {{1, 5}, 5, 6, 9}, - // target - { - {2, 5, 6, 9}, - {1, 5, 6, 9}, - } - }, + {{}, {{3, 24, 24, 9}}}, + {// dynamic + {-1, -1, -1, -1}, + // target + {{1, 15, 12, 9}, {3, 1, 9, 12}, {5, 5, 6, 6}}}, + {// dynamic + {{1, 5}, {1, 64}, {1, 48}, {2, 48}}, + // target + {{2, 5, 6, 9}, {1, 7, 12, 6}, {3, 11, 9, 3}}}, + {// dynamic + {{1, 5}, 5, 6, 9}, + // target + { + {2, 5, 6, 9}, + {1, 5, 6, 9}, + }}, }; -INSTANTIATE_TEST_SUITE_P(smoke_Split4D_CPU_planar, SplitLayerCPUTest, - ::testing::Combine( - ::testing::Values(3), - ::testing::Values(2, 3), - ::testing::ValuesIn(netPrecisions), - ::testing::ValuesIn(inputShapes4D_planar), - ::testing::ValuesIn(outIndices3), - ::testing::Values(planar_4D_ref, perChannels_4D)), - SplitLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_Split4D_CPU_planar, + SplitLayerCPUTest, + ::testing::Combine(::testing::Values(3), + ::testing::Values(2, 3), + ::testing::ValuesIn(netPrecisions), + ::testing::ValuesIn(inputShapes4D_planar), + ::testing::ValuesIn(outIndices3), + ::testing::Values(planar_4D_ref, perChannels_4D)), + SplitLayerCPUTest::getTestCaseName); const std::vector inputShapes4D_block = { - { {}, {{3, 16, 12, 12}} }, - { - // dynamic - {-1, 16, -1, -1}, - // target - { - {1, 16, 12, 12}, - {3, 16, 12, 12}, - {5, 16, 12, 12} - } - }, - { - // dynamic - {{1, 5}, 16, {1, 48}, {2, 24}}, - // target - { - {2, 16, 12, 12}, - {1, 16, 12, 12}, - {3, 16, 12, 12} - } - }, - { - // dynamic - {{1, 5}, 16, 12, 12}, - // target - { - {2, 16, 12, 12}, - {1, 16, 12, 12} - } - }, + {{}, {{3, 16, 12, 12}}}, + {// dynamic + {-1, 16, -1, -1}, + // target + {{1, 16, 12, 12}, {3, 16, 12, 12}, {5, 16, 12, 12}}}, + {// dynamic + {{1, 5}, 16, {1, 48}, {2, 24}}, + // target + {{2, 16, 12, 12}, {1, 16, 12, 12}, {3, 16, 12, 12}}}, + {// dynamic + {{1, 5}, 16, 12, 12}, + // target + {{2, 16, 12, 12}, {1, 16, 12, 12}}}, }; -INSTANTIATE_TEST_SUITE_P(smoke_Split4D_CPU_Block8, SplitLayerCPUTest, - ::testing::Combine( - ::testing::Values(3), - ::testing::Values(2, 3), - ::testing::ValuesIn(netPrecisions), - ::testing::ValuesIn(inputShapes4D_block), - ::testing::ValuesIn(outIndices3), - ::testing::Values(blocked8_4D_ref)), - SplitLayerCPUTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_Split4D_CPU_Block16, SplitLayerCPUTest, - ::testing::Combine( - ::testing::Values(4), - ::testing::Values(2, 3), - ::testing::ValuesIn(netPrecisions), - ::testing::ValuesIn(inputShapes4D_block), - ::testing::ValuesIn(outIndices4), - ::testing::Values(blocked16_4D_ref)), - SplitLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_Split4D_CPU_Block8, + SplitLayerCPUTest, + ::testing::Combine(::testing::Values(3), + ::testing::Values(2, 3), + ::testing::ValuesIn(netPrecisions), + ::testing::ValuesIn(inputShapes4D_block), + ::testing::ValuesIn(outIndices3), + ::testing::Values(blocked8_4D_ref)), + SplitLayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_Split4D_CPU_Block16, + SplitLayerCPUTest, + ::testing::Combine(::testing::Values(4), + ::testing::Values(2, 3), + ::testing::ValuesIn(netPrecisions), + ::testing::ValuesIn(inputShapes4D_block), + ::testing::ValuesIn(outIndices4), + ::testing::Values(blocked16_4D_ref)), + SplitLayerCPUTest::getTestCaseName); const std::vector inputShapes5D_planar = { - { {}, {{3, 5, 3, 6, 12}} }, - { - // dynamic - {-1, -1, -1, -1, -1}, - // target - { - {1, 15, 12, 3, 9}, - {3, 1, 6, 12, 3}, - {5, 5, 6, 6, 6} - } - }, - { - // dynamic - {{1, 5}, {1, 64}, {1, 48}, {2, 48}, {1, 40}}, - // target - { - {2, 5, 12, 3, 6}, - {1, 7, 12, 6, 9}, - {3, 11, 9, 3, 30} - } - }, + {{}, {{3, 5, 3, 6, 12}}}, + {// dynamic + {-1, -1, -1, -1, -1}, + // target + {{1, 15, 12, 3, 9}, {3, 1, 6, 12, 3}, {5, 5, 6, 6, 6}}}, + {// dynamic + {{1, 5}, {1, 64}, {1, 48}, {2, 48}, {1, 40}}, + // target + {{2, 5, 12, 3, 6}, {1, 7, 12, 6, 9}, {3, 11, 9, 3, 30}}}, }; -INSTANTIATE_TEST_SUITE_P(smoke_Split5D_CPU_planar, SplitLayerCPUTest, - ::testing::Combine( - ::testing::Values(3), - ::testing::Values(2, 3, 4), - ::testing::ValuesIn(netPrecisions), - ::testing::ValuesIn(inputShapes5D_planar), - ::testing::ValuesIn(outIndices3), - ::testing::Values(planar_5D_ref, perChannels_5D)), - SplitLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_Split5D_CPU_planar, + SplitLayerCPUTest, + ::testing::Combine(::testing::Values(3), + ::testing::Values(2, 3, 4), + ::testing::ValuesIn(netPrecisions), + ::testing::ValuesIn(inputShapes5D_planar), + ::testing::ValuesIn(outIndices3), + ::testing::Values(planar_5D_ref, perChannels_5D)), + SplitLayerCPUTest::getTestCaseName); const std::vector inputShapes5D_block = { - { {}, {{3, 16, 24, 12, 36}} }, - { - // dynamic - {-1, 16, -1, -1, -1}, - // target - { - {1, 16, 12, 24, 24}, - {3, 16, 12, 12, 12}, - {5, 16, 12, 12, 24} - } - }, - { - // dynamic - {{1, 5}, 16, {1, 48}, {2, 24}, {3, 64}}, - // target - { - {2, 16, 12, 12, 24}, - {1, 16, 12, 12, 24}, - {3, 16, 12, 12, 12} - } - }, + {{}, {{3, 16, 24, 12, 36}}}, + {// dynamic + {-1, 16, -1, -1, -1}, + // target + {{1, 16, 12, 24, 24}, {3, 16, 12, 12, 12}, {5, 16, 12, 12, 24}}}, + {// dynamic + {{1, 5}, 16, {1, 48}, {2, 24}, {3, 64}}, + // target + {{2, 16, 12, 12, 24}, {1, 16, 12, 12, 24}, {3, 16, 12, 12, 12}}}, }; -INSTANTIATE_TEST_SUITE_P(smoke_Split5D_CPU_Block8, SplitLayerCPUTest, - ::testing::Combine( - ::testing::Values(3), - ::testing::Values(2, 3, 4), - ::testing::ValuesIn(netPrecisions), - ::testing::ValuesIn(inputShapes5D_block), - ::testing::ValuesIn(outIndices3), - ::testing::Values(blocked8_5D_ref)), - SplitLayerCPUTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_Split5D_CPU_Block16, SplitLayerCPUTest, - ::testing::Combine( - ::testing::Values(4), - ::testing::Values(2, 3, 4), - ::testing::ValuesIn(netPrecisions), - ::testing::ValuesIn(inputShapes5D_block), - ::testing::ValuesIn(outIndices4), - ::testing::Values(blocked16_5D_ref)), - SplitLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_Split5D_CPU_Block8, + SplitLayerCPUTest, + ::testing::Combine(::testing::Values(3), + ::testing::Values(2, 3, 4), + ::testing::ValuesIn(netPrecisions), + ::testing::ValuesIn(inputShapes5D_block), + ::testing::ValuesIn(outIndices3), + ::testing::Values(blocked8_5D_ref)), + SplitLayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_Split5D_CPU_Block16, + SplitLayerCPUTest, + ::testing::Combine(::testing::Values(4), + ::testing::Values(2, 3, 4), + ::testing::ValuesIn(netPrecisions), + ::testing::ValuesIn(inputShapes5D_block), + ::testing::ValuesIn(outIndices4), + ::testing::Values(blocked16_5D_ref)), + SplitLayerCPUTest::getTestCaseName); const std::vector inputShapes3D = { - { {}, {{14, 28, 21}} }, - { - // dynamic - {-1, -1, -1}, - // target - { - {7, 21, 14}, - {21, 7, 14}, - {21, 14, 7}, - } - }, - { - // dynamic - {{1, 60}, {1, 50}, {1, 48}}, - // target - { - {14, 21, 7}, - {21, 7, 14}, - {7, 14, 21}, - } - }, + {{}, {{14, 28, 21}}}, + {// dynamic + {-1, -1, -1}, + // target + { + {7, 21, 14}, + {21, 7, 14}, + {21, 14, 7}, + }}, + {// dynamic + {{1, 60}, {1, 50}, {1, 48}}, + // target + { + {14, 21, 7}, + {21, 7, 14}, + {7, 14, 21}, + }}, }; -INSTANTIATE_TEST_SUITE_P(smoke_Split3D, SplitLayerCPUTest, - ::testing::Combine( - ::testing::Values(7), - ::testing::Values(1, 2), - ::testing::ValuesIn(netPrecisions), - ::testing::ValuesIn(inputShapes3D), - ::testing::Values(std::vector({})), - ::testing::Values(CPUSpecificParams{{}, {}, {}, "ref"})), - SplitLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_Split3D, + SplitLayerCPUTest, + ::testing::Combine(::testing::Values(7), + ::testing::Values(1, 2), + ::testing::ValuesIn(netPrecisions), + ::testing::ValuesIn(inputShapes3D), + ::testing::Values(std::vector({})), + ::testing::Values(CPUSpecificParams{{}, {}, {}, "ref"})), + SplitLayerCPUTest::getTestCaseName); const std::vector inputShapes2D = { - { {}, {{6, 12}} }, - { - // dynamic - {-1, -1}, - // target - { - {2, 8}, - {10, 4}, - {2, 6}, - } - }, - { - // dynamic - {{1, 60}, {1, 50}}, - // target - { - {2, 4}, - {4, 4}, - {6, 12}, - } - }, + {{}, {{6, 12}}}, + {// dynamic + {-1, -1}, + // target + { + {2, 8}, + {10, 4}, + {2, 6}, + }}, + {// dynamic + {{1, 60}, {1, 50}}, + // target + { + {2, 4}, + {4, 4}, + {6, 12}, + }}, }; -INSTANTIATE_TEST_SUITE_P(smoke_Split2D, SplitLayerCPUTest, - ::testing::Combine( - ::testing::Values(2), - ::testing::Values(1), - ::testing::ValuesIn(netPrecisions), - ::testing::ValuesIn(inputShapes2D), - ::testing::Values(std::vector({})), - ::testing::Values(CPUSpecificParams{{}, {}, {}, "ref"})), - SplitLayerCPUTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_Split1D_static, SplitLayerCPUTest, - ::testing::Combine( - ::testing::Values(5), - ::testing::Values(0), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(InputShape{ {}, {{10}} }), - ::testing::Values(std::vector({})), - ::testing::Values(CPUSpecificParams{{}, {}, {}, "unknown"})), - SplitLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_Split2D, + SplitLayerCPUTest, + ::testing::Combine(::testing::Values(2), + ::testing::Values(1), + ::testing::ValuesIn(netPrecisions), + ::testing::ValuesIn(inputShapes2D), + ::testing::Values(std::vector({})), + ::testing::Values(CPUSpecificParams{{}, {}, {}, "ref"})), + SplitLayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_Split1D_static, + SplitLayerCPUTest, + ::testing::Combine(::testing::Values(5), + ::testing::Values(0), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(InputShape{{}, {{10}}}), + ::testing::Values(std::vector({})), + ::testing::Values(CPUSpecificParams{{}, {}, {}, "unknown"})), + SplitLayerCPUTest::getTestCaseName); const std::vector inputShapes1D = { - { - // dynamic - {-1}, - // target - { - {5}, - {15}, - {10}, - } - }, - { - // dynamic - {{1, 60}}, - // target - { - {15}, - {5}, - {10}, - } - }, + {// dynamic + {-1}, + // target + { + {5}, + {15}, + {10}, + }}, + {// dynamic + {{1, 60}}, + // target + { + {15}, + {5}, + {10}, + }}, }; -INSTANTIATE_TEST_SUITE_P(smoke_Split1D, SplitLayerCPUTest, - ::testing::Combine( - ::testing::Values(5), - ::testing::Values(0), - ::testing::ValuesIn(netPrecisions), - ::testing::ValuesIn(inputShapes1D), - ::testing::Values(std::vector({})), - ::testing::Values(CPUSpecificParams{{}, {}, {}, "ref"})), - SplitLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_Split1D, + SplitLayerCPUTest, + ::testing::Combine(::testing::Values(5), + ::testing::Values(0), + ::testing::ValuesIn(netPrecisions), + ::testing::ValuesIn(inputShapes1D), + ::testing::Values(std::vector({})), + ::testing::Values(CPUSpecificParams{{}, {}, {}, "ref"})), + SplitLayerCPUTest::getTestCaseName); const std::vector inputShapes4D_dynBatch = { - { - // dynamic - {{1, 10}, 6, 6, 9}, - // target - { - {6, 6, 6, 9}, - {9, 6, 6, 9}, - } - }, + {// dynamic + {{1, 10}, 6, 6, 9}, + // target + { + {6, 6, 6, 9}, + {9, 6, 6, 9}, + }}, }; -INSTANTIATE_TEST_SUITE_P(smoke_Split4D_CPU_by_batch, SplitLayerCPUTest, - ::testing::Combine( - ::testing::Values(3), - ::testing::Values(1), - ::testing::ValuesIn(netPrecisions), - ::testing::ValuesIn(inputShapes4D_dynBatch), - ::testing::ValuesIn(outIndices3), - ::testing::Values(planar_4D_ref, perChannels_4D)), - SplitLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_Split4D_CPU_by_batch, + SplitLayerCPUTest, + ::testing::Combine(::testing::Values(3), + ::testing::Values(1), + ::testing::ValuesIn(netPrecisions), + ::testing::ValuesIn(inputShapes4D_dynBatch), + ::testing::ValuesIn(outIndices3), + ::testing::Values(planar_4D_ref, perChannels_4D)), + SplitLayerCPUTest::getTestCaseName); // ============================================== inPlace cases ============================================ -const std::vector inputShapes4D_inPlace_0 = { - {{}, {{3, 24, 24, 9}}}, - {{}, {{6, 24, 24}}}, - {{}, {{9, 24}}}, - { - // dynamic - {3, -1, -1, -1, -1}, - // target - { - {3, 24, 6, 9, 4}, - {3, 12, 12, 15, 5}, - } - }, - { - // dynamic - {6, -1, -1, -1}, - // target - { - {6, 24, 6, 9}, - {6, 12, 12, 15}, - } - }, - { - // dynamic - {9, -1, -1}, - // target - { - {9, 24, 6}, - {9, 12, 12}, - } - } -}; - -INSTANTIATE_TEST_SUITE_P(smoke_Split_CPU_planar_inPlace_0, SplitLayerCPUTest, - ::testing::Combine( - ::testing::Values(3), - ::testing::Values(0), - ::testing::Values(ElementType::f32), - ::testing::ValuesIn(inputShapes4D_inPlace_0), - ::testing::Values(std::vector{}), - ::testing::Values(CPUSpecificParams{{}, {}, {}, "unknown"})), - SplitLayerCPUTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_Split4D_CPU_Block8inPlace_1, SplitLayerCPUTest, - ::testing::Combine( - ::testing::Values(4), - ::testing::Values(1), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(InputShape{ {}, {{1, 32, 5, 6}} }, - InputShape{ {1, 32, -1, -1}, +const std::vector inputShapes4D_inPlace_0 = {{{}, {{3, 24, 24, 9}}}, + {{}, {{6, 24, 24}}}, + {{}, {{9, 24}}}, + {// dynamic + {3, -1, -1, -1, -1}, + // target { - {1, 32, 5, 6}, - {1, 32, 5, 2}, - {1, 32, 5, 8} - } }), - ::testing::ValuesIn(outIndices4), - ::testing::Values(planar_4D, blocked8_4D)), - SplitLayerCPUTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_Split5D_CPU_Block16inPlace_1, SplitLayerCPUTest, - ::testing::Combine( - ::testing::Values(3), - ::testing::Values(1), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(InputShape{ {}, {{1, 48, 5, 6, 3}} }, - InputShape{ {1, 48, -1, -1, 3}, + {3, 24, 6, 9, 4}, + {3, 12, 12, 15, 5}, + }}, + {// dynamic + {6, -1, -1, -1}, + // target { - {1, 48, 5, 6, 3}, - {1, 48, 5, 2, 3}, - {1, 48, 5, 8, 3} - } }), - ::testing::ValuesIn(outIndices3), - ::testing::Values(planar_5D, blocked16_5D)), - SplitLayerCPUTest::getTestCaseName); - -} // namespace - -} // namespace CPULayerTestsDefinitions + {6, 24, 6, 9}, + {6, 12, 12, 15}, + }}, + {// dynamic + {9, -1, -1}, + // target + { + {9, 24, 6}, + {9, 12, 12}, + }}}; + +INSTANTIATE_TEST_SUITE_P(smoke_Split_CPU_planar_inPlace_0, + SplitLayerCPUTest, + ::testing::Combine(::testing::Values(3), + ::testing::Values(0), + ::testing::Values(ElementType::f32), + ::testing::ValuesIn(inputShapes4D_inPlace_0), + ::testing::Values(std::vector{}), + ::testing::Values(CPUSpecificParams{{}, {}, {}, "unknown"})), + SplitLayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P( + smoke_Split4D_CPU_Block8inPlace_1, + SplitLayerCPUTest, + ::testing::Combine(::testing::Values(4), + ::testing::Values(1), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(InputShape{{}, {{1, 32, 5, 6}}}, + InputShape{{1, 32, -1, -1}, {{1, 32, 5, 6}, {1, 32, 5, 2}, {1, 32, 5, 8}}}), + ::testing::ValuesIn(outIndices4), + ::testing::Values(planar_4D, blocked8_4D)), + SplitLayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P( + smoke_Split5D_CPU_Block16inPlace_1, + SplitLayerCPUTest, + ::testing::Combine(::testing::Values(3), + ::testing::Values(1), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(InputShape{{}, {{1, 48, 5, 6, 3}}}, + InputShape{{1, 48, -1, -1, 3}, + {{1, 48, 5, 6, 3}, {1, 48, 5, 2, 3}, {1, 48, 5, 8, 3}}}), + ::testing::ValuesIn(outIndices3), + ::testing::Values(planar_5D, blocked16_5D)), + SplitLayerCPUTest::getTestCaseName); + +} // namespace \ No newline at end of file diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/strided_slice.cpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/strided_slice.cpp index 4c46b33a295155..58abdabb2c5b9d 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/strided_slice.cpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/strided_slice.cpp @@ -2,15 +2,11 @@ // SPDX-License-Identifier: Apache-2.0 // -#include -#include "ov_models/builders.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "common_test_utils/ov_tensor_utils.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include +#include "test_utils/cpu_test_utils.hpp" -using namespace InferenceEngine; using namespace CPUTestUtils; -using namespace LayerTestsDefinitions; using namespace ov; using namespace test; @@ -27,20 +23,21 @@ struct StridedSliceParams { std::vector ellipsisAxisMask; }; -typedef std::tuple< - InputShape, // Input shapes - StridedSliceParams, - ngraph::helpers::InputLayerType, // Secondary input types - ElementType, // Element type - CPUSpecificParams> StridedSliceLayerCPUTestParamSet; +typedef std::tuple + StridedSliceLayerCPUTestParamSet; class StridedSliceLayerCPUTest : public testing::WithParamInterface, - virtual public SubgraphBaseTest, public CPUTestsBase { + virtual public SubgraphBaseTest, + public CPUTestsBase { public: static std::string getTestCaseName(testing::TestParamInfo obj) { InputShape shapes; StridedSliceParams params; - ngraph::helpers::InputLayerType secondaryInputType; + ov::test::utils::InputLayerType secondaryInputType; ElementType dataType; CPUSpecificParams cpuParams; std::tie(shapes, params, secondaryInputType, dataType, cpuParams) = obj.param; @@ -58,16 +55,19 @@ class StridedSliceLayerCPUTest : public testing::WithParamInterface& targetInputStaticShapes) override { + void generate_inputs(const std::vector& targetInputStaticShapes) override { std::vector inputValues = {ssParams.begin.data(), ssParams.end.data(), ssParams.strides.data()}; inputs.clear(); @@ -76,9 +76,13 @@ class StridedSliceLayerCPUTest : public testing::WithParamInterfaceGetParam(); @@ -108,7 +112,7 @@ class StridedSliceLayerCPUTest : public testing::WithParamInterface(dataType, shape)); } ov::NodeVector ss_inputs; - if (secondaryInputType == ngraph::helpers::InputLayerType::PARAMETER) { + if (secondaryInputType == ov::test::utils::InputLayerType::PARAMETER) { ov::Shape inShape = {ssParams.begin.size()}; auto beginNode = std::make_shared(ov::element::i64, inShape); @@ -125,9 +129,11 @@ class StridedSliceLayerCPUTest : public testing::WithParamInterface(ov::element::i64, constShape, ssParams.begin.data()); + 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 strideNode = + std::make_shared(ov::element::i64, constShape, ssParams.strides.data()); ss_inputs.push_back(params[0]); ss_inputs.push_back(beginNode); @@ -157,343 +163,500 @@ TEST_P(StridedSliceLayerCPUTest, CompareWithRefs) { namespace { -const auto cpuParams_nChw16c = CPUSpecificParams {{nChw16c}, {nChw16c}, {}, {}}; -const auto cpuParams_nCdhw16c = CPUSpecificParams {{nCdhw16c}, {nCdhw16c}, {}, {}}; +const auto cpuParams_nChw16c = CPUSpecificParams{{nChw16c}, {nChw16c}, {}, {}}; +const auto cpuParams_nCdhw16c = CPUSpecificParams{{nCdhw16c}, {nCdhw16c}, {}, {}}; -const auto cpuParams_nChw8c = CPUSpecificParams {{nChw8c}, {nChw8c}, {}, {}}; -const auto cpuParams_nCdhw8c = CPUSpecificParams {{nCdhw8c}, {nCdhw8c}, {}, {}}; +const auto cpuParams_nChw8c = CPUSpecificParams{{nChw8c}, {nChw8c}, {}, {}}; +const auto cpuParams_nCdhw8c = CPUSpecificParams{{nCdhw8c}, {nCdhw8c}, {}, {}}; -const auto cpuParams_nhwc = CPUSpecificParams {{nhwc}, {nhwc}, {}, {}}; -const auto cpuParams_ndhwc = CPUSpecificParams {{ndhwc}, {ndhwc}, {}, {}}; +const auto cpuParams_nhwc = CPUSpecificParams{{nhwc}, {nhwc}, {}, {}}; +const auto cpuParams_ndhwc = CPUSpecificParams{{ndhwc}, {ndhwc}, {}, {}}; -const auto cpuParams_nchw = CPUSpecificParams {{nchw}, {nchw}, {}, {}}; -const auto cpuParams_ncdhw = CPUSpecificParams {{ncdhw}, {ncdhw}, {}, {}}; +const auto cpuParams_nchw = CPUSpecificParams{{nchw}, {nchw}, {}, {}}; +const auto cpuParams_ncdhw = CPUSpecificParams{{ncdhw}, {ncdhw}, {}, {}}; -const std::vector inputPrecisions = { - ElementType::f32, - ElementType::bf16, - ElementType::i8 -}; +const std::vector inputPrecisions = {ElementType::f32, ElementType::bf16, ElementType::i8}; -const std::vector inputLayerTypes = { - ngraph::helpers::InputLayerType::CONSTANT, - ngraph::helpers::InputLayerType::PARAMETER -}; +const std::vector inputLayerTypes = {ov::test::utils::InputLayerType::CONSTANT, + ov::test::utils::InputLayerType::PARAMETER}; const std::vector inputShapesDynamic2D = { - {{-1, -1}, - {{32, 20}, {16, 16}, {24, 16}}}, + {{-1, -1}, {{32, 20}, {16, 16}, {24, 16}}}, - {{-1, 16}, - {{16, 16}, {20, 16}, {32, 16}}}, + {{-1, 16}, {{16, 16}, {20, 16}, {32, 16}}}, - {{{16, 32}, {16, 32}}, - {{16, 32}, {32, 16}, {24, 24}}}, + {{{16, 32}, {16, 32}}, {{16, 32}, {32, 16}, {24, 24}}}, }; const std::vector paramsPlain2D = { - StridedSliceParams{ { 2, 5 }, { 16, 8 }, { 1, 1 }, { 0, 0 }, { 0, 0 }, { }, { }, { } }, - StridedSliceParams{ { -10, -11 }, { -2, -3 }, { 1, 1 }, { 0, 0 }, { 0, 0 }, { }, { }, { } }, - StridedSliceParams{ { -16, -17 }, { -2, -3 }, { 1, 1 }, { 0, 0 }, { 0, 0 }, { }, { }, { } }, - StridedSliceParams{ { 2, 44 }, { 55, -2 }, { 2, 3 }, { 0, 1 }, { 0, 0 }, { }, { }, { } }, - StridedSliceParams{ { 2, -7 }, { 1, -2 }, { 2, 3 }, { 1, 0 }, { 1, 0 }, { }, { }, { } }, - StridedSliceParams{ { 2 }, { 22 }, { 2 }, { 0 }, { 0 }, { }, { }, { } }, + StridedSliceParams{{2, 5}, {16, 8}, {1, 1}, {0, 0}, {0, 0}, {}, {}, {}}, + StridedSliceParams{{-10, -11}, {-2, -3}, {1, 1}, {0, 0}, {0, 0}, {}, {}, {}}, + StridedSliceParams{{-16, -17}, {-2, -3}, {1, 1}, {0, 0}, {0, 0}, {}, {}, {}}, + StridedSliceParams{{2, 44}, {55, -2}, {2, 3}, {0, 1}, {0, 0}, {}, {}, {}}, + StridedSliceParams{{2, -7}, {1, -2}, {2, 3}, {1, 0}, {1, 0}, {}, {}, {}}, + StridedSliceParams{{2}, {22}, {2}, {0}, {0}, {}, {}, {}}, }; -INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_Plain_Static_2D, StridedSliceLayerCPUTest, - ::testing::Combine( - ::testing::ValuesIn(static_shapes_to_test_representation({{32, 20}})), - ::testing::ValuesIn(paramsPlain2D), - ::testing::ValuesIn(inputLayerTypes), - ::testing::ValuesIn(inputPrecisions), - ::testing::Values(emptyCPUSpec)), +INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_Plain_Static_2D, + StridedSliceLayerCPUTest, + ::testing::Combine(::testing::ValuesIn(static_shapes_to_test_representation({{32, 20}})), + ::testing::ValuesIn(paramsPlain2D), + ::testing::ValuesIn(inputLayerTypes), + ::testing::ValuesIn(inputPrecisions), + ::testing::Values(emptyCPUSpec)), StridedSliceLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_Plain_Dynamic_2D, StridedSliceLayerCPUTest, - ::testing::Combine( - ::testing::ValuesIn(inputShapesDynamic2D), - ::testing::ValuesIn(paramsPlain2D), - ::testing::ValuesIn(inputLayerTypes), - ::testing::ValuesIn(inputPrecisions), - ::testing::Values(emptyCPUSpec)), +INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_Plain_Dynamic_2D, + StridedSliceLayerCPUTest, + ::testing::Combine(::testing::ValuesIn(inputShapesDynamic2D), + ::testing::ValuesIn(paramsPlain2D), + ::testing::ValuesIn(inputLayerTypes), + ::testing::ValuesIn(inputPrecisions), + ::testing::Values(emptyCPUSpec)), StridedSliceLayerCPUTest::getTestCaseName); const std::vector testCasesCommon4D = { - StridedSliceParams{ { 0, 2, 5, 4 }, { 1, 4, 28, 27 }, { 1, 1, 1, 1 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { }, { }, { } }, - StridedSliceParams{ { 0, 0, 10, 0 }, { 1, 3, 20, 20 }, { 1, 1, 1, 1 }, { 0, 0, 0, 0 }, { 0, 1, 0, 0 }, { }, { }, { } }, - StridedSliceParams{ { 0, 0, 20, 20 }, { 1, 5, 25, 26 }, { 1, 1, 1, 2 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { }, { }, { } }, - StridedSliceParams{ { 0, 0, 0, 20 }, { 1, 2, 30, 30 }, { 1, 1, 2, 1 }, { 0, 0, 0, 1 }, { 0, 1, 0, 1 }, { }, { }, { } }, - StridedSliceParams{ { 0, 0, 2, 10 }, { 1, 3, 32, 20 }, { 1, 1, 1, 1 }, { 0, 0, 1, 1 }, { 0, 0, 0, 0 }, { }, { }, { } }, - StridedSliceParams{ { 0, 1, 0, 10 }, { 1, 5, 32, 30 }, { 1, 1, 1, 1 }, { 0, 1, 0, 0 }, { 0, 0, 0, 0 }, { }, { }, { } }, - StridedSliceParams{ { 0, 0, 2, 10 }, { 1, 8, 32, 18 }, { 1, 2, 1, 2 }, { 0, 0, 1, 0 }, { 0, 0, 0, 1 }, { }, { }, { } }, - StridedSliceParams{ { 0, 0, 10 }, { 0, 32, 18 }, { 1, 1, 1 }, { 1, 1, 0 }, { 1, 1, 0 }, { }, { }, { 1, 0, 0 } }, - StridedSliceParams{ { 0, 4, 10 }, { 1, 8, 0 }, { 1, 1, 1 }, { 1, 0, 1 }, { 1, 1, 1 }, { }, { }, { 0, 0, 1 } } -}; - -const std::vector inputShapesStatic4D = { - { 1, 5, 32, 32 }, { 2, 5, 32, 48 } -}; + StridedSliceParams{{0, 2, 5, 4}, {1, 4, 28, 27}, {1, 1, 1, 1}, {0, 0, 0, 0}, {0, 0, 0, 0}, {}, {}, {}}, + StridedSliceParams{{0, 0, 10, 0}, {1, 3, 20, 20}, {1, 1, 1, 1}, {0, 0, 0, 0}, {0, 1, 0, 0}, {}, {}, {}}, + StridedSliceParams{{0, 0, 20, 20}, {1, 5, 25, 26}, {1, 1, 1, 2}, {0, 0, 0, 0}, {0, 0, 0, 0}, {}, {}, {}}, + StridedSliceParams{{0, 0, 0, 20}, {1, 2, 30, 30}, {1, 1, 2, 1}, {0, 0, 0, 1}, {0, 1, 0, 1}, {}, {}, {}}, + StridedSliceParams{{0, 0, 2, 10}, {1, 3, 32, 20}, {1, 1, 1, 1}, {0, 0, 1, 1}, {0, 0, 0, 0}, {}, {}, {}}, + StridedSliceParams{{0, 1, 0, 10}, {1, 5, 32, 30}, {1, 1, 1, 1}, {0, 1, 0, 0}, {0, 0, 0, 0}, {}, {}, {}}, + StridedSliceParams{{0, 0, 2, 10}, {1, 8, 32, 18}, {1, 2, 1, 2}, {0, 0, 1, 0}, {0, 0, 0, 1}, {}, {}, {}}, + StridedSliceParams{{0, 0, 10}, {0, 32, 18}, {1, 1, 1}, {1, 1, 0}, {1, 1, 0}, {}, {}, {1, 0, 0}}, + StridedSliceParams{{0, 4, 10}, {1, 8, 0}, {1, 1, 1}, {1, 0, 1}, {1, 1, 1}, {}, {}, {0, 0, 1}}}; + +const std::vector inputShapesStatic4D = {{1, 5, 32, 32}, {2, 5, 32, 48}}; const std::vector inputShapesDynamic4D = { - {{-1, -1, -1, -1}, - {{ 1, 5, 32, 32 }, { 2, 5, 32, 32 }, { 1, 5, 64, 64 }, {0, 0, 0, 0}}}, + {{-1, -1, -1, -1}, {{1, 5, 32, 32}, {2, 5, 32, 32}, {1, 5, 64, 64}, {0, 0, 0, 0}}}, - {{-1, 5, -1, -1}, - {{ 1, 5, 32, 32 }, { 2, 5, 32, 32 }, { 3, 5, 32, 36 }, {0, 5, 0, 0}}}, + {{-1, 5, -1, -1}, {{1, 5, 32, 32}, {2, 5, 32, 32}, {3, 5, 32, 36}, {0, 5, 0, 0}}}, - {{{1, 5}, 5, {32, 64}, {32, 64}}, - {{ 2, 5, 32, 32 }, { 1, 5, 48, 32 }, { 5, 5, 32, 32 }}}, + {{{1, 5}, 5, {32, 64}, {32, 64}}, {{2, 5, 32, 32}, {1, 5, 48, 32}, {5, 5, 32, 32}}}, }; const std::vector CPUParamsCommon4D = { - cpuParams_nchw, - cpuParams_nhwc, + cpuParams_nchw, + cpuParams_nhwc, }; -INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_Common_Static_4D, StridedSliceLayerCPUTest, - ::testing::Combine( - ::testing::ValuesIn(static_shapes_to_test_representation(inputShapesStatic4D)), - ::testing::ValuesIn(testCasesCommon4D), - ::testing::ValuesIn(inputLayerTypes), - ::testing::ValuesIn(inputPrecisions), - ::testing::ValuesIn(CPUParamsCommon4D)), - StridedSliceLayerCPUTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_Common_Dynamic_4D, StridedSliceLayerCPUTest, - ::testing::Combine( - ::testing::ValuesIn(inputShapesDynamic4D), - ::testing::ValuesIn(testCasesCommon4D), - ::testing::ValuesIn(inputLayerTypes), - ::testing::ValuesIn(inputPrecisions), - ::testing::ValuesIn(CPUParamsCommon4D)), +INSTANTIATE_TEST_SUITE_P( + smoke_CompareWithRefs_Common_Static_4D, + StridedSliceLayerCPUTest, + ::testing::Combine(::testing::ValuesIn(static_shapes_to_test_representation(inputShapesStatic4D)), + ::testing::ValuesIn(testCasesCommon4D), + ::testing::ValuesIn(inputLayerTypes), + ::testing::ValuesIn(inputPrecisions), + ::testing::ValuesIn(CPUParamsCommon4D)), + StridedSliceLayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_Common_Dynamic_4D, + StridedSliceLayerCPUTest, + ::testing::Combine(::testing::ValuesIn(inputShapesDynamic4D), + ::testing::ValuesIn(testCasesCommon4D), + ::testing::ValuesIn(inputLayerTypes), + ::testing::ValuesIn(inputPrecisions), + ::testing::ValuesIn(CPUParamsCommon4D)), StridedSliceLayerCPUTest::getTestCaseName); const std::vector testCasesBlocked4DSubset1 = { - StridedSliceParams{ { 0, 0, 0, 0 }, { 1, 32, 32, 32 }, { 1, 1, 1, 1 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { }, { }, { } }, - StridedSliceParams{ { 0, 0, 16, 0 }, { 1, 32, 32, 32 }, { 1, 1, 1, 1 }, { 0, 0, 0, 0 }, { 0, 0, 0, 1 }, { }, { }, { } }, - StridedSliceParams{ { 0, 0, 0, 0 }, { 1, 32, 32, 16 }, { 1, 1, 1, 1 }, { 0, 0, 0, 0 }, { 0, 0, 0, 1 }, { }, { }, { } }, - StridedSliceParams{ { 0, 0, 0, 0 }, { 1, 16, 32, 32 }, { 1, 1, 1, 1 }, { 0, 0, 0, 0 }, { 0, 0, 0, 1 }, { }, { }, { } }, + StridedSliceParams{{0, 0, 0, 0}, {1, 32, 32, 32}, {1, 1, 1, 1}, {0, 0, 0, 0}, {0, 0, 0, 0}, {}, {}, {}}, + StridedSliceParams{{0, 0, 16, 0}, {1, 32, 32, 32}, {1, 1, 1, 1}, {0, 0, 0, 0}, {0, 0, 0, 1}, {}, {}, {}}, + StridedSliceParams{{0, 0, 0, 0}, {1, 32, 32, 16}, {1, 1, 1, 1}, {0, 0, 0, 0}, {0, 0, 0, 1}, {}, {}, {}}, + StridedSliceParams{{0, 0, 0, 0}, {1, 16, 32, 32}, {1, 1, 1, 1}, {0, 0, 0, 0}, {0, 0, 0, 1}, {}, {}, {}}, }; const std::vector testCasesBlocked4DSubset2 = { - StridedSliceParams{ { 0, 0, 5, 4 }, { 1, 16, 28, 27 }, { 1, 1, 1, 1 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { }, { }, { } }, - StridedSliceParams{ { 0, 16, 0, 0 }, { 1, 32, 10, 10 }, { 1, 1, 1, 1 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { }, { }, { } }, - StridedSliceParams{ { 0, 0, 20, 20 }, { 1, 32, 25, 25 }, { 1, 1, 1, 1 }, { 0, 1, 0, 0 }, { 0, 1, 0, 0 }, { }, { }, { } }, - StridedSliceParams{ { 0, 16, 2, 10 }, { 1, 32, 32, 20 }, { 1, 1, 2, 1 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { }, { }, { } }, - StridedSliceParams{ { 0, 16, 0, 0 }, { 2, 64, 32, 20 }, { 1, 1, 1, 1 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { }, { }, { } }, - StridedSliceParams{ { 0, 32, 0, 0 }, { 2, 50, 32, 20 }, { 1, 1, 1, 1 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { }, { }, { } }, - StridedSliceParams{ { 0, 0, 0, 0 }, { 2, 12, 32, 20 }, { 1, 1, 1, 1 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { }, { }, { } }, - StridedSliceParams{ { 0, -16, 0, 10 }, { 2, 100, 32, 20 }, { 1, 1, 1, 1 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { }, { }, { } }, - StridedSliceParams{ { 0, -32, 0, 0 }, { 2, -12, 32, 20 }, { 1, 1, 1, 1 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { }, { }, { } }, - StridedSliceParams{ { 0, 10 }, { 0, 20 }, { 1, 1 }, { 1, 0 }, { 1, 0 }, { }, { }, { 1, 0 } }, - StridedSliceParams{ { 0, 16, 0 }, { 2, 32, 0 }, { 1, 1, 1 }, { 1, 0, 1 }, { 1, 1, 1 }, { }, { }, { 0, 0, 1 } }, + StridedSliceParams{{0, 0, 5, 4}, {1, 16, 28, 27}, {1, 1, 1, 1}, {0, 0, 0, 0}, {0, 0, 0, 0}, {}, {}, {}}, + StridedSliceParams{{0, 16, 0, 0}, {1, 32, 10, 10}, {1, 1, 1, 1}, {0, 0, 0, 0}, {0, 0, 0, 0}, {}, {}, {}}, + StridedSliceParams{{0, 0, 20, 20}, {1, 32, 25, 25}, {1, 1, 1, 1}, {0, 1, 0, 0}, {0, 1, 0, 0}, {}, {}, {}}, + StridedSliceParams{{0, 16, 2, 10}, {1, 32, 32, 20}, {1, 1, 2, 1}, {0, 0, 0, 0}, {0, 0, 0, 0}, {}, {}, {}}, + StridedSliceParams{{0, 16, 0, 0}, {2, 64, 32, 20}, {1, 1, 1, 1}, {0, 0, 0, 0}, {0, 0, 0, 0}, {}, {}, {}}, + StridedSliceParams{{0, 32, 0, 0}, {2, 50, 32, 20}, {1, 1, 1, 1}, {0, 0, 0, 0}, {0, 0, 0, 0}, {}, {}, {}}, + StridedSliceParams{{0, 0, 0, 0}, {2, 12, 32, 20}, {1, 1, 1, 1}, {0, 0, 0, 0}, {0, 0, 0, 0}, {}, {}, {}}, + StridedSliceParams{{0, -16, 0, 10}, {2, 100, 32, 20}, {1, 1, 1, 1}, {0, 0, 0, 0}, {0, 0, 0, 0}, {}, {}, {}}, + StridedSliceParams{{0, -32, 0, 0}, {2, -12, 32, 20}, {1, 1, 1, 1}, {0, 0, 0, 0}, {0, 0, 0, 0}, {}, {}, {}}, + StridedSliceParams{{0, 10}, {0, 20}, {1, 1}, {1, 0}, {1, 0}, {}, {}, {1, 0}}, + StridedSliceParams{{0, 16, 0}, {2, 32, 0}, {1, 1, 1}, {1, 0, 1}, {1, 1, 1}, {}, {}, {0, 0, 1}}, }; -const std::vector inputShapesBlockedStatic4DSubset1 = { - { 1, 32, 32, 32 }, { 1, 32, 32, 64 } -}; +const std::vector inputShapesBlockedStatic4DSubset1 = {{1, 32, 32, 32}, {1, 32, 32, 64}}; -const std::vector inputShapesBlockedStatic4DSubset2 = { - { 1, 64, 32, 32 }, { 1, 64, 32, 64 } -}; +const std::vector inputShapesBlockedStatic4DSubset2 = {{1, 64, 32, 32}, {1, 64, 32, 64}}; const std::vector inputShapesBlockedDynamic4DSubset1 = { - {{-1, 32, -1, -1}, - {{ 1, 32, 32, 32 }, { 2, 32, 32, 32 }, { 3, 32, 32, 48 }}}, + {{-1, 32, -1, -1}, {{1, 32, 32, 32}, {2, 32, 32, 32}, {3, 32, 32, 48}}}, - {{{1, 5}, 32, {32, 64}, {32, 64}}, - {{ 2, 32, 32, 32 }, { 1, 32, 48, 32 }, { 5, 32, 32, 48 }}}, + {{{1, 5}, 32, {32, 64}, {32, 64}}, {{2, 32, 32, 32}, {1, 32, 48, 32}, {5, 32, 32, 48}}}, }; const std::vector inputShapesBlockedDynamic4DSubset2 = { - {{-1, 64, -1, -1}, - {{ 1, 64, 64, 32 }, { 2, 64, 32, 32 }, { 3, 64, 32, 48 }}}, + {{-1, 64, -1, -1}, {{1, 64, 64, 32}, {2, 64, 32, 32}, {3, 64, 32, 48}}}, - {{{1, 5}, 64, {32, 64}, {32, 64}}, - {{ 2, 64, 32, 32 }, { 1, 64, 48, 32 }, { 1, 64, 64, 64 }}}, + {{{1, 5}, 64, {32, 64}, {32, 64}}, {{2, 64, 32, 32}, {1, 64, 48, 32}, {1, 64, 64, 64}}}, }; const std::vector CPUParamsBlocked4D = { - cpuParams_nChw16c, - cpuParams_nChw8c, + cpuParams_nChw16c, + cpuParams_nChw8c, }; -const std::vector inputLayerTypesBlocked = { - ngraph::helpers::InputLayerType::CONSTANT, +const std::vector inputLayerTypesBlocked = { + ov::test::utils::InputLayerType::CONSTANT, }; -INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_Common_Static_4D_Subset1, StridedSliceLayerCPUTest, - ::testing::Combine( - ::testing::ValuesIn(static_shapes_to_test_representation(inputShapesBlockedStatic4DSubset1)), - ::testing::ValuesIn(testCasesBlocked4DSubset1), - ::testing::ValuesIn(inputLayerTypesBlocked), - ::testing::ValuesIn(inputPrecisions), - ::testing::ValuesIn(CPUParamsBlocked4D)), - StridedSliceLayerCPUTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_Common_Dynamic_4D_Subset1, StridedSliceLayerCPUTest, - ::testing::Combine( - ::testing::ValuesIn(inputShapesBlockedDynamic4DSubset1), - ::testing::ValuesIn(testCasesBlocked4DSubset1), - ::testing::ValuesIn(inputLayerTypesBlocked), - ::testing::ValuesIn(inputPrecisions), - ::testing::ValuesIn(CPUParamsBlocked4D)), - StridedSliceLayerCPUTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_Common_Static_4D_Subset2, StridedSliceLayerCPUTest, - ::testing::Combine( - ::testing::ValuesIn(static_shapes_to_test_representation(inputShapesBlockedStatic4DSubset2)), - ::testing::ValuesIn(testCasesBlocked4DSubset2), - ::testing::ValuesIn(inputLayerTypesBlocked), - ::testing::ValuesIn(inputPrecisions), - ::testing::ValuesIn(CPUParamsBlocked4D)), +INSTANTIATE_TEST_SUITE_P( + smoke_CompareWithRefs_Common_Static_4D_Subset1, + StridedSliceLayerCPUTest, + ::testing::Combine(::testing::ValuesIn(static_shapes_to_test_representation(inputShapesBlockedStatic4DSubset1)), + ::testing::ValuesIn(testCasesBlocked4DSubset1), + ::testing::ValuesIn(inputLayerTypesBlocked), + ::testing::ValuesIn(inputPrecisions), + ::testing::ValuesIn(CPUParamsBlocked4D)), + StridedSliceLayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_Common_Dynamic_4D_Subset1, + StridedSliceLayerCPUTest, + ::testing::Combine(::testing::ValuesIn(inputShapesBlockedDynamic4DSubset1), + ::testing::ValuesIn(testCasesBlocked4DSubset1), + ::testing::ValuesIn(inputLayerTypesBlocked), + ::testing::ValuesIn(inputPrecisions), + ::testing::ValuesIn(CPUParamsBlocked4D)), StridedSliceLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_Common_Dynamic_4D_Subset2, StridedSliceLayerCPUTest, - ::testing::Combine( - ::testing::ValuesIn(inputShapesBlockedDynamic4DSubset2), - ::testing::ValuesIn(testCasesBlocked4DSubset2), - ::testing::ValuesIn(inputLayerTypesBlocked), - ::testing::ValuesIn(inputPrecisions), - ::testing::ValuesIn(CPUParamsBlocked4D)), +INSTANTIATE_TEST_SUITE_P( + smoke_CompareWithRefs_Common_Static_4D_Subset2, + StridedSliceLayerCPUTest, + ::testing::Combine(::testing::ValuesIn(static_shapes_to_test_representation(inputShapesBlockedStatic4DSubset2)), + ::testing::ValuesIn(testCasesBlocked4DSubset2), + ::testing::ValuesIn(inputLayerTypesBlocked), + ::testing::ValuesIn(inputPrecisions), + ::testing::ValuesIn(CPUParamsBlocked4D)), + StridedSliceLayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_Common_Dynamic_4D_Subset2, + StridedSliceLayerCPUTest, + ::testing::Combine(::testing::ValuesIn(inputShapesBlockedDynamic4DSubset2), + ::testing::ValuesIn(testCasesBlocked4DSubset2), + ::testing::ValuesIn(inputLayerTypesBlocked), + ::testing::ValuesIn(inputPrecisions), + ::testing::ValuesIn(CPUParamsBlocked4D)), StridedSliceLayerCPUTest::getTestCaseName); const std::vector testCasesCommon5D = { - StridedSliceParams{ { 0, 2, 0, 5, 4 }, { 1, 4, 5, 28, 27 }, { 1, 1, 1, 1, 1 }, { 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0 }, { }, { }, { } }, - StridedSliceParams{ { 0, 0, 10, 0, 0 }, { 1, 5, 20, 32, 20 }, { 1, 1, 1, 1, 1 }, { 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0 }, { }, { }, { } }, - StridedSliceParams{ { 0, 1, 10, 0, 0 }, { 1, 3, 20, 32, 20 }, { 1, 1, 1, 1, 1 }, { 0, 1, 0, 0, 0 }, { 0, 0, 0, 0, 0 }, { }, { }, { } }, - StridedSliceParams{ { 0, 0, 0, 20, 20 }, { 1, 5, 20, 30, 26 }, { 1, 1, 1, 2, 2 }, { 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0 }, { }, { }, { } }, - StridedSliceParams{ { 0, 0, 10, 0, 20 }, { 1, 2, 20, 30, 30 }, { 1, 1, 2, 1, 1 }, { 0, 0, 0, 0, 1 }, { 0, 1, 0, 1, 0 }, { }, { }, { } }, - StridedSliceParams{ { 0, 0, 2, 10, 0 }, { 1, 5, 10, 32, 20 }, { 1, 1, 1, 1, 1 }, { 0, 0, 1, 1, 0 }, { 0, 0, 0, 0, 1 }, { }, { }, { } }, - StridedSliceParams{ { 0, 1, 0, 10, 0 }, { 1, 5, 20, 32, 32 }, { 1, 1, 1, 1, 1 }, { 0, 1, 0, 0, 0 }, { 0, 0, 0, 0, 0 }, { }, { }, { } }, - StridedSliceParams{ { 0, 0, 0, 0, 0 }, { 1, 5, 10, 16, 16 }, { 1, 1, 2, 1, 1 }, { 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0 }, { }, { }, { } }, + StridedSliceParams{{0, 2, 0, 5, 4}, + {1, 4, 5, 28, 27}, + {1, 1, 1, 1, 1}, + {0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0}, + {}, + {}, + {}}, + StridedSliceParams{{0, 0, 10, 0, 0}, + {1, 5, 20, 32, 20}, + {1, 1, 1, 1, 1}, + {0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0}, + {}, + {}, + {}}, + StridedSliceParams{{0, 1, 10, 0, 0}, + {1, 3, 20, 32, 20}, + {1, 1, 1, 1, 1}, + {0, 1, 0, 0, 0}, + {0, 0, 0, 0, 0}, + {}, + {}, + {}}, + StridedSliceParams{{0, 0, 0, 20, 20}, + {1, 5, 20, 30, 26}, + {1, 1, 1, 2, 2}, + {0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0}, + {}, + {}, + {}}, + StridedSliceParams{{0, 0, 10, 0, 20}, + {1, 2, 20, 30, 30}, + {1, 1, 2, 1, 1}, + {0, 0, 0, 0, 1}, + {0, 1, 0, 1, 0}, + {}, + {}, + {}}, + StridedSliceParams{{0, 0, 2, 10, 0}, + {1, 5, 10, 32, 20}, + {1, 1, 1, 1, 1}, + {0, 0, 1, 1, 0}, + {0, 0, 0, 0, 1}, + {}, + {}, + {}}, + StridedSliceParams{{0, 1, 0, 10, 0}, + {1, 5, 20, 32, 32}, + {1, 1, 1, 1, 1}, + {0, 1, 0, 0, 0}, + {0, 0, 0, 0, 0}, + {}, + {}, + {}}, + StridedSliceParams{{0, 0, 0, 0, 0}, + {1, 5, 10, 16, 16}, + {1, 1, 2, 1, 1}, + {0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0}, + {}, + {}, + {}}, }; -const std::vector inputShapesStatic5D = { - { 1, 5, 20, 32, 32 }, { 2, 5, 32, 32, 32 } -}; +const std::vector inputShapesStatic5D = {{1, 5, 20, 32, 32}, {2, 5, 32, 32, 32}}; const std::vector inputShapesDynamic5D = { - {{-1, -1, -1, -1, -1}, - {{ 1, 5, 32, 32, 32 }, { 1, 5, 32, 32, 48 }, { 1, 5, 64, 64, 64 }, { 1, 10, 32, 32, 32 }, {0, 0, 0, 0, 0}}}, + {{-1, -1, -1, -1, -1}, + {{1, 5, 32, 32, 32}, {1, 5, 32, 32, 48}, {1, 5, 64, 64, 64}, {1, 10, 32, 32, 32}, {0, 0, 0, 0, 0}}}, - {{-1, 5, -1, -1, -1}, - {{ 1, 5, 32, 32, 48 }, { 1, 5, 32, 48, 32 }, { 1, 5, 48, 32, 32 }, {0, 5, 0, 0, 0}}}, + {{-1, 5, -1, -1, -1}, {{1, 5, 32, 32, 48}, {1, 5, 32, 48, 32}, {1, 5, 48, 32, 32}, {0, 5, 0, 0, 0}}}, - {{{1, 5}, 5, {32, 64}, {32, 64}, {32, 64}}, - {{ 2, 5, 32, 32, 32 }, { 1, 5, 48, 32, 32 }, { 5, 5, 32, 32, 48 }}}, + {{{1, 5}, 5, {32, 64}, {32, 64}, {32, 64}}, {{2, 5, 32, 32, 32}, {1, 5, 48, 32, 32}, {5, 5, 32, 32, 48}}}, }; const std::vector CPUParamsCommon5D = { - cpuParams_ncdhw, - cpuParams_ndhwc, + cpuParams_ncdhw, + cpuParams_ndhwc, }; -INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_Common_Static_5D, StridedSliceLayerCPUTest, - ::testing::Combine( - ::testing::ValuesIn(static_shapes_to_test_representation(inputShapesStatic5D)), - ::testing::ValuesIn(testCasesCommon5D), - ::testing::ValuesIn(inputLayerTypes), - ::testing::ValuesIn(inputPrecisions), - ::testing::ValuesIn(CPUParamsCommon5D)), - StridedSliceLayerCPUTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_Common_Dynamic_5D, StridedSliceLayerCPUTest, - ::testing::Combine( - ::testing::ValuesIn(inputShapesDynamic5D), - ::testing::ValuesIn(testCasesCommon5D), - ::testing::ValuesIn(inputLayerTypes), - ::testing::ValuesIn(inputPrecisions), - ::testing::ValuesIn(CPUParamsCommon5D)), +INSTANTIATE_TEST_SUITE_P( + smoke_CompareWithRefs_Common_Static_5D, + StridedSliceLayerCPUTest, + ::testing::Combine(::testing::ValuesIn(static_shapes_to_test_representation(inputShapesStatic5D)), + ::testing::ValuesIn(testCasesCommon5D), + ::testing::ValuesIn(inputLayerTypes), + ::testing::ValuesIn(inputPrecisions), + ::testing::ValuesIn(CPUParamsCommon5D)), + StridedSliceLayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_Common_Dynamic_5D, + StridedSliceLayerCPUTest, + ::testing::Combine(::testing::ValuesIn(inputShapesDynamic5D), + ::testing::ValuesIn(testCasesCommon5D), + ::testing::ValuesIn(inputLayerTypes), + ::testing::ValuesIn(inputPrecisions), + ::testing::ValuesIn(CPUParamsCommon5D)), StridedSliceLayerCPUTest::getTestCaseName); const std::vector testCasesBlocked5DSubset1 = { - StridedSliceParams{ { 0, 0, 0, 5, 4 }, { 1, 16, 5, 28, 27 }, { 1, 1, 1, 1, 1 }, { 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0 }, { }, { }, { } }, - StridedSliceParams{ { 0, 0, 10, 0, 0 }, { 1, 16, 20, 32, 20 }, { 1, 1, 1, 1, 1 }, { 0, 0, 0, 0, 0 }, { 0, 1, 0, 0, 0 }, { }, { }, { } }, - StridedSliceParams{ { 0, 0, 0, 20, 20 }, { 1, 16, 20, 30, 26 }, { 1, 1, 1, 2, 2 }, { 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0 }, { }, { }, { } }, - StridedSliceParams{ { 0, 0, 10, 0, 20 }, { 1, 16, 20, 30, 30 }, { 1, 1, 2, 1, 1 }, { 0, 0, 0, 0, 1 }, { 0, 1, 0, 1, 0 }, { }, { }, { } }, - StridedSliceParams{ { 0, 0, 2, 10, 0 }, { 1, 16, 10, 32, 20 }, { 1, 1, 1, 1, 1 }, { 0, 0, 1, 1, 0 }, { 0, 0, 0, 0, 1 }, { }, { }, { } }, - StridedSliceParams{ { 0, 0, 0, 10, 0 }, { 1, 8, 20, 32, 32 }, { 1, 1, 1, 1, 1 }, { 0, 1, 0, 0, 0 }, { 0, 1, 0, 0, 0 }, { }, { }, { } }, - StridedSliceParams{ { 0, 0, 0, 0, 0 }, { 1, 16, 10, 16, 16 }, { 1, 1, 2, 1, 1 }, { 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0 }, { }, { }, { } }, + StridedSliceParams{{0, 0, 0, 5, 4}, + {1, 16, 5, 28, 27}, + {1, 1, 1, 1, 1}, + {0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0}, + {}, + {}, + {}}, + StridedSliceParams{{0, 0, 10, 0, 0}, + {1, 16, 20, 32, 20}, + {1, 1, 1, 1, 1}, + {0, 0, 0, 0, 0}, + {0, 1, 0, 0, 0}, + {}, + {}, + {}}, + StridedSliceParams{{0, 0, 0, 20, 20}, + {1, 16, 20, 30, 26}, + {1, 1, 1, 2, 2}, + {0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0}, + {}, + {}, + {}}, + StridedSliceParams{{0, 0, 10, 0, 20}, + {1, 16, 20, 30, 30}, + {1, 1, 2, 1, 1}, + {0, 0, 0, 0, 1}, + {0, 1, 0, 1, 0}, + {}, + {}, + {}}, + StridedSliceParams{{0, 0, 2, 10, 0}, + {1, 16, 10, 32, 20}, + {1, 1, 1, 1, 1}, + {0, 0, 1, 1, 0}, + {0, 0, 0, 0, 1}, + {}, + {}, + {}}, + StridedSliceParams{{0, 0, 0, 10, 0}, + {1, 8, 20, 32, 32}, + {1, 1, 1, 1, 1}, + {0, 1, 0, 0, 0}, + {0, 1, 0, 0, 0}, + {}, + {}, + {}}, + StridedSliceParams{{0, 0, 0, 0, 0}, + {1, 16, 10, 16, 16}, + {1, 1, 2, 1, 1}, + {0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0}, + {}, + {}, + {}}, }; const std::vector testCasesBlocked5DSubset2 = { - StridedSliceParams{ { 0, 0, 0, 5, 4 }, { 1, 16, 5, 28, 27 }, { 1, 1, 1, 1, 1 }, { 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0 }, { }, { }, { } }, - StridedSliceParams{ { 0, 0, 10, 0, 0 }, { 1, 16, 20, 32, 20 }, { 1, 1, 1, 1, 1 }, { 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0 }, { }, { }, { } }, - StridedSliceParams{ { 0, 0, 10, 0, 0 }, { 1, 16, 20, 32, 20 }, { 1, 1, 1, 1, 1 }, { 0, 0, 0, 0, 0 }, { 0, 1, 0, 0, 0 }, { }, { }, { } }, - StridedSliceParams{ { 0, 0, 0, 20, 20 }, { 1, 16, 20, 30, 26 }, { 1, 1, 1, 2, 2 }, { 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0 }, { }, { }, { } }, - StridedSliceParams{ { 0, 0, 10, 0, 20 }, { 1, 16, 20, 30, 30 }, { 1, 1, 2, 1, 1 }, { 0, 0, 0, 0, 1 }, { 0, 1, 0, 1, 0 }, { }, { }, { } }, - StridedSliceParams{ { 0, 0, 2, 10, 0 }, { 1, 16, 10, 32, 20 }, { 1, 1, 1, 1, 1 }, { 0, 0, 1, 1, 0 }, { 0, 0, 0, 0, 1 }, { }, { }, { } }, - StridedSliceParams{ { 0, 0, 0, 10, 0 }, { 1, 8, 20, 32, 32 }, { 1, 1, 1, 1, 1 }, { 0, 1, 0, 0, 0 }, { 0, 1, 0, 0, 0 }, { }, { }, { } }, - StridedSliceParams{ { 0, 0, 0, 0, 0 }, { 1, 16, 10, 16, 16 }, { 1, 1, 2, 1, 1 }, { 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0 }, { }, { }, { } }, - StridedSliceParams{ { 0, 0, 0, 0, 0 }, { 1, 25, 20, 10, 10 }, { 1, 1, 1, 1, 1 }, { 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0 }, { }, { }, { } }, - StridedSliceParams{ { 0, 16, 0, 0, 0 }, { 1, 25, 20, 10, 10 }, { 1, 1, 1, 1, 1 }, { 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0 }, { }, { }, { } }, - StridedSliceParams{ { 0, 16, 0, 0, 0 }, { 1, 64, 20, 10, 10 }, { 1, 1, 1, 1, 1 }, { 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0 }, { }, { }, { } }, + StridedSliceParams{{0, 0, 0, 5, 4}, + {1, 16, 5, 28, 27}, + {1, 1, 1, 1, 1}, + {0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0}, + {}, + {}, + {}}, + StridedSliceParams{{0, 0, 10, 0, 0}, + {1, 16, 20, 32, 20}, + {1, 1, 1, 1, 1}, + {0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0}, + {}, + {}, + {}}, + StridedSliceParams{{0, 0, 10, 0, 0}, + {1, 16, 20, 32, 20}, + {1, 1, 1, 1, 1}, + {0, 0, 0, 0, 0}, + {0, 1, 0, 0, 0}, + {}, + {}, + {}}, + StridedSliceParams{{0, 0, 0, 20, 20}, + {1, 16, 20, 30, 26}, + {1, 1, 1, 2, 2}, + {0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0}, + {}, + {}, + {}}, + StridedSliceParams{{0, 0, 10, 0, 20}, + {1, 16, 20, 30, 30}, + {1, 1, 2, 1, 1}, + {0, 0, 0, 0, 1}, + {0, 1, 0, 1, 0}, + {}, + {}, + {}}, + StridedSliceParams{{0, 0, 2, 10, 0}, + {1, 16, 10, 32, 20}, + {1, 1, 1, 1, 1}, + {0, 0, 1, 1, 0}, + {0, 0, 0, 0, 1}, + {}, + {}, + {}}, + StridedSliceParams{{0, 0, 0, 10, 0}, + {1, 8, 20, 32, 32}, + {1, 1, 1, 1, 1}, + {0, 1, 0, 0, 0}, + {0, 1, 0, 0, 0}, + {}, + {}, + {}}, + StridedSliceParams{{0, 0, 0, 0, 0}, + {1, 16, 10, 16, 16}, + {1, 1, 2, 1, 1}, + {0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0}, + {}, + {}, + {}}, + StridedSliceParams{{0, 0, 0, 0, 0}, + {1, 25, 20, 10, 10}, + {1, 1, 1, 1, 1}, + {0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0}, + {}, + {}, + {}}, + StridedSliceParams{{0, 16, 0, 0, 0}, + {1, 25, 20, 10, 10}, + {1, 1, 1, 1, 1}, + {0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0}, + {}, + {}, + {}}, + StridedSliceParams{{0, 16, 0, 0, 0}, + {1, 64, 20, 10, 10}, + {1, 1, 1, 1, 1}, + {0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0}, + {}, + {}, + {}}, }; -const std::vector inputShapesBlockedStatic5DSubset1 = { - { 1, 16, 32, 32, 32 }, { 2, 16, 32, 32, 32 }, { 2, 32, 32, 32, 32 } -}; +const std::vector inputShapesBlockedStatic5DSubset1 = {{1, 16, 32, 32, 32}, + {2, 16, 32, 32, 32}, + {2, 32, 32, 32, 32}}; -const std::vector inputShapesBlockedStatic5DSubset2 = { - { 1, 64, 32, 32, 32 }, { 2, 64, 32, 64, 32 }, { 2, 64, 32, 32, 32 } -}; +const std::vector inputShapesBlockedStatic5DSubset2 = {{1, 64, 32, 32, 32}, + {2, 64, 32, 64, 32}, + {2, 64, 32, 32, 32}}; const std::vector inputShapesBlockedDynamic5DSubset1 = { - {{-1, 16, -1, -1, -1}, - {{ 1, 16, 32, 32, 32 }, { 2, 16, 32, 32, 32 }, { 2, 16, 32, 32, 32 }}}, + {{-1, 16, -1, -1, -1}, {{1, 16, 32, 32, 32}, {2, 16, 32, 32, 32}, {2, 16, 32, 32, 32}}}, - {{{1, 5}, 16, {16, 32}, {16, 32}, {16, 32}}, - {{ 1, 16, 32, 32, 32 }, { 2, 16, 32, 32, 32 }, { 1, 16, 20, 32, 32 }}}, + {{{1, 5}, 16, {16, 32}, {16, 32}, {16, 32}}, {{1, 16, 32, 32, 32}, {2, 16, 32, 32, 32}, {1, 16, 20, 32, 32}}}, }; const std::vector inputShapesBlockedDynamic5DSubset2 = { - {{-1, 64, -1, -1, -1}, - {{ 1, 64, 64, 32, 32 }, { 2, 64, 32, 32, 32 }, { 3, 64, 32, 48, 32 }}}, + {{-1, 64, -1, -1, -1}, {{1, 64, 64, 32, 32}, {2, 64, 32, 32, 32}, {3, 64, 32, 48, 32}}}, - {{{1, 5}, 64, {16, 32}, {16, 32}, {16, 32}}, - {{ 1, 64, 32, 32, 32 }, { 2, 64, 32, 32, 32 }, { 1, 64, 20, 32, 32 }}}, + {{{1, 5}, 64, {16, 32}, {16, 32}, {16, 32}}, {{1, 64, 32, 32, 32}, {2, 64, 32, 32, 32}, {1, 64, 20, 32, 32}}}, }; const std::vector CPUParamsBlocked5D = { - cpuParams_nCdhw16c, - cpuParams_nCdhw8c, + cpuParams_nCdhw16c, + cpuParams_nCdhw8c, }; -INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_Common_Static_5D_Subset1, StridedSliceLayerCPUTest, - ::testing::Combine( - ::testing::ValuesIn(static_shapes_to_test_representation(inputShapesBlockedStatic5DSubset1)), - ::testing::ValuesIn(testCasesBlocked5DSubset1), - ::testing::ValuesIn(inputLayerTypesBlocked), - ::testing::ValuesIn(inputPrecisions), - ::testing::ValuesIn(CPUParamsBlocked5D)), +INSTANTIATE_TEST_SUITE_P( + smoke_CompareWithRefs_Common_Static_5D_Subset1, + StridedSliceLayerCPUTest, + ::testing::Combine(::testing::ValuesIn(static_shapes_to_test_representation(inputShapesBlockedStatic5DSubset1)), + ::testing::ValuesIn(testCasesBlocked5DSubset1), + ::testing::ValuesIn(inputLayerTypesBlocked), + ::testing::ValuesIn(inputPrecisions), + ::testing::ValuesIn(CPUParamsBlocked5D)), + StridedSliceLayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_Common_Dynamic_5D_Subset1, + StridedSliceLayerCPUTest, + ::testing::Combine(::testing::ValuesIn(inputShapesBlockedDynamic5DSubset1), + ::testing::ValuesIn(testCasesBlocked5DSubset1), + ::testing::ValuesIn(inputLayerTypesBlocked), + ::testing::ValuesIn(inputPrecisions), + ::testing::ValuesIn(CPUParamsBlocked5D)), StridedSliceLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_Common_Dynamic_5D_Subset1, StridedSliceLayerCPUTest, - ::testing::Combine( - ::testing::ValuesIn(inputShapesBlockedDynamic5DSubset1), - ::testing::ValuesIn(testCasesBlocked5DSubset1), - ::testing::ValuesIn(inputLayerTypesBlocked), - ::testing::ValuesIn(inputPrecisions), - ::testing::ValuesIn(CPUParamsBlocked5D)), - StridedSliceLayerCPUTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_Common_Static_5D_Subset2, StridedSliceLayerCPUTest, - ::testing::Combine( - ::testing::ValuesIn(static_shapes_to_test_representation(inputShapesBlockedStatic4DSubset2)), - ::testing::ValuesIn(testCasesBlocked4DSubset2), - ::testing::ValuesIn(inputLayerTypesBlocked), - ::testing::ValuesIn(inputPrecisions), - ::testing::ValuesIn(CPUParamsBlocked4D)), - StridedSliceLayerCPUTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_Common_Dynamic_5D_Subset2, StridedSliceLayerCPUTest, - ::testing::Combine( - ::testing::ValuesIn(inputShapesBlockedDynamic5DSubset2), - ::testing::ValuesIn(testCasesBlocked5DSubset2), - ::testing::ValuesIn(inputLayerTypesBlocked), - ::testing::ValuesIn(inputPrecisions), - ::testing::ValuesIn(CPUParamsBlocked5D)), +INSTANTIATE_TEST_SUITE_P( + smoke_CompareWithRefs_Common_Static_5D_Subset2, + StridedSliceLayerCPUTest, + ::testing::Combine(::testing::ValuesIn(static_shapes_to_test_representation(inputShapesBlockedStatic4DSubset2)), + ::testing::ValuesIn(testCasesBlocked4DSubset2), + ::testing::ValuesIn(inputLayerTypesBlocked), + ::testing::ValuesIn(inputPrecisions), + ::testing::ValuesIn(CPUParamsBlocked4D)), + StridedSliceLayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_Common_Dynamic_5D_Subset2, + StridedSliceLayerCPUTest, + ::testing::Combine(::testing::ValuesIn(inputShapesBlockedDynamic5DSubset2), + ::testing::ValuesIn(testCasesBlocked5DSubset2), + ::testing::ValuesIn(inputLayerTypesBlocked), + ::testing::ValuesIn(inputPrecisions), + ::testing::ValuesIn(CPUParamsBlocked5D)), StridedSliceLayerCPUTest::getTestCaseName); /* Descriptors check */ @@ -505,27 +668,39 @@ TEST_P(StridedSliceLayerDescriptorCPUTest, DescriptorsCheck) { } const std::vector testCasesDescriptors = { - StridedSliceParams{ { 0, -4, 0, 0 }, { 0, 2147483647, 0, 0 }, { 1, 1, 1, 1 }, { 1, 0, 1, 1 }, { 1, 0, 1, 1 }, { }, { }, { } }, - StridedSliceParams{ { 0, 5, 0, 0 }, { 1, 20, 28, 27 }, { 1, 1, 1, 1 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { }, { }, { } }, - StridedSliceParams{ { 0, 0, 0, 0 }, { 1, 2147483647, 32, 32 }, { 1, 2, 1, 1 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { }, { }, { } }, - StridedSliceParams{ { 0, 0, 0, 0 }, { 1, 2147483647, 32, 32 }, { 1, 2, 1, 1 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { }, {0, 1, 0, 0 }, { } }, - StridedSliceParams{ { 0, 0, 0, 0 }, { 1, 2147483647, 32, 32 }, { 1, 2, 1, 1 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, {0, 0, 1, 0 }, { }, { } }, -}; - -const std::vector inputShapesDescriptors = { - {{}, {{ 1, 16, 32, 32 }}}, - {{}, {{ 1, 17, 32, 32 }}}, - {{1, -1, 32, 32}, {{ 1, 16, 32, 32 }, { 1, 32, 32, 32 }}} + StridedSliceParams{{0, -4, 0, 0}, {0, 2147483647, 0, 0}, {1, 1, 1, 1}, {1, 0, 1, 1}, {1, 0, 1, 1}, {}, {}, {}}, + StridedSliceParams{{0, 5, 0, 0}, {1, 20, 28, 27}, {1, 1, 1, 1}, {0, 0, 0, 0}, {0, 0, 0, 0}, {}, {}, {}}, + StridedSliceParams{{0, 0, 0, 0}, {1, 2147483647, 32, 32}, {1, 2, 1, 1}, {0, 0, 0, 0}, {0, 0, 0, 0}, {}, {}, {}}, + StridedSliceParams{{0, 0, 0, 0}, + {1, 2147483647, 32, 32}, + {1, 2, 1, 1}, + {0, 0, 0, 0}, + {0, 0, 0, 0}, + {}, + {0, 1, 0, 0}, + {}}, + StridedSliceParams{{0, 0, 0, 0}, + {1, 2147483647, 32, 32}, + {1, 2, 1, 1}, + {0, 0, 0, 0}, + {0, 0, 0, 0}, + {0, 0, 1, 0}, + {}, + {}}, }; -INSTANTIATE_TEST_SUITE_P(smoke_StridedSliceLayerDescriptorCPUTest, StridedSliceLayerDescriptorCPUTest, - ::testing::Combine( - ::testing::ValuesIn(inputShapesDescriptors), - ::testing::ValuesIn(testCasesDescriptors), - ::testing::Values(ngraph::helpers::InputLayerType::CONSTANT), - ::testing::Values(ElementType::f32), - ::testing::Values(cpuParams_nChw8c)), +const std::vector inputShapesDescriptors = {{{}, {{1, 16, 32, 32}}}, + {{}, {{1, 17, 32, 32}}}, + {{1, -1, 32, 32}, {{1, 16, 32, 32}, {1, 32, 32, 32}}}}; + +INSTANTIATE_TEST_SUITE_P(smoke_StridedSliceLayerDescriptorCPUTest, + StridedSliceLayerDescriptorCPUTest, + ::testing::Combine(::testing::ValuesIn(inputShapesDescriptors), + ::testing::ValuesIn(testCasesDescriptors), + ::testing::Values(ov::test::utils::InputLayerType::CONSTANT), + ::testing::Values(ElementType::f32), + ::testing::Values(cpuParams_nChw8c)), StridedSliceLayerDescriptorCPUTest::getTestCaseName); -} // namespace -} // namespace CPULayerTestsDefinitions +} // namespace +} // namespace CPULayerTestsDefinitions diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/tensor_iterator.cpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/tensor_iterator.cpp index 1b9e89095b0fcc..ba742ee86c819c 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/tensor_iterator.cpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/tensor_iterator.cpp @@ -2,29 +2,23 @@ // SPDX-License-Identifier: Apache-2.0 // -#include +#include "common_test_utils/node_builders/activation.hpp" +#include "common_test_utils/ov_tensor_utils.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include "ov_models/builders.hpp" -#include -using namespace InferenceEngine; using namespace ov; using namespace test; -namespace CPULayerTestsDefinitions { - -using TensorIteratorParams = typename std::tuple< - std::vector, // Input shapes - ngraph::op::RecurrentSequenceDirection, // Direction - ElementType>; // element type - +using TensorIteratorParams = typename std::tuple, // Input shapes + ov::op::RecurrentSequenceDirection, // Direction + ElementType>; // element type class TensorIteratorCPUTest : public testing::WithParamInterface, virtual public SubgraphBaseTest { public: static std::string getTestCaseName(testing::TestParamInfo obj) { std::vector shapes; - ngraph::op::RecurrentSequenceDirection direction; + ov::op::RecurrentSequenceDirection direction; ElementType inType; std::tie(shapes, direction, inType) = obj.param; @@ -45,7 +39,7 @@ class TensorIteratorCPUTest : public testing::WithParamInterface shapes; - ngraph::op::RecurrentSequenceDirection direction; + ov::op::RecurrentSequenceDirection direction; ElementType inType; std::tie(shapes, direction, inType) = this->GetParam(); @@ -53,31 +47,31 @@ class TensorIteratorCPUTest : public testing::WithParamInterface(); + auto tensor_iterator = std::make_shared(); ov::ParameterVector params; for (auto&& shape : inputDynamicShapes) { params.push_back(std::make_shared(inType, shape)); } - ngraph::ParameterVector body_params; + ov::ParameterVector body_params; for (size_t i = 0; i < shapes.size(); i++) { - ngraph::PartialShape shape = shapes[i].first; + ov::PartialShape shape = shapes[i].first; shape[sequence_axis] = 1; - auto paramNode = std::make_shared(inType, shape); + auto paramNode = std::make_shared(inType, shape); body_params.push_back(paramNode); } - auto tanh = ngraph::builder::makeActivation(body_params[0], inType, ngraph::helpers::Tanh); - auto relu = ngraph::builder::makeActivation(body_params[1], inType, ngraph::helpers::Relu); - auto add = std::make_shared(tanh, relu); + auto tanh = ov::test::utils::make_activation(body_params[0], inType, ov::test::utils::ActivationTypes::Tanh); + auto relu = ov::test::utils::make_activation(body_params[1], inType, ov::test::utils::ActivationTypes::Relu); + auto add = std::make_shared(tanh, relu); - auto body = std::make_shared(ngraph::OutputVector{add}, body_params, "body"); + auto body = std::make_shared(ov::OutputVector{add}, body_params, "body"); tensor_iterator->set_function(body); - if (direction == ngraph::op::RecurrentSequenceDirection::FORWARD) { + if (direction == ov::op::RecurrentSequenceDirection::FORWARD) { tensor_iterator->set_sliced_input(body_params[0], params[0], 0, 1, 1, -1, sequence_axis); tensor_iterator->set_sliced_input(body_params[1], params[1], 0, 1, 1, -1, sequence_axis); tensor_iterator->get_concatenated_slices(add, 0, 1, 1, -1, sequence_axis); - } else if (direction == ngraph::op::RecurrentSequenceDirection::REVERSE) { + } else if (direction == ov::op::RecurrentSequenceDirection::REVERSE) { tensor_iterator->set_sliced_input(body_params[0], params[0], -1, -1, 1, 0, sequence_axis); tensor_iterator->set_sliced_input(body_params[1], params[1], -1, -1, 1, 0, sequence_axis); tensor_iterator->get_concatenated_slices(add, -1, -1, 1, 0, sequence_axis); @@ -85,7 +79,7 @@ class TensorIteratorCPUTest : public testing::WithParamInterface(ngraph::OutputVector{tensor_iterator->output(0)}, params); + function = std::make_shared(ov::OutputVector{tensor_iterator->output(0)}, params); } }; @@ -95,64 +89,51 @@ TEST_P(TensorIteratorCPUTest, CompareWithRefs) { namespace { -const std::vector inputPrecisions = { - ElementType::f32, - ElementType::bf16, - ElementType::i8 -}; - -std::vector direction = {ngraph::op::RecurrentSequenceDirection::FORWARD, - ngraph::op::RecurrentSequenceDirection::REVERSE}; -std::vector> inputs = { - { //first test suit - { //dynamic shape for first input - {-1, -1, -1}, - { // target static shapes - {10, 12, 10}, - {10, 8, 10}, - {1, 8, 2}, - {5, 3, 3} - } - }, - { //dynamic shape for second input - {-1, -1, -1}, - { // target static shapes - {1, 12, 1}, - {1, 8, 1}, - {5, 8, 2}, - {5, 3, 3} - } - }, - }, - - { //second test suit - { //dynamic shape for first input - {{1, 12}, 5, {1, 12}}, - { // target static shapes - {1, 5, 1}, - {5, 5, 5}, - {1, 5, 1}, - {5, 5, 5} - } - }, - { //dynamic shape for second input - {{1, 12}, 5, {1, 12}}, - { // target static shapes - {1, 5, 1}, - {1, 5, 1}, - {5, 5, 1}, - {5, 5, 5} - } - }, - } -}; - -INSTANTIATE_TEST_SUITE_P(smoke_TensorIteratorSimple, TensorIteratorCPUTest, - ::testing::Combine( - ::testing::ValuesIn(inputs), - ::testing::ValuesIn(direction), - ::testing::ValuesIn(inputPrecisions)), +const std::vector inputPrecisions = {ElementType::f32, ElementType::bf16, ElementType::i8}; + +std::vector direction = {ov::op::RecurrentSequenceDirection::FORWARD, + ov::op::RecurrentSequenceDirection::REVERSE}; +std::vector> inputs = {{ + // first test suit + {// dynamic shape for first input + {-1, -1, -1}, + {// target static shapes + {10, 12, 10}, + {10, 8, 10}, + {1, 8, 2}, + {5, 3, 3}}}, + {// dynamic shape for second input + {-1, -1, -1}, + {// target static shapes + {1, 12, 1}, + {1, 8, 1}, + {5, 8, 2}, + {5, 3, 3}}}, + }, + + { + // second test suit + {// dynamic shape for first input + {{1, 12}, 5, {1, 12}}, + {// target static shapes + {1, 5, 1}, + {5, 5, 5}, + {1, 5, 1}, + {5, 5, 5}}}, + {// dynamic shape for second input + {{1, 12}, 5, {1, 12}}, + {// target static shapes + {1, 5, 1}, + {1, 5, 1}, + {5, 5, 1}, + {5, 5, 5}}}, + }}; + +INSTANTIATE_TEST_SUITE_P(smoke_TensorIteratorSimple, + TensorIteratorCPUTest, + ::testing::Combine(::testing::ValuesIn(inputs), + ::testing::ValuesIn(direction), + ::testing::ValuesIn(inputPrecisions)), TensorIteratorCPUTest::getTestCaseName); -} // namespace -} // namespace CPULayerTestsDefinitions +} // namespace \ No newline at end of file diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/tile.cpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/tile.cpp index a0a68a6f85a2e4..ea79bd633852e7 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/tile.cpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/tile.cpp @@ -3,27 +3,22 @@ // #include "test_utils/cpu_test_utils.hpp" -#include "ov_models/builders.hpp" +#include "common_test_utils/ov_tensor_utils.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include using namespace CPUTestUtils; -namespace CPULayerTestsDefinitions { +using TileLayerTestParamsSet = typename std::tuple, // Input shapes + std::vector, // Repeats + ov::element::Type_t, // Network precision + bool, // Is Repeats input constant + std::string>; // Device name -using TileLayerTestParamsSet = typename std::tuple< - std::vector, // Input shapes - std::vector, // Repeats - ov::element::Type_t, // Network precision - bool, // Is Repeats input constant - std::string>; // Device name - -typedef std::tuple< - TileLayerTestParamsSet, - CPUSpecificParams> TileLayerCPUTestParamsSet; +typedef std::tuple TileLayerCPUTestParamsSet; class TileLayerCPUTest : public testing::WithParamInterface, - virtual public ov::test::SubgraphBaseTest, public CPUTestsBase { + virtual public ov::test::SubgraphBaseTest, + public CPUTestsBase { public: static std::string getTestCaseName(testing::TestParamInfo obj) { TileLayerTestParamsSet basicParamsSet; @@ -48,7 +43,7 @@ class TileLayerCPUTest : public testing::WithParamInterface(repeatsData.size()) }); + inputDynamicShapes.push_back({static_cast(repeatsData.size())}); } } const size_t targetStaticShapeSize = inputShapes.front().second.size(); @@ -84,16 +79,18 @@ class TileLayerCPUTest : public testing::WithParamInterface(netPrecision, targetStaticShapes.front().front())); + functionParams.push_back( + std::make_shared(netPrecision, targetStaticShapes.front().front())); } else { functionParams.push_back(std::make_shared(netPrecision, inputDynamicShapes.front())); if (!isRepeatsConst) { - functionParams.push_back(std::make_shared(ov::element::i64, inputDynamicShapes[1])); + functionParams.push_back( + std::make_shared(ov::element::i64, inputDynamicShapes[1])); functionParams.back()->set_friendly_name("repeats"); } } @@ -101,15 +98,16 @@ class TileLayerCPUTest : public testing::WithParamInterface tileNode; if (isRepeatsConst) { - tileNode = std::make_shared(functionParams[0], - ov::op::v0::Constant::create(ov::element::i64, { repeatsData.size() }, repeatsData)); + tileNode = std::make_shared( + functionParams[0], + ov::op::v0::Constant::create(ov::element::i64, {repeatsData.size()}, repeatsData)); } else { tileNode = std::make_shared(functionParams[0], functionParams[1]); } function = makeNgraphFunction(netPrecision, functionParams, tileNode, "CPUTile"); } - void generate_inputs(const std::vector& targetInputStaticShapes) override { + void generate_inputs(const std::vector& targetInputStaticShapes) override { inputs.clear(); const auto& funcInputs = function->inputs(); for (size_t i = 0lu; i < funcInputs.size(); i++) { @@ -123,10 +121,14 @@ class TileLayerCPUTest : public testing::WithParamInterface netPrecisions = { - ov::element::f32, - ov::element::bf16, - ov::element::i32, - ov::element::i8 -}; - -const std::vector> staticInputShapes4D = { - { - {{}, - { // Static shapes - {2, 16, 3, 4} - } - } - }, - { - {{}, - { // Static shapes - {1, 16, 1, 1} - } - } - } -}; +const std::vector netPrecisions = {ov::element::f32, + ov::element::bf16, + ov::element::i32, + ov::element::i8}; + +const std::vector> staticInputShapes4D = {{{{}, + {// Static shapes + {2, 16, 3, 4}}}}, + {{{}, + {// Static shapes + {1, 16, 1, 1}}}}}; const std::vector> dynamicInputShapes4D = { - { - { // Origin dynamic shapes - {ov::Dimension(1, 20), ov::Dimension(10, 20), ov::Dimension(1, 20), ov::Dimension(1, 20)}, - { // Dynamic shapes instances - {2, 16, 3, 4}, - {1, 16, 1, 1}, - {1, 16, 2, 3} - } - } - }, - { - { // Origin dynamic shapes - {-1, -1, -1, -1}, - { // Dynamic shapes instances - {3, 15, 5, 7}, - {4, 55, 8, 24} - } - } - } -}; - -const std::vector> staticInputShapes5D = { - { - {{}, - { // Static shapes - {2, 16, 2, 3, 4} - } - } - } -}; + {{// Origin dynamic shapes + {ov::Dimension(1, 20), ov::Dimension(10, 20), ov::Dimension(1, 20), ov::Dimension(1, 20)}, + {// Dynamic shapes instances + {2, 16, 3, 4}, + {1, 16, 1, 1}, + {1, 16, 2, 3}}}}, + {{// Origin dynamic shapes + {-1, -1, -1, -1}, + {// Dynamic shapes instances + {3, 15, 5, 7}, + {4, 55, 8, 24}}}}}; + +const std::vector> staticInputShapes5D = {{{{}, + {// Static shapes + {2, 16, 2, 3, 4}}}}}; const std::vector> dynamicInputShapes5D = { - { - { // Origin dynamic shapes - {ov::Dimension(1, 20), ov::Dimension(1, 20), ov::Dimension(1, 20), ov::Dimension(1, 20), ov::Dimension(1, 70)}, - { // Dynamic shapes instances - {2, 16, 2, 3, 4}, - {1, 16, 8, 5, 4}, - {8, 1, 2, 3, 64} - } - } - }, - { - { // Origin dynamic shapes - {-1, -1, -1, -1, -1}, - { // Dynamic shapes instances - {2, 16, 2, 3, 4}, - {1, 16, 8, 5, 4}, - {8, 1, 2, 3, 64} - } - } - } -}; - -const std::vector> repeats4D = { - {2, 3}, - {1, 2, 3}, - {1, 1, 1, 1}, - {1, 1, 2, 3}, - {1, 2, 1, 3}, - {2, 1, 1, 1}, - {2, 3, 1, 1} -}; -const std::vector> repeats5D = { - {1, 2, 3}, - {1, 1, 2, 3}, - {1, 1, 1, 2, 3}, - {1, 2, 1, 1, 3}, - {2, 1, 1, 1, 1}, - {2, 3, 1, 1, 1} -}; + {{// Origin dynamic shapes + {ov::Dimension(1, 20), ov::Dimension(1, 20), ov::Dimension(1, 20), ov::Dimension(1, 20), ov::Dimension(1, 70)}, + {// Dynamic shapes instances + {2, 16, 2, 3, 4}, + {1, 16, 8, 5, 4}, + {8, 1, 2, 3, 64}}}}, + {{// Origin dynamic shapes + {-1, -1, -1, -1, -1}, + {// Dynamic shapes instances + {2, 16, 2, 3, 4}, + {1, 16, 8, 5, 4}, + {8, 1, 2, 3, 64}}}}}; + +const std::vector> repeats4D = + {{2, 3}, {1, 2, 3}, {1, 1, 1, 1}, {1, 1, 2, 3}, {1, 2, 1, 3}, {2, 1, 1, 1}, {2, 3, 1, 1}}; +const std::vector> repeats5D = + {{1, 2, 3}, {1, 1, 2, 3}, {1, 1, 1, 2, 3}, {1, 2, 1, 1, 3}, {2, 1, 1, 1, 1}, {2, 3, 1, 1, 1}}; const std::vector CPUParams4D = { - cpuParams_nchw, - cpuParams_nChw16c, - cpuParams_nChw8c, - cpuParams_nhwc, + cpuParams_nchw, + cpuParams_nChw16c, + cpuParams_nChw8c, + cpuParams_nhwc, }; const std::vector CPUParams5D = { - cpuParams_ncdhw, - cpuParams_nCdhw16c, - cpuParams_nCdhw8c, - cpuParams_ndhwc, + cpuParams_ncdhw, + cpuParams_nCdhw16c, + cpuParams_nCdhw8c, + cpuParams_ndhwc, }; /* ============= */ /* INSTANCES */ -INSTANTIATE_TEST_CASE_P(smoke_StaticShape4D, TileLayerCPUTest, - ::testing::Combine( - ::testing::Combine( - ::testing::ValuesIn(staticInputShapes4D), - ::testing::ValuesIn(repeats4D), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(true), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - ::testing::ValuesIn(CPUParams4D)), +INSTANTIATE_TEST_CASE_P(smoke_StaticShape4D, + TileLayerCPUTest, + ::testing::Combine(::testing::Combine(::testing::ValuesIn(staticInputShapes4D), + ::testing::ValuesIn(repeats4D), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(true), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::ValuesIn(CPUParams4D)), TileLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_DynamicShape4D, TileLayerCPUTest, - ::testing::Combine( - ::testing::Combine( - ::testing::ValuesIn(dynamicInputShapes4D), - ::testing::ValuesIn(repeats4D), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(true, false), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - ::testing::Values(CPUSpecificParams{{}, {}, {}, "ref"})), +INSTANTIATE_TEST_CASE_P(smoke_DynamicShape4D, + TileLayerCPUTest, + ::testing::Combine(::testing::Combine(::testing::ValuesIn(dynamicInputShapes4D), + ::testing::ValuesIn(repeats4D), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(true, false), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::Values(CPUSpecificParams{{}, {}, {}, "ref"})), TileLayerCPUTest::getTestCaseName); -const std::vector> dynBatchInputShapes4D = { - { // Origin dynamic shapes - { - {{1, 20}, 16, 3, 4}, - { // Dynamic shapes instances - {2, 16, 3, 4}, - {1, 16, 3, 4}, - {3, 16, 3, 4} - } - } - } -}; - -INSTANTIATE_TEST_CASE_P(smoke_DynBatch4D, TileLayerCPUTest, - ::testing::Combine( - ::testing::Combine( - ::testing::ValuesIn(dynBatchInputShapes4D), - ::testing::Values(std::vector{1, 2, 1, 3}), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(true), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - ::testing::Values(CPUSpecificParams{{}, {}, {}, "ref"})), +const std::vector> dynBatchInputShapes4D = {{// Origin dynamic shapes + {{{1, 20}, 16, 3, 4}, + {// Dynamic shapes instances + {2, 16, 3, 4}, + {1, 16, 3, 4}, + {3, 16, 3, 4}}}}}; + +INSTANTIATE_TEST_CASE_P(smoke_DynBatch4D, + TileLayerCPUTest, + ::testing::Combine(::testing::Combine(::testing::ValuesIn(dynBatchInputShapes4D), + ::testing::Values(std::vector{1, 2, 1, 3}), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(true), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::Values(CPUSpecificParams{{}, {}, {}, "ref"})), TileLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_StaticShape5D, TileLayerCPUTest, - ::testing::Combine( - ::testing::Combine( - ::testing::ValuesIn(staticInputShapes5D), - ::testing::ValuesIn(repeats5D), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(true), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - ::testing::ValuesIn(CPUParams5D)), +INSTANTIATE_TEST_CASE_P(smoke_StaticShape5D, + TileLayerCPUTest, + ::testing::Combine(::testing::Combine(::testing::ValuesIn(staticInputShapes5D), + ::testing::ValuesIn(repeats5D), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(true), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::ValuesIn(CPUParams5D)), TileLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_DynamicShape5D, TileLayerCPUTest, - ::testing::Combine( - ::testing::Combine( - ::testing::ValuesIn(dynamicInputShapes5D), - ::testing::ValuesIn(repeats5D), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(true, false), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - ::testing::Values(CPUSpecificParams{{}, {}, {}, "ref"})), +INSTANTIATE_TEST_CASE_P(smoke_DynamicShape5D, + TileLayerCPUTest, + ::testing::Combine(::testing::Combine(::testing::ValuesIn(dynamicInputShapes5D), + ::testing::ValuesIn(repeats5D), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(true, false), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ::testing::Values(CPUSpecificParams{{}, {}, {}, "ref"})), TileLayerCPUTest::getTestCaseName); /* ========= */ -} // namespace - -} // namespace CPULayerTestsDefinitions +} // namespace \ No newline at end of file diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/topk.cpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/topk.cpp index 4d52c4f24d5dd7..afd63882920f7d 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/topk.cpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/topk.cpp @@ -2,42 +2,36 @@ // SPDX-License-Identifier: Apache-2.0 // -#include -#include "test_utils/cpu_test_utils.hpp" +#include "common_test_utils/ov_tensor_utils.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include "ov_models/builders.hpp" +#include "test_utils/cpu_test_utils.hpp" -using namespace InferenceEngine; using namespace CPUTestUtils; using namespace ov::test; using SortMode = ov::op::TopKMode; using SortType = ov::op::TopKSortType; -namespace CPULayerTestsDefinitions { - -typedef std::tuple< - int64_t, // keepK - int64_t, // axis - SortMode, // mode - std::tuple, // sort and stable - ElementType, // Net precision - ElementType, // Input precision - ElementType, // Output precision - InputShape // inputShape -> basicTopKParams; +typedef std::tuple, // sort and stable + ElementType, // Net type + ElementType, // Input type + ElementType, // Output type + InputShape // inputShape + > + basicTopKParams; -typedef std::tuple< - basicTopKParams, - CPUSpecificParams, - std::map> TopKLayerCPUTestParamsSet; +typedef std::tuple TopKLayerCPUTestParamsSet; class TopKLayerCPUTest : public testing::WithParamInterface, - virtual public SubgraphBaseTest, public CPUTestsBase { + virtual public SubgraphBaseTest, + public CPUTestsBase { public: static std::string getTestCaseName(testing::TestParamInfo obj) { basicTopKParams basicParamsSet; CPUSpecificParams cpuParams; - std::map additionalConfig; + ov::AnyMap additionalConfig; std::tie(basicParamsSet, cpuParams, additionalConfig) = obj.param; int64_t keepK, axis; @@ -60,7 +54,8 @@ class TopKLayerCPUTest : public testing::WithParamInterface(ElementType::i64, ov::Shape{}, &keepK); topk = std::dynamic_pointer_cast( - std::make_shared(params[0], k, axis, mode, sort, ElementType::i32, stable)); + std::make_shared(params[0], k, axis, mode, sort, ElementType::i32, stable)); } else { auto k = std::make_shared(ElementType::i64, inputDynamicShapes[1]); params.push_back(k); topk = std::dynamic_pointer_cast( - std::make_shared(params[0], k, axis, mode, sort, ElementType::i32, stable)); + std::make_shared(params[0], k, axis, mode, sort, ElementType::i32, stable)); } topk->get_rt_info() = getCPUInfo(); - ngraph::ResultVector results; + 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"); + function = std::make_shared(results, params, "TopK"); } void generate_inputs(const std::vector& targetInputStaticShapes) override { @@ -160,7 +155,7 @@ class TopKLayerCPUTest : public testing::WithParamInterface data(size); // For int32, deliberately set big numbers which are not accurately representable in fp32 - int start = netPrecision == ElementType::i32 ? pow(2, 30) + 1 : - static_cast(size / 2); + int start = netPrecision == ElementType::i32 ? pow(2, 30) + 1 : -static_cast(size / 2); size_t set_size = sort == SortType::SORT_VALUES && stable ? size / 2 : size; std::iota(data.begin(), data.begin() + set_size, start); if (sort == SortType::SORT_VALUES && stable) { @@ -170,12 +165,12 @@ class TopKLayerCPUTest : public testing::WithParamInterface(tensor.data()); + auto* rawBlobDataPtr = static_cast(tensor.data()); for (size_t i = 0; i < size; ++i) { rawBlobDataPtr[i] = static_cast(data[i]); } } else { - auto *rawBlobDataPtr = static_cast(tensor.data()); + auto* rawBlobDataPtr = static_cast(tensor.data()); for (size_t i = 0; i < size; ++i) { rawBlobDataPtr[i] = static_cast(data[i]); } @@ -190,11 +185,11 @@ class TopKLayerCPUTest : public testing::WithParamInterface(tensor.data()); + auto* rawBlobDataPtr = static_cast(tensor.data()); for (size_t o = 0; o < O; o++) { for (size_t i = 0; i < I; i++) { std::vector data(A); - int start = - static_cast(A / 2); + int start = -static_cast(A / 2); std::iota(data.begin(), data.end(), start); const size_t seed = (o + 1) * (i + 1); std::mt19937 gen(seed); @@ -248,68 +243,57 @@ const std::vector netPrecisions = { ElementType::f32, }; -std::vector> additionalConfig = { - {{PluginConfigParams::KEY_ENFORCE_BF16, PluginConfigParams::NO}}, - {{PluginConfigParams::KEY_ENFORCE_BF16, PluginConfigParams::YES}} -}; +std::vector additionalConfig = {{{ov::hint::inference_precision(ov::element::f32)}}, + {{ov::hint::inference_precision(ov::element::bf16)}}}; const std::vector axes = {0, 1, 2, 3}; const std::vector k = {1, 5, 7, 18, 21}; -const std::vector modes = { - SortMode::MIN, - SortMode::MAX -}; +const std::vector modes = {SortMode::MIN, SortMode::MAX}; const std::vector> sortTypeStable = { std::tuple{SortType::SORT_VALUES, false}, std::tuple{SortType::SORT_VALUES, true}, - std::tuple{SortType::SORT_INDICES, false} -}; + std::tuple{SortType::SORT_INDICES, false}}; std::vector inputShapes = { {{}, {{21, 21, 21, 21}}}, }; std::vector inputShapesDynamic = { - {{21, {20, 25}, 21, {20, 25}}, {{21, 21, 21, 21}, {21, 22, 21, 23}}} -}; - -std::vector cpuParams = { - CPUSpecificParams({nChw16c, x}, {nChw16c, nChw16c}, {}, {}), - CPUSpecificParams({nchw, x}, {nchw, nchw}, {}, {}), - CPUSpecificParams({nhwc, x}, {nhwc, nhwc}, {}, {}) -}; - -INSTANTIATE_TEST_CASE_P(smoke_TopK, TopKLayerCPUTest, - ::testing::Combine( - ::testing::Combine( - ::testing::ValuesIn(k), - ::testing::ValuesIn(axes), - ::testing::ValuesIn(modes), - ::testing::ValuesIn(sortTypeStable), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(ElementType::undefined), - ::testing::Values(ElementType::undefined), - ::testing::ValuesIn(inputShapes)), - ::testing::ValuesIn(filterCPUSpecificParams(cpuParams)), - ::testing::ValuesIn(additionalConfig)), - TopKLayerCPUTest::getTestCaseName); - -INSTANTIATE_TEST_CASE_P(smoke_TopK_dynamic, TopKLayerCPUTest, - ::testing::Combine( - ::testing::Combine( - ::testing::Values(1), - ::testing::ValuesIn(axes), - ::testing::ValuesIn(modes), - ::testing::ValuesIn(sortTypeStable), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(ElementType::undefined), - ::testing::Values(ElementType::undefined), - ::testing::ValuesIn(inputShapesDynamic)), - ::testing::ValuesIn(filterCPUSpecificParams(cpuParams)), - ::testing::ValuesIn(additionalConfig)), - TopKLayerCPUTest::getTestCaseName); + {{21, {20, 25}, 21, {20, 25}}, {{21, 21, 21, 21}, {21, 22, 21, 23}}}}; + +std::vector cpuParams = {CPUSpecificParams({nChw16c, x}, {nChw16c, nChw16c}, {}, {}), + CPUSpecificParams({nchw, x}, {nchw, nchw}, {}, {}), + CPUSpecificParams({nhwc, x}, {nhwc, nhwc}, {}, {})}; + +INSTANTIATE_TEST_CASE_P(smoke_TopK, + TopKLayerCPUTest, + ::testing::Combine(::testing::Combine(::testing::ValuesIn(k), + ::testing::ValuesIn(axes), + ::testing::ValuesIn(modes), + ::testing::ValuesIn(sortTypeStable), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(ElementType::undefined), + ::testing::Values(ElementType::undefined), + ::testing::ValuesIn(inputShapes)), + ::testing::ValuesIn(filterCPUSpecificParams(cpuParams)), + ::testing::ValuesIn(additionalConfig)), + TopKLayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_CASE_P(smoke_TopK_dynamic, + TopKLayerCPUTest, + ::testing::Combine(::testing::Combine(::testing::Values(1), + ::testing::ValuesIn(axes), + ::testing::ValuesIn(modes), + ::testing::ValuesIn(sortTypeStable), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(ElementType::undefined), + ::testing::Values(ElementType::undefined), + ::testing::ValuesIn(inputShapesDynamic)), + ::testing::ValuesIn(filterCPUSpecificParams(cpuParams)), + ::testing::ValuesIn(additionalConfig)), + TopKLayerCPUTest::getTestCaseName); const std::vector k_int32 = {1, 5, 7, 9}; @@ -318,115 +302,107 @@ std::vector inputShapes_int32 = { }; std::vector inputShapesDynamic_int32 = { - {{9, {5, 10}, 9, {5, 10}}, {{9, 9, 9, 9}, {9, 10, 9, 10}}} -}; - -INSTANTIATE_TEST_CASE_P(smoke_TopK_int32, TopKLayerCPUTest, - ::testing::Combine( - ::testing::Combine( - ::testing::ValuesIn(k_int32), - ::testing::ValuesIn(axes), - ::testing::ValuesIn(modes), - ::testing::ValuesIn(sortTypeStable), - ::testing::Values(ElementType::i32), - ::testing::Values(ElementType::undefined), - ::testing::Values(ElementType::undefined), - ::testing::ValuesIn(inputShapes_int32)), - ::testing::ValuesIn(filterCPUSpecificParams(cpuParams)), - ::testing::Values(additionalConfig[0])), - TopKLayerCPUTest::getTestCaseName); - -INSTANTIATE_TEST_CASE_P(smoke_TopK_int32_dynamic, TopKLayerCPUTest, - ::testing::Combine( - ::testing::Combine( - ::testing::Values(1), - ::testing::ValuesIn(axes), - ::testing::ValuesIn(modes), - ::testing::ValuesIn(sortTypeStable), - ::testing::Values(ElementType::i32), - ::testing::Values(ElementType::undefined), - ::testing::Values(ElementType::undefined), - ::testing::ValuesIn(inputShapesDynamic_int32)), - ::testing::ValuesIn(filterCPUSpecificParams(cpuParams)), - ::testing::Values(additionalConfig[0])), - TopKLayerCPUTest::getTestCaseName); + {{9, {5, 10}, 9, {5, 10}}, {{9, 9, 9, 9}, {9, 10, 9, 10}}}}; + +INSTANTIATE_TEST_CASE_P(smoke_TopK_int32, + TopKLayerCPUTest, + ::testing::Combine(::testing::Combine(::testing::ValuesIn(k_int32), + ::testing::ValuesIn(axes), + ::testing::ValuesIn(modes), + ::testing::ValuesIn(sortTypeStable), + ::testing::Values(ElementType::i32), + ::testing::Values(ElementType::undefined), + ::testing::Values(ElementType::undefined), + ::testing::ValuesIn(inputShapes_int32)), + ::testing::ValuesIn(filterCPUSpecificParams(cpuParams)), + ::testing::Values(additionalConfig[0])), + TopKLayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_CASE_P(smoke_TopK_int32_dynamic, + TopKLayerCPUTest, + ::testing::Combine(::testing::Combine(::testing::Values(1), + ::testing::ValuesIn(axes), + ::testing::ValuesIn(modes), + ::testing::ValuesIn(sortTypeStable), + ::testing::Values(ElementType::i32), + ::testing::Values(ElementType::undefined), + ::testing::Values(ElementType::undefined), + ::testing::ValuesIn(inputShapesDynamic_int32)), + ::testing::ValuesIn(filterCPUSpecificParams(cpuParams)), + ::testing::Values(additionalConfig[0])), + TopKLayerCPUTest::getTestCaseName); std::vector inputShapes_bubble_BLK_on_channel_horiz = { {{}, {{2, 2, 2, 2}}}, }; std::vector inputShapesDynamic_bubble_BLK_on_channel_horiz = { - {{2, {2, 3}, 2, 2}, {{2, 2, 2, 2}, {2, 3, 2, 2}}} -}; - -INSTANTIATE_TEST_CASE_P(smoke_TopK_bubble_BLK_on_channel_horiz, TopKLayerCPUTest, - ::testing::Combine( - ::testing::Combine( - ::testing::Values(1), - ::testing::Values(1), - ::testing::ValuesIn(modes), - ::testing::ValuesIn(sortTypeStable), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(ElementType::undefined), - ::testing::Values(ElementType::undefined), - ::testing::ValuesIn(inputShapes_bubble_BLK_on_channel_horiz)), - ::testing::Values(CPUSpecificParams({nChw16c, x}, {nChw16c, nChw16c}, {}, {})), - ::testing::ValuesIn(additionalConfig)), + {{2, {2, 3}, 2, 2}, {{2, 2, 2, 2}, {2, 3, 2, 2}}}}; + +INSTANTIATE_TEST_CASE_P( + smoke_TopK_bubble_BLK_on_channel_horiz, + TopKLayerCPUTest, + ::testing::Combine(::testing::Combine(::testing::Values(1), + ::testing::Values(1), + ::testing::ValuesIn(modes), + ::testing::ValuesIn(sortTypeStable), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(ElementType::undefined), + ::testing::Values(ElementType::undefined), + ::testing::ValuesIn(inputShapes_bubble_BLK_on_channel_horiz)), + ::testing::Values(CPUSpecificParams({nChw16c, x}, {nChw16c, nChw16c}, {}, {})), + ::testing::ValuesIn(additionalConfig)), TopKLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_TopK_bubble_BLK_on_channel_horiz_dynamic, TopKLayerCPUTest, - ::testing::Combine( - ::testing::Combine( - ::testing::Values(1), - ::testing::Values(1), - ::testing::ValuesIn(modes), - ::testing::ValuesIn(sortTypeStable), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(ElementType::undefined), - ::testing::Values(ElementType::undefined), - ::testing::ValuesIn(inputShapesDynamic_bubble_BLK_on_channel_horiz)), - ::testing::Values(CPUSpecificParams({nChw16c, x}, {nChw16c, nChw16c}, {}, {})), - ::testing::ValuesIn(additionalConfig)), +INSTANTIATE_TEST_CASE_P( + smoke_TopK_bubble_BLK_on_channel_horiz_dynamic, + TopKLayerCPUTest, + ::testing::Combine(::testing::Combine(::testing::Values(1), + ::testing::Values(1), + ::testing::ValuesIn(modes), + ::testing::ValuesIn(sortTypeStable), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(ElementType::undefined), + ::testing::Values(ElementType::undefined), + ::testing::ValuesIn(inputShapesDynamic_bubble_BLK_on_channel_horiz)), + ::testing::Values(CPUSpecificParams({nChw16c, x}, {nChw16c, nChw16c}, {}, {})), + ::testing::ValuesIn(additionalConfig)), TopKLayerCPUTest::getTestCaseName); std::vector inputShapes_top1 = { {{}, {{1, 1, 2, 1}}}, }; -std::vector inputShapesDynamic_top1 = { - {{1, 1, 2, {1, 2}}, {{1, 1, 2, 1}, {1, 1, 2, 2}}} -}; - -INSTANTIATE_TEST_CASE_P(smoke_Top1, TopKLayerCPUTest, - ::testing::Combine( - ::testing::Combine( - ::testing::Values(1), - ::testing::Values(3), - ::testing::Values(SortMode::MAX), - ::testing::Values(std::tuple(SortType::SORT_INDICES, false)), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(ElementType::undefined), - ::testing::Values(ElementType::undefined), - ::testing::ValuesIn(inputShapes_top1)), - ::testing::Values(CPUSpecificParams({nchw, x}, {nchw, nchw}, {}, {})), - ::testing::ValuesIn(additionalConfig)), +std::vector inputShapesDynamic_top1 = {{{1, 1, 2, {1, 2}}, {{1, 1, 2, 1}, {1, 1, 2, 2}}}}; + +INSTANTIATE_TEST_CASE_P( + smoke_Top1, + TopKLayerCPUTest, + ::testing::Combine(::testing::Combine(::testing::Values(1), + ::testing::Values(3), + ::testing::Values(SortMode::MAX), + ::testing::Values(std::tuple(SortType::SORT_INDICES, false)), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(ElementType::undefined), + ::testing::Values(ElementType::undefined), + ::testing::ValuesIn(inputShapes_top1)), + ::testing::Values(CPUSpecificParams({nchw, x}, {nchw, nchw}, {}, {})), + ::testing::ValuesIn(additionalConfig)), TopKLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_Top1_dynamic, TopKLayerCPUTest, - ::testing::Combine( - ::testing::Combine( - ::testing::Values(1), - ::testing::Values(3), - ::testing::Values(SortMode::MAX), - ::testing::Values(std::tuple(SortType::SORT_INDICES, false)), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(ElementType::undefined), - ::testing::Values(ElementType::undefined), - ::testing::ValuesIn(inputShapesDynamic_top1)), - ::testing::Values(CPUSpecificParams({nchw, x}, {nchw, nchw}, {}, {})), - ::testing::ValuesIn(additionalConfig)), +INSTANTIATE_TEST_CASE_P( + smoke_Top1_dynamic, + TopKLayerCPUTest, + ::testing::Combine(::testing::Combine(::testing::Values(1), + ::testing::Values(3), + ::testing::Values(SortMode::MAX), + ::testing::Values(std::tuple(SortType::SORT_INDICES, false)), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(ElementType::undefined), + ::testing::Values(ElementType::undefined), + ::testing::ValuesIn(inputShapesDynamic_top1)), + ::testing::Values(CPUSpecificParams({nchw, x}, {nchw, nchw}, {}, {})), + ::testing::ValuesIn(additionalConfig)), TopKLayerCPUTest::getTestCaseName); -} // namespace - -} // namespace CPULayerTestsDefinitions +} // namespace \ No newline at end of file diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/unique.cpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/unique.cpp index 866cdbb9a3fcd8..5b03f0573947d7 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/unique.cpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/unique.cpp @@ -2,27 +2,25 @@ // SPDX-License-Identifier: Apache-2.0 // +#include "common_test_utils/ov_tensor_utils.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include "ov_models/builders.hpp" #include "test_utils/cpu_test_utils.hpp" -#include using namespace CPUTestUtils; using namespace ov::test; -namespace CPULayerTestsDefinitions { - -typedef std::tuple< - std::vector, // Input shapes - std::tuple, // Is flattened and axis - bool, // Sorted - ElementType, // Data precision - CPUSpecificParams, // CPU specific params - std::map // Additional config -> UniqueLayerTestCPUParams; +typedef std::tuple, // Input shapes + std::tuple, // Is flattened and axis + bool, // Sorted + ElementType, // Data precision + CPUSpecificParams, // CPU specific params + ov::AnyMap // Additional config + > + UniqueLayerTestCPUParams; class UniqueLayerTestCPU : public testing::WithParamInterface, - virtual public SubgraphBaseTest, public CPUTestsBase { + virtual public SubgraphBaseTest, + public CPUTestsBase { public: static std::string getTestCaseName(testing::TestParamInfo obj) { std::vector inputShapes; @@ -30,20 +28,22 @@ class UniqueLayerTestCPU : public testing::WithParamInterface additionalConfig; + ov::AnyMap additionalConfig; std::tie(inputShapes, flatOrAxis, sorted, dataPrecision, cpuParams, 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 << 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 << ov::test::utils::vec2str(inputShapes[j].second[i]) + << (j < inputShapes.size() - 1lu ? "_" : ""); } result << "}_"; } @@ -51,7 +51,8 @@ class UniqueLayerTestCPU : public testing::WithParamInterface(flatOrAxis)) { result << "axis=" << std::get<1>(flatOrAxis) << "_"; } else { - result << "flattened" << "_"; + result << "flattened" + << "_"; } result << "sorted=" << (sorted ? "True" : "False") << "_"; result << "dataPrc=" << dataPrecision; @@ -59,9 +60,9 @@ class UniqueLayerTestCPU : public testing::WithParamInterfaceget_friendly_name() == "data") { - int32_t range = std::accumulate(targetInputStaticShapes[0].begin(), targetInputStaticShapes[0].end(), 1, std::multiplies()); - tensor = utils::create_and_fill_tensor( - funcInput.get_element_type(), targetInputStaticShapes[0], range, -range / 2, 1); + int32_t range = std::accumulate(targetInputStaticShapes[0].begin(), + targetInputStaticShapes[0].end(), + 1, + std::multiplies()); + tensor = utils::create_and_fill_tensor(funcInput.get_element_type(), + targetInputStaticShapes[0], + range, + -range / 2, + 1); } inputs.insert({funcInput.get_node_shared_ptr(), tensor}); } @@ -139,22 +147,15 @@ TEST_P(UniqueLayerTestCPU, CompareWithRefs) { namespace { -const std::vector dataPrecisionSmoke = { - ElementType::f32, - ElementType::i32 -}; -const std::vector dataPrecisionNightly = { - ElementType::bf16, - ElementType::i8 -}; +const std::vector dataPrecisionSmoke = {ElementType::f32, ElementType::i32}; +const std::vector dataPrecisionNightly = {ElementType::bf16, ElementType::i8}; -std::vector> flatOrAxis { {true, 0}, {false, 0}, {false, 1}, {false, -1} }; +std::vector> flatOrAxis{{true, 0}, {false, 0}, {false, 1}, {false, -1}}; -std::vector sorted { true, false}; +std::vector sorted{true, false}; -std::vector> additionalConfig - = {{{InferenceEngine::PluginConfigParams::KEY_ENFORCE_BF16, InferenceEngine::PluginConfigParams::NO}}, - {{InferenceEngine::PluginConfigParams::KEY_ENFORCE_BF16, InferenceEngine::PluginConfigParams::YES}}}; +std::vector additionalConfig = {{{ov::hint::inference_precision(ov::element::f32)}}, + {{ov::hint::inference_precision(ov::element::bf16)}}}; std::vector getCPUInfo() { std::vector resCPUParams; @@ -163,121 +164,121 @@ std::vector getCPUInfo() { } std::vector> statShapes1D = { - {{{}, {{1}}}}, // Static shapes - {{{}, {{5}}}}, // Static shapes - {{{}, {{8}}}}, // Static shapes - {{{}, {{16}}}}, // Static shapes - {{{}, {{32}}}}, // Static shapes - {{{}, {{64}}}}, // Static shapes - {{{}, {{99}}}}, // Static shapes + {{{}, {{1}}}}, // Static shapes + {{{}, {{5}}}}, // Static shapes + {{{}, {{8}}}}, // Static shapes + {{{}, {{16}}}}, // Static shapes + {{{}, {{32}}}}, // Static shapes + {{{}, {{64}}}}, // Static shapes + {{{}, {{99}}}}, // Static shapes }; -INSTANTIATE_TEST_SUITE_P(smoke_static_1D, UniqueLayerTestCPU, - ::testing::Combine( - ::testing::ValuesIn(statShapes1D), - ::testing::ValuesIn(std::vector>{{true, 0}, {false, 0}}), - ::testing::ValuesIn(sorted), - ::testing::ValuesIn(dataPrecisionSmoke), - ::testing::ValuesIn(getCPUInfo()), - ::testing::Values(additionalConfig[0])), - UniqueLayerTestCPU::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_static_1D, + UniqueLayerTestCPU, + ::testing::Combine(::testing::ValuesIn(statShapes1D), + ::testing::ValuesIn(std::vector>{{true, 0}, + {false, 0}}), + ::testing::ValuesIn(sorted), + ::testing::ValuesIn(dataPrecisionSmoke), + ::testing::ValuesIn(getCPUInfo()), + ::testing::Values(additionalConfig[0])), + UniqueLayerTestCPU::getTestCaseName); std::vector> getStaticShapes() { std::vector> result = { - { { {}, { {1, 1, 1} } } }, // Static shapes - { { {}, { {1, 2, 1} } } }, // Static shapes - { { {}, { {1, 1, 3} } } }, // Static shapes - { { {}, { {2, 2, 1} } } }, // Static shapes - { { {}, { {1, 4, 1} } } }, // Static shapes - { { {}, { {1, 5, 1} } } }, // Static shapes - { { {}, { {3, 2, 1} } } }, // Static shapes - { { {}, { {1, 1, 7} } } }, // Static shapes - { { {}, { {2, 2, 2} } } }, // Static shapes - { { {}, { {1, 8, 1} } } }, // Static shapes - { { {}, { {3, 3, 1, 1} } } }, // Static shapes - { { {}, { {1, 5, 2, 1} } } }, // Static shapes - { { {}, { {1, 1, 11} } } }, // Static shapes - { { {}, { {32, 35, 37} } } }, // Static shapes - { { {}, { {2, 3, 2} } } }, // Static shapes - { { {}, { {1, 1, 13} } } }, // Static shapes - { { {}, { {7, 1, 2} } } }, // Static shapes - { { {}, { {3, 5, 1} } } }, // Static shapes - { { {}, { {4, 2, 2} } } }, // Static shapes - { { {}, { {1, 17, 1} } } }, // Static shapes - { { {}, { {3, 2, 3, 1} } } }, // Static shapes - { { {}, { {8, 16, 32} } } }, // Static shapes - { { {}, { {37, 19, 11} } } }, // Static shapes - { { {}, { {1, 19, 1} } } }, // Static shapes - { { {}, { {2, 5, 2} } } }, // Static shapes - { { {}, { {1, 3, 7} } } }, // Static shapes - { { {}, { {11, 1, 2} } } }, // Static shapes - { { {}, { {1, 1, 23} } } }, // Static shapes - { { {}, { {4, 3, 2} } } }, // Static shapes - { { {}, { {5, 1, 5} } } }, // Static shapes - { { {}, { {100, 1, 1} } } }, // Static shapes - { { {}, { {5, 5, 5} } } } // Static shapes + {{{}, {{1, 1, 1}}}}, // Static shapes + {{{}, {{1, 2, 1}}}}, // Static shapes + {{{}, {{1, 1, 3}}}}, // Static shapes + {{{}, {{2, 2, 1}}}}, // Static shapes + {{{}, {{1, 4, 1}}}}, // Static shapes + {{{}, {{1, 5, 1}}}}, // Static shapes + {{{}, {{3, 2, 1}}}}, // Static shapes + {{{}, {{1, 1, 7}}}}, // Static shapes + {{{}, {{2, 2, 2}}}}, // Static shapes + {{{}, {{1, 8, 1}}}}, // Static shapes + {{{}, {{3, 3, 1, 1}}}}, // Static shapes + {{{}, {{1, 5, 2, 1}}}}, // Static shapes + {{{}, {{1, 1, 11}}}}, // Static shapes + {{{}, {{32, 35, 37}}}}, // Static shapes + {{{}, {{2, 3, 2}}}}, // Static shapes + {{{}, {{1, 1, 13}}}}, // Static shapes + {{{}, {{7, 1, 2}}}}, // Static shapes + {{{}, {{3, 5, 1}}}}, // Static shapes + {{{}, {{4, 2, 2}}}}, // Static shapes + {{{}, {{1, 17, 1}}}}, // Static shapes + {{{}, {{3, 2, 3, 1}}}}, // Static shapes + {{{}, {{8, 16, 32}}}}, // Static shapes + {{{}, {{37, 19, 11}}}}, // Static shapes + {{{}, {{1, 19, 1}}}}, // Static shapes + {{{}, {{2, 5, 2}}}}, // Static shapes + {{{}, {{1, 3, 7}}}}, // Static shapes + {{{}, {{11, 1, 2}}}}, // Static shapes + {{{}, {{1, 1, 23}}}}, // Static shapes + {{{}, {{4, 3, 2}}}}, // Static shapes + {{{}, {{5, 1, 5}}}}, // Static shapes + {{{}, {{100, 1, 1}}}}, // Static shapes + {{{}, {{5, 5, 5}}}} // Static shapes }; return result; } -INSTANTIATE_TEST_SUITE_P(smoke_static, UniqueLayerTestCPU, - ::testing::Combine( - ::testing::ValuesIn(getStaticShapes()), - ::testing::ValuesIn(flatOrAxis), - ::testing::ValuesIn(sorted), - ::testing::ValuesIn(dataPrecisionSmoke), - ::testing::ValuesIn(getCPUInfo()), - ::testing::Values(additionalConfig[0])), - UniqueLayerTestCPU::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(nightly_static, UniqueLayerTestCPU, - ::testing::Combine( - ::testing::ValuesIn(getStaticShapes()), - ::testing::ValuesIn(flatOrAxis), - ::testing::ValuesIn(sorted), - ::testing::ValuesIn(dataPrecisionNightly), - ::testing::ValuesIn(getCPUInfo()), - ::testing::Values(additionalConfig[0])), - UniqueLayerTestCPU::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_static, + UniqueLayerTestCPU, + ::testing::Combine(::testing::ValuesIn(getStaticShapes()), + ::testing::ValuesIn(flatOrAxis), + ::testing::ValuesIn(sorted), + ::testing::ValuesIn(dataPrecisionSmoke), + ::testing::ValuesIn(getCPUInfo()), + ::testing::Values(additionalConfig[0])), + UniqueLayerTestCPU::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(nightly_static, + UniqueLayerTestCPU, + ::testing::Combine(::testing::ValuesIn(getStaticShapes()), + ::testing::ValuesIn(flatOrAxis), + ::testing::ValuesIn(sorted), + ::testing::ValuesIn(dataPrecisionNightly), + ::testing::ValuesIn(getCPUInfo()), + ::testing::Values(additionalConfig[0])), + UniqueLayerTestCPU::getTestCaseName); const std::vector> dynamicInSapes = { - { { { ov::Dimension(1, 15), -1, -1, -1 }, // Dynamic shape - { {1, 1, 1, 1}, {6, 3, 1, 2}, {4, 5, 3, 1}, {2, 7, 2, 2} } } }, // Target shapes - { { { -1, -1, -1, -1 }, // Dynamic shape - { {1, 2, 1, 5}, {3, 4, 2, 3}, {5, 6, 7, 1}, {7, 8, 2, 4} } } }, // Target shapes - { { { ov::Dimension(2, 15), -1, -1, -1 }, // Dynamic shape - { {8, 3, 3, 3}, {6, 5, 2, 5}, {4, 7, 1, 11}, {2, 9, 3, 4} } } }, // Target shapes - { { { 3, 4, 4, 5 }, // Dynamic shape - { {3, 4, 4, 5}, {3, 4, 4, 5}, {3, 4, 4, 5}, {3, 4, 4, 5} } } }, // Target shapes - { { { -1, -1, -1, -1 }, // Dynamic shape - { {1, 2, 1, 13}, {3, 4, 7, 2}, {5, 6, 3, 5}, {7, 8, 4, 4} } } }, // Target shapes - { { { -1, -1, -1, -1 }, // Dynamic shape - { {2, 11, 1, 17}, {4, 9, 6, 3}, {6, 7, 7, 3}, {8, 3, 2, 11} } } }, // Target shapes - { { { 3, -1, -1, -1 }, // Dynamic shape - { {3, 2, 1, 23}, {3, 4, 3, 8}, {3, 6, 5, 5}, {3, 8, 31, 1} } } }, // Target shapes - { { { -1, 3, -1, -1 }, // Dynamic shape - { {8, 3, 8, 4}, {6, 3, 33, 1}, {4, 3, 8, 6}, {2, 3, 8, 8} } } } // Target shapes + {{{ov::Dimension(1, 15), -1, -1, -1}, // Dynamic shape + {{1, 1, 1, 1}, {6, 3, 1, 2}, {4, 5, 3, 1}, {2, 7, 2, 2}}}}, // Target shapes + {{{-1, -1, -1, -1}, // Dynamic shape + {{1, 2, 1, 5}, {3, 4, 2, 3}, {5, 6, 7, 1}, {7, 8, 2, 4}}}}, // Target shapes + {{{ov::Dimension(2, 15), -1, -1, -1}, // Dynamic shape + {{8, 3, 3, 3}, {6, 5, 2, 5}, {4, 7, 1, 11}, {2, 9, 3, 4}}}}, // Target shapes + {{{3, 4, 4, 5}, // Dynamic shape + {{3, 4, 4, 5}, {3, 4, 4, 5}, {3, 4, 4, 5}, {3, 4, 4, 5}}}}, // Target shapes + {{{-1, -1, -1, -1}, // Dynamic shape + {{1, 2, 1, 13}, {3, 4, 7, 2}, {5, 6, 3, 5}, {7, 8, 4, 4}}}}, // Target shapes + {{{-1, -1, -1, -1}, // Dynamic shape + {{2, 11, 1, 17}, {4, 9, 6, 3}, {6, 7, 7, 3}, {8, 3, 2, 11}}}}, // Target shapes + {{{3, -1, -1, -1}, // Dynamic shape + {{3, 2, 1, 23}, {3, 4, 3, 8}, {3, 6, 5, 5}, {3, 8, 31, 1}}}}, // Target shapes + {{{-1, 3, -1, -1}, // Dynamic shape + {{8, 3, 8, 4}, {6, 3, 33, 1}, {4, 3, 8, 6}, {2, 3, 8, 8}}}} // Target shapes }; -INSTANTIATE_TEST_SUITE_P(smoke_dynamic, UniqueLayerTestCPU, - ::testing::Combine( - ::testing::ValuesIn(dynamicInSapes), - ::testing::ValuesIn(flatOrAxis), - ::testing::ValuesIn(sorted), - ::testing::ValuesIn(dataPrecisionSmoke), - ::testing::ValuesIn(getCPUInfo()), - ::testing::Values(additionalConfig[0])), - UniqueLayerTestCPU::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(nightly_dynamic, UniqueLayerTestCPU, - ::testing::Combine( - ::testing::ValuesIn(dynamicInSapes), - ::testing::ValuesIn(flatOrAxis), - ::testing::ValuesIn(sorted), - ::testing::ValuesIn(dataPrecisionNightly), - ::testing::ValuesIn(getCPUInfo()), - ::testing::Values(additionalConfig[0])), +INSTANTIATE_TEST_SUITE_P(smoke_dynamic, + UniqueLayerTestCPU, + ::testing::Combine(::testing::ValuesIn(dynamicInSapes), + ::testing::ValuesIn(flatOrAxis), + ::testing::ValuesIn(sorted), + ::testing::ValuesIn(dataPrecisionSmoke), + ::testing::ValuesIn(getCPUInfo()), + ::testing::Values(additionalConfig[0])), + UniqueLayerTestCPU::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(nightly_dynamic, + UniqueLayerTestCPU, + ::testing::Combine(::testing::ValuesIn(dynamicInSapes), + ::testing::ValuesIn(flatOrAxis), + ::testing::ValuesIn(sorted), + ::testing::ValuesIn(dataPrecisionNightly), + ::testing::ValuesIn(getCPUInfo()), + ::testing::Values(additionalConfig[0])), UniqueLayerTestCPU::getTestCaseName); -} // namespace -} // namespace CPULayerTestsDefinitions +} // namespace \ No newline at end of file diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/variadic_split.cpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/variadic_split.cpp index 9ccd6bab8feeba..4bd2b50f3042a0 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/variadic_split.cpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/variadic_split.cpp @@ -2,35 +2,31 @@ // SPDX-License-Identifier: Apache-2.0 // -#include - +#include "common_test_utils/ov_tensor_utils.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include -#include "ov_models/builders.hpp" #include "test_utils/cpu_test_utils.hpp" using namespace ov::test; using namespace CPUTestUtils; -namespace CPULayerTestsDefinitions { using LengthsPerInfer = std::vector>; -typedef std::tuple< - InputShape, - int64_t, // Axis - LengthsPerInfer, // Split lengths - ngraph::helpers::InputLayerType, // lengths input type - ElementType, // Net precision - CPUSpecificParams -> varSplitCPUTestParams; +typedef std::tuple + varSplitCPUTestParams; class VariadicSplitLayerCPUTest : public testing::WithParamInterface, - virtual public SubgraphBaseTest, public CPUTestsBase { + virtual public SubgraphBaseTest, + public CPUTestsBase { public: static std::string getTestCaseName(testing::TestParamInfo obj) { InputShape shapes; int64_t axis; LengthsPerInfer splitLengths; - ngraph::helpers::InputLayerType lengthsType; + ov::test::utils::InputLayerType lengthsType; ElementType netPrecision; CPUSpecificParams cpuParams; std::tie(shapes, axis, splitLengths, lengthsType, netPrecision, cpuParams) = obj.param; @@ -59,7 +55,7 @@ class VariadicSplitLayerCPUTest : public testing::WithParamInterfaceGetParam(); @@ -68,7 +64,7 @@ class VariadicSplitLayerCPUTest : public testing::WithParamInterface shapesToInit{inputShapes}; - if (lengthsType == ngraph::helpers::InputLayerType::PARAMETER) { + if (lengthsType == ov::test::utils::InputLayerType::PARAMETER) { std::vector lengthsStaticShapes(inputShapes.second.size(), {lengthsPerInfer[0].size()}); shapesToInit.emplace_back(InputShape{{static_cast(lengthsPerInfer[0].size())}, lengthsStaticShapes}); } @@ -77,25 +73,27 @@ class VariadicSplitLayerCPUTest : public testing::WithParamInterface(netPrecision, inputDynamicShapes[0])}; std::shared_ptr splitLengthsOp; - if (lengthsType == ngraph::helpers::InputLayerType::PARAMETER) { - auto param = std::make_shared(ov::element::i32, ov::Shape{lengthsPerInfer[0].size()}); + if (lengthsType == ov::test::utils::InputLayerType::PARAMETER) { + auto param = + std::make_shared(ov::element::i32, ov::Shape{lengthsPerInfer[0].size()}); params.push_back(param); splitLengthsOp = param; } else { - splitLengthsOp = ov::opset10::Constant::create(ov::element::i32, {lengthsPerInfer[0].size()}, lengthsPerInfer[0]); + splitLengthsOp = + ov::op::v0::Constant::create(ov::element::i32, {lengthsPerInfer[0].size()}, lengthsPerInfer[0]); } - auto splitAxisOp = ov::opset10::Constant::create(ov::element::i64, {}, {axis}); - auto varSplit = std::make_shared(params[0], splitAxisOp, splitLengthsOp); + auto splitAxisOp = ov::op::v0::Constant::create(ov::element::i64, {}, {axis}); + auto varSplit = std::make_shared(params[0], splitAxisOp, splitLengthsOp); varSplit->get_rt_info() = getCPUInfo(); ov::ResultVector results; for (const auto& out : varSplit->outputs()) - results.push_back(std::make_shared(out)); - function = std::make_shared(results, params, "VariadicSplitCPU"); + results.push_back(std::make_shared(out)); + function = std::make_shared(results, params, "VariadicSplitCPU"); } - void generate_inputs(const std::vector& targetInputStaticShapes) override { + void generate_inputs(const std::vector& targetInputStaticShapes) override { inputs.clear(); const auto& funcInputs = function->inputs(); @@ -116,6 +114,7 @@ class VariadicSplitLayerCPUTest : public testing::WithParamInterface netPrecisions = { - ElementType::i8, - ElementType::i32, - ElementType::f32, - ElementType::bf16 -}; +const std::vector netPrecisions = {ElementType::i8, ElementType::i32, ElementType::f32, ElementType::bf16}; -const std::vector lengthsTypes = { - ngraph::helpers::InputLayerType::CONSTANT, - ngraph::helpers::InputLayerType::PARAMETER -}; +const std::vector lengthsTypes = {ov::test::utils::InputLayerType::CONSTANT, + ov::test::utils::InputLayerType::PARAMETER}; const std::vector inputShapes4D_Nspc2NcspSpecial = { - { {}, {{3, 5, 24, 9}} }, - { - // dynamic - {-1, -1, -1, -1}, - // target - { - {1, 8, 5, 7}, - {3, 9, 7, 9}, - {5, 6, 1, 8} - } - }, - { - // dynamic - {{1, 5}, {1, 64}, {1, 25}, {2, 10}}, - // target - { - {2, 7, 5, 7}, - {1, 10, 10, 2}, - {3, 5, 6, 9} - } - }, + {{}, {{3, 5, 24, 9}}}, + {// dynamic + {-1, -1, -1, -1}, + // target + {{1, 8, 5, 7}, {3, 9, 7, 9}, {5, 6, 1, 8}}}, + {// dynamic + {{1, 5}, {1, 64}, {1, 25}, {2, 10}}, + // target + {{2, 7, 5, 7}, {1, 10, 10, 2}, {3, 5, 6, 9}}}, }; -INSTANTIATE_TEST_SUITE_P(smoke_VariadicSplit4D_CPU_Nspc2NcspSpecial, VariadicSplitLayerCPUTest, - ::testing::Combine( - ::testing::ValuesIn(inputShapes4D_Nspc2NcspSpecial), - ::testing::Values(1), - ::testing::Values(LengthsPerInfer{{1, 2, -1, 1}}), - ::testing::ValuesIn(lengthsTypes), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(perChannelsToPlanar_4D)), - VariadicSplitLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_VariadicSplit4D_CPU_Nspc2NcspSpecial, + VariadicSplitLayerCPUTest, + ::testing::Combine(::testing::ValuesIn(inputShapes4D_Nspc2NcspSpecial), + ::testing::Values(1), + ::testing::Values(LengthsPerInfer{{1, 2, -1, 1}}), + ::testing::ValuesIn(lengthsTypes), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(perChannelsToPlanar_4D)), + VariadicSplitLayerCPUTest::getTestCaseName); const std::vector inputShapes5D_Nspc2NcspSpecial = { - { {}, {{3, 4, 7, 9, 3}} }, - { - // dynamic - {-1, -1, -1, -1, -1}, - // target - { - {1, 6, 5, 7, 5}, - {3, 8, 6, 9, 1}, - {5, 9, 1, 8, 2} - } - }, - { - // dynamic - {{1, 5}, {1, 64}, {1, 25}, {2, 10}, {1, 64}}, - // target - { - {2, 5, 5, 7, 7}, - {1, 4, 10, 2, 11}, - {3, 7, 5, 9, 8} - } - }, + {{}, {{3, 4, 7, 9, 3}}}, + {// dynamic + {-1, -1, -1, -1, -1}, + // target + {{1, 6, 5, 7, 5}, {3, 8, 6, 9, 1}, {5, 9, 1, 8, 2}}}, + {// dynamic + {{1, 5}, {1, 64}, {1, 25}, {2, 10}, {1, 64}}, + // target + {{2, 5, 5, 7, 7}, {1, 4, 10, 2, 11}, {3, 7, 5, 9, 8}}}, }; -INSTANTIATE_TEST_SUITE_P(smoke_VariadicSplit5D_CPU_Nspc2NcspSpecial, VariadicSplitLayerCPUTest, - ::testing::Combine( - ::testing::ValuesIn(inputShapes5D_Nspc2NcspSpecial), - ::testing::Values(1), - ::testing::Values(LengthsPerInfer{{2, 1, -1}}), - ::testing::ValuesIn(lengthsTypes), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(perChannelsToPlanar_5D)), - VariadicSplitLayerCPUTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_VariadicSplit4D_CPU_planar_static, VariadicSplitLayerCPUTest, - ::testing::Combine( - ::testing::Values(InputShape{ {}, {{3, 6, 5, 6}} }), - ::testing::Values(2, 3), - ::testing::Values(LengthsPerInfer{{1, 3, -1}}), - ::testing::Values(ngraph::helpers::InputLayerType::CONSTANT), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(planar_4D_ref, perChannels_4D)), - VariadicSplitLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_VariadicSplit5D_CPU_Nspc2NcspSpecial, + VariadicSplitLayerCPUTest, + ::testing::Combine(::testing::ValuesIn(inputShapes5D_Nspc2NcspSpecial), + ::testing::Values(1), + ::testing::Values(LengthsPerInfer{{2, 1, -1}}), + ::testing::ValuesIn(lengthsTypes), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(perChannelsToPlanar_5D)), + VariadicSplitLayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_VariadicSplit4D_CPU_planar_static, + VariadicSplitLayerCPUTest, + ::testing::Combine(::testing::Values(InputShape{{}, {{3, 6, 5, 6}}}), + ::testing::Values(2, 3), + ::testing::Values(LengthsPerInfer{{1, 3, -1}}), + ::testing::Values(ov::test::utils::InputLayerType::CONSTANT), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(planar_4D_ref, perChannels_4D)), + VariadicSplitLayerCPUTest::getTestCaseName); const std::vector inputShapes4D_planar = { - { - // dynamic - {-1, -1, -1, -1}, - // target - { - {1, 9, 8, 7}, - {3, 8, 6, 5}, - {5, 3, 7, 6} - } - }, - { - // dynamic - {{1, 5}, {1, 64}, {1, 48}, {2, 48}}, - // target - { - {2, 9, 5, 6}, - {1, 6, 9, 8}, - {3, 1, 6, 7} - } - }, + {// dynamic + {-1, -1, -1, -1}, + // target + {{1, 9, 8, 7}, {3, 8, 6, 5}, {5, 3, 7, 6}}}, + {// dynamic + {{1, 5}, {1, 64}, {1, 48}, {2, 48}}, + // target + {{2, 9, 5, 6}, {1, 6, 9, 8}, {3, 1, 6, 7}}}, }; -INSTANTIATE_TEST_SUITE_P(smoke_VariadicSplit4D_CPU_planar, VariadicSplitLayerCPUTest, - ::testing::Combine( - ::testing::ValuesIn(inputShapes4D_planar), - ::testing::Values(2, 3), - ::testing::Values(LengthsPerInfer{{1, 3, -1}}), - ::testing::ValuesIn(lengthsTypes), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(planar_4D_ref, perChannels_4D)), - VariadicSplitLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_VariadicSplit4D_CPU_planar, + VariadicSplitLayerCPUTest, + ::testing::Combine(::testing::ValuesIn(inputShapes4D_planar), + ::testing::Values(2, 3), + ::testing::Values(LengthsPerInfer{{1, 3, -1}}), + ::testing::ValuesIn(lengthsTypes), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(planar_4D_ref, perChannels_4D)), + VariadicSplitLayerCPUTest::getTestCaseName); const std::vector inputShapes4D_block = { - { {}, {{3, 16, 6, 7}} }, - { - // dynamic - {-1, 16, -1, -1}, - // target - { - {1, 16, 8, 7}, - {3, 16, 7, 8}, - {5, 16, 9, 8} - } - }, - { - // dynamic - {{1, 5}, 16, {1, 48}, {2, 24}}, - // target - { - {2, 16, 12, 6}, - {1, 16, 6, 9}, - {3, 16, 7, 6} - } - }, + {{}, {{3, 16, 6, 7}}}, + {// dynamic + {-1, 16, -1, -1}, + // target + {{1, 16, 8, 7}, {3, 16, 7, 8}, {5, 16, 9, 8}}}, + {// dynamic + {{1, 5}, 16, {1, 48}, {2, 24}}, + // target + {{2, 16, 12, 6}, {1, 16, 6, 9}, {3, 16, 7, 6}}}, }; -INSTANTIATE_TEST_SUITE_P(smoke_VariadicSplit4D_CPU_Block8, VariadicSplitLayerCPUTest, - ::testing::Combine( - ::testing::ValuesIn(inputShapes4D_block), - ::testing::Values(2, 3), - ::testing::Values(LengthsPerInfer{{2, 2, -1}}), - ::testing::ValuesIn(lengthsTypes), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(blocked8_4D_ref)), - VariadicSplitLayerCPUTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_VariadicSplit4D_CPU_Block16, VariadicSplitLayerCPUTest, - ::testing::Combine( - ::testing::ValuesIn(inputShapes4D_block), - ::testing::Values(2, 3), - ::testing::Values(LengthsPerInfer{{2, 2, -1, 1}}), - ::testing::ValuesIn(lengthsTypes), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(blocked16_4D_ref)), - VariadicSplitLayerCPUTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_VariadicSplit5D_CPU_planar_static, VariadicSplitLayerCPUTest, - ::testing::Combine( - ::testing::Values(InputShape{ {}, {{3, 24, 4, 5, 6}} }), - ::testing::Values(2, 3, 4), - ::testing::Values(LengthsPerInfer{{2, 1, -1}}), - ::testing::Values(ngraph::helpers::InputLayerType::CONSTANT), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(planar_5D_ref, perChannels_5D)), - VariadicSplitLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_VariadicSplit4D_CPU_Block8, + VariadicSplitLayerCPUTest, + ::testing::Combine(::testing::ValuesIn(inputShapes4D_block), + ::testing::Values(2, 3), + ::testing::Values(LengthsPerInfer{{2, 2, -1}}), + ::testing::ValuesIn(lengthsTypes), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(blocked8_4D_ref)), + VariadicSplitLayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_VariadicSplit4D_CPU_Block16, + VariadicSplitLayerCPUTest, + ::testing::Combine(::testing::ValuesIn(inputShapes4D_block), + ::testing::Values(2, 3), + ::testing::Values(LengthsPerInfer{{2, 2, -1, 1}}), + ::testing::ValuesIn(lengthsTypes), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(blocked16_4D_ref)), + VariadicSplitLayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_VariadicSplit5D_CPU_planar_static, + VariadicSplitLayerCPUTest, + ::testing::Combine(::testing::Values(InputShape{{}, {{3, 24, 4, 5, 6}}}), + ::testing::Values(2, 3, 4), + ::testing::Values(LengthsPerInfer{{2, 1, -1}}), + ::testing::Values(ov::test::utils::InputLayerType::CONSTANT), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(planar_5D_ref, perChannels_5D)), + VariadicSplitLayerCPUTest::getTestCaseName); const std::vector inputShapes5D_planar = { - { - // dynamic - {-1, -1, -1, -1, -1}, - // target - { - {1, 2, 4, 6, 5}, - {3, 1, 6, 4, 5}, - {5, 6, 5, 7, 4} - } - }, - { - // dynamic - {{1, 5}, {1, 64}, {1, 48}, {2, 48}, {2, 40}}, - // target - { - {2, 5, 4, 5, 6}, - {1, 7, 5, 4, 7}, - {3, 3, 5, 6, 4} - } - }, + {// dynamic + {-1, -1, -1, -1, -1}, + // target + {{1, 2, 4, 6, 5}, {3, 1, 6, 4, 5}, {5, 6, 5, 7, 4}}}, + {// dynamic + {{1, 5}, {1, 64}, {1, 48}, {2, 48}, {2, 40}}, + // target + {{2, 5, 4, 5, 6}, {1, 7, 5, 4, 7}, {3, 3, 5, 6, 4}}}, }; -INSTANTIATE_TEST_SUITE_P(smoke_VariadicSplit5D_CPU_planar, VariadicSplitLayerCPUTest, - ::testing::Combine( - ::testing::ValuesIn(inputShapes5D_planar), - ::testing::Values(2, 3, 4), - ::testing::Values(LengthsPerInfer{{2, 1, -1}}), - ::testing::ValuesIn(lengthsTypes), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(planar_5D_ref, perChannels_5D)), - VariadicSplitLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_VariadicSplit5D_CPU_planar, + VariadicSplitLayerCPUTest, + ::testing::Combine(::testing::ValuesIn(inputShapes5D_planar), + ::testing::Values(2, 3, 4), + ::testing::Values(LengthsPerInfer{{2, 1, -1}}), + ::testing::ValuesIn(lengthsTypes), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(planar_5D_ref, perChannels_5D)), + VariadicSplitLayerCPUTest::getTestCaseName); const std::vector inputShapes5D_block = { - { {}, {{3, 16, 8, 5, 6}} }, - { - // dynamic - {-1, 16, -1, -1, -1}, - // target - { - {1, 16, 5, 6, 7}, - {3, 16, 24, 5, 8}, - {5, 16, 6, 7, 5} - } - }, - { - // dynamic - {{1, 5}, 16, {1, 48}, {2, 24}, {2, 64}}, - // target - { - {2, 16, 7, 6, 5}, - {1, 16, 6, 5, 7}, - {3, 16, 5, 7, 6} - } - }, + {{}, {{3, 16, 8, 5, 6}}}, + {// dynamic + {-1, 16, -1, -1, -1}, + // target + {{1, 16, 5, 6, 7}, {3, 16, 24, 5, 8}, {5, 16, 6, 7, 5}}}, + {// dynamic + {{1, 5}, 16, {1, 48}, {2, 24}, {2, 64}}, + // target + {{2, 16, 7, 6, 5}, {1, 16, 6, 5, 7}, {3, 16, 5, 7, 6}}}, }; -INSTANTIATE_TEST_SUITE_P(smoke_VariadicSplit5D_CPU_Block8, VariadicSplitLayerCPUTest, - ::testing::Combine( - ::testing::ValuesIn(inputShapes5D_block), - ::testing::Values(2, 3, 4), - ::testing::Values(LengthsPerInfer{{1, 2, -1}}), - ::testing::ValuesIn(lengthsTypes), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(blocked8_5D_ref)), - VariadicSplitLayerCPUTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_VariadicSplit5D_CPU_Block16, VariadicSplitLayerCPUTest, - ::testing::Combine( - ::testing::ValuesIn(inputShapes5D_block), - ::testing::Values(2, 3, 4), - ::testing::Values(LengthsPerInfer{{2, 1, -1, 1}}), - ::testing::ValuesIn(lengthsTypes), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(blocked16_5D_ref)), - VariadicSplitLayerCPUTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_VariadicSplit3D_static, VariadicSplitLayerCPUTest, - ::testing::Combine( - ::testing::Values(InputShape{ {}, {{14, 7, 21}} }), - ::testing::Values(1, 2), - ::testing::Values(LengthsPerInfer{{2, 4, -1}}), - ::testing::Values(ngraph::helpers::InputLayerType::CONSTANT), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(CPUSpecificParams{{}, {}, {}, "ref"})), - VariadicSplitLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_VariadicSplit5D_CPU_Block8, + VariadicSplitLayerCPUTest, + ::testing::Combine(::testing::ValuesIn(inputShapes5D_block), + ::testing::Values(2, 3, 4), + ::testing::Values(LengthsPerInfer{{1, 2, -1}}), + ::testing::ValuesIn(lengthsTypes), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(blocked8_5D_ref)), + VariadicSplitLayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_VariadicSplit5D_CPU_Block16, + VariadicSplitLayerCPUTest, + ::testing::Combine(::testing::ValuesIn(inputShapes5D_block), + ::testing::Values(2, 3, 4), + ::testing::Values(LengthsPerInfer{{2, 1, -1, 1}}), + ::testing::ValuesIn(lengthsTypes), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(blocked16_5D_ref)), + VariadicSplitLayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_VariadicSplit3D_static, + VariadicSplitLayerCPUTest, + ::testing::Combine(::testing::Values(InputShape{{}, {{14, 7, 21}}}), + ::testing::Values(1, 2), + ::testing::Values(LengthsPerInfer{{2, 4, -1}}), + ::testing::Values(ov::test::utils::InputLayerType::CONSTANT), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(CPUSpecificParams{{}, {}, {}, "ref"})), + VariadicSplitLayerCPUTest::getTestCaseName); const std::vector inputShapes3D = { - { - // dynamic - {-1, -1, -1}, - // target - { - {7, 21, 14}, - {21, 7, 14}, - {21, 14, 7}, - } - }, - { - // dynamic - {{1, 60}, {1, 50}, {1, 48}}, - // target - { - {14, 21, 7}, - {21, 7, 14}, - {7, 14, 21}, - } - }, + {// dynamic + {-1, -1, -1}, + // target + { + {7, 21, 14}, + {21, 7, 14}, + {21, 14, 7}, + }}, + {// dynamic + {{1, 60}, {1, 50}, {1, 48}}, + // target + { + {14, 21, 7}, + {21, 7, 14}, + {7, 14, 21}, + }}, }; -INSTANTIATE_TEST_SUITE_P(smoke_VariadicSplit3D, VariadicSplitLayerCPUTest, - ::testing::Combine( - ::testing::ValuesIn(inputShapes3D), - ::testing::Values(0, 1, 2), - ::testing::Values(LengthsPerInfer{{2, 4, -1}}), - ::testing::ValuesIn(lengthsTypes), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(CPUSpecificParams{{}, {}, {}, "ref"})), - VariadicSplitLayerCPUTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_VariadicSplit2D_static, VariadicSplitLayerCPUTest, - ::testing::Combine( - ::testing::Values(InputShape{ {}, {{6, 12}} }), - ::testing::Values(1), - ::testing::Values(LengthsPerInfer{{2, -1}}), - ::testing::Values(ngraph::helpers::InputLayerType::CONSTANT), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(CPUSpecificParams{{}, {}, {}, "ref"})), - VariadicSplitLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_VariadicSplit3D, + VariadicSplitLayerCPUTest, + ::testing::Combine(::testing::ValuesIn(inputShapes3D), + ::testing::Values(0, 1, 2), + ::testing::Values(LengthsPerInfer{{2, 4, -1}}), + ::testing::ValuesIn(lengthsTypes), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(CPUSpecificParams{{}, {}, {}, "ref"})), + VariadicSplitLayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_VariadicSplit2D_static, + VariadicSplitLayerCPUTest, + ::testing::Combine(::testing::Values(InputShape{{}, {{6, 12}}}), + ::testing::Values(1), + ::testing::Values(LengthsPerInfer{{2, -1}}), + ::testing::Values(ov::test::utils::InputLayerType::CONSTANT), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(CPUSpecificParams{{}, {}, {}, "ref"})), + VariadicSplitLayerCPUTest::getTestCaseName); const std::vector inputShapes2D = { - { - // dynamic - {-1, -1}, - // target - { - {3, 8}, - {10, 4}, - {3, 6}, - } - }, - { - // dynamic - {{1, 60}, {1, 50}}, - // target - { - {3, 4}, - {4, 4}, - {6, 12}, - } - }, + {// dynamic + {-1, -1}, + // target + { + {3, 8}, + {10, 4}, + {3, 6}, + }}, + {// dynamic + {{1, 60}, {1, 50}}, + // target + { + {3, 4}, + {4, 4}, + {6, 12}, + }}, }; -INSTANTIATE_TEST_SUITE_P(smoke_VariadicSplit2D, VariadicSplitLayerCPUTest, - ::testing::Combine( - ::testing::ValuesIn(inputShapes2D), - ::testing::Values(0, 1), - ::testing::Values(LengthsPerInfer{{2, -1}}), - ::testing::ValuesIn(lengthsTypes), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(CPUSpecificParams{{}, {}, {}, "ref"})), - VariadicSplitLayerCPUTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_VariadicSplit1D_static, VariadicSplitLayerCPUTest, - ::testing::Combine( - ::testing::Values(InputShape{ {}, {{10}} }), - ::testing::Values(0), - ::testing::Values(LengthsPerInfer{{2, 1, 1, -1}}), - ::testing::Values(ngraph::helpers::InputLayerType::CONSTANT), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(CPUSpecificParams{{}, {}, {}, "unknown"}, CPUSpecificParams{{}, {}, {"ref"}, "ref"})), - VariadicSplitLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_VariadicSplit2D, + VariadicSplitLayerCPUTest, + ::testing::Combine(::testing::ValuesIn(inputShapes2D), + ::testing::Values(0, 1), + ::testing::Values(LengthsPerInfer{{2, -1}}), + ::testing::ValuesIn(lengthsTypes), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(CPUSpecificParams{{}, {}, {}, "ref"})), + VariadicSplitLayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_VariadicSplit1D_static, + VariadicSplitLayerCPUTest, + ::testing::Combine(::testing::Values(InputShape{{}, {{10}}}), + ::testing::Values(0), + ::testing::Values(LengthsPerInfer{{2, 1, 1, -1}}), + ::testing::Values(ov::test::utils::InputLayerType::CONSTANT), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(CPUSpecificParams{{}, {}, {}, "unknown"}, + CPUSpecificParams{{}, {}, {"ref"}, "ref"})), + VariadicSplitLayerCPUTest::getTestCaseName); const std::vector inputShapes1D = { - { - // dynamic - {-1}, - // target - { - {5}, - {15}, - {10}, - } - }, - { - // dynamic - {{1, 60}}, - // target - { - {15}, - {5}, - {10}, - } - }, + {// dynamic + {-1}, + // target + { + {5}, + {15}, + {10}, + }}, + {// dynamic + {{1, 60}}, + // target + { + {15}, + {5}, + {10}, + }}, }; -INSTANTIATE_TEST_SUITE_P(smoke_VariadicSplit1D, VariadicSplitLayerCPUTest, - ::testing::Combine( - ::testing::ValuesIn(inputShapes1D), - ::testing::Values(0), - ::testing::Values(LengthsPerInfer{{2, 1, 1, -1}}), - ::testing::ValuesIn(lengthsTypes), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(CPUSpecificParams{{}, {}, {}, "ref"})), - VariadicSplitLayerCPUTest::getTestCaseName); - -const std::vector inputShapes4D_zero_dims = { - { - // dynamic - {-1, -1, -1, -1}, - // target - { - {1, 7, 7, 7}, - {3, 7, 7, 7}, - } - } -}; - -INSTANTIATE_TEST_SUITE_P(smoke_VariadicSplit4D_CPU_zero_dims, VariadicSplitLayerCPUTest, - ::testing::Combine( - ::testing::ValuesIn(inputShapes4D_zero_dims), - ::testing::Values(1, 2, 3), - ::testing::Values(LengthsPerInfer{{3, 4, -1}}, LengthsPerInfer{{3, -1, 4}}, LengthsPerInfer{{-1, 3, 4}}), - ::testing::ValuesIn(lengthsTypes), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(planar_4D_ref)), - VariadicSplitLayerCPUTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_VariadicSplit4D_CPU_zero_dims_nspc_ncsp, VariadicSplitLayerCPUTest, - ::testing::Combine( - ::testing::ValuesIn(inputShapes4D_zero_dims), - ::testing::Values(1), - ::testing::Values(LengthsPerInfer{{3, 4, -1}}, LengthsPerInfer{{3, -1, 4}}, LengthsPerInfer{{-1, 3, 4}}), - ::testing::ValuesIn(lengthsTypes), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(perChannelsToPlanar_4D)), - VariadicSplitLayerCPUTest::getTestCaseName); - +INSTANTIATE_TEST_SUITE_P(smoke_VariadicSplit1D, + VariadicSplitLayerCPUTest, + ::testing::Combine(::testing::ValuesIn(inputShapes1D), + ::testing::Values(0), + ::testing::Values(LengthsPerInfer{{2, 1, 1, -1}}), + ::testing::ValuesIn(lengthsTypes), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(CPUSpecificParams{{}, {}, {}, "ref"})), + VariadicSplitLayerCPUTest::getTestCaseName); + +const std::vector inputShapes4D_zero_dims = {{// dynamic + {-1, -1, -1, -1}, + // target + { + {1, 7, 7, 7}, + {3, 7, 7, 7}, + }}}; + +INSTANTIATE_TEST_SUITE_P(smoke_VariadicSplit4D_CPU_zero_dims, + VariadicSplitLayerCPUTest, + ::testing::Combine(::testing::ValuesIn(inputShapes4D_zero_dims), + ::testing::Values(1, 2, 3), + ::testing::Values(LengthsPerInfer{{3, 4, -1}}, + LengthsPerInfer{{3, -1, 4}}, + LengthsPerInfer{{-1, 3, 4}}), + ::testing::ValuesIn(lengthsTypes), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(planar_4D_ref)), + VariadicSplitLayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_VariadicSplit4D_CPU_zero_dims_nspc_ncsp, + VariadicSplitLayerCPUTest, + ::testing::Combine(::testing::ValuesIn(inputShapes4D_zero_dims), + ::testing::Values(1), + ::testing::Values(LengthsPerInfer{{3, 4, -1}}, + LengthsPerInfer{{3, -1, 4}}, + LengthsPerInfer{{-1, 3, 4}}), + ::testing::ValuesIn(lengthsTypes), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(perChannelsToPlanar_4D)), + VariadicSplitLayerCPUTest::getTestCaseName); const std::vector inputShapes4D_dynamic_lengths = { - { - {1, 16, 8, 7}, - { - {1, 16, 8, 7}, - {1, 16, 8, 7}, - {1, 16, 8, 7} - } - }, - { - {-1, -1, -1, -1}, - { - {1, 16, 8, 7}, - {1, 16, 8, 7}, - {1, 16, 8, 7} - } - }, - { - {{1, 5}, -1, {1, 48}, {2, 24}}, - { - {2, 16, 12, 6}, - {1, 16, 6, 9}, - {3, 16, 7, 6} - } - }, + {{1, 16, 8, 7}, {{1, 16, 8, 7}, {1, 16, 8, 7}, {1, 16, 8, 7}}}, + {{-1, -1, -1, -1}, {{1, 16, 8, 7}, {1, 16, 8, 7}, {1, 16, 8, 7}}}, + {{{1, 5}, -1, {1, 48}, {2, 24}}, {{2, 16, 12, 6}, {1, 16, 6, 9}, {3, 16, 7, 6}}}, }; std::vector lengthsPerInfer = { @@ -601,108 +488,72 @@ std::vector lengthsPerInfer = { LengthsPerInfer{{10, 4, 2}, {2, 4, 10}, {4, 2, 10}}, }; -INSTANTIATE_TEST_SUITE_P(smoke_VariadicSplit4D_CPU_dynamic_lengths, VariadicSplitLayerCPUTest, - ::testing::Combine( - ::testing::ValuesIn(inputShapes4D_dynamic_lengths), - ::testing::Values(1), - ::testing::ValuesIn(lengthsPerInfer), - ::testing::Values(ngraph::helpers::InputLayerType::PARAMETER), - ::testing::Values(ElementType::f32), - ::testing::Values(planar_4D_ref)), - VariadicSplitLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_VariadicSplit4D_CPU_dynamic_lengths, + VariadicSplitLayerCPUTest, + ::testing::Combine(::testing::ValuesIn(inputShapes4D_dynamic_lengths), + ::testing::Values(1), + ::testing::ValuesIn(lengthsPerInfer), + ::testing::Values(ov::test::utils::InputLayerType::PARAMETER), + ::testing::Values(ElementType::f32), + ::testing::Values(planar_4D_ref)), + VariadicSplitLayerCPUTest::getTestCaseName); // =========================================== in - place ============================================================// -INSTANTIATE_TEST_SUITE_P(smoke_VariadicSplit_CPU_planar_inPlace_0, VariadicSplitLayerCPUTest, - ::testing::Combine( - ::testing::Values(InputShape{ {}, {{5, 6, 5, 6, 7}} }, - InputShape{ {}, {{5, 6, 5, 6}} }, - InputShape{ {}, {{5, 6, 5}} }, - InputShape{ {5, -1, -1, -1, -1}, - { - {5, 6, 5, 6, 7}, - {5, 2, 5, 2, 7}, - {5, 8, 5, 8, 7} - } }, - InputShape{ {5, -1, -1, -1}, - { - {5, 6, 5, 6}, - {5, 2, 5, 2}, - {5, 8, 5, 8} - } }, - InputShape{ {5, -1, -1}, - { - {5, 6, 5}, - {5, 2, 5}, - {5, 8, 5} - } }), - ::testing::Values(0), - ::testing::Values(LengthsPerInfer{{1, 2, -1}}), - ::testing::Values(ngraph::helpers::InputLayerType::CONSTANT), - ::testing::Values(ElementType::f32), - ::testing::Values(CPUSpecificParams{{}, {}, {}, "unknown"})), - VariadicSplitLayerCPUTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_VariadicSplit_CPU_planar_inPlace_1, VariadicSplitLayerCPUTest, - ::testing::Combine( - ::testing::Values(InputShape{ {}, {{1, 6, 5, 6, 7}} }, - InputShape{ {}, {{1, 6, 5, 6}} }, - InputShape{ {}, {{1, 6, 5}} }, - InputShape{ {1, 6, -1, -1, -1}, - { - {1, 6, 5, 6, 7}, - {1, 6, 5, 2, 7}, - {1, 6, 5, 8, 7} - } }, - InputShape{ {1, 6, -1, -1}, - { - {1, 6, 5, 6}, - {1, 6, 5, 2}, - {1, 6, 5, 8} - } }, - InputShape{ {1, 6, -1}, - { - {1, 6, 5}, - {1, 6, 3}, - {1, 6, 7} - } }), - ::testing::Values(1), - ::testing::Values(LengthsPerInfer{{1, 2, -1}}), - ::testing::Values(ngraph::helpers::InputLayerType::CONSTANT), - ::testing::Values(ElementType::f32), - ::testing::Values(CPUSpecificParams{{}, {}, {}, "unknown"})), - VariadicSplitLayerCPUTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_VariadicSplit4D_CPU_block8_inPlace, VariadicSplitLayerCPUTest, - ::testing::Combine( - ::testing::Values(InputShape{ {}, {{1, 32, 5, 6}} }, - InputShape{ {1, 32, -1, -1}, - { - {1, 32, 5, 6}, - {1, 32, 5, 2}, - {1, 32, 5, 8} - } }), - ::testing::Values(1), - ::testing::Values(LengthsPerInfer{{8, 16, -1}}), - ::testing::Values(ngraph::helpers::InputLayerType::CONSTANT), - ::testing::Values(ElementType::f32), - ::testing::Values(blocked8_4D)), - VariadicSplitLayerCPUTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_VariadicSplit4D_CPU_block16_inPlace, VariadicSplitLayerCPUTest, - ::testing::Combine( - ::testing::Values(InputShape{ {}, {{1, 64, 5, 6}} }, - InputShape{ {1, 64, -1, -1}, - { - {1, 64, 5, 6}, - {1, 64, 5, 2}, - {1, 64, 5, 8} - } }), - ::testing::Values(1), - ::testing::Values(LengthsPerInfer{{16, 32, -1}}), - ::testing::Values(ngraph::helpers::InputLayerType::CONSTANT), - ::testing::Values(ElementType::f32), - ::testing::Values(blocked16_4D)), - VariadicSplitLayerCPUTest::getTestCaseName); -} // namespace - -} // namespace CPULayerTestsDefinitions +INSTANTIATE_TEST_SUITE_P( + smoke_VariadicSplit_CPU_planar_inPlace_0, + VariadicSplitLayerCPUTest, + ::testing::Combine(::testing::Values(InputShape{{}, {{5, 6, 5, 6, 7}}}, + InputShape{{}, {{5, 6, 5, 6}}}, + InputShape{{}, {{5, 6, 5}}}, + InputShape{{5, -1, -1, -1, -1}, + {{5, 6, 5, 6, 7}, {5, 2, 5, 2, 7}, {5, 8, 5, 8, 7}}}, + InputShape{{5, -1, -1, -1}, {{5, 6, 5, 6}, {5, 2, 5, 2}, {5, 8, 5, 8}}}, + InputShape{{5, -1, -1}, {{5, 6, 5}, {5, 2, 5}, {5, 8, 5}}}), + ::testing::Values(0), + ::testing::Values(LengthsPerInfer{{1, 2, -1}}), + ::testing::Values(ov::test::utils::InputLayerType::CONSTANT), + ::testing::Values(ElementType::f32), + ::testing::Values(CPUSpecificParams{{}, {}, {}, "unknown"})), + VariadicSplitLayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P( + smoke_VariadicSplit_CPU_planar_inPlace_1, + VariadicSplitLayerCPUTest, + ::testing::Combine(::testing::Values(InputShape{{}, {{1, 6, 5, 6, 7}}}, + InputShape{{}, {{1, 6, 5, 6}}}, + InputShape{{}, {{1, 6, 5}}}, + InputShape{{1, 6, -1, -1, -1}, + {{1, 6, 5, 6, 7}, {1, 6, 5, 2, 7}, {1, 6, 5, 8, 7}}}, + InputShape{{1, 6, -1, -1}, {{1, 6, 5, 6}, {1, 6, 5, 2}, {1, 6, 5, 8}}}, + InputShape{{1, 6, -1}, {{1, 6, 5}, {1, 6, 3}, {1, 6, 7}}}), + ::testing::Values(1), + ::testing::Values(LengthsPerInfer{{1, 2, -1}}), + ::testing::Values(ov::test::utils::InputLayerType::CONSTANT), + ::testing::Values(ElementType::f32), + ::testing::Values(CPUSpecificParams{{}, {}, {}, "unknown"})), + VariadicSplitLayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P( + smoke_VariadicSplit4D_CPU_block8_inPlace, + VariadicSplitLayerCPUTest, + ::testing::Combine(::testing::Values(InputShape{{}, {{1, 32, 5, 6}}}, + InputShape{{1, 32, -1, -1}, {{1, 32, 5, 6}, {1, 32, 5, 2}, {1, 32, 5, 8}}}), + ::testing::Values(1), + ::testing::Values(LengthsPerInfer{{8, 16, -1}}), + ::testing::Values(ov::test::utils::InputLayerType::CONSTANT), + ::testing::Values(ElementType::f32), + ::testing::Values(blocked8_4D)), + VariadicSplitLayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P( + smoke_VariadicSplit4D_CPU_block16_inPlace, + VariadicSplitLayerCPUTest, + ::testing::Combine(::testing::Values(InputShape{{}, {{1, 64, 5, 6}}}, + InputShape{{1, 64, -1, -1}, {{1, 64, 5, 6}, {1, 64, 5, 2}, {1, 64, 5, 8}}}), + ::testing::Values(1), + ::testing::Values(LengthsPerInfer{{16, 32, -1}}), + ::testing::Values(ov::test::utils::InputLayerType::CONSTANT), + ::testing::Values(ElementType::f32), + ::testing::Values(blocked16_4D)), + VariadicSplitLayerCPUTest::getTestCaseName); +} // namespace \ No newline at end of file diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/add_convert_to_reorder.cpp b/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/add_convert_to_reorder.cpp index 645b85e9816ea0..cac8cb98fb81cf 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/add_convert_to_reorder.cpp +++ b/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/add_convert_to_reorder.cpp @@ -2,53 +2,51 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "test_utils/cpu_test_utils.hpp" -#include "shared_test_classes/base/layer_test_utils.hpp" -#include "ov_models/utils/ov_helpers.hpp" #include "ov_models/builders.hpp" +#include "shared_test_classes/base/ov_subgraph.hpp" +#include "test_utils/cpu_test_utils.hpp" -using namespace InferenceEngine; using namespace CPUTestUtils; -namespace LayerTestsDefinitions { +namespace ov { +namespace test { -class AddConvertToReorderTest : virtual public LayerTestsUtils::LayerTestsCommon { +class AddConvertToReorderTest : virtual public SubgraphBaseStaticTest { public: - void BuildGraph(const ngraph::element::Type& secondInpType) { + void BuildGraph(const ov::element::Type& secondInpType) { secondConstantType = secondInpType; int axis = 2; std::vector indices = {0, 3, 2, 1}; std::vector indicesShape = {2, 2}; std::vector inputShape = {10, 20, 30, 40}; - InferenceEngine::Precision netPrecision = inPrc = outPrc = Precision::FP32; + ov::element::Type netPrecision = inType = outType = ov::element::f32; targetDevice = ov::test::utils::DEVICE_CPU; - ASSERT_EQ(ngraph::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 params{std::make_shared(ngPrc, ov::Shape(inputShape))}; - auto indicesNode = ngraph::opset3::Constant::create(secondConstantType, ngraph::Shape(indicesShape), indices); - auto axisNode = ngraph::opset3::Constant::create(ngraph::element::i64, ngraph::Shape({}), {axis}); - auto gather = std::make_shared(params[0], indicesNode, axisNode); - ngraph::ResultVector results{std::make_shared(gather)}; - function = std::make_shared(results, params, "gather"); + ASSERT_EQ(ov::shape_size(indicesShape), indices.size()) + << "Indices vector size and provided indices shape doesn't fit each other"; + ov::ParameterVector params{std::make_shared(netPrecision, ov::Shape(inputShape))}; + auto indicesNode = ov::op::v0::Constant::create(secondConstantType, ov::Shape(indicesShape), indices); + auto axisNode = ov::op::v0::Constant::create(ov::element::i64, ov::Shape({}), {axis}); + auto gather = std::make_shared(params[0], indicesNode, axisNode); + ov::ResultVector results{std::make_shared(gather)}; + function = std::make_shared(results, params, "gather"); } - std::vector>> CalculateRefs() override { + std::vector calculate_refs() override { // Convert the second input constant precision to i64 to run the reference function - if (ngraph::element::Type_t::i8 == secondConstantType) { - ngraph::pass::ConvertPrecision().run_on_model(functionRefs); - } else if (ngraph::element::Type_t::bf16 == secondConstantType) { - ngraph::pass::ConvertPrecision().run_on_model(functionRefs); + if (ov::element::i8 == secondConstantType) { + convert_precisions.insert({ov::element::i8, ov::element::i64}); + } else if (ov::element::bf16 == secondConstantType) { + convert_precisions.insert({ov::element::bf16, ov::element::i64}); } - return LayerTestsUtils::LayerTestsCommon::CalculateRefs(); + return SubgraphBaseTest::calculate_refs(); } private: - ngraph::element::Type secondConstantType; + ov::element::Type secondConstantType; }; -namespace { +namespace { /* Test insertion of the Reorder layer if there is one. @@ -63,10 +61,11 @@ namespace { Output[FP32] */ TEST_F(AddConvertToReorderTest, smoke_TestAddReorder_CPU) { - BuildGraph(ngraph::element::i8); - Run(); - CheckNumberOfNodesWithType(executableNetwork, "Convert", 0); - CheckNumberOfNodesWithType(executableNetwork, "Reorder", 1); + BuildGraph(ov::element::i8); + run(); + CheckNumberOfNodesWithType(compiledModel, "Convert", 0); + CheckNumberOfNodesWithType(compiledModel, "Reorder", 1); } -} // namespace -} // namespace LayerTestsDefinitions +} // namespace +} // namespace test +} // namespace ov diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/align_matmul_input_ranks.cpp b/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/align_matmul_input_ranks.cpp index f5c6a6abb09ef5..5f77d49f8e14a6 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/align_matmul_input_ranks.cpp +++ b/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/align_matmul_input_ranks.cpp @@ -2,35 +2,37 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "test_utils/cpu_test_utils.hpp" -#include "test_utils/fusing_test_utils.hpp" -#include "ov_models/builders.hpp" -#include "common_test_utils/common_utils.hpp" - #include #include -using namespace ngraph; -using namespace InferenceEngine; +#include "common_test_utils/common_utils.hpp" +#include "ov_models/builders.hpp" +#include "shared_test_classes/base/ov_subgraph.hpp" +#include "test_utils/cpu_test_utils.hpp" +#include "test_utils/fusing_test_utils.hpp" + using namespace CPUTestUtils; -namespace SubgraphTestsDefinitions { +namespace ov { +namespace test { -using AlignMatMulInputRanksTestParams = std::tuple, // IS fully connected - fusingSpecificParams>; +using AlignMatMulInputRanksTestParams = std::tuple, // IS fully connected + fusingSpecificParams>; -class AlignMatMulInputRanksTest : public testing::WithParamInterface, public CpuTestWithFusing, - virtual public LayerTestsUtils::LayerTestsCommon { +class AlignMatMulInputRanksTest : public testing::WithParamInterface, + public CpuTestWithFusing, + virtual public SubgraphBaseStaticTest { public: static std::string getTestCaseName(testing::TestParamInfo obj) { - std::pair supportedInputShapes; + std::pair supportedInputShapes; fusingSpecificParams fusingParams; std::tie(supportedInputShapes, fusingParams) = obj.param; - SizeVector inputShapeA = supportedInputShapes.first; SizeVector inputShapeB = supportedInputShapes.second; + ov::Shape inputShapeA = supportedInputShapes.first; + ov::Shape inputShapeB = supportedInputShapes.second; std::ostringstream result; - result << "IS_A=" << ov::test::utils::vec2str(inputShapeA) << "_"; - result << "IS_B=" << ov::test::utils::vec2str(inputShapeB) << "_"; + result << "IS_A=" << inputShapeA << "_"; + result << "IS_B=" << inputShapeB << "_"; result << CpuTestWithFusing::getTestCaseName(fusingParams); return result.str(); @@ -39,7 +41,7 @@ class AlignMatMulInputRanksTest : public testing::WithParamInterface inShapes; + std::pair inShapes; fusingSpecificParams fusingParams; std::tie(inShapes, fusingParams) = this->GetParam(); @@ -48,14 +50,14 @@ class AlignMatMulInputRanksTest : public testing::WithParamInterface(ngPrec, ov::Shape(inShapes.first)), - std::make_shared(ngPrec, ov::Shape(inShapes.second))}; + ov::ParameterVector inputParams{std::make_shared(ngPrec, inShapes.first), + std::make_shared(ngPrec, inShapes.second)}; const auto matMul = std::make_shared(inputParams[0], inputParams[1], false, false); selectedType = makeSelectedTypeStr(with_cpu_x86_avx512_core() ? "brgemm_avx512" : "jit_gemm", ngPrec); @@ -67,18 +69,20 @@ class AlignMatMulInputRanksTest : public testing::WithParamInterface> supportedInputShapes = { - {{4, 10, 5}, {1, 5, 10}}, // nothing to be done - {{3}, {3}}, // 3x1 * 1x3 -> 1 - {{18}, {1, 5, 18, 20}}, // 1x1x1x18 * 1x5x18x20 -> 1x5x20 - {{2, 3, 4, 4, 4, 10, 5}, {5}}, // 2x3x4x4x4x10x5 * 1x1x1x1x1x5x1 -> 1x1x1x1x1x5 +const std::vector> supportedInputShapes = { + {{4, 10, 5}, {1, 5, 10}}, // nothing to be done + {{3}, {3}}, // 3x1 * 1x3 -> 1 + {{18}, {1, 5, 18, 20}}, // 1x1x1x18 * 1x5x18x20 -> 1x5x20 + {{2, 3, 4, 4, 4, 10, 5}, {5}}, // 2x3x4x4x4x10x5 * 1x1x1x1x1x5x1 -> 1x1x1x1x1x5 {{1, 18}, {1, 5, 18, 20}}, {{1, 70, 18}, {1, 5, 18, 20}}, {{7, 1, 10, 3, 2, 7}, {1, 7, 5}}, @@ -86,16 +90,18 @@ const std::vector> supportedInputShapes = { }; // verify fusing just in case -std::vector fusingParamsSet { - emptyFusingSpec, - fusingElu, +std::vector fusingParamsSet{ + emptyFusingSpec, + fusingElu, }; -INSTANTIATE_TEST_SUITE_P(smoke_Check, AlignMatMulInputRanksTest, +INSTANTIATE_TEST_SUITE_P(smoke_Check, + AlignMatMulInputRanksTest, ::testing::Combine(::testing::ValuesIn(supportedInputShapes), ::testing::ValuesIn(fusingParamsSet)), AlignMatMulInputRanksTest::getTestCaseName); -} // namespace +} // namespace -} // namespace SubgraphTestsDefinitions +} // namespace test +} // namespace ov diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/any_layout.cpp b/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/any_layout.cpp index 5d7bcbfbdfcc2f..c37704699216d6 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/any_layout.cpp +++ b/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/any_layout.cpp @@ -3,10 +3,10 @@ // #include "test_utils/cpu_test_utils.hpp" +#include "openvino/core/preprocess/pre_post_process.hpp" -using namespace InferenceEngine; - -namespace SubgraphTestsDefinitions { +namespace ov { +namespace test { class AnyLayoutOnInputsAndOutputs : public ::testing::TestWithParam { public: @@ -17,18 +17,18 @@ class AnyLayoutOnInputsAndOutputs : public ::testing::TestWithParam { } protected: - std::shared_ptr + std::shared_ptr create_test_function(const ov::Shape & shape) { - auto param = std::make_shared(ov::element::f32, shape); + auto param = std::make_shared(ov::element::f32, shape); float shift = 1.0f; - auto shift_node = std::make_shared(ov::element::f32, ov::Shape{1}, &shift); + auto shift_node = std::make_shared(ov::element::f32, ov::Shape{1}, &shift); - auto add = std::make_shared(param, shift_node); + auto add = std::make_shared(param, shift_node); - auto result = std::make_shared(add); + auto result = std::make_shared(add); - return std::make_shared(ngraph::ResultVector{result}, ngraph::ParameterVector{param}); + return std::make_shared(ov::ResultVector{result}, ov::ParameterVector{param}); } void Run() { @@ -39,38 +39,26 @@ class AnyLayoutOnInputsAndOutputs : public ::testing::TestWithParam { std::vector output_data(shape_size); std::vector expected_output(shape_size, 3); - // Create CNNNetwork - auto ngraph_function = create_test_function(shape); - auto cnn = InferenceEngine::CNNNetwork(ngraph_function); - - // Fill inputs and outputs - std::vector input_names; - std::vector out_names; - for (const auto& it : cnn.getInputsInfo()) { - input_names.push_back(it.first); - } - for (const auto& it : cnn.getOutputsInfo()) { - out_names.push_back(it.first); - } - - BlobMap inputBlobs; - BlobMap outputBlobs; + // Create model + auto function = create_test_function(shape); - TensorDesc tensorDescInp1(Precision::FP32, shape, Layout::ANY); - TensorDesc tensorDescOut(Precision::FP32, shape, Layout::ANY); + auto ppp_model = ov::preprocess::PrePostProcessor(function); + ppp_model.input().tensor().set_layout("..."); + ppp_model.output().tensor().set_layout("..."); + function = ppp_model.build(); - inputBlobs[input_names[0]] = make_shared_blob(tensorDescInp1, input_data.data()); - outputBlobs[out_names[0]] = make_shared_blob(tensorDescOut, output_data.data()); + auto input = ov::Tensor(ov::element::f32, shape, input_data.data()); + auto output = ov::Tensor(ov::element::f32, shape, output_data.data()); - // Load network - Core ie; - ExecutableNetwork executable_network = ie.LoadNetwork(cnn, "CPU"); + // Load model + Core core; + auto compiled_model = core.compile_model(function, "CPU"); // Infer - InferRequest infer_request = executable_network.CreateInferRequest(); - infer_request.SetInput(inputBlobs); - infer_request.SetOutput(outputBlobs); - infer_request.Infer(); + auto infer_req = compiled_model.create_infer_request(); + infer_req.set_input_tensor(input); + infer_req.set_output_tensor(output); + infer_req.infer(); ASSERT_EQ(output_data, expected_output); } @@ -91,4 +79,5 @@ INSTANTIATE_TEST_SUITE_P(AnyLayoutOnInputsAndOutputs, ::testing::ValuesIn(AnyLayoutOnInputsAndOutputsParams), AnyLayoutOnInputsAndOutputs::getTestCaseName); -} // namespace SubgraphTestsDefinitions +} // namespace test +} // 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/subgraph_tests/src/arm/convert_group_conv.cpp index 48aea1512428e5..2a631c344162f2 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/arm/convert_group_conv.cpp +++ b/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/arm/convert_group_conv.cpp @@ -2,28 +2,14 @@ // SPDX-License-Identifier: Apache-2.0 // -#include -#include -#include -#include -#include -#include -#include -#include "common_test_utils/common_utils.hpp" -#include -#include "functional_test_utils/skip_tests_config.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 "cpp_interfaces/interface/ie_internal_plugin_config.hpp" - -#include "test_utils/cpu_test_utils.hpp" -#include "test_utils/convolution_params.hpp" using namespace CPUTestUtils; -using namespace ov::test; -using namespace ngraph; -using namespace ngraph::helpers; -namespace CPUSubgraphTestsDefinitions { +namespace ov { +namespace test { typedef std::tuple groupConvLayerCPUTestParamsSet; @@ -60,15 +46,23 @@ class GroupConvToConvTransformationCPUTest: public testing::WithParamInterface(ngraph::element::f32, shape)); + inputParams.push_back(std::make_shared(ov::element::f32, shape)); } - conv = builder::makeGroupConvolution(inputParams[0], element::f32, kernelSize, strides, padBegin, padEnd, dilation, - paddingType, numOutChannels, numOfGroups); + conv = utils::make_group_convolution(inputParams[0], + element::f32, + kernelSize, + strides, + padBegin, + padEnd, + dilation, + paddingType, + numOutChannels, + numOfGroups); ResultVector results; - results.push_back(std::make_shared(conv)); + results.push_back(std::make_shared(conv)); - function = std::make_shared(results, inputParams, "groupConvolution"); + function = std::make_shared(results, inputParams, "groupConvolution"); } }; @@ -96,5 +90,6 @@ const auto groupConvTransformationParams = ::testing::Combine(::testing::ValuesI INSTANTIATE_TEST_SUITE_P(smoke_GroupConvToConvTransformationTest, GroupConvToConvTransformationCPUTest, groupConvTransformationParams, GroupConvToConvTransformationCPUTest::getTestCaseName); -} // namespace -} // namespace CPUSubgraphTestsDefinitions +} // namespace +} // namespace test +} // namespace ov diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/arm/convert_group_conv1d.cpp b/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/arm/convert_group_conv1d.cpp index 79a21d4c8bd854..9beb3be72f5882 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/arm/convert_group_conv1d.cpp +++ b/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/arm/convert_group_conv1d.cpp @@ -2,35 +2,23 @@ // SPDX-License-Identifier: Apache-2.0 // -#include -#include -#include -#include -#include -#include -#include #include "common_test_utils/common_utils.hpp" -#include -#include "functional_test_utils/skip_tests_config.hpp" +#include "common_test_utils/node_builders/convolution.hpp" +#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 "cpp_interfaces/interface/ie_internal_plugin_config.hpp" -#include "test_utils/cpu_test_utils.hpp" -#include "test_utils/convolution_params.hpp" - -using namespace InferenceEngine; using namespace CPUTestUtils; -using namespace ov::test; -using namespace ngraph; -using namespace ngraph::helpers; -namespace CPUSubgraphTestsDefinitions { +namespace ov { +namespace test { -typedef std::tuple conv1dConvertCPUTestParamsSet; +typedef std::tuple conv1dConvertCPUTestParamsSet; -class Conv1dConvertTransformationCPUTest: public testing::WithParamInterface, - virtual public SubgraphBaseTest, public CPUTestsBase { +class Conv1dConvertTransformationCPUTest : public testing::WithParamInterface, + virtual public SubgraphBaseTest, + public CPUTestsBase { public: static std::string getTestCaseName(testing::TestParamInfo obj) { InputShape inputShapes; @@ -65,16 +53,16 @@ class Conv1dConvertTransformationCPUTest: public testing::WithParamInterface(ngraph::element::f32, shape)); + inputParams.push_back(std::make_shared(ov::element::f32, shape)); } switch (convType) { case nodeType::convolution : { - conv = builder::makeConvolution(inputParams[0], element::f32, kernelSize, strides, padBegin, padEnd, dilation, + conv = utils::make_convolution(inputParams[0], element::f32, kernelSize, strides, padBegin, padEnd, dilation, paddingType, numOutChannels); break; } case nodeType::groupConvolution : { - conv = builder::makeGroupConvolution(inputParams[0], element::f32, kernelSize, strides, padBegin, padEnd, dilation, + conv = utils::make_group_convolution(inputParams[0], element::f32, kernelSize, strides, padBegin, padEnd, dilation, paddingType, numOutChannels, numOfGroups); break; } @@ -84,9 +72,9 @@ class Conv1dConvertTransformationCPUTest: public testing::WithParamInterface(conv)); + results.push_back(std::make_shared(conv)); - function = std::make_shared(results, inputParams, "convolution"); + function = std::make_shared(results, inputParams, "convolution"); } }; @@ -132,5 +120,6 @@ const auto groupConvTransformationParams = ::testing::Combine(::testing::ValuesI INSTANTIATE_TEST_SUITE_P(smoke_GroupConvToConvTransformationTest, Conv1dConvertTransformationCPUTest, groupConvTransformationParams, Conv1dConvertTransformationCPUTest::getTestCaseName); -} // namespace -} // namespace CPUSubgraphTestsDefinitions +} // namespace +} // namespace test +} // namespace ov 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/subgraph_tests/src/arm/convert_reduce_multi_axis.cpp index 3bb5a06c7d9f2c..2b837a4fd275c4 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/arm/convert_reduce_multi_axis.cpp +++ b/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/arm/convert_reduce_multi_axis.cpp @@ -2,35 +2,22 @@ // SPDX-License-Identifier: Apache-2.0 // -#include -#include -#include -#include -#include -#include -#include #include "common_test_utils/common_utils.hpp" -#include -#include "functional_test_utils/skip_tests_config.hpp" +#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 "cpp_interfaces/interface/ie_internal_plugin_config.hpp" -#include "test_utils/cpu_test_utils.hpp" -#include "test_utils/convolution_params.hpp" - -using namespace InferenceEngine; using namespace CPUTestUtils; -using namespace ov::test; -using namespace ngraph; -using namespace ngraph::helpers; -namespace CPUSubgraphTestsDefinitions { +namespace ov { +namespace test { -typedef std::tuple< - std::vector, // Axis to reduce order - ngraph::helpers::ReductionType, // Reduce operation type - std::vector // Input shapes -> reduceConvertCPUTestParamsSet; +typedef std::tuple, // Axis to reduce order + ov::test::utils::ReductionType, // Reduce operation type + std::vector // Input shapes + > + reduceConvertCPUTestParamsSet; class reduceTransformationCPUTest: public testing::WithParamInterface, virtual public SubgraphBaseTest, public CPUTestsBase { @@ -38,7 +25,7 @@ class reduceTransformationCPUTest: public testing::WithParamInterface obj) { std::vector inputShapes; std::vector axes; - ReductionType reductionType; + utils::ReductionType reductionType; std::tie(axes, reductionType, inputShapes) = obj.param; std::ostringstream result; @@ -65,18 +52,18 @@ class reduceTransformationCPUTest: public testing::WithParamInterface(ngraph::element::f32, shape)); + params.push_back(std::make_shared(ov::element::f32, shape)); } std::vector shapeAxes; shapeAxes.push_back(axes.size()); - auto reductionAxesNode = std::dynamic_pointer_cast( - std::make_shared(ngraph::element::Type_t::i64, ngraph::Shape(shapeAxes), axes)); + 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 auto reduce = utils::make_reduce(params[0], reductionAxesNode, keepDims, reductionType); function = makeNgraphFunction(ElementType::f32, params, reduce, "Reduce"); } private: - ngraph::helpers::ReductionType reductionType; + utils::ReductionType reductionType; }; TEST_P(reduceTransformationCPUTest, CompareWithRefs) { @@ -88,11 +75,11 @@ namespace { std::vector> inputShapes = { {{{}, {{2, 19, 2, 9}}}} }; -const std::vector reductionTypes = { - ReductionType::Min, - ReductionType::Max, - ReductionType::Sum, - ReductionType::Prod +const std::vector reductionTypes = { + utils::ReductionType::Min, + utils::ReductionType::Max, + utils::ReductionType::Sum, + utils::ReductionType::Prod }; const std::vector> axes = { {0, 1}, @@ -114,5 +101,6 @@ const auto reduceTransformationParams = ::testing::Combine(::testing::ValuesIn(a INSTANTIATE_TEST_SUITE_P(smoke_GroupConvToConvTransformationTest, reduceTransformationCPUTest, reduceTransformationParams, reduceTransformationCPUTest::getTestCaseName); -} // namespace -} // namespace CPUSubgraphTestsDefinitions +} // namespace +} // namespace test +} // namespace ov diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/broadcast_eltwise.cpp b/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/broadcast_eltwise.cpp index b3a6c80097d39d..60d3d866a6ed17 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/broadcast_eltwise.cpp +++ b/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/broadcast_eltwise.cpp @@ -2,21 +2,15 @@ // SPDX-License-Identifier: Apache-2.0 // -#include -#include - -#include "ov_models/builders.hpp" -#include "ov_models/utils/ov_helpers.hpp" +#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" -using namespace ngraph; -using namespace ov::test; using namespace CPUTestUtils; -using namespace InferenceEngine; +namespace ov { +namespace test { -namespace SubgraphTestsDefinitions { using BroadcastEltwiseParams = std::tuple< ElementType, // input precision InputShape, // input shape @@ -134,4 +128,5 @@ INSTANTIATE_TEST_SUITE_P(smoke_BroadcastEltwise, ::testing::ValuesIn(target_shapes)), BroadcastEltwise::getTestCaseName); } // namespace -} // namespace SubgraphTestsDefinitions \ No newline at end of file +} // namespace test +} // namespace ov \ No newline at end of file diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/concat_reshape_concat.cpp b/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/concat_reshape_concat.cpp index fa0c73c2d7381c..73ffc34651042c 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/concat_reshape_concat.cpp +++ b/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/concat_reshape_concat.cpp @@ -6,7 +6,6 @@ #include "ov_models/utils/ov_helpers.hpp" #include "ov_models/builders.hpp" - /*This test runs the following subgraph: param1 param2 param3 param4 @@ -39,10 +38,8 @@ Softmax is used as a model of an arbitrary subgraph preceding the pattern. */ -using namespace InferenceEngine; -using namespace ov::test; - -namespace SubgraphTestsDefinitions { +namespace ov { +namespace test { using VectorShapes = std::vector; @@ -86,32 +83,32 @@ class ConcatReshapeConcatSubgraphTest : public testing::WithParamInterface(input_params[i], softmax_axis); + auto soft_max = std::make_shared(input_params[i], softmax_axis); auto reshape_param = ngraph::builder::makeConstant(ov::element::i32, {1}, {0}); - auto reshape = std::make_shared(soft_max, reshape_param); + auto reshape = std::make_shared(soft_max, reshape_param); first_level_reshapes.push_back(reshape); } - auto concat1 = std::make_shared(ov::NodeVector{first_level_reshapes[0], first_level_reshapes[1]}, concat_axis); - auto concat2 = std::make_shared(ov::NodeVector{first_level_reshapes[2], first_level_reshapes[3]}, concat_axis); + auto concat1 = std::make_shared(ov::NodeVector{first_level_reshapes[0], first_level_reshapes[1]}, concat_axis); + auto concat2 = std::make_shared(ov::NodeVector{first_level_reshapes[2], first_level_reshapes[3]}, concat_axis); ov::NodeVector second_level_reshapes; ov::NodeVector first_level_concats = {concat1, concat2}; for (size_t i = 0; i < number_of_params / 2; ++i) { auto reshape_param = ngraph::builder::makeConstant(ov::element::i32, {1}, {0}); - auto reshape = std::make_shared(first_level_concats[i], reshape_param); + auto reshape = std::make_shared(first_level_concats[i], reshape_param); second_level_reshapes.push_back(reshape); } - auto concat3 = std::make_shared(second_level_reshapes, concat_axis); - auto soft_max = std::make_shared(concat3, softmax_axis); + auto concat3 = std::make_shared(second_level_reshapes, concat_axis); + auto soft_max = std::make_shared(concat3, softmax_axis); - ngraph::ResultVector results; + ov::ResultVector results; for (size_t i = 0; i < soft_max->get_output_size(); i++) - results.push_back(std::make_shared(soft_max->output(i))); + results.push_back(std::make_shared(soft_max->output(i))); - function = std::make_shared(results, input_params, "ConcatReshapeConcatPattern"); + function = std::make_shared(results, input_params, "ConcatReshapeConcatPattern"); } }; @@ -142,4 +139,5 @@ INSTANTIATE_TEST_SUITE_P(smoke_Concat_Reshape_Concat, ConcatReshapeConcatSubgrap ::testing::ValuesIn(inputShapes), ConcatReshapeConcatSubgraphTest::getTestCaseName); } // namespace -} // namespace SubgraphTestsDefinitions \ No newline at end of file +} // namespace test +} // namespace ov \ No newline at end of file diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/concat_sdp.cpp b/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/concat_sdp.cpp index bf5dac2d822ba6..7f7ea0f30f9997 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/concat_sdp.cpp +++ b/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/concat_sdp.cpp @@ -73,7 +73,7 @@ class ConcatSDPTest : public testing::WithParamInterface, v bool hasShapeOf; std::tie(inType, inputShapes, hasShapeOf) = this->GetParam(); targetDevice = ov::test::utils::DEVICE_CPU; - rel_threshold = 1e-4f; + rel_threshold = 1e-2f; if (inType == ElementType::bf16) { configuration.insert({"ENFORCE_BF16", "YES"}); rel_threshold = 0.01f; @@ -170,7 +170,6 @@ class ConcatSDPTest : public testing::WithParamInterface, v for (auto&& state : inferRequest.query_state()) { state.reset(); } - inferRequest = ov::InferRequest(); } std::vector run_test(std::shared_ptr model) { function = model; diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/conv_dw_conv.cpp b/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/conv_dw_conv.cpp index e0f3473794b772..71fcb4122cb739 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/conv_dw_conv.cpp +++ b/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/conv_dw_conv.cpp @@ -7,9 +7,12 @@ #include "test_utils/cpu_test_utils.hpp" #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" +#include "common_test_utils/node_builders/group_convolution.hpp" + +namespace ov { +namespace test { -using namespace ngraph; -namespace SubgraphTestsDefinitions { class ConvDWConv : virtual public ov::test::SubgraphBaseTest { protected: void SetUp() override { @@ -24,27 +27,27 @@ class ConvDWConv : virtual public ov::test::SubgraphBaseTest { params.push_back(std::make_shared(precision, shape)); } auto conv_weights = ngraph::builder::makeConstant(precision, std::vector{32, 32, 1, 1}, std::vector{}, true); - auto conv = ngraph::builder::makeConvolution(params[0], - conv_weights, - precision, - std::vector{1, 1}, - std::vector{1, 1}, - ov::CoordinateDiff{0, 0}, - ov::CoordinateDiff{0, 0}, - std::vector{1, 1}, - ngraph::op::PadType::EXPLICIT, - 32, - true); + auto conv = ov::test::utils::make_convolution(params[0], + conv_weights, + precision, + std::vector{1, 1}, + std::vector{1, 1}, + ov::CoordinateDiff{0, 0}, + ov::CoordinateDiff{0, 0}, + std::vector{1, 1}, + ov::op::PadType::EXPLICIT, + 32, + true); auto dw_conv_weights = ngraph::builder::makeConstant(precision, std::vector{32, 1, 1, 3, 3}, std::vector{}, true); - auto dw_conv = ngraph::builder::makeGroupConvolution(conv, - dw_conv_weights, - precision, - std::vector{1, 1}, - ov::CoordinateDiff{1, 1}, - ov::CoordinateDiff{1, 1}, - std::vector{1, 1}, - ngraph::op::PadType::EXPLICIT); + auto dw_conv = ov::test::utils::make_group_convolution(conv, + dw_conv_weights, + precision, + std::vector{1, 1}, + ov::CoordinateDiff{1, 1}, + ov::CoordinateDiff{1, 1}, + std::vector{1, 1}, + ov::op::PadType::EXPLICIT); auto bias_const = ngraph::builder::makeConstant(precision, {1, 32 , 1, 1}, std::vector{}, true); auto bias = std::make_shared(dw_conv, bias_const); function = std::make_shared(bias, params, "ConvDWConv"); @@ -55,4 +58,5 @@ TEST_F(ConvDWConv, smoke_CompareWithRefs) { run(); } -} // namespace SubgraphTestsDefinitions +} // namespace test +} // namespace ov diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/conv_sum_broadcast.cpp b/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/conv_sum_broadcast.cpp index 564a6fd4d2c21c..3d6b89db51fe8e 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/conv_sum_broadcast.cpp +++ b/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/conv_sum_broadcast.cpp @@ -2,28 +2,31 @@ // SPDX-License-Identifier: Apache-2.0 // -#include -#include -#include "test_utils/fusing_test_utils.hpp" -#include "test_utils/convolution_params.hpp" -#include "shared_test_classes/base/ov_subgraph.hpp" -#include "ov_models/utils/ov_helpers.hpp" -#include "ov_models/builders.hpp" +#include "common_test_utils/node_builders/convolution.hpp" +#include "common_test_utils/node_builders/activation.hpp" #include "cpp_interfaces/interface/ie_internal_plugin_config.hpp" +#include "ov_models/builders.hpp" +#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 "internal_properties.hpp" + +#include using namespace CPUTestUtils; -using namespace InferenceEngine; -using namespace ov::test; -namespace SubgraphTestsDefinitions { -typedef std::tuple< - InputShape, //convShape - InputShape, //second term shape - bool, // bias flag - fusingSpecificParams, - std::map // config -> convSumBroadcastParamSet; +namespace ov { +namespace test { +typedef std::tuple + convSumBroadcastParamSet; class ConvSumInPlaceTest : public testing::WithParamInterface, virtual public SubgraphBaseTest, public CpuTestWithFusing { @@ -33,7 +36,7 @@ class ConvSumInPlaceTest : public testing::WithParamInterface additionalConfig; + ov::AnyMap additionalConfig; std::tie(convShape, secondShape, bias, fusingParams, additionalConfig) = obj.param; std::ostringstream result; @@ -55,30 +58,30 @@ class ConvSumInPlaceTest : public testing::WithParamInterface additionalConfig; + ov::AnyMap additionalConfig; std::tie(convShape, secondShape, bias, fusingParams, additionalConfig) = this->GetParam(); std::tie(postOpMgrPtr, fusedOps) = fusingParams; @@ -108,20 +111,20 @@ class ConvSumInPlaceTest : public testing::WithParamInterface(ngraph::element::Type_t::f32, ngraph::Shape({1, _convOutChannels, 1, 1}), {}, true); - conv = std::make_shared(conv, biasNode); + auto biasNode = ngraph::builder::makeConstant(ov::element::Type_t::f32, ov::Shape({1, _convOutChannels, 1, 1}), {}, true); + conv = std::make_shared(conv, biasNode); } auto sum = addSum(conv, inputParams); runtimeType = getNetType(); - if (configuration.count(PluginConfigParams::KEY_ENFORCE_BF16) && - PluginConfigParams::YES == configuration[PluginConfigParams::KEY_ENFORCE_BF16].as()) { - runtimeType = ngraph::element::Type_t::bf16; + auto it = configuration.find(ov::hint::inference_precision.name()); + if (it != configuration.end() && it->second.as() == ov::element::bf16) { + runtimeType = ov::element::Type_t::bf16; } - if (inputParams.front()->get_element_type() == ngraph::element::i8 || inputParams.front()->get_element_type() == ngraph::element::u8) { - runtimeType = ngraph::element::i8; + if (inputParams.front()->get_element_type() == ov::element::i8 || inputParams.front()->get_element_type() == ov::element::u8) { + runtimeType = ov::element::i8; } selectedType = "?"; @@ -129,10 +132,8 @@ class ConvSumInPlaceTest : public testing::WithParamInterface _padBegin = {0, 0}; std::vector _padEnd = {0, 0}; size_t _convOutChannels = 64; @@ -194,45 +195,51 @@ TEST_P(ConvSumInPlaceStrided, CompareWithRefs) { class ConvSumInPlaceTestInt8 : public ConvSumInPlaceTest { public: - ngraph::ParameterVector makeParams() override { - ngraph::ParameterVector outs(2); - outs[0] = std::make_shared(ngraph::element::u8, inputDynamicShapes[0]); - outs[1] = std::make_shared(ngraph::element::f32, inputDynamicShapes[1]); + ov::ParameterVector makeParams() override { + ov::ParameterVector outs(2); + outs[0] = std::make_shared(ov::element::u8, inputDynamicShapes[0]); + outs[1] = std::make_shared(ov::element::f32, inputDynamicShapes[1]); return outs; } - std::shared_ptr makeConv(const ngraph::ParameterVector& inputParams) override { - using namespace ngraph; + std::shared_ptr makeConv(const ov::ParameterVector& inputParams) override { auto inputParamsFP32 = std::make_shared(element::f32, inputParams.front()->get_partial_shape()); - auto convolutionNodeRelaxed = std::make_shared>( - *as_type_ptr(builder::makeConvolution(inputParamsFP32, element::f32, _kernel, _stride, _padBegin, - _padEnd, _dilation, ngraph::op::PadType::EXPLICIT, _convOutChannels)), - element::f32); + auto convolutionNodeRelaxed = std::make_shared>( + *as_type_ptr(ov::test::utils::make_convolution(inputParamsFP32, + element::f32, + _kernel, + _stride, + _padBegin, + _padEnd, + _dilation, + ov::op::PadType::EXPLICIT, + _convOutChannels)), + ov::element::f32); auto inpShape = inputParams.front()->get_partial_shape(); Shape filterShape = {_convOutChannels, static_cast(inpShape[1].get_length())}; filterShape.insert(filterShape.end(), _kernel.begin(), _kernel.end()); - auto filterWeightsNode = builder::makeConstant(element::i8, filterShape, {}, true); + auto filterWeightsNode = ngraph::builder::makeConstant(ov::element::i8, filterShape, {}, true); auto conv = convolutionNodeRelaxed->copy_with_new_inputs({inputParams.front(), filterWeightsNode}); return conv; } - std::shared_ptr addSum(std::shared_ptr lastNode, const ngraph::ParameterVector& inputParams) override { + std::shared_ptr addSum(std::shared_ptr lastNode, const ov::ParameterVector& inputParams) override { std::vector additionalFusedOps; - lastNode = ngraph::builder::makeActivation(lastNode, ngraph::element::f32, ngraph::helpers::Relu); + lastNode = ov::test::utils::make_activation(lastNode, ov::element::f32, ov::test::utils::Relu); //additionalFusedOps.push_back("Relu"); - auto fqShape = ngraph::Shape(lastNode->get_output_partial_shape(0).size(), 1); - lastNode = ngraph::builder::makeFakeQuantize(lastNode, ngraph::element::f32, 256, fqShape); + auto fqShape = ov::Shape(lastNode->get_output_partial_shape(0).size(), 1); + lastNode = ngraph::builder::makeFakeQuantize(lastNode, ov::element::f32, 256, fqShape); additionalFusedOps.push_back("FakeQuantize"); - auto secondTerm = ngraph::builder::makeFakeQuantize(inputParams[1], ngraph::element::f32, 256, fqShape); + auto secondTerm = ngraph::builder::makeFakeQuantize(inputParams[1], ov::element::f32, 256, fqShape); - auto sum = std::make_shared(lastNode, secondTerm); + auto sum = std::make_shared(lastNode, secondTerm); additionalFusedOps.push_back("Add"); fusedOps.insert(fusedOps.begin(), additionalFusedOps.begin(), additionalFusedOps.end()); @@ -241,12 +248,10 @@ class ConvSumInPlaceTestInt8 : public ConvSumInPlaceTest { void SetUp() override { abs_threshold = 1.001f; - using ngraph::pass::ConvertPrecision; ConvSumInPlaceTest::SetUp(); functionRefs = function->clone(); - ngraph::pass::ConvertPrecision().run_on_model(functionRefs); - ngraph::pass::ConvertPrecision().run_on_model(functionRefs); - functionRefs->validate_nodes_and_infer_types(); + convert_precisions.insert({ov::element::i8, ov::element::f32}); + convert_precisions.insert({ov::element::u8, ov::element::f32}); } }; @@ -258,12 +263,12 @@ TEST_P(ConvSumInPlaceTestInt8, CompareWithRefs) { class ConvSumInPlaceTestSeveralConsumers : public ConvSumInPlaceTest { public: - std::shared_ptr addSum(std::shared_ptr lastNode, const ngraph::ParameterVector& inputParams) override { - auto sum = std::make_shared(lastNode, inputParams[1]); + std::shared_ptr addSum(std::shared_ptr lastNode, const ov::ParameterVector& inputParams) override { + auto sum = std::make_shared(lastNode, inputParams[1]); fusedOps.insert(fusedOps.begin(), "Add"); - auto shapeOf = std::make_shared(sum); - return std::make_shared(sum, shapeOf, true); + auto shapeOf = std::make_shared(sum); + return std::make_shared(sum, shapeOf, true); } }; @@ -278,70 +283,70 @@ TEST_P(ConvSumInPlaceTestSeveralConsumers, CompareWithRefs) { namespace { const auto fusingMulAddFQMullAdd = fusingSpecificParams{ std::make_shared(std::vector{ {[](postNodeConfig& cfg) { - ngraph::Shape newShape = generatePerChannelShape(cfg.input); + ov::Shape newShape = generatePerChannelShape(cfg.input); auto constNode = ngraph::builder::makeConstant(cfg.type, newShape, std::vector{}, true); - return std::make_shared(cfg.input, constNode); + return std::make_shared(cfg.input, constNode); }, "Multiply(PerChannel)"}, {[](postNodeConfig& cfg) { - ngraph::Shape newShape = generatePerChannelShape(cfg.input); + ov::Shape newShape = generatePerChannelShape(cfg.input); auto constNode = ngraph::builder::makeConstant(cfg.type, newShape, std::vector{}, true); - return std::make_shared(cfg.input, constNode); + return std::make_shared(cfg.input, constNode); }, "Add(PerChannel)"}, {[](postNodeConfig& cfg){ auto localPrc = cfg.input->get_element_type(); - ngraph::Shape newShape = generatePerChannelShape(cfg.input); + ov::Shape newShape = generatePerChannelShape(cfg.input); return ngraph::builder::makeFakeQuantize(cfg.input, localPrc, 256, newShape); }, "FakeQuantize(PerChannel)"}, {[](postNodeConfig& cfg) { - ngraph::Shape newShape = generatePerChannelShape(cfg.input); + ov::Shape newShape = generatePerChannelShape(cfg.input); auto constNode = ngraph::builder::makeConstant(cfg.type, newShape, std::vector{}, true); - return std::make_shared(cfg.input, constNode); + return std::make_shared(cfg.input, constNode); }, "Multiply(PerChannel)"}, {[](postNodeConfig& cfg) { - ngraph::Shape newShape = generatePerChannelShape(cfg.input); + ov::Shape newShape = generatePerChannelShape(cfg.input); auto constNode = ngraph::builder::makeConstant(cfg.type, newShape, std::vector{}, true); - return std::make_shared(cfg.input, constNode); + return std::make_shared(cfg.input, constNode); }, "Add(PerChannel)"}}), {"Add"} }; const auto fusingDivSubFQ = fusingSpecificParams{ std::make_shared(std::vector{ {[](postNodeConfig& cfg){ - ngraph::Shape secondMultInShape = generatePerChannelShape(cfg.input); + ov::Shape secondMultInShape = generatePerChannelShape(cfg.input); auto secondMultInput = ngraph::builder::makeConstant(cfg.type, secondMultInShape, std::vector{}, true); - return std::make_shared(cfg.input, secondMultInput); + return std::make_shared(cfg.input, secondMultInput); }, "Divide(PerChannel)"}, {[](postNodeConfig& cfg){ - ngraph::Shape secondMultInShape = generatePerChannelShape(cfg.input); + ov::Shape secondMultInShape = generatePerChannelShape(cfg.input); auto secondMultInput = ngraph::builder::makeConstant(cfg.type, secondMultInShape, std::vector{}, true); - return std::make_shared(cfg.input, secondMultInput); + return std::make_shared(cfg.input, secondMultInput); }, "Subtract(PerChannel)"}, {[](postNodeConfig& cfg){ auto localPrc = cfg.input->get_element_type(); - ngraph::Shape newShape = generatePerChannelShape(cfg.input); + ov::Shape newShape = generatePerChannelShape(cfg.input); return ngraph::builder::makeFakeQuantize(cfg.input, localPrc, 256, newShape); }, "FakeQuantize(PerChannel)"}}), {"FakeQuantize"} }; const auto fusingSigmoidFQFQ = fusingSpecificParams{ std::make_shared(std::vector{ {[](postNodeConfig& cfg){ - return ngraph::builder::makeActivation(cfg.input, cfg.type, ngraph::helpers::Sigmoid); + return ov::test::utils::make_activation(cfg.input, cfg.type, ov::test::utils::Sigmoid); }, "Sigmoid"}, {[](postNodeConfig& cfg){ auto localPrc = cfg.input->get_element_type(); - ngraph::Shape newShape = generatePerChannelShape(cfg.input); + ov::Shape newShape = generatePerChannelShape(cfg.input); return ngraph::builder::makeFakeQuantize(cfg.input, localPrc, 256, newShape); }, "FakeQuantize(PerChannel)"}, {[](postNodeConfig& cfg){ auto localPrc = cfg.input->get_element_type(); - ngraph::Shape newShape = generatePerChannelShape(cfg.input); + ov::Shape newShape = generatePerChannelShape(cfg.input); return ngraph::builder::makeFakeQuantize(cfg.input, localPrc, 256, newShape); }, "FakeQuantize(PerChannel)"}}), {"Sigmoid", "FakeQuantize", "FakeQuantize"} }; const auto fusingClampFQ = fusingSpecificParams{ std::make_shared(std::vector{ {[](postNodeConfig& cfg){ - return ngraph::builder::makeActivation(cfg.input, cfg.type, ngraph::helpers::Clamp, {}, {3.0f, 6.0f}); + return ov::test::utils::make_activation(cfg.input, cfg.type, ov::test::utils::Clamp, {}, {3.0f, 6.0f}); }, "Clamp"}, {[](postNodeConfig& cfg){ auto localPrc = cfg.input->get_element_type(); - ngraph::Shape newShape = generatePerChannelShape(cfg.input); + ov::Shape newShape = generatePerChannelShape(cfg.input); return ngraph::builder::makeFakeQuantize(cfg.input, localPrc, 256, newShape); }, "FakeQuantize(PerChannel)"}}), {"FakeQuantize"} }; @@ -403,16 +408,16 @@ INSTANTIATE_TEST_SUITE_P(smoke_Conv_Sum_Broadcast_FP32, ConvSumInPlaceTest, ::testing::ValuesIn(secondInp), ::testing::Values(true, false), ::testing::ValuesIn(fusingParamsSet), - ::testing::Values(cpuEmptyPluginConfig)), + ::testing::Values(empty_plugin_config)), ConvSumInPlaceTest::getTestCaseName); -INSTANTIATE_TEST_SUITE_P(smoke_Conv_Sum_Broadcast_BF16, ConvSumInPlaceTest, - ::testing::Combine( - ::testing::Values(convInpShape), - ::testing::ValuesIn(secondInp), - ::testing::Values(true, false), - ::testing::ValuesIn(fusingParamsSetBF16), - ::testing::Values(cpuBF16PluginConfig)), +INSTANTIATE_TEST_SUITE_P(smoke_Conv_Sum_Broadcast_BF16, + ConvSumInPlaceTest, + ::testing::Combine(::testing::Values(convInpShape), + ::testing::ValuesIn(secondInp), + ::testing::Values(true, false), + ::testing::ValuesIn(fusingParamsSetBF16), + ::testing::Values(cpu_bf16_plugin_config)), ConvSumInPlaceTest::getTestCaseName); INSTANTIATE_TEST_SUITE_P(smoke_Conv_Sum_Broadcast_INT8, ConvSumInPlaceTestInt8, @@ -421,7 +426,7 @@ INSTANTIATE_TEST_SUITE_P(smoke_Conv_Sum_Broadcast_INT8, ConvSumInPlaceTestInt8, ::testing::ValuesIn(secondInp), ::testing::Values(true, false), ::testing::ValuesIn(fusingParamsSet), - ::testing::Values(cpuEmptyPluginConfig)), + ::testing::Values(empty_plugin_config)), ConvSumInPlaceTest::getTestCaseName); INSTANTIATE_TEST_SUITE_P(smoke_Conv_Sum_Broadcast_Several_Consumers, ConvSumInPlaceTestSeveralConsumers, @@ -430,7 +435,7 @@ INSTANTIATE_TEST_SUITE_P(smoke_Conv_Sum_Broadcast_Several_Consumers, ConvSumInPl ::testing::ValuesIn(secondInp), ::testing::Values(true), ::testing::Values(emptyFusingSpec), - ::testing::Values(cpuEmptyPluginConfig)), + ::testing::Values(empty_plugin_config)), ConvSumInPlaceTest::getTestCaseName); InputShape convInpShapeStrided = { @@ -457,8 +462,9 @@ INSTANTIATE_TEST_SUITE_P(smoke_Conv_Sum_Broadcast_Strided, ConvSumInPlaceStrided ::testing::Values(secondInpStrided), ::testing::Values(true), ::testing::Values(emptyFusingSpec), - ::testing::Values(cpuEmptyPluginConfig)), + ::testing::Values(empty_plugin_config)), ConvSumInPlaceTest::getTestCaseName); } // namespace -} // namespace SubgraphTestsDefinitions +} // namespace test +} // namespace ov 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/subgraph_tests/src/conv_with_zero_point_fuse.cpp index 9832fa0ac18551..f4cf62baea49ab 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/conv_with_zero_point_fuse.cpp +++ b/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/conv_with_zero_point_fuse.cpp @@ -52,7 +52,7 @@ void ConvWithZeroPointFuseSubgraphTest::SetUp() { {-12.8f}, {12.7f}); - std::vector> branches(2); + std::vector> branches(2); { ov::Strides strides{1, 1}; ov::Shape pads_begin{0, 0}, pads_end{0, 0}, kernel{1, 1}; 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/subgraph_tests/src/convert_fq_rnn_to_quantized_rnn.cpp index 43c793230ac85a..ff464d1774d41e 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/subgraph_tests/src/convert_fq_rnn_to_quantized_rnn.cpp @@ -2,31 +2,25 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "ngraph/output_vector.hpp" -#include "ngraph/type/element_type.hpp" +#include "common_test_utils/common_utils.hpp" +#include "common_test_utils/ov_tensor_utils.hpp" #include "openvino/core/node.hpp" #include "openvino/core/type/element_type.hpp" -#include "openvino/op/gru_sequence.hpp" -#include "openvino/op/lstm_sequence.hpp" #include "openvino/runtime/tensor.hpp" -#include "test_utils/cpu_test_utils.hpp" +#include "ov_models/builders.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" +#include "test_utils/cpu_test_utils.hpp" #include "test_utils/fusing_test_utils.hpp" -#include "ov_models/builders.hpp" -#include "common_test_utils/common_utils.hpp" -#include #include #include #include #include -using namespace InferenceEngine; using namespace CPUTestUtils; -using namespace ov::test; -using namespace ov; -namespace SubgraphTestsDefinitions { +namespace ov { +namespace test { using ConvertFqRnnToQuantizedRnnTestParams = std::tuple, bool>; @@ -68,7 +62,7 @@ class ConvertFqRnnToQuantizedRnn : public testing::WithParamInterface& targetInputStaticShapes) override { + void generate_inputs(const std::vector& targetInputStaticShapes) override { inputs.clear(); const auto& funcInputs = function->inputs(); @@ -116,9 +110,9 @@ class ConvertFqRnnToQuantizedRnn : public testing::WithParamInterface(ngPrec, shape)); - auto makeDataFQ = [](const ngraph::Output& input) { + auto makeDataFQ = [](const ov::Output& input) { const auto fqLevels = 256; - return ngraph::builder::makeFakeQuantize(input, ngraph::element::f32, fqLevels, {}, + return ngraph::builder::makeFakeQuantize(input, ov::element::f32, fqLevels, {}, {-128.f/127}, {1.f}, {-128.f/127}, {1.f}); }; @@ -128,16 +122,16 @@ class ConvertFqRnnToQuantizedRnn : public testing::WithParamInterface weight) { const auto fqLevelsW = 255; - return ngraph::builder::makeFakeQuantize(weight, ngraph::element::f32, + return ngraph::builder::makeFakeQuantize(weight, ov::element::f32, fqLevelsW, std::vector{}, {-127.f/63}, {127.f/63}, {-127.f/63}, {127.f/63}); @@ -152,7 +146,7 @@ class ConvertFqRnnToQuantizedRnn : public testing::WithParamInterface lengths(batchSize, static_cast(maxSeqLen)); - auto seq_lengths = ngraph::opset1::Constant::create(element::i64, Shape{batchSize}, lengths); + auto seq_lengths = ov::op::v0::Constant::create(element::i64, Shape{batchSize}, lengths); if (rnnType == "LSTMSequence") { hasCell = true; @@ -215,4 +209,5 @@ INSTANTIATE_TEST_SUITE_P(smoke_static, ConvertFqRnnToQuantizedRnn, ConvertFqRnnToQuantizedRnn::getTestCaseName); } // namespace -} // namespace SubgraphTestsDefinitions +} // namespace test +} // namespace ov diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/convert_range.cpp b/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/convert_range.cpp index 86a0e2323dbfc4..f67cc147e6d1a3 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/convert_range.cpp +++ b/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/convert_range.cpp @@ -9,10 +9,9 @@ #include using namespace CPUTestUtils; -using namespace InferenceEngine; -using namespace ov::test; -namespace SubgraphTestsDefinitions { +namespace ov { +namespace test { /* This test runs the following subgraph: @@ -149,4 +148,5 @@ INSTANTIATE_TEST_SUITE_P(smoke_ConvertRangeSubgraphCPUTest, ConvertRangeSubgraphCPUTest::getTestCaseName); } // namespace -} // namespace SubgraphTestsDefinitions +} // namespace test +} // namespace ov 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/subgraph_tests/src/custom_op_insert_convert_i64.cpp index 518676a15e63b3..9ca6af1f8d96f0 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/custom_op_insert_convert_i64.cpp +++ b/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/custom_op_insert_convert_i64.cpp @@ -11,7 +11,8 @@ using namespace ov::test; using namespace CPUTestUtils; -namespace CPULayerTestsDefinitions { +namespace ov { +namespace test { using CustomOpI64CPUTestParams = std::tuple; class CustomOpI64 : public ov::op::Op { @@ -151,4 +152,5 @@ INSTANTIATE_TEST_SUITE_P(smoke_CustomOp, ::testing::Combine(::testing::Values(ElementType::i32), ::testing::Values(inputShapes)), CustomOpConvertI64CPUTest::getTestCaseName); -} // namespace CPULayerTestsDefinitions +} // namespace test +} // namespace ov diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/custom_op_scalar.cpp b/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/custom_op_scalar.cpp index c108d067a47311..4b6b237886ade3 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/custom_op_scalar.cpp +++ b/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/custom_op_scalar.cpp @@ -2,15 +2,15 @@ // SPDX-License-Identifier: Apache-2.0 // -#include -#include -#include +#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" using namespace CPUTestUtils; -using namespace ov::test; -namespace CPULayerTestsDefinitions { +namespace ov { +namespace test { using CustomOpScalarCPUTestParams = std::tuple; @@ -149,4 +149,5 @@ INSTANTIATE_TEST_SUITE_P(smoke_CustomOp, ::testing::Combine(::testing::Values(ElementType::u8), ::testing::ValuesIn(inputShapes)), CustomOpScalarCPUTest::getTestCaseName); -} // namespace CPULayerTestsDefinitions +} // namespace test +} // namespace ov diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/denormal_check.cpp b/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/denormal_check.cpp index 5b9e5ae550c236..2c68b14cb41508 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/denormal_check.cpp +++ b/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/denormal_check.cpp @@ -8,9 +8,8 @@ #include "ov_models/builders.hpp" #include "ngraph/runtime/aligned_buffer.hpp" -using namespace InferenceEngine; -using namespace ov::test; -namespace SubgraphTestsDefinitions { +namespace ov { +namespace test { template class AlignedBufferWrapper { @@ -67,13 +66,13 @@ void SetUp() override { pConstStorage.reset(new AlignedBufferWrapper(elemsCount, alignment)); auto constTensor = std::make_shared(rtPrc, inpShape, pConstStorage->get_ptr()); - auto constNode = std::make_shared(constTensor); + auto constNode = std::make_shared(constTensor); ov::NodeVector input = {params[0], constNode}; - auto concat = std::make_shared(input, 1); + auto concat = std::make_shared(input, 1); - ov::ResultVector results{std::make_shared(concat->output(0))}; + ov::ResultVector results{std::make_shared(concat->output(0))}; - function = std::make_shared(results, params, "denormal_check"); + function = std::make_shared(results, params, "denormal_check"); } }; @@ -110,4 +109,5 @@ TEST_F(DenormalNullifyCheck, smoke_CPU_Denormal_Check) { } } -}// namespace SubgraphTestsDefinitions +} // namespace test +} // namespace ov diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/eltwise_caching.cpp b/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/eltwise_caching.cpp index d5f5f3ead3cac9..487235fa8dd15b 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/eltwise_caching.cpp +++ b/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/eltwise_caching.cpp @@ -32,23 +32,23 @@ // |output| // -------- -#include -#include -#include -#include -#include -#include -#include #include "common_test_utils/common_utils.hpp" -#include -#include "functional_test_utils/skip_tests_config.hpp" +#include "common_test_utils/node_builders/eltwise.hpp" +#include "common_test_utils/ov_tensor_utils.hpp" +#include "ov_models/builders.hpp" +#include "shared_test_classes/base/ov_subgraph.hpp" #include "test_utils/cpu_test_utils.hpp" +#include +#include +#include +#include + using namespace CPUTestUtils; -using ngraph::helpers::EltwiseTypes; -using namespace ov::test; -namespace CPUSubgraphTestsDefinitions { +namespace ov { +namespace test { +using namespace ov::test::utils; using InputShapesTuple = std::tuple< std::vector, // eltwise input shapes @@ -122,7 +122,7 @@ class EltwiseCacheTest : public testing::WithParamInterface& targetInputStaticShapes) override { + void generate_inputs(const std::vector& targetInputStaticShapes) override { inputs.clear(); const auto& funcInputs = function->inputs(); for (size_t i = 0; i < funcInputs.size(); ++i) { @@ -155,31 +155,31 @@ class EltwiseCacheTest : public testing::WithParamInterface> ngraphInputs; + ov::ParameterVector paramVec; + std::vector> inputNodes; for (size_t i = 0; i < inputDynamicShapes.size(); i++) { - ngraphParam.push_back(std::make_shared(inputPrecisions[i], inputDynamicShapes[i])); - ngraphInputs.push_back(ngraphParam.back()); + paramVec.push_back(std::make_shared(inputPrecisions[i], inputDynamicShapes[i])); + inputNodes.push_back(paramVec.back()); } - auto lastNode0 = ngraph::builder::makeEltwise(ngraphParam[0], ngraphParam[1], eltwiseOpTypes[0]); + auto lastNode0 = utils::makeEltwise(paramVec[0], paramVec[1], eltwiseOpTypes[0]); lastNode0->get_rt_info() = getCPUInfo(); - auto lastNode1 = ngraph::builder::makeEltwise(ngraphParam[2], ngraphParam[3], eltwiseOpTypes[1]); + auto lastNode1 = utils::makeEltwise(paramVec[2], paramVec[3], eltwiseOpTypes[1]); lastNode1->get_rt_info() = getCPUInfo(); if (withQuantization) { - lastNode0 = ngraph::builder::makeFakeQuantize(lastNode0, ::ngraph::element::Type(::ngraph::element::Type_t::f32), + lastNode0 = ngraph::builder::makeFakeQuantize(lastNode0, ov::element::Type(ov::element::Type_t::f32), 256, fqInputShapes[0]); - lastNode1 = ngraph::builder::makeFakeQuantize(lastNode1, ::ngraph::element::Type(::ngraph::element::Type_t::f32), + lastNode1 = ngraph::builder::makeFakeQuantize(lastNode1, ov::element::Type(ov::element::Type_t::f32), 256, fqInputShapes[1]); } if (needReshape) { - auto reshapeConstNode = ngraph::builder::makeConstant(::ngraph::element::Type(::ngraph::element::Type_t::i32), + auto reshapeConstNode = ngraph::builder::makeConstant(ov::element::Type(ov::element::Type_t::i32), {reshapeShape.size()}, reshapeShape); - lastNode1 = std::make_shared(lastNode1, reshapeConstNode, false); + lastNode1 = std::make_shared(lastNode1, reshapeConstNode, false); } auto concat = std::make_shared(ov::NodeVector{lastNode0, lastNode1}, 0); - function = std::make_shared(concat, ngraphParam, "eltwise_cache"); + function = std::make_shared(concat, paramVec, "eltwise_cache"); } }; @@ -1328,5 +1328,6 @@ INSTANTIATE_TEST_SUITE_P(smoke_EltwiseCache_7D_dyn, EltwiseCacheTest, ::testing::Values(cpuParams_empty)), EltwiseCacheTest::getTestCaseName); -} // namespace -} // namespace CPUSubgraphTestsDefinitions +} // namespace +} // namespace test +} // namespace ov \ No newline at end of file diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/eltwise_chain.cpp b/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/eltwise_chain.cpp index ef20c4ffd0518d..b4bff5634bcac6 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/eltwise_chain.cpp +++ b/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/eltwise_chain.cpp @@ -6,35 +6,36 @@ #include #include #include -#include -#include -#include + +#include "shared_test_classes/base/ov_subgraph.hpp" +#include "ov_models/builders.hpp" #include "common_test_utils/common_utils.hpp" -#include -#include "functional_test_utils/skip_tests_config.hpp" +#include "common_test_utils/ov_tensor_utils.hpp" #include "test_utils/cpu_test_utils.hpp" +#include "common_test_utils/node_builders/eltwise.hpp" using namespace CPUTestUtils; -using ngraph::helpers::EltwiseTypes; -using namespace ov::test; -namespace CPUSubgraphTestsDefinitions { -typedef std::tuple< - std::vector, // Input shapes - ngraph::helpers::InputLayerType, // Secondary input type - std::vector, // Input precisions - std::vector, // Eltwise operations - bool, // With quantization - std::string // Device name -> EltwiseChainTuple; +namespace ov { +namespace test { +using namespace ov::test::utils; + +typedef std::tuple, // Input shapes + InputLayerType, // Secondary input type + std::vector, // Input precisions + std::vector, // Eltwise operations + bool, // With quantization + std::string // Device name + > + EltwiseChainTuple; class EltwiseChainTest : public testing::WithParamInterface, virtual public SubgraphBaseTest { public: static std::string getTestCaseName(const testing::TestParamInfo &obj) { std::vector inputShapes; - ngraph::helpers::InputLayerType secondaryInputType; + InputLayerType secondaryInputType; std::vector inputPrecisions; std::vector eltwiseOpTypes; bool withQuantization; @@ -65,7 +66,7 @@ class EltwiseChainTest : public testing::WithParamInterface, return results.str(); } - void generate_inputs(const std::vector& targetInputStaticShapes) override { + void generate_inputs(const std::vector& targetInputStaticShapes) override { inputs.clear(); const auto& funcInputs = function->inputs(); for (size_t i = 0; i < funcInputs.size(); ++i) { @@ -81,7 +82,7 @@ class EltwiseChainTest : public testing::WithParamInterface, abs_threshold = 0.1f; std::vector inputShapes; - ngraph::helpers::InputLayerType secondaryInputType; + InputLayerType secondaryInputType; std::vector inputPrecisions; std::vector eltwiseOpTypes; bool withQuantization; @@ -89,27 +90,27 @@ class EltwiseChainTest : public testing::WithParamInterface, init_input_shapes(inputShapes); - ngraph::ParameterVector ngraphParam; - std::vector> ngraphInputs; + ov::ParameterVector paramVec; + std::vector> inputNodes; if (secondaryInputType == ngraph::helpers::InputLayerType::PARAMETER) { for (size_t i = 0; i < inputDynamicShapes.size(); i++) { - ngraphParam.push_back(std::make_shared(inputPrecisions[i], inputDynamicShapes[i])); - ngraphInputs.push_back(ngraphParam.back()); + paramVec.push_back(std::make_shared(inputPrecisions[i], inputDynamicShapes[i])); + inputNodes.push_back(paramVec.back()); } } else { - ngraphParam = ov::ParameterVector {std::make_shared(inputPrecisions[0], inputDynamicShapes.front())}; + paramVec = ov::ParameterVector {std::make_shared(inputPrecisions[0], inputDynamicShapes.front())}; for (size_t i = 1; i < inputPrecisions.size(); i++) { - std::vector ngraphInput1Data(ngraph::shape_size(targetStaticShapes[0][i])); - ngraphInputs.push_back(ngraph::builder::makeConstant(inputPrecisions[i], targetStaticShapes[0][i], - ngraphInput1Data, true)); + std::vector input1Data(ov::shape_size(targetStaticShapes[0][i])); + inputNodes.push_back( + ngraph::builder::makeConstant(inputPrecisions[i], targetStaticShapes[0][i], input1Data, true)); } } if (withQuantization) { - std::vector> eltwiseOps; - eltwiseOps.push_back(ngraph::builder::makeEltwise(ngraphParam[0], ngraphInputs[0], eltwiseOpTypes[0])); + std::vector> eltwiseOps; + eltwiseOps.push_back(makeEltwise(paramVec[0], inputNodes[0], eltwiseOpTypes[0])); for (size_t i = 1; i < eltwiseOpTypes.size() - 1; i++) { - eltwiseOps.push_back(ngraph::builder::makeEltwise(eltwiseOps[eltwiseOps.size() - 1], ngraphInputs[i], eltwiseOpTypes[i])); + eltwiseOps.push_back(makeEltwise(eltwiseOps[eltwiseOps.size() - 1], inputNodes[i], eltwiseOpTypes[i])); } std::vector constShape(targetStaticShapes[0][0].size(), 1); @@ -118,19 +119,19 @@ class EltwiseChainTest : public testing::WithParamInterface, ::ngraph::element::Type(::ngraph::element::Type_t::f32), 256, constShape); - eltwiseOps.push_back(ngraph::builder::makeEltwise(fq, ngraphInputs[eltwiseOpTypes.size() - 1], eltwiseOpTypes[eltwiseOpTypes.size() - 1])); + eltwiseOps.push_back(makeEltwise(fq, inputNodes[eltwiseOpTypes.size() - 1], eltwiseOpTypes[eltwiseOpTypes.size() - 1])); - ngraph::ResultVector results{std::make_shared(eltwiseOps[eltwiseOps.size() - 1])}; - function = std::make_shared(results, ngraphParam, "eltwise_chain_fq"); + ov::ResultVector results{std::make_shared(eltwiseOps[eltwiseOps.size() - 1])}; + function = std::make_shared(results, paramVec, "eltwise_chain_fq"); } else { - std::vector> eltwiseOps; - eltwiseOps.push_back(ngraph::builder::makeEltwise(ngraphParam[0], ngraphInputs[0], eltwiseOpTypes[0])); + std::vector> eltwiseOps; + eltwiseOps.push_back(makeEltwise(paramVec[0], inputNodes[0], eltwiseOpTypes[0])); for (size_t i = 1; i < eltwiseOpTypes.size(); i++) { - eltwiseOps.push_back(ngraph::builder::makeEltwise(eltwiseOps[eltwiseOps.size() - 1], ngraphInputs[i], eltwiseOpTypes[i])); + eltwiseOps.push_back(makeEltwise(eltwiseOps[eltwiseOps.size() - 1], inputNodes[i], eltwiseOpTypes[i])); } - ngraph::ResultVector results{std::make_shared(eltwiseOps[eltwiseOps.size() - 1])}; - function = std::make_shared(results, ngraphParam, "eltwise_chain"); + ov::ResultVector results{std::make_shared(eltwiseOps[eltwiseOps.size() - 1])}; + function = std::make_shared(results, paramVec, "eltwise_chain"); } } }; @@ -141,7 +142,7 @@ TEST_P(EltwiseChainTest, CompareWithRefs) { namespace { -std::vector> inputShapes = { +std::vector> inputShapes = { {{1, 1, 2, 3}, {1, 1, 2, 3}, {1, 1, 2, 3}, {1, 1, 2, 3}}, {{1, 48, 5, 6}, {1, 48, 1, 1}, {1, 48, 5, 6}, {1, 1, 5, 6}}, {{1, 72, 28, 28}, {1, 72, 1, 1}, {1, 72, 1, 1}, {1, 72, 1, 1}}, @@ -166,14 +167,14 @@ std::vector> eltwiseOps = { INSTANTIATE_TEST_SUITE_P(smoke_EltwiseChain, EltwiseChainTest, ::testing::Combine( ::testing::ValuesIn(static_shapes_to_test_representation(inputShapes)), - ::testing::Values(ngraph::helpers::InputLayerType::CONSTANT), + ::testing::Values(InputLayerType::CONSTANT), ::testing::ValuesIn(inputPrecisions), ::testing::ValuesIn(eltwiseOps), ::testing::Values(false), ::testing::Values(ov::test::utils::DEVICE_CPU)), EltwiseChainTest::getTestCaseName); -std::vector> inputShapesFQ = { +std::vector> inputShapesFQ = { {{1, 2, 2, 3}, {1, 2, 2, 3}, {1, 2, 2, 3}, {1, 2, 2, 3}}, {{2, 33, 5, 5}, {2, 33, 5, 5}, {2, 33, 1, 5}, {2, 33, 5, 5}}, {{2, 33, 5, 17}, {2, 33, 5, 17}, {2, 33, 5, 17}, {2, 33, 5, 17}}, @@ -197,7 +198,7 @@ std::vector> inputPrecisionsFQ { INSTANTIATE_TEST_SUITE_P(smoke_EltwiseChainWithFQ, EltwiseChainTest, ::testing::Combine( ::testing::ValuesIn(static_shapes_to_test_representation(inputShapesFQ)), - ::testing::Values(ngraph::helpers::InputLayerType::CONSTANT), + ::testing::Values(InputLayerType::CONSTANT), ::testing::ValuesIn(inputPrecisionsFQ), ::testing::ValuesIn(eltwiseOps), ::testing::Values(true), @@ -455,12 +456,13 @@ std::vector> inputShapes_dyn = { INSTANTIATE_TEST_SUITE_P(smoke_EltwiseChain_dyn, EltwiseChainTest, ::testing::Combine( ::testing::ValuesIn(inputShapes_dyn), - ::testing::Values(ngraph::helpers::InputLayerType::PARAMETER), + ::testing::Values(InputLayerType::PARAMETER), ::testing::ValuesIn(inputPrecisions), ::testing::ValuesIn(eltwiseOps), ::testing::Values(false), ::testing::Values(ov::test::utils::DEVICE_CPU)), EltwiseChainTest::getTestCaseName); -} // namespace -} // namespace CPUSubgraphTestsDefinitions +} // namespace +} // namespace test +} // namespace ov diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/gather_add_avgpool.cpp b/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/gather_add_avgpool.cpp index f145b2a0586659..cc9a325ae1f72c 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/gather_add_avgpool.cpp +++ b/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/gather_add_avgpool.cpp @@ -2,12 +2,13 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "shared_test_classes/base/layer_test_utils.hpp" #include -#include +#include "openvino/runtime/exec_model_info.hpp" +#include "shared_test_classes/base/ov_subgraph.hpp" -namespace SubgraphTestsDefinitions { +namespace ov { +namespace test { using namespace ngraph; @@ -25,30 +26,33 @@ using namespace ngraph; input's precision if its child has Subgraph consumers. Same scenario happens when we have Eltwise instead of Subgraph - to be addressed in #78939. */ -class GatherAddAvgpool : virtual public LayerTestsUtils::LayerTestsCommon { +class GatherAddAvgpool : virtual public SubgraphBaseStaticTest { protected: void SetUp() override { targetDevice = ov::test::utils::DEVICE_CPU; - inPrc = InferenceEngine::Precision::U8; - outPrc = InferenceEngine::Precision::FP32; - auto type = element::f32; - auto param = std::make_shared(type, Shape{1, 3, 64, 64}); - auto gather = std::make_shared(param, - op::Constant::create(element::i32, Shape{3}, {2, 1, 0}), - op::Constant::create(element::i32, Shape{1}, {1})); - auto add = std::make_shared(gather, op::Constant::create(type, Shape{1, 3, 1, 1}, {3})); - auto avgpool = std::make_shared(add, Strides{1, 1}, Shape{0, 0}, Shape{0, 0}, Shape{2, 2}, false); - function = std::make_shared(avgpool, ParameterVector{param}); + inType = ov::element::u8; + outType = ov::element::f32; + auto type = ov::element::f32; + auto param = std::make_shared(type, Shape{1, 3, 64, 64}); + auto gather = + std::make_shared(param, + ov::op::v0::Constant::create(element::i32, Shape{3}, {2, 1, 0}), + ov::op::v0::Constant::create(element::i32, Shape{1}, {1})); + auto add = + std::make_shared(gather, ov::op::v0::Constant::create(type, Shape{1, 3, 1, 1}, {3})); + auto avgpool = + std::make_shared(add, Strides{1, 1}, Shape{0, 0}, Shape{0, 0}, Shape{2, 2}, false); + function = std::make_shared(avgpool, ov::ParameterVector{param}); } void TearDown() override { - auto exec_model = executableNetwork.GetExecGraphInfo().getFunction(); + auto exec_model = compiledModel.get_runtime_model(); int eltwise_nodes_found = 0; int pool_nodes_found = 0; for (const auto& n : exec_model->get_ordered_ops()) { - auto layer_type = n->get_rt_info().at(ExecGraphInfoSerialization::LAYER_TYPE).as(); - auto output_layout = n->get_rt_info().at(ExecGraphInfoSerialization::OUTPUT_LAYOUTS).as(); + auto layer_type = n->get_rt_info().at(ov::exec_model_info::LAYER_TYPE).as(); + auto output_layout = n->get_rt_info().at(ov::exec_model_info::OUTPUT_LAYOUTS).as(); if (layer_type == "Subgraph") { eltwise_nodes_found++; ASSERT_EQ("abcd", output_layout); @@ -63,7 +67,8 @@ class GatherAddAvgpool : virtual public LayerTestsUtils::LayerTestsCommon { }; TEST_F(GatherAddAvgpool, smoke_CompareWithRefs) { - Run(); + run(); } -} // namespace SubgraphTestsDefinitions +} // namespace test +} // namespace ov diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/inplace_edge.cpp b/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/inplace_edge.cpp index 1385313ce88d41..7d5c1ebb8a9e2b 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/inplace_edge.cpp +++ b/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/inplace_edge.cpp @@ -2,16 +2,13 @@ // SPDX-License-Identifier: Apache-2.0 // -#include +#include "common_test_utils/node_builders/eltwise.hpp" +#include "shared_test_classes/base/ov_subgraph.hpp" #include "test_utils/cpu_test_utils.hpp" -#include "shared_test_classes/base/layer_test_utils.hpp" -#include "ov_models/utils/ov_helpers.hpp" -#include "ov_models/builders.hpp" using namespace CPUTestUtils; -using namespace InferenceEngine; - -namespace SubgraphTestsDefinitions { +namespace ov { +namespace test { // If a node (CumSum) with constant parents has several non-constant nodes (Eltwises) than the edge is broken. // The fix is to check node type - is should be Input. // Subgraph: @@ -24,16 +21,13 @@ namespace SubgraphTestsDefinitions { * \ / \ / * \ / \ / * Eltwise Eltwise - * \ / + * \ / * Eltwise * | * Result */ -using namespace ov::test; - -class NonInputInPlaceTest : public testing::WithParamInterface, - virtual public SubgraphBaseTest { +class NonInputInPlaceTest : public testing::WithParamInterface, virtual public SubgraphBaseTest { public: static std::string getTestCaseName(testing::TestParamInfo obj) { std::ostringstream result; @@ -44,34 +38,36 @@ class NonInputInPlaceTest : public testing::WithParamInterface, void SetUp() override { targetDevice = utils::DEVICE_CPU; configuration.insert({ov::hint::inference_precision.name(), ov::element::f16.to_string()}); - const std::vector inputShape = {1, 11, 3, 3}; + const ov::Shape inputShape = {1, 11, 3, 3}; targetStaticShapes = {{inputShape, inputShape}}; ElementType prc = this->GetParam(); - ov::ParameterVector inputParams {std::make_shared(prc, ov::Shape(inputShape)), - std::make_shared(prc, ov::Shape(inputShape))}; + ov::ParameterVector inputParams{std::make_shared(prc, ov::Shape(inputShape)), + std::make_shared(prc, ov::Shape(inputShape))}; - auto cumsum_tensor = ngraph::opset8::Constant::create(prc, inputShape, {10.0f}); - auto axis_node = ngraph::opset8::Constant::create(ngraph::element::i32, {}, {0}); + auto cumsum_tensor = ov::op::v0::Constant::create(prc, inputShape, {10.0f}); + auto axis_node = ov::op::v0::Constant::create(ov::element::i32, {}, {0}); const auto cumsum = std::make_shared(cumsum_tensor, axis_node); - auto eltwiseMul = ngraph::builder::makeEltwise(inputParams[0], cumsum, ngraph::helpers::EltwiseTypes::MULTIPLY); - auto eltwiseAdd1 = ngraph::builder::makeEltwise(inputParams[1], cumsum, ngraph::helpers::EltwiseTypes::ADD); - auto eltwiseAdd2 = ngraph::builder::makeEltwise(eltwiseAdd1, eltwiseMul, ngraph::helpers::EltwiseTypes::ADD); + auto eltwiseMul = ov::test::utils::makeEltwise(inputParams[0], cumsum, ov::test::utils::EltwiseTypes::MULTIPLY); + auto eltwiseAdd1 = ov::test::utils::makeEltwise(inputParams[1], cumsum, ov::test::utils::EltwiseTypes::ADD); + auto eltwiseAdd2 = ov::test::utils::makeEltwise(eltwiseAdd1, eltwiseMul, ov::test::utils::EltwiseTypes::ADD); - ngraph::ResultVector results{std::make_shared(eltwiseAdd2)}; - function = std::make_shared(results, inputParams, "NonInputInPlaceT"); + ov::ResultVector results{std::make_shared(eltwiseAdd2)}; + function = std::make_shared(results, inputParams, "NonInputInPlaceT"); } }; namespace { - TEST_P(NonInputInPlaceTest, CompareWithRefs) { - run(); - } +TEST_P(NonInputInPlaceTest, CompareWithRefs) { + run(); +} -INSTANTIATE_TEST_SUITE_P(smoke_NonInputInPlaceTest_CPU, NonInputInPlaceTest, - testing::Values(ngraph::element::f32, ngraph::element::f16), - NonInputInPlaceTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_NonInputInPlaceTest_CPU, + NonInputInPlaceTest, + testing::Values(ov::element::f32, ov::element::f16), + NonInputInPlaceTest::getTestCaseName); -} // namespace -} // namespace SubgraphTestsDefinitions +} // namespace +} // namespace test +} // 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/subgraph_tests/src/input_noreorder_eltwise_bf16.cpp index 8371c336bacff0..6579aacded8873 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/input_noreorder_eltwise_bf16.cpp +++ b/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/input_noreorder_eltwise_bf16.cpp @@ -2,39 +2,38 @@ // SPDX-License-Identifier: Apache-2.0 // -#include -#include "ie_common.h" +#include "common_test_utils/node_builders/eltwise.hpp" +#include "common_test_utils/ov_tensor_utils.hpp" +#include "ov_models/builders.hpp" #include "ov_models/utils/ov_helpers.hpp" +#include "shared_test_classes/base/ov_subgraph.hpp" #include "test_utils/cpu_test_utils.hpp" -#include "common_test_utils/ov_tensor_utils.hpp" -using namespace InferenceEngine; using namespace CPUTestUtils; -namespace CPULayerTestsDefinitions { +namespace ov { +namespace test { -class InputNoReorderEltwiseBF16 : virtual public LayerTestsUtils::LayerTestsCommon, - public CPUTestsBase { +class InputNoReorderEltwiseBF16 : virtual public SubgraphBaseStaticTest, public CPUTestsBase { protected: void SetUp() override { - auto netPrecision = inPrc = Precision::FP32; - outPrc = Precision::BF16; + auto netPrecision = inType = ov::element::f32; + outType = ov::element::bf16; targetDevice = ov::test::utils::DEVICE_CPU; - std::map additional_config{{PluginConfigParams::KEY_ENFORCE_BF16, PluginConfigParams::NO}}; + ov::AnyMap additional_config{ov::hint::inference_precision(ov::element::bf16)}; configuration.insert(additional_config.begin(), additional_config.end()); - std::vector inputShape {2, 4, 4, 1}; - auto eltwiseType = ngraph::helpers::EltwiseTypes::ADD; + ov::Shape inputShape{2, 4, 4, 1}; + auto eltwiseType = ov::test::utils::EltwiseTypes::ADD; - auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); - ov::ParameterVector input {std::make_shared(ngPrc, ov::Shape(inputShape))}; + ov::ParameterVector input{std::make_shared(netPrecision, inputShape)}; - auto tensor = ov::test::utils::create_and_fill_tensor(ngPrc, inputShape); + auto tensor = ov::test::utils::create_and_fill_tensor(netPrecision, inputShape); auto secondaryInput = std::make_shared(tensor); - auto eltwise = ngraph::builder::makeEltwise(input[0], secondaryInput, eltwiseType); + auto eltwise = ov::test::utils::makeEltwise(input[0], secondaryInput, eltwiseType); - function = makeNgraphFunction(ngPrc, input, eltwise, "Eltwise"); + function = makeNgraphFunction(netPrecision, input, eltwise, "Eltwise"); } }; @@ -53,10 +52,11 @@ class InputNoReorderEltwiseBF16 : virtual public LayerTestsUtils::LayerTestsComm Output[BF16] */ TEST_F(InputNoReorderEltwiseBF16, smoke_CompareWithRefs) { - Run(); + run(); - CheckNumberOfNodesWithType(executableNetwork, "Reorder", 0); - CheckNumberOfNodesWithType(executableNetwork, "Convert", 0); - CheckNumberOfNodesWithTypes(executableNetwork, {"Eltwise", "Subgraph"}, 1); + CheckNumberOfNodesWithType(compiledModel, "Reorder", 0); + CheckNumberOfNodesWithType(compiledModel, "Convert", 0); + CheckNumberOfNodesWithTypes(compiledModel, {"Eltwise", "Subgraph"}, 1); } -} // namespace CPULayerTestsDefinitions +} // namespace test +} // namespace ov diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/input_output_tensor_reuse.cpp b/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/input_output_tensor_reuse.cpp index ee09a571dbd690..1173eb7df3f3a4 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/input_output_tensor_reuse.cpp +++ b/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/input_output_tensor_reuse.cpp @@ -3,11 +3,9 @@ // #include "shared_test_classes/base/ov_subgraph.hpp" -#include "ov_models/utils/ov_helpers.hpp" -#include "ov_models/builders.hpp" -using namespace InferenceEngine; -using namespace ov::test; +namespace ov { +namespace test { /*This test runs the following subgraph: @@ -22,14 +20,13 @@ using namespace ov::test; Softmax | Output_1 - + Output_1 -> Param_1 The main purpose of this test is checking the code path when the output tensor is reused as an input tensor of the next infer request. */ -namespace SubgraphTestsDefinitions { class InputOutputTensorReuse : public SubgraphBaseTest { public: void SetUp() override { @@ -45,16 +42,17 @@ class InputOutputTensorReuse : public SubgraphBaseTest { input_params[1]->set_friendly_name("Param_1"); auto first_soft_max = std::make_shared(input_params[1], softmax_axis); - auto concat = std::make_shared(ov::NodeVector{input_params[0], first_soft_max}, concat_axis); + auto concat = + std::make_shared(ov::NodeVector{input_params[0], first_soft_max}, concat_axis); auto last_soft_max = std::make_shared(concat, softmax_axis); - ngraph::ResultVector results; + ov::ResultVector results; for (size_t i = 0; i < last_soft_max->get_output_size(); i++) - results.push_back(std::make_shared(last_soft_max->output(i))); + results.push_back(std::make_shared(last_soft_max->output(i))); results.front()->set_friendly_name("Output_1"); - function = std::make_shared(results, input_params, "InputOutputTensorReuseTest"); + function = std::make_shared(results, input_params, "InputOutputTensorReuseTest"); } }; @@ -68,9 +66,11 @@ TEST_F(InputOutputTensorReuse, smoke_Input_Output_Binding) { for (size_t i = 0; i < num_iter; i++) { auto outputTensor = inferRequest.get_output_tensor(0); inputShapes.back() = outputTensor.get_shape(); - auto itr = std::find_if(inputs.begin(), inputs.end(), [](const std::pair, ov::Tensor>& item) { - return item.first->get_friendly_name() == "Param_1"; - }); + auto itr = std::find_if(inputs.begin(), + inputs.end(), + [](const std::pair, ov::Tensor>& item) { + return item.first->get_friendly_name() == "Param_1"; + }); ASSERT_NE(itr, inputs.end()); itr->second = outputTensor; const auto& expectedOutputs = calculate_refs(); @@ -91,9 +91,10 @@ TEST_F(InputOutputTensorReuse, smoke_Input_Output_Bind_Once) { auto outputTensor = inferRequest.get_output_tensor(0); inputShapes.back() = outputTensor.get_shape(); - auto itr = std::find_if(inputs.begin(), inputs.end(), [](const std::pair, ov::Tensor>& item) { - return item.first->get_friendly_name() == "Param_1"; - }); + auto itr = + std::find_if(inputs.begin(), inputs.end(), [](const std::pair, ov::Tensor>& item) { + return item.first->get_friendly_name() == "Param_1"; + }); ASSERT_NE(itr, inputs.end()); itr->second = outputTensor; @@ -107,9 +108,11 @@ TEST_F(InputOutputTensorReuse, smoke_Input_Output_Bind_Once) { inferRequest.infer(); compare(expectedOutputs, {outputTensor}); - auto itr = std::find_if(inputs.begin(), inputs.end(), [](const std::pair, ov::Tensor>& item) { - return item.first->get_friendly_name() == "Param_1"; - }); + auto itr = std::find_if(inputs.begin(), + inputs.end(), + [](const std::pair, ov::Tensor>& item) { + return item.first->get_friendly_name() == "Param_1"; + }); ASSERT_NE(itr, inputs.end()); itr->second = expectedOutputs.front(); } @@ -123,9 +126,10 @@ TEST_F(InputOutputTensorReuse, smoke_Input_Output_Bind_Once_Empty_Tensor) { auto outputTensor = inferRequest.get_output_tensor(0); inputShapes.back() = outputTensor.get_shape(); - auto itr = std::find_if(inputs.begin(), inputs.end(), [](const std::pair, ov::Tensor>& item) { - return item.first->get_friendly_name() == "Param_1"; - }); + auto itr = + std::find_if(inputs.begin(), inputs.end(), [](const std::pair, ov::Tensor>& item) { + return item.first->get_friendly_name() == "Param_1"; + }); ASSERT_NE(itr, inputs.end()); itr->second = outputTensor; @@ -139,12 +143,15 @@ TEST_F(InputOutputTensorReuse, smoke_Input_Output_Bind_Once_Empty_Tensor) { inferRequest.infer(); compare(expectedOutputs, {outputTensor}); - auto itr = std::find_if(inputs.begin(), inputs.end(), [](const std::pair, ov::Tensor>& item) { - return item.first->get_friendly_name() == "Param_1"; - }); + auto itr = std::find_if(inputs.begin(), + inputs.end(), + [](const std::pair, ov::Tensor>& item) { + return item.first->get_friendly_name() == "Param_1"; + }); ASSERT_NE(itr, inputs.end()); itr->second = expectedOutputs.front(); } } -} // namespace SubgraphTestsDefinitions \ No newline at end of file +} // namespace test +} // namespace ov \ No newline at end of file diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/input_tensor_roi.cpp b/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/input_tensor_roi.cpp index 02f5c3e9b0e292..32095fbbc7d546 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/input_tensor_roi.cpp +++ b/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/input_tensor_roi.cpp @@ -2,16 +2,13 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "ov_models/builders.hpp" -#include "test_utils/cpu_test_utils.hpp" #include "functional_test_utils/ov_plugin_cache.hpp" +#include "test_utils/cpu_test_utils.hpp" -using namespace ngraph; -using namespace ngraph::op; -using namespace InferenceEngine; using namespace CPUTestUtils; -namespace SubgraphTestsDefinitions { +namespace ov { +namespace test { struct InputTensorROIParamType { ov::PartialShape shape; @@ -30,24 +27,23 @@ class InputTensorROI : public ::testing::TestWithParam } protected: - std::shared_ptr - create_test_function(element::Type type, - const ov::PartialShape & shape, - const ov::Layout & layout) { + std::shared_ptr create_test_function(element::Type type, + const ov::PartialShape& shape, + const ov::Layout& layout) { ResultVector res; ParameterVector params; - auto param = std::make_shared(type, shape); + auto param = std::make_shared(type, shape); param->set_friendly_name("input_0"); param->get_output_tensor(0).set_names({"tensor_input_0"}); param->set_layout(layout); - auto constant = opset8::Constant::create(type, {1}, {1}); + auto constant = ov::op::v0::Constant::create(type, {1}, {1}); - auto add = std::make_shared(param, constant); + auto add = std::make_shared(param, constant); add->set_friendly_name("Add"); - auto result = std::make_shared(add); + auto result = std::make_shared(add); result->set_friendly_name("result_0"); result->get_output_tensor(0).set_names({"tensor_output_0"}); @@ -57,7 +53,7 @@ class InputTensorROI : public ::testing::TestWithParam return std::make_shared(res, params); } - template + template void Run() { std::shared_ptr ie = ov::test::utils::PluginCache::get().core(); @@ -70,14 +66,14 @@ class InputTensorROI : public ::testing::TestWithParam ov::InferRequest req = compiled_model.create_infer_request(); // Create input tensor - auto input_shape = Shape{ 1, 4, 4, 4 }; + auto input_shape = Shape{1, 4, 4, 4}; auto input_shape_size = ov::shape_size(input_shape); std::vector data(input_shape_size); std::iota(data.begin(), data.end(), 0); auto input_tensor = ov::Tensor(GetParam().type, input_shape, &data[0]); // Set ROI - auto roi = ov::Tensor(input_tensor, { 0, 1, 1, 1 }, { 1, 3, 3, 3 }); + auto roi = ov::Tensor(input_tensor, {0, 1, 1, 1}, {1, 3, 3, 3}); req.set_tensor("tensor_input_0", roi); // Infer @@ -99,24 +95,24 @@ class InputTensorROI : public ::testing::TestWithParam TEST_P(InputTensorROI, SetInputTensorROI) { switch (GetParam().type) { - case ov::element::Type_t::f32: { - Run(); - break; - } - case ov::element::Type_t::u8: { - Run(); - break; - } - default: - break; + case ov::element::Type_t::f32: { + Run(); + break; + } + case ov::element::Type_t::u8: { + Run(); + break; + } + default: + break; } } static InputTensorROI::ParamType InputTensorROIParams[] = { - { ov::PartialShape{ 1, 2, 2, 2 }, element::f32, "NCHW" }, - { ov::PartialShape{ 1, 2, ov::Dimension::dynamic(), ov::Dimension::dynamic() }, element::f32, "NCHW" }, - { ov::PartialShape{ 1, 2, 2, 2 }, element::u8, "NCHW" }, - { ov::PartialShape{ 1, 2, ov::Dimension::dynamic(), ov::Dimension::dynamic() }, element::u8, "NCHW" }, + {ov::PartialShape{1, 2, 2, 2}, element::f32, "NCHW"}, + {ov::PartialShape{1, 2, ov::Dimension::dynamic(), ov::Dimension::dynamic()}, element::f32, "NCHW"}, + {ov::PartialShape{1, 2, 2, 2}, element::u8, "NCHW"}, + {ov::PartialShape{1, 2, ov::Dimension::dynamic(), ov::Dimension::dynamic()}, element::u8, "NCHW"}, }; INSTANTIATE_TEST_SUITE_P(smoke_InputTensorROI, @@ -124,4 +120,5 @@ INSTANTIATE_TEST_SUITE_P(smoke_InputTensorROI, ::testing::ValuesIn(InputTensorROIParams), InputTensorROI::getTestCaseName); -} // namespace SubgraphTestsDefinitions +} // namespace test +} // namespace ov diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/interaction.cpp b/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/interaction.cpp index 1a3874378536ef..572c4e80706f2a 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/interaction.cpp +++ b/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/interaction.cpp @@ -2,49 +2,37 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "shared_test_classes/base/ov_subgraph.hpp" -#include "ie_precision.hpp" -#include "test_utils/fusing_test_utils.hpp" -#include -#include -#include -#include -#include -#include -#include -#include #include "common_test_utils/common_utils.hpp" -#include -#include "functional_test_utils/skip_tests_config.hpp" +#include "common_test_utils/ov_tensor_utils.hpp" +#include "shared_test_classes/base/ov_subgraph.hpp" #include "test_utils/cpu_test_utils.hpp" using namespace CPUTestUtils; using namespace ov::test; -using namespace ov; - -static std::shared_ptr createFQ(const std::shared_ptr& input) { - auto input_low = std::make_shared(element::f32, ov::Shape{1}, std::vector{0}); - auto input_high = std::make_shared(element::f32, ov::Shape{1}, std::vector{49.4914f}); - auto output_low = std::make_shared(element::f32, ov::Shape{1}, std::vector{0}); - auto output_high = std::make_shared(element::f32, ov::Shape{1}, std::vector{49.4914f}); - return std::make_shared(input, input_low, input_high, output_low, output_high, 256); + +static std::shared_ptr createFQ(const std::shared_ptr& input) { + auto input_low = std::make_shared(ov::element::f32, ov::Shape{1}, std::vector{0}); + auto input_high = std::make_shared(ov::element::f32, ov::Shape{1}, std::vector{49.4914f}); + auto output_low = std::make_shared(ov::element::f32, ov::Shape{1}, std::vector{0}); + auto output_high = std::make_shared(ov::element::f32, ov::Shape{1}, std::vector{49.4914f}); + return std::make_shared(input, input_low, input_high, output_low, output_high, 256); } static std::shared_ptr makeInteraction(const ElementType inType, const ov::PartialShape& inputShape) { bool intraFQ = inType == ElementType::i8; auto paramType = intraFQ ? ElementType::f32 : inType; - std::shared_ptr input = std::make_shared(paramType, inputShape); + std::shared_ptr input = std::make_shared(paramType, inputShape); std::shared_ptr dense_feature = nullptr; if (intraFQ) { dense_feature = createFQ(input); } else { dense_feature = input; } - NodeVector features{dense_feature}; - ParameterVector inputsParams{input}; + ov::NodeVector features{dense_feature}; + ov::ParameterVector inputsParams{input}; const size_t sparse_feature_num = 26; for (size_t i = 0; i < sparse_feature_num; i++) { - auto sparse_input = std::make_shared(paramType, inputShape); + auto sparse_input = std::make_shared(paramType, inputShape); std::shared_ptr sparse_feat = nullptr; if (intraFQ) { sparse_feat = createFQ(sparse_input); @@ -55,23 +43,24 @@ static std::shared_ptr makeInteraction(const ElementType inType, cons inputsParams.push_back(sparse_input); } auto shapeof = std::make_shared(dense_feature); - auto gather_batch_indices = std::make_shared(element::i32, ov::Shape{1}, std::vector{0}); - auto gather_batch_axis = std::make_shared(element::i32, ov::Shape{}, 0); - auto gather_batch = std::make_shared(shapeof, gather_batch_indices, gather_batch_axis); + auto gather_batch_indices = std::make_shared(ov::element::i32, ov::Shape{1}, std::vector{0}); + auto gather_batch_axis = std::make_shared(ov::element::i32, ov::Shape{}, 0); + auto gather_batch = std::make_shared(shapeof, gather_batch_indices, gather_batch_axis); - auto gather_feature_indices = std::make_shared(element::i32, ov::Shape{1}, std::vector{1}); - auto gather_feature_axis = std::make_shared(element::i32, ov::Shape{1}, 0); - auto gather_feature = std::make_shared(shapeof, gather_feature_indices, gather_feature_axis); + auto gather_feature_indices = + std::make_shared(ov::element::i32, ov::Shape{1}, std::vector{1}); + auto gather_feature_axis = std::make_shared(ov::element::i32, ov::Shape{1}, 0); + auto gather_feature = std::make_shared(shapeof, gather_feature_indices, gather_feature_axis); - auto reshape_dim2 = std::make_shared(element::i64, ov::Shape{1}, std::vector{-1}); - auto reshape_shape = std::make_shared(NodeVector{gather_batch, reshape_dim2, gather_feature}, 0); + auto reshape_dim2 = std::make_shared(ov::element::i64, ov::Shape{1}, std::vector{-1}); + auto reshape_shape = std::make_shared(ov::NodeVector{gather_batch, reshape_dim2, gather_feature}, 0); - auto concat1 = std::make_shared(features, 1); - auto reshape = std::make_shared(concat1, reshape_shape, true); + auto concat1 = std::make_shared(features, 1); + auto reshape = std::make_shared(concat1, reshape_shape, true); std::vector transpose1_value = {0, 2, 1}; - auto transpose1_shape = std::make_shared(element::i32, ov::Shape{3}, transpose1_value); - auto transpose1 = std::make_shared(reshape, transpose1_shape); - auto matmul = std::make_shared(reshape, transpose1); + auto transpose1_shape = std::make_shared(ov::element::i32, ov::Shape{3}, transpose1_value); + auto transpose1 = std::make_shared(reshape, transpose1_shape); + auto matmul = std::make_shared(reshape, transpose1); std::shared_ptr inter = nullptr; if (intraFQ) { inter = createFQ(matmul); @@ -79,42 +68,42 @@ static std::shared_ptr makeInteraction(const ElementType inType, cons inter = matmul; } std::vector transpose2_value = {1, 2, 0}; - auto transpose2_shape = std::make_shared(element::i32, ov::Shape{3}, transpose2_value); - auto transpose2 = std::make_shared(inter, transpose2_shape); + auto transpose2_shape = std::make_shared(ov::element::i32, ov::Shape{3}, transpose2_value); + auto transpose2 = std::make_shared(inter, transpose2_shape); std::vector reshape2_value = {729, -1}; - auto reshape2_shape = std::make_shared(element::i32, ov::Shape{2}, reshape2_value); - auto reshape2 = std::make_shared(transpose2, reshape2_shape, true); + auto reshape2_shape = std::make_shared(ov::element::i32, ov::Shape{2}, reshape2_value); + auto reshape2 = std::make_shared(transpose2, reshape2_shape, true); std::vector gather_indices_value; for (int i = 1; i < 27; i++) { - for (int j = 0; j < i; j ++) { + for (int j = 0; j < i; j++) { gather_indices_value.push_back(i * 27 + j); } } - auto gather_indices = std::make_shared(element::i32, ov::Shape{351}, gather_indices_value); - auto gather_axis = std::make_shared(element::i32, ov::Shape{}, 0); - auto gather = std::make_shared(reshape2, gather_indices, gather_axis); - auto reshape3_dim1 = std::make_shared(element::i64, ov::Shape{1}, std::vector{-1}); - auto reshape3_shape = std::make_shared(NodeVector{reshape3_dim1, gather_batch}, 0); - auto reshape3 = std::make_shared(gather, reshape3_shape, true); + auto gather_indices = std::make_shared(ov::element::i32, ov::Shape{351}, gather_indices_value); + auto gather_axis = std::make_shared(ov::element::i32, ov::Shape{}, 0); + auto gather = std::make_shared(reshape2, gather_indices, gather_axis); + auto reshape3_dim1 = std::make_shared(ov::element::i64, ov::Shape{1}, std::vector{-1}); + auto reshape3_shape = std::make_shared(ov::NodeVector{reshape3_dim1, gather_batch}, 0); + auto reshape3 = std::make_shared(gather, reshape3_shape, true); std::vector transpose3_value = {1, 0}; - auto transpose3_shape = std::make_shared(element::i32, ov::Shape{2}, transpose3_value); - auto transpose3 = std::make_shared(reshape3, transpose3_shape); + auto transpose3_shape = std::make_shared(ov::element::i32, ov::Shape{2}, transpose3_value); + auto transpose3 = std::make_shared(reshape3, transpose3_shape); std::vector reshape4_value = {-1, 351}; - auto reshape4_shape = std::make_shared(element::i32, ov::Shape{2}, reshape4_value); - auto reshape4 = std::make_shared(transpose3, reshape4_shape, true); - auto concat2 = std::make_shared(NodeVector{dense_feature, reshape4}, 1); + auto reshape4_shape = std::make_shared(ov::element::i32, ov::Shape{2}, reshape4_value); + auto reshape4 = std::make_shared(transpose3, reshape4_shape, true); + auto concat2 = std::make_shared(ov::NodeVector{dense_feature, reshape4}, 1); std::shared_ptr model; if (intraFQ) { - auto add_const = std::make_shared(element::i8, ov::Shape{355, 1}, 3); - auto convert = std::make_shared(add_const, element::f32); - auto zp_const = std::make_shared(element::f32, ov::Shape{1}, 0); - auto scale_const = std::make_shared(element::f32, ov::Shape{1}, 1); - auto sub = std::make_shared(convert, zp_const); - auto multipy = std::make_shared(sub, scale_const); - const auto matmul = std::make_shared(concat2, multipy); + auto add_const = std::make_shared(ov::element::i8, ov::Shape{355, 1}, 3); + auto convert = std::make_shared(add_const, ov::element::f32); + auto zp_const = std::make_shared(ov::element::f32, ov::Shape{1}, 0); + auto scale_const = std::make_shared(ov::element::f32, ov::Shape{1}, 1); + auto sub = std::make_shared(convert, zp_const); + auto multipy = std::make_shared(sub, scale_const); + const auto matmul = std::make_shared(concat2, multipy); model = std::make_shared(matmul, inputsParams, "interaction"); } else { model = std::make_shared(concat2, inputsParams, "interaction"); @@ -122,7 +111,6 @@ static std::shared_ptr makeInteraction(const ElementType inType, cons return model; } -namespace CPULayerTestsDefinitions { using InteractionLayerCPUTestParams = std::tuple; class IntertactionCPUTest : public testing::WithParamInterface, @@ -146,7 +134,11 @@ class IntertactionCPUTest : public testing::WithParamInterfaceGetParam(); - bool with_bf16 = InferenceEngine::with_cpu_x86_bfloat16(); + bool with_bf16 = ov::with_cpu_x86_bfloat16(); if (with_bf16 && (inType == ov::element::bf16 || inType == ov::element::i32)) { selectedType = makeSelectedTypeStr("ref_any", ov::element::bf16); } else { @@ -166,7 +158,7 @@ class IntertactionCPUTest : public testing::WithParamInterface(27, targetInput[i])); } @@ -180,15 +172,10 @@ TEST_P(IntertactionCPUTest, CompareWithRefs) { } namespace { -const std::vector inPrecisions = { - ElementType::f32, - ElementType::bf16, - ElementType::i32, - ElementType::i8 -}; +const std::vector inPrecisions = {ElementType::f32, ElementType::bf16, ElementType::i32, ElementType::i8}; // the model has 27 inputs with same shape const std::vector input_shapes = { -// temporarily disable dynamic shape for performance issue + // temporarily disable dynamic shape for performance issue // // dynamic batch // { // {-1, 4}, @@ -200,22 +187,11 @@ const std::vector input_shapes = { // {{3, 4}, {5, 6}, {7, 8}} // }, // static shape - { - {6, 4}, - {{6, 4}} - }, - { - {3, 4}, - {{3, 4}} - } -}; - -INSTANTIATE_TEST_SUITE_P(smoke_Interaction, IntertactionCPUTest, - ::testing::Combine( - ::testing::ValuesIn(inPrecisions), - ::testing::ValuesIn(input_shapes)), - IntertactionCPUTest::getTestCaseName); -} // namespace - - -} // namespace CPULayerTestsDefinitions + {{6, 4}, {{6, 4}}}, + {{3, 4}, {{3, 4}}}}; + +INSTANTIATE_TEST_SUITE_P(smoke_Interaction, + IntertactionCPUTest, + ::testing::Combine(::testing::ValuesIn(inPrecisions), ::testing::ValuesIn(input_shapes)), + IntertactionCPUTest::getTestCaseName); +} // namespace diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/matmul_decompress_convert.cpp b/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/matmul_decompress_convert.cpp index b0edba98c1dbff..55197fa04e63ca 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/matmul_decompress_convert.cpp +++ b/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/matmul_decompress_convert.cpp @@ -2,17 +2,15 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "test_utils/fusing_test_utils.hpp" #include "ov_models/builders.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" +#include "test_utils/fusing_test_utils.hpp" #include "transformations/rt_info/decompression.hpp" -using namespace ngraph; -using namespace InferenceEngine; using namespace CPUTestUtils; -using namespace ov::test; -namespace SubgraphTestsDefinitions { +namespace ov { +namespace test { /* This test checks MatMul weights constant folding on CPU plugin side and cover two optimizations: 1. Decompressing Convert FP16 -> FP32 CF (FuseFCAndConvertOnWeights in cpu graph optimizer) @@ -82,22 +80,21 @@ namespace SubgraphTestsDefinitions { -------- */ -using MatMulDecompressConvertParams = std::tuple< - std::vector, // input shapes - std::pair, // transposeA, transposeB - ElementType, // weights precision - std::map, // additional config - CPUSpecificParams ->; +using MatMulDecompressConvertParams = std::tuple, // input shapes + std::pair, // transposeA, transposeB + ElementType, // weights precision + ov::AnyMap, // additional config + CPUSpecificParams>; class MatMulDecompressConvertTest : public testing::WithParamInterface, - virtual public SubgraphBaseTest, public CPUTestsBase { + virtual public SubgraphBaseTest, + public CPUTestsBase { public: static std::string getTestCaseName(testing::TestParamInfo obj) { std::vector inputShapes; std::pair transpose; ElementType weiElemType; - std::map additionalConfig; + ov::AnyMap additionalConfig; CPUSpecificParams cpuParams; std::tie(inputShapes, transpose, weiElemType, additionalConfig, cpuParams) = obj.param; @@ -124,7 +121,7 @@ class MatMulDecompressConvertTest : public testing::WithParamInterface() << ":"; } result << ")"; @@ -134,14 +131,14 @@ class MatMulDecompressConvertTest : public testing::WithParamInterface - void transposeShape(T& shape) { + template + void transpose_shape(T& shape) { OPENVINO_ASSERT(shape.size() > 1); std::swap(*(shape.end() - 1), *(shape.end() - 2)); } - void CheckFCWeightsPrecision(ElementType expectedWeiElemType) const { - auto getExecValue = [](const ov::Node::RTMap& rtInfo, const std::string ¶mName) -> std::string { + void check_fc_weights_precision(ElementType expectedWeiElemType) const { + auto getExecValue = [](const ov::Node::RTMap& rtInfo, const std::string& paramName) -> std::string { auto it = rtInfo.find(paramName); OPENVINO_ASSERT(rtInfo.end() != it); return it->second.as(); @@ -149,10 +146,11 @@ class MatMulDecompressConvertTest : public testing::WithParamInterfaceget_ops()) { + for (const auto& fcNode : execFunction->get_ops()) { if (getExecValue(fcNode->get_rt_info(), ExecGraphInfoSerialization::LAYER_TYPE) == "FullyConnected") { - const auto &constNode = fcNode->get_input_node_shared_ptr(1); - element::Type expectedType(getExecValue(constNode->get_rt_info(), ExecGraphInfoSerialization::OUTPUT_PRECISIONS)); + const auto& constNode = fcNode->get_input_node_shared_ptr(1); + ov::element::Type expectedType( + getExecValue(constNode->get_rt_info(), ov::exec_model_info::OUTPUT_PRECISIONS)); ASSERT_EQ(expectedType, expectedWeiElemType); } } @@ -164,7 +162,7 @@ class MatMulDecompressConvertTest : public testing::WithParamInterface inputShapes; std::pair transpose; ElementType weiConstElemType; - std::map additionalConfig; + ov::AnyMap additionalConfig; CPUSpecificParams cpuParams; std::tie(inputShapes, transpose, weiConstElemType, additionalConfig, cpuParams) = this->GetParam(); @@ -175,19 +173,21 @@ class MatMulDecompressConvertTest : public testing::WithParamInterfacesecond.as() == ov::element::bf16) { convertOutType = inType = outType = netType = ElementType::bf16; weiConstElemType = (weiConstElemType != ElementType::f32) ? weiConstElemType : ElementType::bf16; } else { @@ -209,9 +210,10 @@ class MatMulDecompressConvertTest : public testing::WithParamInterface(inType, inShapeA)}; - std::shared_ptr inputB = builder::makeConstant(weiConstElemType, inShapeB.get_shape(), {}, true); + std::shared_ptr inputB = + ngraph::builder::makeConstant(weiConstElemType, inShapeB.get_shape(), {}, true); if (weiConstElemType == ElementType::f16) { - inputB = std::make_shared(inputB, convertOutType); + inputB = std::make_shared(inputB, convertOutType); mark_as_decompression(inputB); } expectedWeiConstElemType = weiConstElemType; @@ -221,13 +223,13 @@ class MatMulDecompressConvertTest : public testing::WithParamInterface> transposeParams = { const std::vector> inputShapes2D = { static_shapes_to_test_representation({{2, 3}, {3, 4}}), - { - {{-1, -1}, {{2, 3}, {5, 3}}}, - {{3, 4}, {{3, 4}, {3, 4}}} - }, + {{{-1, -1}, {{2, 3}, {5, 3}}}, {{3, 4}, {{3, 4}, {3, 4}}}}, }; const std::vector> inputShapes3D = { static_shapes_to_test_representation({{2, 2, 3}, {3, 4}}), static_shapes_to_test_representation({{2, 3}, {1, 3, 4}}), static_shapes_to_test_representation({{1, 2, 3}, {1, 3, 4}}), - { - {{-1, -1, -1}, {{2, 2, 3}, {3, 5, 3}}}, - {{3, 4}, {{3, 4}, {3, 4}}} - }, - { - {{-1, -1}, {{2, 3}, {5, 3}}}, - {{1, 3, 4}, {{1, 3, 4}, {1, 3, 4}}} - }, - { - {{-1, -1, -1}, {{1, 2, 3}, {1, 5, 3}}}, - {{1, 3, 4}, {{1, 3, 4}, {1, 3, 4}}} - }, + {{{-1, -1, -1}, {{2, 2, 3}, {3, 5, 3}}}, {{3, 4}, {{3, 4}, {3, 4}}}}, + {{{-1, -1}, {{2, 3}, {5, 3}}}, {{1, 3, 4}, {{1, 3, 4}, {1, 3, 4}}}}, + {{{-1, -1, -1}, {{1, 2, 3}, {1, 5, 3}}}, {{1, 3, 4}, {{1, 3, 4}, {1, 3, 4}}}}, }; -std::map emptyConfig = {/* empty config */}; +ov::AnyMap emptyConfig = {/* empty config */}; -std::vector> filterAdditionalConfig_BF16() { - std::vector> additionalConfig; - if (with_cpu_x86_avx512_core()) { - additionalConfig.push_back({{PluginConfigParams::KEY_ENFORCE_BF16, PluginConfigParams::YES}}); +std::vector filter_additional_config_bf16() { + std::vector additionalConfig; + if (ov::with_cpu_x86_avx512_core()) { + additionalConfig.push_back({{ov::hint::inference_precision(ov::element::bf16)}}); } return additionalConfig; } -std::vector filterSpecificParams(bool trySetMlas) { +std::vector filter_specific_params(bool trySetMlas) { std::vector specificParams; if (trySetMlas) { #ifdef OV_CPU_WITH_MLAS @@ -295,9 +285,9 @@ std::vector filterSpecificParams(bool trySetMlas) { } // try set onednn jit params if we can't or shouldn't use mlas if (specificParams.empty()) { - if (with_cpu_x86_avx512_core()) { + if (ov::with_cpu_x86_avx512_core()) { specificParams.push_back(CPUSpecificParams{{}, {}, {"brgemm_avx512"}, "brgemm_avx512"}); - } else if (with_cpu_x86_avx2()) { + } else if (ov::with_cpu_x86_avx2()) { specificParams.push_back(CPUSpecificParams{{}, {}, {"brgemm_avx2"}, "brgemm_avx2"}); } } @@ -305,84 +295,84 @@ std::vector filterSpecificParams(bool trySetMlas) { return specificParams; } -std::vector filterSpecificParams_BF16() { +std::vector filter_specific_params_bf16() { std::vector specificParams; specificParams.push_back(CPUSpecificParams{{}, {}, {"jit_gemm"}, "jit_gemm"}); return specificParams; } - -const auto testParams2D_FP32_smoke = ::testing::Combine( - ::testing::ValuesIn(inputShapes2D), - ::testing::ValuesIn(transposeParams), - ::testing::Values(ElementType::f32), - ::testing::Values(emptyConfig), - ::testing::ValuesIn(filterSpecificParams(true))); - -INSTANTIATE_TEST_SUITE_P(smoke_FC_2D_FP32, MatMulDecompressConvertTest, testParams2D_FP32_smoke, - MatMulDecompressConvertTest::getTestCaseName); - - -const auto testParams2D_FP16_smoke = ::testing::Combine( - ::testing::ValuesIn(inputShapes2D), - ::testing::ValuesIn(transposeParams), - ::testing::Values(ElementType::f16), - ::testing::Values(emptyConfig), - ::testing::ValuesIn(filterSpecificParams(false))); - -INSTANTIATE_TEST_SUITE_P(smoke_FC_2D_FP16, MatMulDecompressConvertTest, testParams2D_FP16_smoke, - MatMulDecompressConvertTest::getTestCaseName); - - -const auto testParams2D_BF16_smoke = ::testing::Combine( - ::testing::ValuesIn(inputShapes2D), - ::testing::ValuesIn(transposeParams), - ::testing::Values(ElementType::f32, ElementType::f16), - ::testing::ValuesIn(filterAdditionalConfig_BF16()), - ::testing::ValuesIn(filterSpecificParams_BF16())); - -INSTANTIATE_TEST_SUITE_P(smoke_FC_2D_BF16, MatMulDecompressConvertTest, testParams2D_BF16_smoke, - MatMulDecompressConvertTest::getTestCaseName); - - -const auto testParams3D_FP32_smoke = ::testing::Combine( - ::testing::ValuesIn(inputShapes3D), - ::testing::ValuesIn(transposeParams), - ::testing::Values(ElementType::f32), - ::testing::Values(emptyConfig), - ::testing::ValuesIn(filterSpecificParams(true))); - -INSTANTIATE_TEST_SUITE_P(smoke_FC_3D_FP32, MatMulDecompressConvertTest, testParams3D_FP32_smoke, - MatMulDecompressConvertTest::getTestCaseName); - - -const auto testParams3D_FP16_smoke = ::testing::Combine( - ::testing::ValuesIn(inputShapes3D), - ::testing::ValuesIn(transposeParams), - ::testing::Values(ElementType::f16), - ::testing::Values(emptyConfig), - ::testing::ValuesIn(filterSpecificParams(false))); - -INSTANTIATE_TEST_SUITE_P(smoke_FC_3D_FP16, MatMulDecompressConvertTest, testParams3D_FP16_smoke, - MatMulDecompressConvertTest::getTestCaseName); - - -const auto testParams3D_BF16_smoke = ::testing::Combine( - ::testing::ValuesIn(inputShapes3D), - ::testing::ValuesIn(transposeParams), - ::testing::Values(ElementType::f32, ElementType::f16), - ::testing::ValuesIn(filterAdditionalConfig_BF16()), - ::testing::ValuesIn(filterSpecificParams_BF16())); - -INSTANTIATE_TEST_SUITE_P(smoke_FC_3D_BF16, MatMulDecompressConvertTest, testParams3D_BF16_smoke, - MatMulDecompressConvertTest::getTestCaseName); - -} // namespace +const auto testParams2D_FP32_smoke = ::testing::Combine(::testing::ValuesIn(inputShapes2D), + ::testing::ValuesIn(transposeParams), + ::testing::Values(ElementType::f32), + ::testing::Values(emptyConfig), + ::testing::ValuesIn(filter_specific_params(true))); + +INSTANTIATE_TEST_SUITE_P(smoke_FC_2D_FP32, + MatMulDecompressConvertTest, + testParams2D_FP32_smoke, + MatMulDecompressConvertTest::getTestCaseName); + +const auto testParams2D_FP16_smoke = ::testing::Combine(::testing::ValuesIn(inputShapes2D), + ::testing::ValuesIn(transposeParams), + ::testing::Values(ElementType::f16), + ::testing::Values(emptyConfig), + ::testing::ValuesIn(filter_specific_params(false))); + +INSTANTIATE_TEST_SUITE_P(smoke_FC_2D_FP16, + MatMulDecompressConvertTest, + testParams2D_FP16_smoke, + MatMulDecompressConvertTest::getTestCaseName); + +const auto testParams2D_BF16_smoke = ::testing::Combine(::testing::ValuesIn(inputShapes2D), + ::testing::ValuesIn(transposeParams), + ::testing::Values(ElementType::f32, ElementType::f16), + ::testing::ValuesIn(filter_additional_config_bf16()), + ::testing::ValuesIn(filter_specific_params_bf16())); + +INSTANTIATE_TEST_SUITE_P(smoke_FC_2D_BF16, + MatMulDecompressConvertTest, + testParams2D_BF16_smoke, + MatMulDecompressConvertTest::getTestCaseName); + +const auto testParams3D_FP32_smoke = ::testing::Combine(::testing::ValuesIn(inputShapes3D), + ::testing::ValuesIn(transposeParams), + ::testing::Values(ElementType::f32), + ::testing::Values(emptyConfig), + ::testing::ValuesIn(filter_specific_params(true))); + +INSTANTIATE_TEST_SUITE_P(smoke_FC_3D_FP32, + MatMulDecompressConvertTest, + testParams3D_FP32_smoke, + MatMulDecompressConvertTest::getTestCaseName); + +const auto testParams3D_FP16_smoke = ::testing::Combine(::testing::ValuesIn(inputShapes3D), + ::testing::ValuesIn(transposeParams), + ::testing::Values(ElementType::f16), + ::testing::Values(emptyConfig), + ::testing::ValuesIn(filter_specific_params(false))); + +INSTANTIATE_TEST_SUITE_P(smoke_FC_3D_FP16, + MatMulDecompressConvertTest, + testParams3D_FP16_smoke, + MatMulDecompressConvertTest::getTestCaseName); + +const auto testParams3D_BF16_smoke = ::testing::Combine(::testing::ValuesIn(inputShapes3D), + ::testing::ValuesIn(transposeParams), + ::testing::Values(ElementType::f32, ElementType::f16), + ::testing::ValuesIn(filter_additional_config_bf16()), + ::testing::ValuesIn(filter_specific_params_bf16())); + +INSTANTIATE_TEST_SUITE_P(smoke_FC_3D_BF16, + MatMulDecompressConvertTest, + testParams3D_BF16_smoke, + MatMulDecompressConvertTest::getTestCaseName); + +} // namespace /* In case of Convert has 2 or more consumers there is a problem with memory allocation in CPU plug-in (see Edge::init() method). Maybe we can just remove the check (edgePtr->getParent()->isConstant() && !edgePtr->getChild()->isConstant()) and everything will be OK, But this solution should be additionally checked. For now, for these cases we will not be - doing CF on the CPU side and it should be done on the ngraph side. + doing CF on the CPU side and it should be done on the graph side. * Graph before: ------------ ------------ ------------ @@ -422,13 +412,11 @@ INSTANTIATE_TEST_SUITE_P(smoke_FC_3D_BF16, MatMulDecompressConvertTest, testPara |Output| -------- */ -using MatMulDecompressConvertParams2 = std::tuple< - std::vector, // input shapes - std::pair, // transposeA, transposeB - ElementType, // weights precision - std::map, // additional config - CPUSpecificParams ->; +using MatMulDecompressConvertParams2 = std::tuple, // input shapes + std::pair, // transposeA, transposeB + ElementType, // weights precision + ov::AnyMap, // additional property + CPUSpecificParams>; class MatMulDecompressConvertTest2 : public MatMulDecompressConvertTest { protected: @@ -438,7 +426,7 @@ class MatMulDecompressConvertTest2 : public MatMulDecompressConvertTest { std::vector inputShapes; std::pair transpose; ElementType weiConstElemType; - std::map additionalConfig; + ov::AnyMap additionalConfig; CPUSpecificParams cpuParams; std::tie(inputShapes, transpose, weiConstElemType, additionalConfig, cpuParams) = this->GetParam(); @@ -450,23 +438,25 @@ class MatMulDecompressConvertTest2 : public MatMulDecompressConvertTest { bool transpB = transpose.second; fullyConnectedCount = 2; - if (transpA) transposeCount += 2; - if (!transpB) transposeCount++; + if (transpA) + transposeCount += 2; + if (!transpB) + transposeCount++; if (transpA) { - transposeShape(inputDynamicShapes[0]); + transpose_shape(inputDynamicShapes[0]); for (auto& shapes : targetStaticShapes) { - transposeShape(shapes[0]); + transpose_shape(shapes[0]); } - transposeShape(inputDynamicShapes[1]); + transpose_shape(inputDynamicShapes[1]); for (auto& shapes : targetStaticShapes) { - transposeShape(shapes[1]); + transpose_shape(shapes[1]); } } if (transpB) { - transposeShape(inputDynamicShapes[2]); + transpose_shape(inputDynamicShapes[2]); for (auto& shapes : targetStaticShapes) { - transposeShape(shapes[2]); + transpose_shape(shapes[2]); } } @@ -478,7 +468,8 @@ class MatMulDecompressConvertTest2 : public MatMulDecompressConvertTest { ElementType netType = ElementType::f32; ElementType convertOutType = ElementType::f32; - if (additionalConfig[PluginConfigParams::KEY_ENFORCE_BF16] == PluginConfigParams::YES) { + auto it = additionalConfig.find(ov::hint::inference_precision.name()); + if (it != additionalConfig.end() && it->second.as() == ov::element::bf16) { convertOutType = inType = outType = netType = ElementType::bf16; weiConstElemType = (weiConstElemType != ElementType::f32) ? weiConstElemType : ElementType::bf16; } else { @@ -492,12 +483,13 @@ class MatMulDecompressConvertTest2 : public MatMulDecompressConvertTest { for (auto&& shape : {inShapeFC0, inShapeFC1}) { params.push_back(std::make_shared(inType, shape)); } - std::shared_ptr inputWeights = builder::makeConstant(weiConstElemType, inShapeWeights.get_shape(), {}, true); + std::shared_ptr inputWeights = + ngraph::builder::makeConstant(weiConstElemType, inShapeWeights.get_shape(), {}, true); if (weiConstElemType == ElementType::f16) { - inputWeights = std::make_shared(inputWeights, convertOutType); + inputWeights = std::make_shared(inputWeights, convertOutType); mark_as_decompression(inputWeights); } - // In this test, convert must be folded on the ngraph side, so the constant with fp32 precision is expected + // In this test, convert must be folded on the graph side, so the constant with fp32 precision is expected expectedWeiConstElemType = ElementType::f32; auto matMul0 = std::make_shared(params[0], inputWeights, transpA, transpB); @@ -512,21 +504,24 @@ class MatMulDecompressConvertTest2 : public MatMulDecompressConvertTest { TEST_P(MatMulDecompressConvertTest2, CompareWithRefs) { SKIP_IF_CURRENT_TEST_IS_DISABLED(); run(); - CheckExecutionGraph(); + check_execution_graph(); } namespace { -const auto testParams2D_FP16_2_smoke = ::testing::Combine( - ::testing::Values(static_shapes_to_test_representation({{2, 3}, {2, 3}, {3, 4}})), - ::testing::Values(std::pair{false, true}), - ::testing::Values(ElementType::f16), - ::testing::Values(emptyConfig), - ::testing::ValuesIn(filterSpecificParams(true))); +const auto testParams2D_FP16_2_smoke = + ::testing::Combine(::testing::Values(static_shapes_to_test_representation({{2, 3}, {2, 3}, {3, 4}})), + ::testing::Values(std::pair{false, true}), + ::testing::Values(ElementType::f16), + ::testing::Values(emptyConfig), + ::testing::ValuesIn(filter_specific_params(true))); -INSTANTIATE_TEST_SUITE_P(smoke_FC_2D_FP16_2, MatMulDecompressConvertTest2, testParams2D_FP16_2_smoke, - MatMulDecompressConvertTest2::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_FC_2D_FP16_2, + MatMulDecompressConvertTest2, + testParams2D_FP16_2_smoke, + MatMulDecompressConvertTest2::getTestCaseName); -} // namespace +} // namespace -} // namespace SubgraphTestsDefinitions +} // namespace test +} // namespace ov diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/matmul_quantized_subgraph.cpp b/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/matmul_quantized_subgraph.cpp index 2a04bdf843a72a..c5e2a9ec08d903 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/matmul_quantized_subgraph.cpp +++ b/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/matmul_quantized_subgraph.cpp @@ -6,18 +6,18 @@ #include "test_utils/fusing_test_utils.hpp" #include "ov_models/builders.hpp" #include "common_test_utils/common_utils.hpp" +#include "shared_test_classes/base/ov_subgraph.hpp" #include #include -using namespace ngraph; -using namespace InferenceEngine; using namespace CPUTestUtils; -namespace SubgraphTestsDefinitions { +namespace ov { +namespace test { using ElementType = ov::element::Type_t; -using MatmulBrgemmInt8TestParams = std::tuplef32 // (u8/s8 + s8)->u8/s8 class MatmulBrgemmInt8Test : public testing::WithParamInterface, public CpuTestWithFusing, - virtual public LayerTestsUtils::LayerTestsCommon { + virtual public ov::test::SubgraphBaseStaticTest { public: static std::string getTestCaseName(testing::TestParamInfo obj) { - SizeVector supportedInputShapes; + ov::Shape supportedInputShapes; bool isFC; ElementType inType; ElementType outType; @@ -41,7 +41,7 @@ class MatmulBrgemmInt8Test : public testing::WithParamInterfaceGetParam(); std::tie(inFmts, outFmts, priority, selectedType) = cpuParams; - const auto ngPrec = element::f32; + const auto ngPrec = ov::element::f32; ov::ParameterVector inputParams {std::make_shared(ngPrec, ov::Shape(inShapes))}; - std::shared_ptr fq1; - std::shared_ptr matMul; - std::shared_ptr nodeBeforeConv; + std::shared_ptr fq1; + std::shared_ptr matMul; + std::shared_ptr nodeBeforeConv; selectedType = makeSelectedTypeStr(selectedType, ElementType::i8); if (inType == ElementType::u8) fq1 = ngraph::builder::makeFakeQuantize(inputParams[0], ngPrec, 256, {}, {0.0f}, {2.55f}, {0.0f}, {2.55f}); @@ -74,15 +74,15 @@ class MatmulBrgemmInt8Test : public testing::WithParamInterface{0.0f}, true); auto fq2 = ngraph::builder::makeFakeQuantize(weightsNode, ngPrec, 256, {}, {-1.28f}, {1.27f}, {-1.28f}, {1.27f}); - auto fc = std::make_shared(fq1, fq2, false, false); + auto fc = std::make_shared(fq1, fq2, false, false); fc->get_rt_info() = getCPUInfo(); fc->set_friendly_name(nameMatmul); auto biasWeightsNode = ngraph::builder::makeConstant(ngPrec, {}, std::vector{0.0f}, true); - matMul = std::make_shared(fc, biasWeightsNode); + matMul = std::make_shared(fc, biasWeightsNode); } else { auto fq2 = ngraph::builder::makeFakeQuantize(inputParams[0], ngPrec, 256, {}, {-1.28f}, {1.27f}, {-1.28f}, {1.27f}); matMul = std::make_shared(fq1, fq2, false, true); @@ -98,7 +98,7 @@ class MatmulBrgemmInt8Test : public testing::WithParamInterfacefq->matmul can cover x8*s8->x8 case auto filterWeightsShape = matMul->get_output_shape(0); - auto filterWeightsNode = ngraph::builder::makeConstant(element::f32, filterWeightsShape, std::vector{}, true); + auto filterWeightsNode = ngraph::builder::makeConstant(ov::element::f32, filterWeightsShape, std::vector{}, true); auto fq3 = ngraph::builder::makeFakeQuantize(filterWeightsNode, ngPrec, 256, {}, {-1.28f}, {1.27f}, {-1.28f}, {1.27f}); // only matmul avx2 support s8*s8 input auto matMul2 = std::make_shared(nodeBeforeConv, fq3, false, false); @@ -106,7 +106,7 @@ class MatmulBrgemmInt8Test : public testing::WithParamInterface function, const std::string& nodeName) { + void check_node(std::shared_ptr function, const std::string& nodeName) { ASSERT_NE(nullptr, function); for (const auto &node : function->get_ops()) { const auto & rtInfo = node->get_rt_info(); @@ -127,18 +127,17 @@ class MatmulBrgemmInt8Test : public testing::WithParamInterface supportedInputShapes = { +const std::vector supportedInputShapes = { {16, 32}, {17, 15}, }; @@ -148,7 +147,8 @@ const std::vectormatmulSpecificFilterParams = { {{}, {}, {"jit_gemm"}, "jit_gemm"} }; -INSTANTIATE_TEST_SUITE_P(smoke_matmulBrgemmInt8, MatmulBrgemmInt8Test, +INSTANTIATE_TEST_SUITE_P(smoke_matmulBrgemmInt8, + MatmulBrgemmInt8Test, ::testing::Combine(::testing::ValuesIn(supportedInputShapes), ::testing::ValuesIn({true, false}), ::testing::ValuesIn({ElementType::u8, ElementType::i8}), @@ -156,6 +156,7 @@ INSTANTIATE_TEST_SUITE_P(smoke_matmulBrgemmInt8, MatmulBrgemmInt8Test, ::testing::ValuesIn(matmulSpecificFilterParams)), MatmulBrgemmInt8Test::getTestCaseName); -} // namespace +} // namespace -} // namespace SubgraphTestsDefinitions +} // namespace test +} // namespace ov diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/matmul_strided_inputs_outputs.cpp b/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/matmul_strided_inputs_outputs.cpp index 4bf666a1600bd0..ced1ce82c8b7b6 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/matmul_strided_inputs_outputs.cpp +++ b/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/matmul_strided_inputs_outputs.cpp @@ -2,59 +2,62 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "test_utils/cpu_test_utils.hpp" #include "ov_models/builders.hpp" +#include "shared_test_classes/base/ov_subgraph.hpp" +#include "test_utils/cpu_test_utils.hpp" -using namespace ngraph; -using namespace InferenceEngine; using namespace CPUTestUtils; -namespace SubgraphTestsDefinitions { +namespace ov { +namespace test { -using MatmulStridedInputsOutputsTestParams = Precision; +using MatmulStridedInputsOutputsTestParams = ov::element::Type; class MatmulStridedInputsOutputsTest : public testing::WithParamInterface, public CPUTestsBase, - virtual public LayerTestsUtils::LayerTestsCommon { + virtual public SubgraphBaseStaticTest { public: static std::string getTestCaseName(testing::TestParamInfo obj) { - Precision netPrecision; + ov::element::Type netPrecision; netPrecision = obj.param; std::ostringstream result; - result << "netPRC=" << netPrecision.name() << "_"; + result << "netPRC=" << netPrecision.to_string() << "_"; return result.str(); } protected: void SetUp() override { - targetDevice = ov::test::utils::DEVICE_CPU; - Precision netPrecision; - netPrecision = this->GetParam(); - const auto ngPrec = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); + targetDevice = utils::DEVICE_CPU; + const auto ngPrec = this->GetParam(); - SizeVector splitShape{1, 2, 1, 16}; + ov::Shape splitShape{1, 2, 1, 16}; ov::ParameterVector splitInputParams {std::make_shared(ngPrec, ov::Shape(splitShape))}; auto split_axis_op = std::make_shared(ov::element::Type_t::i64, ov::Shape{}, std::vector{1}); auto split = std::make_shared(splitInputParams[0], split_axis_op, 2); std::vector concatShapes{{1, 1, 8, 8}, {1, 1, 8, 8}}; - ov::ParameterVector concatInputParams {std::make_shared(ngPrec, concatShapes[0]), - std::make_shared(ngPrec, concatShapes[1])}; - const auto concatOutputNodes = helpers::convert2OutputVector(helpers::castOps2Nodes(concatInputParams)); + ov::ParameterVector concatInputParams{std::make_shared(ngPrec, concatShapes[0]), + std::make_shared(ngPrec, concatShapes[1])}; + ov::OutputVector concatOutputNodes; + for (auto&& node : concatInputParams) { + for (auto&& param : node->outputs()) + concatOutputNodes.push_back(param); + } + const auto concat = std::make_shared(concatOutputNodes, 2); const auto matMul1 = std::make_shared(split->output(0), concat, false, false); - SizeVector matmulShape{1, 1, 16, 8}; + ov::Shape matmulShape{1, 1, 16, 8}; ov::ParameterVector matmulInputParams {std::make_shared(ngPrec, ov::Shape(matmulShape))}; const auto matMul2 = std::make_shared(split->output(1), matmulInputParams[0], false, false); const auto concatMatMuls = std::make_shared(ov::NodeVector{matMul1, matMul2}, 2 /* 3rd axis */); - ngraph::ParameterVector inputParams = {splitInputParams[0], concatInputParams[0], concatInputParams[1], matmulInputParams[0]}; + ov::ParameterVector inputParams = {splitInputParams[0], concatInputParams[0], concatInputParams[1], matmulInputParams[0]}; function = makeNgraphFunction(ngPrec, inputParams, concatMatMuls, "MatmulStridedInputsOutputs"); } }; @@ -84,16 +87,17 @@ class MatmulStridedInputsOutputsTest : public testing::WithParamInterface, // additional config + ov::AnyMap, // additional config fusingSpecificParams, bool>; // should use decompression implementation @@ -73,7 +71,7 @@ class MatmulWeightsDecompression : public testing::WithParamInterface additional_config; + ov::AnyMap additional_config; fusingSpecificParams fusing_params; bool should_fuse; @@ -99,7 +97,7 @@ class MatmulWeightsDecompression : public testing::WithParamInterface() << ":"; } result << ")"; result << CpuTestWithFusing::getTestCaseName(fusing_params); @@ -145,7 +143,7 @@ class MatmulWeightsDecompression : public testing::WithParamInterface(weights_precision, transformed_weights_shape, {}, true, 7); weights->set_friendly_name("Compressed_weights"); - auto weights_convert = std::make_shared(weights, decompression_precision); + auto weights_convert = std::make_shared(weights, decompression_precision); std::shared_ptr mul_parent = weights_convert; auto output_channels = *weights_shape.rbegin(); @@ -166,7 +164,7 @@ class MatmulWeightsDecompression : public testing::WithParamInterface(weights_precision, scaleshift_const_shape, {}, true, 7); - std::shared_ptr shift_convert = std::make_shared(shift_const, decompression_precision); + std::shared_ptr shift_convert = std::make_shared(shift_const, decompression_precision); if (reshape_on_decompression_constant) { auto shift_reshape_const = ov::opset10::Constant::create(ov::element::i32, {scaleshift_target_shape.size()}, scaleshift_target_shape); auto shift_reshape = std::make_shared(shift_convert, shift_reshape_const, false); @@ -234,7 +232,7 @@ class MatmulWeightsDecompression : public testing::WithParamInterface additional_config; + ov::AnyMap additional_config; fusingSpecificParams fusing_params; bool should_fuse; @@ -252,7 +250,7 @@ class MatmulWeightsDecompression : public testing::WithParamInterface(test_param); @@ -290,19 +288,19 @@ class MatmulWeightsDecompression : public testing::WithParamInterface> filterAdditionalConfigBasic() { - std::vector> additional_config = {CPUTestUtils::cpuEmptyPluginConfig}; +std::vector filter_additional_config_basic() { + std::vector additional_config = {CPUTestUtils::empty_plugin_config}; return additional_config; } -std::vector> filterAdditionalConfigAMX() { - std::vector> additional_config = {}; - if (with_cpu_x86_avx512_core_amx()) - additional_config.push_back({{PluginConfigParams::KEY_ENFORCE_BF16, PluginConfigParams::YES}}); +std::vector filter_additional_config_amx() { + std::vector additional_config = {}; + if (ov::with_cpu_x86_avx512_core_amx()) + additional_config.push_back({{ov::hint::inference_precision(ov::element::bf16)}}); return additional_config; } @@ -331,11 +329,7 @@ const std::vector input_shapes_amx = { {{{}, {{11, 339, 577}}}, {577, 335}}, {{{}, {{1, 1, 256}}}, {256, 128}, 64ul}, }; -const std::vector fusing_params { - emptyFusingSpec, - fusingBias, - fusingFakeQuantizePerTensorRelu -}; +const std::vector fusing_params{emptyFusingSpec, fusingBias, fusingFakeQuantizePerTensorRelu}; INSTANTIATE_TEST_SUITE_P(smoke_MatMulCompressedWeights_basic, MatmulWeightsDecompression, @@ -345,7 +339,7 @@ INSTANTIATE_TEST_SUITE_P(smoke_MatMulCompressedWeights_basic, ::testing::Values(true), ::testing::Values(true), ::testing::Values(true), - ::testing::ValuesIn(filterAdditionalConfigBasic()), + ::testing::ValuesIn(filter_additional_config_basic()), ::testing::ValuesIn(fusing_params), ::testing::Values(true)), MatmulWeightsDecompression::getTestCaseName); @@ -358,7 +352,7 @@ INSTANTIATE_TEST_SUITE_P(smoke_MatMulCompressedWeights_amx, ::testing::Values(true), ::testing::Values(true), ::testing::Values(true), - ::testing::ValuesIn(filterAdditionalConfigAMX()), + ::testing::ValuesIn(filter_additional_config_amx()), ::testing::ValuesIn(fusing_params), ::testing::Values(true)), MatmulWeightsDecompression::getTestCaseName); @@ -387,7 +381,7 @@ INSTANTIATE_TEST_SUITE_P(smoke_MatMulCompressedWeights_corner_cases_basic, ::testing::ValuesIn(transpose_weights), ::testing::ValuesIn(add_decompression_sub), ::testing::ValuesIn(reshape_on_decompression), - ::testing::ValuesIn(filterAdditionalConfigBasic()), + ::testing::ValuesIn(filter_additional_config_basic()), ::testing::Values(emptyFusingSpec), ::testing::Values(true)), MatmulWeightsDecompression::getTestCaseName); @@ -400,9 +394,10 @@ INSTANTIATE_TEST_SUITE_P(smoke_MatMulCompressedWeights_corner_cases_amx, ::testing::ValuesIn(transpose_weights), ::testing::ValuesIn(add_decompression_sub), ::testing::ValuesIn(reshape_on_decompression), - ::testing::ValuesIn(filterAdditionalConfigAMX()), + ::testing::ValuesIn(filter_additional_config_amx()), ::testing::Values(emptyFusingSpec), ::testing::Values(true)), MatmulWeightsDecompression::getTestCaseName); -} // namespace -} // namespace SubgraphTestsDefinitions +} // namespace +} // namespace test +} // namespace ov diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/memory_sharing_test.cpp b/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/memory_sharing_test.cpp index ccd09e50da2e47..e693270a807b99 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/memory_sharing_test.cpp +++ b/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/memory_sharing_test.cpp @@ -2,14 +2,15 @@ // SPDX-License-Identifier: Apache-2.0 // +#include "common_test_utils/node_builders/convolution.hpp" #include "openvino/openvino.hpp" -#include "test_utils/cpu_test_utils.hpp" -#include "ov_models/builders.hpp" #include "test_utils/convolution_params.hpp" +#include "test_utils/cpu_test_utils.hpp" using namespace CPUTestUtils; -namespace SubgraphTestsDefinitions { +namespace ov { +namespace test { class EdgeWithSameNameInTwoModels : public ::testing::Test, public CPUTestsBase {}; @@ -24,36 +25,52 @@ TEST_F(EdgeWithSameNameInTwoModels, smoke_CompareWithRef) { const std::vector padsBegin{0, 0}; const std::vector padsEnd{0, 0}; const std::vector dilations{1, 1}; - const ngraph::op::PadType autoPad(ngraph::op::PadType::EXPLICIT); + const ov::op::PadType autoPad(ov::op::PadType::EXPLICIT); - if (InferenceEngine::with_cpu_x86_avx512f()) { + if (ov::with_cpu_x86_avx512f()) { std::tie(inFmts, outFmts, priority, selectedType) = conv_avx512_2D; - } else if (InferenceEngine::with_cpu_x86_avx2()) { + } else if (ov::with_cpu_x86_avx2()) { std::tie(inFmts, outFmts, priority, selectedType) = conv_avx2_2D; - } else if (InferenceEngine::with_cpu_x86_sse42()) { + } else if (ov::with_cpu_x86_sse42()) { std::tie(inFmts, outFmts, priority, selectedType) = conv_sse42_2D; } // first model - const std::vector> shapes1{{1, 16, 720, 1280}}; + const std::vector shapes1{{1, 16, 720, 1280}}; ov::ParameterVector params1; for (auto&& shape : shapes1) { - params1.push_back(std::make_shared(type, ov::Shape(shape))); + params1.push_back(std::make_shared(type, shape)); } const size_t convOutCh1 = 32; - auto conv1 = ngraph::builder::makeConvolution(params1.front(), type, kernel, strides, padsBegin, padsEnd, dilations, autoPad, convOutCh1); + auto conv1 = ov::test::utils::make_convolution(params1.front(), + type, + kernel, + strides, + padsBegin, + padsEnd, + dilations, + autoPad, + convOutCh1); conv1->set_friendly_name(convName); conv1->get_input_node_shared_ptr(1)->set_friendly_name(weightName); auto model1 = makeNgraphFunction(type, params1, conv1, "Model1"); // second model - const std::vector> shapes2{{1, 32, 24, 24}}; + const std::vector shapes2{{1, 32, 24, 24}}; ov::ParameterVector params2; for (auto&& shape : shapes2) { - params2.push_back(std::make_shared(type, ov::Shape(shape))); + params2.push_back(std::make_shared(type, shape)); } const size_t convOutCh2 = 16; - auto conv2 = ngraph::builder::makeConvolution(params2.front(), type, kernel, strides, padsBegin, padsEnd, dilations, autoPad, convOutCh2); + auto conv2 = ov::test::utils::make_convolution(params2.front(), + type, + kernel, + strides, + padsBegin, + padsEnd, + dilations, + autoPad, + convOutCh2); conv2->set_friendly_name(convName); conv2->get_input_node_shared_ptr(1)->set_friendly_name(weightName); auto model2 = makeNgraphFunction(type, params2, conv2, "Model2"); @@ -78,4 +95,5 @@ TEST_F(EdgeWithSameNameInTwoModels, smoke_CompareWithRef) { inferReq2.infer(); } -} // namespace SubgraphTestsDefinitions +} // namespace test +} // namespace ov diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/mha.cpp b/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/mha.cpp index 068585b2ca9029..66bcb7baf5b744 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/mha.cpp +++ b/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/mha.cpp @@ -2,49 +2,41 @@ // SPDX-License-Identifier: Apache-2.0 // -#include -#include -#include -#include -#include -#include -#include #include "common_test_utils/common_utils.hpp" -#include +#include "common_test_utils/ov_tensor_utils.hpp" #include "functional_test_utils/skip_tests_config.hpp" +#include "ov_models/builders.hpp" +#include "shared_test_classes/base/ov_subgraph.hpp" #include "test_utils/cpu_test_utils.hpp" -#include "cpp_interfaces/interface/ie_internal_plugin_config.hpp" using namespace CPUTestUtils; using namespace ov::test; -using namespace ngraph::helpers; - -namespace CPUSubgraphTestsDefinitions { using ExpectedNodes = std::vector>; -typedef std::tuple< - std::vector, // Input shapes - std::vector, // Input precisions - std::vector, // MatMul input #0 precisions - size_t, // pattern type # - ExpectedNodes, // Expected node -> count - std::string // Device name -> MHATuple; +typedef std::tuple, // Input shapes + std::vector, // Input precisions + std::vector, // MatMul input #0 precisions + size_t, // pattern type # + ExpectedNodes, // Expected node -> count + std::string // Device name + > + MHATuple; -static std::shared_ptr initMHASubgraph0(std::vector& inputDynamicShapes, std::vector& inputPrecisions) { - ngraph::ParameterVector ngraphParam; +static std::shared_ptr initMHASubgraph0(std::vector& inputDynamicShapes, + std::vector& inputPrecisions) { + ov::ParameterVector ngraphParam; - auto transpose0Param = std::make_shared(inputPrecisions[0], inputDynamicShapes[0]); + auto transpose0Param = std::make_shared(inputPrecisions[0], inputDynamicShapes[0]); ngraphParam.push_back(transpose0Param); - auto transpose1Param = std::make_shared(inputPrecisions[1], inputDynamicShapes[1]); + auto transpose1Param = std::make_shared(inputPrecisions[1], inputDynamicShapes[1]); ngraphParam.push_back(transpose1Param); - auto addParam = std::make_shared(inputPrecisions[2], inputDynamicShapes[2]); + auto addParam = std::make_shared(inputPrecisions[2], inputDynamicShapes[2]); ngraphParam.push_back(addParam); - auto transpose2Param = std::make_shared(inputPrecisions[3], inputDynamicShapes[3]); + auto transpose2Param = std::make_shared(inputPrecisions[3], inputDynamicShapes[3]); ngraphParam.push_back(transpose2Param); std::vector constantShapes; @@ -62,12 +54,13 @@ static std::shared_ptr initMHASubgraph0(std::vector std::vector transpose1ConstData = {0, 2, 3, 1}; auto transpose1Const = ngraph::builder::makeConstant(ElementType::i64, constantShapes[1], transpose1ConstData); - std::vector mulConstData(ngraph::shape_size(constantShapes[2])); + std::vector mulConstData(ov::shape_size(constantShapes[2])); auto mulConst = ngraph::builder::makeConstant(inputPrecisions[0], constantShapes[2], mulConstData, true); - std::vector reshape0ConstData = {static_cast(inputDynamicShapes[0].get_shape()[0] * - inputDynamicShapes[0].get_shape()[1] * inputDynamicShapes[0].get_shape()[2]), - -1}; + std::vector reshape0ConstData = { + static_cast(inputDynamicShapes[0].get_shape()[0] * inputDynamicShapes[0].get_shape()[1] * + inputDynamicShapes[0].get_shape()[2]), + -1}; auto reshape0Const = ngraph::builder::makeConstant(ElementType::i64, constantShapes[3], reshape0ConstData); std::vector reshape1ConstData = {static_cast(inputDynamicShapes[0].get_shape()[0]), @@ -86,33 +79,34 @@ static std::shared_ptr initMHASubgraph0(std::vector float transB = false; const auto transpose0 = std::make_shared(transpose0Param, transpose0Const); const auto transpose1 = std::make_shared(transpose1Param, transpose1Const); - const auto mul = std::make_shared(transpose1, mulConst); - const auto matMul0 = std::make_shared(transpose0, mul, transA, transB); - const auto add = std::make_shared(matMul0, addParam); - const auto reshape0 = std::make_shared(add, reshape0Const, true); - const auto softMax = std::make_shared(reshape0, 1); - const auto reshape1 = std::make_shared(softMax, reshape1Const, true); + const auto mul = std::make_shared(transpose1, mulConst); + const auto matMul0 = std::make_shared(transpose0, mul, transA, transB); + const auto add = std::make_shared(matMul0, addParam); + const auto reshape0 = std::make_shared(add, reshape0Const, true); + const auto softMax = std::make_shared(reshape0, 1); + const auto reshape1 = std::make_shared(softMax, reshape1Const, true); const auto transpose2 = std::make_shared(transpose2Param, transpose2Const); - const auto matMul1 = std::make_shared(reshape1, transpose2, transA, transB); + const auto matMul1 = std::make_shared(reshape1, transpose2, transA, transB); const auto transpose3 = std::make_shared(matMul1, transpose3Const); - ngraph::ResultVector results{std::make_shared(transpose3)}; - return std::make_shared(results, ngraphParam, "mha"); + ov::ResultVector results{std::make_shared(transpose3)}; + return std::make_shared(results, ngraphParam, "mha"); } -static std::shared_ptr initMHASubgraph1(std::vector& inputDynamicShapes, std::vector& inputPrecisions) { - ngraph::ParameterVector ngraphParam; +static std::shared_ptr initMHASubgraph1(std::vector& inputDynamicShapes, + std::vector& inputPrecisions) { + ov::ParameterVector ngraphParam; - auto transpose0Param = std::make_shared(inputPrecisions[0], inputDynamicShapes[0]); + auto transpose0Param = std::make_shared(inputPrecisions[0], inputDynamicShapes[0]); ngraphParam.push_back(transpose0Param); - auto transpose1Param = std::make_shared(inputPrecisions[1], inputDynamicShapes[1]); + auto transpose1Param = std::make_shared(inputPrecisions[1], inputDynamicShapes[1]); ngraphParam.push_back(transpose1Param); - auto addParam = std::make_shared(inputPrecisions[2], inputDynamicShapes[2]); + auto addParam = std::make_shared(inputPrecisions[2], inputDynamicShapes[2]); ngraphParam.push_back(addParam); - auto transpose2Param = std::make_shared(inputPrecisions[3], inputDynamicShapes[3]); + auto transpose2Param = std::make_shared(inputPrecisions[3], inputDynamicShapes[3]); ngraphParam.push_back(transpose2Param); std::vector constantShapes; @@ -140,21 +134,20 @@ static std::shared_ptr initMHASubgraph1(std::vector float transB = false; const auto transpose0 = std::make_shared(transpose0Param, transpose0Const); const auto transpose1 = std::make_shared(transpose1Param, transpose1Const); - const auto matMul0 = std::make_shared(transpose0, transpose1, transA, transB); - const auto add = std::make_shared(matMul0, addParam); - const auto softMax = std::make_shared(add, 3); + const auto matMul0 = std::make_shared(transpose0, transpose1, transA, transB); + const auto add = std::make_shared(matMul0, addParam); + const auto softMax = std::make_shared(add, 3); const auto transpose2 = std::make_shared(transpose2Param, transpose2Const); - const auto matMul1 = std::make_shared(softMax, transpose2, transA, transB); + const auto matMul1 = std::make_shared(softMax, transpose2, transA, transB); const auto transpose3 = std::make_shared(matMul1, transpose3Const); - ngraph::ResultVector results{std::make_shared(transpose3)}; - return std::make_shared(results, ngraphParam, "mha"); + ov::ResultVector results{std::make_shared(transpose3)}; + return std::make_shared(results, ngraphParam, "mha"); } -class MHATest : public testing::WithParamInterface, - virtual public SubgraphBaseTest, public CPUTestsBase { +class MHATest : public testing::WithParamInterface, virtual public SubgraphBaseTest, public CPUTestsBase { public: - static std::string getTestCaseName(const testing::TestParamInfo &obj) { + static std::string getTestCaseName(const testing::TestParamInfo& obj) { std::vector inputShapes; std::vector inputPrecisions; std::vector matMulIn0Precisions; @@ -180,23 +173,31 @@ class MHATest : public testing::WithParamInterface, results << "patternType=" << patternType; results << "expect="; for (const auto& node : expectedNodes) { - results << node.first << "[" << node.second << "]" << "_"; + results << node.first << "[" << node.second << "]" + << "_"; } results << "targetDevice=" << targetName; return results.str(); } - void generate_inputs(const std::vector& targetInputStaticShapes) override { + 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 (funcInput.get_element_type() == ov::element::bf16) - tensor = ov::test::utils::create_and_fill_tensor(funcInput.get_element_type(), targetInputStaticShapes[i], 2, -1, 256); + tensor = ov::test::utils::create_and_fill_tensor(funcInput.get_element_type(), + targetInputStaticShapes[i], + 2, + -1, + 256); else - tensor = ov::test::utils::create_and_fill_tensor_unique_sequence(funcInput.get_element_type(), targetInputStaticShapes[i], -1, 5); + tensor = ov::test::utils::create_and_fill_tensor_unique_sequence(funcInput.get_element_type(), + targetInputStaticShapes[i], + -1, + 5); inputs.insert({funcInput.get_node_shared_ptr(), tensor}); inputs.insert({funcInput.get_node_shared_ptr(), tensor}); } @@ -209,7 +210,8 @@ class MHATest : public testing::WithParamInterface, std::vector inputShapes; std::vector inputPrecisions; std::vector matMulIn0Precisions; - std::tie(inputShapes, inputPrecisions, matMulIn0Precisions, patternType, expectedNodes, targetDevice) = this->GetParam(); + std::tie(inputShapes, inputPrecisions, matMulIn0Precisions, patternType, expectedNodes, targetDevice) = + this->GetParam(); init_input_shapes(inputShapes); @@ -227,14 +229,14 @@ class MHATest : public testing::WithParamInterface, abs_threshold = 0.1f; rel_threshold = 10.f; - configuration.insert({{ InferenceEngine::PluginConfigParams::KEY_ENFORCE_BF16, InferenceEngine::PluginConfigParams::YES }}); + configuration.insert({ov::hint::inference_precision(ov::element::bf16)}); } - // Snippets MHA tokenization has limitations to avoid performance degradations. These limitations depend on target machine. - // Just for testing, we disable these limitations to allow Snippets to tokenize pattern on all machines for validation. - if (!configuration.count(InferenceEngine::PluginConfigInternalParams::KEY_SNIPPETS_MODE)) { - configuration.insert({InferenceEngine::PluginConfigInternalParams::KEY_SNIPPETS_MODE, - InferenceEngine::PluginConfigInternalParams::IGNORE_CALLBACK}); + // Snippets MHA tokenization has limitations to avoid performance degradations. These limitations depend on + // target machine. Just for testing, we disable these limitations to allow Snippets to tokenize pattern on all + // machines for validation. + if (!configuration.count("SNIPPETS_MODE")) { + configuration.insert({"SNIPPETS_MODE", "IGNORE_CALLBACK"}); } } }; @@ -245,12 +247,13 @@ TEST_P(MHATest, CompareWithRefs) { std::vector matMulIn0Precisions; size_t patternType; ExpectedNodes expectedNodes; - std::tie(inputShapes, inputPrecisions, matMulIn0Precisions, patternType, expectedNodes, targetDevice) = this->GetParam(); + std::tie(inputShapes, inputPrecisions, matMulIn0Precisions, patternType, expectedNodes, targetDevice) = + this->GetParam(); - if (inputPrecisions[0] == ElementType::bf16 && !InferenceEngine::with_cpu_x86_bfloat16()) + if (inputPrecisions[0] == ElementType::bf16 && !ov::with_cpu_x86_bfloat16()) GTEST_SKIP(); - if (!InferenceEngine::with_cpu_x86_avx512_core()) + if (!ov::with_cpu_x86_avx512_core()) GTEST_SKIP(); run(); @@ -262,61 +265,66 @@ TEST_P(MHATest, CompareWithRefs) { namespace { -std::vector> inputShapes = { +std::vector> inputShapes = { {{2, 8, 16, 64}, {2, 8, 16, 64}, {2, 1, 1, 8}, {2, 8, 16, 64}}, {{1, 384, 16, 64}, {1, 384, 16, 64}, {1, 1, 1, 384}, {1, 384, 16, 64}}, {{2, 64, 16, 80}, {2, 64, 16, 80}, {2, 1, 1, 64}, {2, 64, 16, 80}}, {{3, 96, 16, 64}, {3, 96, 16, 64}, {3, 1, 1, 96}, {3, 96, 16, 64}}, {{2, 192, 16, 160}, {2, 192, 16, 160}, {2, 1, 1, 192}, {2, 192, 16, 160}}, {{2, 4, 16, 8}, {2, 4, 16, 8}, {2, 1, 1, 4}, {2, 4, 16, 8}}, - {{1, 204, 13, 212}, {1, 204, 13, 212}, {1, 1, 1, 204}, {1, 204, 13, 212}}, + {{1, 204, 13, 212}, {1, 204, 13, 212}, {1, 1, 1, 204}, {1, 204, 13, 212}}, }; std::vector> matMulIn0Precisions = { {}, }; -std::vector patternTypes = { - 0, 1 -}; - -INSTANTIATE_TEST_SUITE_P(smoke_MHA, MHATest, - ::testing::Combine( - ::testing::ValuesIn(static_shapes_to_test_representation(inputShapes)), - ::testing::Values(std::vector{ ElementType::f32, ElementType::f32, ElementType::f32, ElementType::f32 }), - ::testing::ValuesIn(matMulIn0Precisions), - ::testing::ValuesIn(patternTypes), - ::testing::Values(ExpectedNodes{{"Subgraph", 1}}), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - MHATest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_MHA_BF16, MHATest, - ::testing::Combine( - ::testing::ValuesIn(static_shapes_to_test_representation(inputShapes)), - ::testing::Values(std::vector{ ElementType::bf16, ElementType::bf16, ElementType::bf16, ElementType::bf16 }), - ::testing::ValuesIn(matMulIn0Precisions), - ::testing::ValuesIn(patternTypes), - ::testing::Values(ExpectedNodes{{"Subgraph", 1}, - {"Transpose", 1}}), // Plugin disables tokenization of Transpose on output - ::testing::Values(ov::test::utils::DEVICE_CPU)), +std::vector patternTypes = {0, 1}; + +INSTANTIATE_TEST_SUITE_P(smoke_MHA, + MHATest, + ::testing::Combine(::testing::ValuesIn(static_shapes_to_test_representation(inputShapes)), + ::testing::Values(std::vector{ElementType::f32, + ElementType::f32, + ElementType::f32, + ElementType::f32}), + ::testing::ValuesIn(matMulIn0Precisions), + ::testing::ValuesIn(patternTypes), + ::testing::Values(ExpectedNodes{{"Subgraph", 1}}), + ::testing::Values(ov::test::utils::DEVICE_CPU)), MHATest::getTestCaseName); -} // namespace - -static std::shared_ptr initMHAQuantSubgraph0(std::vector& inputDynamicShapes, std::vector& inputPrecisions, +INSTANTIATE_TEST_SUITE_P( + smoke_MHA_BF16, + MHATest, + ::testing::Combine( + ::testing::ValuesIn(static_shapes_to_test_representation(inputShapes)), + ::testing::Values( + std::vector{ElementType::bf16, ElementType::bf16, ElementType::bf16, ElementType::bf16}), + ::testing::ValuesIn(matMulIn0Precisions), + ::testing::ValuesIn(patternTypes), + ::testing::Values(ExpectedNodes{{"Subgraph", 1}, + {"Transpose", 1}}), // Plugin disables tokenization of Transpose on output + ::testing::Values(ov::test::utils::DEVICE_CPU)), + MHATest::getTestCaseName); + +} // namespace + +static std::shared_ptr initMHAQuantSubgraph0(std::vector& inputDynamicShapes, + std::vector& inputPrecisions, std::vector& matMulIn0Precisions) { - ngraph::ParameterVector ngraphParam; + ov::ParameterVector ngraphParam; - auto transpose0Param = std::make_shared(inputPrecisions[0], inputDynamicShapes[0]); + auto transpose0Param = std::make_shared(inputPrecisions[0], inputDynamicShapes[0]); ngraphParam.push_back(transpose0Param); - auto transpose1Param = std::make_shared(inputPrecisions[1], inputDynamicShapes[1]); + auto transpose1Param = std::make_shared(inputPrecisions[1], inputDynamicShapes[1]); ngraphParam.push_back(transpose1Param); - auto addParam = std::make_shared(inputPrecisions[2], inputDynamicShapes[2]); + auto addParam = std::make_shared(inputPrecisions[2], inputDynamicShapes[2]); ngraphParam.push_back(addParam); - auto transpose2Param = std::make_shared(inputPrecisions[3], inputDynamicShapes[3]); + auto transpose2Param = std::make_shared(inputPrecisions[3], inputDynamicShapes[3]); ngraphParam.push_back(transpose2Param); std::vector constantShapes; @@ -333,9 +341,10 @@ static std::shared_ptr initMHAQuantSubgraph0(std::vector transpose1ConstData = {0, 2, 3, 1}; auto transpose1Const = ngraph::builder::makeConstant(ElementType::i64, constantShapes[1], transpose1ConstData); - std::vector reshape0ConstData = {static_cast(inputDynamicShapes[0].get_shape()[0] * - inputDynamicShapes[0].get_shape()[1] * inputDynamicShapes[0].get_shape()[2]), - -1}; + std::vector reshape0ConstData = { + static_cast(inputDynamicShapes[0].get_shape()[0] * inputDynamicShapes[0].get_shape()[1] * + inputDynamicShapes[0].get_shape()[2]), + -1}; auto reshape0Const = ngraph::builder::makeConstant(ElementType::i64, constantShapes[2], reshape0ConstData); std::vector reshape1ConstData = {static_cast(inputDynamicShapes[0].get_shape()[0]), @@ -355,52 +364,96 @@ static std::shared_ptr initMHAQuantSubgraph0(std::vector fakeQuantize0; if (matMulIn0Precisions[0] == ElementType::u8) - fakeQuantize0 = ngraph::builder::makeFakeQuantize(transpose0Param, inputPrecisions[0], 256, {}, {0.0f}, {2.55f}, {0.0f}, {2.55f}); + fakeQuantize0 = ngraph::builder::makeFakeQuantize(transpose0Param, + inputPrecisions[0], + 256, + {}, + {0.0f}, + {2.55f}, + {0.0f}, + {2.55f}); else - fakeQuantize0 = ngraph::builder::makeFakeQuantize(transpose0Param, inputPrecisions[0], 256, {}, {-1.28f}, {1.27f}, {-1.28f}, {1.27f}); - - const auto fakeQuantize1 = ngraph::builder::makeFakeQuantize(transpose1Param, inputPrecisions[1], 256, {}, {-1.28f}, {1.27f}, {-1.28f}, {1.27f}); - const auto fakeQuantize2 = ngraph::builder::makeFakeQuantize(transpose2Param, inputPrecisions[3], 256, {}, {-1.28f}, {1.27f}, {-1.28f}, {1.27f}); + fakeQuantize0 = ngraph::builder::makeFakeQuantize(transpose0Param, + inputPrecisions[0], + 256, + {}, + {-1.28f}, + {1.27f}, + {-1.28f}, + {1.27f}); + + const auto fakeQuantize1 = ngraph::builder::makeFakeQuantize(transpose1Param, + inputPrecisions[1], + 256, + {}, + {-1.28f}, + {1.27f}, + {-1.28f}, + {1.27f}); + const auto fakeQuantize2 = ngraph::builder::makeFakeQuantize(transpose2Param, + inputPrecisions[3], + 256, + {}, + {-1.28f}, + {1.27f}, + {-1.28f}, + {1.27f}); std::shared_ptr fakeQuantize4; const auto transpose0 = std::make_shared(fakeQuantize0, transpose0Const); const auto transpose1 = std::make_shared(fakeQuantize1, transpose1Const); - const auto matMul0 = std::make_shared(transpose0, transpose1, transA, transB); - const auto fakeQuantize3 = ngraph::builder::makeFakeQuantize(matMul0, inputPrecisions[0], 256, {}, {-1.28f}, {1.27f}, {-1.28f}, {1.27f}); - const auto add = std::make_shared(fakeQuantize3, addParam); - const auto reshape0 = std::make_shared(add, reshape0Const, true); - const auto softMax = std::make_shared(reshape0, 1); - const auto reshape1 = std::make_shared(softMax, reshape1Const, true); + const auto matMul0 = std::make_shared(transpose0, transpose1, transA, transB); + const auto fakeQuantize3 = + ngraph::builder::makeFakeQuantize(matMul0, inputPrecisions[0], 256, {}, {-1.28f}, {1.27f}, {-1.28f}, {1.27f}); + const auto add = std::make_shared(fakeQuantize3, addParam); + const auto reshape0 = std::make_shared(add, reshape0Const, true); + const auto softMax = std::make_shared(reshape0, 1); + const auto reshape1 = std::make_shared(softMax, reshape1Const, true); if (matMulIn0Precisions[1] == ElementType::u8) - fakeQuantize4 = ngraph::builder::makeFakeQuantize(reshape1, inputPrecisions[0], 256, {}, {0.0f}, {0.255f}, {0.0f}, {0.255f}); + fakeQuantize4 = ngraph::builder::makeFakeQuantize(reshape1, + inputPrecisions[0], + 256, + {}, + {0.0f}, + {0.255f}, + {0.0f}, + {0.255f}); else - fakeQuantize4 = ngraph::builder::makeFakeQuantize(reshape1, inputPrecisions[0], 256, {}, {-0.128f}, {0.127f}, {-0.128f}, {0.127f}); + fakeQuantize4 = ngraph::builder::makeFakeQuantize(reshape1, + inputPrecisions[0], + 256, + {}, + {-0.128f}, + {0.127f}, + {-0.128f}, + {0.127f}); const auto transpose2 = std::make_shared(fakeQuantize2, transpose2Const); - const auto matMul1 = std::make_shared(fakeQuantize4, transpose2, transA, transB); - const auto fakeQuantize5 = ngraph::builder::makeFakeQuantize(matMul1, inputPrecisions[0], 256, {}, {-1.28f}, {1.27f}, {-1.28f}, {1.27f}); + const auto matMul1 = std::make_shared(fakeQuantize4, transpose2, transA, transB); + const auto fakeQuantize5 = + ngraph::builder::makeFakeQuantize(matMul1, inputPrecisions[0], 256, {}, {-1.28f}, {1.27f}, {-1.28f}, {1.27f}); const auto transpose3 = std::make_shared(fakeQuantize5, transpose3Const); - ngraph::ResultVector results{std::make_shared(transpose3)}; - return std::make_shared(results, ngraphParam, "mha"); + ov::ResultVector results{std::make_shared(transpose3)}; + return std::make_shared(results, ngraphParam, "mha"); } static std::shared_ptr initMHAQuantSubgraph1(const std::vector& inputDynamicShapes, const std::vector& inputPrecisions, const std::vector& matMulIn0Precisions, const bool fakeQuantize3Exists) { - ngraph::ParameterVector ngraphParam; + ov::ParameterVector ngraphParam; - auto transpose0Param = std::make_shared(inputPrecisions[0], inputDynamicShapes[0]); + auto transpose0Param = std::make_shared(inputPrecisions[0], inputDynamicShapes[0]); ngraphParam.push_back(transpose0Param); - auto transpose1Param = std::make_shared(inputPrecisions[1], inputDynamicShapes[1]); + auto transpose1Param = std::make_shared(inputPrecisions[1], inputDynamicShapes[1]); ngraphParam.push_back(transpose1Param); - auto addParam = std::make_shared(inputPrecisions[2], inputDynamicShapes[2]); + auto addParam = std::make_shared(inputPrecisions[2], inputDynamicShapes[2]); ngraphParam.push_back(addParam); - auto transpose2Param = std::make_shared(inputPrecisions[3], inputDynamicShapes[3]); + auto transpose2Param = std::make_shared(inputPrecisions[3], inputDynamicShapes[3]); ngraphParam.push_back(transpose2Param); std::vector constantShapes; @@ -422,7 +475,7 @@ static std::shared_ptr initMHAQuantSubgraph1(const std::vector transpose3ConstData = {0, 2, 1, 3}; auto transpose3Const = ngraph::builder::makeConstant(ElementType::i64, constantShapes[3], transpose3ConstData); - std::vector mulConstData(ngraph::shape_size(constantShapes[4])); + std::vector mulConstData(ov::shape_size(constantShapes[4])); auto mulConst = ngraph::builder::makeConstant(inputPrecisions[0], constantShapes[4], mulConstData, true); float transA = false; @@ -430,33 +483,55 @@ static std::shared_ptr initMHAQuantSubgraph1(const std::vector fakeQuantize0; if (matMulIn0Precisions[0] == ElementType::u8) - fakeQuantize0 = ngraph::builder::makeFakeQuantize(transpose0Param, inputPrecisions[0], 256, {}, {0.0f}, {2.55f}, {0.0f}, {2.55f}); + fakeQuantize0 = ngraph::builder::makeFakeQuantize(transpose0Param, + inputPrecisions[0], + 256, + {}, + {0.0f}, + {2.55f}, + {0.0f}, + {2.55f}); else - fakeQuantize0 = ngraph::builder::makeFakeQuantize(transpose0Param, inputPrecisions[0], 256, {}, {-1.28f}, {1.27f}, {-1.28f}, {1.27f}); + fakeQuantize0 = ngraph::builder::makeFakeQuantize(transpose0Param, + inputPrecisions[0], + 256, + {}, + {-1.28f}, + {1.27f}, + {-1.28f}, + {1.27f}); const auto transpose0 = std::make_shared(fakeQuantize0, transpose0Const); const auto transpose1 = std::make_shared(transpose1Param, transpose1Const); - const auto fakeQuantize1 = ngraph::builder::makeFakeQuantize(transpose1, inputPrecisions[1], 256, {}, {-1.28f}, {1.27f}, {-1.28f}, {1.27f}); - const auto matMul0 = std::make_shared(transpose0, fakeQuantize1, transA, transB); - const auto mul = std::make_shared(addParam, mulConst); - const auto add = std::make_shared(matMul0, mul); - const auto softMax = std::make_shared(add, 3); + const auto fakeQuantize1 = ngraph::builder::makeFakeQuantize(transpose1, + inputPrecisions[1], + 256, + {}, + {-1.28f}, + {1.27f}, + {-1.28f}, + {1.27f}); + const auto matMul0 = std::make_shared(transpose0, fakeQuantize1, transA, transB); + const auto mul = std::make_shared(addParam, mulConst); + const auto add = std::make_shared(matMul0, mul); + const auto softMax = std::make_shared(add, 3); const auto transpose2 = std::make_shared(transpose2Param, transpose2Const); - const auto matMul1 = std::make_shared(softMax, transpose2, transA, transB); + const auto matMul1 = std::make_shared(softMax, transpose2, transA, transB); const auto transpose3 = std::make_shared( - fakeQuantize3Exists ? - ngraph::builder::makeFakeQuantize(matMul1, inputPrecisions[0], 256, {}, { 0.0f }, { 2.55f }, { 0.0f }, { 2.55f }) : - matMul1, + fakeQuantize3Exists + ? ngraph::builder::makeFakeQuantize(matMul1, inputPrecisions[0], 256, {}, {0.0f}, {2.55f}, {0.0f}, {2.55f}) + : matMul1, transpose3Const); - ngraph::ResultVector results{std::make_shared(transpose3)}; - return std::make_shared(results, ngraphParam, "mha"); + ov::ResultVector results{std::make_shared(transpose3)}; + return std::make_shared(results, ngraphParam, "mha"); } class MHAQuantTest : public testing::WithParamInterface, - virtual public SubgraphBaseTest, public CPUTestsBase { + virtual public SubgraphBaseTest, + public CPUTestsBase { public: - static std::string getTestCaseName(const testing::TestParamInfo &obj) { + static std::string getTestCaseName(const testing::TestParamInfo& obj) { std::vector inputShapes; std::vector inputPrecisions; std::vector matMulIn0Precisions; @@ -485,24 +560,31 @@ class MHAQuantTest : public testing::WithParamInterface, results << "patternType=" << patternType; results << "expect="; for (const auto& node : expectedNodes) { - results << node.first << "[" << node.second << "]" << "_"; + results << node.first << "[" << node.second << "]" + << "_"; } results << "targetDevice=" << targetName; return results.str(); } - void generate_inputs(const std::vector& targetInputStaticShapes) override { + 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 (funcInput.get_element_type().is_real()) - tensor = ov::test::utils::create_and_fill_tensor_normal_distribution(funcInput.get_element_type(), targetInputStaticShapes[i], 0.0f, 1.5f); + tensor = ov::test::utils::create_and_fill_tensor_normal_distribution(funcInput.get_element_type(), + targetInputStaticShapes[i], + 0.0f, + 1.5f); else - tensor = ov::test::utils::create_and_fill_tensor(funcInput.get_element_type(), targetInputStaticShapes[i], 255, 0, 1); - + tensor = ov::test::utils::create_and_fill_tensor(funcInput.get_element_type(), + targetInputStaticShapes[i], + 255, + 0, + 1); inputs.insert({funcInput.get_node_shared_ptr(), tensor}); } @@ -517,7 +599,8 @@ class MHAQuantTest : public testing::WithParamInterface, std::vector matMulIn0Precisions; size_t patternType; ExpectedNodes expectedNodes; - std::tie(inputShapes, inputPrecisions, matMulIn0Precisions, patternType, expectedNodes, targetDevice) = this->GetParam(); + std::tie(inputShapes, inputPrecisions, matMulIn0Precisions, patternType, expectedNodes, targetDevice) = + this->GetParam(); init_input_shapes(inputShapes); @@ -531,11 +614,11 @@ class MHAQuantTest : public testing::WithParamInterface, FAIL() << "Unsupported MHA pattern type"; } - // Snippets MHA tokenization has limitations to avoid performance degradations. These limitations depend on target machine. - // Just for testing, we disable these limitations to allow Snippets to tokenize pattern on all machines for validation. - if (!configuration.count(InferenceEngine::PluginConfigInternalParams::KEY_SNIPPETS_MODE)) { - configuration.insert({InferenceEngine::PluginConfigInternalParams::KEY_SNIPPETS_MODE, - InferenceEngine::PluginConfigInternalParams::IGNORE_CALLBACK}); + // Snippets MHA tokenization has limitations to avoid performance degradations. These limitations depend on + // target machine. Just for testing, we disable these limitations to allow Snippets to tokenize pattern on all + // machines for validation. + if (!configuration.count("SNIPPETS_MODE")) { + configuration.insert({"SNIPPETS_MODE", "IGNORE_CALLBACK"}); } } }; @@ -546,12 +629,13 @@ TEST_P(MHAQuantTest, CompareWithRefs) { std::vector matMulIn0Precisions; size_t patternType; ExpectedNodes expectedNodes; - std::tie(inputShapes, inputPrecisions, matMulIn0Precisions, patternType, expectedNodes, targetDevice) = this->GetParam(); + std::tie(inputShapes, inputPrecisions, matMulIn0Precisions, patternType, expectedNodes, targetDevice) = + this->GetParam(); - if (inputPrecisions[0] == ElementType::bf16 && !InferenceEngine::with_cpu_x86_bfloat16()) + if (inputPrecisions[0] == ElementType::bf16 && !ov::with_cpu_x86_bfloat16()) GTEST_SKIP(); - if (!InferenceEngine::with_cpu_x86_avx512_core_vnni()) + if (!ov::with_cpu_x86_avx512_core_vnni()) GTEST_SKIP(); run(); @@ -563,7 +647,7 @@ TEST_P(MHAQuantTest, CompareWithRefs) { namespace { -std::vector> inputShapesQuant = { +std::vector> inputShapesQuant = { {{2, 7, 16, 9}, {2, 7, 16, 9}, {2, 1, 1, 7}, {2, 7, 16, 9}}, {{2, 8, 16, 64}, {2, 8, 16, 64}, {2, 1, 1, 8}, {2, 8, 16, 64}}, {{1, 384, 16, 64}, {1, 384, 16, 64}, {1, 1, 1, 384}, {1, 384, 16, 64}}, @@ -571,52 +655,52 @@ std::vector> inputShapesQuant = { {{3, 96, 16, 64}, {3, 96, 16, 64}, {3, 1, 1, 96}, {3, 96, 16, 64}}, {{2, 192, 16, 160}, {2, 192, 16, 160}, {2, 1, 1, 192}, {2, 192, 16, 160}}, {{2, 4, 16, 8}, {2, 4, 16, 8}, {2, 1, 1, 4}, {2, 4, 16, 8}}, - {{1, 204, 13, 212}, {1, 204, 13, 212}, {1, 1, 1, 204}, {1, 204, 13, 212}}, - {{1, 207, 13, 211}, {1, 207, 13, 211}, {1, 1, 1, 207}, {1, 207, 13, 211}}, + {{1, 204, 13, 212}, {1, 204, 13, 212}, {1, 1, 1, 204}, {1, 204, 13, 212}}, + {{1, 207, 13, 211}, {1, 207, 13, 211}, {1, 1, 1, 207}, {1, 207, 13, 211}}, }; std::vector> inputPrecisionsQuant = { - { ElementType::f32, ElementType::f32, ElementType::f32, ElementType::f32 }, + {ElementType::f32, ElementType::f32, ElementType::f32, ElementType::f32}, }; std::vector> matMulIn0PrecisionsQuant = { - { ElementType::i8, ElementType::i8 }, - { ElementType::i8, ElementType::u8 }, + {ElementType::i8, ElementType::i8}, + {ElementType::i8, ElementType::u8}, }; -INSTANTIATE_TEST_SUITE_P(smoke_MHAQuant_Pattern0, MHAQuantTest, - ::testing::Combine( - ::testing::ValuesIn(static_shapes_to_test_representation(inputShapesQuant)), - ::testing::ValuesIn(inputPrecisionsQuant), - ::testing::ValuesIn(matMulIn0PrecisionsQuant), - ::testing::Values(0), - ::testing::Values(ExpectedNodes{{"Subgraph", 5}, // FQs on inputs x 3 + MHA + Deq Mul - {"Transpose", 1}}), // Transpose between MHA and Deq Mul - ::testing::Values(ov::test::utils::DEVICE_CPU)), - MHAQuantTest::getTestCaseName); - - -INSTANTIATE_TEST_SUITE_P(smoke_MHAQuant_Pattern1, MHAQuantTest, - ::testing::Combine( - ::testing::ValuesIn(static_shapes_to_test_representation(inputShapesQuant)), - ::testing::ValuesIn(inputPrecisionsQuant), - ::testing::ValuesIn(matMulIn0PrecisionsQuant), - ::testing::Values(1), - ::testing::Values(ExpectedNodes{{"Subgraph", 3}, // FQ on input + MHA + Deq Mul - {"Transpose", 1}}), // Transpose between MHA and Deq Mul - ::testing::Values(ov::test::utils::DEVICE_CPU)), - MHAQuantTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_MHAQuant_Pattern2, MHAQuantTest, - ::testing::Combine( - ::testing::ValuesIn(static_shapes_to_test_representation(inputShapesQuant)), - ::testing::ValuesIn(inputPrecisionsQuant), - ::testing::ValuesIn(matMulIn0PrecisionsQuant), - ::testing::Values(2), - ::testing::Values(ExpectedNodes{{"Subgraph", 2}, // MHA + Deq Mul - {"Transpose", 0}}), // Transpose is fused - ::testing::Values(ov::test::utils::DEVICE_CPU)), - MHAQuantTest::getTestCaseName); - -} // namespace -} // namespace CPUSubgraphTestsDefinitions +INSTANTIATE_TEST_SUITE_P(smoke_MHAQuant_Pattern0, + MHAQuantTest, + ::testing::Combine(::testing::ValuesIn(static_shapes_to_test_representation(inputShapesQuant)), + ::testing::ValuesIn(inputPrecisionsQuant), + ::testing::ValuesIn(matMulIn0PrecisionsQuant), + ::testing::Values(0), + ::testing::Values(ExpectedNodes{ + {"Subgraph", 5}, // FQs on inputs x 3 + MHA + Deq Mul + {"Transpose", 1}}), // Transpose between MHA and Deq Mul + ::testing::Values(ov::test::utils::DEVICE_CPU)), + MHAQuantTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_MHAQuant_Pattern1, + MHAQuantTest, + ::testing::Combine(::testing::ValuesIn(static_shapes_to_test_representation(inputShapesQuant)), + ::testing::ValuesIn(inputPrecisionsQuant), + ::testing::ValuesIn(matMulIn0PrecisionsQuant), + ::testing::Values(1), + ::testing::Values(ExpectedNodes{ + {"Subgraph", 3}, // FQ on input + MHA + Deq Mul + {"Transpose", 1}}), // Transpose between MHA and Deq Mul + ::testing::Values(ov::test::utils::DEVICE_CPU)), + MHAQuantTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_MHAQuant_Pattern2, + MHAQuantTest, + ::testing::Combine(::testing::ValuesIn(static_shapes_to_test_representation(inputShapesQuant)), + ::testing::ValuesIn(inputPrecisionsQuant), + ::testing::ValuesIn(matMulIn0PrecisionsQuant), + ::testing::Values(2), + ::testing::Values(ExpectedNodes{{"Subgraph", 2}, // MHA + Deq Mul + {"Transpose", 0}}), // Transpose is fused + ::testing::Values(ov::test::utils::DEVICE_CPU)), + MHAQuantTest::getTestCaseName); + +} // namespace diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/ngram.cpp b/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/ngram.cpp index 58edce33fcda60..865268c500a31b 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/ngram.cpp +++ b/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/ngram.cpp @@ -2,46 +2,37 @@ // SPDX-License-Identifier: Apache-2.0 // -#include -#include -#include -#include -#include -#include -#include #include "common_test_utils/common_utils.hpp" -#include +#include "common_test_utils/ov_tensor_utils.hpp" +#include "shared_test_classes/base/ov_subgraph.hpp" #include "test_utils/cpu_test_utils.hpp" -#include -#include "cpp_interfaces/interface/ie_internal_plugin_config.hpp" using namespace CPUTestUtils; -using namespace ov::test; -using namespace ngraph::helpers; -namespace CPUSubgraphTestsDefinitions { +namespace ov { +namespace test { -typedef std::tuple< - std::vector, - ElementType, - ElementType, - size_t -> NgramTestParams; +typedef std::tuple, ElementType, ElementType, size_t> NgramTestParams; static std::shared_ptr getStridedSlice(const std::shared_ptr& data, const std::shared_ptr& begin, const std::shared_ptr& end, const std::vector& shrink_axis_mask = {}) { std::vector default_mask(begin->get_shape()[0], 0); - return std::make_shared(data, begin, end, default_mask, default_mask, - std::vector{}, shrink_axis_mask); + return std::make_shared(data, + begin, + end, + default_mask, + default_mask, + std::vector{}, + shrink_axis_mask); } static std::shared_ptr getReshape(const std::shared_ptr& data, const std::vector& requested_shape, const ov::element::Type& prc) { - auto requested_shape_node = ov::opset1::Constant::create(prc, {requested_shape.size()}, requested_shape); - return std::make_shared(data, requested_shape_node, true); + auto requested_shape_node = ov::op::v0::Constant::create(prc, {requested_shape.size()}, requested_shape); + return std::make_shared(data, requested_shape_node, true); } static std::shared_ptr initNgram(std::vector& input_shapes, @@ -58,78 +49,80 @@ static std::shared_ptr initNgram(std::vector& input auto param_node = std::make_shared(input_precisions[i], input_shapes[i]); params.push_back(param_node); } - auto shape_of = std::make_shared(params[0], idces_et); - auto shape_ss_begin = ov::opset1::Constant::create(idces_et, {1}, {0}); - auto shape_ss_end = ov::opset1::Constant::create(idces_et, {1}, {1}); + auto shape_of = std::make_shared(params[0], idces_et); + auto shape_ss_begin = ov::op::v0::Constant::create(idces_et, {1}, {0}); + auto shape_ss_end = ov::op::v0::Constant::create(idces_et, {1}, {1}); auto shape_ss = getStridedSlice(shape_of, shape_ss_begin, shape_ss_end, {1}); auto getInputsToPad = [&](const ov::Output data, const int pad_value) { const size_t length = data.get_partial_shape()[1].get_length(); ov::OutputVector inputs; if (left_pad > 0) { - inputs.push_back(ov::opset1::Constant::create(data.get_element_type(), {left_pad, length}, {pad_value})); + inputs.push_back(ov::op::v0::Constant::create(data.get_element_type(), {left_pad, length}, {pad_value})); } inputs.push_back(data); if (right_pad > 0) { - inputs.push_back(ov::opset1::Constant::create(data.get_element_type(), {right_pad, length}, {pad_value})); + inputs.push_back(ov::op::v0::Constant::create(data.get_element_type(), {right_pad, length}, {pad_value})); } return inputs; }; - auto data_padded = std::make_shared(getInputsToPad(params[0], 0), 0); - auto idces_padded = std::make_shared(getInputsToPad(params[1], -1), 0); + auto data_padded = std::make_shared(getInputsToPad(params[0], 0), 0); + auto idces_padded = std::make_shared(getInputsToPad(params[1], -1), 0); std::shared_ptr as_is_bias = shape_ss; if (mid_idx != 0) { - auto bias_const = ov::opset1::Constant::create(idces_et, {}, {mid_idx}); - as_is_bias = std::make_shared(shape_ss, bias_const); + auto bias_const = ov::op::v0::Constant::create(idces_et, {}, {mid_idx}); + as_is_bias = std::make_shared(shape_ss, bias_const); } - auto as_is_ss_begin = ov::opset1::Constant::create(idces_et, {1}, {mid_idx}); + auto as_is_ss_begin = ov::op::v0::Constant::create(idces_et, {1}, {mid_idx}); auto as_is_ss_end = getReshape(as_is_bias, {1}, idces_et); auto as_is_ss = getStridedSlice(data_padded, as_is_ss_begin, as_is_ss_end); auto getSelectBranch = [&](const size_t cur_idx, const size_t mid_idx) { std::shared_ptr eq_left_bias = shape_ss; if (cur_idx != 0) { - auto bias_const = ov::opset1::Constant::create(idces_et, {}, {cur_idx}); - eq_left_bias = std::make_shared(shape_ss, bias_const); + auto bias_const = ov::op::v0::Constant::create(idces_et, {}, {cur_idx}); + eq_left_bias = std::make_shared(shape_ss, bias_const); } auto eq_left_reshape = getReshape(eq_left_bias, {1}, idces_et); - auto eq_left_concat_const = ov::opset1::Constant::create(idces_et, {1}, {1}); - auto eq_left_concat = std::make_shared(ov::OutputVector{eq_left_reshape, eq_left_concat_const}, 0); - auto eq_left_ss_begin = ov::opset1::Constant::create(idces_et, {2}, std::vector{cur_idx, 0ul}); + auto eq_left_concat_const = ov::op::v0::Constant::create(idces_et, {1}, {1}); + auto eq_left_concat = + std::make_shared(ov::OutputVector{eq_left_reshape, eq_left_concat_const}, 0); + auto eq_left_ss_begin = ov::op::v0::Constant::create(idces_et, {2}, std::vector{cur_idx, 0ul}); auto eq_left_ss = getStridedSlice(idces_padded, eq_left_ss_begin, eq_left_concat, {0, 1}); std::shared_ptr eq_right_bias = shape_ss; if (mid_idx != 0) { - auto bias_const = ov::opset1::Constant::create(idces_et, {}, {mid_idx}); - eq_right_bias = std::make_shared(shape_ss, bias_const); + auto bias_const = ov::op::v0::Constant::create(idces_et, {}, {mid_idx}); + eq_right_bias = std::make_shared(shape_ss, bias_const); } auto eq_right_reshape = getReshape(eq_right_bias, {1}, idces_et); - auto eq_right_concat_const = ov::opset1::Constant::create(idces_et, {1}, {1}); - auto eq_right_concat = std::make_shared(ov::OutputVector{eq_right_reshape, eq_right_concat_const}, 0); - auto eq_right_ss_begin = ov::opset1::Constant::create(idces_et, {2}, std::vector{mid_idx, 0ul}); + auto eq_right_concat_const = ov::op::v0::Constant::create(idces_et, {1}, {1}); + auto eq_right_concat = + std::make_shared(ov::OutputVector{eq_right_reshape, eq_right_concat_const}, 0); + auto eq_right_ss_begin = ov::op::v0::Constant::create(idces_et, {2}, std::vector{mid_idx, 0ul}); auto eq_right_ss = getStridedSlice(idces_padded, eq_right_ss_begin, eq_right_concat, {0, 1}); - auto equal = std::make_shared(eq_left_ss, eq_right_ss); + auto equal = std::make_shared(eq_left_ss, eq_right_ss); auto cond = getReshape(equal, {-1, 1}, idces_et); std::shared_ptr then_bias = shape_ss; if (cur_idx != 0) { - auto bias_const = ov::opset1::Constant::create(idces_et, {}, {cur_idx}); - then_bias = std::make_shared(shape_ss, bias_const); + auto bias_const = ov::op::v0::Constant::create(idces_et, {}, {cur_idx}); + then_bias = std::make_shared(shape_ss, bias_const); } auto then_reshape = getReshape(then_bias, {1}, idces_et); - auto then_ss_begin = ov::opset1::Constant::create(idces_et, {1}, {cur_idx}); + auto then_ss_begin = ov::op::v0::Constant::create(idces_et, {1}, {cur_idx}); auto then = getStridedSlice(data_padded, then_ss_begin, then_reshape); auto else_reshape = getReshape(shape_ss, {1}, idces_et); - auto else_concat_const = ov::opset1::Constant::create(idces_et, {1}, {input_shapes[0][1].get_length()}); - auto else_concat = std::make_shared(ov::OutputVector{else_reshape, else_concat_const}, 0); - auto else_bcast_const = ov::opset1::Constant::create(data_et, {}, {0}); - auto else_bcast = std::make_shared(else_bcast_const, else_concat); + auto else_concat_const = ov::op::v0::Constant::create(idces_et, {1}, {input_shapes[0][1].get_length()}); + auto else_concat = std::make_shared(ov::OutputVector{else_reshape, else_concat_const}, 0); + auto else_bcast_const = ov::op::v0::Constant::create(data_et, {}, {0}); + auto else_bcast = std::make_shared(else_bcast_const, else_concat); - auto select = std::make_shared(cond, then, else_bcast); + auto select = std::make_shared(cond, then, else_bcast); return select; }; @@ -141,13 +134,15 @@ static std::shared_ptr initNgram(std::vector& input concat_inputs[i] = getSelectBranch(i, mid_idx); } - auto final_concat = std::make_shared(concat_inputs, 1); + auto final_concat = std::make_shared(concat_inputs, 1); return std::make_shared(final_concat, params, "ngram"); } -class NgramCPUTest : public testing::WithParamInterface, virtual public SubgraphBaseTest, public CPUTestsBase { +class NgramCPUTest : public testing::WithParamInterface, + virtual public SubgraphBaseTest, + public CPUTestsBase { public: - static std::string getTestCaseName(const testing::TestParamInfo &obj) { + static std::string getTestCaseName(const testing::TestParamInfo& obj) { std::vector input_shapes; size_t k; ElementType data_et; @@ -178,7 +173,6 @@ class NgramCPUTest : public testing::WithParamInterface, virtua auto embeddings_tensor = ov::test::utils::create_and_fill_tensor_consistently(data_et, data_shape, 100, 1, 1); inputs.insert({model_inputs[0].get_node_shared_ptr(), embeddings_tensor}); - const auto& indices_et = model_inputs[1].get_element_type(); const auto& indices_shape = targetInputStaticShapes[1]; const size_t batch_size = data_shape[0]; @@ -207,9 +201,8 @@ class NgramCPUTest : public testing::WithParamInterface, virtua init_input_shapes(inputShapes); function = initNgram(inputDynamicShapes, data_et, idces_et, k); - if (!configuration.count(InferenceEngine::PluginConfigInternalParams::KEY_SNIPPETS_MODE)) { - configuration.insert({InferenceEngine::PluginConfigInternalParams::KEY_SNIPPETS_MODE, - InferenceEngine::PluginConfigInternalParams::DISABLE}); + if (!configuration.count("SNIPPETS_MODE")) { + configuration.insert({"SNIPPETS_MODE", "DISABLE"}); } } }; @@ -222,28 +215,21 @@ TEST_P(NgramCPUTest, CompareWithRefs) { namespace { std::vector> inputShapes = { - { - InputShape{{-1, 2}, {{3, 2}, {5, 2}, {7, 2}}}, - InputShape{{-1, 2}, {{3, 2}, {5, 2}, {7, 2}}} - }, - { - InputShape{{-1, 256}, {{12, 256}, {25, 256}}}, - InputShape{{-1, 2}, {{12, 2}, {25, 2}}} - }, - { - InputShape{{-1, 1}, {{12, 1}}}, - InputShape{{-1, 2}, {{12, 2}}} - }, + {InputShape{{-1, 2}, {{3, 2}, {5, 2}, {7, 2}}}, InputShape{{-1, 2}, {{3, 2}, {5, 2}, {7, 2}}}}, + {InputShape{{-1, 256}, {{12, 256}, {25, 256}}}, InputShape{{-1, 2}, {{12, 2}, {25, 2}}}}, + {InputShape{{-1, 1}, {{12, 1}}}, InputShape{{-1, 2}, {{12, 2}}}}, }; std::vector k_values = {2, 3, 5, 7}; std::vector idces_precisions = {ElementType::i32, ElementType::i64}; -INSTANTIATE_TEST_SUITE_P(smoke_Ngram, NgramCPUTest, - ::testing::Combine(::testing::ValuesIn(inputShapes), - ::testing::Values(ElementType::f32), - ::testing::ValuesIn(idces_precisions), - ::testing::ValuesIn(k_values)), - NgramCPUTest::getTestCaseName); -} // namespace -} // namespace CPUSubgraphTestsDefinitions +INSTANTIATE_TEST_SUITE_P(smoke_Ngram, + NgramCPUTest, + ::testing::Combine(::testing::ValuesIn(inputShapes), + ::testing::Values(ElementType::f32), + ::testing::ValuesIn(idces_precisions), + ::testing::ValuesIn(k_values)), + NgramCPUTest::getTestCaseName); +} // namespace +} // namespace test +} // namespace ov 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/subgraph_tests/src/not_fused_conv_simple_op.cpp index 4229e15282648d..e25350d1adfb50 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/not_fused_conv_simple_op.cpp +++ b/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/not_fused_conv_simple_op.cpp @@ -2,21 +2,23 @@ // SPDX-License-Identifier: Apache-2.0 // +#include "common_test_utils/node_builders/convolution.hpp" +#include "common_test_utils/node_builders/eltwise.hpp" #include "ov_models/builders.hpp" +#include "shared_test_classes/base/ov_subgraph.hpp" #include "test_utils/cpu_test_utils.hpp" -using namespace ngraph; -using ngraph::helpers::EltwiseTypes; +namespace ov { +namespace test { -namespace SubgraphTestsDefinitions { - -class NotFusedConvSimpleOp : virtual public LayerTestsUtils::LayerTestsCommon { +class NotFusedConvSimpleOp : virtual public ov::test::SubgraphBaseStaticTest { protected: void SetUp() override { targetDevice = ov::test::utils::DEVICE_CPU; - ov::ParameterVector inputParams{std::make_shared(ov::element::f32, ov::Shape{1, 3, 12, 9}), - std::make_shared(ov::element::f32, ov::Shape{1, 16, 12, 9})}; + ov::ParameterVector inputParams{ + std::make_shared(ov::element::f32, ov::Shape{1, 3, 12, 9}), + std::make_shared(ov::element::f32, ov::Shape{1, 16, 12, 9})}; std::shared_ptr conv; { @@ -27,20 +29,29 @@ class NotFusedConvSimpleOp : virtual public LayerTestsUtils::LayerTestsCommon { const std::vector dilation = {1, 1}; const size_t numOutChannels = 16; const op::PadType paddingType = op::PadType::EXPLICIT; - conv = builder::makeConvolution(inputParams[0], element::f32, kernelSize, strides, padBegin, padEnd, dilation, paddingType, numOutChannels); + conv = ov::test::utils::make_convolution(inputParams[0], + element::f32, + kernelSize, + strides, + padBegin, + padEnd, + dilation, + paddingType, + numOutChannels); } - const auto sharedNode = builder::makeConstant(element::f32, {1, 16, 1, 1}, std::vector{}, true); - const auto postOpCandidate = builder::makeEltwise(conv, sharedNode, EltwiseTypes::ADD); + const auto sharedNode = ngraph::builder::makeConstant(element::f32, {1, 16, 1, 1}, std::vector{}, true); + const auto postOpCandidate = ov::test::utils::makeEltwise(conv, sharedNode, utils::EltwiseTypes::ADD); - const auto secondConsumpt = builder::makeEltwise(inputParams[1], sharedNode, EltwiseTypes::ADD); + const auto secondConsumpt = ov::test::utils::makeEltwise(inputParams[1], sharedNode, utils::EltwiseTypes::ADD); NodeVector results{postOpCandidate, secondConsumpt}; - function = std::make_shared(results, inputParams, "NotFusedConvSimpleOp"); + function = std::make_shared(results, inputParams, "NotFusedConvSimpleOp"); } }; TEST_F(NotFusedConvSimpleOp, smoke_CompareWithRefs) { - Run(); + run(); } -} // namespace SubgraphTestsDefinitions +} // namespace test +} // namespace ov diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/param_result_custom_blob.cpp b/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/param_result_custom_blob.cpp index b762671a66d610..8b086d0833ecf5 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/param_result_custom_blob.cpp +++ b/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/param_result_custom_blob.cpp @@ -6,10 +6,9 @@ #include "shared_test_classes/subgraph/parameter_result.hpp" using namespace SubgraphTestsDefinitions; -using namespace ov::test; -using namespace InferenceEngine; -namespace CPULayerTestsDefinitions { +namespace ov { +namespace test { class ParameterResultCustomBlobTest : public ParameterResultSubgraphTestLegacyApi { protected: @@ -21,7 +20,7 @@ class ParameterResultCustomBlobTest : public ParameterResultSubgraphTestLegacyAp auto inputBlob = inputs.front(); const size_t elementsCount = inputBlob->size(); for (size_t i = 0; i < inferIterations; ++i) { - ov::test::utils::fill_data_random(inputBlob, 10, 0, 1, i); + ov::test::utils::fill_data_random(inputBlob, 10, 0, 1, i); auto inputsInfo = cnnNetwork.getInputsInfo().begin()->second; std::string inputName = cnnNetwork.getInputsInfo().begin()->first; @@ -30,7 +29,7 @@ class ParameterResultCustomBlobTest : public ParameterResultSubgraphTestLegacyAp std::copy(inpBlobData, inpBlobData + elementsCount, customInpData.begin()); auto& tensorDesc = inputsInfo->getTensorDesc(); - auto customBlob = make_shared_blob(tensorDesc, customInpData.data(), elementsCount); + auto customBlob = InferenceEngine::make_shared_blob(tensorDesc, customInpData.data(), elementsCount); inferRequest.SetBlob(inputName, customBlob); inferRequest.Infer(); @@ -46,8 +45,8 @@ class ParameterResultCustomBlobTest : public ParameterResultSubgraphTestLegacyAp TEST_P(ParameterResultCustomBlobTest, CompareWithRefs) { // Just to show that it is not possible to set different precisions for inputs and outputs with the same name. // If it was possible, the input would have I8 precision and couldn't store data from the custom blob. - inPrc = Precision::I8; - outPrc = Precision::FP32; + inPrc = InferenceEngine::Precision::I8; + outPrc = InferenceEngine::Precision::FP32; Run(); } @@ -84,4 +83,5 @@ INSTANTIATE_TEST_SUITE_P(smoke_Check_Same_Blob, ::testing::Values(ov::test::utils::DEVICE_CPU)), ParameterResultSubgraphTestBase::getTestCaseName); } // namespace -} // namespace CPULayerTestsDefinitions +} // namespace test +} // namespace ov diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/remove_convert.cpp b/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/remove_convert.cpp index 5a214177867311..8ba11aedcb6544 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/remove_convert.cpp +++ b/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/remove_convert.cpp @@ -2,24 +2,20 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "ov_models/builders.hpp" -#include "ov_models/utils/ov_helpers.hpp" -#include "shared_test_classes/base/layer_test_utils.hpp" +#include "common_test_utils/node_builders/activation.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" #include "test_utils/cpu_test_utils.hpp" #include "test_utils/fusing_test_utils.hpp" -using namespace ov::test; -using namespace ngraph; using namespace CPUTestUtils; -using namespace InferenceEngine; -namespace SubgraphTestsDefinitions { +namespace ov { +namespace test { using RemoveConvertCPUTestParams = std::tuple; class RemoveUselessBF16ConvertCPUTest : public testing::WithParamInterface, - virtual public SubgraphBaseTest, - public CPUTestsBase { + virtual public SubgraphBaseTest, + public CPUTestsBase { public: static std::string getTestCaseName(const testing::TestParamInfo& obj) { ElementType inType; @@ -44,9 +40,9 @@ class RemoveUselessBF16ConvertCPUTest : public testing::WithParamInterface(inType, inputShape.first); auto convert = std::make_shared(input_params, element::f32); - auto begin = builder::makeConstant(element::i64, ov::Shape{4}, std::vector{0, 0, 0, 0}); - auto end = builder::makeConstant(element::i64, ov::Shape{4}, std::vector{0, 0, 16, 0}); - auto stride = builder::makeConstant(element::i64, ov::Shape{4}, std::vector{1, 1, 1, 1}); + auto begin = ngraph::builder::makeConstant(element::i64, ov::Shape{4}, std::vector{0, 0, 0, 0}); + auto end = ngraph::builder::makeConstant(element::i64, ov::Shape{4}, std::vector{0, 0, 16, 0}); + auto stride = ngraph::builder::makeConstant(element::i64, ov::Shape{4}, std::vector{1, 1, 1, 1}); auto slice = std::make_shared(convert, begin, end, @@ -84,17 +80,19 @@ class RemoveUselessConvertCPUTest : public testing::WithParamInterface(inType, inputShape.first); - // Such complicated graph is necessary to cover the case when Convert has several children and connected to non zero output - const auto split_axis = builder::makeConstant(element::i64, ov::Shape{}, std::vector{1}); - const auto split_lengths = builder::makeConstant(element::i64, ov::Shape{2}, std::vector{-1, 1}); - const auto split = std::make_shared(input_params, split_axis, split_lengths); + // Such complicated graph is necessary to cover the case when Convert has several children and connected to non + // zero output + const auto split_axis = ngraph::builder::makeConstant(element::i64, ov::Shape{}, std::vector{1}); + const auto split_lengths = + ngraph::builder::makeConstant(element::i64, ov::Shape{2}, std::vector{-1, 1}); + const auto split = std::make_shared(input_params, split_axis, split_lengths); auto convert = std::make_shared(split->output(1), inType); - auto relu = builder::makeActivation(convert, inType, ::helpers::ActivationTypes::Relu); + auto relu = ov::test::utils::make_activation(convert, inType, ov::test::utils::ActivationTypes::Relu); ov::ResultVector results{ - std::make_shared(split->output(0)), - std::make_shared(convert), - std::make_shared(relu), + std::make_shared(split->output(0)), + std::make_shared(convert), + std::make_shared(relu), }; function = std::make_shared(results, ov::ParameterVector{input_params}, "remove_convert"); @@ -131,4 +129,5 @@ INSTANTIATE_TEST_SUITE_P(smoke_RemoveConvert, ::testing::Combine(::testing::Values(ElementType::f32), ::testing::Values(inputShapes[0])), RemoveUselessConvertCPUTest::getTestCaseName); } // namespace -} // namespace SubgraphTestsDefinitions +} // namespace test +} // namespace ov diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/reshape_chain.cpp b/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/reshape_chain.cpp index a2cb19c8e1da3f..2be92f3e984fc2 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/reshape_chain.cpp +++ b/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/reshape_chain.cpp @@ -2,15 +2,13 @@ // SPDX-License-Identifier: Apache-2.0 // -#include -#include -#include #include "common_test_utils/common_utils.hpp" #include "functional_test_utils/skip_tests_config.hpp" +#include "ov_models/builders.hpp" +#include "shared_test_classes/base/ov_subgraph.hpp" -using namespace ov::test; - -namespace SubgraphTestsDefinitions { +namespace ov { +namespace test { class ReshapeChain : public SubgraphBaseTest { void SetUp() override { @@ -19,23 +17,23 @@ class ReshapeChain : public SubgraphBaseTest { InputShape inputShapes{{-1, -1, -1, -1}, {{10, 20, 30, 40}, {16, 24, 16, 24}, {4, 8, 12, 16}}}; init_input_shapes({inputShapes}); - auto ngPrc = ngraph::element::f32; - const auto secondInPrc = ngraph::element::Type_t::i32; + auto ngPrc = ov::element::f32; + const auto secondInPrc = ov::element::Type_t::i32; ov::ParameterVector inputParams; for (auto&& shape : inputDynamicShapes) { inputParams.push_back(std::make_shared(ngPrc, shape)); } auto reshapeParam1 = ngraph::builder::makeConstant(secondInPrc, {3}, {0, 0, -1}); - auto reshape1 = std::make_shared(inputParams.front(), reshapeParam1, true); + auto reshape1 = std::make_shared(inputParams.front(), reshapeParam1, true); auto reshapeParam2 = ngraph::builder::makeConstant(secondInPrc, {2}, {0, -1}); - auto reshape2 = std::make_shared(reshape1, reshapeParam2, true); + auto reshape2 = std::make_shared(reshape1, reshapeParam2, true); auto reshapeParam3 = ngraph::builder::makeConstant(secondInPrc, {1}, {-1}); - auto reshape3 = std::make_shared(reshape2, reshapeParam3, true); + auto reshape3 = std::make_shared(reshape2, reshapeParam3, true); auto reshapeParam4 = ngraph::builder::makeConstant(secondInPrc, {2}, {4, -1}); - auto reshape4 = std::make_shared(reshape3, reshapeParam4, true); + auto reshape4 = std::make_shared(reshape3, reshapeParam4, true); - ngraph::ResultVector results{std::make_shared(reshape4)}; - function = std::make_shared(results, inputParams, "reshapeChain"); + ov::ResultVector results{std::make_shared(reshape4)}; + function = std::make_shared(results, inputParams, "reshapeChain"); } }; @@ -43,4 +41,5 @@ TEST_F(ReshapeChain, smoke_ReshapeChain) { run(); } -} // namespace SubgraphTestsDefinitions +} // namespace test +} // namespace ov diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/reshape_fc.cpp b/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/reshape_fc.cpp index d7660cb919093d..2e2d44aeefb28a 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/reshape_fc.cpp +++ b/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/reshape_fc.cpp @@ -2,25 +2,25 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "shared_test_classes/base/ov_subgraph.hpp" #include + #include "ov_models/builders.hpp" +#include "shared_test_classes/base/ov_subgraph.hpp" #include "test_utils/fusing_test_utils.hpp" using namespace CPUTestUtils; -using namespace ov::test; - -namespace CPULayerTestsDefinitions { +namespace ov { +namespace test { -using ReshapeFcSpecParams = std::tuple, // input shapes - std::vector, // reshape data - ElementType>; // precision +using ReshapeFcSpecParams = std::tuple, // input shapes + std::vector, // reshape data + ElementType>; // precision -using ReshapeFcParams = std::tuple; +using ReshapeFcParams = std::tuple; -class ReshapeFcCPUTest : public testing::WithParamInterface, virtual public SubgraphBaseTest, public CpuTestWithFusing { +class ReshapeFcCPUTest : public testing::WithParamInterface, + virtual public SubgraphBaseTest, + public CpuTestWithFusing { public: static std::string getTestCaseName(testing::TestParamInfo obj) { std::vector shapes; @@ -51,7 +51,8 @@ class ReshapeFcCPUTest : public testing::WithParamInterface, vi } result << ")_"; } - result << "DATA=" << "[" << ov::test::utils::vec2str(data) << "]_"; + result << "DATA=" + << "[" << ov::test::utils::vec2str(data) << "]_"; result << "PRC=" << prc << "_"; result << CpuTestWithFusing::getTestCaseName(fusingParams); @@ -83,7 +84,7 @@ class ReshapeFcCPUTest : public testing::WithParamInterface, vi ov::ParameterVector params{std::make_shared(prc, inputDynamicShapes.front())}; auto reshapeData = ngraph::builder::makeConstant(ElementType::i32, {data.size()}, data); - auto reshape = std::make_shared(params[0], reshapeData, true); + auto reshape = std::make_shared(params[0], reshapeData, true); auto tensor = ov::test::utils::create_and_fill_tensor(prc, inputDynamicShapes.back().to_shape()); auto weight = std::make_shared(tensor); @@ -94,20 +95,14 @@ class ReshapeFcCPUTest : public testing::WithParamInterface, vi }; TEST_P(ReshapeFcCPUTest, CompareWithRefs) { - run(); - CheckPluginRelatedResults(compiledModel, "FullyConnected"); + run(); + CheckPluginRelatedResults(compiledModel, "FullyConnected"); } -const std::vector reshFcParams = { - ReshapeFcSpecParams{ - { - {{{1, 10}, 160}, {{1, 160}, {1, 160}, {5, 160}, {2, 160}}}, - {{32, 3}, {{32, 3}, {32, 3}, {32, 3}, {32, 3}}} - }, - std::vector{-1, 5, 32}, - ElementType::f32 - } -}; +const std::vector reshFcParams = {ReshapeFcSpecParams{ + {{{{1, 10}, 160}, {{1, 160}, {1, 160}, {5, 160}, {2, 160}}}, {{32, 3}, {{32, 3}, {32, 3}, {32, 3}, {32, 3}}}}, + std::vector{-1, 5, 32}, + ElementType::f32}}; static std::vector filterFusingParams(const std::vector& orig) { #ifdef OV_CPU_WITH_MLAS @@ -117,22 +112,18 @@ static std::vector filterFusingParams(const std::vector fusingParamsSet { - emptyFusingSpec, - fusingBias, - fusingMultiplyPerChannel -}; +std::vector fusingParamsSet{emptyFusingSpec, fusingBias, fusingMultiplyPerChannel}; #ifdef OV_CPU_WITH_MLAS const auto gemmParam = CPUSpecificParams{{}, {}, {"gemm_mlas"}, "gemm_mlas"}; #else const auto gemmParam = CPUSpecificParams{{}, {}, {"jit_gemm"}, "jit_gemm"}; #endif -const auto params = ::testing::Combine( - ::testing::ValuesIn(reshFcParams), - ::testing::ValuesIn(filterFusingParams(fusingParamsSet)), - ::testing::Values(gemmParam)); +const auto params = ::testing::Combine(::testing::ValuesIn(reshFcParams), + ::testing::ValuesIn(filterFusingParams(fusingParamsSet)), + ::testing::Values(gemmParam)); INSTANTIATE_TEST_SUITE_P(smoke_ReshapeFc, ReshapeFcCPUTest, params, ReshapeFcCPUTest::getTestCaseName); -} // namespace CPULayerTestsDefinitions +} // namespace test +} // namespace ov diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/reshape_inplace.cpp b/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/reshape_inplace.cpp index bcdc28c75de99a..52caa4fdabc54e 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/reshape_inplace.cpp +++ b/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/reshape_inplace.cpp @@ -2,16 +2,13 @@ // SPDX-License-Identifier: Apache-2.0 // -#include -#include "ngraph/runtime/aligned_buffer.hpp" +#include "common_test_utils/ov_tensor_utils.hpp" #include "ov_models/builders.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" -using namespace InferenceEngine; -using namespace ov::test; -namespace SubgraphTestsDefinitions { +namespace ov { +namespace test { // Subgraph: /* * params[0] params[1] @@ -49,8 +46,8 @@ class InPlaceReshapeFromConstantCheck : public SubgraphBaseTest { auto c = ngraph::builder::makeConstant(rtPrc, {}, {1.0f}); auto broadcast = std::make_shared(c, shape); auto reshape = std::make_shared(broadcast, params[1], false); - ov::ResultVector results{std::make_shared(reshape->output(0))}; - function = std::make_shared(results, params, "reshape_check"); + ov::ResultVector results{std::make_shared(reshape->output(0))}; + function = std::make_shared(results, params, "reshape_check"); } void generate_inputs(const std::vector& targetInputStaticShapes) override { inputs.clear(); @@ -84,4 +81,5 @@ class InPlaceReshapeFromConstantCheck : public SubgraphBaseTest { TEST_F(InPlaceReshapeFromConstantCheck, smoke_CPU_InPlaceReshapeFromConstantCheck) { run(); } -} // namespace SubgraphTestsDefinitions +} // namespace test +} // namespace ov 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/subgraph_tests/src/reshape_permute_conv_permute_reshape_act.cpp index 41e1142d7572dd..a70c81c0bf124e 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/subgraph_tests/src/reshape_permute_conv_permute_reshape_act.cpp @@ -2,26 +2,28 @@ // SPDX-License-Identifier: Apache-2.0 // -#include #include "subgraph_tests/reshape_permute_conv_permute_reshape_act.hpp" + +#include + #include "common_test_utils/test_constants.hpp" +namespace ov { +namespace test { namespace { -using ov::test::ConvReshapeAct; - -std::vector> input_shapes { +std::vector> input_shapes{ {1, 1, 166, 2}, {1, 1, 144, 2}, {1, 1, 288, 2}, {1, 1, 144, 4}, }; -std::vector> kernel_shapes { +std::vector> kernel_shapes{ {1, 7}, {1, 15}, }; -std::vector output_channels { +std::vector output_channels{ 16, 8, 4, @@ -32,16 +34,17 @@ std::vector model_types = { ov::element::f16, }; -std::map additional_config = { }; - -INSTANTIATE_TEST_SUITE_P(smoke_basic, ConvReshapeAct, - ::testing::Combine( - ::testing::ValuesIn(model_types), - ::testing::Values(ov::test::utils::DEVICE_CPU), - ::testing::ValuesIn(input_shapes), - ::testing::ValuesIn(kernel_shapes), - ::testing::ValuesIn(output_channels), - ::testing::Values(additional_config)), - ConvReshapeAct::getTestCaseName); - -} // namespace \ No newline at end of file +ov::AnyMap additional_config = {}; + +INSTANTIATE_TEST_SUITE_P(smoke_basic, + ConvReshapeAct, + ::testing::Combine(::testing::ValuesIn(model_types), + ::testing::Values(ov::test::utils::DEVICE_CPU), + ::testing::ValuesIn(input_shapes), + ::testing::ValuesIn(kernel_shapes), + ::testing::ValuesIn(output_channels), + ::testing::Values(additional_config)), + ConvReshapeAct::getTestCaseName); +} // namespace +} // namespace test +} // namespace ov \ No newline at end of file diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/rotary_pos_emb.cpp b/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/rotary_pos_emb.cpp index edfce4dcc9520e..c9b367599ab5b7 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/rotary_pos_emb.cpp +++ b/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/rotary_pos_emb.cpp @@ -22,9 +22,11 @@ using namespace CPUTestUtils; using namespace ov::gen_pattern; -using namespace ov::test; using namespace ov; +namespace ov { +namespace test { + static ov::OutputVector makeCosSinCache(int max_position_embeddings, int rotary_ndims) { std::vector lut_sin(max_position_embeddings * rotary_ndims, 0.0f); std::vector lut_cos(max_position_embeddings * rotary_ndims, 0.0f); @@ -129,9 +131,7 @@ static std::shared_ptr buildROPE_Llama2(const int batch, return std::make_shared(ov::NodeVector{add_Add}, ov::ParameterVector{input, pos_id_end, pos_ids}); } -namespace CPULayerTestsDefinitions { - -class RoPECPUTest : public SubgraphBaseTest { +class RoPECPUTestLlama2 : public SubgraphBaseTest { public: ov::Tensor create_i32_tensor(const ov::Shape& shape, int start, int step = 1) { auto tensor = ov::Tensor(ov::element::i32, shape); @@ -177,8 +177,156 @@ class RoPECPUTest : public SubgraphBaseTest { } }; -TEST_F(RoPECPUTest, smoke_CompareWithRefs) { +TEST_F(RoPECPUTestLlama2, smoke_CompareWithRefs) { + run(); + CheckNumberOfNodesWithType(compiledModel, "RoPE", 1); +} + +class RoPECPUTestChatGLM : public SubgraphBaseTest { +public: + ov::Tensor create_i32_tensor(const ov::Shape& shape, int start, int step = 1) { + auto tensor = ov::Tensor(ov::element::i32, shape); + auto* ptr = static_cast(tensor.data()); + for (size_t i = 0; i < tensor.get_size(); i++) { + ptr[i] = start; + start += step; + } + return tensor; + } + + void generate_inputs(const std::vector& targetInputStaticShapes) override { + const auto& funcInputs = function->inputs(); + + auto& input_shape = targetInputStaticShapes[0]; + auto seq_length = input_shape[0]; + // auto batch = input_shape[1]; + + ov::Tensor t_input = + utils::create_and_fill_tensor(funcInputs[0].get_element_type(), input_shape, 2, -1.0f, 32768); + ov::Tensor t_cos_sin_cache = + utils::create_and_fill_tensor(funcInputs[1].get_element_type(), {32768, 32, 2}, 2, -1.0f, 32768); + ov::Tensor t_position_ids = create_i32_tensor(ov::Shape({1, seq_length}), 15); + + inputs.clear(); + inputs.insert({funcInputs[0].get_node_shared_ptr(), t_input}); + inputs.insert({funcInputs[1].get_node_shared_ptr(), t_cos_sin_cache}); + inputs.insert({funcInputs[2].get_node_shared_ptr(), t_position_ids}); + } + +protected: + std::shared_ptr buildROPE_ChatGLM(int batch, int head_cnt, int rotary_dims) { + auto input = + std::make_shared(ov::element::f32, PartialShape{-1, batch, 4096 + 256 + 256}); + auto cos_sin_cache = std::make_shared(ov::element::f32, PartialShape{32768, 32, 2}); + auto position_ids = std::make_shared(ov::element::i32, PartialShape{-1, -1}); + + auto __module_transformer_index_67_Gather = + makeOP({cos_sin_cache, position_ids, 0}, {{"batch_dims", 0}}); + auto __module_transformer_transpose_Transpose = + makeOP({__module_transformer_index_67_Gather, {1, 0, 2, 3}}); + auto size_ShapeOf_110 = + makeOP({__module_transformer_transpose_Transpose}, {{"output_type", "i32"}}); + auto __getitem___Gather = makeOP({size_ShapeOf_110, -2, 0}, {{"batch_dims", 0}}); + auto mul_Multiply = makeOP({__getitem___Gather, 2}, {{"auto_broadcast", "numpy"}}); + auto slice_Unsqueeze_112 = makeOP({mul_Multiply, 0}); + + auto floordiv_Divide = + makeOP({mul_Multiply, 2}, {{"auto_broadcast", "numpy"}, {"m_pythondiv", true}}); + auto floordiv_Floor = makeOP({floordiv_Divide}); + auto ListConstruct_126_Reshape_2 = makeOP({floordiv_Floor, {-1}}, {{"special_zero", false}}); + + auto ListUnpack_321 = makeOP({input, -1, {4096, 256, 256}}); + auto view_Reshape = + makeOP({ListUnpack_321->output(0), {0, 0, 32, 128}}, {{"special_zero", true}}); + + auto ScatterUpdate_229053 = makeOP({{0, 0, 0, 0}, {3}, slice_Unsqueeze_112, {0}}); + auto slice_Slice_357 = + makeOP({view_Reshape, {0, 0, 0, 0}, ScatterUpdate_229053, {1, 1, 1, 1}}, + {{"begin_mask", {1, 1, 1, 0}}, + {"end_mask", {1, 1, 1, 0}}, + {"new_axis_mask", {}}, + {"shrink_axis_mask", {}}, + {"ellipsis_mask", {}}}); + auto size_ShapeOf_346 = makeOP({view_Reshape}, {{"output_type", "i32"}}); + auto size_Gather_348 = makeOP({size_ShapeOf_346, 0, 0}, {{"batch_dims", 0}}); + auto ListConstruct_372_Reshape = makeOP({size_Gather_348, {-1}}, {{"special_zero", false}}); + auto size_Gather_351 = makeOP({size_ShapeOf_346, {2}, 0}, {{"batch_dims", 0}}); + auto ListConstruct_372_Concat = + makeOP({ListConstruct_372_Reshape, {-1}, size_Gather_351, ListConstruct_126_Reshape_2, {2}}, + {{"axis", 0}}); + auto reshape_Reshape_373 = + makeOP({slice_Slice_357, ListConstruct_372_Concat}, {{"special_zero", false}}); + auto select_Gather_381 = makeOP({reshape_Reshape_373, 0, -1}, {{"batch_dims", 0}}); + auto slice_Unsqueeze_367 = makeOP({size_Gather_348, 0}); + auto slice_Slice_369 = + makeOP({__module_transformer_transpose_Transpose, {0}, slice_Unsqueeze_367, {1}}, + {{"begin_mask", {0}}, + {"end_mask", {0}}, + {"new_axis_mask", {}}, + {"shrink_axis_mask", {}}, + {"ellipsis_mask", {}}}); + auto size_ShapeOf_374 = makeOP({reshape_Reshape_373}, {{"output_type", "i32"}}); + auto size_Gather_376 = makeOP({size_ShapeOf_374, {3}, 0}, {{"batch_dims", 0}}); + auto ListConstruct_379_Concat = + makeOP({ListConstruct_372_Reshape, {-1}, {1}, size_Gather_376, {2}}, {{"axis", 0}}); + auto view_Reshape_380 = + makeOP({slice_Slice_369, ListConstruct_379_Concat}, {{"special_zero", false}}); + auto select_Gather_382 = makeOP({view_Reshape_380, 0, -1}, {{"batch_dims", 0}}); + auto mul_Multiply_383 = + makeOP({select_Gather_381, select_Gather_382}, {{"auto_broadcast", "numpy"}}); + auto select_Gather_384 = makeOP({reshape_Reshape_373, 1, -1}, {{"batch_dims", 0}}); + auto select_Gather_385 = makeOP({view_Reshape_380, 1, -1}, {{"batch_dims", 0}}); + auto mul_Multiply_386 = + makeOP({select_Gather_384, select_Gather_385}, {{"auto_broadcast", "numpy"}}); + auto sub_Subtract_389 = + makeOP({mul_Multiply_383, mul_Multiply_386}, {{"auto_broadcast", "numpy"}}); + auto Unsqueeze_62716 = makeOP({sub_Subtract_389, -1}); + auto mul_Multiply_391 = + makeOP({select_Gather_384, select_Gather_382}, {{"auto_broadcast", "numpy"}}); + auto mul_Multiply_393 = + makeOP({select_Gather_381, select_Gather_385}, {{"auto_broadcast", "numpy"}}); + auto add_Add_396 = makeOP({mul_Multiply_391, mul_Multiply_393}, {{"auto_broadcast", "numpy"}}); + auto Unsqueeze_62717 = makeOP({add_Add_396, -1}); + auto stack_401 = makeOP({Unsqueeze_62716, Unsqueeze_62717}, {{"axis", -1}}); + auto flatten_ShapeOf_402 = makeOP({stack_401}, {{"output_type", "i32"}}); + auto flatten_Slice_417 = makeOP({flatten_ShapeOf_402, {0}, {3}, {1}}, + {{"begin_mask", {0}}, + {"end_mask", {0}}, + {"new_axis_mask", {}}, + {"shrink_axis_mask", {}}, + {"ellipsis_mask", {}}}); + auto flatten_Concat_420 = makeOP({flatten_Slice_417, {-1}}, {{"axis", 0}}); + auto flatten_Reshape_421 = makeOP({stack_401, flatten_Concat_420}, {{"special_zero", true}}); + auto ScatterUpdate_229067 = makeOP({{0, 0, 0, 0}, {3}, slice_Unsqueeze_112, {0}}); + auto slice_Slice_363 = + makeOP({view_Reshape, ScatterUpdate_229067, {0, 0, 0, INT_MAX}, {1, 1, 1, 1}}, + {{"begin_mask", {1, 1, 1, 0}}, + {"end_mask", {1, 1, 1, 0}}, + {"new_axis_mask", {}}, + {"shrink_axis_mask", {}}, + {"ellipsis_mask", {}}}); + auto cat_Concat_425 = makeOP({flatten_Reshape_421, slice_Slice_363}, {{"axis", -1}}); + return std::make_shared(ov::NodeVector{cat_Concat_425}, + ov::ParameterVector{input, cos_sin_cache, position_ids}); + } + void SetUp() override { + targetDevice = ov::test::utils::DEVICE_CPU; + + const int batch = 2; + const int seq_length = 7; + const int num_head = 32; + const int rotary_dims = 64; + + InputShape inpShape = {{-1, batch, 4096 + 256 + 256}, {{seq_length, batch, 4096 + 256 + 256}}}; + init_input_shapes({inpShape}); + function = buildROPE_ChatGLM(batch, num_head, rotary_dims); + } +}; + +TEST_F(RoPECPUTestChatGLM, smoke_CompareWithRefs) { run(); + CheckNumberOfNodesWithType(compiledModel, "RoPE", 1); } -} // namespace CPULayerTestsDefinitions +} // namespace test +} // namespace ov diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/seq_native_order.cpp b/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/seq_native_order.cpp index 5c8d1d8e2ddcf2..5c20ec3a6440cd 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/seq_native_order.cpp +++ b/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/seq_native_order.cpp @@ -2,16 +2,19 @@ // SPDX-License-Identifier: Apache-2.0 // +#include "common_test_utils/node_builders/gru_cell.hpp" +#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 "ov_models/builders.hpp" #include "test_utils/cpu_test_utils.hpp" #include "transformations/op_conversions/bidirectional_sequences_decomposition.hpp" #include "transformations/op_conversions/convert_sequences_to_tensor_iterator.hpp" using namespace CPUTestUtils; -using namespace ov::test; +using namespace ov::test::utils; -namespace SubgraphTestsDefinitions { +namespace ov { +namespace test { enum class SEQ_TYPE { GRU, @@ -34,7 +37,7 @@ using SeqParams = std::tuple; // 'sequence_lengths' input type + InputLayerType>; // 'sequence_lengths' input type class SequenceCPUTest : public testing::WithParamInterface, virtual public ov::test::SubgraphBaseTest, public CPUTestsBase { public: @@ -47,7 +50,7 @@ class SequenceCPUTest : public testing::WithParamInterface, virtual p bool linearBeforeReset; ov::op::RecurrentSequenceDirection direction; ElementType netPrecision; - ngraph::helpers::InputLayerType seqInType; + InputLayerType seqInType; std::tie(seqType, hidden_size, input_size, inShapeParams, activations, clip, linearBeforeReset, direction, netPrecision, seqInType) = obj.param; @@ -141,7 +144,7 @@ class SequenceCPUTest : public testing::WithParamInterface, virtual p weightShape.push_back(B_shape); ov::PartialShape seq_len_shape(std::vector{bounds[batch_size_pos]}); - if (seqInType == ngraph::helpers::InputLayerType::PARAMETER) { + if (seqInType == InputLayerType::PARAMETER) { inputDynamicShapes.push_back(seq_len_shape); } else { OPENVINO_ASSERT(seq_len_shape.is_static()); @@ -160,7 +163,7 @@ class SequenceCPUTest : public testing::WithParamInterface, virtual p if (seqType == SEQ_TYPE::LSTM) { currTS.emplace_back(std::vector{bs, numDirections, hidden_size}); } - if (seqInType == ngraph::helpers::InputLayerType::PARAMETER) { + if (seqInType == InputLayerType::PARAMETER) { currTS.emplace_back(std::vector{bs}); } targetStaticShapes.push_back(currTS); @@ -168,7 +171,7 @@ class SequenceCPUTest : public testing::WithParamInterface, virtual p // funciton creation std::vector types(inputDynamicShapes.size(), netPrecision); - if (seqInType == ngraph::helpers::InputLayerType::PARAMETER) { + if (seqInType == InputLayerType::PARAMETER) { types.back() = ElementType::i64; } ov::ParameterVector params; @@ -190,45 +193,45 @@ class SequenceCPUTest : public testing::WithParamInterface, virtual p std::shared_ptr seq_node; if (seqType == SEQ_TYPE::GRU) { - seq_node = ngraph::builder::makeGRU(inputs, - weightShape, - hidden_size, - activations, - {}, - {}, - clip, - linearBeforeReset, - true, - direction, - (seqInType == ngraph::helpers::InputLayerType::CONSTANT ? - ngraph::helpers::SequenceTestsMode::CONVERT_TO_TI_MAX_SEQ_LEN_CONST : - ngraph::helpers::SequenceTestsMode::PURE_SEQ_RAND_SEQ_LEN_PARAM)); + seq_node = utils::make_gru( + inputs, + weightShape, + hidden_size, + activations, + {}, + {}, + clip, + linearBeforeReset, + true, + direction, + (seqInType == InputLayerType::CONSTANT ? SequenceTestsMode::CONVERT_TO_TI_MAX_SEQ_LEN_CONST + : SequenceTestsMode::PURE_SEQ_RAND_SEQ_LEN_PARAM)); } else if (seqType == SEQ_TYPE::LSTM) { - seq_node = ngraph::builder::makeLSTM(inputs, - weightShape, - hidden_size, - activations, - {}, - {}, - clip, - true, - direction, - (seqInType == ngraph::helpers::InputLayerType::CONSTANT ? - ngraph::helpers::SequenceTestsMode::CONVERT_TO_TI_MAX_SEQ_LEN_CONST : - ngraph::helpers::SequenceTestsMode::PURE_SEQ_RAND_SEQ_LEN_PARAM)); + seq_node = utils::make_lstm( + inputs, + weightShape, + hidden_size, + activations, + {}, + {}, + clip, + true, + direction, + (seqInType == InputLayerType::CONSTANT ? SequenceTestsMode::CONVERT_TO_TI_MAX_SEQ_LEN_CONST + : SequenceTestsMode::PURE_SEQ_RAND_SEQ_LEN_PARAM)); } else if (seqType == SEQ_TYPE::RNN) { - seq_node = ngraph::builder::makeRNN(inputs, - weightShape, - hidden_size, - activations, - {}, - {}, - clip, - true, - direction, - (seqInType == ngraph::helpers::InputLayerType::CONSTANT ? - ngraph::helpers::SequenceTestsMode::CONVERT_TO_TI_MAX_SEQ_LEN_CONST : - ngraph::helpers::SequenceTestsMode::PURE_SEQ_RAND_SEQ_LEN_PARAM)); + seq_node = utils::make_rnn( + inputs, + weightShape, + hidden_size, + activations, + {}, + {}, + clip, + true, + direction, + (seqInType == InputLayerType::CONSTANT ? SequenceTestsMode::CONVERT_TO_TI_MAX_SEQ_LEN_CONST + : SequenceTestsMode::PURE_SEQ_RAND_SEQ_LEN_PARAM)); } else { OPENVINO_THROW("Unsupported seq type"); } @@ -254,7 +257,7 @@ class SequenceCPUTest : public testing::WithParamInterface, virtual p const size_t batchSize = targetInputStaticShapes[0][1]; const int64_t maxSeqLen = targetInputStaticShapes[0][0]; - if (seqInType == ngraph::helpers::InputLayerType::PARAMETER) { + if (seqInType == InputLayerType::PARAMETER) { const auto& funcInputs = function->inputs(); const auto& seqLenInput = inputs.find(funcInputs[seqLengthInIdx].get_node_shared_ptr()); if (seqLenInput == inputs.end()) @@ -266,7 +269,7 @@ class SequenceCPUTest : public testing::WithParamInterface, virtual p } private: - ngraph::helpers::InputLayerType seqInType; + InputLayerType seqInType; size_t seqLengthInIdx = 2; }; @@ -326,7 +329,7 @@ INSTANTIATE_TEST_SUITE_P(smoke_SequenceCPUTest_dynamic_lstm_rnn, SequenceCPUTest ::testing::ValuesIn(linearBeforeReset), ::testing::ValuesIn(direction), ::testing::ValuesIn(netPrecisions), - ::testing::Values(ngraph::helpers::InputLayerType::PARAMETER)), + ::testing::Values(InputLayerType::PARAMETER)), SequenceCPUTest::getTestCaseName); INSTANTIATE_TEST_SUITE_P(smoke_SequenceCPUTest_dynamic_gru, SequenceCPUTest, @@ -339,7 +342,7 @@ INSTANTIATE_TEST_SUITE_P(smoke_SequenceCPUTest_dynamic_gru, SequenceCPUTest, ::testing::ValuesIn(linearBeforeReset), ::testing::ValuesIn(direction), ::testing::ValuesIn(netPrecisions), - ::testing::Values(ngraph::helpers::InputLayerType::PARAMETER)), + ::testing::Values(InputLayerType::PARAMETER)), SequenceCPUTest::getTestCaseName); INSTANTIATE_TEST_SUITE_P(smoke_SequenceCPUTest_static_gru, SequenceCPUTest, @@ -352,7 +355,7 @@ INSTANTIATE_TEST_SUITE_P(smoke_SequenceCPUTest_static_gru, SequenceCPUTest, ::testing::ValuesIn(linearBeforeReset), ::testing::ValuesIn(direction), ::testing::ValuesIn(netPrecisions), - ::testing::Values(ngraph::helpers::InputLayerType::CONSTANT)), + ::testing::Values(InputLayerType::CONSTANT)), SequenceCPUTest::getTestCaseName); INSTANTIATE_TEST_SUITE_P(smoke_SequenceCPUTest_static_rnn_lstm, SequenceCPUTest, @@ -365,7 +368,8 @@ INSTANTIATE_TEST_SUITE_P(smoke_SequenceCPUTest_static_rnn_lstm, SequenceCPUTest, ::testing::ValuesIn(linearBeforeReset), ::testing::ValuesIn(direction), ::testing::ValuesIn(netPrecisions), - ::testing::Values(ngraph::helpers::InputLayerType::CONSTANT)), + ::testing::Values(InputLayerType::CONSTANT)), SequenceCPUTest::getTestCaseName); -} // namespace SubgraphTestsDefinitions +} // namespace test +} // namespace ov diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/split_concat_add.cpp b/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/split_concat_add.cpp index 12c5588ac7fcf5..82beb9341ae99d 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/split_concat_add.cpp +++ b/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/split_concat_add.cpp @@ -2,9 +2,10 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "shared_test_classes/base/ov_subgraph.hpp" -#include "ov_models/utils/ov_helpers.hpp" +#include "common_test_utils/node_builders/eltwise.hpp" #include "ov_models/builders.hpp" +#include "ov_models/utils/ov_helpers.hpp" +#include "shared_test_classes/base/ov_subgraph.hpp" /*This test runs the following subgraph: @@ -29,10 +30,8 @@ The main purpose of the test is to check the memory sharing between result and in_place edges. */ -using namespace InferenceEngine; -using namespace ov::test; - -namespace SubgraphTestsDefinitions { +namespace ov { +namespace test { class SplitConcatAddInPlace : virtual public ov::test::SubgraphBaseTest { protected: @@ -50,17 +49,17 @@ class SplitConcatAddInPlace : virtual public ov::test::SubgraphBaseTest { auto split = std::make_shared(params.front(), split_axis_op, 3); auto add_const = ngraph::builder::makeConstant(precision, {1}, std::vector({1.0f})); - auto add_1 = ngraph::builder::makeEltwise(split->output(0), add_const, ngraph::helpers::EltwiseTypes::ADD); - auto result_add_1 = std::make_shared(add_1); - auto add_2 = ngraph::builder::makeEltwise(split->output(1), add_const, ngraph::helpers::EltwiseTypes::ADD); - auto add_3 = ngraph::builder::makeEltwise(split->output(2), add_const, ngraph::helpers::EltwiseTypes::ADD); + auto add_1 = utils::makeEltwise(split->output(0), add_const, utils::EltwiseTypes::ADD); + auto result_add_1 = std::make_shared(add_1); + auto add_2 = utils::makeEltwise(split->output(1), add_const, utils::EltwiseTypes::ADD); + auto add_3 = utils::makeEltwise(split->output(2), add_const, utils::EltwiseTypes::ADD); auto concat = std::make_shared(ov::NodeVector{add_1, add_2, add_3}, 1); - auto result_concat = std::make_shared(concat); - auto add_4 = ngraph::builder::makeEltwise(concat, add_const, ngraph::helpers::EltwiseTypes::ADD); - auto add_5 = ngraph::builder::makeEltwise(concat, add_const, ngraph::helpers::EltwiseTypes::ADD); - auto result_1 = std::make_shared(add_4); - auto result_2 = std::make_shared(add_5); - ngraph::ResultVector results = {result_1, result_2, result_add_1, result_concat}; + auto result_concat = std::make_shared(concat); + auto add_4 = utils::makeEltwise(concat, add_const, utils::EltwiseTypes::ADD); + auto add_5 = utils::makeEltwise(concat, add_const, utils::EltwiseTypes::ADD); + auto result_1 = std::make_shared(add_4); + auto result_2 = std::make_shared(add_5); + ov::ResultVector results = {result_1, result_2, result_add_1, result_concat}; function = std::make_shared(results, params, "Subgraph"); } }; @@ -69,4 +68,5 @@ TEST_F(SplitConcatAddInPlace, smoke_CompareWithRefs) { run(); } -} // namespace SubgraphTestsDefinitions \ No newline at end of file +} // namespace test +} // namespace ov \ No newline at end of file diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/split_matmul_concat.cpp b/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/split_matmul_concat.cpp index 6a77c027e9df97..b1cdb1c258b581 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/split_matmul_concat.cpp +++ b/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/split_matmul_concat.cpp @@ -6,12 +6,10 @@ #include "ov_models/builders.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -using namespace ngraph; -using namespace InferenceEngine; using namespace CPUTestUtils; -using namespace ov::test; -namespace SubgraphTestsDefinitions { +namespace ov { +namespace test { /* --------------- @@ -107,9 +105,9 @@ class SplitMatMulConcatTest : public testing::WithParamInterface(ElementType::f32, inShapeA)}; - std::shared_ptr inputB = builder::makeConstant(ElementType::f32, inShapeB.get_shape(), {}, true); + std::shared_ptr inputB = ngraph::builder::makeConstant(ElementType::f32, inShapeB.get_shape(), {}, true); - auto split = builder::makeVariadicSplit(params[0], {1, 1}, 0); + auto split = ngraph::builder::makeVariadicSplit(params[0], {1, 1}, 0); auto matMul = std::make_shared(split->output(0), inputB, transpA, transpB); @@ -143,4 +141,5 @@ INSTANTIATE_TEST_SUITE_P(smoke_FC_2D_FP32, SplitMatMulConcatTest, testParams2D_F } // namespace -} // namespace SubgraphTestsDefinitions +} // namespace test +} // namespace ov diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/static_zero_dims.cpp b/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/static_zero_dims.cpp index 1072890e51774b..4d304f5d19002d 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/static_zero_dims.cpp +++ b/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/static_zero_dims.cpp @@ -2,14 +2,12 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "shared_test_classes/base/ov_subgraph.hpp" +#include "common_test_utils/ov_tensor_utils.hpp" #include "ov_models/builders.hpp" -#include -#include "functional_test_utils/skip_tests_config.hpp" - -using namespace ov::test; +#include "shared_test_classes/base/ov_subgraph.hpp" -namespace SubgraphTestsDefinitions { +namespace ov { +namespace test { class StaticZeroDims : public SubgraphBaseTest { protected: @@ -20,26 +18,26 @@ class StaticZeroDims : public SubgraphBaseTest { init_input_shapes({inputShapes}); - auto ngPrc = ngraph::element::f32; + auto ngPrc = ov::element::f32; ov::ParameterVector inputParams; for (auto&& shape : inputDynamicShapes) { inputParams.push_back(std::make_shared(ngPrc, shape)); } - auto splitAxisOp = std::make_shared(ngraph::element::i64, ngraph::Shape{}, std::vector{0}); + auto splitAxisOp = std::make_shared(ov::element::i64, ov::Shape{}, std::vector{0}); std::vector splitLenght = {1, 0, 6}; - auto splitLengthsOp = std::make_shared(ngraph::element::i32, ngraph::Shape{splitLenght.size()}, splitLenght); - auto varSplit = std::make_shared(inputParams[0], splitAxisOp, splitLengthsOp); + auto splitLengthsOp = std::make_shared(ov::element::i32, ov::Shape{splitLenght.size()}, splitLenght); + auto varSplit = std::make_shared(inputParams[0], splitAxisOp, splitLengthsOp); - auto relu1 = std::make_shared(varSplit->output(0)); + auto relu1 = std::make_shared(varSplit->output(0)); auto numInRoi = ngraph::builder::makeConstant(ngPrc, {0}, std::vector{}, false); auto expDet = std::make_shared(varSplit->output(1), numInRoi, 10); - auto relu2 = std::make_shared(expDet); + auto relu2 = std::make_shared(expDet); - auto relu3 = std::make_shared(varSplit->output(2)); + auto relu3 = std::make_shared(varSplit->output(2)); - ngraph::NodeVector results{relu1, relu2, relu3}; - function = std::make_shared(results, inputParams, "StaticZeroDims"); + ov::NodeVector results{relu1, relu2, relu3}; + function = std::make_shared(results, inputParams, "StaticZeroDims"); } void compare(const std::vector &expected, const std::vector &actual) override { @@ -59,4 +57,5 @@ TEST_F(StaticZeroDims, smoke_CompareWithRefs) { run(); } -} // namespace SubgraphTestsDefinitions +} // namespace test +} // namespace ov diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/strided_slice_zero_dims.cpp b/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/strided_slice_zero_dims.cpp index 6d888bbba8d9f6..976c4d7de463bb 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/strided_slice_zero_dims.cpp +++ b/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/strided_slice_zero_dims.cpp @@ -6,11 +6,8 @@ #include "ov_models/utils/ov_helpers.hpp" #include "ov_models/builders.hpp" -using namespace InferenceEngine; -using namespace ov::test; -using namespace ngraph; - -namespace SubgraphTestsDefinitions { +namespace ov { +namespace test { /* param1 [56] param2 [-1, -1, 768] (dynamic shape) @@ -40,12 +37,12 @@ class StridedSliceZeroDimsTest : public SubgraphBaseTest { for (auto&& shape : inputDynamicShapes) { inputParams.push_back(std::make_shared(ov::element::f32, shape)); } - auto end = builder::makeConstant(element::i64, {1}, std::vector{2147483647}); - auto stride = builder::makeConstant(element::i64, {1}, std::vector{1}); - auto indices = builder::makeConstant(element::i64, {1}, std::vector{1}); - auto axes = builder::makeConstant(element::i64, {1}, std::vector{0}); - auto shapeOf = std::make_shared(inputParams[1]); - auto gather = std::make_shared(shapeOf, indices, axes); + auto end = ngraph::builder::makeConstant(element::i64, {1}, std::vector{2147483647}); + auto stride = ngraph::builder::makeConstant(element::i64, {1}, std::vector{1}); + auto indices = ngraph::builder::makeConstant(element::i64, {1}, std::vector{1}); + auto axes = ngraph::builder::makeConstant(element::i64, {1}, std::vector{0}); + auto shapeOf = std::make_shared(inputParams[1]); + auto gather = std::make_shared(shapeOf, indices, axes); auto strided_slice = std::make_shared(inputParams.front(), gather, end, @@ -56,7 +53,7 @@ class StridedSliceZeroDimsTest : public SubgraphBaseTest { std::vector{}, std::vector{}); NodeVector results{strided_slice}; - function = std::make_shared(results, inputParams, "StridedSliceStaticShape"); + function = std::make_shared(results, inputParams, "StridedSliceStaticShape"); } }; @@ -64,4 +61,5 @@ TEST_F(StridedSliceZeroDimsTest, smoke_CompareWithRefs) { run(); } -} // namespace SubgraphTestsDefinitions \ No newline at end of file +} // namespace test +} // namespace ov \ No newline at end of file diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/subgraph_serialize.cpp b/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/subgraph_serialize.cpp index b3e2912855dbe3..8432cf90a46d7c 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/subgraph_serialize.cpp +++ b/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/subgraph_serialize.cpp @@ -12,7 +12,8 @@ using namespace CPUTestUtils; using namespace ov::opset9; -namespace SubgraphTestsDefinitions { +namespace ov { +namespace test { class SubgraphSnippetSerializationTest : public ::testing::Test, public CPUTestsBase {}; @@ -146,4 +147,5 @@ TEST_F(SubgraphSnippetSerializationTest, smoke_SerializeSubgraphWithResultAs1stO ASSERT_TRUE(results.valid) << results.message; } -} // namespace SubgraphTestsDefinitions +} // namespace test +} // namespace ov diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/subgraph_with_blocked_format.cpp b/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/subgraph_with_blocked_format.cpp index 807e458ee4deb6..8eefc9e644ba72 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/subgraph_with_blocked_format.cpp +++ b/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/subgraph_with_blocked_format.cpp @@ -2,44 +2,64 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "test_utils/cpu_test_utils.hpp" #include "ov_models/builders.hpp" -#include - -using namespace ngraph; +#include "shared_test_classes/base/ov_subgraph.hpp" +#include "test_utils/cpu_test_utils.hpp" +#include "openvino/opsets/opset8.hpp" -namespace SubgraphTestsDefinitions { +namespace ov { +namespace test { -class SubgraphWithBlockedFormat : virtual public LayerTestsUtils::LayerTestsCommon { +class SubgraphWithBlockedFormat : virtual public SubgraphBaseStaticTest { protected: void SetUp() override { targetDevice = ov::test::utils::DEVICE_CPU; + abs_threshold = 1e-2; auto type = element::f32; - auto param = std::make_shared(type, Shape{1, 32, 64, 32}); - auto weights = builder::makeConstant(type, Shape{32, 32, 1, 1}, std::vector{}, true); - auto conv = std::make_shared(param, weights, Strides{1, 1}, CoordinateDiff{0, 0}, CoordinateDiff{0, 0}, Strides{1, 1}); - auto mean = std::make_shared(conv, opset8::Constant::create(element::i32, Shape{2}, {2, 3}), true); - auto reshape_before = std::make_shared(mean, opset8::Constant::create(element::i32, Shape{3}, {0, 16, -1}), true); - auto mvn = std::make_shared(reshape_before, opset8::Constant::create(element::i32, Shape{1}, {2}), - false, 0.1, op::MVNEpsMode::INSIDE_SQRT); - auto reshape_after = std::make_shared(mvn, std::make_shared(mean), false); - auto mul = std::make_shared(reshape_after, builder::makeConstant(type, Shape{32, 1, 1}, std::vector{}, true)); - auto add = std::make_shared(mul, builder::makeConstant(type, Shape{32, 1, 1}, std::vector{}, true)); - auto sigmoid = std::make_shared(add); - auto mul2 = std::make_shared(conv, sigmoid); - - function = std::make_shared(mul2, ParameterVector{param}); + auto param = std::make_shared(type, Shape{1, 32, 64, 32}); + auto weights = ngraph::builder::makeConstant(type, Shape{32, 32, 1, 1}, std::vector{}, true); + auto conv = std::make_shared(param, + weights, + Strides{1, 1}, + CoordinateDiff{0, 0}, + CoordinateDiff{0, 0}, + Strides{1, 1}); + auto mean = + std::make_shared(conv, + ov::opset8::Constant::create(element::i32, Shape{2}, {2, 3}), + true); + auto reshape_before = + std::make_shared(mean, + ov::opset8::Constant::create(element::i32, Shape{3}, {0, 16, -1}), + true); + auto mvn = std::make_shared(reshape_before, + ov::opset8::Constant::create(element::i32, Shape{1}, {2}), + false, + 0.1, + op::MVNEpsMode::INSIDE_SQRT); + auto reshape_after = + std::make_shared(mvn, std::make_shared(mean), false); + auto mul = std::make_shared( + reshape_after, + ngraph::builder::makeConstant(type, Shape{32, 1, 1}, std::vector{}, true)); + auto add = std::make_shared( + mul, + ngraph::builder::makeConstant(type, Shape{32, 1, 1}, std::vector{}, true)); + auto sigmoid = std::make_shared(add); + auto mul2 = std::make_shared(conv, sigmoid); + + function = std::make_shared(mul2, ParameterVector{param}); } void TearDown() override { - auto runtime_function = executableNetwork.GetExecGraphInfo().getFunction(); + auto runtime_function = compiledModel.get_runtime_model(); int nodes_found = 0; for (const auto& n : runtime_function->get_ordered_ops()) { - auto layer_type = n->get_rt_info().at(ExecGraphInfoSerialization::LAYER_TYPE).as(); + auto layer_type = n->get_rt_info().at(ov::exec_model_info::LAYER_TYPE).as(); if (layer_type == "Subgraph") { nodes_found++; - auto output_layout = n->get_rt_info().at(ExecGraphInfoSerialization::OUTPUT_LAYOUTS).as(); + auto output_layout = n->get_rt_info().at(ov::exec_model_info::OUTPUT_LAYOUTS).as(); // convolution maybe chooses 'nhwc' and the subgraph will follow it ASSERT_TRUE(output_layout == "aBcd8b" || output_layout == "aBcd16b" || output_layout == "acdb"); } @@ -49,7 +69,8 @@ class SubgraphWithBlockedFormat : virtual public LayerTestsUtils::LayerTestsComm }; TEST_F(SubgraphWithBlockedFormat, smoke_CompareWithRefs) { - Run(); + run(); } -} // namespace SubgraphTestsDefinitions +} // namespace test +} // 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/subgraph_tests/src/tile_with_two_output_edges.cpp index 97c12a7131cfb6..c3c861d1efef4f 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/tile_with_two_output_edges.cpp +++ b/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/tile_with_two_output_edges.cpp @@ -2,18 +2,18 @@ // SPDX-License-Identifier: Apache-2.0 // +#include "common_test_utils/node_builders/eltwise.hpp" #include "ov_models/builders.hpp" +#include "shared_test_classes/base/ov_subgraph.hpp" #include "test_utils/cpu_test_utils.hpp" -using namespace ngraph; -using ngraph::helpers::EltwiseTypes; +namespace ov { +namespace test { -namespace SubgraphTestsDefinitions { - -class TileWithTwoOutputEdges : public LayerTestsUtils::LayerTestsCommon { +class TileWithTwoOutputEdges : public SubgraphBaseStaticTest { protected: void SetUp() override { - targetDevice = ov::test::utils::DEVICE_CPU; + targetDevice = utils::DEVICE_CPU; auto ngPrc = element::f32; ov::ParameterVector inputParams {std::make_shared(ngPrc, ov::Shape{1, 3, 12, 9})}; @@ -25,16 +25,17 @@ class TileWithTwoOutputEdges : public LayerTestsUtils::LayerTestsCommon { const auto const1 = ngraph::builder::makeConstant(ngPrc, std::vector{1, 6, 1, 1}, std::vector{}, true); const auto const2 = ngraph::builder::makeConstant(ngPrc, std::vector{1, 6, 1, 1}, std::vector{}, true); - const auto add1 = ngraph::builder::makeEltwise(tile->output(0), const1, ngraph::helpers::EltwiseTypes::ADD); - const auto add2 = ngraph::builder::makeEltwise(tile->output(0), const2, ngraph::helpers::EltwiseTypes::ADD); + const auto add1 = utils::makeEltwise(tile->output(0), const1, utils::EltwiseTypes::ADD); + const auto add2 = utils::makeEltwise(tile->output(0), const2, utils::EltwiseTypes::ADD); NodeVector results{add1, add2}; - function = std::make_shared(results, inputParams, "TileWithTwoOutputEdges"); + function = std::make_shared(results, inputParams, "TileWithTwoOutputEdges"); } }; TEST_F(TileWithTwoOutputEdges, smoke_CompareWithRefs) { - Run(); + run(); } -} // namespace SubgraphTestsDefinitions +} // namespace test +} // namespace ov diff --git a/src/plugins/intel_cpu/tests/functional/test_utils/arm/filter_cpu_info.cpp b/src/plugins/intel_cpu/tests/functional/test_utils/arm/filter_cpu_info.cpp index bb16db068b01ec..21a3e8d76b8529 100644 --- a/src/plugins/intel_cpu/tests/functional/test_utils/arm/filter_cpu_info.cpp +++ b/src/plugins/intel_cpu/tests/functional/test_utils/arm/filter_cpu_info.cpp @@ -4,11 +4,9 @@ #include "test_utils/cpu_test_utils.hpp" #include "test_utils/filter_cpu_info.hpp" -#include "ie_ngraph_utils.hpp" #include "openvino/core/type/element_type.hpp" #include "utils/rt_info/memory_formats_attribute.hpp" #include "utils/general_utils.h" -#include namespace CPUTestUtils { @@ -28,7 +26,11 @@ std::vector filterCPUInfoForArch(const std::vector +#include "utils/rt_info/memory_formats_attribute.hpp" namespace CPUTestUtils { const char* CPUTestsBase::any_type = "any_type"; @@ -147,14 +146,14 @@ void CPUTestsBase::CheckPluginRelatedResultsImpl(const std::shared_ptrsecond.as(); }; - auto getExecValueOutputsLayout = [] (const std::shared_ptr& node) -> std::string { + auto getExecValueOutputsLayout = [] (const std::shared_ptr& node) -> std::string { auto rtInfo = node->get_rt_info(); - auto it = rtInfo.find(ExecGraphInfoSerialization::OUTPUT_LAYOUTS); + auto it = rtInfo.find(ov::exec_model_info::OUTPUT_LAYOUTS); OPENVINO_ASSERT(rtInfo.end() != it); return it->second.as(); }; // skip policy - auto should_be_skipped = [] (const ngraph::PartialShape &partialShape, cpu_memory_format_t fmt) { + auto should_be_skipped = [] (const ov::PartialShape &partialShape, cpu_memory_format_t fmt) { if (partialShape.is_dynamic()) { return false; } @@ -165,7 +164,7 @@ void CPUTestsBase::CheckPluginRelatedResultsImpl(const std::shared_ptrget_input_size()); ASSERT_LE(outFmts.size(), node->get_output_size()); for (size_t i = 0; i < inFmts.size(); i++) { @@ -211,7 +210,7 @@ void CPUTestsBase::CheckPluginRelatedResultsImpl(const std::shared_ptrget_output_partial_shape(i); if (should_be_skipped(shape, outFmts[i])) @@ -219,7 +218,7 @@ void CPUTestsBase::CheckPluginRelatedResultsImpl(const std::shared_ptr& inFmts, return cpuInfo; } -std::shared_ptr -CPUTestsBase::makeNgraphFunction(const ngraph::element::Type &ngPrc, ngraph::ParameterVector ¶ms, - const std::shared_ptr &lastNode, std::string name) { +std::shared_ptr +CPUTestsBase::makeNgraphFunction(const ov::element::Type &ngPrc, ov::ParameterVector ¶ms, + const std::shared_ptr &lastNode, std::string name) { auto newLastNode = modifyGraph(ngPrc, params, lastNode); - ngraph::ResultVector results; + ov::ResultVector results; for (size_t i = 0; i < newLastNode->get_output_size(); i++) - results.push_back(std::make_shared(newLastNode->output(i))); + results.push_back(std::make_shared(newLastNode->output(i))); - return std::make_shared(results, params, name); + return std::make_shared(results, params, name); } -std::shared_ptr -CPUTestsBase::modifyGraph(const ngraph::element::Type &ngPrc, ngraph::ParameterVector ¶ms, const std::shared_ptr &lastNode) { +std::shared_ptr +CPUTestsBase::modifyGraph(const ov::element::Type &ngPrc, ov::ParameterVector ¶ms, const std::shared_ptr &lastNode) { lastNode->get_rt_info() = getCPUInfo(); return lastNode; } -std::string CPUTestsBase::makeSelectedTypeStr(std::string implString, ngraph::element::Type_t elType) { +std::string CPUTestsBase::makeSelectedTypeStr(std::string implString, ov::element::Type_t elType) { implString.push_back('_'); implString += ov::element::Type(elType).get_type_name(); return implString; @@ -418,7 +417,7 @@ std::vector filterCPUSpecificParams(const std::vector filteredParamsVector = paramsVector; - if (!InferenceEngine::with_cpu_x86_avx512f()) { + if (!ov::with_cpu_x86_avx512f()) { for (auto& param : filteredParamsVector) { adjustBlockedFormatByIsa(std::get<0>(param)); adjustBlockedFormatByIsa(std::get<1>(param)); @@ -441,7 +440,7 @@ inline void CheckNumberOfNodesWithTypeImpl(std::shared_ptr func return it->second.as(); }; - if (nodeTypes.count(getExecValue(ExecGraphInfoSerialization::LAYER_TYPE))) { + if (nodeTypes.count(getExecValue(ov::exec_model_info::LAYER_TYPE))) { actualNodeCount++; } } diff --git a/src/plugins/intel_cpu/tests/functional/test_utils/cpu_test_utils.hpp b/src/plugins/intel_cpu/tests/functional/test_utils/cpu_test_utils.hpp index 8777314f4980bf..06696c5824babe 100644 --- a/src/plugins/intel_cpu/tests/functional/test_utils/cpu_test_utils.hpp +++ b/src/plugins/intel_cpu/tests/functional/test_utils/cpu_test_utils.hpp @@ -4,13 +4,15 @@ #pragma once -#include -#include "ie_system_conf.h" +#include "openvino/runtime/compiled_model.hpp" +#include "openvino/runtime/exec_model_info.hpp" +#include "openvino/runtime/system_conf.hpp" #include "shared_test_classes/base/layer_test_utils.hpp" #include "transformations/rt_info/primitives_priority_attribute.hpp" -#include -#include + +// To be removed #include "ie_system_conf.h" +#include "exec_graph_info.hpp" namespace CPUTestUtils { typedef enum { @@ -128,13 +130,13 @@ class CPUTestsBase { const std::vector& outFmts, const std::vector& priority); //TODO: change to setter method - static std::string makeSelectedTypeStr(std::string implString, ngraph::element::Type_t elType); + static std::string makeSelectedTypeStr(std::string implString, ov::element::Type_t elType); void updateSelectedType(const std::string& primitiveType, const ov::element::Type netType, const ov::AnyMap& config); CPUInfo getCPUInfo() const; - std::shared_ptr makeNgraphFunction(const ngraph::element::Type &ngPrc, - ngraph::ParameterVector ¶ms, - const std::shared_ptr &lastNode, + std::shared_ptr makeNgraphFunction(const ov::element::Type &ngPrc, + ov::ParameterVector ¶ms, + const std::shared_ptr &lastNode, std::string name); void CheckPluginRelatedResults(InferenceEngine::ExecutableNetwork &execNet, const std::set& nodeType) const; @@ -153,9 +155,9 @@ class CPUTestsBase { * @param lastNode The last node of the initial graph. * @return The last node of the modified graph. */ - virtual std::shared_ptr modifyGraph(const ngraph::element::Type &ngPrc, - ngraph::ParameterVector ¶ms, - const std::shared_ptr &lastNode); + virtual std::shared_ptr modifyGraph(const ov::element::Type& ngPrc, + ov::ParameterVector& params, + const std::shared_ptr& lastNode); virtual bool primTypeCheck(std::string primType) const; @@ -171,11 +173,9 @@ class CPUTestsBase { const auto emptyCPUSpec = CPUSpecificParams{{}, {}, {}, {}}; const std::map cpuEmptyPluginConfig; const ov::AnyMap empty_plugin_config{}; -const std::map cpuFP32PluginConfig = - { { InferenceEngine::PluginConfigParams::KEY_ENFORCE_BF16, InferenceEngine::PluginConfigParams::NO } }; const std::map cpuBF16PluginConfig = { { InferenceEngine::PluginConfigParams::KEY_ENFORCE_BF16, InferenceEngine::PluginConfigParams::YES } }; - +const ov::AnyMap cpu_bf16_plugin_config = {{ov::hint::inference_precision(ov::element::bf16)}}; // utility functions std::vector filterCPUSpecificParams(const std::vector& paramsVector); diff --git a/src/plugins/intel_cpu/tests/functional/test_utils/fusing_test_utils.cpp b/src/plugins/intel_cpu/tests/functional/test_utils/fusing_test_utils.cpp index c1aef766be4f86..1e03755270ac97 100644 --- a/src/plugins/intel_cpu/tests/functional/test_utils/fusing_test_utils.cpp +++ b/src/plugins/intel_cpu/tests/functional/test_utils/fusing_test_utils.cpp @@ -8,7 +8,6 @@ using namespace LayerTestsDefinitions; namespace CPUTestUtils { - std::string CpuTestWithFusing::getTestCaseName(fusingSpecificParams params) { std::ostringstream result; std::vector fusedOps; @@ -25,10 +24,10 @@ std::string CpuTestWithFusing::getTestCaseName(fusingSpecificParams params) { return result.str(); } -std::shared_ptr -CpuTestWithFusing::modifyGraph(const ngraph::element::Type &ngPrc, ngraph::ParameterVector ¶ms, const std::shared_ptr &lastNode) { +std::shared_ptr +CpuTestWithFusing::modifyGraph(const ov::element::Type &ngPrc, ov::ParameterVector ¶ms, const std::shared_ptr &lastNode) { CPUTestsBase::modifyGraph(ngPrc, params, lastNode); - std::shared_ptr retNode = lastNode; + std::shared_ptr retNode = lastNode; if (postOpMgrPtr) { retNode = postOpMgrPtr->addPostOps(ngPrc, params, lastNode); } @@ -42,7 +41,7 @@ void CpuTestWithFusing::CheckFusingResults(const std::shared_ptrget_ops()) { const auto &rtInfo = op->get_rt_info(); - auto getExecValue = [](const std::string ¶mName, const ngraph::Node::RTMap& rtInfo) -> std::string { + auto getExecValue = [](const std::string ¶mName, const ov::Node::RTMap& rtInfo) -> std::string { auto it = rtInfo.find(paramName); OPENVINO_ASSERT(rtInfo.end() != it); return it->second.as(); @@ -76,9 +75,9 @@ void CpuTestWithFusing::CheckPluginRelatedResultsImpl(const std::shared_ptr -postFunctionMgr::addPostOps(const ngraph::element::Type &ngPrc, ngraph::ParameterVector ¶ms, const std::shared_ptr &lastNode) const { - auto clonedPostFunction = ngraph::clone_function(*_pFunction); +std::shared_ptr +postFunctionMgr::addPostOps(const ov::element::Type &ngPrc, ov::ParameterVector ¶ms, const std::shared_ptr &lastNode) const { + auto clonedPostFunction = ov::clone_model(*_pFunction); clonedPostFunction->set_friendly_name(_pFunction->get_friendly_name()); clonedPostFunction->replace_node(clonedPostFunction->get_parameters()[0], lastNode); return clonedPostFunction->get_result()->get_input_node_shared_ptr(0); @@ -90,9 +89,9 @@ std::string postFunctionMgr::getFusedOpsNames() const { postNodesMgr::postNodesMgr(std::vector postNodes) : _postNodes(std::move(postNodes)) {} -std::shared_ptr -postNodesMgr::addPostOps(const ngraph::element::Type &ngPrc, ngraph::ParameterVector ¶ms, const std::shared_ptr &lastNode) const { - std::shared_ptr tmpNode = lastNode; +std::shared_ptr +postNodesMgr::addPostOps(const ov::element::Type &ngPrc, ov::ParameterVector ¶ms, const std::shared_ptr &lastNode) const { + std::shared_ptr tmpNode = lastNode; postNodeConfig cfg{lastNode, tmpNode, ngPrc, params}; diff --git a/src/plugins/intel_cpu/tests/functional/test_utils/fusing_test_utils.hpp b/src/plugins/intel_cpu/tests/functional/test_utils/fusing_test_utils.hpp index a11755f826c58e..c084a775509467 100644 --- a/src/plugins/intel_cpu/tests/functional/test_utils/fusing_test_utils.hpp +++ b/src/plugins/intel_cpu/tests/functional/test_utils/fusing_test_utils.hpp @@ -4,51 +4,55 @@ #pragma once +#include "common_test_utils/node_builders/activation.hpp" #include "cpu_test_utils.hpp" -#include -#include +#include "openvino/runtime/system_conf.hpp" +#include "ov_models/utils/data_utils.hpp" +#include "shared_test_classes/single_layer/activation.hpp" + +using namespace ov::test; namespace CPUTestUtils { struct postNodeConfig { - const std::shared_ptr target; - std::shared_ptr input; - const ngraph::element::Type& type; - ngraph::ParameterVector& params; + const std::shared_ptr target; + std::shared_ptr input; + const ov::element::Type& type; + ov::ParameterVector& params; }; struct postNodeBuilder { - std::function(postNodeConfig& cfg)> makeNode; + std::function(postNodeConfig& cfg)> makeNode; std::string name; }; class postOpMgr { public: - virtual std::shared_ptr addPostOps(const ngraph::element::Type &ngPrc, - ngraph::ParameterVector ¶ms, - const std::shared_ptr &lastNode) const = 0; + virtual std::shared_ptr addPostOps(const ov::element::Type& ngPrc, + ov::ParameterVector& params, + const std::shared_ptr& lastNode) const = 0; virtual std::string getFusedOpsNames() const = 0; virtual ~postOpMgr() = default; }; class postFunctionMgr : public postOpMgr { public: - postFunctionMgr(std::shared_ptr function) : _pFunction(std::move(function)) {} - std::shared_ptr addPostOps(const ngraph::element::Type &ngPrc, - ngraph::ParameterVector ¶ms, - const std::shared_ptr &lastNode) const override; + postFunctionMgr(std::shared_ptr function) : _pFunction(std::move(function)) {} + std::shared_ptr addPostOps(const ov::element::Type& ngPrc, + ov::ParameterVector& params, + const std::shared_ptr& lastNode) const override; std::string getFusedOpsNames() const override; private: - std::shared_ptr _pFunction; + std::shared_ptr _pFunction; }; class postNodesMgr : public postOpMgr { public: postNodesMgr(std::vector postNodes); - std::shared_ptr addPostOps(const ngraph::element::Type &ngPrc, - ngraph::ParameterVector ¶ms, - const std::shared_ptr &lastNode) const override; + std::shared_ptr addPostOps(const ov::element::Type& ngPrc, + ov::ParameterVector& params, + const std::shared_ptr& lastNode) const override; std::string getFusedOpsNames() const override; private: @@ -68,9 +72,9 @@ class CpuTestWithFusing : public CPUTestsBase { /** * @brief This function adds post operations. */ - std::shared_ptr modifyGraph(const ngraph::element::Type &ngPrc, - ngraph::ParameterVector ¶ms, - const std::shared_ptr &lastNode) override; + std::shared_ptr modifyGraph(const ov::element::Type& ngPrc, + ov::ParameterVector& params, + const std::shared_ptr& lastNode) override; void CheckPluginRelatedResultsImpl(const std::shared_ptr& function, const std::set& nodeType) const override; @@ -99,25 +103,25 @@ static int getChannelAxis(const ov::AxisSet &axes, bool keep_dims) { return channelAxis; } -static int getFusingAxis(const std::shared_ptr& node) { - if (std::dynamic_pointer_cast(node)) { +static int getFusingAxis(const std::shared_ptr& node) { + if (std::dynamic_pointer_cast(node)) { return node->get_output_partial_shape(0).size() - 1; // last dimension - } else if (const auto reduce = std::dynamic_pointer_cast(node)) { + } else if (const auto reduce = std::dynamic_pointer_cast(node)) { return getChannelAxis(reduce->get_reduction_axes(), reduce->get_keep_dims()); - } else if (const auto reduce = std::dynamic_pointer_cast(node)) { + } else if (const auto reduce = std::dynamic_pointer_cast(node)) { return getChannelAxis(reduce->get_reduction_axes(), reduce->get_keep_dims()); } else { return 1; // second dimension } } -static ngraph::Shape generatePerChannelShape(const std::shared_ptr& node) { +static ov::Shape generatePerChannelShape(const std::shared_ptr& node) { const auto shape = node->get_output_partial_shape(0); if (shape.size() == 0) OPENVINO_THROW("If shape.size() == 0 then PerTensor fusing tests are N/A"); if (shape.size() == 1) OPENVINO_THROW("If shape.size() == 1 then Granularity can be PerTensor only"); - ngraph::Shape perChannelShape(shape.size(), 1); + ov::Shape perChannelShape(shape.size(), 1); const auto channelAxis = getFusingAxis(node); if (channelAxis >= 0) perChannelShape[channelAxis] = shape[channelAxis].get_length(); @@ -130,176 +134,176 @@ const auto emptyFusingSpec = fusingSpecificParams{nullptr, {}}; const auto fusingRelu = fusingSpecificParams{std::make_shared(std::vector{ {[](postNodeConfig& cfg){ - return ngraph::builder::makeActivation(cfg.input, cfg.type, ngraph::helpers::Relu); + return utils::make_activation(cfg.input, cfg.type, utils::Relu); }, "Relu"}}), {"Relu"}}; const auto fusingElu = fusingSpecificParams{std::make_shared(std::vector{ {[](postNodeConfig& cfg){ - return ngraph::builder::makeActivation(cfg.input, cfg.type, ngraph::helpers::Elu, {}, {2.0f}); + return utils::make_activation(cfg.input, cfg.type, utils::Elu, {}, {2.0f}); }, "Elu"}}), {"Elu"}}; const auto fusingGelu = fusingSpecificParams{std::make_shared(std::vector{ {[](postNodeConfig& cfg){ - return ngraph::builder::makeActivation(cfg.input, cfg.type, ngraph::helpers::Gelu); + return utils::make_activation(cfg.input, cfg.type, utils::Gelu); }, "Gelu"}}), {"Gelu"}}; const auto fusingSigmoid = fusingSpecificParams{std::make_shared(std::vector{ {[](postNodeConfig& cfg){ - return ngraph::builder::makeActivation(cfg.input, cfg.type, ngraph::helpers::Sigmoid); + return utils::make_activation(cfg.input, cfg.type, utils::Sigmoid); }, "Sigmoid"}}), {"Sigmoid"}}; const auto fusingClamp = fusingSpecificParams{std::make_shared(std::vector{ {[](postNodeConfig& cfg){ - return ngraph::builder::makeActivation(cfg.input, cfg.type, ngraph::helpers::Clamp, {}, {3.0f, 6.0f}); + return utils::make_activation(cfg.input, cfg.type, utils::Clamp, {}, {3.0f, 6.0f}); }, "Clamp"}}), {"Clamp"}}; const auto fusingTanh = fusingSpecificParams{std::make_shared(std::vector{ {[](postNodeConfig& cfg){ - return ngraph::builder::makeActivation(cfg.input, cfg.type, ngraph::helpers::Tanh); + return utils::make_activation(cfg.input, cfg.type, utils::Tanh); }, "Tanh"}}), {"Tanh"}}; const auto fusingAbs = fusingSpecificParams{std::make_shared(std::vector{ {[](postNodeConfig& cfg){ - return ngraph::builder::makeActivation(cfg.input, cfg.type, ngraph::helpers::Abs); + return utils::make_activation(cfg.input, cfg.type, utils::Abs); }, "Abs"}}), {"Abs"}}; const auto fusingSqrt = fusingSpecificParams{std::make_shared(std::vector{ {[](postNodeConfig& cfg){ - return ngraph::builder::makeActivation(cfg.input, cfg.type, ngraph::helpers::Sqrt); + return utils::make_activation(cfg.input, cfg.type, utils::Sqrt); }, "Sqrt"}}), {"Sqrt"}}; const auto fusingPReluPerChannel = fusingSpecificParams{std::make_shared(std::vector{ {[](postNodeConfig& cfg){ - ngraph::Shape newShape = generatePerChannelShape(cfg.target); - auto data = NGraphFunctions::Utils::generateVector(ngraph::shape_size(newShape)); - return ngraph::builder::makeActivation(cfg.input, cfg.type, ngraph::helpers::LeakyRelu, newShape, data); + ov::Shape newShape = generatePerChannelShape(cfg.target); + auto data = NGraphFunctions::Utils::generateVector(ov::shape_size(newShape)); + return utils::make_activation(cfg.input, cfg.type, utils::LeakyRelu, newShape, data); }, "PRelu(PerChannel)"}}), {"PRelu"}}; const auto fusingPReluPerTensor = fusingSpecificParams{std::make_shared(std::vector{ {[](postNodeConfig& cfg){ - ngraph::Shape shape(1, 1); - auto data = NGraphFunctions::Utils::generateVector(ngraph::shape_size(shape)); - return ngraph::builder::makeActivation(cfg.input, cfg.type, ngraph::helpers::LeakyRelu, shape, data); + ov::Shape shape(1, 1); + auto data = NGraphFunctions::Utils::generateVector(ov::shape_size(shape)); + return utils::make_activation(cfg.input, cfg.type, utils::LeakyRelu, shape, data); }, "PRelu(PerTensor)"}}), {"PRelu"}}; const auto fusingSwish = fusingSpecificParams{std::make_shared(std::vector{ {[](postNodeConfig& cfg){ - return ngraph::builder::makeActivation(cfg.input, cfg.type, ngraph::helpers::Swish, {}, {1.0f}); + return utils::make_activation(cfg.input, cfg.type, utils::Swish, {}, {1.0f}); }, "Swish"}}), {"Swish"}}; const auto fusingSoftPlus = fusingSpecificParams{std::make_shared(std::vector{ {[](postNodeConfig& cfg){ - return ngraph::builder::makeActivation(cfg.input, cfg.type, ngraph::helpers::SoftPlus, {}, {}); + return utils::make_activation(cfg.input, cfg.type, utils::SoftPlus, {}, {}); }, "SoftPlus"}}), {"SoftPlus"}}; const auto fusingHSwish = fusingSpecificParams{std::make_shared(std::vector{ {[](postNodeConfig& cfg){ - return ngraph::builder::makeActivation(cfg.input, cfg.type, ngraph::helpers::HSwish, {}, {}); + return utils::make_activation(cfg.input, cfg.type, utils::HSwish, {}, {}); }, "HSwish"}}), {"HSwish"}}; const auto fusingMish = fusingSpecificParams{std::make_shared(std::vector{ {[](postNodeConfig& cfg){ - return ngraph::builder::makeActivation(cfg.input, cfg.type, ngraph::helpers::Mish, {}, {}); + return utils::make_activation(cfg.input, cfg.type, utils::Mish, {}, {}); }, "Mish"}}), {"Mish"}}; const auto fusingHSigmoid = fusingSpecificParams{std::make_shared(std::vector{ {[](postNodeConfig& cfg){ - return ngraph::builder::makeActivation(cfg.input, cfg.type, ngraph::helpers::HSigmoid); + return utils::make_activation(cfg.input, cfg.type, utils::HSigmoid); }, "HSigmoid"}}), {"HSigmoid"}}; const auto fusingReluAdd = fusingSpecificParams{std::make_shared(std::vector{ {[](postNodeConfig& cfg){ - return ngraph::builder::makeActivation(cfg.input, cfg.type, ngraph::helpers::Relu); + return utils::make_activation(cfg.input, cfg.type, utils::Relu); }, "Relu"}, {[](postNodeConfig& cfg){ - ngraph::Shape newShape = generatePerChannelShape(cfg.target); + ov::Shape newShape = generatePerChannelShape(cfg.target); auto constNode = ngraph::builder::makeConstant(cfg.type, newShape, std::vector{}, true); - return std::make_shared(cfg.input, constNode); + return std::make_shared(cfg.input, constNode); }, "Add(PerChannel)"}}), {"Relu", "Add"}}; const auto fusingReluScaleShift = fusingSpecificParams{std::make_shared(std::vector{ {[](postNodeConfig& cfg){ - return ngraph::builder::makeActivation(cfg.input, cfg.type, ngraph::helpers::Relu); + return utils::make_activation(cfg.input, cfg.type, utils::Relu); }, "Relu"}, {[](postNodeConfig& cfg){ - ngraph::Shape newShape = generatePerChannelShape(cfg.target); + ov::Shape newShape = generatePerChannelShape(cfg.target); auto constNode = ngraph::builder::makeConstant(cfg.type, newShape, std::vector{}, true); - return std::make_shared(cfg.input, constNode); + return std::make_shared(cfg.input, constNode); }, "Multiply(PerChannel)"}, {[](postNodeConfig& cfg){ - ngraph::Shape newShape = generatePerChannelShape(cfg.target); + ov::Shape newShape = generatePerChannelShape(cfg.target); auto constNode = ngraph::builder::makeConstant(cfg.type, newShape, std::vector{}, true); - return std::make_shared(cfg.input, constNode); + return std::make_shared(cfg.input, constNode); }, "Add(PerChannel)"}}), {"Relu", "Add"}}; const auto fusingScaleShift = fusingSpecificParams{ std::make_shared(std::vector{ {[](postNodeConfig& cfg) { - ngraph::Shape newShape = generatePerChannelShape(cfg.target); + ov::Shape newShape = generatePerChannelShape(cfg.target); auto constNode = ngraph::builder::makeConstant(cfg.type, newShape, std::vector{}, true); - return std::make_shared(cfg.input, constNode); + return std::make_shared(cfg.input, constNode); }, "Multiply(PerChannel)"}, {[](postNodeConfig& cfg) { - ngraph::Shape newShape = generatePerChannelShape(cfg.target); + ov::Shape newShape = generatePerChannelShape(cfg.target); auto constNode = ngraph::builder::makeConstant(cfg.type, newShape, std::vector{}, true); - return std::make_shared(cfg.input, constNode); + return std::make_shared(cfg.input, constNode); }, "Add(PerChannel)"}}), {"Add"} }; const auto fusingClampRoundAddRelu = fusingSpecificParams{ std::make_shared(std::vector{ {[](postNodeConfig& cfg){ - return ngraph::builder::makeActivation(cfg.input, cfg.type, ngraph::helpers::Clamp, {}, {3.0f, 6.0f}); + return utils::make_activation(cfg.input, cfg.type, utils::Clamp, {}, {3.0f, 6.0f}); }, "Clamp"}, {[](postNodeConfig& cfg){ - return ngraph::builder::makeActivation(cfg.input, cfg.type, ngraph::helpers::RoundHalfToEven); + return utils::make_activation(cfg.input, cfg.type, utils::RoundHalfToEven); }, "RoundHalfToEven"}, {[](postNodeConfig& cfg){ - ngraph::Shape secondMultInShape(1, 1); + ov::Shape secondMultInShape(1, 1); auto secondMultInput = ngraph::builder::makeConstant(cfg.type, secondMultInShape, std::vector{}, true); - return std::make_shared(cfg.input, secondMultInput); + return std::make_shared(cfg.input, secondMultInput); }, "AddPerTensor"}, {[](postNodeConfig& cfg){ - return ngraph::builder::makeActivation(cfg.input, cfg.type, ngraph::helpers::Relu); + return utils::make_activation(cfg.input, cfg.type, utils::Relu); }, "Relu"}}), {"Clamp", "Round", "Add", "Relu"}}; const auto fusingScaleShiftAndFakeQuantizePerChannel = fusingSpecificParams{ std::make_shared(std::vector{ {[](postNodeConfig& cfg) { - ngraph::Shape newShape = generatePerChannelShape(cfg.target); + ov::Shape newShape = generatePerChannelShape(cfg.target); auto constNode = ngraph::builder::makeConstant(cfg.type, newShape, std::vector{}, true); - return std::make_shared(cfg.input, constNode); + return std::make_shared(cfg.input, constNode); }, "Multiply(PerChannel)"}, {[](postNodeConfig& cfg) { - ngraph::Shape newShape = generatePerChannelShape(cfg.target); + ov::Shape newShape = generatePerChannelShape(cfg.target); auto constNode = ngraph::builder::makeConstant(cfg.type, newShape, std::vector{}, true); - return std::make_shared(cfg.input, constNode); + return std::make_shared(cfg.input, constNode); }, "Add(PerChannel)"}, {[](postNodeConfig& cfg){ auto localPrc = cfg.input->get_element_type(); - ngraph::Shape newShape = generatePerChannelShape(cfg.target); - // auto newShape = ngraph::Shape(cfg.inputNode->get_output_partial_shape(0).size(), 1); + ov::Shape newShape = generatePerChannelShape(cfg.target); + // auto newShape = ov::Shape(cfg.inputNode->get_output_partial_shape(0).size(), 1); return ngraph::builder::makeFakeQuantize(cfg.input, localPrc, 256, newShape); }, "FakeQuantize(PerChannel)"}}), {"FakeQuantize"}}; const auto fusingFakeQuantizePerTensor = fusingSpecificParams{ std::make_shared(std::vector{ {[](postNodeConfig& cfg){ auto localPrc = cfg.input->get_element_type(); - ngraph::Shape newShape(cfg.input->get_output_partial_shape(0).size(), 1); + ov::Shape newShape(cfg.input->get_output_partial_shape(0).size(), 1); return ngraph::builder::makeFakeQuantize(cfg.input, localPrc, 256, newShape); }, "FakeQuantize(PerTensor)"}}), {"FakeQuantize"} }; const auto fusingFakeQuantizePerChannel = fusingSpecificParams{std::make_shared(std::vector{ {[](postNodeConfig& cfg){ auto localPrc = cfg.input->get_element_type(); - ngraph::Shape newShape = generatePerChannelShape(cfg.target); + ov::Shape newShape = generatePerChannelShape(cfg.target); return ngraph::builder::makeFakeQuantize(cfg.input, localPrc, 256, newShape); }, "FakeQuantize(PerChannel)"}}), {"FakeQuantize"}}; const auto fusingFakeQuantizePerChannelRelu = fusingSpecificParams{std::make_shared(std::vector{ {[](postNodeConfig& cfg){ auto localPrc = cfg.input->get_element_type(); - ngraph::Shape newShape = generatePerChannelShape(cfg.target); + ov::Shape newShape = generatePerChannelShape(cfg.target); return ngraph::builder::makeFakeQuantize(cfg.input, localPrc, 256, newShape); }, "FakeQuantize(PerChannel)"}, {[](postNodeConfig& cfg){ - return ngraph::builder::makeActivation(cfg.input, cfg.type, ngraph::helpers::Relu); + return utils::make_activation(cfg.input, cfg.type, utils::Relu); }, "Relu"}}), {"FakeQuantize", "Relu"}}; const auto fusingFQPerChannelSigmoidFQPerChannel = fusingSpecificParams{std::make_shared(std::vector{ @@ -308,19 +312,19 @@ const auto fusingFQPerChannelSigmoidFQPerChannel = fusingSpecificParams{std::mak auto shape = cfg.input->get_output_partial_shape(0); if (shape.size() == 1) OPENVINO_THROW("If shape.size() == 1 then Granularity can be PerTensor only"); - ngraph::Shape newShape(shape.size(), 1); + ov::Shape newShape(shape.size(), 1); newShape[1] = shape[1].get_length(); return ngraph::builder::makeFakeQuantize(cfg.input, localPrc, 256, newShape); }, "FakeQuantize(PerChannel)"}, {[](postNodeConfig& cfg){ - return ngraph::builder::makeActivation(cfg.input, cfg.type, ngraph::helpers::Sigmoid); + return utils::make_activation(cfg.input, cfg.type, utils::Sigmoid); }, "Sigmoid"}, {[](postNodeConfig& cfg){ auto localPrc = cfg.input->get_element_type(); auto shape = cfg.input->get_output_partial_shape(0); if (shape.size() == 1) OPENVINO_THROW("If shape.size() == 1 then Granularity can be PerTensor only"); - ngraph::Shape newShape(shape.size(), 1); + ov::Shape newShape(shape.size(), 1); newShape[1] = shape[1].get_length(); return ngraph::builder::makeFakeQuantize(cfg.input, localPrc, 256, newShape); }, "FakeQuantize(PerChannel)"}}), {"FakeQuantize", "Sigmoid", "FakeQuantize"}}; @@ -331,30 +335,30 @@ const auto fusingFQPerChannelSigmoidFQPerTensor = fusingSpecificParams{std::make auto shape = cfg.input->get_output_partial_shape(0); if (shape.size() == 1) OPENVINO_THROW("If shape.size() == 1 then Granularity can be PerTensor only"); - ngraph::Shape newShape(shape.size(), 1); + ov::Shape newShape(shape.size(), 1); newShape[1] = shape[1].get_length(); return ngraph::builder::makeFakeQuantize(cfg.input, localPrc, 256, newShape); }, "FakeQuantize(PerChannel)"}, {[](postNodeConfig& cfg){ - return ngraph::builder::makeActivation(cfg.input, cfg.type, ngraph::helpers::Sigmoid); + return utils::make_activation(cfg.input, cfg.type, utils::Sigmoid); }, "Sigmoid"}, {[](postNodeConfig& cfg){ auto localPrc = cfg.input->get_element_type(); auto shape = cfg.input->get_output_partial_shape(0); if (shape.size() == 1) OPENVINO_THROW("If shape.size() == 1 then Granularity can be PerTensor only"); - ngraph::Shape newShape(shape.size(), 1); + ov::Shape newShape(shape.size(), 1); return ngraph::builder::makeFakeQuantize(cfg.input, localPrc, 256, newShape); }, "FakeQuantize(PerTensor)"}}), {"FakeQuantize", "Sigmoid", "FakeQuantize"}}; const auto fusingFakeQuantizePerTensorRelu = fusingSpecificParams{std::make_shared(std::vector{ {[](postNodeConfig& cfg) { auto localPrc = cfg.input->get_element_type(); - auto newShape = ngraph::Shape(cfg.input->get_output_partial_shape(0).size(), 1); + auto newShape = ov::Shape(cfg.input->get_output_partial_shape(0).size(), 1); return ngraph::builder::makeFakeQuantize(cfg.input, localPrc, 256, newShape); }, "FakeQuantize(PerTensor)"}, {[](postNodeConfig& cfg){ - return ngraph::builder::makeActivation(cfg.input, cfg.type, ngraph::helpers::Relu); + return utils::make_activation(cfg.input, cfg.type, utils::Relu); }, "Relu"}}), {"FakeQuantize", "Relu"}}; const auto fusingSum = fusingSpecificParams{std::make_shared(std::vector{ @@ -362,7 +366,7 @@ const auto fusingSum = fusingSpecificParams{std::make_shared(std:: auto shape = cfg.input->get_output_partial_shape(0); ov::ParameterVector newParams{std::make_shared(cfg.type, shape)}; cfg.params.insert(cfg.params.end(), newParams.begin(), newParams.end()); - return std::make_shared(cfg.input, newParams[0]); + return std::make_shared(cfg.input, newParams[0]); }, "Add(Parameters)"}}), {"Add"}}; const auto fusingSumEluFQ = fusingSpecificParams{std::make_shared(std::vector{ @@ -370,116 +374,116 @@ const auto fusingSumEluFQ = fusingSpecificParams{std::make_shared( auto shape = cfg.input->get_output_partial_shape(0); ov::ParameterVector newParams{std::make_shared(cfg.type, shape)}; cfg.params.insert(cfg.params.end(), newParams.begin(), newParams.end()); - return std::make_shared(cfg.input, newParams[0]); + return std::make_shared(cfg.input, newParams[0]); }, "Add(Parameters)"}, {[](postNodeConfig& cfg){ - return ngraph::builder::makeActivation(cfg.input, cfg.type, ngraph::helpers::Elu, {}, {2.0f}); + return utils::make_activation(cfg.input, cfg.type, utils::Elu, {}, {2.0f}); }, "Elu"}, {[](postNodeConfig& cfg) { auto localPrc = cfg.input->get_element_type(); - auto newShape = ngraph::Shape(cfg.input->get_output_partial_shape(0).size(), 1); + auto newShape = ov::Shape(cfg.input->get_output_partial_shape(0).size(), 1); return ngraph::builder::makeFakeQuantize(cfg.input, localPrc, 256, newShape); }, "FakeQuantize(PerTensor)"}}), {"Add", "Elu", "FakeQuantize"}}; const auto fusingMultiplyPerTensor = fusingSpecificParams{std::make_shared(std::vector{ {[](postNodeConfig& cfg){ - ngraph::Shape secondMultInShape(1, 1); + ov::Shape secondMultInShape(1, 1); auto secondMultInput = ngraph::builder::makeConstant(cfg.type, secondMultInShape, std::vector{}, true); - return std::make_shared(cfg.input, secondMultInput); + return std::make_shared(cfg.input, secondMultInput); }, "Multiply(PerTensor)"}}), {"Multiply"}}; const auto fusingMultiplyPerChannel = fusingSpecificParams{std::make_shared(std::vector{ {[](postNodeConfig& cfg){ - ngraph::Shape secondMultInShape = generatePerChannelShape(cfg.target); + ov::Shape secondMultInShape = generatePerChannelShape(cfg.target); auto secondMultInput = ngraph::builder::makeConstant(cfg.type, secondMultInShape, std::vector{}, true); - return std::make_shared(cfg.input, secondMultInput); + return std::make_shared(cfg.input, secondMultInput); }, "Multiply(PerChannel)"}}), {"Multiply"}}; const auto fusingMultiplyAddPerChannel = fusingSpecificParams{std::make_shared(std::vector{ {[](postNodeConfig& cfg) { - ngraph::Shape newShape = generatePerChannelShape(cfg.input); + ov::Shape newShape = generatePerChannelShape(cfg.input); auto constNode = ngraph::builder::makeConstant(cfg.type, newShape, std::vector{}, true); - return std::make_shared(cfg.input, constNode); + return std::make_shared(cfg.input, constNode); }, "Multiply(PerChannel)"}, {[](postNodeConfig& cfg) { - ngraph::Shape newShape = generatePerChannelShape(cfg.input); + ov::Shape newShape = generatePerChannelShape(cfg.input); auto constNode = ngraph::builder::makeConstant(cfg.type, newShape, std::vector{}, true); - return std::make_shared(cfg.input, constNode); + return std::make_shared(cfg.input, constNode); }, "Add(PerChannel)"}}), {"Add"} }; const auto fusingAddPerTensor = fusingSpecificParams{std::make_shared(std::vector{ {[](postNodeConfig& cfg){ - ngraph::Shape secondMultInShape(1, 1); + ov::Shape secondMultInShape(1, 1); auto secondMultInput = ngraph::builder::makeConstant(cfg.type, secondMultInShape, std::vector{}, true); - return std::make_shared(cfg.input, secondMultInput); + return std::make_shared(cfg.input, secondMultInput); }, "Add(PerTensor)"}}), {"Add"}}; const auto fusingAddPerChannel = fusingSpecificParams{std::make_shared(std::vector{ {[](postNodeConfig& cfg){ - ngraph::Shape secondMultInShape = generatePerChannelShape(cfg.target); + ov::Shape secondMultInShape = generatePerChannelShape(cfg.target); auto secondMultInput = ngraph::builder::makeConstant(cfg.type, secondMultInShape, std::vector{}, true); - return std::make_shared(cfg.input, secondMultInput); + return std::make_shared(cfg.input, secondMultInput); }, "Add(PerChannel)"}}), {"Add"}}; const auto fusingSubtractPerTensor = fusingSpecificParams{std::make_shared(std::vector{ {[](postNodeConfig& cfg){ - ngraph::Shape secondMultInShape(1, 1); + ov::Shape secondMultInShape(1, 1); auto secondMultInput = ngraph::builder::makeConstant(cfg.type, secondMultInShape, std::vector{}, true); - return std::make_shared(cfg.input, secondMultInput); + return std::make_shared(cfg.input, secondMultInput); }, "Subtract(PerTensor)"}}), {"Subtract"}}; const auto fusingSubtractPerChannel = fusingSpecificParams{std::make_shared(std::vector{ {[](postNodeConfig& cfg){ - ngraph::Shape secondMultInShape = generatePerChannelShape(cfg.target); + ov::Shape secondMultInShape = generatePerChannelShape(cfg.target); auto secondMultInput = ngraph::builder::makeConstant(cfg.type, secondMultInShape, std::vector{}, true); - return std::make_shared(cfg.input, secondMultInput); + return std::make_shared(cfg.input, secondMultInput); }, "Subtract(PerChannel)"}}), {"Subtract"}}; const auto fusingDividePerTensor = fusingSpecificParams{std::make_shared(std::vector{ {[](postNodeConfig& cfg){ - ngraph::Shape secondMultInShape(1, 1); + ov::Shape secondMultInShape(1, 1); auto secondMultInput = ngraph::builder::makeConstant(cfg.type, secondMultInShape, std::vector{}, true); - return std::make_shared(cfg.input, secondMultInput); + return std::make_shared(cfg.input, secondMultInput); }, "Divide(PerTensor)"}}), {"Divide"}}; const auto fusingDividePerChannel = fusingSpecificParams{std::make_shared(std::vector{ {[](postNodeConfig& cfg){ - ngraph::Shape secondMultInShape = generatePerChannelShape(cfg.target); + ov::Shape secondMultInShape = generatePerChannelShape(cfg.target); auto secondMultInput = ngraph::builder::makeConstant(cfg.type, secondMultInShape, std::vector{}, true); - return std::make_shared(cfg.input, secondMultInput); + return std::make_shared(cfg.input, secondMultInput); }, "Divide(PerChannel)"}}), {"Divide"}}; const auto fusingPRelu1D = fusingSpecificParams{std::make_shared(std::vector{ {[](postNodeConfig& cfg){ auto shape = cfg.input->get_output_partial_shape(0); - ngraph::Shape newShape({static_cast(shape[1].get_length())}); - auto data = NGraphFunctions::Utils::generateVector(ngraph::shape_size(newShape)); - return ngraph::builder::makeActivation(cfg.input, cfg.type, ngraph::helpers::LeakyRelu, newShape, data); + ov::Shape newShape({static_cast(shape[1].get_length())}); + auto data = NGraphFunctions::Utils::generateVector(ov::shape_size(newShape)); + return utils::make_activation(cfg.input, cfg.type, utils::LeakyRelu, newShape, data); }, "PRelu1D"}}), {"PRelu"}}; const auto fusingPRelu1DScaleShift = fusingSpecificParams{std::make_shared(std::vector{ {[](postNodeConfig& cfg){ auto shape = cfg.input->get_output_partial_shape(0); - ngraph::Shape newShape({static_cast(shape[1].get_length())}); - auto data = NGraphFunctions::Utils::generateVector(ngraph::shape_size(newShape)); - return ngraph::builder::makeActivation(cfg.input, cfg.type, ngraph::helpers::LeakyRelu, newShape, data); + ov::Shape newShape({static_cast(shape[1].get_length())}); + auto data = NGraphFunctions::Utils::generateVector(ov::shape_size(newShape)); + return utils::make_activation(cfg.input, cfg.type, utils::LeakyRelu, newShape, data); }, "PRelu1D"}, {[](postNodeConfig& cfg) { - ngraph::Shape newShape = generatePerChannelShape(cfg.input); + ov::Shape newShape = generatePerChannelShape(cfg.input); auto constNode = ngraph::builder::makeConstant(cfg.type, newShape, std::vector{}, true); - return std::make_shared(cfg.input, constNode); + return std::make_shared(cfg.input, constNode); }, "Multiply(PerChannel)"}, {[](postNodeConfig& cfg) { - ngraph::Shape newShape = generatePerChannelShape(cfg.input); + ov::Shape newShape = generatePerChannelShape(cfg.input); auto constNode = ngraph::builder::makeConstant(cfg.type, newShape, std::vector{}, true); - return std::make_shared(cfg.input, constNode); + return std::make_shared(cfg.input, constNode); }, "Add(PerChannel)"}}), {"Add"} }; const auto fusingBias = fusingSpecificParams{std::make_shared(std::vector{ {[](postNodeConfig& cfg) { size_t last_dim = cfg.input->get_output_partial_shape(0).rbegin()->get_length(); - auto bias = ngraph::builder::makeConstant(cfg.type, ngraph::Shape{last_dim}, std::vector{}, true); - return std::make_shared(cfg.input, bias); + auto bias = ngraph::builder::makeConstant(cfg.type, ov::Shape{last_dim}, std::vector{}, true); + return std::make_shared(cfg.input, bias); }, "fusingBias"}}), {"Add"}}; } // namespace CPUTestUtils diff --git a/src/plugins/intel_cpu/tests/functional/test_utils/x64/filter_cpu_info.cpp b/src/plugins/intel_cpu/tests/functional/test_utils/x64/filter_cpu_info.cpp index 1e22e6e1cd08c6..9944ddba9b1dfa 100644 --- a/src/plugins/intel_cpu/tests/functional/test_utils/x64/filter_cpu_info.cpp +++ b/src/plugins/intel_cpu/tests/functional/test_utils/x64/filter_cpu_info.cpp @@ -4,7 +4,6 @@ #include "test_utils/cpu_test_utils.hpp" #include "test_utils/filter_cpu_info.hpp" -#include "ie_ngraph_utils.hpp" #include "openvino/core/type/element_type.hpp" #include "utils/rt_info/memory_formats_attribute.hpp" #include "utils/general_utils.h" diff --git a/src/plugins/intel_cpu/tests/unit/CMakeLists.txt b/src/plugins/intel_cpu/tests/unit/CMakeLists.txt index be9c4a1c5da408..6bb37da132021a 100644 --- a/src/plugins/intel_cpu/tests/unit/CMakeLists.txt +++ b/src/plugins/intel_cpu/tests/unit/CMakeLists.txt @@ -53,8 +53,6 @@ ov_add_test_target( gtest_main gmock dnnl - inference_engine_transformations - inference_engine_lp_transformations openvino::shape_inference inference_engine_s unit_test_utils @@ -62,6 +60,8 @@ ov_add_test_target( ov_snippets_models snippets_test_utils ${MLAS_LIBRARY} + inference_engine_transformations + inference_engine_lp_transformations ADD_CPPLINT LABELS OV UNIT CPU diff --git a/src/plugins/intel_cpu/tests/unit/graph/scaled_attn.cpp b/src/plugins/intel_cpu/tests/unit/graph/scaled_attn.cpp index 081d9ddfc7b42d..48db2d5fd701eb 100644 --- a/src/plugins/intel_cpu/tests/unit/graph/scaled_attn.cpp +++ b/src/plugins/intel_cpu/tests/unit/graph/scaled_attn.cpp @@ -22,30 +22,40 @@ #include "ov_models/builders.hpp" #include "nodes/scaled_attn.h" #include "nodes/input.h" +#include "nodes/convert.h" #include "graph.h" #include "cpu_tensor.h" using namespace ov::intel_cpu; +#ifdef OPENVINO_ARCH_ARM64 +// Ticket: 126975 +TEST(ScaledAttnGraphTest, DISABLED_smoke_Check_Scaled_Concat_Noplace) { +#else TEST(ScaledAttnGraphTest, smoke_Check_Scaled_Concat_Noplace) { +#endif auto build_graph = [](const ov::Shape& shape, float* qkv_val, float* past_kv_val) { auto qkv = ov::op::v0::Constant::create(ov::element::f32, shape, qkv_val); qkv->set_friendly_name("qkv_const"); - auto pastkv = ov::op::v0::Constant::create(ov::element::f32, shape, past_kv_val); + auto pastkv_f32 = ov::op::v0::Constant::create(ov::element::f32, shape, past_kv_val); + pastkv_f32->set_friendly_name("pastkv_const_f32"); + auto pastkv = std::make_shared(pastkv_f32, ov::element::f16); pastkv->set_friendly_name("pastkv_const"); // only need a dynamic parameter but its value will not be used auto attn = std::make_shared(ov::element::f32, ov::PartialShape{-1}); attn->set_friendly_name("attn"); - ov::intel_cpu::ScaledDotProductAttentionStub::Config config; + ov::intel_cpu::ScaledDotProductAttentionWithKVCache::Config config; config.fuse_concat = true; config.is_causal = true; - auto sdpa = std::make_shared(ov::OutputVector{qkv, qkv, qkv, attn, pastkv, pastkv}, config); + auto sdpa = std::make_shared(ov::OutputVector{qkv, qkv, qkv, attn, pastkv, pastkv}, config); + auto out_pastk_convert = std::make_shared(sdpa->output(1), ov::element::f32); + auto out_pastv_convert = std::make_shared(sdpa->output(2), ov::element::f32); auto out_qkv = std::make_shared(sdpa->output(0)); out_qkv->set_friendly_name("qkv"); - auto out_pastk = std::make_shared(sdpa->output(1)); + auto out_pastk = std::make_shared(out_pastk_convert); out_pastk->set_friendly_name("pastk"); - auto out_pastv = std::make_shared(sdpa->output(2)); + auto out_pastv = std::make_shared(out_pastv_convert); out_pastv->set_friendly_name("pastv"); std::unordered_set nodes_set; @@ -65,9 +75,12 @@ TEST(ScaledAttnGraphTest, smoke_Check_Scaled_Concat_Noplace) { auto context = std::make_shared(conf, nullptr, nullptr, false); auto qkv_node = std::make_shared(qkv, context); - auto pastkv_node = std::make_shared(pastkv, context); + auto pastkv_f32_node = std::make_shared(pastkv_f32, context); auto attn_node = std::make_shared(attn, context); + auto pastkv_node = std::make_shared(pastkv, context); auto sdpa_node = std::make_shared(sdpa, context); + auto out_pastk_node_convert = std::make_shared(out_pastk_convert, context); + auto out_pastv_node_convert = std::make_shared(out_pastv_convert, context); auto out_qkv_node = std::make_shared(out_qkv, context); auto out_pastk_node = std::make_shared(out_pastk, context); auto out_pastv_node = std::make_shared(out_pastv, context); @@ -76,11 +89,14 @@ TEST(ScaledAttnGraphTest, smoke_Check_Scaled_Concat_Noplace) { add_edge(qkv_node, sdpa_node, 0, 1); add_edge(qkv_node, sdpa_node, 0, 2); add_edge(attn_node, sdpa_node, 0, 3); + add_edge(pastkv_f32_node, pastkv_node, 0, 0); add_edge(pastkv_node, sdpa_node, 0, 4); add_edge(pastkv_node, sdpa_node, 0, 5); add_edge(sdpa_node, out_qkv_node, 0, 0); - add_edge(sdpa_node, out_pastk_node, 1, 0); - add_edge(sdpa_node, out_pastv_node, 2, 0); + add_edge(sdpa_node, out_pastk_node_convert, 1, 0); + add_edge(sdpa_node, out_pastv_node_convert, 2, 0); + add_edge(out_pastk_node_convert, out_pastk_node, 0, 0); + add_edge(out_pastv_node_convert, out_pastv_node, 0, 0); std::vector graph_nodes(nodes_set.begin(), nodes_set.end()); @@ -104,7 +120,7 @@ TEST(ScaledAttnGraphTest, smoke_Check_Scaled_Concat_Noplace) { auto check_graph = [] (Graph& graph, std::map>& expected) { auto& outputNodesMap = graph.GetOutputNodesMap(); auto is_same = [] (float a, float b) { - return std::abs(a - b) < 0.0001f; + return std::abs(a - b) < 0.01f; }; for (auto &outputMap : outputNodesMap) { auto name = outputMap.first; diff --git a/src/plugins/intel_cpu/tests/unit/shape_inference_test/multinomial_shape_inference_test.cpp b/src/plugins/intel_cpu/tests/unit/shape_inference_test/multinomial_shape_inference_test.cpp index c3253be8a5d775..957c8c068b4e1d 100644 --- a/src/plugins/intel_cpu/tests/unit/shape_inference_test/multinomial_shape_inference_test.cpp +++ b/src/plugins/intel_cpu/tests/unit/shape_inference_test/multinomial_shape_inference_test.cpp @@ -11,21 +11,6 @@ using namespace ov; using namespace ov::intel_cpu; -TEST(StaticShapeInferenceTest, MultinomialStaticShapeInferenceTest1D) { - auto probs = std::make_shared(element::f32, Shape{4}); - auto num_samples = std::make_shared(element::i32, Shape{1}); - auto multinomial = std::make_shared(probs, num_samples, element::i32, false, false, 0, 0); - - // Test Static Shape 1D input - std::vector static_input_shapes = {StaticShape{4}, StaticShape{1}}; - int32_t num_elements_val = 2; - auto const_data = - std::unordered_map{{1, {element::i32, Shape{1}, &num_elements_val}}}; - auto acc = make_tensor_accessor(const_data); - auto static_output_shapes = shape_infer(multinomial.get(), static_input_shapes, acc); - ASSERT_EQ(static_output_shapes[0], StaticShape({2})); -} - TEST(StaticShapeInferenceTest, MultinomialStaticShapeInferenceTest2D) { auto probs = std::make_shared(element::f32, Shape{4, 4}); auto num_samples = std::make_shared(element::i32, Shape{1}); @@ -34,28 +19,12 @@ TEST(StaticShapeInferenceTest, MultinomialStaticShapeInferenceTest2D) { // Test Static Shape 2D input std::vector static_input_shapes = {StaticShape{4, 4}, StaticShape{1}}; int32_t num_elements_val = 2; - auto const_data = - std::unordered_map{{1, {element::i32, Shape{1}, &num_elements_val}}}; + auto const_data = std::unordered_map{{1, {element::i32, Shape{1}, &num_elements_val}}}; auto acc = make_tensor_accessor(const_data); auto static_output_shapes = shape_infer(multinomial.get(), static_input_shapes, acc); ASSERT_EQ(static_output_shapes[0], StaticShape({4, 2})); } -TEST(StaticShapeInferenceTest, MultinomialDynamicShapeInferenceTestAllDimKnown1D) { - auto probs = std::make_shared(element::f32, PartialShape{3}); - auto num_samples = std::make_shared(element::i32, PartialShape{1}); - auto multinomial = std::make_shared(probs, num_samples, element::i32, false, false, 0, 0); - - // Test Partial Shape 1D input - std::vector partial_input_shapes = {PartialShape{3}, PartialShape{1}}; - int32_t num_elements_val = 2; - auto const_data = - std::unordered_map{{1, {element::i32, Shape{1}, &num_elements_val}}}; - auto acc = make_tensor_accessor(const_data); - auto partial_output_shapes = shape_infer(multinomial.get(), partial_input_shapes, acc); - ASSERT_EQ(partial_output_shapes[0], PartialShape({2})); -} - TEST(StaticShapeInferenceTest, MultinomialDynamicShapeInferenceTestAllDimKnown2D) { auto probs = std::make_shared(element::f32, PartialShape{2, 3}); auto num_samples = std::make_shared(element::i32, PartialShape{1}); @@ -64,24 +33,12 @@ TEST(StaticShapeInferenceTest, MultinomialDynamicShapeInferenceTestAllDimKnown2D // Test Partial Shape 2D input std::vector partial_input_shapes = {PartialShape{2, 3}, PartialShape{1}}; int32_t num_elements_val = 2; - auto const_data = - std::unordered_map{{1, {element::i32, Shape{1}, &num_elements_val}}}; + auto const_data = std::unordered_map{{1, {element::i32, Shape{1}, &num_elements_val}}}; auto acc = make_tensor_accessor(const_data); auto partial_output_shapes = shape_infer(multinomial.get(), partial_input_shapes, acc); ASSERT_EQ(partial_output_shapes[0], PartialShape({2, 2})); } -TEST(StaticShapeInferenceTest, MultinomialDynamicShapeInferenceTestDynamicNumSamples1D) { - auto probs = std::make_shared(element::f32, PartialShape{4}); - auto num_samples = std::make_shared(element::i32, PartialShape{-1}); - auto multinomial = std::make_shared(probs, num_samples, element::i32, false, false, 0, 0); - - // Test Partial Shape 1D input, unknown num_samples - std::vector partial_input_shapes = {PartialShape{4}, PartialShape{-1}}; - auto partial_output_shapes = shape_infer(multinomial.get(), partial_input_shapes, make_tensor_accessor()); - ASSERT_EQ(partial_output_shapes[0], PartialShape({-1})); -} - TEST(StaticShapeInferenceTest, MultinomialDynamicShapeInferenceTestDynamicNumSamples2D) { auto probs = std::make_shared(element::f32, PartialShape{4, 4}); auto num_samples = std::make_shared(element::i32, PartialShape{-1}); @@ -93,17 +50,6 @@ TEST(StaticShapeInferenceTest, MultinomialDynamicShapeInferenceTestDynamicNumSam ASSERT_EQ(partial_output_shapes[0], PartialShape({4, -1})); } -TEST(StaticShapeInferenceTest, MultinomialDynamicShapeInferenceTestDynamicProbsDynamicNumSamples1D) { - auto probs = std::make_shared(element::f32, PartialShape{-1}); - auto num_samples = std::make_shared(element::i32, PartialShape{-1}); - auto multinomial = std::make_shared(probs, num_samples, element::i32, false, false, 0, 0); - - // Test Partial Shape 1D input, unknown num_samples and probs shape - std::vector partial_input_shapes = {PartialShape{-1}, PartialShape{-1}}; - auto partial_output_shapes = shape_infer(multinomial.get(), partial_input_shapes, make_tensor_accessor()); - ASSERT_EQ(partial_output_shapes[0], PartialShape({-1})); -} - TEST(StaticShapeInferenceTest, MultinomialDynamicShapeInferenceTestDynamicProbsDynamicNumSamples2D) { auto probs = std::make_shared(element::f32, PartialShape{-1, -1}); auto num_samples = std::make_shared(element::i32, PartialShape{-1}); diff --git a/src/plugins/intel_cpu/tests/unit/snippets_transformations/lowered/buffer_allocation.cpp b/src/plugins/intel_cpu/tests/unit/snippets_transformations/lowered/buffer_allocation.cpp index 6202fdc77efd5f..de5b02c3c8349f 100644 --- a/src/plugins/intel_cpu/tests/unit/snippets_transformations/lowered/buffer_allocation.cpp +++ b/src/plugins/intel_cpu/tests/unit/snippets_transformations/lowered/buffer_allocation.cpp @@ -70,8 +70,8 @@ class BufferAllocationCPUTest : public testing::TestWithParam(); pipeline.register_pass(m_vector_size); + pipeline.register_pass(); pipeline.register_pass(m_vector_size); pipeline.register_pass(); if (with_split_loops) @@ -120,7 +120,7 @@ class BufferAllocationCPUTest : public testing::TestWithParam GetModel() const override { - const auto subtensor_scalar = std::vector{1, 1}; + const auto subtensor_scalar = std::vector{1}; const auto subtensor_softmax = std::vector{1, ov::snippets::lowered::PortDescriptor::ServiceDimensions::FULL_DIM}; const auto subtensor_full = std::vector(2, ov::snippets::lowered::PortDescriptor::ServiceDimensions::FULL_DIM); @@ -136,10 +136,12 @@ class MHABF16AMXBufferAllocationTest : public BufferAllocationCPUTest { const auto brgemm_copyb0 = std::make_shared( convert1, ov::element::bf16, ov::intel_cpu::BrgemmCopyB::OnlyRepacking, 0, 0, 0); - const auto scratch0 = std::make_shared(ov::Shape{ov::intel_cpu::BrgemmCPU::SCRATCH_BYTE_SIZE}); + const auto scratch0 = std::make_shared(ov::Shape{ov::intel_cpu::BrgemmCPU::SCRATCH_BYTE_SIZE}); const auto brgemm_cpu0 = std::make_shared( parameter0, brgemm_copyb0->output(0), scratch0, ov::intel_cpu::BrgemmCPU::Type::AMX); brgemm_cpu0->set_m_block_size(32); + brgemm_cpu0->set_k_block_size(16); + brgemm_cpu0->set_n_block_size(64); const auto relu1 = std::make_shared(brgemm_cpu0); const auto softmax = std::make_shared(relu1, 3); @@ -147,10 +149,12 @@ class MHABF16AMXBufferAllocationTest : public BufferAllocationCPUTest { const auto brgemm_copyb1 = std::make_shared( parameter2, ov::element::bf16, ov::intel_cpu::BrgemmCopyB::OnlyRepacking, 0, 0, 0); - const auto scratch1 = std::make_shared(ov::Shape{ov::intel_cpu::BrgemmCPU::SCRATCH_BYTE_SIZE}); + const auto scratch1 = std::make_shared(ov::Shape{ov::intel_cpu::BrgemmCPU::SCRATCH_BYTE_SIZE}); const auto brgemm_cpu1 = std::make_shared( convert2, brgemm_copyb1->output(0), scratch1, ov::intel_cpu::BrgemmCPU::Type::AMX); brgemm_cpu1->set_m_block_size(32); + brgemm_cpu1->set_k_block_size(16); + brgemm_cpu1->set_n_block_size(64); const auto relu2 = std::make_shared(brgemm_cpu1); @@ -191,7 +195,7 @@ INSTANTIATE_TEST_SUITE_P(smoke_Snippets_BufferAllocation_MHAOptimizedWSplit, MHA ::testing::Values(true), ::testing::Values(true), ::testing::Values(90112), - ::testing::Values(4)), + ::testing::Values(5)), BufferAllocationCPUTest::getTestCaseName); INSTANTIATE_TEST_SUITE_P(smoke_Snippets_BufferAllocation_MHANotOptimizedWOSplit, MHABF16AMXBufferAllocationTest, diff --git a/src/plugins/intel_cpu/tests/unit/snippets_transformations/mul_add_to_fma.cpp b/src/plugins/intel_cpu/tests/unit/snippets_transformations/mul_add_to_fma.cpp index ced190761843de..5912cb9debfc83 100644 --- a/src/plugins/intel_cpu/tests/unit/snippets_transformations/mul_add_to_fma.cpp +++ b/src/plugins/intel_cpu/tests/unit/snippets_transformations/mul_add_to_fma.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include "snippets/op/scalar.hpp" 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 61efd3ec2e1b10..3b68ef44d693fc 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 @@ -222,6 +222,43 @@ StreamsCalculationTestCase _2sockets_104cores_latency_socket_7 = { {0, MAIN_CORE_PROC, 26, 2, 1}, {0, MAIN_CORE_PROC, 26, 3, 1}}, }; +StreamsCalculationTestCase _2sockets_104cores_latency_socket_8 = { + 1, + false, + 208, + 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, HYPER_THREADING_PROC, 52, 1, 1}}, +}; +StreamsCalculationTestCase _2sockets_104cores_latency_socket_9 = { + 1, + false, + 104, + 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}}, +}; +StreamsCalculationTestCase _2sockets_104cores_latency_socket_10 = { + 1, + false, + 52, + 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, MAIN_CORE_PROC, 52, 0, 0}}, +}; StreamsCalculationTestCase _2sockets_104cores_latency_node_1 = { 1, false, @@ -262,17 +299,17 @@ StreamsCalculationTestCase _2sockets_104cores_latency_node_3 = { {52, 26, 0, 26, 1, 0}, {52, 26, 0, 26, 2, 1}, {52, 26, 0, 26, 3, 1}}, - {{1, ALL_PROC, 52, 0, 0}, + {{1, ALL_PROC, 52, -1, 0}, {0, MAIN_CORE_PROC, 26, 0, 0}, - {0, HYPER_THREADING_PROC, 26, 0, 0}, - {1, ALL_PROC, 52, 1, 0}, {0, MAIN_CORE_PROC, 26, 1, 0}, - {0, HYPER_THREADING_PROC, 26, 1, 0}, - {1, ALL_PROC, 52, 2, 1}, + {1, ALL_PROC, 52, -1, 1}, {0, MAIN_CORE_PROC, 26, 2, 1}, - {0, HYPER_THREADING_PROC, 26, 2, 1}, - {1, ALL_PROC, 52, 3, 1}, {0, MAIN_CORE_PROC, 26, 3, 1}, + {1, ALL_PROC, 52, -1, 0}, + {0, HYPER_THREADING_PROC, 26, 0, 0}, + {0, HYPER_THREADING_PROC, 26, 1, 0}, + {1, ALL_PROC, 52, -1, 1}, + {0, HYPER_THREADING_PROC, 26, 2, 1}, {0, HYPER_THREADING_PROC, 26, 3, 1}}, }; StreamsCalculationTestCase _2sockets_104cores_latency_node_4 = { @@ -304,6 +341,43 @@ StreamsCalculationTestCase _2sockets_104cores_latency_node_5 = { {0, MAIN_CORE_PROC, 26, 2, 1}, {0, MAIN_CORE_PROC, 26, 3, 1}}, }; +StreamsCalculationTestCase _2sockets_104cores_latency_node_6 = { + 1, + false, + 104, + 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, 104, -1, -1}, + {0, MAIN_CORE_PROC, 26, 0, 0}, + {0, MAIN_CORE_PROC, 26, 1, 0}, + {0, MAIN_CORE_PROC, 26, 2, 1}, + {0, MAIN_CORE_PROC, 26, 3, 1}}, +}; +StreamsCalculationTestCase _2sockets_104cores_latency_node_7 = { + 1, + false, + 52, + 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}}, +}; +StreamsCalculationTestCase _2sockets_104cores_latency_node_8 = { + 1, + false, + 26, + 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, MAIN_CORE_PROC, 26, 0, 0}}, +}; StreamsCalculationTestCase _2sockets_104cores_latency_1 = { 1, false, @@ -705,7 +779,17 @@ StreamsCalculationTestCase _2sockets_48cores_latency_1 = { {{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, + 96, + 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, ALL_PROC, 48, -1, -1}, {0, MAIN_CORE_PROC, 24, 0, 0}, {0, MAIN_CORE_PROC, 24, 1, 1}}, +}; StreamsCalculationTestCase _2sockets_48cores_tput_1 = { 1, false, @@ -754,6 +838,18 @@ StreamsCalculationTestCase _2sockets_48cores_tput_4 = { {{2, MAIN_CORE_PROC, 10, 0, 0}}, }; +StreamsCalculationTestCase _2sockets_20cores_tput_1 = { + 1, + false, + 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}}, + {{2, MAIN_CORE_PROC, 5, 0, 0}, {2, MAIN_CORE_PROC, 5, 1, 1}}, +}; + StreamsCalculationTestCase _1sockets_14cores_latency_1 = { 1, false, @@ -1747,6 +1843,30 @@ StreamsCalculationTestCase _1sockets_mock_tput_1 = { {{6, MAIN_CORE_PROC, 1, 0, 0}, {3, EFFICIENT_CORE_PROC, 2, 0, 0}, {3, HYPER_THREADING_PROC, 1, 0, 0}}, }; +StreamsCalculationTestCase _1sockets_mock_tput_2 = { + 1, + false, + 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}}, + {{4, MAIN_CORE_PROC, 4, 0, 0}, {2, MAIN_CORE_PROC, 4, 1, 1}}, +}; + +StreamsCalculationTestCase _1sockets_mock_tput_3 = { + 1, + false, + 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}}, +}; + TEST_P(StreamsCalculationTests, StreamsCalculation) {} INSTANTIATE_TEST_SUITE_P(StreamsInfoTable, @@ -1762,11 +1882,17 @@ INSTANTIATE_TEST_SUITE_P(StreamsInfoTable, _2sockets_104cores_latency_socket_5, _2sockets_104cores_latency_socket_6, _2sockets_104cores_latency_socket_7, + _2sockets_104cores_latency_socket_8, + _2sockets_104cores_latency_socket_9, + _2sockets_104cores_latency_socket_10, _2sockets_104cores_latency_node_1, _2sockets_104cores_latency_node_2, _2sockets_104cores_latency_node_3, _2sockets_104cores_latency_node_4, _2sockets_104cores_latency_node_5, + _2sockets_104cores_latency_node_6, + _2sockets_104cores_latency_node_7, + _2sockets_104cores_latency_node_8, _2sockets_104cores_latency_1, _2sockets_104cores_latency_2, _2sockets_104cores_latency_3, @@ -1796,10 +1922,12 @@ INSTANTIATE_TEST_SUITE_P(StreamsInfoTable, _2sockets_104cores_tput_19, _2sockets_104cores_tput_20, _2sockets_48cores_latency_1, + _2sockets_48cores_latency_2, _2sockets_48cores_tput_1, _2sockets_48cores_tput_2, _2sockets_48cores_tput_3, _2sockets_48cores_tput_4, + _2sockets_20cores_tput_1, _1sockets_14cores_latency_1, _1sockets_14cores_latency_2, _1sockets_14cores_latency_3, @@ -1879,6 +2007,8 @@ INSTANTIATE_TEST_SUITE_P(StreamsInfoTable, _1sockets_ecores_tput_3, _1sockets_ecores_tput_4, _1sockets_ecores_tput_5, - _1sockets_mock_tput_1)); + _1sockets_mock_tput_1, + _1sockets_mock_tput_2, + _1sockets_mock_tput_3)); } // namespace \ No newline at end of file diff --git a/src/plugins/intel_cpu/tests/unit/transformations/convert_to_rope.cpp b/src/plugins/intel_cpu/tests/unit/transformations/convert_to_rope.cpp index 91fae33253a494..6001e3539a1759 100644 --- a/src/plugins/intel_cpu/tests/unit/transformations/convert_to_rope.cpp +++ b/src/plugins/intel_cpu/tests/unit/transformations/convert_to_rope.cpp @@ -139,6 +139,9 @@ TEST_F(TransformationTestsF, ConvertToROPE_LLama2_no_gather) { {"config.slice_stop", 0}, {"config.input_trans0213", true}, {"config.is_interleaved", false}, + {"config.is_chatglm", false}, + {"config.head_cnt", 0}, + {"config.head_size", 0}, {"config.rotary_ndims", static_cast(ndims)}, {"config.gather_position_arg_id", 0}}); @@ -170,6 +173,9 @@ TEST_F(TransformationTestsF, ConvertToROPE_LLama2_with_gather) { {"config.slice_stop", 0}, {"config.input_trans0213", true}, {"config.is_interleaved", false}, + {"config.is_chatglm", false}, + {"config.head_cnt", 0}, + {"config.head_size", 0}, {"config.rotary_ndims", static_cast(ndims)}, {"config.gather_position_arg_id", 3}}); @@ -304,6 +310,9 @@ TEST_F(TransformationTestsF, ConvertToROPE_GPTNEOX_no_gather) { {"config.slice_stop", ndims}, {"config.input_trans0213", true}, {"config.is_interleaved", false}, + {"config.is_chatglm", false}, + {"config.head_cnt", 0}, + {"config.head_size", 0}, {"config.rotary_ndims", rotary_ndims}, {"config.gather_position_arg_id", 0}}); model_ref = std::make_shared(ov::NodeVector{rope}, ov::ParameterVector{input, param_cos, param_sin}); @@ -334,6 +343,9 @@ TEST_F(TransformationTestsF, ConvertToROPE_GPTNEOX_with_gather) { {"config.slice_stop", ndims}, {"config.input_trans0213", true}, {"config.is_interleaved", false}, + {"config.is_chatglm", false}, + {"config.head_cnt", 0}, + {"config.head_size", 0}, {"config.rotary_ndims", rotary_ndims}, {"config.gather_position_arg_id", 3}}); model_ref = @@ -445,8 +457,119 @@ TEST_F(TransformationTestsF, ConvertToROPE_GPTJ) { {"config.slice_stop", 0}, {"config.input_trans0213", false}, {"config.is_interleaved", true}, + {"config.is_chatglm", false}, + {"config.head_cnt", 0}, + {"config.head_size", 0}, {"config.rotary_ndims", rotary_ndims}, {"config.gather_position_arg_id", 0}}); model_ref = std::make_shared(ov::NodeVector{rope}, ov::ParameterVector{input, cos_sin}); } +} + +TEST_F(TransformationTestsF, ConvertToROPE_chatGML) { + disable_rt_info_check(); + const int batch = 2; + const int seq_len = 7; + const int num_heads = 32; + const int ndims = 128; + const int rotary_ndims = 64; + const int max_pos_length = 2048; + { + auto input = std::make_shared(ov::element::f32, ov::Shape{seq_len, batch, 4608}); + auto seq_length = std::make_shared(ov::element::i32, ov::Shape{1}); + auto cos_sin_cache = + std::make_shared(ov::element::f32, + ov::Shape{max_pos_length, batch, rotary_ndims / 2, 2}); + + auto ListUnpack_321 = makeOP({input, -1, {4096, 256, 256}}); + auto view_Reshape = makeOP({ListUnpack_321->output(0), {0, 0, num_heads, ndims}}, + {{"special_zero", true}}); + auto aten_slice_Slice_357 = + makeOP({view_Reshape, {0, 0, 0, 0}, {0, 0, 0, rotary_ndims}, {1, 1, 1, 1}}, + {{"begin_mask", {1, 1, 1, 0}}, + {"end_mask", {1, 1, 1, 0}}, + {"new_axis_mask", {}}, + {"shrink_axis_mask", {}}, + {"ellipsis_mask", {}}}); + auto ListConstruct_372_Concat = + makeOP({seq_length, {-1}, {num_heads}, {rotary_ndims / 2}, {2}}, {{"axis", 0}}); + auto aten_reshape_Reshape_373 = + makeOP({aten_slice_Slice_357, ListConstruct_372_Concat}, {{"special_zero", false}}); + auto aten_select_Gather_381 = + makeOP({aten_reshape_Reshape_373, 0, -1}, {{"batch_dims", 0}}); + auto aten_slice_Slice_369 = makeOP({cos_sin_cache, {0}, seq_length, {1}}, + {{"begin_mask", {0}}, + {"end_mask", {0}}, + {"new_axis_mask", {}}, + {"shrink_axis_mask", {}}, + {"ellipsis_mask", {}}}); + auto ListConstruct_379_Concat = + makeOP({seq_length, {-1}, {1}, {rotary_ndims / 2}, {2}}, {{"axis", 0}}); + auto aten_view_Reshape_380 = + makeOP({aten_slice_Slice_369, ListConstruct_379_Concat}, {{"special_zero", false}}); + auto aten_select_Gather_382 = makeOP({aten_view_Reshape_380, 0, -1}, {{"batch_dims", 0}}); + auto aten_mul_Multiply_383 = makeOP({aten_select_Gather_381, aten_select_Gather_382}, + {{"auto_broadcast", "numpy"}}); + auto aten_select_Gather_384 = + makeOP({aten_reshape_Reshape_373, 1, -1}, {{"batch_dims", 0}}); + auto aten_select_Gather_385 = makeOP({aten_view_Reshape_380, 1, -1}, {{"batch_dims", 0}}); + auto aten_mul_Multiply_386 = makeOP({aten_select_Gather_384, aten_select_Gather_385}, + {{"auto_broadcast", "numpy"}}); + auto Multiply_101315 = + makeOP({aten_mul_Multiply_386, -1.000000f}, {{"auto_broadcast", "numpy"}}); + auto aten_sub_Subtract_389 = + makeOP({aten_mul_Multiply_383, Multiply_101315}, {{"auto_broadcast", "numpy"}}); + auto Unsqueeze_62716 = makeOP({aten_sub_Subtract_389, -1}); + auto aten_mul_Multiply_391 = makeOP({aten_select_Gather_384, aten_select_Gather_382}, + {{"auto_broadcast", "numpy"}}); + auto aten_mul_Multiply_393 = makeOP({aten_select_Gather_381, aten_select_Gather_385}, + {{"auto_broadcast", "numpy"}}); + auto aten_add_Add_396 = + makeOP({aten_mul_Multiply_391, aten_mul_Multiply_393}, {{"auto_broadcast", "numpy"}}); + auto Unsqueeze_62717 = makeOP({aten_add_Add_396, -1}); + auto aten_stack_401 = makeOP({Unsqueeze_62716, Unsqueeze_62717}, {{"axis", -1}}); + auto ShapeOf_134820 = makeOP>( + {aten_stack_401}, + {{"type_relax", true}, {"input_data_types", {}}, {"output_data_types", {ov::element::i32}}}); + auto aten_flatten_Slice_417 = makeOP({ShapeOf_134820, {0}, {3}, {1}}, + {{"begin_mask", {0}}, + {"end_mask", {0}}, + {"new_axis_mask", {}}, + {"shrink_axis_mask", {}}, + {"ellipsis_mask", {}}}); + auto aten_flatten_Concat_420 = makeOP({aten_flatten_Slice_417, {-1}}, {{"axis", 0}}); + auto aten_flatten_Reshape_421 = + makeOP({aten_stack_401, aten_flatten_Concat_420}, {{"special_zero", true}}); + auto aten_slice_Slice_363 = + makeOP({view_Reshape, {0, 0, 0, rotary_ndims}, {0, 0, 0, INT_MAX}, {1, 1, 1, 1}}, + {{"begin_mask", {1, 1, 1, 0}}, + {"end_mask", {1, 1, 1, 0}}, + {"new_axis_mask", {}}, + {"shrink_axis_mask", {}}, + {"ellipsis_mask", {}}}); + auto aten_cat_Concat_425 = + makeOP({aten_flatten_Reshape_421, aten_slice_Slice_363}, {{"axis", -1}}); + model = std::make_shared(ov::NodeVector{aten_cat_Concat_425}, + ov::ParameterVector{input, seq_length, cos_sin_cache}); + } + manager.register_pass(); + { + auto input = std::make_shared(ov::element::f32, ov::Shape{seq_len, batch, 4608}); + auto seq_length = std::make_shared(ov::element::i32, ov::Shape{1}); + auto cos_sin_cache = + std::make_shared(ov::element::f32, + ov::Shape{max_pos_length, batch, rotary_ndims / 2, 2}); + auto rope = makeOP({input, cos_sin_cache, cos_sin_cache}, + {{"config.slice_start", 0}, + {"config.slice_stop", 4096}, + {"config.input_trans0213", false}, + {"config.is_interleaved", false}, + {"config.rotary_ndims", rotary_ndims}, + {"config.is_chatglm", true}, + {"config.head_cnt", num_heads}, + {"config.head_size", ndims}, + {"config.gather_position_arg_id", 0}}); + model_ref = + std::make_shared(ov::NodeVector{rope}, ov::ParameterVector{input, seq_length, cos_sin_cache}); + } } \ 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 6f30e3390f4d37..1ce6263cb2d631 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 @@ -8,8 +8,8 @@ #include #include -#include -#include +#include +#include #include #include #include @@ -38,9 +38,9 @@ static std::shared_ptr makeSDPA(const ov::PartialShape& inputShape, b pastv = std::make_shared(pastv, element::f32); } if (isRef) { - ov::intel_cpu::ScaledDotProductAttentionStub::Config config; + ov::intel_cpu::ScaledDotProductAttentionWithKVCache::Config config; config.fuse_concat = true; - auto new_node = std::make_shared(OutputVector{q, k, v, pastk, pastv}, config); + auto new_node = std::make_shared(OutputVector{q, k, v, pastk, pastv}, config); sdp = new_node->output(0); concatK = new_node->output(1); concatV = new_node->output(2); @@ -71,7 +71,7 @@ TEST(TransformationTests, StateConcatSDPA) { f = makeSDPA(inputShape); pass::Manager m; m.register_pass(); - m.register_pass(); + m.register_pass(); m.run_passes(f); } //construct ref interaction @@ -92,7 +92,7 @@ TEST(TransformationTests, StateConcatSDPAWithConvert) { f = makeSDPA(inputShape, false, true); pass::Manager m; m.register_pass(); - m.register_pass(); + m.register_pass(); m.run_passes(f); } //construct ref interaction diff --git a/src/plugins/intel_cpu/thirdparty/CMakeLists.txt b/src/plugins/intel_cpu/thirdparty/CMakeLists.txt index ef8e5cd1da8985..4a45a07021a9fd 100644 --- a/src/plugins/intel_cpu/thirdparty/CMakeLists.txt +++ b/src/plugins/intel_cpu/thirdparty/CMakeLists.txt @@ -126,10 +126,12 @@ function(ov_add_onednn) # but for this we need to install library files install(FILES $ DESTINATION ${OV_CPACK_ARCHIVEDIR} - COMPONENT ${OV_CPACK_COMP_CORE}) + COMPONENT ${OV_CPACK_COMP_CORE} + ${OV_CPACK_COMP_CORE_EXCLUDE_ALL}) install(FILES "${intel_cpu_thirdparty_SOURCE_DIR}/ACLConfig.cmake" DESTINATION ${OV_CPACK_OPENVINO_CMAKEDIR} - COMPONENT ${OV_CPACK_COMP_CORE_DEV}) + COMPONENT ${OV_CPACK_COMP_CORE_DEV} + ${OV_CPACK_COMP_CORE_DEV_EXCLUDE_ALL}) endif() endfunction() diff --git a/src/plugins/intel_gna/CMakeLists.txt b/src/plugins/intel_gna/CMakeLists.txt index ecb94ece6b3db2..ce51c8fc88a156 100644 --- a/src/plugins/intel_gna/CMakeLists.txt +++ b/src/plugins/intel_gna/CMakeLists.txt @@ -96,7 +96,7 @@ if(BUILD_SHARED_LIBS) set(gna_component gna) else() # during static build all plugins are part of the core, thus the dependencies as well - set(gna_component core) + set(gna_component ${OV_CPACK_COMP_CORE}) endif() file(GLOB_RECURSE gna_libraries "${libGNA_LIBRARIES_BASE_PATH}/*${CMAKE_SHARED_LIBRARY_SUFFIX}*") @@ -125,14 +125,16 @@ if(NOT BUILD_SHARED_LIBS) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/libGNAConfig.cmake ${CMAKE_BINARY_DIR} COPYONLY) install(FILES "${CMAKE_BINARY_DIR}/libGNAConfig.cmake" DESTINATION ${OV_CPACK_IE_CMAKEDIR} - COMPONENT ${gna_component}) + COMPONENT ${gna_component} + ${OV_CPACK_COMP_CORE_DEV_EXCLUDE_ALL}) # install .lib file on Windows if(WIN32) file(GLOB_RECURSE gna_libraries "${libGNA_LIBRARIES_BASE_PATH}/*${CMAKE_STATIC_LIBRARY_SUFFIX}") install(FILES ${gna_libraries} DESTINATION ${OV_CPACK_LIBRARYDIR} - COMPONENT ${gna_component}) + COMPONENT ${gna_component} + ${OV_CPACK_COMP_CORE_DEV_EXCLUDE_ALL}) endif() endif() diff --git a/src/plugins/intel_gna/src/backend/gna_limitations.cpp b/src/plugins/intel_gna/src/backend/gna_limitations.cpp index 0d459ecabaebb7..276ea7c5f2f9f3 100644 --- a/src/plugins/intel_gna/src/backend/gna_limitations.cpp +++ b/src/plugins/intel_gna/src/backend/gna_limitations.cpp @@ -677,7 +677,7 @@ constexpr uint32_t Limitations::kBytesPerCropElement; constexpr uint32_t Limitations::kBytesPerConcatElement; constexpr uint32_t Limitations::kMemoryPageSize; -thread_local std::shared_ptr Limitations::k_instance{nullptr}; +ov::threading::ThreadLocal> Limitations::kInstance{nullptr}; Limitations::Limitations(const DeviceVersion& target) { m_use_only_16bit_conv_weights = @@ -689,7 +689,13 @@ Limitations::Limitations(const DeviceVersion& target) { } void Limitations::init(const DeviceVersion& compile_target) { - k_instance = std::shared_ptr(new Limitations(compile_target)); + auto& localInstance = kInstance.local(); + localInstance.reset(new Limitations(compile_target)); +} + +void Limitations::deinit() { + auto& localInstance = kInstance.local(); + localInstance.reset(); } size_t Limitations::get_min_batch_to_fit_in_buffer(InferenceEngine::DataPtr input) { diff --git a/src/plugins/intel_gna/src/backend/gna_limitations.hpp b/src/plugins/intel_gna/src/backend/gna_limitations.hpp index b30a32a18561e1..bfb68b3f35f5c3 100644 --- a/src/plugins/intel_gna/src/backend/gna_limitations.hpp +++ b/src/plugins/intel_gna/src/backend/gna_limitations.hpp @@ -20,6 +20,7 @@ #include "legacy/ngraph_ops/fully_connected.hpp" #include "ngraph/opsets/opset7.hpp" #include "ngraph/opsets/opset9.hpp" +#include "openvino/runtime/threading/thread_local.hpp" #include "ops/gna_convolution.hpp" #include "ops/gna_max_pool.hpp" @@ -164,12 +165,17 @@ class AbstractValidator { class Limitations { public: /** - * @brief Create instance of the Limitations class. Due to Limitations being a singleton, multiple instances of the - * plugin with different compilation targets cannot exist at the same time + * @brief Create an instance of the Limitations class. Since Limitations is designed as a singleton, multiple + * instances of the plugin with different compilation targets cannot coexist simultaneously for the same thread. * @param compile_target GNA compile target */ static void init(const target::DeviceVersion& compile_target); + /** + * @brief Delete the instance of the Limitations class for the currently running thread. + */ + static void deinit(); + /** * @brief Returns the instance of Limitations object. Requires an Init call before the first usage */ @@ -309,14 +315,16 @@ class Limitations { bool m_use_only_16bit_conv_weights = false; size_t m_mem_alignment = 0; std::shared_ptr m_cnn_validator; - static thread_local std::shared_ptr k_instance; + + static ov::threading::ThreadLocal> kInstance; }; inline std::shared_ptr Limitations::get_instance() { - if (!k_instance) { + auto& instance = kInstance.local(); + if (!instance) { THROW_GNA_EXCEPTION << "Limitations instance is not initialized.\n"; } - return k_instance; + return instance; } inline bool Limitations::is_crop_affined_offset(size_t numberOfElements) const { diff --git a/src/plugins/intel_gna/src/gna_plugin.cpp b/src/plugins/intel_gna/src/gna_plugin.cpp index e9adb59c70b613..ef658a339a1798 100644 --- a/src/plugins/intel_gna/src/gna_plugin.cpp +++ b/src/plugins/intel_gna/src/gna_plugin.cpp @@ -1429,4 +1429,6 @@ InferenceEngine::QueryNetworkResult GNAPlugin::QueryNetwork( GNAPlugin::~GNAPlugin() { if (gnadevice) gnadevice->close(); + + Limitations::deinit(); } diff --git a/src/plugins/intel_gna/tests/deprecated/unit/engines/gna/I8_quantisation_test.cpp b/src/plugins/intel_gna/tests/deprecated/unit/engines/gna/I8_quantisation_test.cpp index cdd882c107aa4c..e7da37e1467bab 100644 --- a/src/plugins/intel_gna/tests/deprecated/unit/engines/gna/I8_quantisation_test.cpp +++ b/src/plugins/intel_gna/tests/deprecated/unit/engines/gna/I8_quantisation_test.cpp @@ -52,6 +52,10 @@ class I8QuantisationTest : public GNATest<> { void SetUp() override { Limitations::init(target::DeviceVersion::Default); } + + void TearDown() override { + Limitations::deinit(); + } }; // TODO: add test for FC weights after quantization diff --git a/src/plugins/intel_gna/tests/deprecated/unit/engines/gna/i16_quantisation_test.cpp b/src/plugins/intel_gna/tests/deprecated/unit/engines/gna/i16_quantisation_test.cpp index 64645325513d93..5a64a2c3bff795 100644 --- a/src/plugins/intel_gna/tests/deprecated/unit/engines/gna/i16_quantisation_test.cpp +++ b/src/plugins/intel_gna/tests/deprecated/unit/engines/gna/i16_quantisation_test.cpp @@ -54,6 +54,10 @@ class I16QuantisationTest : public GNATest<> { void SetUp() override { Limitations::init(target::DeviceVersion::Default); } + + void TearDown() override { + Limitations::deinit(); + } }; template diff --git a/src/plugins/intel_gna/tests/functional/pass_tests/concat_restrictions.cpp b/src/plugins/intel_gna/tests/functional/pass_tests/concat_restrictions.cpp index 4e32acaf67d867..f749287d38ee7c 100644 --- a/src/plugins/intel_gna/tests/functional/pass_tests/concat_restrictions.cpp +++ b/src/plugins/intel_gna/tests/functional/pass_tests/concat_restrictions.cpp @@ -767,7 +767,7 @@ INSTANTIATE_TEST_SUITE_P(smoke_concat_restrictions, ConvConcatConcatNHWCRestrictionsPos::getTestCaseName); const vector ttc_input_shapes = {{64, 384}}; -const vector> ttc_configs = { +const vector> ttc_configs = { {{"GNA_DEVICE_MODE", "GNA_SW_FP32"}}, {{"GNA_DEVICE_MODE", "GNA_SW_EXACT"}, {"GNA_EXEC_TARGET", "GNA_TARGET_2_0"}}, {{"GNA_DEVICE_MODE", "GNA_SW_EXACT"}, {"GNA_EXEC_TARGET", "GNA_TARGET_3_0"}}, diff --git a/src/plugins/intel_gna/tests/functional/pass_tests/diagonal_insertion_test.cpp b/src/plugins/intel_gna/tests/functional/pass_tests/diagonal_insertion_test.cpp index 8e99b7699998cc..c92aad2e8a11e3 100644 --- a/src/plugins/intel_gna/tests/functional/pass_tests/diagonal_insertion_test.cpp +++ b/src/plugins/intel_gna/tests/functional/pass_tests/diagonal_insertion_test.cpp @@ -27,8 +27,8 @@ using namespace ngraph::op; using namespace ngraph::opset9; using namespace std; -using DiagonalInsertionTestParams = tuple, // Configuration - vector> // FakeQuantize min/max params +using DiagonalInsertionTestParams = tuple, // Configuration + vector> // FakeQuantize min/max params >; constexpr uint16_t fq_levels = numeric_limits::max(); @@ -89,13 +89,13 @@ class DiagonalInsertionTest : public testing::WithParamInterface(input_node, target_shape_const, false); } - bool IsDebugEnabled(map& configuration) { + bool IsDebugEnabled(map& configuration) { return configuration.find("LOG_LEVEL") != configuration.end() && configuration["LOG_LEVEL"] == "LOG_DEBUG"; } public: - static string getTestCaseName(testing::TestParamInfo obj) { - map configuration; + static std::string getTestCaseName(testing::TestParamInfo obj) { + map configuration; vector> fq_min_max; tie(configuration, fq_min_max) = obj.param; @@ -156,7 +156,7 @@ TEST_P(DiagonalInsertionTest, CompareWithRefs) { Run(); }; -const vector> configs = { +const vector> configs = { { {"GNA_DEVICE_MODE", "GNA_SW_EXACT"}, {"GNA_PRECISION", "I16"}, diff --git a/src/plugins/intel_gna/tests/functional/shared_tests_instances/single_layer_tests/conv_low_precision.cpp b/src/plugins/intel_gna/tests/functional/shared_tests_instances/single_layer_tests/conv_low_precision.cpp index 752d1a6bd2d237..5048e80ccf1c80 100644 --- a/src/plugins/intel_gna/tests/functional/shared_tests_instances/single_layer_tests/conv_low_precision.cpp +++ b/src/plugins/intel_gna/tests/functional/shared_tests_instances/single_layer_tests/conv_low_precision.cpp @@ -29,12 +29,12 @@ using namespace ov::op; using namespace ov::opset12; using namespace std; -using ConvLowPrecisionTestParams = tuple, // Configuration - Shape, // Input Shape - pair, // FQ Min and Max (before conv) - std::size_t // Levels +using ConvLowPrecisionTestParams = tuple, // Configuration + Shape, // Input Shape + pair, // FQ Min and Max (before conv) + std::size_t // Levels >; class ConvLowPrecisionTest : public testing::WithParamInterface, @@ -44,10 +44,10 @@ class ConvLowPrecisionTest : public testing::WithParamInterface obj) { + static std::string getTestCaseName(testing::TestParamInfo obj) { InferenceEngine::Precision netPrecision; - string targetDevice; - map configuration; + std::string targetDevice; + map configuration; Shape inputShape; pair fqMinMax; std::size_t levels = 0; @@ -129,17 +129,17 @@ TEST_P(ConvLowPrecisionTest, CompareWithRefs) { const vector netPrecisions = {InferenceEngine::Precision::FP16, InferenceEngine::Precision::FP32}; -const vector> configs_1 = { +const vector> configs_1 = { {{"GNA_DEVICE_MODE", "GNA_AUTO"}, {"GNA_PRECISION", "I8"}, {"GNA_EXEC_TARGET", "GNA_TARGET_1_0"}}, {{"GNA_DEVICE_MODE", "GNA_AUTO"}, {"GNA_PRECISION", "I16"}, {"GNA_EXEC_TARGET", "GNA_TARGET_1_0"}}, }; -const vector> configs_2 = { +const vector> configs_2 = { {{"GNA_DEVICE_MODE", "GNA_AUTO"}, {"GNA_PRECISION", "I8"}, {"GNA_EXEC_TARGET", "GNA_TARGET_2_0"}}, {{"GNA_DEVICE_MODE", "GNA_AUTO"}, {"GNA_PRECISION", "I16"}, {"GNA_EXEC_TARGET", "GNA_TARGET_2_0"}}, }; -const vector> configs_3 = { +const vector> configs_3 = { {{"GNA_DEVICE_MODE", "GNA_AUTO"}, {"GNA_PRECISION", "I8"}, {"GNA_EXEC_TARGET", "GNA_TARGET_3_0"}}, {{"GNA_DEVICE_MODE", "GNA_AUTO"}, {"GNA_PRECISION", "I16"}, {"GNA_EXEC_TARGET", "GNA_TARGET_3_0"}}, {{"GNA_DEVICE_MODE", "GNA_AUTO"}, {"GNA_PRECISION", "I8"}, {"GNA_EXEC_TARGET", "GNA_TARGET_3_5"}}, diff --git a/src/plugins/intel_gna/tests/functional/shared_tests_instances/subgraph_tests/reshape_permute_conv_permute_reshape_act.cpp b/src/plugins/intel_gna/tests/functional/shared_tests_instances/subgraph_tests/reshape_permute_conv_permute_reshape_act.cpp index 4266a70b147d7d..22225f69cabf1d 100644 --- a/src/plugins/intel_gna/tests/functional/shared_tests_instances/subgraph_tests/reshape_permute_conv_permute_reshape_act.cpp +++ b/src/plugins/intel_gna/tests/functional/shared_tests_instances/subgraph_tests/reshape_permute_conv_permute_reshape_act.cpp @@ -33,9 +33,8 @@ std::vector model_types = { ov::element::f32, }; -std::vector> configs = { - {{"GNA_DEVICE_MODE", "GNA_SW_EXACT"}, {"GNA_SCALE_FACTOR_0", "2340"}}, - {{"GNA_DEVICE_MODE", "GNA_SW_FP32"}}}; +std::vector configs = {{{"GNA_DEVICE_MODE", "GNA_SW_EXACT"}, {"GNA_SCALE_FACTOR_0", "2340"}}, + {{"GNA_DEVICE_MODE", "GNA_SW_FP32"}}}; INSTANTIATE_TEST_SUITE_P(smoke_basic, ConvReshapeAct, diff --git a/src/plugins/intel_gna/tests/unit/backend/gna_limitations_test.cpp b/src/plugins/intel_gna/tests/unit/backend/gna_limitations_test.cpp index 4ce23c8de29bd2..fd1014e716c46e 100644 --- a/src/plugins/intel_gna/tests/unit/backend/gna_limitations_test.cpp +++ b/src/plugins/intel_gna/tests/unit/backend/gna_limitations_test.cpp @@ -287,6 +287,10 @@ class GNAcnn2dValidatorTest : public ::testing::TestWithParam validator; }; diff --git a/src/plugins/intel_gna/tests/unit/gna_get_aligned_split_sizes.cpp b/src/plugins/intel_gna/tests/unit/gna_get_aligned_split_sizes.cpp index 672d8666b5dbcf..0cfc4caed8ae59 100644 --- a/src/plugins/intel_gna/tests/unit/gna_get_aligned_split_sizes.cpp +++ b/src/plugins/intel_gna/tests/unit/gna_get_aligned_split_sizes.cpp @@ -65,6 +65,7 @@ void RunVariadicSplitSupportedTest(DeviceVersion device_version, std::vectorget_memory_alignment(), 64); + Limitations::deinit(); } TEST(MemoryAlignmentTest, getMemoryAlignmentBytes_Expect16ByteAlignmentWhenTargetIsGNA3_6) { Limitations::init(DeviceVersion::GNA3_6); EXPECT_EQ(Limitations::get_instance()->get_memory_alignment(), 16); + Limitations::deinit(); } } // namespace testing diff --git a/src/plugins/intel_gna/tests/unit/transformations/gna_decompose_2d_convolution.cpp b/src/plugins/intel_gna/tests/unit/transformations/gna_decompose_2d_convolution.cpp index ea03b9971e1166..2eed9b367d034e 100644 --- a/src/plugins/intel_gna/tests/unit/transformations/gna_decompose_2d_convolution.cpp +++ b/src/plugins/intel_gna/tests/unit/transformations/gna_decompose_2d_convolution.cpp @@ -295,6 +295,7 @@ class Decompose2DConvTestInvalidFixture : public ov::test::TestsCommon, public ::testing::WithParamInterface { public: void SetUp() override; + void TearDown() override; public: std::shared_ptr function, reference_function; @@ -339,12 +340,17 @@ void Decompose2DConvTestInvalidFixture::SetUp() { conv_params); } +void Decompose2DConvTestInvalidFixture::TearDown() { + Limitations::deinit(); +} + // --------------------------------------------------------------------------------------------------------------------- class Decompose2DConvTestFixture : public ov::test::TestsCommon, public ::testing::WithParamInterface { public: void SetUp() override; + void TearDown() override; std::shared_ptr get_reference(const bool& fq, const modelType& model, @@ -385,6 +391,10 @@ void Decompose2DConvTestFixture::SetUp() { reference_function = get_reference(fq, model, input_shape, graph_data, conv_params); } +void Decompose2DConvTestFixture::TearDown() { + Limitations::deinit(); +} + std::shared_ptr ReshapeBiasConst(std::shared_ptr conv_bias, const ConvParams& conv_params) { auto add_const = diff --git a/src/plugins/intel_gna/tests/unit/transformations/gna_insert_copy_layer.cpp b/src/plugins/intel_gna/tests/unit/transformations/gna_insert_copy_layer.cpp index c3d778b903e22d..87d53ff68f9c1f 100644 --- a/src/plugins/intel_gna/tests/unit/transformations/gna_insert_copy_layer.cpp +++ b/src/plugins/intel_gna/tests/unit/transformations/gna_insert_copy_layer.cpp @@ -44,6 +44,7 @@ class InsertCopyLayerTest : public ov::test::TestsCommon, public ::testing::With return result.str(); } void SetUp() override; + void TearDown() override; virtual void Validate(); virtual void Run(); @@ -64,6 +65,9 @@ void InsertCopyLayerTest::SetUp() { std::tie(m_device_ver, m_axis, m_inputs_num) = this->GetParam(); Limitations::init(m_device_ver); } +void InsertCopyLayerTest::TearDown() { + Limitations::deinit(); +} void InsertCopyLayerTest::Run() { Validate(); @@ -212,6 +216,7 @@ class TransformationTestsBase : public ov::test::TestsCommon, void TearDown() override { m_func.reset(); + Limitations::deinit(); } void RunPasses(ngraph::pass::Manager& m) { diff --git a/src/plugins/intel_gna/tests/unit/transformations/gna_insert_identity_layer.cpp b/src/plugins/intel_gna/tests/unit/transformations/gna_insert_identity_layer.cpp index 229ca62f9fc30c..3ba212c6dc76cf 100644 --- a/src/plugins/intel_gna/tests/unit/transformations/gna_insert_identity_layer.cpp +++ b/src/plugins/intel_gna/tests/unit/transformations/gna_insert_identity_layer.cpp @@ -81,7 +81,7 @@ typedef tuple { public: - static string getTestCaseName(const testing::TestParamInfo& obj) { + static std::string getTestCaseName(const testing::TestParamInfo& obj) { size_t axis, inputs_num; tie(axis, inputs_num) = obj.param; @@ -198,7 +198,7 @@ typedef tuple { public: - static string getTestCaseName(const testing::TestParamInfo& obj) { + static std::string getTestCaseName(const testing::TestParamInfo& obj) { ELTWISE_TYPE type; bool low_precision, both_inputs_32bits; tie(type, low_precision, both_inputs_32bits) = obj.param; @@ -472,7 +472,7 @@ typedef tuple { public: - static string getTestCaseName(const testing::TestParamInfo& obj) { + static std::string getTestCaseName(const testing::TestParamInfo& obj) { bool with_pool, with_act, swap_matmul; tie(with_pool, with_act, swap_matmul) = obj.param; @@ -613,7 +613,7 @@ TEST_F(InsertIdentityLayerResultTest, CompareWithRefs) { } class InsertIdentityForNonQuantizableConcatInputTest : public InsertIdentityLayerTest { - string getName() { + std::string getName() { return "InsertIdentityForPrecAgnosticConcatInput"; } diff --git a/src/plugins/intel_gna/tests/unit/transformations/gna_split_convolution_with_large_buffer_size.cpp b/src/plugins/intel_gna/tests/unit/transformations/gna_split_convolution_with_large_buffer_size.cpp index e51b7832d44ee5..863e42d21a45bd 100644 --- a/src/plugins/intel_gna/tests/unit/transformations/gna_split_convolution_with_large_buffer_size.cpp +++ b/src/plugins/intel_gna/tests/unit/transformations/gna_split_convolution_with_large_buffer_size.cpp @@ -270,6 +270,7 @@ class SplitConvolutionFixture : public ov::test::TestsCommon, public ::testing::WithParamInterface> { public: void SetUp() override; + void TearDown() override; public: std::shared_ptr function, reference_function; @@ -290,6 +291,10 @@ void SplitConvolutionFixture::SetUp() { reference_function = reference_graph.createFunction(); } +void SplitConvolutionFixture::TearDown() { + Limitations::deinit(); +} + void execute_test(std::shared_ptr function, std::shared_ptr reference_function, ngraph::pass::Manager& pass_manager) { diff --git a/src/plugins/intel_gna/tests/unit/transformations/gna_split_eltwise.cpp b/src/plugins/intel_gna/tests/unit/transformations/gna_split_eltwise.cpp index 05f928a596d07a..fd92a12cf89eb2 100644 --- a/src/plugins/intel_gna/tests/unit/transformations/gna_split_eltwise.cpp +++ b/src/plugins/intel_gna/tests/unit/transformations/gna_split_eltwise.cpp @@ -134,6 +134,7 @@ class SplitEltwiseTestSuiteFixture : public ov::test::TestsCommon, public ::testing::WithParamInterface { public: void SetUp() override; + void TearDown() override; public: std::shared_ptr function, reference_function; @@ -151,6 +152,10 @@ void SplitEltwiseTestSuiteFixture::SetUp() { reference_function = createFunction(shape, with_const, with_fq, type, true); } +void SplitEltwiseTestSuiteFixture::TearDown() { + Limitations::deinit(); +} + void execute_test(std::shared_ptr function, std::shared_ptr reference_function) { ngraph::pass::Manager manager; manager.register_pass(); diff --git a/src/plugins/intel_gpu/src/graph/condition.cpp b/src/plugins/intel_gpu/src/graph/condition.cpp index 5b7470e8887598..6c1262e00bc023 100644 --- a/src/plugins/intel_gpu/src/graph/condition.cpp +++ b/src/plugins/intel_gpu/src/graph/condition.cpp @@ -108,9 +108,7 @@ static ov::PartialShape resolve_shape(const ov::PartialShape& true_pshape, const // if rangs of shapes are not equal or rang of one of them is dynamic function // return shape with dynamic rank - if (then_rank.is_dynamic() || else_rank.is_dynamic()) { - return ov::PartialShape::dynamic(); - } + OPENVINO_ASSERT((then_rank.is_static() && else_rank.is_static()), "dynamic rank is not supported"); if (then_rank.get_length() != else_rank.get_length()) { // Union of scalar and 1D case if (then_rank.get_length() <= 1 && else_rank.get_length() <= 1) { @@ -139,22 +137,15 @@ static ov::PartialShape resolve_shape(const ov::PartialShape& true_pshape, const return ov::PartialShape(new_dims); } -static std::vector resolve_shape(std::vector& target_list, std::vector& other_list) { - std::vector resolved_layout; - for (size_t i = 0; i < target_list.size(); i++) { - auto target = target_list[i]; - auto other = other_list[i]; - auto target_pshape = target.get_partial_shape(); - auto other_pshape = other.get_partial_shape(); - auto target_rank = target_pshape.rank(); - auto other_rank = other_pshape.rank(); - if (target_rank.get_length() == 0 && other_rank.get_length() == 1) { - resolved_layout.push_back({ov::PartialShape{1}, target.data_type, target.format}); - } else { - resolved_layout.push_back(target); - } +layout condition_inst::adjust_scalar_to_1d_layout(layout& target, layout& other) { + auto target_pshape = target.get_partial_shape(); + auto other_pshape = other.get_partial_shape(); + auto target_rank = target_pshape.rank(); + auto other_rank = other_pshape.rank(); + if (target_rank.get_length() == 0 && other_rank.get_length() == 1) { + return {ov::PartialShape{1}, target.data_type, target.format}; } - return resolved_layout; + return target; } template @@ -179,7 +170,6 @@ std::vector condition_inst::calc_output_layouts(condition_node const& /* output_layouts.push_back(layout{out_layout, layouts_true[i].data_type, layouts_true[i].format }); } } - return output_layouts; } else { auto layouts_true = get_output_layouts(get_out_layout_map(impl_param.inner_nets[idx_branch_true]), impl_param.io_output_maps[idx_branch_true]); @@ -192,11 +182,17 @@ std::vector condition_inst::calc_output_layouts(condition_node const& /* OPENVINO_ASSERT(memory_deps.count(0) > 0, "The count of memory deps should not be zero"); auto mem_ptr = memory_deps.at(0); auto pred = condition_inst::get_pred_from_memory(mem_ptr, impl_param.get_stream()); + std::vector output_layouts; if (pred) { - return resolve_shape(layouts_true, layouts_false); + for (size_t i = 0; i < num_outputs; i++) { + output_layouts.push_back(condition_inst::adjust_scalar_to_1d_layout(layouts_true[i], layouts_false[i])); + } } else { - return resolve_shape(layouts_false, layouts_true); + for (size_t i = 0; i < num_outputs; i++) { + output_layouts.push_back(condition_inst::adjust_scalar_to_1d_layout(layouts_false[i], layouts_true[i])); + } } + return output_layouts; } } diff --git a/src/plugins/intel_gpu/src/graph/crop.cpp b/src/plugins/intel_gpu/src/graph/crop.cpp index 99d738258824f0..b7d81cc5ba8bc8 100644 --- a/src/plugins/intel_gpu/src/graph/crop.cpp +++ b/src/plugins/intel_gpu/src/graph/crop.cpp @@ -69,6 +69,7 @@ std::vector crop_inst::calc_output_layouts(const crop_node& /*node*/, co const_data.emplace(2, make_tensor(split_length_mem->get_layout(), split_length_mem_lock.data())); ov::op::v1::VariadicSplit op; + op.set_friendly_name(desc->id); output_shapes = shape_infer(&op, input_shapes, ov::make_tensor_accessor(const_data)); } else { auto input0_layout = impl_param.get_input_layout(0); @@ -84,6 +85,7 @@ std::vector crop_inst::calc_output_layouts(const crop_node& /*node*/, co const_data.emplace(1, make_tensor(axis_values_mem->get_layout(), axis_values_mem_lock.data())); ov::op::v1::Split op; + op.set_friendly_name(desc->id); op.set_num_splits(desc->num_splits); output_shapes = shape_infer(&op, input_shapes, ov::make_tensor_accessor(const_data)); } else if (desc->op_mode == cldnn::crop_ngraph_op_mode::none) { diff --git a/src/plugins/intel_gpu/src/graph/fully_connected.cpp b/src/plugins/intel_gpu/src/graph/fully_connected.cpp index 4d65e5223e27dd..3650fb4d0c4f89 100644 --- a/src/plugins/intel_gpu/src/graph/fully_connected.cpp +++ b/src/plugins/intel_gpu/src/graph/fully_connected.cpp @@ -167,7 +167,6 @@ std::vector fully_connected_inst::calc_output_layouts(fully_connected_no return { layout{output_shapes[0], output_type, output_format} }; } - kernel_impl_params fully_connected_inst::get_fake_aligned_params(kernel_impl_params const& orig_impl_param) { // fc_tiled_opt kernel is optimized for row shape aligned by 8. // Thus, use fake aligned shape at kernel execution for better performance. @@ -175,21 +174,46 @@ kernel_impl_params fully_connected_inst::get_fake_aligned_params(kernel_impl_par auto orig_output_layout = orig_impl_param.get_output_layout(); OPENVINO_ASSERT(orig_input_layout.is_static() && orig_output_layout.is_static(), "in/out layouts should be static for fake alignment!"); - if (orig_input_layout.format == format::bfyx && orig_output_layout.format == format::bfyx) { + + auto input_shape = orig_input_layout.get_partial_shape().to_shape(); + auto output_shape = orig_output_layout.get_partial_shape().to_shape(); + + // Allow padding only for feature and outermost dimmension + auto can_apply_fake_alignment = true; + if (input_shape.size() == 3) + can_apply_fake_alignment &= orig_input_layout.data_padding.lower_size().sizes()[1] == 0 && + orig_input_layout.data_padding.upper_size().sizes()[1] == 0; + + if (output_shape.size() == 3) + can_apply_fake_alignment &= orig_output_layout.data_padding.lower_size().sizes()[1] == 0 && + orig_output_layout.data_padding.upper_size().sizes()[1] == 0; + + if (orig_input_layout.format == format::bfyx && orig_output_layout.format == format::bfyx && can_apply_fake_alignment) { auto updated_param = orig_impl_param; - auto input_shape = orig_input_layout.get_partial_shape().to_shape(); - auto input_row_idx = input_shape.size() - 2; - auto output_shape = orig_output_layout.get_partial_shape().to_shape(); - auto output_row_idx = output_shape.size() - 2; + + auto batch_size = std::accumulate(input_shape.begin(), + input_shape.end() - 1, + size_t{1}, + std::multiplies()); // Vector by matrix multiplication sometimes works slower if we align it - if (input_shape[input_row_idx] == 1 && output_shape[output_row_idx] == 1 && input_shape[input_shape.size() - 1] >= 1024) { + if (batch_size == 1 && input_shape.back() >= 1024) { return std::move(orig_impl_param); } - size_t fake_align_base = (orig_impl_param.dev_type == cldnn::device_type::integrated_gpu) ? 16 : 8; - input_shape[input_row_idx] = align_to(input_shape[input_row_idx], fake_align_base); - output_shape[output_row_idx] = align_to(output_shape[output_row_idx], fake_align_base); + size_t fake_align_base = 8; + if (orig_impl_param.dev_type == cldnn::device_type::integrated_gpu) { + auto weights_layout_dt = orig_impl_param.weights_layout.value().data_type; + auto is_4bit = weights_layout_dt == data_types::i4 || weights_layout_dt == data_types::u4; + auto is_extra_alignment_needed = batch_size >= 256; + fake_align_base = is_4bit && is_extra_alignment_needed ? 64 : 16; + } + + std::fill(input_shape.begin(), input_shape.end() - 1, 1); + std::fill(output_shape.begin(), output_shape.end() - 1, 1); + + input_shape[0] = align_to(batch_size, fake_align_base); + output_shape[0] = align_to(batch_size, fake_align_base); updated_param.input_layouts[0] = layout(ov::PartialShape(input_shape), orig_input_layout.data_type, 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 b9a88e01c4a9e3..d223c2cd55075f 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 @@ -470,6 +470,8 @@ void prepare_primitive_fusing::fuse_bias(program &p) { fc_with_bias_prim->compressed_weights = true; fc_with_bias_prim->decompression_scale = desc->decompression_scale; fc_with_bias_prim->decompression_zero_point = desc->decompression_zero_point; + if (desc->decompression_zero_point_scalar.has_value()) + fc_with_bias_prim->decompression_zero_point_scalar = desc->decompression_zero_point_scalar.value(); } auto& new_fc_node = p.get_or_create(fc_with_bias_prim); fuse_bias_f(fc, new_fc_node, bias_node, eltw_node); diff --git a/src/plugins/intel_gpu/src/graph/graph_optimizer/prepare_primitive_fusing_through.cpp b/src/plugins/intel_gpu/src/graph/graph_optimizer/prepare_primitive_fusing_through.cpp index 899369aa5c7077..64895c4b6f2814 100644 --- a/src/plugins/intel_gpu/src/graph/graph_optimizer/prepare_primitive_fusing_through.cpp +++ b/src/plugins/intel_gpu/src/graph/graph_optimizer/prepare_primitive_fusing_through.cpp @@ -131,6 +131,14 @@ void prepare_primitive_fusing_through::run(program& p) { auto new_prev = fuse_through_order[fuse_through_order.size() - 1]; auto new_next = fuse_through_order[fuse_through_order.size() - 2]; + // Check broadcastable for fused eltwise's output + if (node->is_type()) { + auto out_shape = new_prev->get_output_layout().get_partial_shape(); // new_prev's layout became node's new layout after fusing + auto in_shape = node->get_dependency(1).get_output_layout().get_partial_shape(); + if (!broadcastable(in_shape, out_shape, true, true)) + continue; + } + if (new_prev->is_type() || new_prev->is_type() || new_prev->is_type()) diff --git a/src/plugins/intel_gpu/src/graph/impls/common/condition.cpp b/src/plugins/intel_gpu/src/graph/impls/common/condition.cpp index 14a904c6297fb0..48a4e89a03fe1f 100644 --- a/src/plugins/intel_gpu/src/graph/impls/common/condition.cpp +++ b/src/plugins/intel_gpu/src/graph/impls/common/condition.cpp @@ -79,7 +79,8 @@ struct condition_impl : typed_primitive_impl { << ", external: " << input_external_node->first << ")" << std::endl; for (size_t dep_idx = 0; dep_idx < instance.dependencies().size(); ++dep_idx) { if (instance.dependencies()[dep_idx].first->id() == input_external_node->first) { - output_events.push_back(events[dep_idx]); + if (events.size() > dep_idx) + output_events.push_back(events[dep_idx]); output_mem_ptr = instance.input_memory_ptr(dep_idx); output_layout = instance.dependencies()[dep_idx].first->get_output_layout(); break; @@ -87,6 +88,14 @@ struct condition_impl : typed_primitive_impl { } } } + + if (output_layout.get_partial_shape().rank().get_length() == 0) { + auto other_branch = !pred ? instance.get_branch_true() : instance.get_branch_false(); + auto other_layout = other_branch.inner_program->get_outputs()[out_idx]->get_output_layout(); + output_layout = condition_inst::adjust_scalar_to_1d_layout(output_layout, other_layout); + output_mem_ptr = instance.get_network().get_engine().reinterpret_buffer(*output_mem_ptr, output_layout); + GPU_DEBUG_LOG << " output layout is updated to " << output_layout.to_short_string() << std::endl; + } GPU_DEBUG_LOG << " set output layout : " << output_layout.to_short_string() << std::endl; instance.set_output_layout(output_layout, out_idx); instance.set_output_memory(output_mem_ptr, out_idx); @@ -100,18 +109,25 @@ struct condition_impl : typed_primitive_impl { if (iter != branch.input_map.end()) { const primitive_id& input_internal_id = iter->second; auto mem_ptr = instance.input_memory_ptr(mem_idx); + auto dep = instance.dependencies()[mem_idx]; + auto layout = dep.first->get_impl_params()->get_output_layout(dep.second); if (mem_ptr) { - auto dep = instance.dependencies()[mem_idx]; - auto layout = dep.first->get_impl_params()->get_output_layout(dep.second); GPU_DEBUG_LOG << "Reshape input from " << mem_ptr->get_layout().to_short_string() << " to " << layout.to_short_string() << std::endl; // Preallocation logic may allocate more memory than actually produced on current iteration, so // we need to adjust input buffers layout mem_ptr = instance.get_network().get_engine().reinterpret_buffer(*mem_ptr, layout); + } else if (layout.count() == 0) { + // Use dummy memory for empty tensor + mem_ptr = std::make_shared(layout, nullptr); } + OPENVINO_ASSERT(mem_ptr != nullptr, "[GPU] Can't assign nullptr memory buffer for condition primitive with id=", instance.id(), " (" + "mem_idx=", mem_idx, ", " + "external_id=", input_external_id, ", " + "internal_id=", input_internal_id, ")"); executed_net->set_input_data(input_internal_id, mem_ptr); - GPU_DEBUG_LOG << "Inner net - Inputs[" << mem_idx << "]" << mem_ptr->get_layout().to_short_string() - << std::endl; + GPU_DEBUG_LOG << "Inner net - Inputs[" << mem_idx << "]: layout=" << mem_ptr->get_layout().to_short_string() << ", " + << "allocation_type=" << mem_ptr->get_allocation_type() << std::endl; } } } diff --git a/src/plugins/intel_gpu/src/graph/impls/ocl/kernel_selector_helper.h b/src/plugins/intel_gpu/src/graph/impls/ocl/kernel_selector_helper.h index 6d72f3c2c00c7a..e4bfd599f8bc16 100644 --- a/src/plugins/intel_gpu/src/graph/impls/ocl/kernel_selector_helper.h +++ b/src/plugins/intel_gpu/src/graph/impls/ocl/kernel_selector_helper.h @@ -236,17 +236,24 @@ inline ov::PartialShape extend_shape_to_rank_from_begin(ov::PartialShape pshape, return extended_pshape; } -inline bool broadcastable(const ov::PartialShape& first_pshape, const ov::PartialShape& second_pshape, bool use_new_shape_infer) { +inline bool broadcastable(const ov::PartialShape& first_pshape, const ov::PartialShape& second_pshape, bool use_new_shape_infer, + bool first_to_second_only = false) { if (first_pshape.is_dynamic() || second_pshape.is_dynamic()) { return false; } - if (first_pshape.size() != second_pshape.size() && use_new_shape_infer) { - return false; + if (first_to_second_only) { + if (first_pshape.size() > second_pshape.size()) { + return false; + } + } else { + if (first_pshape.size() != second_pshape.size() && use_new_shape_infer) { + return false; + } } size_t min_size = std::min(first_pshape.size(), second_pshape.size()); for (size_t i = 0; i < min_size; ++i) { - if (!(first_pshape[i] == 1 || second_pshape[i] == 1 || first_pshape[i] == second_pshape[i])) { + if (!(first_pshape[i] == 1 || (!first_to_second_only && second_pshape[i] == 1) || first_pshape[i] == second_pshape[i])) { return false; } } 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 98d65e63ab9f4c..d314128ad38115 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 @@ -143,6 +143,8 @@ struct typed_primitive_impl_ocl : public typed_primitive_impl { // batch program hash and kernel entry point to find corresponding cl source code kernel_dump_info = std::make_pair(std::to_string(kernels_cache.get_kernel_batch_hash(params)), _kernel_data.kernels[0].code.kernelString->entry_point); + for (size_t i = 1; i < _kernel_data.kernels.size(); ++i) + kernel_dump_info.second += " " + _kernel_data.kernels[i].code.kernelString->entry_point; } } diff --git a/src/plugins/intel_gpu/src/graph/include/condition_inst.h b/src/plugins/intel_gpu/src/graph/include/condition_inst.h index 65b56202a9a311..c07d5277f463b4 100644 --- a/src/plugins/intel_gpu/src/graph/include/condition_inst.h +++ b/src/plugins/intel_gpu/src/graph/include/condition_inst.h @@ -81,6 +81,8 @@ class typed_primitive_inst : public typed_primitive_inst_base : public typed_primitive_inst_base { // num_iteration is used for slicing input memory int64_t get_num_iterations(); - void update_backedge_exec_deps(const cldnn::program_node& node, const cldnn::primitive_id& backedge_from_prim_id); - std::vector preprocess_memory_for_body_network(int64_t current_iteration_idx); std::vector postprocess_memory_for_body_network(int64_t current_iteration_idx); diff --git a/src/plugins/intel_gpu/src/graph/input_layout.cpp b/src/plugins/intel_gpu/src/graph/input_layout.cpp index 07b26b9323c084..cf9383406e3a8a 100644 --- a/src/plugins/intel_gpu/src/graph/input_layout.cpp +++ b/src/plugins/intel_gpu/src/graph/input_layout.cpp @@ -43,7 +43,8 @@ event::ptr input_layout_inst::set_data(memory::ptr mem) { auto& engine = get_network().get_engine(); auto& stream = get_network().get_stream(); - if (mem->is_allocated_by(engine)) { + // Allow to set dummy simple_attached_memory empty tensor as network input + if (mem->is_allocated_by(engine) || mem->get_layout().count() == 0) { OPENVINO_ASSERT(!_outputs.empty(), "[GPU] Can't set data for empty input memory"); _outputs[0] = mem; ev = stream.create_user_event(true); diff --git a/src/plugins/intel_gpu/src/graph/loop.cpp b/src/plugins/intel_gpu/src/graph/loop.cpp index d24c69e8edabb7..ae13b8a08c2de5 100644 --- a/src/plugins/intel_gpu/src/graph/loop.cpp +++ b/src/plugins/intel_gpu/src/graph/loop.cpp @@ -481,7 +481,23 @@ void loop_inst::preprocess_input_memory(const int64_t num_iterations) { << input_inst->get_output_layout().to_short_string() << " to " << memory->get_layout().to_short_string() << std::endl; } - body_network->set_input_data(internal_id.pid, memory); + + auto internal_input_memory = memory; + auto iter = std::find_if(_back_edges.begin(), _back_edges.end(), [&](cldnn::loop::backedge_mapping& mapping) { + return (mapping.to == internal_id.pid); + }); + // if internal input memory is in backedge, allocate new memory. + // Because internal input memory's data will be updated through backedge process. + if (iter != _back_edges.end()) { + internal_input_memory = body_network->get_engine().allocate_memory(memory->get_layout(), false); + internal_input_memory->copy_from(body_network->get_stream(), *memory); + GPU_DEBUG_LOG << "Input memory of internal node(" << internal_id.to_string() << ") is set to new memory(" + << internal_input_memory << ", " << internal_input_memory->get_layout().to_short_string() + << ") instead of external node(" << external_id.to_string() + <<")'s memory(" << memory << "," << memory->get_layout().to_short_string() << ")" << std::endl; + } + + body_network->set_input_data(internal_id.pid, internal_input_memory); } else { OPENVINO_ASSERT(memory != nullptr, "In preprocessing concat input mapping, concat memory should be allocated"); auto memory_mapping_info = create_concat_memory_map(*input_map, memory, num_iterations); @@ -519,7 +535,9 @@ void loop_inst::preprocess_backedge_memory() { backedge_from_prim, backedge_to_prim, backedged_sliced_output, initial_mem, body_network->get_stream()); GPU_DEBUG_LOG << idx << ") add back_edge mapping with CONCAT_OUTPUT type, backedged_sliced_output(" << backedged_sliced_output << "), initial_mem(" << initial_mem << ")" << std::endl; - } else if (output_mapping.empty() && backedge_to_prim == backedge_from_prim->dependencies().front().first) { + // Set backedge mode to SINGLE when backedge_from_prim has multiple users. + } else if ((output_mapping.empty() && backedge_to_prim == backedge_from_prim->dependencies().front().first) + || (backedge_to_prim->get_users().size() > 1) ) { // SINGLE mode, from and to primitives in backedge are connected directly backedge_memory_mappings.emplace_back( backedge_from_prim, backedge_to_prim, initial_mem, body_network->get_stream()); @@ -573,35 +591,6 @@ void loop_inst::preprocess_backedge_memory() { GPU_DEBUG_LOG << idx << ") add back_edge mapping with SINGLE_SHARED type, backedge_mem(" << backedge_mem << "), initial_mem(" << initial_mem << ")" << std::endl; } - - if (backedge_to_prim->_node != nullptr) { - update_backedge_exec_deps(backedge_to_prim->get_node(), backedge_from_prim->id()); - } - } -} - -void loop_inst::update_backedge_exec_deps(const cldnn::program_node& node, const cldnn::primitive_id& backedge_from_prim_id) { - // Add _exec_deps for backedge primitives to prevent early execution in body network - // In below topology, input and result has shared memory as they are backedge_to/from. - // When op2 executes earlier thant op1, input is updated with op2 result and op1 has wrong input value if there is no proper _exec_deps. - // input(backedge_to) ------> op1 -----> - // | - // L-----> op2 -----> result (backedge_from) - for (auto& user : node.get_users()) { - if (user->can_be_optimized()) { - // Run until non opt out user - update_backedge_exec_deps(*user, backedge_from_prim_id); - } else { - auto user_primitive_id = user->get_primitive()->id; - auto user_primitive = body_network->get_primitive(user_primitive_id); - - const auto backedge_from_prim = body_network->get_primitive(backedge_from_prim_id); - if (std::find(backedge_from_prim->_exec_deps.begin(), backedge_from_prim->_exec_deps.end(), user_primitive) - != backedge_from_prim->_exec_deps.end()) { - backedge_from_prim->_exec_dep_ids.push_back(user_primitive_id); - backedge_from_prim->_exec_deps.push_back(user_primitive); - } - } } } @@ -1005,6 +994,8 @@ std::vector loop_inst::handle_buffers_for_next_iteration(const loop_ if (mapping.type == loop_inst::backedge_memory_mapping::CONCAT_OUTPUT) { if (iter == 0) { set_memory_in_body_network(body_network, mapping.to_primitive, mapping.initial_mem); + GPU_DEBUG_LOG << iter << ") [CONCAT_OUTPUT] Copy data from inintal_mem(" << mapping.initial_mem + << ") to " << mapping.to_primitive->id() << std::endl; } else if (iter > 0) { if (is_dynamic()) { auto from_id = mapping.from_primitive->id(); @@ -1017,9 +1008,13 @@ std::vector loop_inst::handle_buffers_for_next_iteration(const loop_ memory::ptr from_mem = mapping.from_primitive->output_memory_ptr(); auto ev = to_mem->copy_from(body_network->get_stream(), *(from_mem)); if (ev) event_vec = {ev}; + GPU_DEBUG_LOG << iter << ") [CONCAT_OUTPUT] Copy data from [" << mapping.from_primitive->id() << "(" << from_mem + << ")] to [" << mapping.to_primitive->id() << "(" << to_mem << ")]" << std::endl; } else { auto mem = mapping.concat_mem_mapping->get_sliced_mems().at(iter - 1); set_memory_in_body_network(body_network, mapping.to_primitive, mem); + GPU_DEBUG_LOG << iter << ") [CONCAT_OUTPUT] Set memory from concat_mem[" << (iter - 1) << "](" << mem + << ") to " << mapping.to_primitive->id() << ")" << std::endl; } } } else if (mapping.type == loop_inst::backedge_memory_mapping::SINGLE_SHARED) { @@ -1027,7 +1022,7 @@ std::vector loop_inst::handle_buffers_for_next_iteration(const loop_ if (mapping.from_mem != nullptr) { auto ev = mapping.from_mem->copy_from(body_network->get_stream(), *(mapping.initial_mem)); if (ev) event_vec = {ev}; - GPU_DEBUG_LOG << iter << ") Copy data from inintal_mem(" << mapping.initial_mem << ")" << std::endl; + GPU_DEBUG_LOG << iter << ") [SINGLE_SHARED] Copy data from inintal_mem(" << mapping.initial_mem << ")" << std::endl; } } else { // In dynamic model, output memory is not defined before execution. @@ -1036,7 +1031,8 @@ std::vector loop_inst::handle_buffers_for_next_iteration(const loop_ mapping.from_mem = mapping.from_primitive->output_memory_ptr(); OPENVINO_ASSERT(mapping.from_mem != nullptr, "from_mem should not be null"); set_memory_in_body_network(body_network, mapping.to_primitive, mapping.from_mem); - GPU_DEBUG_LOG << iter << ") Set memory from from_mem(" << mapping.from_mem << ") to " << mapping.to_primitive->id() << ")" << std::endl; + GPU_DEBUG_LOG << iter << ") [SINGLE_SHARED] Set memory from from_mem(" << mapping.from_mem + << ") to " << mapping.to_primitive->id() << ")" << std::endl; } } } else if (mapping.type == loop_inst::backedge_memory_mapping::SINGLE) { @@ -1044,9 +1040,10 @@ std::vector loop_inst::handle_buffers_for_next_iteration(const loop_ if (iter == 0) { auto ev = to_mem->copy_from(body_network->get_stream(), *(mapping.initial_mem)); if (ev) event_vec = {ev}; + GPU_DEBUG_LOG << iter << ") [SINGLE] Copy data from inintal_mem(" << mapping.initial_mem << ")" << std::endl; } else { if (is_dynamic()) { - // In dynamic model, do not set memory buffer between input and output in inner body network. + // In dynamic model, do not swap memory buffer between input and output in inner body network. // Just copy data from input buffer memory to output buffer memory. auto from_id = mapping.from_primitive->id(); if (body_network->has_event(from_id)) { @@ -1056,11 +1053,19 @@ std::vector loop_inst::handle_buffers_for_next_iteration(const loop_ memory::ptr from_mem = mapping.from_primitive->output_memory_ptr(); auto ev = to_mem->copy_from(body_network->get_stream(), *(from_mem)); if (ev) event_vec = {ev}; + GPU_DEBUG_LOG << iter << ") [SINGLE] Copy data from [" << mapping.from_primitive->id() + << "(" << from_mem << ")] to [" << mapping.to_primitive->id() << "(" << to_mem << ")]" << std::endl; } else { // In static model, swap memory buffer between output and input in inner body network memory::ptr from_mem = mapping.from_primitive->output_memory_ptr(); + GPU_DEBUG_LOG << iter << ") [SINGLE] Before swap between [" << mapping.from_primitive->id() + << "(" << mapping.from_primitive->output_memory_ptr() << ")] and [" << mapping.to_primitive->id() + << "(" << mapping.to_primitive->output_memory_ptr() << ")]" << std::endl; set_memory_in_body_network(body_network, mapping.to_primitive, std::move(from_mem)); set_memory_in_body_network(body_network, mapping.from_primitive, std::move(to_mem)); + GPU_DEBUG_LOG << iter << ") [SINGLE] After swap between [" << mapping.from_primitive->id() + << "(" << mapping.from_primitive->output_memory_ptr() << ")] and [" << mapping.to_primitive->id() + << "(" << mapping.to_primitive->output_memory_ptr() << ")]" << std::endl; } } } diff --git a/src/plugins/intel_gpu/src/graph/primitive_inst.cpp b/src/plugins/intel_gpu/src/graph/primitive_inst.cpp index 3f83e740a8eaed..8c3b430e3efe28 100644 --- a/src/plugins/intel_gpu/src/graph/primitive_inst.cpp +++ b/src/plugins/intel_gpu/src/graph/primitive_inst.cpp @@ -451,7 +451,26 @@ event::ptr primitive_inst::realloc_if_needed() { variable.set_layout(actual_layout); } - bool can_reuse_buffer = _outputs[0] && actual_layout.count() <= max_output_layout_size; + // Update output layout with respect to FC's fake alignment + auto updated_layout = actual_layout; + for (auto user : get_user_insts()) { + // Since fake alignment is applicable for input tensor as well, make sure we allocate enough memory + // to prevemt reading beyound the allocated memory bounds + if (user->get_node().is_type()) { + user->update_shape(); + user->update_shape_done_by_other = true; + + auto fc_impl_params = *user->_impl_params; + auto fc_input_layout = user->get_node().type()->get_fake_aligned_params(fc_impl_params).input_layouts[0]; + if (fc_input_layout.bytes_count() > updated_layout.bytes_count()) { + GPU_DEBUG_TRACE_DETAIL << id() << ": increase output layout allocation size from " << actual_layout.to_short_string() << " -> " + << fc_input_layout.to_short_string() << " to meet the input buffer alignment requirements for FC\n"; + updated_layout = fc_input_layout; + } + } + } + + bool can_reuse_buffer = _outputs[0] && updated_layout.count() <= max_output_layout_size; // Handle runtime dynamic concat optimization if (_node->is_type() && can_be_optimized() && allocation_done_by_other) { @@ -469,6 +488,9 @@ event::ptr primitive_inst::realloc_if_needed() { updated_params.output_layouts[0] = new_layout; } + if (updated_params.output_layouts[0].count() < updated_layout.count()) + updated_params.output_layouts[0] = updated_layout; + if (can_reuse_buffer) { GPU_DEBUG_TRACE_DETAIL << id() << ": reuse previously allocated output buffer" << std::endl; if (_outputs[0]->get_layout() != actual_layout) { diff --git a/src/plugins/intel_gpu/src/graph/strided_slice.cpp b/src/plugins/intel_gpu/src/graph/strided_slice.cpp index 9dd37819170ac0..a922a4d33788ff 100644 --- a/src/plugins/intel_gpu/src/graph/strided_slice.cpp +++ b/src/plugins/intel_gpu/src/graph/strided_slice.cpp @@ -73,6 +73,7 @@ std::vector strided_slice_inst::calc_output_layouts(strided_slice_node c strides_shape }; + op.set_friendly_name(desc->id); op.set_begin_mask(desc->begin_mask); op.set_end_mask(desc->end_mask); op.set_new_axis_mask(desc->new_axis_mask); 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 633fab52febf1c..e4f1b105b85c67 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 @@ -61,6 +61,10 @@ #define BIAS_BLOCK_READ(ptr, offset) BLOCK_READN(BIAS_TYPE, TILE_OFM, ptr, offset) #define OUTPUT_BLOCK_WRITE(ptr, offset, val) BLOCK_WRITEN(OUTPUT_TYPE, TILE_OFM, ptr, offset, val) +#define SLM_FILTER_VEC MAKE_VECTOR_TYPE(ACCUMULATOR_TYPE, TILE_OFM) +#define SLM_FILTER_PACKED_VEC MAKE_VECTOR_TYPE(FILTER_TYPE, FILTER_LOAD_BLOCK_SIZE) +#define SLM_FILTER_UNPACKED_VEC MAKE_VECTOR_TYPE(ACCUMULATOR_TYPE, FILTER_ELEMENTS_PER_LOAD) + // Check alignment restrictions for using block writes on output. #define USE_BLOCK_WRITE ((OUTPUT_TYPE_SIZE * TILE_OUT_B_PITCH) % 16 == 0 && (OUTPUT_TYPE_SIZE * OUTPUT_OFFSET) % 16 == 0) @@ -309,7 +313,7 @@ inline void FUNC(fc_bf_tiled_kernel_tile_b1)( uint offset_ofm = out_f + fi*SIMD + get_sub_group_local_id(); #if DECOMPRESSION_SCALE_GROUPS_NUM > 1 const uint scale_offset = (offset_ofm % DECOMPRESSION_SCALE_BATCH_NUM) * DECOMPRESSION_SCALE_BATCH_PITCH + - ((kii + ki*TILE_K + ni*TILE_IFM*SIMD) / DECOMPRESSION_SCALE_GROUP_SIZE)*DECOMPRESSION_SCALE_FEATURE_PITCH; + ((kii + ki*TILE_K + iterations*TILE_IFM*SIMD) / DECOMPRESSION_SCALE_GROUP_SIZE)*DECOMPRESSION_SCALE_FEATURE_PITCH; ACCUMULATOR_TYPE ds = decompression_scale[scale_offset]; #else ACCUMULATOR_TYPE ds = d_scales[fi % DECOMPRESSION_SCALE_LENGTH]; @@ -320,7 +324,7 @@ inline void FUNC(fc_bf_tiled_kernel_tile_b1)( ACCUMULATOR_TYPE dzp = DECOMPRESSION_ZP_VALUE; #elif DECOMPRESSION_ZP_GROUPS_NUM > 1 const uint zp_offset = (offset_ofm % DECOMPRESSION_ZP_BATCH_NUM) * DECOMPRESSION_ZP_BATCH_PITCH + - ((kii + ki*TILE_K + ni*TILE_IFM*SIMD) / DECOMPRESSION_ZP_GROUP_SIZE) * DECOMPRESSION_ZP_FEATURE_PITCH; + ((kii + ki*TILE_K + iterations*TILE_IFM*SIMD) / DECOMPRESSION_ZP_GROUP_SIZE) * DECOMPRESSION_ZP_FEATURE_PITCH; ACCUMULATOR_TYPE dzp = decompression_zp[zp_offset]; #else ACCUMULATOR_TYPE dzp = d_zps[fi % DECOMPRESSION_ZP_LENGTH]; @@ -462,6 +466,9 @@ inline void FUNC(fc_bf_tiled_kernel_default)( #endif __global OUTPUT_TYPE* output, const __global FILTER_TYPE* weights +#if USE_SLM + , __local ACCUMULATOR_TYPE* wei_local_mem +#endif #if BIAS_TERM , const __global BIAS_TYPE* biases #endif @@ -469,7 +476,12 @@ inline void FUNC(fc_bf_tiled_kernel_default)( , FUSED_OPS_DECLS #endif ) { +#if USE_SLM + uint gid = (uint)get_group_id(0); + uint local_id = (uint)get_local_id(2); +#else uint gid = (uint)get_group_id(0); +#endif uint sglid = (uint)get_sub_group_local_id(); // Dispatch as bs_fs_bsv_fsv, where bsv = DISPATCH_BSV and fsv = DISPATCH_FSV. @@ -482,13 +494,21 @@ inline void FUNC(fc_bf_tiled_kernel_default)( uint feature_mega_block = gid / (DISPATCH_FSV * DISPATCH_BSV) % (CEIL_DIV(TILE_OUT_F_NUM, TILE_OFM * SIMD) / DISPATCH_FSV); uint batch_mega_block = gid / (DISPATCH_FSV * DISPATCH_BSV * CEIL_DIV(TILE_OUT_F_NUM, TILE_OFM * SIMD) / DISPATCH_FSV); +#if USE_SLM + uint out_f = gid * (TILE_OFM * SIMD); + uint out_b = LWS_BATCHES * TILE_B * (uint)get_group_id(2) + local_id * TILE_B; +#else uint out_f = (feature_mega_block * DISPATCH_FSV + feature_mini_block) * (TILE_OFM * SIMD); uint out_b = ((batch_mega_block * DISPATCH_BSV + batch_mini_block) * TILE_B); +#endif ACCUMULATOR_VEC_TYPE acc[TILE_B] = { }; INPUT_VEC_TYPE in_0[TILE_B] = { }; +#if !USE_SLM FILTER_VEC_TYPE wei = 0; +#endif + uint input_offset = out_b * TILE_IN_B_PITCH + INPUT0_OFFSET; #if COMPRESSED_WEIGHTS_INT4 uint weights_offset = out_f * (INPUT_ELEMENTS_COUNT / 2); @@ -567,15 +587,121 @@ inline void FUNC(fc_bf_tiled_kernel_default)( ACCUMULATOR_VEC_TYPE acc_tmp[TILE_B] = { }; #endif + #if USE_SLM && COMPRESSED_WEIGHTS_INT4 + #if TILE_OFM != 2 + #error "FC bf_tiled kernel: can't use SLM optimization with TILE_OFM != 2" + #endif + + // Skip first barrier synchronization if there is only single outer loop iteration. + #if MAIN_LOOP_ELEMENTS_COUNT / (TILE_IFM * SIMD) > 1 + barrier(CLK_LOCAL_MEM_FENCE); + #endif + + __local SLM_FILTER_VEC* slm_wei_vec = (__local SLM_FILTER_VEC*)wei_local_mem; + + uint weights_idx = weights_offset + local_id * SIMD * FILTER_LOAD_ITERS * FILTER_LOAD_BLOCK_SIZE; + uint wei_local_idx = local_id * SIMD * FILTER_LOAD_ITERS * FILTER_LOAD_BLOCK_SIZE + sglid; + + unroll_for(uint load_iter = 0; load_iter < FILTER_LOAD_ITERS; ++load_iter) { + SLM_FILTER_PACKED_VEC wei_packed = BLOCK_READN(FILTER_TYPE, FILTER_LOAD_BLOCK_SIZE, weights, weights_idx); + SLM_FILTER_UNPACKED_VEC wei_unpacked = UNPACK_INT4x2(ACCUMULATOR_TYPE, *((INT4_PACKED_TYPE_PRELOAD*)&wei_packed)); + + ACCUMULATOR_TYPE* w = (ACCUMULATOR_TYPE*)(&wei_unpacked); + unroll_for(uint fi = 0; fi < TILE_OFM; ++fi) { + unroll_for(uint kii = 0; kii < FILTER_LOAD_BLOCK_SIZE; ++kii) { + const uint w_idx = kii * TILE_OFM + fi; + const uint offset_ofm = out_f + fi*SIMD + sglid; + const uint offset_ifm = ni * TILE_IFM * SIMD + local_id * FILTER_LOAD_ITERS * FILTER_LOAD_BLOCK_SIZE + load_iter * FILTER_LOAD_BLOCK_SIZE + kii; + #if !DECOMPRESSION_SCALE_POST_OP + #if DECOMPRESSION_SCALE_GROUPS_NUM > 1 + const uint scale_offset = (offset_ofm % DECOMPRESSION_SCALE_BATCH_NUM) * DECOMPRESSION_SCALE_BATCH_PITCH + + (offset_ifm / DECOMPRESSION_SCALE_GROUP_SIZE) * DECOMPRESSION_SCALE_FEATURE_PITCH; + ACCUMULATOR_TYPE ds = decompression_scale[scale_offset]; + #else + ACCUMULATOR_TYPE ds = d_scales[fi % DECOMPRESSION_SCALE_LENGTH]; + #endif + #else + ACCUMULATOR_TYPE ds = ACCUMULATOR_VAL_ONE; + #endif + + #if DECOMPRESSION_ZP_TERM + #if DECOMPRESSION_ZP_SCALAR + ACCUMULATOR_TYPE dzp = DECOMPRESSION_ZP_VALUE; + #elif DECOMPRESSION_ZP_GROUPS_NUM > 1 + const uint zp_offset = (offset_ofm % DECOMPRESSION_ZP_BATCH_NUM) * DECOMPRESSION_ZP_BATCH_PITCH + + (offset_ifm / DECOMPRESSION_ZP_GROUP_SIZE) * DECOMPRESSION_ZP_FEATURE_PITCH; + ACCUMULATOR_TYPE dzp = decompression_zp[zp_offset]; + #else + ACCUMULATOR_TYPE dzp = d_zps[fi % DECOMPRESSION_ZP_LENGTH]; + #endif + #else + ACCUMULATOR_TYPE dzp = ACCUMULATOR_VAL_ZERO; + #endif + w[w_idx] = (w[w_idx] - dzp) * ds; + } + } + + #define STORE_TO_SLM(vec2) slm_wei_vec[wei_local_idx] = vec2; wei_local_idx += SIMD; + + #if FILTER_LOAD_BLOCK_SIZE == 2 + STORE_TO_SLM(wei_unpacked.s01); + STORE_TO_SLM(wei_unpacked.s23); + #elif FILTER_LOAD_BLOCK_SIZE == 4 + STORE_TO_SLM(wei_unpacked.s01); + STORE_TO_SLM(wei_unpacked.s23); + STORE_TO_SLM(wei_unpacked.s45); + STORE_TO_SLM(wei_unpacked.s67); + #elif FILTER_LOAD_BLOCK_SIZE == 8 + STORE_TO_SLM(wei_unpacked.s01); + STORE_TO_SLM(wei_unpacked.s23); + STORE_TO_SLM(wei_unpacked.s45); + STORE_TO_SLM(wei_unpacked.s67); + STORE_TO_SLM(wei_unpacked.s89); + STORE_TO_SLM(wei_unpacked.sab); + STORE_TO_SLM(wei_unpacked.scd); + STORE_TO_SLM(wei_unpacked.sef); + #else + #error "FC bf_tiled kernel: unsupported FILTER_LOAD_BLOCK_SIZE for SLM kernel" + #endif + + #undef STORE_TO_SLM + + weights_idx += SIMD * FILTER_LOAD_BLOCK_SIZE; + } + + wei_local_idx = sglid; + + barrier(CLK_LOCAL_MEM_FENCE); + #endif + unroll_for(uint ki = 0; ki < (TILE_IFM * SIMD) / TILE_K; ++ki) { #if COMPRESSED_WEIGHTS_INT4 - FILTER_PACKED_VEC_TYPE wei_packed = FILTER_BLOCK_READ(weights, weights_offset); - wei = UNPACK_INT4x2(ACCUMULATOR_TYPE, *((INT4_PACKED_TYPE*)&wei_packed)); + #if USE_SLM + FILTER_VEC_TYPE wei = 0; + #define LOAD_FROM_SLM(vec2) vec2 = slm_wei_vec[wei_local_idx]; wei_local_idx += SIMD; + #if TILE_K == 1 + LOAD_FROM_SLM(wei.s01); + #elif TILE_K == 2 + LOAD_FROM_SLM(wei.s01); + LOAD_FROM_SLM(wei.s23); + #elif TILE_K == 4 + LOAD_FROM_SLM(wei.s01); + LOAD_FROM_SLM(wei.s23); + LOAD_FROM_SLM(wei.s45); + LOAD_FROM_SLM(wei.s67); + #else + #error "FC bf_tiled kernel: unsupported TILE_K size for SLM kernel" + #endif + #undef LOAD_FROM_SLM + #else + FILTER_PACKED_VEC_TYPE wei_packed = FILTER_BLOCK_READ(weights, weights_offset); + wei = UNPACK_INT4x2(ACCUMULATOR_TYPE, *((INT4_PACKED_TYPE*)&wei_packed)); + #endif #else wei = TO_FILTER_VEC_TYPE(FILTER_BLOCK_READ(weights, weights_offset)); #endif - #if COMPRESSED_WEIGHTS + #if COMPRESSED_WEIGHTS && !USE_SLM ACCUMULATOR_TYPE* w = (ACCUMULATOR_TYPE*)(&wei); unroll_for(uint kii = 0; kii < TILE_K; ++kii) { unroll_for(uint fi = 0; fi < TILE_OFM; ++fi) { @@ -634,7 +760,7 @@ inline void FUNC(fc_bf_tiled_kernel_default)( #if DECOMPRESSION_SCALE_GROUPS_NUM > 1 const uint scale_offset = (offset_ofm % DECOMPRESSION_SCALE_BATCH_NUM) * DECOMPRESSION_SCALE_BATCH_PITCH + - ((ni*TILE_IFM*SIMD) / DECOMPRESSION_SCALE_GROUP_SIZE)*DECOMPRESSION_SCALE_FEATURE_PITCH; + ((ni*TILE_IFM*SIMD) / DECOMPRESSION_SCALE_GROUP_SIZE)*DECOMPRESSION_SCALE_FEATURE_PITCH; ACCUMULATOR_TYPE ds = decompression_scale[scale_offset]; #else ACCUMULATOR_TYPE ds = d_scales[fi % DECOMPRESSION_SCALE_LENGTH]; @@ -659,6 +785,10 @@ inline void FUNC(fc_bf_tiled_kernel_default)( #undef LOAD_IN_0 input_offset += TILE_IFM * SIMD - TILE_IN_B_PITCH * TILE_B; unroll_for(uint ki = 0; ki < CEIL_DIV(LEFTOVER_IFM, TILE_K); ++ki) { + #if USE_SLM + FILTER_VEC_TYPE wei = 0; + #endif + #if COMPRESSED_WEIGHTS_INT4 FILTER_PACKED_VEC_TYPE wei_packed = FILTER_BLOCK_READ(weights, weights_offset); wei = UNPACK_INT4x2(ACCUMULATOR_TYPE, *((INT4_PACKED_TYPE*)&wei_packed)); @@ -674,7 +804,7 @@ inline void FUNC(fc_bf_tiled_kernel_default)( uint offset_ofm = out_f + fi*SIMD + get_sub_group_local_id(); #if DECOMPRESSION_SCALE_GROUPS_NUM > 1 const uint scale_offset = (offset_ofm % DECOMPRESSION_SCALE_BATCH_NUM) * DECOMPRESSION_SCALE_BATCH_PITCH + - ((kii + ki*TILE_K + ni*TILE_IFM*SIMD) / DECOMPRESSION_SCALE_GROUP_SIZE)*DECOMPRESSION_SCALE_FEATURE_PITCH; + ((kii + ki*TILE_K + iterations*TILE_IFM*SIMD) / DECOMPRESSION_SCALE_GROUP_SIZE)*DECOMPRESSION_SCALE_FEATURE_PITCH; ACCUMULATOR_TYPE ds = decompression_scale[scale_offset]; #else ACCUMULATOR_TYPE ds = d_scales[fi % DECOMPRESSION_SCALE_LENGTH]; @@ -685,7 +815,7 @@ inline void FUNC(fc_bf_tiled_kernel_default)( ACCUMULATOR_TYPE dzp = DECOMPRESSION_ZP_VALUE; #elif DECOMPRESSION_ZP_GROUPS_NUM > 1 const uint zp_offset = (offset_ofm % DECOMPRESSION_ZP_BATCH_NUM) * DECOMPRESSION_ZP_BATCH_PITCH + - ((kii + ki*TILE_K + ni*TILE_IFM*SIMD) / DECOMPRESSION_ZP_GROUP_SIZE) * DECOMPRESSION_ZP_FEATURE_PITCH; + ((kii + ki*TILE_K + iterations*TILE_IFM*SIMD) / DECOMPRESSION_ZP_GROUP_SIZE) * DECOMPRESSION_ZP_FEATURE_PITCH; ACCUMULATOR_TYPE dzp = decompression_zp[zp_offset]; #else ACCUMULATOR_TYPE dzp = d_zps[fi % DECOMPRESSION_ZP_LENGTH]; @@ -834,6 +964,9 @@ KERNEL(fc)( , FUSED_OPS_DECLS #endif ) { +#if USE_SLM + __local ACCUMULATOR_TYPE wei_local_mem[TILE_IFM * SIMD * TILE_OFM * SIMD]; +#endif #if IS_DYNAMIC && COMPRESSED_WEIGHTS_INT4 if (BATCH_SIZE == 1) { FUNC_CALL(fc_bf_tiled_kernel_tile_b1)( @@ -866,6 +999,9 @@ KERNEL(fc)( #endif output, weights + #if USE_SLM + , wei_local_mem + #endif #if BIAS_TERM , biases #endif @@ -886,6 +1022,9 @@ KERNEL(fc)( #endif output, weights + #if USE_SLM + , wei_local_mem + #endif #if BIAS_TERM , biases #endif 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 f486667c34c3a6..fc946d9e4272bb 100644 --- a/src/plugins/intel_gpu/src/kernel_selector/common_types.h +++ b/src/plugins/intel_gpu/src/kernel_selector/common_types.h @@ -492,6 +492,8 @@ enum class ScatterUpdateAxis { Y, Z, W, + U, + V, FEATURE, BATCH, }; diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_base.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_base.cpp index b6f60d58ad45a4..e17cea44e05dfa 100644 --- a/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_base.cpp +++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_base.cpp @@ -55,7 +55,7 @@ JitConstants FullyConnectedKernelBase::GetJitConstants(const fully_connected_par } FullyConnectedKernelBase::DispatchData FullyConnectedKernelBase::SetDefault(const fully_connected_params& params, - int) const { + int, int /*kernel_number*/) const { DispatchData dispatchData; // Determine global work sizes. @@ -87,7 +87,8 @@ KernelsData FullyConnectedKernelBase::GetCommonKernelsData(const Params ¶ms, DataLayout dl, WeightsLayout wl, const std::string exeMode, - int autoTuneIndex) const { + int autoTuneIndex, + int kernel_number) const { if (!Validate(params, options)) { return KernelsData(); } @@ -121,9 +122,9 @@ KernelsData FullyConnectedKernelBase::GetCommonKernelsData(const Params ¶ms, kd.kernels.resize(1); - auto entry_point = GetEntryPoint(kernelName, orgParams.layerID, params, options); + auto entry_point = GetEntryPoint(kernelName, orgParams.layerID, params, options, kernel_number); - const DispatchData dispatchData = SetDefault(newParams, autoTuneIndex); + const DispatchData dispatchData = SetDefault(newParams, autoTuneIndex, kernel_number); auto cldnn_jit = GetJitConstants(newParams, dispatchData); auto jit = CreateJit(kernelName, cldnn_jit, entry_point); diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_base.h b/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_base.h index 0eb94cd61eea72..ecc82d4561ed69 100644 --- a/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_base.h +++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_base.h @@ -33,6 +33,8 @@ class FullyConnectedKernelBase : public WeightBiasKernelBase { uint32_t last_rg_size = 0; uint32_t rg_count = 0; + bool use_slm = false; + // Gemm style params uint32_t tile_m = 0; uint32_t tile_n = 0; @@ -54,13 +56,14 @@ class FullyConnectedKernelBase : public WeightBiasKernelBase { protected: using WeightBiasKernelBase::GetJitConstants; virtual JitConstants GetJitConstants(const fully_connected_params& params, const DispatchData& dispatchData) const; - virtual DispatchData SetDefault(const fully_connected_params& params, int autoTuneIndex = -1) const; + virtual DispatchData SetDefault(const fully_connected_params& params, int autoTuneIndex = -1, int kernel_number = 0) const; KernelsData GetCommonKernelsData(const Params ¶ms, const optional_params &options, DataLayout dl, WeightsLayout wl, const std::string exeMode = EXE_MODE_DEFAULT, - int autoTuneIndex = -1) const; + int autoTuneIndex = -1, + int kernel_number = 0) const; // Fused ops virtual JitConstants GetFusedPrimitivesJitConstants(const fully_connected_params& params, const DispatchData& dispatchData) const; diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_bf_io_gemm.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_bf_io_gemm.cpp index 1b9a478d9bbc4c..2d79b72110c997 100644 --- a/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_bf_io_gemm.cpp +++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_bf_io_gemm.cpp @@ -26,7 +26,8 @@ ParamsKey FullyConnected_bf_io_GEMM::GetSupportedKey() const { } FullyConnected_bf_io_GEMM::DispatchData FullyConnected_bf_io_GEMM::SetDefault(const fully_connected_params& params, - int autoTuneIndex) const { + int autoTuneIndex, + int /*kernel_number*/) const { auto dispatchData = Parent::SetDefault(params, autoTuneIndex); const uint32_t localWorkSizeX = 64; diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_bf_io_gemm.h b/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_bf_io_gemm.h index c454bfc0ae6ec4..34c10f7544081b 100644 --- a/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_bf_io_gemm.h +++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_bf_io_gemm.h @@ -18,7 +18,7 @@ class FullyConnected_bf_io_GEMM : public FullyConnectedKernelBase { ParamsKey GetSupportedKey() const override; protected: - DispatchData SetDefault(const fully_connected_params& params, int autoTuneIndex = -1) const override; + DispatchData SetDefault(const fully_connected_params& params, int autoTuneIndex = -1, int kernel_number = 0) const override; JitConstants GetJitConstants(const fully_connected_params& params, const DispatchData& dispatchData) const override; bool Validate(const Params& p, const optional_params& o) const override; }; diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_bf_io_input_spatial.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_bf_io_input_spatial.cpp index a77c47b3c4b75b..9f6bb3dd885c34 100644 --- a/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_bf_io_input_spatial.cpp +++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_bf_io_input_spatial.cpp @@ -32,7 +32,8 @@ DeviceFeaturesKey FullyConnected_bf_io_input_spatial::get_required_device_featur FullyConnected_bf_io_input_spatial::DispatchData FullyConnected_bf_io_input_spatial::SetDefault( const fully_connected_params& arg, - int) const { + int, + int /*kernel_number*/) const { auto dispatchData = FullyConnectedKernelBase::SetDefault(arg); dispatchData.gws[0] = Align(arg.outputs[0].LogicalSize() / arg.inputs[0].Batch().v, 16); diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_bf_io_input_spatial.h b/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_bf_io_input_spatial.h index 5dde9daa04667e..3aa091319925d6 100644 --- a/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_bf_io_input_spatial.h +++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_bf_io_input_spatial.h @@ -20,6 +20,6 @@ class FullyConnected_bf_io_input_spatial : public FullyConnectedKernelBase { protected: bool Validate(const Params& p, const optional_params& o) const override; - DispatchData SetDefault(const fully_connected_params& arg, int autoTuneIndex = -1) const override; + DispatchData SetDefault(const fully_connected_params& arg, int autoTuneIndex = -1, int kernel_number = 0) const override; }; } // namespace kernel_selector diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_bf_tiled.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_bf_tiled.cpp index d82db3715bacac..5b9bb1c5716fb0 100644 --- a/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_bf_tiled.cpp +++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_bf_tiled.cpp @@ -177,6 +177,28 @@ bool TuneParamsSelector::VerifyTuneParams(const fully_connected_params& params, if (tparams.tile_ofm * simd > 64) return false; + if (tparams.kernel_type == FullyConnected_bf_tiled::KernelType::SLM) { + const auto required_batch_alignment = 64; + if (!params.is_shape_agnostic && (!IsAligned(output_b, required_batch_alignment) || output_b < 256)) + return false; + + const auto required_tile_b = 8; + if (tparams.tile_b != required_tile_b) + return false; + + const auto required_tile_ofm = 2; + if (tparams.tile_ofm != required_tile_ofm) + return false; + + if (params.weights.GetDType() != WeightsType::INT4 && params.weights.GetDType() != WeightsType::UINT4) + return false; + + if (params.engineInfo.deviceType != dev_type::integrated_gpu) + return false; + + return true; + } + // Reject tile sizes that are guaranteed to spill out of registers. unsigned acc_register_bytes = tparams.tile_b * tparams.tile_ofm * simd * BytesPerElement(params.inputs[0].GetDType()); unsigned in_register_bytes = tparams.tile_b * tparams.tile_ifm * simd * BytesPerElement(params.inputs[0].GetDType()); @@ -194,7 +216,7 @@ bool TuneParamsSelector::VerifyTuneParams(const fully_connected_params& params, } // namespace FullyConnected_bf_tiled::tune_params -FullyConnected_bf_tiled::GetAutoTuneParams(const fully_connected_params& params, int idx) const { +FullyConnected_bf_tiled::GetAutoTuneParams(const fully_connected_params& params, KernelType preffered_kernel_type, int idx) const { if (idx >= 0 && idx < static_cast(auto_tune_params.size()) && TuneParamsSelector::VerifyTuneParams(params, auto_tune_params[idx])) return auto_tune_params[idx]; @@ -216,13 +238,14 @@ FullyConnected_bf_tiled::GetAutoTuneParams(const fully_connected_params& params, max_tile_ofm *= 2; if (params.weights.GetDType() == WeightsType::UINT4 || params.weights.GetDType() == WeightsType::INT4) { - if (!params.is_shape_agnostic) { - if (batch == 1) { - return selector.Default(tune_params(1, 2, 1, 4, 1, 1, EXE_MODE_DEFAULT)); - } else { - return selector.Default(tune_params(8, 2, 1, 4, 1, 1, EXE_MODE_DEFAULT)); - } + if (!params.is_shape_agnostic && batch == 1) { + return selector.Default(tune_params(1, 2, 1, 4, 1, 1, EXE_MODE_DEFAULT)); } else { + // Try to use SLM kernels if possible + if (preffered_kernel_type != KernelType::DEFAULT) { + selector.Case(tune_params(8, 2, 2, 4, 1, 1, EXE_MODE_DEFAULT, KernelType::SLM)) + .Case(tune_params(8, 2, 1, 4, 1, 1, EXE_MODE_DEFAULT, KernelType::SLM)); + } return selector.Default(tune_params(8, 2, 1, 4, 1, 1, EXE_MODE_DEFAULT)); } } else if (params.compressed && params.engineInfo.supports_immad) { @@ -289,9 +312,17 @@ FullyConnected_bf_tiled::GetAutoTuneParams(const fully_connected_params& params, } FullyConnected_bf_tiled::DispatchData -FullyConnected_bf_tiled::SetDefault(const fully_connected_params& params, int autoTuneIndex) const { +FullyConnected_bf_tiled::SetDefault(const fully_connected_params& params, int autoTuneIndex, int kernel_number) const { auto dispatchData = Parent::SetDefault(params); - auto tparams = GetAutoTuneParams(params, autoTuneIndex); + + // Use KernelType::ANY by default, in case of shape-agnostic kernel, choose kernel type based + // on `kernel_number` (this implementation allows to have 2 shape-agnostic kernels at the same time + // for small batches and large batches and change them during inference on the fly) + auto kernel_type = KernelType::ANY; + if (params.is_shape_agnostic) + kernel_type = kernel_number == 0 ? KernelType::DEFAULT : KernelType::SLM; + + auto tparams = GetAutoTuneParams(params, kernel_type, autoTuneIndex); size_t feature_threads = CeilDiv(params.outputs[0].Feature().v, tparams.tile_ofm * simd); size_t batch_threads = params.outputs[0].Batch().v; @@ -302,13 +333,18 @@ FullyConnected_bf_tiled::SetDefault(const fully_connected_params& params, int au batch_threads = CeilDiv(batch_threads, tparams.tile_b); - dispatchData.gws[0] = feature_threads * batch_threads * simd; + const size_t lws_batches = 8; + const size_t aligned_batch = Align(batch_threads, lws_batches); // Each WG calculates 8x8 batches (TILE_B x LWS[2] size) + const bool can_use_slm = tparams.kernel_type == KernelType::SLM; + + dispatchData.gws[0] = can_use_slm ? feature_threads * simd + : feature_threads * batch_threads * simd; dispatchData.gws[1] = 1; - dispatchData.gws[2] = 1; + dispatchData.gws[2] = can_use_slm ? aligned_batch : 1; dispatchData.lws[0] = simd; dispatchData.lws[1] = 1; - dispatchData.lws[2] = 1; + dispatchData.lws[2] = can_use_slm ? lws_batches : 1; dispatchData.tile_m = tparams.tile_b; dispatchData.tile_n = tparams.tile_ofm; @@ -316,6 +352,7 @@ FullyConnected_bf_tiled::SetDefault(const fully_connected_params& params, int au dispatchData.tile_nk = tparams.tile_k; dispatchData.tile_ms = tparams.dispatch_bsv; dispatchData.tile_ns = tparams.dispatch_fsv; + dispatchData.use_slm = can_use_slm; return dispatchData; } @@ -340,15 +377,51 @@ JitConstants FullyConnected_bf_tiled::GetJitConstants(const fully_connected_para JitConstants jit = Parent::GetJitConstants(params, dispatchData); size_t tile_k_ofm = dispatchData.tile_nk * dispatchData.tile_n; size_t tile_k_ofm_packed = tile_k_ofm; - if (params.weights.GetDType() == WeightsType::UINT4 || params.weights.GetDType() == WeightsType::INT4) { + + WeightsType weights_dt = params.weights.GetDType(); + if (weights_dt == WeightsType::UINT4 || weights_dt == WeightsType::INT4) { tile_k_ofm_packed /= 2; - jit.Merge(make_int4_packed_type_jit_constant("INT4_PACKED_TYPE", params.weights.GetDType(), tile_k_ofm)); + jit.Merge(make_int4_packed_type_jit_constant("INT4_PACKED_TYPE", weights_dt, tile_k_ofm)); const size_t scale_group_size = params.weights.IFM().v / params.decompression_scale.Feature().v; - if (scale_group_size % simd == 0) + // Do not use SCALE_POST_OP for SLM kernel, since it demonstrates worse performance + if (scale_group_size % simd == 0 && !dispatchData.use_slm) jit.AddConstant(MakeJitConstant("DECOMPRESSION_SCALE_POST_OP", 1)); } + if (dispatchData.use_slm) { + OPENVINO_ASSERT(dispatchData.tile_n == 2, "[GPU] Unsupported TILE_OFM size for SLM kernel configuration"); + OPENVINO_ASSERT(weights_dt == WeightsType::INT4 || weights_dt == WeightsType::UINT4, "[GPU] Unsupported FC weights type for SLM kernel configuration"); + + auto lws_batches = dispatchData.lws[2]; + auto total_weights_elements = simd * dispatchData.tile_n * simd * dispatchData.tile_mk; // SIMD * TILE_OFM * SIMD * TILE_IFM + auto weights_elements_per_sg = total_weights_elements / lws_batches; + auto weights_elements_per_wi = weights_elements_per_sg / simd; + auto weights_elements_per_wi_8bit = weights_elements_per_wi / 2; // number of pairs of int4 weights per WI + + auto block_read_size = 0; + auto preferred_block_sizes = { 8, 4, 2 }; + + for (auto block_size : preferred_block_sizes) { + if (weights_elements_per_wi_8bit % block_size == 0) { + block_read_size = block_size; + break; + } + } + + OPENVINO_ASSERT(block_read_size != 0, "[GPU] Can't configure proper block size"); + + auto weights_load_iters = weights_elements_per_wi_8bit / block_read_size; + auto weights_elements_per_load = block_read_size * 2; + + jit.AddConstant(MakeJitConstant("USE_SLM", 1)); + jit.AddConstant(MakeJitConstant("LWS_BATCHES", lws_batches)); + jit.AddConstant(MakeJitConstant("FILTER_LOAD_ITERS", weights_load_iters)); + jit.AddConstant(MakeJitConstant("FILTER_LOAD_BLOCK_SIZE", block_read_size)); + jit.AddConstant(MakeJitConstant("FILTER_ELEMENTS_PER_LOAD", weights_elements_per_load)); + jit.Merge(make_int4_packed_type_jit_constant("INT4_PACKED_TYPE_PRELOAD", params.weights.GetDType(), weights_elements_per_load)); + } + jit.AddConstant(MakeJitConstant("SIMD", simd)); jit.AddConstant(MakeJitConstant("TILE_B", dispatchData.tile_m)); jit.AddConstant(MakeJitConstant("TILE_OFM", dispatchData.tile_n)); @@ -412,6 +485,40 @@ JitConstants FullyConnected_bf_tiled::GetJitConstants(const fully_connected_para return jit; } +void FullyConnected_bf_tiled::GetUpdateDispatchDataFunc(KernelData& kd) const { + if (kd.kernels.size() == 1) { + Parent::GetUpdateDispatchDataFunc(kd); + } else { + kd.update_dispatch_data_func = [this](const Params& params, KernelData& kd) { + const auto& prim_params = static_cast(params); + + OPENVINO_ASSERT(kd.kernels.size() == 2, "[GPU] Invalid kernels size for update dispatch data func, expected 2, got ", kd.kernels.size()); + + size_t output_batch = prim_params.outputs[0].Batch().v; + if (prim_params.outputs[0].GetLayout() == DataLayout::bfyx) + output_batch *= prim_params.outputs[0].Feature().v; + + // Choose one of the two shape agnostic kernels: + // - kd.kernels[0] for batches <= 240 (default version) + // - kd.kernels[1] for batches >= 256 (slm version) + const auto default_alignment = 16; + // We can use SLM version if `output_batch + default_alignment > 256` because memory and batch are aligned (whether 16 or 64 elements) + const auto skip_kernel_idx = output_batch + default_alignment > 256 ? 0 : 1; + const auto execute_kernel_idx = 1 - skip_kernel_idx; + + kd.kernels[skip_kernel_idx].skip_execution = true; + + GPU_DEBUG_TRACE_DETAIL << "FC bf tiled: " << (execute_kernel_idx == 1 ? "SLM" : "Default") << " shape-agnostic kernel version " + << "will be used for batch size = " << output_batch << "\n"; + + auto dispatchData = SetDefault(prim_params, -1, execute_kernel_idx); + kd.kernels[execute_kernel_idx].params.workGroups.global = dispatchData.gws; + kd.kernels[execute_kernel_idx].params.workGroups.local = dispatchData.lws; + kd.kernels[execute_kernel_idx].skip_execution = KernelData::SkipKernelExecution(prim_params); + }; + } +} + KernelsData FullyConnected_bf_tiled::GetTunedKernelsDataByIndex(const Params ¶ms, const optional_params &options, const int autoTuneIndex) const { @@ -421,7 +528,7 @@ KernelsData FullyConnected_bf_tiled::GetTunedKernelsDataByIndex(const Params &pa && !TuneParamsSelector::VerifyTuneParams(fc_params, auto_tune_params[autoTuneIndex])) return {}; - tune_params tparams = GetAutoTuneParams(fc_params, autoTuneIndex); + tune_params tparams = GetAutoTuneParams(fc_params, KernelType::ANY, autoTuneIndex); WeightsLayout weights_layout = WeightsLayout::os_iyx_osv16; if (tparams.tile_ofm * simd == 32) @@ -429,12 +536,39 @@ KernelsData FullyConnected_bf_tiled::GetTunedKernelsDataByIndex(const Params &pa else if (tparams.tile_ofm * simd == 64) weights_layout = WeightsLayout::os_iyx_osv64; - return GetCommonKernelsData(params, - options, - fc_params.inputs[0].GetLayout(), - weights_layout, - tparams.exec_options, - autoTuneIndex); + auto kernels_data = GetCommonKernelsData(params, + options, + fc_params.inputs[0].GetLayout(), + weights_layout, + tparams.exec_options, + autoTuneIndex); + + // In case of dynamic params try to configure additional optimized SLM kernel for large batches + if (params.is_shape_agnostic) { + auto tparams = GetAutoTuneParams(fc_params, KernelType::SLM, autoTuneIndex); + auto can_select_slm_kernel = tparams.kernel_type == KernelType::SLM; + + if (!can_select_slm_kernel) + return kernels_data; + + auto slm_kernel = GetCommonKernelsData(params, + options, + fc_params.inputs[0].GetLayout(), + weights_layout, + tparams.exec_options, + autoTuneIndex, + 1); + + if (slm_kernel.empty() || slm_kernel[0].kernels.empty()) + return kernels_data; + + kernels_data[0].kernels.push_back(slm_kernel[0].kernels.back()); + + // Update default update_dispatch_data_func function + GetUpdateDispatchDataFunc(kernels_data[0]); + } + + return kernels_data; } KernelsData FullyConnected_bf_tiled::GetKernelsDataForAutoTune(const Params& params, const optional_params& options) const { diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_bf_tiled.h b/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_bf_tiled.h index 099e0f7aa03dbc..ec7f5ce92f045e 100644 --- a/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_bf_tiled.h +++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_bf_tiled.h @@ -12,6 +12,12 @@ namespace kernel_selector { class FullyConnected_bf_tiled : public FullyConnectedKernelBase { public: + enum class KernelType : uint8_t { + DEFAULT = 0, + SLM, + ANY + }; + using Parent = FullyConnectedKernelBase; FullyConnected_bf_tiled(); @@ -33,7 +39,8 @@ class FullyConnected_bf_tiled : public FullyConnectedKernelBase { unsigned tile_k, unsigned dispatch_bsv, unsigned dispatch_fsv, - std::string exec_options) + std::string exec_options, + KernelType kernel_type = KernelType::DEFAULT) : tile_b(tile_b) , tile_ofm(tile_ofm) , tile_ifm(tile_ifm) @@ -41,6 +48,7 @@ class FullyConnected_bf_tiled : public FullyConnectedKernelBase { , dispatch_bsv(dispatch_bsv) , dispatch_fsv(dispatch_fsv) , exec_options(exec_options) + , kernel_type(kernel_type) {} tune_params() = default; @@ -52,10 +60,11 @@ class FullyConnected_bf_tiled : public FullyConnectedKernelBase { unsigned dispatch_bsv; unsigned dispatch_fsv; std::string exec_options; + KernelType kernel_type; }; protected: - DispatchData SetDefault(const fully_connected_params& params, int autoTuneIndex = -1) const override; + DispatchData SetDefault(const fully_connected_params& params, int autoTuneIndex = -1, int kernel_number = 0) const override; std::vector GetSupportedFusedOps() const override { return { FusedOpType::ACTIVATION, FusedOpType::ELTWISE, @@ -63,8 +72,9 @@ class FullyConnected_bf_tiled : public FullyConnectedKernelBase { } JitConstants GetJitConstants(const fully_connected_params& params, const DispatchData& dispatchData) const override; bool Validate(const Params& params, const optional_params& options) const override; + void GetUpdateDispatchDataFunc(KernelData& kd) const override; - tune_params GetAutoTuneParams(const fully_connected_params& params, int idx = -1) const; + tune_params GetAutoTuneParams(const fully_connected_params& params, KernelType preffered_kernel_type = KernelType::DEFAULT, int idx = -1) const; std::vector auto_tune_params; }; diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_bfyx_ref.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_bfyx_ref.cpp index d9b1a55e8eba82..c7c4eda88fa257 100644 --- a/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_bfyx_ref.cpp +++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_bfyx_ref.cpp @@ -44,7 +44,7 @@ ParamsKey FullyConnected_bfyx_Ref::GetSupportedKey() const { } FullyConnected_bfyx_Ref::DispatchData FullyConnected_bfyx_Ref::SetDefault(const fully_connected_params& params, - int) const { + int, int /*kernel_number*/) const { auto dispatchData = Parent::SetDefault(params); std::vector global = { params.outputs[0].Feature().v, params.outputs[0].Batch().v, 1 }; diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_bfyx_ref.h b/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_bfyx_ref.h index f7e97252eeb838..d97d2f11eb672a 100644 --- a/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_bfyx_ref.h +++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_bfyx_ref.h @@ -21,7 +21,7 @@ class FullyConnected_bfyx_Ref : public FullyConnectedKernelBase { ParamsKey GetSupportedKey() const override; protected: - DispatchData SetDefault(const fully_connected_params& params, int autoTuneIndex = -1) const override; + DispatchData SetDefault(const fully_connected_params& params, int autoTuneIndex = -1, int kernel_number = 0) const override; std::vector GetSupportedFusedOps() const override { return { FusedOpType::QUANTIZE, FusedOpType::ACTIVATION, diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_bs_f_bsv16_af8.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_bs_f_bsv16_af8.cpp index 48234686e2fff7..19be133b576d91 100644 --- a/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_bs_f_bsv16_af8.cpp +++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_bs_f_bsv16_af8.cpp @@ -28,7 +28,7 @@ DeviceFeaturesKey FullyConnected_bs_f_bsv16_af8::get_required_device_features_ke } FullyConnected_bs_f_bsv16_af8::DispatchData FullyConnected_bs_f_bsv16_af8::SetDefault(const fully_connected_params& arg, - int) const { + int, int /*kernel_number*/) const { auto dispatchData = FullyConnectedBlockKernelBase::SetDefault(arg); size_t groups_per_batches = GetLocalGroupsSize(arg); diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_bs_f_bsv16_af8.h b/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_bs_f_bsv16_af8.h index 2aaa83bcc36d02..ef3488e0c12adb 100644 --- a/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_bs_f_bsv16_af8.h +++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_bs_f_bsv16_af8.h @@ -19,6 +19,6 @@ class FullyConnected_bs_f_bsv16_af8 : public FullyConnectedBlockKernelBase { protected: bool Validate(const Params& p, const optional_params& o) const override; - DispatchData SetDefault(const fully_connected_params& arg, int autoTuneIndex = -1) const override; + DispatchData SetDefault(const fully_connected_params& arg, int autoTuneIndex = -1, int kernel_number = 0) const override; }; } // namespace kernel_selector diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_bs_f_bsv16_b1.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_bs_f_bsv16_b1.cpp index d7c3fef59c4124..0542fa7fde3ce1 100644 --- a/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_bs_f_bsv16_b1.cpp +++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_bs_f_bsv16_b1.cpp @@ -52,7 +52,7 @@ JitConstants FullyConnected_bs_f_bsv16_b1::GetJitConstants( } FullyConnected_bs_f_bsv16_b1::DispatchData FullyConnected_bs_f_bsv16_b1::SetDefault(const fully_connected_params& arg, - int) const { + int, int /*kernel_number*/) const { DispatchData dispatchData = FullyConnectedKernelBase::SetDefault(arg); // Properties of chunk and unit. diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_bs_f_bsv16_b1.h b/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_bs_f_bsv16_b1.h index 20304d7cb2747a..88a907d78dde0e 100644 --- a/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_bs_f_bsv16_b1.h +++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_bs_f_bsv16_b1.h @@ -20,7 +20,7 @@ class FullyConnected_bs_f_bsv16_b1 : public FullyConnectedKernelBase { protected: JitConstants GetJitConstants(const fully_connected_params& params, const FullyConnectedKernelBase::DispatchData& dispatchData) const override; - DispatchData SetDefault(const fully_connected_params& arg, int autoTuneIndex = -1) const override; + DispatchData SetDefault(const fully_connected_params& arg, int autoTuneIndex = -1, int kernel_number = 0) const override; bool Validate(const Params& p, const optional_params& o) const override; }; } // namespace kernel_selector diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_bs_f_bsv8_af8.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_bs_f_bsv8_af8.cpp index 404c0b30796706..ae52337ccd36f5 100644 --- a/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_bs_f_bsv8_af8.cpp +++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_bs_f_bsv8_af8.cpp @@ -30,7 +30,7 @@ DeviceFeaturesKey FullyConnected_bs_f_bsv8_af8::get_required_device_features_key } FullyConnected_bs_f_bsv8_af8::DispatchData FullyConnected_bs_f_bsv8_af8::SetDefault(const fully_connected_params& arg, - int) const { + int, int /*kernel_number*/) const { auto dispatchData = FullyConnectedBlockKernelBase::SetDefault(arg); size_t groups_per_batches = GetLocalGroupsSize(arg); diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_bs_f_bsv8_af8.h b/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_bs_f_bsv8_af8.h index 532af4dd1a5523..bfdd38c3f64f90 100644 --- a/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_bs_f_bsv8_af8.h +++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_bs_f_bsv8_af8.h @@ -19,6 +19,6 @@ class FullyConnected_bs_f_bsv8_af8 : public FullyConnectedBlockKernelBase { protected: bool Validate(const Params& p, const optional_params& o) const override; - DispatchData SetDefault(const fully_connected_params& arg, int autoTuneIndex = -1) const override; + DispatchData SetDefault(const fully_connected_params& arg, int autoTuneIndex = -1, int kernel_number = 0) const override; }; } // namespace kernel_selector diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_fb_io_b8_f8.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_fb_io_b8_f8.cpp index 35d5d40915a166..a93fdcbf7617c5 100644 --- a/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_fb_io_b8_f8.cpp +++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_fb_io_b8_f8.cpp @@ -43,7 +43,7 @@ size_t FullyConnected_fb_io_b8_f8::GetBatchesPerWorkItem(const fully_connected_p } FullyConnected_fb_io_b8_f8::DispatchData FullyConnected_fb_io_b8_f8::SetDefault(const fully_connected_params& arg, - int) const { + int, int /*kernel_number*/) const { auto dispatchData = FullyConnectedBlockKernelBase::SetDefault(arg); const auto& output = arg.outputs[0]; diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_fb_io_b8_f8.h b/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_fb_io_b8_f8.h index df81a3f4dc64b9..e8c54a33489808 100644 --- a/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_fb_io_b8_f8.h +++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_fb_io_b8_f8.h @@ -18,7 +18,7 @@ class FullyConnected_fb_io_b8_f8 : public FullyConnectedBlockKernelBase { protected: bool Validate(const Params& p, const optional_params& o) const override; - DispatchData SetDefault(const fully_connected_params& arg, int autoTuneIndex = -1) const override; + DispatchData SetDefault(const fully_connected_params& arg, int autoTuneIndex = -1, int kernel_number = 0) const override; size_t GetBatchesPerWorkItem(const fully_connected_params& params) const override; }; } // namespace kernel_selector diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_fb_io_block.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_fb_io_block.cpp index e6bfd71236133f..f207874127f59b 100644 --- a/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_fb_io_block.cpp +++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_fb_io_block.cpp @@ -27,7 +27,7 @@ DeviceFeaturesKey FullyConnected_fb_io_block::get_required_device_features_key(c } FullyConnected_fb_io_block::DispatchData FullyConnected_fb_io_block::SetDefault(const fully_connected_params& arg, - int) const { + int, int /*kernel_number*/) const { auto dispatchData = FullyConnectedKernelBase::SetDefault(arg); const auto& output = arg.outputs[0]; diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_fb_io_block.h b/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_fb_io_block.h index b47a80c167a41e..6d9a736aa29bca 100644 --- a/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_fb_io_block.h +++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_fb_io_block.h @@ -21,6 +21,6 @@ class FullyConnected_fb_io_block : public FullyConnectedKernelBase { bool Validate(const Params& p, const optional_params& o) const override; JitConstants GetJitConstants(const fully_connected_params& params, const FullyConnectedKernelBase::DispatchData& dispatchData) const override; - DispatchData SetDefault(const fully_connected_params& arg, int autoTuneIndex = -1) const override; + DispatchData SetDefault(const fully_connected_params& arg, int autoTuneIndex = -1, int kernel_number = 0) const override; }; } // namespace kernel_selector diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_fb_oi_b8_ref.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_fb_oi_b8_ref.cpp index 40f2a8112971e5..582b57e24eef9a 100644 --- a/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_fb_oi_b8_ref.cpp +++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_fb_oi_b8_ref.cpp @@ -27,7 +27,7 @@ DeviceFeaturesKey FullyConnected_fb_oi_b8_ref::get_required_device_features_key( } FullyConnected_fb_oi_b8_ref::DispatchData FullyConnected_fb_oi_b8_ref::SetDefault(const fully_connected_params& arg, - int) const { + int, int /*kernel_number*/) const { auto dispatchData = FullyConnectedKernelBase::SetDefault(arg); const auto& output = arg.outputs[0]; diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_fb_oi_b8_ref.h b/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_fb_oi_b8_ref.h index 4248350ab46b2e..90afdaf9f07f1f 100644 --- a/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_fb_oi_b8_ref.h +++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_fb_oi_b8_ref.h @@ -19,6 +19,6 @@ class FullyConnected_fb_oi_b8_ref : public FullyConnectedKernelBase { protected: bool Validate(const Params& p, const optional_params& o) const override; - DispatchData SetDefault(const fully_connected_params& arg, int autoTuneIndex = -1) const override; + DispatchData SetDefault(const fully_connected_params& arg, int autoTuneIndex = -1, int kernel_number = 0) const override; }; } // namespace kernel_selector diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_fs_byx_fsv32.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_fs_byx_fsv32.cpp index 4e8979ff41005a..777dba1254d15b 100644 --- a/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_fs_byx_fsv32.cpp +++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_fs_byx_fsv32.cpp @@ -37,7 +37,8 @@ DeviceFeaturesKey FullyConnected_fs_byx_fsv32::get_required_device_features_key( FullyConnected_fs_byx_fsv32::Parent::DispatchData FullyConnected_fs_byx_fsv32::SetDefault( const fully_connected_params& params, - int autoTuneIndex) const { + int autoTuneIndex, + int /*kernel_number*/) const { auto dispatchData = Parent::SetDefault(params, autoTuneIndex); auto blockSizeB = std::min(outputBlockSizeB, params.outputs[0].Batch().v); diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_fs_byx_fsv32.h b/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_fs_byx_fsv32.h index a038de232122ea..88d33da46d2f3c 100644 --- a/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_fs_byx_fsv32.h +++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_fs_byx_fsv32.h @@ -19,7 +19,7 @@ class FullyConnected_fs_byx_fsv32 : public FullyConnectedKernelBase { DeviceFeaturesKey get_required_device_features_key(const Params& params, const optional_params& /*options*/) const override; protected: - DispatchData SetDefault(const fully_connected_params& params, int autoTuneIndex = -1) const override; + DispatchData SetDefault(const fully_connected_params& params, int autoTuneIndex = -1, int kernel_number = 0) const override; JitConstants GetJitConstants(const fully_connected_params& params, const DispatchData& dispatchData) const override; bool Validate(const Params& p, const optional_params& o) const override; }; diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_imad.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_imad.cpp index a38a7af0c77cb0..16800951ae9f6e 100644 --- a/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_imad.cpp +++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_imad.cpp @@ -56,7 +56,7 @@ DeviceFeaturesKey FullyConnectedKernelIMAD::get_required_device_features_key(con return k; } -FullyConnectedKernelIMAD::Parent::DispatchData FullyConnectedKernelIMAD::SetDefault(const fully_connected_params& params, int) const { +FullyConnectedKernelIMAD::Parent::DispatchData FullyConnectedKernelIMAD::SetDefault(const fully_connected_params& params, int, int /*kernel_number*/) const { auto dispatchData = Parent::SetDefault(params); if (!params.has_dynamic_tensors()) { diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_imad.h b/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_imad.h index a1f64e0e628c38..46aae2b4697837 100644 --- a/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_imad.h +++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_imad.h @@ -23,7 +23,7 @@ class FullyConnectedKernelIMAD : public FullyConnectedKernelBase { protected: bool Validate(const Params& params, const optional_params& options) const override; - DispatchData SetDefault(const fully_connected_params& params, int autoTuneIndex = -1) const override; + DispatchData SetDefault(const fully_connected_params& params, int autoTuneIndex = -1, int kernel_number = 0) const override; JitConstants GetJitConstants(const fully_connected_params& params, const DispatchData& dispatchData) const override; std::vector GetSupportedFusedOps() const override { return { FusedOpType::QUANTIZE, diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_mmad.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_mmad.cpp index 9f3fd7ea9b33f2..54f091cde45137 100644 --- a/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_mmad.cpp +++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_mmad.cpp @@ -136,7 +136,7 @@ FullyConnectedKernelMMAD::FullyConnectedTuningData FullyConnectedKernelMMAD::Get } FullyConnectedKernelMMAD::DispatchData FullyConnectedKernelMMAD::SetDefault(const fully_connected_params& params, - int) const { + int, int /*kernel_number*/) const { FullyConnectedTuningData tuning_data = GetTuningParams(params); auto dispatchData = Parent::SetDefault(params); const auto& output = params.outputs[0]; diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_mmad.h b/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_mmad.h index 7a8cc6aded3202..3f7d1d57983d13 100644 --- a/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_mmad.h +++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_mmad.h @@ -32,7 +32,7 @@ class FullyConnectedKernelMMAD : public FullyConnectedKernelBase { protected: JitConstants GetJitConstants(const fully_connected_params& params, const DispatchData& kd) const override; - DispatchData SetDefault(const fully_connected_params& params, int autoTuneIndex = -1) const override; + DispatchData SetDefault(const fully_connected_params& params, int autoTuneIndex = -1, int kernel_number = 0) const override; std::vector GetSupportedFusedOps() const override { return { FusedOpType::QUANTIZE, FusedOpType::ACTIVATION, diff --git a/src/plugins/intel_gpu/src/plugin/ops/gather.cpp b/src/plugins/intel_gpu/src/plugin/ops/gather.cpp index 7d941375d5ae14..c8f009ea5ae32a 100644 --- a/src/plugins/intel_gpu/src/plugin/ops/gather.cpp +++ b/src/plugins/intel_gpu/src/plugin/ops/gather.cpp @@ -106,7 +106,12 @@ void CreateGatherOpBase(ProgramBuilder& p, const std::shared_ptr& op, const i // Set tensors for crop shape and offset ov::Shape start_offset(input_shape.size()); - start_offset[0] = static_cast(result); + int32_t new_offset0 = static_cast(result); + if (support_neg_ind && new_offset0 < 0) { + new_offset0 += static_cast(start_offset.size()); + } + + start_offset[0] = static_cast(new_offset0); auto offsetTensor = tensor_from_dims(start_offset, 0); auto outTensor = tensor_from_dims(out_shape, 1); diff --git a/src/plugins/intel_gpu/src/plugin/ops/loop.cpp b/src/plugins/intel_gpu/src/plugin/ops/loop.cpp index c5465d638d8619..215e322cf83fcf 100644 --- a/src/plugins/intel_gpu/src/plugin/ops/loop.cpp +++ b/src/plugins/intel_gpu/src/plugin/ops/loop.cpp @@ -268,6 +268,16 @@ static void CreateCommonLoopOp(ProgramBuilder& p, const std::shared_ptr(update_current_iter_op); ov_model->add_results({result}); + + const cldnn::primitive_id first_iter_id = layerName + "_firstIter"; + cldnn::mutable_data first_iter_data = CreateScalarData(p, first_iter_id, shape, prec, 0, + static_cast(current_iteration_input_op->get_output_partial_shape(0).rank().get_length())); + + p.add_primitive(*op, std::move(first_iter_data)); + inputs.insert(inputs.begin(), cldnn::input_info(first_iter_id, 0)); + + input_primitive_maps.emplace_back(cldnn::input_info(first_iter_id), cldnn::input_info(body_current_iteration_id)); + back_edges.emplace_back(updated_current_iteration_id, body_current_iteration_id); } // set trip count, num iteration primitives @@ -279,12 +289,6 @@ static void CreateCommonLoopOp(ProgramBuilder& p, const std::shared_ptr n } return false; } + +static bool is_non_decompression_multiply(const std::shared_ptr node) { + auto get_single_consumer = [](const std::shared_ptr node) -> std::shared_ptr { + const auto consumers = node->get_output_target_inputs(0); + if (consumers.size() != 1) + return nullptr; + return consumers.begin()->get_node()->shared_from_this(); + }; + + auto consumer = get_single_consumer(node); + if (!consumer) + return true; + + if (ov::is_type(consumer)) { + return false; + } else if (ov::is_type(consumer)) { + consumer = get_single_consumer(consumer); + if (consumer != nullptr && ov::is_type(consumer)) { + return false; + } + } + if (consumer != nullptr && ov::is_type(consumer)) { + consumer = get_single_consumer(consumer); + if (consumer != nullptr && ov::is_type(consumer)) { + return false; + } + } + return true; +} } // namespace namespace ov { @@ -247,6 +276,8 @@ void TransformationsPipeline::apply(std::shared_ptr func) { }); manager.register_pass(ov::element::TypeVector{ov::element::u8, ov::element::u4, ov::element::i4}, true); + // Ignore nodes that are not related to FullyConnected and allow ConstantFolding to be applied to them + pass_config->set_callback(is_non_decompression_multiply); const bool keep_precision_sensitive_in_fp32_1 = true; const bool convert_input_output_precision = false; diff --git a/src/plugins/intel_gpu/src/runtime/debug_configuration.cpp b/src/plugins/intel_gpu/src/runtime/debug_configuration.cpp index 55f166c4880015..27252ffe3efbdb 100644 --- a/src/plugins/intel_gpu/src/runtime/debug_configuration.cpp +++ b/src/plugins/intel_gpu/src/runtime/debug_configuration.cpp @@ -140,6 +140,7 @@ static void print_help_messages() { message_list.emplace_back("OV_GPU_DisableDynamicImpl", "Disable dynamic implementation"); message_list.emplace_back("OV_GPU_DisableRuntimeBufferFusing", "Disable runtime buffer fusing"); message_list.emplace_back("OV_GPU_DisableMemoryReuse", "Disable memory reuse"); + message_list.emplace_back("OV_GPU_DumpRuntimeMemoryPool", "Dump memory pool contents of each iteration"); message_list.emplace_back("OV_GPU_DisableBuildTimeWeightReorderForDynamicNodes", "Disable build time weight reorder for dynmaic nodes."); message_list.emplace_back("OV_GPU_DisableRuntimeSkipReorder", "Disable runtime skip reorder."); message_list.emplace_back("OV_GPU_DisablePrimitiveFusing", "Disable primitive fusing"); diff --git a/src/plugins/intel_gpu/tests/functional/behavior/hetero_gpu_query_network.cpp b/src/plugins/intel_gpu/tests/functional/behavior/hetero_gpu_query_network.cpp index fe4ae47541d178..54865d7273a752 100644 --- a/src/plugins/intel_gpu/tests/functional/behavior/hetero_gpu_query_network.cpp +++ b/src/plugins/intel_gpu/tests/functional/behavior/hetero_gpu_query_network.cpp @@ -4,19 +4,16 @@ #include "behavior/plugin/hetero_query_network.hpp" -using namespace HeteroTests; - namespace HeteroTests { - TEST_P(HeteroQueryNetworkTest, HeteroSinglePlugin) { std::string deviceName = GetParam(); RunTest(deviceName); } INSTANTIATE_TEST_CASE_P( - HeteroGpu, - HeteroQueryNetworkTest, - ::testing::Values( - std::string("HETERO:GPU"))); + HeteroGpu, + HeteroQueryNetworkTest, + ::testing::Values( + std::string("HETERO:GPU"))); } // namespace HeteroTests diff --git a/src/plugins/intel_gpu/tests/functional/behavior/infer_request.cpp b/src/plugins/intel_gpu/tests/functional/behavior/infer_request.cpp index 6262c366aec905..19631c5d1cbd3a 100644 --- a/src/plugins/intel_gpu/tests/functional/behavior/infer_request.cpp +++ b/src/plugins/intel_gpu/tests/functional/behavior/infer_request.cpp @@ -2,129 +2,98 @@ // SPDX-License-Identifier: Apache-2.0 // -#include -#include -#include -#include - +#include "common_test_utils/test_common.hpp" +#include "common_test_utils/common_utils.hpp" +#include "common_test_utils/node_builders/activation.hpp" +#include "openvino/core/preprocess/pre_post_process.hpp" #include "openvino/runtime/core.hpp" - -#include #include "ov_models/subgraph_builders.hpp" -#include "functional_test_utils/blob_utils.hpp" -#include "openvino/core/preprocess/pre_post_process.hpp" #include "transformations/utils/utils.hpp" -#include "common_test_utils/common_utils.hpp" -#include "shared_test_classes/base/layer_test_utils.hpp" - -using namespace ::testing; - -const std::vector inputPrecisions = { - InferenceEngine::Precision::I16, - InferenceEngine::Precision::U16, - InferenceEngine::Precision::FP32, - InferenceEngine::Precision::FP16, - InferenceEngine::Precision::U8, - InferenceEngine::Precision::I8, - InferenceEngine::Precision::I32, - InferenceEngine::Precision::U32, - InferenceEngine::Precision::U64, - InferenceEngine::Precision::I64, - // Interpreter backend doesn't implement evaluate method for OP - // InferenceEngine::Precision::FP64, -}; +#include "shared_test_classes/base/ov_subgraph.hpp" +namespace { typedef std::tuple< - InferenceEngine::Precision, // Input/Output Precision - InferenceEngine::Layout, // Input layout - InferenceEngine::Layout, // Output layout - std::vector, // Input Shape + ov::element::Type, // Input/Output type + ov::Shape, // Input Shape std::string> newtworkParams; class InferRequestIOPrecision : public testing::WithParamInterface, - virtual public LayerTestsUtils::LayerTestsCommon { + virtual public ov::test::SubgraphBaseStaticTest { 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 InferRequestIOPrecision::getTestCaseName(const testing::TestParamInfo &obj) { - InferenceEngine::Precision netPrecision; - InferenceEngine::Layout inLayout, outLayout; - std::vector shape; + ov::element::Type model_type; + ov::Shape shape; std::string targetDevice; - std::tie(netPrecision, inLayout, outLayout, shape, targetDevice) = obj.param; + std::tie(model_type, shape, targetDevice) = obj.param; std::ostringstream result; const char separator = '_'; - result << "netPRC=" << netPrecision.name() << separator; - result << "inL=" << inLayout << separator; - result << "outL=" << outLayout << separator; + result << "netPRC=" << model_type.get_type_name() << separator; result << "trgDev=" << targetDevice; return result.str(); } void InferRequestIOPrecision::SetUp() { - InferenceEngine::Precision netPrecision; - std::vector shape; - std::tie(netPrecision, inLayout, outLayout, shape, targetDevice) = GetParam(); - inPrc = netPrecision; - outPrc = netPrecision; + ov::element::Type model_type; + ov::Shape shape; + std::tie(model_type, shape, targetDevice) = GetParam(); - float clamp_min = netPrecision.isSigned() ? -5.f : 0.0f; + float clamp_min = model_type.is_signed() ? -5.f : 0.0f; float clamp_max = 5.0f; - auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); - ov::ParameterVector params {std::make_shared(ngPrc, ov::Shape(shape))}; + ov::ParameterVector params {std::make_shared(model_type, ov::Shape(shape))}; params[0]->set_friendly_name("Input"); - auto activation = ngraph::builder::makeActivation(params[0], - ngPrc, - ngraph::helpers::ActivationTypes::Clamp, - {}, - {clamp_min, clamp_max}); + auto activation = ov::test::utils::make_activation(params[0], + model_type, + ov::test::utils::ActivationTypes::Clamp, + {}, + {clamp_min, clamp_max}); - function = std::make_shared(ngraph::NodeVector{activation}, params); + function = std::make_shared(ov::NodeVector{activation}, params); } -InferenceEngine::Blob::Ptr InferRequestIOPrecision::GenerateInput(const InferenceEngine::InputInfo &info) const { - bool inPrcSigned = function->get_parameters()[0]->get_element_type().is_signed(); - bool inPrcReal = function->get_parameters()[0]->get_element_type().is_real(); - - int32_t data_start_from = inPrcSigned ? -10 : 0; - uint32_t data_range = 20; - int32_t resolution = inPrcReal ? 32768 : 1; - - return FuncTestUtils::createAndFillBlob(info.getTensorDesc(), data_range, - data_start_from, - resolution); +TEST_P(InferRequestIOPrecision, Inference) { + run(); } -TEST_P(InferRequestIOPrecision, CompareWithRefs) { - Run(); -} +const std::vector input_types = { + ov::element::i16, + ov::element::u16, + ov::element::f32, + ov::element::f16, + ov::element::u8, + ov::element::i8, + ov::element::i32, + ov::element::u32, + ov::element::u64, + ov::element::i64, + // Interpreter backend doesn't implement evaluate method for OP + // ov::element::f64, +}; INSTANTIATE_TEST_SUITE_P(smoke_GPU_BehaviorTests, InferRequestIOPrecision, ::testing::Combine( - ::testing::ValuesIn(inputPrecisions), - ::testing::Values(InferenceEngine::Layout::ANY), - ::testing::Values(InferenceEngine::Layout::ANY), - ::testing::Values(std::vector{1, 50}), + ::testing::ValuesIn(input_types), + ::testing::Values(ov::Shape{1, 50}), ::testing::Values(ov::test::utils::DEVICE_GPU)), InferRequestIOPrecision::getTestCaseName); TEST(TensorTest, smoke_canSetShapeForPreallocatedTensor) { - auto ie = ov::Core(); + auto core = ov::Core(); using namespace ov::preprocess; auto p = PrePostProcessor(ngraph::builder::subgraph::makeSplitMultiConvConcat()); p.input().tensor().set_element_type(ov::element::i8); p.input().preprocess().convert_element_type(ov::element::f32); auto function = p.build(); - auto exec_net = ie.compile_model(function, ov::test::utils::DEVICE_GPU); + auto exec_net = core.compile_model(function, ov::test::utils::DEVICE_GPU); auto inf_req = exec_net.create_infer_request(); // Check set_shape call for pre-allocated input/output tensors @@ -144,27 +113,27 @@ TEST(TensorTest, smoke_canSetScalarTensor) { params.front()->output(0).get_tensor().set_names({"scalar1"}); std::vector const_shape = {1}; - auto const1 = ngraph::opset1::Constant::create(ngraph::element::i64, ngraph::Shape{1}, const_shape); + auto const1 = std::make_shared(ov::element::i64, ov::Shape{1}, const_shape); const1->set_friendly_name("Const_1"); const1->output(0).get_tensor().set_names({"const1"}); const1->fill_data(ov::element::i64, 0); - auto unsqueeze1 = std::make_shared(params.front(), const1); + auto unsqueeze1 = std::make_shared(params.front(), const1); - ngraph::ResultVector results{std::make_shared(unsqueeze1)}; - std::shared_ptr fnPtr = std::make_shared(results, params); + ov::ResultVector results{std::make_shared(unsqueeze1)}; + auto model = std::make_shared(results, params); - auto ie = ov::Core(); - auto compiled_model = ie.compile_model(fnPtr, ov::test::utils::DEVICE_GPU); + auto core = ov::Core(); + auto compiled_model = core.compile_model(model, ov::test::utils::DEVICE_GPU); auto request = compiled_model.create_infer_request(); double real_data = 1.0; - ov::Tensor input_data(ngraph::element::f64, {}, &real_data); + ov::Tensor input_data(ov::element::f64, {}, &real_data); request.set_tensor("scalar1", input_data); ASSERT_NO_THROW(request.infer()); } TEST(TensorTest, smoke_canSetTensorForDynamicInput) { - auto ie = ov::Core(); + auto core = ov::Core(); using namespace ov::preprocess; auto p = PrePostProcessor(ngraph::builder::subgraph::makeSplitMultiConvConcat()); p.input().tensor().set_element_type(ov::element::i8); @@ -173,7 +142,7 @@ TEST(TensorTest, smoke_canSetTensorForDynamicInput) { auto function = p.build(); std::map shapes = { {0, ov::PartialShape{-1, -1, -1, -1}} }; function->reshape(shapes); - auto exec_net = ie.compile_model(function, ov::test::utils::DEVICE_GPU); + auto exec_net = core.compile_model(function, ov::test::utils::DEVICE_GPU); auto inf_req = exec_net.create_infer_request(); ov::Tensor t1(ov::element::i8, {1, 4, 20, 20}); @@ -243,3 +212,4 @@ TEST(VariablesTest, smoke_canSetStateTensor) { ASSERT_NO_THROW(request.infer()); } +} // namespace \ No newline at end of file diff --git a/src/plugins/intel_gpu/tests/functional/behavior/inference_precision.cpp b/src/plugins/intel_gpu/tests/functional/behavior/inference_precision.cpp index ac4d17fb7739e2..5c7bfd8adb9b60 100644 --- a/src/plugins/intel_gpu/tests/functional/behavior/inference_precision.cpp +++ b/src/plugins/intel_gpu/tests/functional/behavior/inference_precision.cpp @@ -2,24 +2,13 @@ // SPDX-License-Identifier: Apache-2.0 // -#include -#include -#include -#include - -#include "openvino/runtime/core.hpp" - -#include -#include "shared_test_classes/base/layer_test_utils.hpp" #include "base/ov_behavior_test_utils.hpp" -#include "functional_test_utils/ov_plugin_cache.hpp" - -using namespace ::testing; +#include "openvino/runtime/core.hpp" +namespace { using params = std::tuple; -class InferencePrecisionTests : public testing::WithParamInterface, - virtual public LayerTestsUtils::LayerTestsCommon { +class InferencePrecisionTests : public ::testing::TestWithParam { public: static std::string getTestCaseName(const testing::TestParamInfo &obj) { ov::element::Type model_precision; @@ -33,7 +22,7 @@ class InferencePrecisionTests : public testing::WithParamInterface, TEST_P(InferencePrecisionTests, smoke_canSetInferencePrecisionAndInfer) { SKIP_IF_CURRENT_TEST_IS_DISABLED() - auto core = ov::test::utils::PluginCache::get().core(); + auto core = ov::test::utils::PluginCache::get().core(); ov::element::Type model_precision; ov::element::Type inference_precision; std::tie(model_precision, inference_precision) = GetParam(); @@ -84,3 +73,4 @@ TEST(ExecutionModeTest, SetCompileGetInferPrecisionAndExecMode) { ASSERT_EQ(ov::element::f16, compiled_model.get_property(ov::hint::inference_precision)); } } +} // namespace \ No newline at end of file diff --git a/src/plugins/intel_gpu/tests/functional/behavior/memory_dyn_batch.cpp b/src/plugins/intel_gpu/tests/functional/behavior/memory_dyn_batch.cpp index d502850e367027..9572a128e95424 100644 --- a/src/plugins/intel_gpu/tests/functional/behavior/memory_dyn_batch.cpp +++ b/src/plugins/intel_gpu/tests/functional/behavior/memory_dyn_batch.cpp @@ -2,23 +2,18 @@ // SPDX-License-Identifier: Apache-2.0 // +#include "common_test_utils/test_common.hpp" +#include "common_test_utils/common_utils.hpp" +#include "common_test_utils/test_constants.hpp" +#include "functional_test_utils/skip_tests_config.hpp" +#include "functional_test_utils/ov_plugin_cache.hpp" #include "openvino/core/partial_shape.hpp" -#include "openvino/opsets/opset8.hpp" #include "openvino/runtime/compiled_model.hpp" #include "openvino/runtime/infer_request.hpp" #include "openvino/runtime/core.hpp" -#include "ov_models/subgraph_builders.hpp" -#include "shared_test_classes/base/ov_subgraph.hpp" -#include "functional_test_utils/skip_tests_config.hpp" -#include "functional_test_utils/ov_plugin_cache.hpp" -#include "common_test_utils/common_utils.hpp" - -#include - -#include - -using namespace ov::test; +#include "openvino/op/add.hpp" +namespace { using MemoryDynamicBatchParams = std::tuple< ov::PartialShape, // Partial shape for network initialization ov::Shape, // Actual shape to be passed to inference request @@ -57,9 +52,9 @@ class MemoryDynamicBatch : public ::testing::Test, infer_request = compiled_model.create_infer_request(); } - static std::shared_ptr build_model(ElementType precision, const ov::PartialShape& shape) { - auto param = std::make_shared(precision, shape); - const ov::op::util::VariableInfo variable_info { shape, precision, "v0" }; + static std::shared_ptr build_model(ov::element::Type type, const ov::PartialShape& shape) { + auto param = std::make_shared(type, shape); + const ov::op::util::VariableInfo variable_info { shape, type, "v0" }; auto variable = std::make_shared(variable_info); auto read_value = std::make_shared(param, variable); auto add = std::make_shared(read_value, param); @@ -169,3 +164,4 @@ INSTANTIATE_TEST_SUITE_P(smoke_MemoryDynamicBatch, MemoryDynamicBatch, ::testing::ValuesIn(iterations_num), ::testing::Values(ov::test::utils::DEVICE_GPU)), MemoryDynamicBatch::get_test_case_name); +} // namespace diff --git a/src/plugins/intel_gpu/tests/functional/concurrency/gpu_concurrency_tests.cpp b/src/plugins/intel_gpu/tests/functional/concurrency/gpu_concurrency_tests.cpp index 29b80e9759df2a..0e763f41919847 100644 --- a/src/plugins/intel_gpu/tests/functional/concurrency/gpu_concurrency_tests.cpp +++ b/src/plugins/intel_gpu/tests/functional/concurrency/gpu_concurrency_tests.cpp @@ -2,16 +2,9 @@ // SPDX-License-Identifier: Apache-2.0 // -#include -#include -#include -#include -#include "openvino/runtime/core.hpp" - -#include -#include -#include +#include "common_test_utils/test_common.hpp" +#include "functional_test_utils/plugin_cache.hpp" #include "ov_models/subgraph_builders.hpp" #include "functional_test_utils/blob_utils.hpp" #include "openvino/core/preprocess/pre_post_process.hpp" @@ -20,14 +13,17 @@ #include "openvino/runtime/intel_gpu/properties.hpp" #include "common_test_utils/ov_tensor_utils.hpp" #include "common_test_utils/data_utils.hpp" +#include "openvino/runtime/core.hpp" +#include "openvino/runtime/infer_request.hpp" +#include "openvino/runtime/compiled_model.hpp" +#include "functional_test_utils/ov_plugin_cache.hpp" -using namespace ::testing; - +namespace { using ConcurrencyTestParams = std::tuple; // number of requests class OVConcurrencyTest : public ov::test::TestsCommon, - public testing::WithParamInterface { + public testing::WithParamInterface { void SetUp() override { std::tie(num_streams, num_requests) = this->GetParam(); fn_ptrs = {ngraph::builder::subgraph::makeSplitMultiConvConcat(), @@ -43,7 +39,7 @@ class OVConcurrencyTest : public ov::test::TestsCommon, } void execute(bool is_caching_test = false) { - auto ie = ov::Core(); + auto core = ov::test::utils::PluginCache::get().core(); std::string cacheFolderName; if (is_caching_test) { @@ -53,80 +49,67 @@ class OVConcurrencyTest : public ov::test::TestsCommon, ov::test::utils::removeFilesWithExt(cacheFolderName, "blob"); ov::test::utils::removeFilesWithExt(cacheFolderName, "cl_cache"); ov::test::utils::removeDir(cacheFolderName); - ie.set_property(ov::cache_dir(cacheFolderName)); - ie.set_property(ov::intel_gpu::enable_loop_unrolling(false)); + core->set_property(ov::cache_dir(cacheFolderName)); + core->set_property(ov::test::utils::DEVICE_GPU, ov::intel_gpu::enable_loop_unrolling(false)); } - ov::ResultVector outputs; - std::vector irs; - std::vector> ref; - std::vector outElementsCount; + std::vector, ov::InferRequest>> irs; + std::vector irs_ref; for (size_t i = 0; i < fn_ptrs.size(); ++i) { auto fn = fn_ptrs[i]; - ov::CompiledModel exec_net; - if (is_caching_test) { { - auto _dummy_exec_net = ie.compile_model(fn_ptrs[i], ov::test::utils::DEVICE_GPU, + auto _dummy_exec_net = core->compile_model(fn, ov::test::utils::DEVICE_GPU, ov::num_streams(ov::streams::Num(num_streams)), ov::hint::inference_precision(ov::element::f32)); } { - exec_net = ie.compile_model(fn_ptrs[i], ov::test::utils::DEVICE_GPU, + exec_net = core->compile_model(fn, ov::test::utils::DEVICE_GPU, ov::num_streams(ov::streams::Num(num_streams)), ov::hint::inference_precision(ov::element::f32)); } } else { - exec_net = ie.compile_model(fn_ptrs[i], ov::test::utils::DEVICE_GPU, + exec_net = core->compile_model(fn, ov::test::utils::DEVICE_GPU, ov::num_streams(ov::streams::Num(num_streams)), ov::hint::inference_precision(ov::element::f32)); } - auto output = fn_ptrs[i]->get_results().at(0); - for (size_t j = 0; j < num_streams * num_requests; j++) { - outputs.push_back(output); - auto inf_req = exec_net.create_infer_request(); - irs.push_back(inf_req); + irs.push_back({fn, inf_req}); - std::vector> inputs; - for (size_t param_idx = 0; param_idx < fn_ptrs[i]->get_parameters().size(); ++param_idx) { - auto input = fn_ptrs[i]->get_parameters().at(param_idx); + auto compiled_model_ref = core->compile_model(fn, ov::test::utils::DEVICE_TEMPLATE); + auto inf_req_ref = compiled_model_ref.create_infer_request(); + irs_ref.push_back(inf_req_ref); + + std::vector input_tensors; + for (size_t param_idx = 0; param_idx < fn->get_parameters().size(); ++param_idx) { + auto input = fn->get_parameters().at(param_idx); auto tensor = ov::test::utils::create_and_fill_tensor(input->get_element_type(), input->get_shape()); inf_req.set_tensor(input, tensor); - - const auto in_tensor = inf_req.get_tensor(input); - const auto tensorSize = in_tensor.get_byte_size(); - const auto inBlobBuf = static_cast(in_tensor.data()); - std::vector inData(inBlobBuf, inBlobBuf + tensorSize); - inputs.emplace_back(inData); + inf_req_ref.set_tensor(input, tensor); } - - auto reOutData = ngraph::helpers::interpreterFunction(fn_ptrs[i], inputs).front().second; - ref.push_back(reOutData); - outElementsCount.push_back(ov::shape_size(fn_ptrs[i]->get_output_shape(0))); + inf_req_ref.infer(); } } const int niter = 10; for (int i = 0; i < niter; i++) { for (auto ir : irs) { - ir.start_async(); + ir.second.start_async(); } for (auto ir : irs) { - ir.wait(); + ir.second.wait(); } } - auto thr = FuncTestUtils::GetComparisonThreshold(InferenceEngine::Precision::FP32); for (size_t i = 0; i < irs.size(); ++i) { - const auto &refBuffer = ref[i].data(); - ASSERT_EQ(outElementsCount[i], irs[i].get_tensor(outputs[i]).get_size()); - FuncTestUtils::compareRawBuffers(irs[i].get_tensor(outputs[i]).data(), - reinterpret_cast(refBuffer), outElementsCount[i], - outElementsCount[i], - thr); + // TODO now it compares only 1st output + // When CVS-126856 is fixed, update to compare all outputs + auto output = irs[i].first->get_results().at(0); + auto out = irs[i].second.get_tensor(output); + auto out_ref = irs_ref[i].get_tensor(output); + ov::test::utils::compare(out_ref, out); } if (is_caching_test) { @@ -139,15 +122,15 @@ class OVConcurrencyTest : public ov::test::TestsCommon, protected: size_t num_streams; size_t num_requests; - std::vector> fn_ptrs; + std::vector> fn_ptrs; }; TEST_P(OVConcurrencyTest, canInferTwoExecNets) { - this->execute(false); + execute(false); } TEST_P(OVConcurrencyTest, canInferTwoExecNets_cached) { - this->execute(true); + execute(true); } const std::vector num_streams{ 1, 2 }; @@ -159,12 +142,12 @@ INSTANTIATE_TEST_SUITE_P(smoke_RemoteTensor, OVConcurrencyTest, OVConcurrencyTest::getTestCaseName); TEST(canSwapTensorsBetweenInferRequests, inputs) { - std::vector> ref; + std::vector ref; std::vector input_tensors; auto fn = ngraph::builder::subgraph::makeSplitMultiConvConcat(); - auto ie = ov::Core(); - auto compiled_model = ie.compile_model(fn, ov::test::utils::DEVICE_GPU, ov::hint::inference_precision(ov::element::f32)); + auto core = ov::test::utils::PluginCache::get().core(); + auto compiled_model = core->compile_model(fn, ov::test::utils::DEVICE_GPU, ov::hint::inference_precision(ov::element::f32)); const int infer_requests_num = 2; ov::InferRequest infer_request1 = compiled_model.create_infer_request(); @@ -174,20 +157,16 @@ TEST(canSwapTensorsBetweenInferRequests, inputs) { input_tensors.push_back(infer_request2.get_input_tensor()); auto calc_ref_results = [&](const ov::Tensor& tensor){ - const auto tensor_size = tensor.get_byte_size(); - const auto in_blob_buf = static_cast(tensor.data()); - std::vector inData(in_blob_buf, in_blob_buf + tensor_size); - auto ref_out_data = ngraph::helpers::interpreterFunction(fn, {inData}).front().second; - ref.push_back(ref_out_data); - }; + auto compiled_model_ref = core->compile_model(fn, ov::test::utils::DEVICE_TEMPLATE); + auto inf_req_ref = compiled_model_ref.create_infer_request(); - auto compare_results = [&](ov::Tensor& result, const uint8_t* refResult) { - auto thr = FuncTestUtils::GetComparisonThreshold(InferenceEngine::Precision::FP32); - ASSERT_EQ(ov::shape_size(fn->get_output_shape(0)), result.get_size()); - FuncTestUtils::compareRawBuffers(result.data(), - reinterpret_cast(refResult), ov::shape_size(fn->get_output_shape(0)), - ov::shape_size(fn->get_output_shape(0)), - thr); + auto input = fn->input(0); + inf_req_ref.set_tensor(input, tensor); + inf_req_ref.infer(); + + auto output = fn->get_result(); + auto out_ref = inf_req_ref.get_tensor(output); + ref.push_back(out_ref); }; for (int32_t i = 0; i < infer_requests_num; i++) { @@ -207,7 +186,7 @@ TEST(canSwapTensorsBetweenInferRequests, inputs) { } else { iter1++; ov::Tensor output_tensor = infer_request1.get_output_tensor(); - compare_results(output_tensor, ref[iter1 % 2].data()); + ov::test::utils::compare(ref[iter1 % 2], output_tensor); if (iter1 < niter_limit) { infer_request1.set_input_tensor(input_tensors[(iter1 + 1) % 2]); infer_request1.start_async(); @@ -221,7 +200,7 @@ TEST(canSwapTensorsBetweenInferRequests, inputs) { } else { iter2++; ov::Tensor output_tensor = infer_request2.get_output_tensor(); - compare_results(output_tensor, ref[(iter2 + 1) % 2].data()); + ov::test::utils::compare(ref[(iter2 + 1) % 2], output_tensor); if (iter2 < niter_limit) { infer_request2.set_input_tensor(input_tensors[iter2 % 2]); infer_request2.start_async(); @@ -239,10 +218,10 @@ TEST(canSwapTensorsBetweenInferRequests, inputs) { } TEST(smoke_InferRequestDeviceMemoryAllocation, usmHostIsNotChanged) { - auto fn = ngraph::builder::subgraph::makeDetectionOutput(ngraph::element::Type_t::f32); + auto fn = ngraph::builder::subgraph::makeDetectionOutput(ov::element::f32); - auto ie = ov::Core(); - auto compiled_model = ie.compile_model(fn, ov::test::utils::DEVICE_GPU, ov::hint::inference_precision(ov::element::f32)); + auto core = ov::test::utils::PluginCache::get().core(); + auto compiled_model = core->compile_model(fn, ov::test::utils::DEVICE_GPU, ov::hint::inference_precision(ov::element::f32)); ov::InferRequest infer_request1 = compiled_model.create_infer_request(); ov::InferRequest infer_request2 = compiled_model.create_infer_request(); @@ -278,10 +257,10 @@ TEST(smoke_InferRequestDeviceMemoryAllocation, usmHostIsNotChanged) { } TEST(smoke_InferRequestDeviceMemoryAllocation, canSetSystemHostTensor) { - auto fn = ngraph::builder::subgraph::makeDetectionOutput(ngraph::element::Type_t::f32); + auto fn = ngraph::builder::subgraph::makeDetectionOutput(ov::element::f32); - auto ie = ov::Core(); - auto compiled_model = ie.compile_model(fn, ov::test::utils::DEVICE_GPU, ov::hint::inference_precision(ov::element::f32)); + auto core = ov::test::utils::PluginCache::get().core(); + auto compiled_model = core->compile_model(fn, ov::test::utils::DEVICE_GPU, ov::hint::inference_precision(ov::element::f32)); ov::InferRequest infer_request1 = compiled_model.create_infer_request(); ov::InferRequest infer_request2 = compiled_model.create_infer_request(); @@ -301,13 +280,13 @@ TEST(smoke_InferRequestDeviceMemoryAllocation, canSetSystemHostTensor) { } TEST(canSwapTensorsBetweenInferRequests, outputs) { - std::vector> ref; + std::vector ref; std::vector input_tensors; std::vector output_tensors; auto fn = ngraph::builder::subgraph::makeSplitMultiConvConcat(); - auto ie = ov::Core(); - auto compiled_model = ie.compile_model(fn, ov::test::utils::DEVICE_GPU, ov::hint::inference_precision(ov::element::f32)); + auto core = ov::test::utils::PluginCache::get().core(); + auto compiled_model = core->compile_model(fn, ov::test::utils::DEVICE_GPU, ov::hint::inference_precision(ov::element::f32)); const int infer_requests_num = 2; ov::InferRequest infer_request1 = compiled_model.create_infer_request(); @@ -319,20 +298,16 @@ TEST(canSwapTensorsBetweenInferRequests, outputs) { output_tensors.push_back(infer_request2.get_output_tensor()); auto calc_ref_results = [&](const ov::Tensor& tensor){ - const auto tensor_size = tensor.get_byte_size(); - const auto in_blob_buf = static_cast(tensor.data()); - std::vector inData(in_blob_buf, in_blob_buf + tensor_size); - auto ref_out_data = ngraph::helpers::interpreterFunction(fn, {inData}).front().second; - ref.push_back(ref_out_data); - }; + auto compiled_model_ref = core->compile_model(fn, ov::test::utils::DEVICE_TEMPLATE); + auto inf_req_ref = compiled_model_ref.create_infer_request(); + + auto input = fn->input(0); + inf_req_ref.set_tensor(input, tensor); + inf_req_ref.infer(); - auto compare_results = [&](ov::Tensor& result, const uint8_t* refResult) { - auto thr = FuncTestUtils::GetComparisonThreshold(InferenceEngine::Precision::FP32); - ASSERT_EQ(ov::shape_size(fn->get_output_shape(0)), result.get_size()); - FuncTestUtils::compareRawBuffers(result.data(), - reinterpret_cast(refResult), ov::shape_size(fn->get_output_shape(0)), - ov::shape_size(fn->get_output_shape(0)), - thr); + auto output = fn->get_result(); + auto out_ref = inf_req_ref.get_tensor(output); + ref.push_back(out_ref); }; for (int32_t i = 0; i < infer_requests_num; i++) { @@ -352,7 +327,7 @@ TEST(canSwapTensorsBetweenInferRequests, outputs) { } else { iter1++; ov::Tensor output_tensor = infer_request1.get_output_tensor(); - compare_results(output_tensor, ref[0].data()); + ov::test::utils::compare(ref[0], output_tensor); if (iter1 < niter_limit) { infer_request1.set_output_tensor(output_tensors[(iter1 + 1) % 2]); infer_request1.start_async(); @@ -366,7 +341,7 @@ TEST(canSwapTensorsBetweenInferRequests, outputs) { } else { iter2++; ov::Tensor output_tensor = infer_request2.get_output_tensor(); - compare_results(output_tensor, ref[1].data()); + ov::test::utils::compare(ref[1], output_tensor); if (iter2 < niter_limit) { infer_request2.set_output_tensor(output_tensors[iter2 % 2]); infer_request2.start_async(); @@ -382,3 +357,4 @@ TEST(canSwapTensorsBetweenInferRequests, outputs) { infer_request2.wait(); } } +} // namespace \ No newline at end of file diff --git a/src/plugins/intel_gpu/tests/functional/dynamic_tests/gpu_dyn_batch_shape_tests.cpp b/src/plugins/intel_gpu/tests/functional/dynamic_tests/gpu_dyn_batch_shape_tests.cpp index 9f4c18ef5d2ce4..880e401bc1acb3 100644 --- a/src/plugins/intel_gpu/tests/functional/dynamic_tests/gpu_dyn_batch_shape_tests.cpp +++ b/src/plugins/intel_gpu/tests/functional/dynamic_tests/gpu_dyn_batch_shape_tests.cpp @@ -2,42 +2,41 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "openvino/runtime/core.hpp" -#include -#include "common_test_utils/common_utils.hpp" +#include "common_test_utils/test_common.hpp" #include "common_test_utils/file_utils.hpp" #include "functional_test_utils/skip_tests_config.hpp" #include "functional_test_utils/ov_plugin_cache.hpp" +#include "openvino/runtime/core.hpp" #include "ov_models/subgraph_builders.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -using namespace ::testing; -using namespace ov::test; +namespace { +using ov::test::InputShape; using OVDynamicBatchParams = std::tuple< - std::vector, // dynamic and static case sizes - ElementType, // Network precision + std::vector, // dynamic and static case sizes + ov::element::Type, // Model type std::string, // Device name ov::AnyMap // Config >; -class OVDynamicBatchShape_Tests : public WithParamInterface, - virtual public ov::test::SubgraphBaseTest { +class OVDynamicBatchShape_Tests : public ::testing::WithParamInterface, + virtual public ov::test::SubgraphBaseTest { public: - static std::string getTestCaseName(TestParamInfo obj) { - std::vector inputShapes; - ElementType netPrecision; - std::string targetDevice; + static std::string getTestCaseName(::testing::TestParamInfo obj) { + std::vector input_shapes; + ov::element::Type model_type; + std::string target_device; ov::AnyMap configuration; - std::tie(inputShapes, netPrecision, targetDevice, configuration) = obj.param; + std::tie(input_shapes, model_type, target_device, configuration) = obj.param; std::ostringstream result; result << "IS="; - for (const auto& shape : inputShapes) { + for (const auto& shape : input_shapes) { result << ov::test::utils::partialShape2str({ shape.first }) << "_"; } result << "TS="; - for (const auto& shape : inputShapes) { + for (const auto& shape : input_shapes) { result << "("; if (!shape.second.empty()) { for (const auto& itr : shape.second) { @@ -46,8 +45,8 @@ class OVDynamicBatchShape_Tests : public WithParamInterface input_shape; - std::tie(inputShape, netPrecision, targetDevice, configuration) = this->GetParam(); + std::tie(input_shape, model_type, targetDevice, configuration) = this->GetParam(); - init_input_shapes(inputShape); + init_input_shapes(input_shape); //TODO: think how we can switch between several input topologies in the future - // function = ngraph::builder::subgraph::makeSplitConvConcat(inputShape.front().first.get_min_shape(), netPrecision); - function = ngraph::builder::subgraph::makeSplitMultiConvConcat(inputShape.front().first.get_min_shape(), netPrecision); + // function = ngraph::builder::subgraph::makeSplitConvConcat(input_shape.front().first.get_min_shape(), model_type); + function = ngraph::builder::subgraph::makeSplitMultiConvConcat(input_shape.front().first.get_min_shape(), model_type); // make topology dynamic std::map dynShape; - dynShape["input_tensor"] = inputShape.front().first; + dynShape["input_tensor"] = input_shape.front().first; function->reshape(dynShape); } - std::shared_ptr src_func; - // std::map configuration; - std::vector inputShape; - ElementType netPrecision; + ov::element::Type model_type; }; TEST_P(OVDynamicBatchShape_Tests, InferDynamicBatchBound) { @@ -94,7 +91,7 @@ TEST_P(OVDynamicBatchShape_Tests, InferDynamicBatchBound_cached) { std::string cacheFolderName; { std::stringstream ss; - ss << "InferDynamicBatchBound_cached_" << netPrecision << "_" << targetDevice; + ss << "InferDynamicBatchBound_cached_" << model_type << "_" << targetDevice; cacheFolderName = ss.str(); ov::test::utils::removeFilesWithExt(cacheFolderName, "blob"); @@ -116,7 +113,6 @@ TEST_P(OVDynamicBatchShape_Tests, InferDynamicBatchBound_cached) { } } -namespace { auto config = []() { return ov::AnyMap{}; }; @@ -125,27 +121,27 @@ auto hetero_config = []() { return ov::AnyMap{{"TARGET_FALLBACK", ov::test::utils::DEVICE_GPU}}; }; -const std::vector inputShapes = { +const std::vector input_shapes = { { { {1, 19}, 4, 20, 20}, { {1, 4, 20, 20}, {7, 4, 20, 20}, {17, 4, 20, 20} } } }; -const std::vector netPrecisions = { - ElementType::f16, - ElementType::f32 +const std::vector model_types = { + ov::element::f16, + ov::element::f32 }; INSTANTIATE_TEST_SUITE_P(smoke_GPU_DynBatch, OVDynamicBatchShape_Tests, ::testing::Combine( - ::testing::Values(inputShapes), - ::testing::ValuesIn(netPrecisions), + ::testing::Values(input_shapes), + ::testing::ValuesIn(model_types), ::testing::Values(ov::test::utils::DEVICE_GPU), ::testing::Values(config())), OVDynamicBatchShape_Tests::getTestCaseName); INSTANTIATE_TEST_SUITE_P(smoke_GPU_DynBatchHetero, OVDynamicBatchShape_Tests, ::testing::Combine( - ::testing::Values(inputShapes), - ::testing::ValuesIn(netPrecisions), + ::testing::Values(input_shapes), + ::testing::ValuesIn(model_types), ::testing::Values(ov::test::utils::DEVICE_HETERO), ::testing::Values(hetero_config())), OVDynamicBatchShape_Tests::getTestCaseName); 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 62eb867df971fa..f852a378f26048 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 @@ -1,18 +1,16 @@ // Copyright (C) 2022 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // - +#include "common_test_utils/test_constants.hpp" +#include "common_test_utils/ov_tensor_utils.hpp" +#include "common_test_utils/test_enums.hpp" +#include "ov_models/builders.hpp" #include "shared_test_classes/single_layer/strided_slice.hpp" #include "shared_test_classes/single_layer/shape_of.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include "ov_models/builders.hpp" -#include "common_test_utils/test_constants.hpp" -#include "common_test_utils/ov_tensor_utils.hpp" - -using namespace InferenceEngine; -using namespace ov::test; -namespace GPULayerTestsDefinitions { +namespace { +using ov::test::InputShape; struct StridedSliceParams { std::vector begin; @@ -28,22 +26,21 @@ struct StridedSliceParams { typedef std::tuple< InputShape, // Input shapes StridedSliceParams, - ElementType, // Element type - std::vector, // begin/end/stride input type + ov::element::Type, // Element type + std::vector, // begin/end/stride input type std::map // Additional network configuration > StridedSliceLayerParamSet; class DynamicShapeHugeRangeGPUTest : public testing::WithParamInterface, - virtual public SubgraphBaseTest { + virtual public ov::test::SubgraphBaseTest { public: static std::string getTestCaseName(const testing::TestParamInfo& obj) { InputShape shapes; StridedSliceParams params; - ElementType elementType; - std::vector restInputType; - TargetDevice targetDevice; + ov::element::Type model_type; + std::vector restInputType; std::map additionalConfig; - std::tie(shapes, params, elementType, restInputType, additionalConfig) = obj.param; + std::tie(shapes, params, model_type, restInputType, additionalConfig) = obj.param; std::ostringstream results; results << "IS=" << ov::test::utils::partialShape2str({shapes.first}) << "_"; @@ -51,7 +48,7 @@ class DynamicShapeHugeRangeGPUTest : public testing::WithParamInterface& targetInputStaticShapes) override { + void generate_inputs(const std::vector& targetInputStaticShapes) override { inputs.clear(); const auto& funcInputs = function->inputs(); ov::Tensor tensor; @@ -83,7 +80,7 @@ class DynamicShapeHugeRangeGPUTest : public testing::WithParamInterface(); @@ -94,7 +91,7 @@ class DynamicShapeHugeRangeGPUTest : public testing::WithParamInterface(); @@ -105,7 +102,7 @@ class DynamicShapeHugeRangeGPUTest : public testing::WithParamInterface(); @@ -122,7 +119,7 @@ class DynamicShapeHugeRangeGPUTest : public testing::WithParamInterface begin; std::vector end; std::vector stride; - std::vector restInputType; + std::vector restInputType; size_t inferRequestNum = 0; void SetUp() override { @@ -139,11 +136,11 @@ class DynamicShapeHugeRangeGPUTest : public testing::WithParamInterface inputShapes; inputShapes.push_back(shapes); - if (restInputType[0] == ngraph::helpers::InputLayerType::PARAMETER) + if (restInputType[0] == ov::test::utils::InputLayerType::PARAMETER) inputShapes.push_back(InputShape({static_cast(begin.size())}, std::vector(shapes.second.size(), {begin.size()}))); - if (restInputType[1] == ngraph::helpers::InputLayerType::PARAMETER) + if (restInputType[1] == ov::test::utils::InputLayerType::PARAMETER) inputShapes.push_back(InputShape({static_cast(end.size())}, std::vector(shapes.second.size(), {end.size()}))); - if (restInputType[2] == ngraph::helpers::InputLayerType::PARAMETER) + if (restInputType[2] == ov::test::utils::InputLayerType::PARAMETER) inputShapes.push_back(InputShape({static_cast(stride.size())}, std::vector(shapes.second.size(), {stride.size()}))); init_input_shapes(inputShapes); @@ -151,67 +148,65 @@ class DynamicShapeHugeRangeGPUTest : public testing::WithParamInterface(inType, inputDynamicShapes.front())}; std::shared_ptr beginInput, endInput, strideInput; - if (restInputType[0] == ngraph::helpers::InputLayerType::PARAMETER) { - auto beginNode = std::make_shared(ngraph::element::Type_t::i64, ov::Shape{begin.size()}); + if (restInputType[0] == ov::test::utils::InputLayerType::PARAMETER) { + auto beginNode = std::make_shared(ov::element::i64, ov::Shape{begin.size()}); params.push_back(beginNode); beginInput = beginNode; } else { - beginInput = std::make_shared(ngraph::element::Type_t::i64, ov::Shape{begin.size()}, begin); + beginInput = std::make_shared(ov::element::i64, ov::Shape{begin.size()}, begin); } - if (restInputType[1] == ngraph::helpers::InputLayerType::PARAMETER) { - auto endNode = std::make_shared(ngraph::element::Type_t::i64, ov::Shape{end.size()}); + if (restInputType[1] == ov::test::utils::InputLayerType::PARAMETER) { + auto endNode = std::make_shared(ov::element::i64, ov::Shape{end.size()}); params.push_back(endNode); endInput = endNode; } else { - endInput = std::make_shared(ngraph::element::Type_t::i64, ov::Shape{end.size()}, end); + endInput = std::make_shared(ov::element::i64, ov::Shape{end.size()}, end); } - if (restInputType[2] == ngraph::helpers::InputLayerType::PARAMETER) { - auto strideNode = std::make_shared(ngraph::element::Type_t::i64, ov::Shape{stride.size()}); + if (restInputType[2] == ov::test::utils::InputLayerType::PARAMETER) { + auto strideNode = std::make_shared(ov::element::i64, ov::Shape{stride.size()}); params.push_back(strideNode); strideInput = strideNode; } else { - strideInput = std::make_shared(ngraph::element::Type_t::i64, ov::Shape{stride.size()}, stride); + strideInput = std::make_shared(ov::element::i64, ov::Shape{stride.size()}, stride); } - auto stridedSliceOp = std::make_shared(params[0], beginInput, endInput, strideInput, ssParams.beginMask, ssParams.endMask, + auto stridedSliceOp = std::make_shared(params[0], beginInput, endInput, strideInput, ssParams.beginMask, ssParams.endMask, ssParams.newAxisMask, ssParams.shrinkAxisMask, ssParams.ellipsisAxisMask); - auto shapeOfOp = std::make_shared(stridedSliceOp, ov::element::Type_t::i32); + auto shapeOfOp = std::make_shared(stridedSliceOp, ov::element::i32); - ngraph::ResultVector results; + ov::ResultVector results; for (size_t i = 0; i < shapeOfOp->get_output_size(); i++) { - results.push_back(std::make_shared(shapeOfOp->output(i))); + results.push_back(std::make_shared(shapeOfOp->output(i))); } - function = std::make_shared(results, params, "result"); + function = std::make_shared(results, params, "result"); } }; -TEST_P(DynamicShapeHugeRangeGPUTest, CompareWithRefs) { +TEST_P(DynamicShapeHugeRangeGPUTest, Inference) { SKIP_IF_CURRENT_TEST_IS_DISABLED() run(); } -namespace { - std::map emptyAdditionalConfig; -const std::vector inputPrecisions = { - ElementType::f32 +const std::vector model_types = { + ov::element::f32 }; -const std::vector> restInputTypes = { - {ngraph::helpers::InputLayerType::CONSTANT, ngraph::helpers::InputLayerType::CONSTANT, ngraph::helpers::InputLayerType::CONSTANT}, - {ngraph::helpers::InputLayerType::PARAMETER, ngraph::helpers::InputLayerType::PARAMETER, ngraph::helpers::InputLayerType::PARAMETER}, - {ngraph::helpers::InputLayerType::PARAMETER, ngraph::helpers::InputLayerType::CONSTANT, ngraph::helpers::InputLayerType::CONSTANT}, - {ngraph::helpers::InputLayerType::CONSTANT, ngraph::helpers::InputLayerType::PARAMETER, ngraph::helpers::InputLayerType::CONSTANT}, - {ngraph::helpers::InputLayerType::CONSTANT, ngraph::helpers::InputLayerType::CONSTANT, ngraph::helpers::InputLayerType::PARAMETER}, - {ngraph::helpers::InputLayerType::CONSTANT, ngraph::helpers::InputLayerType::PARAMETER, ngraph::helpers::InputLayerType::PARAMETER}, - {ngraph::helpers::InputLayerType::PARAMETER, ngraph::helpers::InputLayerType::CONSTANT, ngraph::helpers::InputLayerType::PARAMETER}, - {ngraph::helpers::InputLayerType::PARAMETER, ngraph::helpers::InputLayerType::PARAMETER, ngraph::helpers::InputLayerType::CONSTANT}, +const std::vector> restInputTypes = { + {ov::test::utils::InputLayerType::CONSTANT, ov::test::utils::InputLayerType::CONSTANT, ov::test::utils::InputLayerType::CONSTANT}, + {ov::test::utils::InputLayerType::PARAMETER, ov::test::utils::InputLayerType::PARAMETER, ov::test::utils::InputLayerType::PARAMETER}, + {ov::test::utils::InputLayerType::PARAMETER, ov::test::utils::InputLayerType::CONSTANT, ov::test::utils::InputLayerType::CONSTANT}, + {ov::test::utils::InputLayerType::CONSTANT, ov::test::utils::InputLayerType::PARAMETER, ov::test::utils::InputLayerType::CONSTANT}, + {ov::test::utils::InputLayerType::CONSTANT, ov::test::utils::InputLayerType::CONSTANT, ov::test::utils::InputLayerType::PARAMETER}, + {ov::test::utils::InputLayerType::CONSTANT, ov::test::utils::InputLayerType::PARAMETER, ov::test::utils::InputLayerType::PARAMETER}, + {ov::test::utils::InputLayerType::PARAMETER, ov::test::utils::InputLayerType::CONSTANT, ov::test::utils::InputLayerType::PARAMETER}, + {ov::test::utils::InputLayerType::PARAMETER, ov::test::utils::InputLayerType::PARAMETER, ov::test::utils::InputLayerType::CONSTANT}, }; const std::vector inputShapesDynamic2D_excessive_uppper_boundary = { @@ -227,9 +222,8 @@ INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_Dynamic_2D_excessive_uppper_bound ::testing::Combine( ::testing::ValuesIn(inputShapesDynamic2D_excessive_uppper_boundary), ::testing::ValuesIn(paramsPlain2D_excessive_uppper_boundary), - ::testing::ValuesIn(inputPrecisions), + ::testing::ValuesIn(model_types), ::testing::Values(restInputTypes[0]), ::testing::Values(emptyAdditionalConfig)), DynamicShapeHugeRangeGPUTest::getTestCaseName); } // namespace -} // namespace GPULayerTestsDefinitions diff --git a/src/plugins/intel_gpu/tests/functional/shared_tests_instances/single_layer_tests/gather.cpp b/src/plugins/intel_gpu/tests/functional/shared_tests_instances/single_layer_tests/gather.cpp index 0573d427d8a419..d299d303815cb3 100644 --- a/src/plugins/intel_gpu/tests/functional/shared_tests_instances/single_layer_tests/gather.cpp +++ b/src/plugins/intel_gpu/tests/functional/shared_tests_instances/single_layer_tests/gather.cpp @@ -534,4 +534,29 @@ INSTANTIATE_TEST_CASE_P(smoke, Gather8withIndicesDataLayerTest::getTestCaseName ); +std::vector> nagativeSingleindicesData = { + {-1}, + {-2}, + {-3} +}; + +gather7ParamsTuple dummyParams2 = { + ov::test::static_shapes_to_test_representation(std::vector({{4, 8, 2, 2}})), + ov::Shape({}), + std::tuple{0, 0}, + ov::element::f32, + ov::test::utils::DEVICE_GPU, +}; + +const auto gatherWithNagativeIndicesParams = testing::Combine( + testing::Values(dummyParams2), + testing::ValuesIn(nagativeSingleindicesData) +); + +INSTANTIATE_TEST_CASE_P(smoke_Gather8NagativeIndice, + Gather8withIndicesDataLayerTest, + gatherWithNagativeIndicesParams, + Gather8withIndicesDataLayerTest::getTestCaseName +); + } // namespace diff --git a/src/plugins/intel_gpu/tests/functional/single_layer_tests/loop.cpp b/src/plugins/intel_gpu/tests/functional/shared_tests_instances/single_layer_tests/loop.cpp similarity index 100% rename from src/plugins/intel_gpu/tests/functional/single_layer_tests/loop.cpp rename to src/plugins/intel_gpu/tests/functional/shared_tests_instances/single_layer_tests/loop.cpp diff --git a/src/plugins/intel_gpu/tests/functional/shared_tests_instances/single_layer_tests/multinomial.cpp b/src/plugins/intel_gpu/tests/functional/shared_tests_instances/single_layer_tests/multinomial.cpp index be746c4d5adb19..5c3bc0857fd83e 100644 --- a/src/plugins/intel_gpu/tests/functional/shared_tests_instances/single_layer_tests/multinomial.cpp +++ b/src/plugins/intel_gpu/tests/functional/shared_tests_instances/single_layer_tests/multinomial.cpp @@ -15,7 +15,6 @@ const std::vector netPrecisions = { const std::vector inputShapes = { {1, 32}, {2, 28}, - {32}, }; const std::vector numSamples = { diff --git a/src/plugins/intel_gpu/tests/functional/shared_tests_instances/subgraph_tests/reshape_permute_conv_permute_reshape_act.cpp b/src/plugins/intel_gpu/tests/functional/shared_tests_instances/subgraph_tests/reshape_permute_conv_permute_reshape_act.cpp index c4d58689112a99..ac84ce1f2144e2 100644 --- a/src/plugins/intel_gpu/tests/functional/shared_tests_instances/subgraph_tests/reshape_permute_conv_permute_reshape_act.cpp +++ b/src/plugins/intel_gpu/tests/functional/shared_tests_instances/subgraph_tests/reshape_permute_conv_permute_reshape_act.cpp @@ -32,7 +32,7 @@ std::vector model_types = { ov::element::f16, }; -std::map additional_config = {}; +ov::AnyMap additional_config = {}; INSTANTIATE_TEST_SUITE_P(smoke_basic, ConvReshapeAct, ::testing::Combine( diff --git a/src/plugins/intel_gpu/tests/functional/single_layer_tests/convolution.cpp b/src/plugins/intel_gpu/tests/functional/single_layer_tests/convolution.cpp index ca0c19bd3f3c54..458b5fffd76d50 100644 --- a/src/plugins/intel_gpu/tests/functional/single_layer_tests/convolution.cpp +++ b/src/plugins/intel_gpu/tests/functional/single_layer_tests/convolution.cpp @@ -1,47 +1,40 @@ // Copyright (C) 2018-2023 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // -#include -#include -#include -#include -#include "ov_models/utils/ov_helpers.hpp" -#include "ov_models/builders.hpp" -#include "shared_test_classes/base/ov_subgraph.hpp" -#include "shared_test_classes/single_layer/convolution.hpp" -#include "common_test_utils/test_constants.hpp" +#include "common_test_utils/ov_tensor_utils.hpp" +#include "common_test_utils/file_utils.hpp" +#include "shared_test_classes/single_op/convolution.hpp" +#include "common_test_utils/node_builders/convolution.hpp" -// using namespace LayerTestsDefinitions; -using namespace InferenceEngine; -using namespace ov::test; +#include "openvino/op/parameter.hpp" +#include "openvino/op/result.hpp" -namespace GPULayerTestsDefinitions { - -using LayerTestsDefinitions::convSpecificParams; +namespace { +using ov::test::InputShape; +using ov::test::convSpecificParams; typedef std::tuple< convSpecificParams, - ElementType, // Net precision - ElementType, // Input precision - ElementType, // Output precision - InputShape, // Input shape - LayerTestsUtils::TargetDevice // Device name + ov::element::Type, // Net precision + ov::element::Type, // Input precision + ov::element::Type, // Output precision + InputShape, // Input shape + std::string // Device name > convLayerTestParamsSet; - class ConvolutionLayerGPUTest : public testing::WithParamInterface, - virtual public SubgraphBaseTest { + virtual public ov::test::SubgraphBaseTest { public: static std::string getTestCaseName(const testing::TestParamInfo& obj) { convSpecificParams convParams; - ElementType netType; - ElementType inType, outType; + ov::element::Type netType; + ov::element::Type inType, outType; InputShape inputShape; std::string targetDevice; std::tie(convParams, netType, inType, outType, inputShape, targetDevice) = obj.param; - ngraph::op::PadType padType; - InferenceEngine::SizeVector kernel, stride, dilation; + ov::op::PadType padType; + std::vector kernel, stride, dilation; std::vector padBegin, padEnd; size_t convOutChannels; std::tie(kernel, stride, padBegin, padEnd, dilation, convOutChannels, padType) = convParams; @@ -73,13 +66,13 @@ class ConvolutionLayerGPUTest : public testing::WithParamInterfaceGetParam(); init_input_shapes({inputShape}); - ngraph::op::PadType padType; - InferenceEngine::SizeVector kernel, stride, dilation; + ov::op::PadType padType; + std::vector kernel, stride, dilation; std::vector padBegin, padEnd; size_t convOutChannels; std::tie(kernel, stride, padBegin, padEnd, dilation, convOutChannels, padType) = convParams; @@ -88,40 +81,36 @@ class ConvolutionLayerGPUTest : public testing::WithParamInterface(inType, shape)); - auto convolutionNode = ngraph::builder::makeConvolution(inputParams.front(), netType, kernel, stride, padBegin, - padEnd, dilation, padType, convOutChannels); + auto convolutionNode = ov::test::utils::make_convolution(inputParams.front(), netType, kernel, stride, padBegin, + padEnd, dilation, padType, convOutChannels); - ngraph::ResultVector results; + ov::ResultVector results; for (size_t i = 0; i < convolutionNode->get_output_size(); i++) - results.push_back(std::make_shared(convolutionNode->output(i))); + results.push_back(std::make_shared(convolutionNode->output(i))); - function = std::make_shared(results, inputParams, "Convolution"); + function = std::make_shared(results, inputParams, "Convolution"); } }; -TEST_P(ConvolutionLayerGPUTest, CompareWithRefs) { - SKIP_IF_CURRENT_TEST_IS_DISABLED() +TEST_P(ConvolutionLayerGPUTest, Inference) { run(); } -namespace { -// Check 3D input tensor for convolution is handled properly and its output is correct comparing with ngraph runtime. +// Check 3D input tensor for convolution is handled properly and its output is correct comparing with ov runtime. INSTANTIATE_TEST_SUITE_P(smoke_ConvolutionLayerGPUTest_3D_tensor_basic, ConvolutionLayerGPUTest, ::testing::Combine( ::testing::Combine( - ::testing::Values(SizeVector{3}), - ::testing::Values(SizeVector{1}), + ::testing::Values(std::vector{3}), + ::testing::Values(std::vector{1}), ::testing::Values(std::vector{0}), ::testing::Values(std::vector{0}), - ::testing::Values(SizeVector{1}), + ::testing::Values(std::vector{1}), ::testing::Values(13), - ::testing::Values(ngraph::op::PadType::SAME_UPPER)), - ::testing::Values(ElementType::f16), - ::testing::Values(ElementType::f16), - ::testing::Values(ElementType::undefined), + ::testing::Values(ov::op::PadType::SAME_UPPER)), + ::testing::Values(ov::element::f16), + ::testing::Values(ov::element::f16), + ::testing::Values(ov::element::undefined), ::testing::Values(InputShape{{}, {{1, 13, 30}}}), ::testing::Values(ov::test::utils::DEVICE_GPU)), ConvolutionLayerGPUTest::getTestCaseName); } // namespace - -} // namespace GPULayerTestsDefinitions diff --git a/src/plugins/intel_gpu/tests/functional/single_layer_tests/tensor_iterator.cpp b/src/plugins/intel_gpu/tests/functional/single_layer_tests/tensor_iterator.cpp index 4bd41f87cd51a6..97b98da4d66633 100644 --- a/src/plugins/intel_gpu/tests/functional/single_layer_tests/tensor_iterator.cpp +++ b/src/plugins/intel_gpu/tests/functional/single_layer_tests/tensor_iterator.cpp @@ -2,26 +2,17 @@ // SPDX-License-Identifier: Apache-2.0 // -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "common_test_utils/test_constants.hpp" -#include "ie_api.h" -#include "shared_test_classes/base/layer_test_utils.hpp" -#include "ov_models/builders.hpp" -#include "ov_models/utils/ov_helpers.hpp" - -using namespace InferenceEngine; -using Config = std::pair>; - -namespace LayerTestsDefinitions { +// +#include "common_test_utils/ov_tensor_utils.hpp" +#include "common_test_utils/file_utils.hpp" +#include "shared_test_classes/base/ov_subgraph.hpp" +#include "common_test_utils/node_builders/convolution.hpp" +#include "common_test_utils/test_enums.hpp" +#include "common_test_utils/node_builders/gru_cell.hpp" +#include "common_test_utils/node_builders/lstm_cell.hpp" +#include "common_test_utils/node_builders/rnn_cell.hpp" +namespace { using TensorIteratorWithConfigParams = typename std::tuple< size_t, // seq_lengths size_t, // batch @@ -30,13 +21,13 @@ using TensorIteratorWithConfigParams = typename std::tuple< //size_t, // input size size_t, // sequence axis float, // clip - ngraph::helpers::TensorIteratorBody, // body type - ngraph::op::RecurrentSequenceDirection, // direction - InferenceEngine::Precision, // Network precision - Config>; // Target device name & Configuration + ov::test::utils::TensorIteratorBody, // body type + ov::op::RecurrentSequenceDirection, // direction + ov::element::Type, // Model type + std::string>; // Device class TensorIteratorWithConfigTest : public testing::WithParamInterface, - virtual public LayerTestsUtils::LayerTestsCommon { + virtual public ov::test::SubgraphBaseStaticTest { public: static std::string getTestCaseName(const testing::TestParamInfo &obj) { size_t seq_lengths; @@ -44,29 +35,28 @@ class TensorIteratorWithConfigTest : public testing::WithParamInterface> config; - std::tie(seq_lengths, batch, hidden_size, sequence_axis, clip, ti_body, direction, netPrecision, - config) = obj.param; + ov::op::RecurrentSequenceDirection direction; + ov::element::Type model_type; + std::string target_device; + std::tie(seq_lengths, batch, hidden_size, sequence_axis, clip, ti_body, direction, model_type, target_device) = obj.param; std::vector> inputShapes = {}; switch (ti_body) { - case ngraph::helpers::TensorIteratorBody::LSTM: + case ov::test::utils::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: + case ov::test::utils::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: + case ov::test::utils::TensorIteratorBody::RNN: inputShapes = {{batch, input_size}, {batch, hidden_size}, {hidden_size, input_size}, {hidden_size, hidden_size}, {hidden_size}}; break; @@ -82,17 +72,8 @@ class TensorIteratorWithConfigTest : public testing::WithParamInterface(lstm_cell->output(0), axis); - ngraph::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"); + ov::ParameterVector body_params{std::make_shared(model_type, ov::Shape(inputShapes[0])), + std::make_shared(model_type, ov::Shape(inputShapes[1])), + std::make_shared(model_type, 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 = ov::test::utils::make_lstm(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 == ngraph::op::RecurrentSequenceDirection::FORWARD) { + 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 == ngraph::op::RecurrentSequenceDirection::REVERSE) { + } 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 { - NGRAPH_CHECK(false, "Bidirectional case is not supported."); + OPENVINO_THROW("Bidirectional case is not supported."); } tensor_iterator->set_merged_input(body_params[1], outer_params[1], results[1]); @@ -169,11 +146,11 @@ class TensorIteratorWithConfigTest : public testing::WithParamInterfaceget_iter_value(results[2]); // 3. Outer function - function = std::make_shared(ngraph::OutputVector{tensor_iterator->output(0), tensor_iterator->output(1), + 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: { + case ov::test::utils::TensorIteratorBody::GRU: { inputShapes = { {{batch, seq_lengths, input_size}, {batch, hidden_size}, {3 * hidden_size, input_size}, {3 * hidden_size, hidden_size}, {3 * hidden_size}}, @@ -182,43 +159,43 @@ class TensorIteratorWithConfigTest : public testing::WithParamInterface(ngPrc, ov::Shape(inputShapes[0])), - std::make_shared(ngPrc, ov::Shape(inputShapes[1]))}; + ov::ParameterVector outer_params{std::make_shared(model_type, ov::Shape(inputShapes[0])), + std::make_shared(model_type, 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); - ngraph::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); - ngraph::ResultVector results{std::make_shared(gru_cell->output(0)), - std::make_shared(unsqueeze)}; - auto body = std::make_shared(results, body_params, "gru_cell"); + ov::ParameterVector body_params{std::make_shared(model_type, ov::Shape(inputShapes[0])), + std::make_shared(model_type, 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 = ov::test::utils::make_gru(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 == ngraph::op::RecurrentSequenceDirection::FORWARD) { + 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 == ngraph::op::RecurrentSequenceDirection::REVERSE) { + } 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 { - NGRAPH_CHECK(false, "Bidirectional case is not supported."); + OPENVINO_THROW("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(ngraph::OutputVector{tensor_iterator->output(0), tensor_iterator->output(1)}, outer_params); + function = std::make_shared(ov::OutputVector{tensor_iterator->output(0), tensor_iterator->output(1)}, outer_params); break; } - case ngraph::helpers::TensorIteratorBody::RNN: { + case ov::test::utils::TensorIteratorBody::RNN: { inputShapes = {{batch, seq_lengths, input_size}, {batch, hidden_size}, {hidden_size, input_size}, @@ -228,77 +205,69 @@ class TensorIteratorWithConfigTest : public testing::WithParamInterface(ngPrc, ov::Shape(inputShapes[0])), - std::make_shared(ngPrc, ov::Shape(inputShapes[1]))}; + ov::ParameterVector outer_params{std::make_shared(model_type, ov::Shape(inputShapes[0])), + std::make_shared(model_type, 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); - ngraph::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); - ngraph::ResultVector results{std::make_shared(rnn_cell), - std::make_shared(unsqueeze)}; - auto body = std::make_shared(results, body_params, "rnn_cell"); + ov::ParameterVector body_params{std::make_shared(model_type, ov::Shape(inputShapes[0])), + std::make_shared(model_type, 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 = ov::test::utils::make_rnn(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 == ngraph::op::RecurrentSequenceDirection::FORWARD) { + 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 == ngraph::op::RecurrentSequenceDirection::REVERSE) { + } 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 { - NGRAPH_CHECK(false, "Bidirectional case is not supported."); + OPENVINO_THROW("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(ngraph::OutputVector{tensor_iterator->output(0), tensor_iterator->output(1)}, outer_params); + function = std::make_shared(ov::OutputVector{tensor_iterator->output(0), tensor_iterator->output(1)}, outer_params); break; } } } }; -TEST_P(TensorIteratorWithConfigTest, CompareWithRefs) { - Run(); +TEST_P(TensorIteratorWithConfigTest, Inference) { + run(); }; -} // namespace LayerTestsDefinitions - -using namespace LayerTestsDefinitions; - -namespace { - INSTANTIATE_TEST_SUITE_P(smoke_TensorIteratorCommon, TensorIteratorWithConfigTest, - ::testing::Combine( - ::testing::ValuesIn(std::vector {2, 4}), // seq lengths - ::testing::ValuesIn(std::vector {1}), // only single batch supported - ::testing::ValuesIn(std::vector {2, 4}), // hidden size - ::testing::ValuesIn(std::vector {0, 1}), // seq axis - ::testing::ValuesIn(std::vector {0.f}), // clip - not used - ::testing::ValuesIn(std::vector { - ngraph::helpers::TensorIteratorBody::LSTM, - ngraph::helpers::TensorIteratorBody::RNN, - ngraph::helpers::TensorIteratorBody::GRU, - }), // body type - ::testing::ValuesIn(std::vector{ - ngraph::op::RecurrentSequenceDirection::FORWARD, - ngraph::op::RecurrentSequenceDirection::REVERSE, - }), - ::testing::ValuesIn(std::vector { - InferenceEngine::Precision::FP32, - InferenceEngine::Precision::FP16, - }), // precision - ::testing::ValuesIn(std::vector { - {ov::test::utils::DEVICE_GPU, {{GPUConfigParams::KEY_GPU_ENABLE_LOOP_UNROLLING, PluginConfigParams::YES}}}, - {ov::test::utils::DEVICE_GPU, {{GPUConfigParams::KEY_GPU_ENABLE_LOOP_UNROLLING, PluginConfigParams::NO}}} - })), // configuration - TensorIteratorWithConfigTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_TensorIteratorCommon, TensorIteratorWithConfigTest, + ::testing::Combine( + ::testing::ValuesIn(std::vector {2, 4}), // seq lengths + ::testing::ValuesIn(std::vector {1}), // only single batch supported + ::testing::ValuesIn(std::vector {2, 4}), // hidden size + ::testing::ValuesIn(std::vector {0, 1}), // seq axis + ::testing::ValuesIn(std::vector {0.f}), // clip - not used + ::testing::ValuesIn(std::vector { + ov::test::utils::TensorIteratorBody::LSTM, + ov::test::utils::TensorIteratorBody::RNN, + ov::test::utils::TensorIteratorBody::GRU, + }), // body type + ::testing::ValuesIn(std::vector{ + ov::op::RecurrentSequenceDirection::FORWARD, + ov::op::RecurrentSequenceDirection::REVERSE, + }), + ::testing::ValuesIn(std::vector { + ov::element::f32, + ov::element::f16, + }), + ::testing::Values(ov::test::utils::DEVICE_GPU)), + TensorIteratorWithConfigTest::getTestCaseName); } // namespace diff --git a/src/plugins/intel_gpu/tests/functional/subgraph_tests/condition.cpp b/src/plugins/intel_gpu/tests/functional/subgraph_tests/condition.cpp index 99359ba07aa6ba..dbb6cef94c8072 100644 --- a/src/plugins/intel_gpu/tests/functional/subgraph_tests/condition.cpp +++ b/src/plugins/intel_gpu/tests/functional/subgraph_tests/condition.cpp @@ -2,26 +2,27 @@ // SPDX-License-Identifier: Apache-2.0 // -#include -#include -#include -#include -#include "ov_models/utils/ov_helpers.hpp" -#include "shared_test_classes/base/layer_test_utils.hpp" -#include "ov_models/builders.hpp" -#include "shared_test_classes/base/ov_subgraph.hpp" #include "common_test_utils/test_constants.hpp" -#include "shared_test_classes/base/utils/ranges.hpp" -#include -#include "shared_test_classes/base/utils/compare_results.hpp" +#include "common_test_utils/ov_tensor_utils.hpp" +#include "shared_test_classes/base/ov_subgraph.hpp" #include "openvino/pass/constant_folding.hpp" - - -using namespace InferenceEngine; -using namespace ov::test; - -namespace GPULayerTestsDefinitions { - +#include "ov_models/utils/ov_helpers.hpp" +#include "common_test_utils/node_builders/reduce.hpp" + +#include "openvino/op/parameter.hpp" +#include "openvino/op/constant.hpp" +#include "openvino/op/result.hpp" +#include "openvino/op/add.hpp" +#include "openvino/op/multiply.hpp" +#include "openvino/op/greater_eq.hpp" +#include "openvino/op/if.hpp" +#include "openvino/op/shape_of.hpp" +#include "openvino/op/reshape.hpp" +#include "openvino/op/convert.hpp" +#include "openvino/op/max_pool.hpp" +#include "openvino/op/avg_pool.hpp" + +namespace { class InnerBodyGenerator { public: using ptr = std::shared_ptr; @@ -65,140 +66,143 @@ enum InnerBodyType { public: InnerBodyGenerator() { } - virtual std::shared_ptr get_function() { return _func; } - virtual std::shared_ptr get_input() { return _param; } - virtual std::shared_ptr get_result() { return _result; } + virtual std::shared_ptr get_function() { return _func; } + virtual std::shared_ptr get_input() { return _param; } + virtual std::shared_ptr get_result() { return _result; } - // virtual void create_body(ngraph::Shape input_shape, ngraph::element::Type prc) { - virtual void create_body(ov::PartialShape& input_shape, ngraph::element::Type prc) { + // virtual void create_body(ov::Shape input_shape, ov::element::Type prc) { + virtual void create_body(ov::PartialShape& input_shape, ov::element::Type prc) { _func = generate(input_shape, prc); _param = (_func->get_parameters().size() > 0)? _func->get_parameters().front() : nullptr; _result = _func->get_results().front(); } protected: - virtual std::shared_ptr generate(ov::PartialShape& input_shape, ngraph::element::Type prc) = 0; + virtual std::shared_ptr generate(ov::PartialShape& input_shape, ov::element::Type prc) = 0; - std::shared_ptr _func; - std::shared_ptr _param; - std::shared_ptr _result; + std::shared_ptr _func; + std::shared_ptr _param; + std::shared_ptr _result; }; class InnerBodyType01 : public InnerBodyGenerator { protected: - std::shared_ptr generate(ov::PartialShape& input_shape, ngraph::element::Type prc) override { - auto constantA = ngraph::opset9::Constant::create(prc, ov::Shape(input_shape.rank().get_length(), 2), {2.0f}); + std::shared_ptr generate(ov::PartialShape& input_shape, ov::element::Type prc) override { + auto constantA = ov::op::v0::Constant::create(prc, ov::Shape(input_shape.rank().get_length(), 2), {2.0f}); constantA->set_friendly_name("body1_constantA"); - auto constantB = ngraph::opset9::Constant::create(prc, ov::Shape(input_shape.rank().get_length(), 2), {12.0f}); + + auto constantB = ov::op::v0::Constant::create(prc, ov::Shape(input_shape.rank().get_length(), 2), {12.0f}); constantB->set_friendly_name("body1_constantB"); - auto add = std::make_shared(constantA, constantB); + + auto add = std::make_shared(constantA, constantB); add->set_friendly_name("body1_add"); - auto result = std::make_shared(add); - auto o_layout = result->get_layout(); + + auto result = std::make_shared(add); result->set_friendly_name("body1_result"); - auto body = std::make_shared( - ngraph::OutputVector {result}, - ngraph::ParameterVector{}, - "constant"); + + auto body = std::make_shared(ov::OutputVector{result}, ov::ParameterVector{}, "constant"); return body; } }; class InnerBodyType02 : public InnerBodyGenerator { protected: - std::shared_ptr generate(ov::PartialShape& input_shape, ngraph::element::Type prc) override { - auto constant = std::make_shared(prc, ngraph::Shape{}, 10.0f); + std::shared_ptr generate(ov::PartialShape& input_shape, ov::element::Type prc) override { + auto constant = std::make_shared(prc, ov::Shape{}, 10.0f); constant->set_friendly_name("body2_const"); - auto data = std::make_shared(prc, input_shape); + + auto data = std::make_shared(prc, input_shape); data->set_friendly_name("body2_data"); - auto sum = std::make_shared(data, constant); + + auto sum = std::make_shared(data, constant); sum->set_friendly_name("body2_mul"); - auto result = std::make_shared(sum); + + auto result = std::make_shared(sum); result->set_friendly_name("body2_result"); - auto body = std::make_shared( - ngraph::OutputVector {result}, - ngraph::ParameterVector{data}, - "eltwise_mul"); + + auto body = std::make_shared(ov::OutputVector{result}, ov::ParameterVector{data}, "eltwise_mul"); return body; } }; class InnerBodyType03 : public InnerBodyGenerator { protected: - std::shared_ptr generate(ov::PartialShape& input_shape, ngraph::element::Type prc) override { - auto constant = std::make_shared(prc, ngraph::Shape{}, 2.0f); + std::shared_ptr generate(ov::PartialShape& input_shape, ov::element::Type prc) override { + auto constant = std::make_shared(prc, ov::Shape{}, 2.0f); constant->set_friendly_name("body3_constant"); - auto data = std::make_shared(prc, input_shape); + + auto data = std::make_shared(prc, input_shape); data->set_friendly_name("body3_data"); - auto add = std::make_shared(data, constant); + + auto add = std::make_shared(data, constant); add->set_friendly_name("body3_add"); - auto result = std::make_shared(add); + + auto result = std::make_shared(add); result->set_friendly_name("body3_result"); - auto body = std::make_shared( - ngraph::OutputVector {result}, - ngraph::ParameterVector{data}, - "eltwise_sum"); + + auto body = std::make_shared(ov::OutputVector{result}, ov::ParameterVector{data}, "eltwise_sum"); return body; } }; class InnerBodyType04 : public InnerBodyGenerator { protected: - std::shared_ptr generate(ov::PartialShape& input_shape, ngraph::element::Type prc) override { - auto scale = std::make_shared(prc, ngraph::Shape{}, 2.0f); + std::shared_ptr generate(ov::PartialShape& input_shape, ov::element::Type prc) override { + auto scale = std::make_shared(prc, ov::Shape{}, 2.0f); scale->set_friendly_name("body4_scale"); - auto data = std::make_shared(prc, input_shape); + + auto data = std::make_shared(prc, input_shape); data->set_friendly_name("body4_data"); - auto mul = std::make_shared(data, scale); + + auto mul = std::make_shared(data, scale); mul->set_friendly_name("body4_mul"); - auto pooling = generate_pooling(mul, input_shape); + + auto pooling = generate_pooling(mul, input_shape); pooling->set_friendly_name("body4_pool"); - auto result = std::make_shared(pooling); + + auto result = std::make_shared(pooling); result->set_friendly_name("body4_result"); - auto body = std::make_shared( - ngraph::OutputVector {result}, - ngraph::ParameterVector{data}, - "eltwise_mul_pooling"); + + auto body = std::make_shared(ov::OutputVector{result}, ov::ParameterVector{data}, "eltwise_mul_pooling"); return body; } - struct poolSpecificParams { - ngraph::helpers::PoolingTypes pooling_type; // Pooling type, max or avg - std::vector kernel_size; // Kernel size - std::vector stride; // Stride - std::vector pad_begin; // Pad begin - std::vector pad_end; // Pad end - ngraph::op::RoundingType rounding_type; // Rounding type - ngraph::op::PadType pad_type; // Pad type - bool exclued_pad; // Exclude pad + ov::test::utils::PoolingTypes pooling_type; // Pooling type, max or avg + std::vector kernel_size; // Kernel size + std::vector stride; // Stride + std::vector pad_begin; // Pad begin + std::vector pad_end; // Pad end + ov::op::RoundingType rounding_type; // Rounding type + ov::op::PadType pad_type; // Pad type + bool exclued_pad; // Exclude pad }; - std::shared_ptr generate_pooling(const ngraph::Output &in, ov::PartialShape& input_shape) { + std::shared_ptr generate_pooling(const ov::Output &in, ov::PartialShape& input_shape) { poolSpecificParams params; switch (input_shape.rank().get_length()) { case 5: { - params = poolSpecificParams{ ngraph::helpers::PoolingTypes::MAX, + params = poolSpecificParams{ ov::test::utils::PoolingTypes::MAX, {2, 2, 2}, {1, 1, 1}, {0, 0, 0}, {0, 0, 0}, - ngraph::op::RoundingType::CEIL, - ngraph::op::PadType::SAME_LOWER, true }; + ov::op::RoundingType::CEIL, + ov::op::PadType::SAME_LOWER, true }; break; } case 4: { - params = poolSpecificParams{ ngraph::helpers::PoolingTypes::MAX, + params = poolSpecificParams{ ov::test::utils::PoolingTypes::MAX, {2, 2}, {2, 2}, {0, 0}, {0, 0}, - ngraph::op::RoundingType::CEIL, - ngraph::op::PadType::SAME_LOWER, true }; + ov::op::RoundingType::CEIL, + ov::op::PadType::SAME_LOWER, true }; break; } case 3: { - params = poolSpecificParams{ ngraph::helpers::PoolingTypes::MAX, + params = poolSpecificParams{ ov::test::utils::PoolingTypes::MAX, {2}, {2}, {0}, {0}, - ngraph::op::RoundingType::CEIL, - ngraph::op::PadType::SAME_LOWER, true }; + ov::op::RoundingType::CEIL, + ov::op::PadType::SAME_LOWER, true }; break; } default: @@ -229,29 +233,33 @@ class InnerBodyType04 : public InnerBodyGenerator { class InnerBodyType05 : public InnerBodyGenerator { protected: - std::shared_ptr generate(ov::PartialShape& input_shape, ngraph::element::Type prc) override { - auto constant = std::make_shared(prc, ngraph::Shape{}, 2.0f); + std::shared_ptr generate(ov::PartialShape& input_shape, ov::element::Type prc) override { + auto constant = std::make_shared(prc, ov::Shape{}, 2.0f); constant->set_friendly_name("body5_constant"); - auto data = std::make_shared(prc, input_shape); + + auto data = std::make_shared(prc, input_shape); data->set_friendly_name("body5_data"); - auto add = std::make_shared(data, constant); + + auto add = std::make_shared(data, constant); add->set_friendly_name("body5_add"); + std::vector axes; for (int i = 0, r = 0; i < input_shape.rank().get_length(); i++) { axes.push_back(r--); } + std::vector shapeAxes; shapeAxes.push_back(axes.size()); - auto reductionAxesNode = std::dynamic_pointer_cast( - std::make_shared(ngraph::element::Type_t::i64, ngraph::Shape(shapeAxes), axes)); + std::shared_ptr reductionAxesNode = std::make_shared(ov::element::i64, ov::Shape(shapeAxes), axes); - const auto reduce = ngraph::builder::makeReduce(add, reductionAxesNode, false, ngraph::helpers::ReductionType::Min); + const auto reduce = ov::test::utils::make_reduce(add, reductionAxesNode, false, ov::test::utils::ReductionType::Min); reduce->set_friendly_name("body5_reduce"); - auto constant_ref = std::make_shared(prc, ngraph::Shape{}, 10.0f); + + auto constant_ref = std::make_shared(prc, ov::Shape{}, 10.0f); constant_ref->set_friendly_name("body5_ref_constant"); - auto pred = std::make_shared(reduce, constant_ref); + auto pred = std::make_shared(reduce, constant_ref); pred->set_friendly_name("nested_pred"); auto nested_body_then_generator = std::make_shared(); @@ -263,68 +271,62 @@ class InnerBodyType05 : public InnerBodyGenerator { nested_body_then_generator->get_function()->set_friendly_name("nested_then_inner_body"); nested_body_else_generator->get_function()->set_friendly_name("nested_else_inner_body"); - auto cond_nested = std::make_shared(pred); + auto cond_nested = std::make_shared(pred); cond_nested->set_friendly_name("if_operator_nested"); cond_nested->set_else_body(nested_body_else_generator->get_function()); cond_nested->set_then_body(nested_body_then_generator->get_function()); cond_nested->set_input(add, nested_body_then_generator->get_input(), nested_body_else_generator->get_input()); cond_nested->set_output(nested_body_then_generator->get_result(), nested_body_else_generator->get_result()); - auto result = std::make_shared(cond_nested); + auto result = std::make_shared(cond_nested); result->set_friendly_name("body5_result"); - auto body = std::make_shared( - ngraph::OutputVector {result}, - ngraph::ParameterVector{data}, - "eltwise_sum"); + + auto body = std::make_shared(ov::OutputVector {result}, ov::ParameterVector{data}, "eltwise_sum"); return body; } }; class InnerBodyType06 : public InnerBodyGenerator { protected: - std::shared_ptr generate(ov::PartialShape& input_shape, ngraph::element::Type prc) override { - auto constant = ngraph::opset9::Constant::create(prc, ov::Shape(input_shape.rank().get_length(), 1), {2.0f}); + std::shared_ptr generate(ov::PartialShape& input_shape, ov::element::Type prc) override { + auto constant = ov::op::v0::Constant::create(prc, ov::Shape(input_shape.rank().get_length(), 1), {2.0f}); constant->set_friendly_name("body6_constant"); - auto result = std::make_shared(constant); - auto o_layout = result->get_layout(); + + auto result = std::make_shared(constant); result->set_friendly_name("body6_result"); - auto body = std::make_shared( - ngraph::OutputVector {result}, - ngraph::ParameterVector{}, - "constant_only"); + + auto body = std::make_shared(ov::OutputVector{result}, ov::ParameterVector{}, "constant_only"); return body; } }; class InnerBodyType07 : public InnerBodyGenerator { protected: - std::shared_ptr generate(ov::PartialShape& input_shape, ngraph::element::Type prc) override { - auto constant = ngraph::opset9::Constant::create(prc, input_shape.to_shape(), {2.0f}); + std::shared_ptr generate(ov::PartialShape& input_shape, ov::element::Type prc) override { + auto constant = ov::op::v0::Constant::create(prc, input_shape.to_shape(), {2.0f}); constant->set_friendly_name("body7_constant"); - auto result = std::make_shared(constant); - auto o_layout = result->get_layout(); + + auto result = std::make_shared(constant); result->set_friendly_name("body7_result"); - auto body = std::make_shared( - ngraph::OutputVector {result}, - ngraph::ParameterVector{}, - "constant_to_result"); + + auto body = std::make_shared(ov::OutputVector{result}, ov::ParameterVector{}, "constant_to_result"); return body; } }; class InnerBodyType08 : public InnerBodyGenerator { protected: - std::shared_ptr generate(ov::PartialShape& input_shape, ngraph::element::Type prc) override { - auto constant = std::make_shared(prc, ngraph::Shape{}, 10.0f); + std::shared_ptr generate(ov::PartialShape& input_shape, ov::element::Type prc) override { + auto constant = std::make_shared(prc, ov::Shape{}, 10.0f); constant->set_friendly_name("body8_const"); - auto data = std::make_shared(prc, input_shape); + + auto data = std::make_shared(prc, input_shape); data->set_friendly_name("body8_data"); - auto result = std::make_shared(data); + + auto result = std::make_shared(data); result->set_friendly_name("body8_result"); - auto body = std::make_shared( - ngraph::OutputVector {result}, - ngraph::ParameterVector{data}, - "parameter_to_result"); + + auto body = std::make_shared(ov::OutputVector{result}, ov::ParameterVector{data}, "parameter_to_result"); return body; } }; @@ -380,66 +382,69 @@ class TestModelGenerator { public: TestModelGenerator(InnerBodyGenerator::InnerBodyType then_body_type, - InnerBodyGenerator::InnerBodyType else_body_type, - PredicateTypes pred_type, - ngraph::element::Type prc, - ov::PartialShape input_shape, - bool cond_execution_value = false) { - body_then_generator = get_inner_body_generator(then_body_type); - body_else_generator = get_inner_body_generator(else_body_type); - - body_then_generator->create_body(input_shape, prc); - body_else_generator->create_body(input_shape, prc); - body_else_generator->get_function()->set_friendly_name("else_inner_body"); - body_then_generator->get_function()->set_friendly_name("then_inner_body"); - - ngraph::ParameterVector params{}; - auto predicate = create_cond_execution(pred_type, params, ngraph::element::boolean, ngraph::Shape{}); - predicate->set_friendly_name("if_predicate"); - auto data = create_condition_input(params, prc, input_shape); - data->set_friendly_name("input_data"); - auto cond = std::make_shared(predicate); - cond->set_friendly_name("if_operator"); - cond->set_else_body(body_else_generator->get_function()); - cond->set_then_body(body_then_generator->get_function()); - cond->set_input(data, body_then_generator->get_input(), body_else_generator->get_input()); - cond->set_output(body_then_generator->get_result(), body_else_generator->get_result()); - if (then_body_type == InnerBodyGenerator::InnerBodyType::Type06 || else_body_type == InnerBodyGenerator::InnerBodyType::Type06) { - auto constant = create_condition_input(params, prc, ngraph::Shape{1}, 0, true); - auto addition = std::make_shared(cond, constant); - auto shapeof1 = std::make_shared(addition); - auto convert = std::make_shared(shapeof1, prc); - auto mul = std::make_shared(convert, constant); - auto shapePatternsNode = create_condition_input(params, ov::element::Type_t::i64, ngraph::Shape{1}, 0, true); - auto reshapeOp = std::make_shared(mul, shapePatternsNode, true); - auto result = std::make_shared(reshapeOp); - result->set_friendly_name("outer_result"); - function = std::make_shared(ngraph::OutputVector {result}, params); - } else { - auto result = std::make_shared(cond); - result->set_friendly_name("outer_result"); - function = std::make_shared(ngraph::OutputVector {result}, params); - } - } - std::shared_ptr get_function() { return function; } + InnerBodyGenerator::InnerBodyType else_body_type, + PredicateTypes pred_type, + ov::element::Type prc, + ov::PartialShape input_shape, + bool cond_execution_value = false) { + body_then_generator = get_inner_body_generator(then_body_type); + body_else_generator = get_inner_body_generator(else_body_type); + + body_then_generator->create_body(input_shape, prc); + body_else_generator->create_body(input_shape, prc); + body_else_generator->get_function()->set_friendly_name("else_inner_body"); + body_then_generator->get_function()->set_friendly_name("then_inner_body"); + + ov::ParameterVector params{}; + auto predicate = create_cond_execution(pred_type, params, ov::element::boolean, ov::Shape{}); + predicate->set_friendly_name("if_predicate"); + + auto data = create_condition_input(params, prc, input_shape); + data->set_friendly_name("input_data"); + + auto cond = std::make_shared(predicate); + cond->set_friendly_name("if_operator"); + cond->set_else_body(body_else_generator->get_function()); + cond->set_then_body(body_then_generator->get_function()); + cond->set_input(data, body_then_generator->get_input(), body_else_generator->get_input()); + cond->set_output(body_then_generator->get_result(), body_else_generator->get_result()); + + if (then_body_type == InnerBodyGenerator::InnerBodyType::Type06 || else_body_type == InnerBodyGenerator::InnerBodyType::Type06) { + auto constant = create_condition_input(params, prc, ov::Shape{1}, 0, true); + auto addition = std::make_shared(cond, constant); + auto shapeof1 = std::make_shared(addition); + auto convert = std::make_shared(shapeof1, prc); + auto mul = std::make_shared(convert, constant); + auto shapePatternsNode = create_condition_input(params, ov::element::i64, ov::Shape{1}, 0, true); + auto reshapeOp = std::make_shared(mul, shapePatternsNode, true); + auto result = std::make_shared(reshapeOp); + result->set_friendly_name("outer_result"); + function = std::make_shared(ov::OutputVector {result}, params); + } else { + auto result = std::make_shared(cond); + result->set_friendly_name("outer_result"); + function = std::make_shared(ov::OutputVector {result}, params); + } + } + std::shared_ptr get_function() { return function; } private: - std::shared_ptr create_condition_input(ngraph::ParameterVector& params, - const ngraph::element::Type prc, const ov::PartialShape& shape, + std::shared_ptr create_condition_input(ov::ParameterVector& params, + const ov::element::Type prc, const ov::PartialShape& shape, int value = 0, bool is_static = false) { if (is_static) - return std::make_shared(prc, shape.to_shape(), value); + return std::make_shared(prc, shape.to_shape(), value); - auto input = std::make_shared(prc, shape); + auto input = std::make_shared(prc, shape); params.push_back(input); return input; } - std::shared_ptr create_cond_execution(PredicateTypes pred_type, - ngraph::ParameterVector& params, - const ngraph::element::Type prc = ngraph::element::u8, - const ngraph::Shape shape = ngraph::Shape{}) { - std::shared_ptr pred; + std::shared_ptr create_cond_execution(PredicateTypes pred_type, + ov::ParameterVector& params, + const ov::element::Type prc = ov::element::u8, + const ov::Shape shape = ov::Shape{}) { + std::shared_ptr pred; switch (pred_type) { case PredicateTypes::PARAM: { @@ -450,9 +455,9 @@ class TestModelGenerator { { auto param_cond = create_condition_input(params, prc, shape); param_cond->set_friendly_name("param_cond"); - auto const_cond = create_condition_input(params, prc, ngraph::Shape{}, 1, true); + auto const_cond = create_condition_input(params, prc, ov::Shape{}, 1, true); const_cond->set_friendly_name("const_cond"); - pred = std::make_shared(param_cond, const_cond); + pred = std::make_shared(param_cond, const_cond); pred->set_friendly_name("pred"); break; } @@ -465,7 +470,7 @@ class TestModelGenerator { } private: - std::shared_ptr function; + std::shared_ptr function; InnerBodyGenerator::ptr body_then_generator; InnerBodyGenerator::ptr body_else_generator; }; @@ -543,25 +548,25 @@ static std::ostream& operator<<(std::ostream& os, const TestModelGenerator::Pred } using ConditionParams = typename std::tuple< - InferenceEngine::SizeVector, // Shape - InferenceEngine::Precision, // Precision + ov::Shape, // Shape + ov::element::Type, // Precision TestModelGenerator::PredicateTypes, // if predicate type - LayerTestsUtils::TargetDevice // Device name ->; + std::string>; // Device name + class StaticConditionLayerGPUTest : public testing::WithParamInterface, - virtual public LayerTestsUtils::LayerTestsCommon { + virtual public ov::test::SubgraphBaseStaticTest { public: static std::string getTestCaseName(const testing::TestParamInfo& obj) { - InferenceEngine::SizeVector data_shape; - InferenceEngine::Precision data_prc; + ov::Shape data_shape; + ov::element::Type model_type; TestModelGenerator::PredicateTypes pred; std::string targetDevice; - std::tie(data_shape, data_prc, pred, targetDevice) = obj.param; + std::tie(data_shape, model_type, pred, targetDevice) = obj.param; std::ostringstream result; result << "IS=" << ov::test::utils::vec2str(data_shape) << "_"; - result << "netPRC=" << std::to_string(data_prc) << "_"; + result << "netPRC=" << model_type << "_"; result << "ifCond=" << pred << "_"; result << "targetDevice=" << targetDevice << "_"; auto res_str = result.str(); @@ -573,60 +578,53 @@ class StaticConditionLayerGPUTest : public testing::WithParamInterfaceallocate(); - - if (tensor_desc.getLayout() == InferenceEngine::SCALAR) { - auto prc = tensor_desc.getPrecision(); - auto scalar_1d = ov::test::utils::make_reshape_view(blob, {1}); - if (prc == InferenceEngine::Precision::BOOL) { - auto mem_blob = dynamic_cast(blob.get()); - auto mem = mem_blob->rwmap(); - auto data_ptr = mem.as(); - *data_ptr = false; + void generate_inputs(const std::vector& target_input_static_shapes) override { + inputs.clear(); + const auto& model_inputs = function->inputs(); + for (size_t i = 0; i < model_inputs.size(); ++i) { + const auto& model_input = model_inputs[i]; + auto type = model_input.get_element_type(); + ov::Tensor tensor; + if (ov::element::boolean == type) { + tensor = ov::test::utils::create_and_fill_tensor(model_input.get_element_type(), target_input_static_shapes[i], 0, 0); } else { - ov::test::utils::fill_data_with_broadcast(scalar_1d, 0, {20.f}); + tensor = ov::test::utils::create_and_fill_tensor(model_input.get_element_type(), target_input_static_shapes[i], 0, 20); } - } else { - ov::test::utils::fill_data_with_broadcast(blob, 0, {20.f}); + inputs.insert({model_input.get_node_shared_ptr(), tensor}); } - return blob; } - InferenceEngine::SizeVector data_shape; - InferenceEngine::Precision data_prc; + ov::Shape data_shape; + ov::element::Type model_type; }; TEST_P(StaticConditionLayerGPUTest, CompareWithRefs) { - SKIP_IF_CURRENT_TEST_IS_DISABLED(); - Run(); + run(); } -std::vector netPrecisions_static = { - InferenceEngine::Precision::FP32, - InferenceEngine::Precision::FP16, - InferenceEngine::Precision::I8 +std::vector netPrecisions_static = { + ov::element::f32, + ov::element::f16, + ov::element::i8 }; -std::vector inputs_shape = { +std::vector inputs_shape = { {3, 6} }; -std::vector if_cond_types = { - GPULayerTestsDefinitions::TestModelGenerator::PredicateTypes::PARAM +std::vector if_cond_types = { + TestModelGenerator::PredicateTypes::PARAM }; INSTANTIATE_TEST_SUITE_P(smoke_ConditionGPUTest_static, StaticConditionLayerGPUTest, @@ -640,18 +638,18 @@ INSTANTIATE_TEST_SUITE_P(smoke_ConditionGPUTest_static, StaticConditionLayerGPUT /// Static shape single layer test class StaticConditionSingleLayerGPUTest : public testing::WithParamInterface, - virtual public LayerTestsUtils::LayerTestsCommon { + virtual public ov::test::SubgraphBaseStaticTest { public: static std::string getTestCaseName(const testing::TestParamInfo& obj) { - InferenceEngine::SizeVector data_shape; - InferenceEngine::Precision data_prc; + ov::Shape data_shape; + ov::element::Type model_type; TestModelGenerator::PredicateTypes pred; std::string targetDevice; - std::tie(data_shape, data_prc, pred, targetDevice) = obj.param; + std::tie(data_shape, model_type, pred, targetDevice) = obj.param; std::ostringstream result; result << "IS=" << ov::test::utils::vec2str(data_shape) << "_"; - result << "netPRC=" << std::to_string(data_prc) << "_"; + result << "netPRC=" << model_type << "_"; result << "ifCond=" << pred << "_"; result << "targetDevice=" << targetDevice << "_"; auto res_str = result.str(); @@ -663,62 +661,55 @@ class StaticConditionSingleLayerGPUTest : public testing::WithParamInterfaceallocate(); - - if (tensor_desc.getLayout() == InferenceEngine::SCALAR) { - auto prc = tensor_desc.getPrecision(); - auto scalar_1d = ov::test::utils::make_reshape_view(blob, {1}); - if (prc == InferenceEngine::Precision::BOOL) { - auto mem_blob = dynamic_cast(blob.get()); - auto mem = mem_blob->rwmap(); - auto data_ptr = mem.as(); - *data_ptr = false; + void generate_inputs(const std::vector& target_input_static_shapes) override { + inputs.clear(); + const auto& model_inputs = function->inputs(); + for (size_t i = 0; i < model_inputs.size(); ++i) { + const auto& model_input = model_inputs[i]; + auto type = model_input.get_element_type(); + ov::Tensor tensor; + if (ov::element::boolean == type) { + tensor = ov::test::utils::create_and_fill_tensor(model_input.get_element_type(), target_input_static_shapes[i], 0, 0); } else { - ov::test::utils::fill_data_with_broadcast(scalar_1d, 0, {20.f}); + tensor = ov::test::utils::create_and_fill_tensor(model_input.get_element_type(), target_input_static_shapes[i], 0, 20); } - } else { - ov::test::utils::fill_data_with_broadcast(blob, 0, {20.f}); + inputs.insert({model_input.get_node_shared_ptr(), tensor}); } - return blob; } - InferenceEngine::SizeVector data_shape; - InferenceEngine::Precision data_prc; + ov::Shape data_shape; + ov::element::Type model_type; }; -TEST_P(StaticConditionSingleLayerGPUTest, CompareWithRefs) { - SKIP_IF_CURRENT_TEST_IS_DISABLED(); - Run(); +TEST_P(StaticConditionSingleLayerGPUTest, Inference) { + run(); } -std::vector netPrecisions_static_single = { - InferenceEngine::Precision::FP32, - InferenceEngine::Precision::FP16, - InferenceEngine::Precision::I8 +std::vector model_types_static_single = { + ov::element::f32, + ov::element::f16, + ov::element::i8 }; -std::vector inputs_shape_single = { +std::vector inputs_shape_single = { {64} }; INSTANTIATE_TEST_SUITE_P(smoke_ConditionGPUTest_static, StaticConditionSingleLayerGPUTest, testing::Combine( testing::ValuesIn(inputs_shape_single), - testing::ValuesIn(netPrecisions_static_single), + testing::ValuesIn(model_types_static_single), testing::ValuesIn(if_cond_types), testing::Values(ov::test::utils::DEVICE_GPU)), StaticConditionLayerGPUTest::getTestCaseName); @@ -730,25 +721,26 @@ struct InnerBodyTypeParams { InnerBodyGenerator::InnerBodyType else_body_type; }; +using ov::test::InputShape; + using ConditionGPUParams = typename std::tuple< InputShape, // Input Shapes InnerBodyTypeParams, // Inner body type - InferenceEngine::Precision, // Precision + ov::element::Type, // Type TestModelGenerator::PredicateTypes, // if predicate type - LayerTestsUtils::TargetDevice // Device name ->; + std::string>; // Device name class DynamicConditionLayerGPUTest : public testing::WithParamInterface, - virtual public SubgraphBaseTest { + virtual public ov::test::SubgraphBaseTest { public: static std::string getTestCaseName(const testing::TestParamInfo& obj) { InputShape inputShapes; InnerBodyTypeParams bodyParams; - InferenceEngine::Precision dataPrc; + ov::element::Type model_type; TestModelGenerator::PredicateTypes condType; std::string targetDevice; - std::tie(inputShapes, bodyParams, dataPrc, condType, targetDevice) = obj.param; + std::tie(inputShapes, bodyParams, model_type, condType, targetDevice) = obj.param; std::ostringstream result; result << "IS=("; result << ov::test::utils::partialShape2str({inputShapes.first}) << "_"; @@ -759,7 +751,7 @@ class DynamicConditionLayerGPUTest : public testing::WithParamInterface condSecondVec; for (size_t i = 0; i < num_second; i++) { @@ -782,11 +774,10 @@ class DynamicConditionLayerGPUTest : public testing::WithParamInterfaceset_friendly_name("if_operator_outer"); @@ -816,13 +807,7 @@ class DynamicConditionLayerGPUTest : public testing::WithParamInterfaceget_element_type(), input_shape, inGenData.range, - inGenData.start_from, inGenData.resolution, inGenData.seed); + auto tensor = ov::test::utils::create_and_fill_tensor(param->get_element_type(), input_shape, 10, 0, 128); inputs.insert({param, tensor}); } } @@ -832,18 +817,9 @@ class DynamicConditionLayerGPUTest : public testing::WithParamInterface netPrecisions_f32 = { - InferenceEngine::Precision::FP32 -}; - -const std::vector netPrecisions_f16 = { - InferenceEngine::Precision::FP16 -}; - const std::vector dynamicInputShapes_f32 = { ov::test::InputShape(ov::PartialShape({-1, -1, -1, -1, -1}), {{4, 1, 1, 64, 32}, {6, 1, 1, 8, 4}, {8, 1, 1, 24, 16}}), ov::test::InputShape(ov::PartialShape({1, 1, -1, -1}), {{1, 1, 64, 32}, {1, 1, 8, 4}, {1, 1, 24, 16}}) @@ -900,7 +876,7 @@ INSTANTIATE_TEST_SUITE_P(smoke_ConditionGPUTest_dynamic_f32, DynamicConditionLay testing::Combine( testing::ValuesIn(dynamicInputShapes_f32), // input shapes testing::ValuesIn(innerBodyTypes_f32), // inner body type - testing::ValuesIn(netPrecisions_f32), // network precision + testing::Values(ov::element::f32), // network precision testing::ValuesIn(condTypes), // cond type testing::Values(ov::test::utils::DEVICE_GPU)), // device type DynamicConditionLayerGPUTest::getTestCaseName); @@ -910,7 +886,7 @@ INSTANTIATE_TEST_SUITE_P(smoke_ConditionGPUTest_dynamic_f16, DynamicConditionLay testing::Combine( testing::ValuesIn(dynamicInputShapes_f16), // input shapes testing::ValuesIn(innerBodyTypes_f16), // inner body type - testing::ValuesIn(netPrecisions_f16), // network precision + testing::Values(ov::element::f16), // network precision testing::ValuesIn(condTypes), // cond type testing::Values(ov::test::utils::DEVICE_GPU)), // device type DynamicConditionLayerGPUTest::getTestCaseName); @@ -919,8 +895,8 @@ INSTANTIATE_TEST_SUITE_P(smoke_ConditionGPUTest_zero_dims, DynamicConditionLayer testing::Combine( testing::ValuesIn(dynamicInputShapes_zero_dims), // input shapes testing::ValuesIn(innerBodyTypes_zero_dims), // inner body type - testing::ValuesIn(netPrecisions_f32), // network precision + testing::Values(ov::element::f32), // network precision testing::ValuesIn(condTypes_zero_dims), // cond type testing::Values(ov::test::utils::DEVICE_GPU)), // device type DynamicConditionLayerGPUTest::getTestCaseName); -} // namespace GPULayerTestsDefinitions +} // namespace diff --git a/src/plugins/intel_gpu/tests/functional/subgraph_tests/dynamic/broadcast_eltwise.cpp b/src/plugins/intel_gpu/tests/functional/subgraph_tests/dynamic/broadcast_eltwise.cpp index 9030ea1129313d..65373ff1d76ff9 100644 --- a/src/plugins/intel_gpu/tests/functional/subgraph_tests/dynamic/broadcast_eltwise.cpp +++ b/src/plugins/intel_gpu/tests/functional/subgraph_tests/dynamic/broadcast_eltwise.cpp @@ -2,36 +2,35 @@ // SPDX-License-Identifier: Apache-2.0 // -#include -#include - -#include "ov_models/builders.hpp" -#include "ov_models/utils/ov_helpers.hpp" -#include "shared_test_classes/base/layer_test_utils.hpp" +#include "common_test_utils/ov_tensor_utils.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include "openvino/pass/serialize.hpp" -using namespace ngraph; -using namespace ov::test; -using namespace InferenceEngine; +#include "openvino/op/parameter.hpp" +#include "openvino/op/constant.hpp" +#include "openvino/op/result.hpp" +#include "openvino/op/add.hpp" +#include "openvino/op/broadcast.hpp" + +namespace { +using ov::test::InputShape; -namespace GPULayerTestsDefinitions { using BroadcastEltwiseParams = std::tuple< - ElementType, // input precision - InputShape, // input shape - ov::Shape // target broadcast shape + ov::element::Type, // input type + InputShape, // input shape + ov::Shape // target broadcast shape >; -class BroadcastEltwise : virtual public SubgraphBaseTest, public testing::WithParamInterface { +class BroadcastEltwise : virtual public ov::test::SubgraphBaseTest, + public testing::WithParamInterface { public: static std::string getTestCaseName(const testing::TestParamInfo& obj) { - ElementType input_precision; + ov::element::Type model_type; InputShape input_shape; ov::Shape target_shape; - std::tie(input_precision, input_shape, target_shape) = obj.param; + std::tie(model_type, input_shape, target_shape) = obj.param; std::ostringstream result; - result << "precision=" << input_precision << "IS=(" << ov::test::utils::partialShape2str({input_shape.first}) << ")_TS=("; + result << "precision=" << model_type << "IS=(" << ov::test::utils::partialShape2str({input_shape.first}) << ")_TS=("; for (const auto& item : input_shape.second) { result << ov::test::utils::vec2str(item) << "_"; } @@ -41,23 +40,23 @@ class BroadcastEltwise : virtual public SubgraphBaseTest, public testing::WithPa protected: void SetUp() override { - ElementType input_precision; + ov::element::Type model_type; InputShape input_shape; - std::tie(input_precision, input_shape, target_shape) = GetParam(); + std::tie(model_type, input_shape, target_shape) = GetParam(); targetDevice = ov::test::utils::DEVICE_GPU; std::vector input_shapes{input_shape, {{}, {{target_shape.size()}}}}; init_input_shapes(input_shapes); - ov::element::TypeVector input_precisions{input_precision, ov::element::i64}; + ov::element::TypeVector model_types{model_type, ov::element::i64}; ov::ParameterVector params; - for (size_t i = 0; i < input_precisions.size(); i++) { - auto param_node = std::make_shared(input_precisions[i], inputDynamicShapes[i]); + for (size_t i = 0; i < model_types.size(); i++) { + auto param_node = std::make_shared(model_types[i], inputDynamicShapes[i]); params.push_back(param_node); } - const auto bcast_data = ov::opset10::Constant::create(input_precision, {}, {1.f}); - const auto bcast = std::make_shared(bcast_data, params[1]); - const auto add = std::make_shared(params[0], bcast); + const auto bcast_data = ov::op::v0::Constant::create(model_type, {}, {1.f}); + const auto bcast = std::make_shared(bcast_data, params[1]); + const auto add = std::make_shared(params[0], bcast); function = std::make_shared(add, params); } @@ -95,7 +94,6 @@ TEST_P(BroadcastEltwise, smoke_CompareWithRefs) { EXPECT_EQ(last_input_layer_type, "broadcast"); } -namespace { const std::vector input_shapes = { {{-1, -1, -1, -1}, {{1, 3, 16, 16}}}, {{-1, -1}, {{16, 16}}}, @@ -113,4 +111,4 @@ INSTANTIATE_TEST_SUITE_P(smoke_BroadcastEltwise, ::testing::ValuesIn(target_shapes)), BroadcastEltwise::getTestCaseName); } // namespace -} // namespace GPULayerTestsDefinitions + diff --git a/src/plugins/intel_gpu/tests/functional/subgraph_tests/dynamic/dynamic_model_static_split_layer.cpp b/src/plugins/intel_gpu/tests/functional/subgraph_tests/dynamic/dynamic_model_static_split_layer.cpp index 658102694142a9..4f94d1a8dc2583 100644 --- a/src/plugins/intel_gpu/tests/functional/subgraph_tests/dynamic/dynamic_model_static_split_layer.cpp +++ b/src/plugins/intel_gpu/tests/functional/subgraph_tests/dynamic/dynamic_model_static_split_layer.cpp @@ -1,45 +1,39 @@ // Copyright (C) 2023 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // -#include -#include -#include -#include -#include "ov_models/utils/ov_helpers.hpp" -#include "ov_models/builders.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include "shared_test_classes/single_layer/split.hpp" -#include +#include "common_test_utils/ov_tensor_utils.hpp" +#include "common_test_utils/node_builders/eltwise.hpp" -using namespace ngraph; -using namespace InferenceEngine; -using namespace ov::test; +#include "openvino/op/parameter.hpp" +#include "openvino/op/constant.hpp" +#include "openvino/op/result.hpp" +#include "openvino/op/variadic_split.hpp" -namespace GPULayerTestsDefinitions { +namespace { +using ov::test::InputShape; typedef std::tuple< - std::vector, // input shapes - ElementType, // Network precision - TargetDevice, // Device name - std::map // Additional network configuration + std::vector, // input shapes + ov::element::Type, // Model type + std::string // Device name > DynamicModelStaticSplitLayerGPUTestParamsSet; -const std::vector netPrecisions = { - ElementType::f16 +const std::vector model_types = { + ov::element::f16 }; class DynamicModelStaticSplitLayerGPUTest : public testing::WithParamInterface, - virtual public SubgraphBaseTest { + virtual public ov::test::SubgraphBaseTest { public: static std::string getTestCaseName(const testing::TestParamInfo& obj) { DynamicModelStaticSplitLayerGPUTestParamsSet basicParamsSet = obj.param; std::ostringstream result; std::vector inputShapes; - ElementType netType; - TargetDevice targetDevice; - std::map additionalConfig; + ov::element::Type model_type; + std::string targetDevice; - std::tie(inputShapes, netType, targetDevice, additionalConfig) = basicParamsSet; + std::tie(inputShapes, model_type, targetDevice) = basicParamsSet; result << "IS="; for (const auto& shape : inputShapes) { result << ov::test::utils::partialShape2str({shape.first}) << "_"; @@ -47,13 +41,13 @@ class DynamicModelStaticSplitLayerGPUTest : public testing::WithParamInterfaceset_friendly_name("split_sizes"); - auto variadicSplitOp = std::make_shared(params[0], axis, split_sizes); + auto variadicSplitOp = std::make_shared(params[0], axis, split_sizes); variadicSplitOp->set_friendly_name("variadicSplit"); - auto addOp = ngraph::builder::makeEltwise(params[1], variadicSplitOp->output(1), ngraph::helpers::EltwiseTypes::ADD); + auto addOp = ov::test::utils::makeEltwise(params[1], variadicSplitOp->output(1), ov::test::utils::EltwiseTypes::ADD); addOp->set_friendly_name("add"); - ngraph::ResultVector results = {std::make_shared(addOp)}; - function = std::make_shared(results, params, "eltwise_add_out"); + ov::ResultVector results = {std::make_shared(addOp)}; + function = std::make_shared(results, params, "eltwise_add_out"); } }; - -TEST_P(DynamicModelStaticSplitLayerGPUTest, CompareWithRefs) { - SKIP_IF_CURRENT_TEST_IS_DISABLED() +TEST_P(DynamicModelStaticSplitLayerGPUTest, Inference) { run(); } -namespace { -std::map emptyAdditionalConfig; const std::vector> dynInputShapes = { { // Input for static VariadicSplit @@ -124,11 +113,9 @@ const std::vector> dynInputShapes = { const auto testParams_smoke = ::testing::Combine(::testing::ValuesIn(dynInputShapes), - ::testing::ValuesIn(netPrecisions), // netprec - ::testing::Values(ov::test::utils::DEVICE_GPU), - ::testing::Values(emptyAdditionalConfig)); + ::testing::ValuesIn(model_types), // netprec + ::testing::Values(ov::test::utils::DEVICE_GPU)); INSTANTIATE_TEST_SUITE_P(smoke_dynamic_model_static_split, DynamicModelStaticSplitLayerGPUTest, testParams_smoke, DynamicModelStaticSplitLayerGPUTest::getTestCaseName); } // namespace -} // namespace GPULayerTestsDefinitions diff --git a/src/plugins/intel_gpu/tests/functional/subgraph_tests/dynamic/dynamic_smoke_test_gen_impl_key.cpp b/src/plugins/intel_gpu/tests/functional/subgraph_tests/dynamic/dynamic_smoke_test_gen_impl_key.cpp index 66c8ebe1426ef9..8daf22f14d06d3 100644 --- a/src/plugins/intel_gpu/tests/functional/subgraph_tests/dynamic/dynamic_smoke_test_gen_impl_key.cpp +++ b/src/plugins/intel_gpu/tests/functional/subgraph_tests/dynamic/dynamic_smoke_test_gen_impl_key.cpp @@ -1,47 +1,43 @@ // Copyright (C) 2018-2023 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // -#include -#include -#include -#include -#include "ov_models/utils/ov_helpers.hpp" -#include "ov_models/builders.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include "shared_test_classes/single_layer/shape_of.hpp" -#include "shared_test_classes/single_layer/strided_slice.hpp" -#include -#include +#include "common_test_utils/ov_tensor_utils.hpp" +#include "common_test_utils/node_builders/eltwise.hpp" +#include "common_test_utils/node_builders/reduce.hpp" -using namespace ngraph; -using namespace InferenceEngine; -using namespace ov::test; +#include "openvino/op/parameter.hpp" +#include "openvino/op/constant.hpp" +#include "openvino/op/result.hpp" +#include "openvino/op/reshape.hpp" +#include "openvino/op/shape_of.hpp" -namespace GPULayerTestsDefinitions { +namespace { +using ov::test::InputShape; typedef std::tuple< std::vector, // input shapes - ElementType, // Network precision - TargetDevice, // Device name + ov::element::Type, // Model type + std::string, // Device name std::map // Additional network configuration > genImplKeyDynamicGPUTestParamsSet; -const std::vector netPrecisions = { - ElementType::f16, - ElementType::f32, - ElementType::i32, - ElementType::i64, +const std::vector model_types = { + ov::element::f16, + ov::element::f32, + ov::element::i32, + ov::element::i64, }; class GenlImplKeyDynamicGPUTest : public testing::WithParamInterface, - virtual public SubgraphBaseTest { + virtual public ov::test::SubgraphBaseTest { public: static std::string getTestCaseName(const testing::TestParamInfo& obj) { genImplKeyDynamicGPUTestParamsSet basicParamsSet = obj.param; std::ostringstream result; std::vector inputShapes; - ElementType netType; - TargetDevice targetDevice; + ov::element::Type netType; + std::string targetDevice; std::map additionalConfig; std::tie(inputShapes, netType, targetDevice, additionalConfig) = basicParamsSet; @@ -58,7 +54,7 @@ class GenlImplKeyDynamicGPUTest : public testing::WithParamInterface& targetInputStaticShapes) override { + void generate_inputs(const std::vector& targetInputStaticShapes) override { inputs.clear(); const auto& funcInputs = function->inputs(); for (size_t i = 0; i < funcInputs.size(); ++i) { @@ -66,9 +62,7 @@ class GenlImplKeyDynamicGPUTest : public testing::WithParamInterfaceGetParam(); std::vector inputShapes; - ElementType netType; + ov::element::Type netType; std::map additionalConfig; std::tie(inputShapes, netType, targetDevice, additionalConfig) = basicParamsSet; @@ -87,64 +81,60 @@ class GenlImplKeyDynamicGPUTest : public testing::WithParamInterface(netType, shape)); - auto addOp1 = ngraph::builder::makeEltwise(params[1], params[1], ngraph::helpers::EltwiseTypes::ADD); + auto addOp1 = ov::test::utils::makeEltwise(params[1], params[1], ov::test::utils::EltwiseTypes::ADD); addOp1->set_friendly_name("add1"); - auto shapeOfOp1 = std::make_shared(addOp1, ElementType::i64); + auto shapeOfOp1 = std::make_shared(addOp1, ov::element::i64); shapeOfOp1->set_friendly_name("shapeof1"); std::vector reduce_axes = {0}; - auto reduceAxesNode1 = std::dynamic_pointer_cast( - std::make_shared(ngraph::element::Type_t::i64, ngraph::Shape({1}), reduce_axes)); - auto reduceOp1 = ngraph::builder::makeReduce(shapeOfOp1, reduceAxesNode1, true, ngraph::helpers::ReductionType::Prod); + auto reduceAxesNode1 = std::dynamic_pointer_cast( + std::make_shared(ov::element::i64, ov::Shape({1}), reduce_axes)); + auto reduceOp1 = ov::test::utils::make_reduce(shapeOfOp1, reduceAxesNode1, true, ov::test::utils::ReductionType::Prod); reduceOp1->set_friendly_name("reduce1"); std::vector shapePatternFill = {-1}; - auto reshapePatternComp1 = std::make_shared(ngraph::element::Type_t::i64, - ngraph::Shape{1}, shapePatternFill); + auto reshapePatternComp1 = std::make_shared(ov::element::i64, + ov::Shape{1}, shapePatternFill); auto concatOp1 = std::make_shared(ov::NodeVector{reduceOp1, reshapePatternComp1}, 0); concatOp1->set_friendly_name("concat1"); - auto reshapeOp1 = std::make_shared(addOp1, concatOp1, false); + auto reshapeOp1 = std::make_shared(addOp1, concatOp1, false); reshapeOp1->set_friendly_name("reshapeOp1"); - auto addOp2 = ngraph::builder::makeEltwise(params[1], params[1], ngraph::helpers::EltwiseTypes::ADD); + auto addOp2 = ov::test::utils::makeEltwise(params[1], params[1], ov::test::utils::EltwiseTypes::ADD); addOp2->set_friendly_name("add2"); - auto shapeOfOp2 = std::make_shared(addOp2, ElementType::i64); + auto shapeOfOp2 = std::make_shared(addOp2, ov::element::i64); shapeOfOp2->set_friendly_name("shapeof2"); - auto reduceAxesNode2 = std::dynamic_pointer_cast( - std::make_shared(ngraph::element::Type_t::i64, ngraph::Shape({1}), reduce_axes)); - auto reduceOp2 = ngraph::builder::makeReduce(shapeOfOp2, reduceAxesNode2, true, ngraph::helpers::ReductionType::Prod); + auto reduceAxesNode2 = std::make_shared(ov::element::i64, ov::Shape({1}), reduce_axes); + auto reduceOp2 = ov::test::utils::make_reduce(shapeOfOp2, reduceAxesNode2, true, ov::test::utils::ReductionType::Prod); reduceOp2->set_friendly_name("reduce2"); - auto reshapePatternComp2 = std::make_shared(ngraph::element::Type_t::i64, - ngraph::Shape{1}, shapePatternFill); + auto reshapePatternComp2 = std::make_shared(ov::element::i64, + ov::Shape{1}, shapePatternFill); auto concatOp2 = std::make_shared(ov::NodeVector{reduceOp2, reshapePatternComp2}, 0); concatOp2->set_friendly_name("concat2"); - auto reshapeOp2 = std::make_shared(addOp2, concatOp2, false); + auto reshapeOp2 = std::make_shared(addOp2, concatOp2, false); reshapeOp2->set_friendly_name("reshapeOp2"); - auto addOp3 = ngraph::builder::makeEltwise(reshapeOp1, reshapeOp2, ngraph::helpers::EltwiseTypes::ADD); + auto addOp3 = ov::test::utils::makeEltwise(reshapeOp1, reshapeOp2, ov::test::utils::EltwiseTypes::ADD); addOp3->set_friendly_name("add3"); - auto shapeOf3 = std::make_shared(addOp3, ElementType::i64); + auto shapeOf3 = std::make_shared(addOp3, ov::element::i64); shapeOf3->set_friendly_name("shapeof3"); - ngraph::ResultVector results = {std::make_shared(shapeOf3)}; - function = std::make_shared(results, params, "shapeof_out"); + ov::ResultVector results = {std::make_shared(shapeOf3)}; + function = std::make_shared(results, params, "shapeof_out"); } }; - -TEST_P(GenlImplKeyDynamicGPUTest, CompareWithRefs) { - SKIP_IF_CURRENT_TEST_IS_DISABLED() +TEST_P(GenlImplKeyDynamicGPUTest, Inference) { run(); } -namespace { std::map emptyAdditionalConfig; const std::vector> dynInputShapes = { // 1D @@ -177,13 +167,11 @@ const std::vector> dynInputShapes = { } }; - const auto testParams_smoke = ::testing::Combine(::testing::ValuesIn(dynInputShapes), - ::testing::ValuesIn(netPrecisions), // netprec + ::testing::ValuesIn(model_types), ::testing::Values(ov::test::utils::DEVICE_GPU), ::testing::Values(emptyAdditionalConfig)); INSTANTIATE_TEST_SUITE_P(smoke_dynamic_impl_key, GenlImplKeyDynamicGPUTest, testParams_smoke, GenlImplKeyDynamicGPUTest::getTestCaseName); } // namespace -} // namespace GPULayerTestsDefinitions diff --git a/src/plugins/intel_gpu/tests/functional/subgraph_tests/dynamic/dynamic_smoke_test_reduce_deconvolution_concat.cpp b/src/plugins/intel_gpu/tests/functional/subgraph_tests/dynamic/dynamic_smoke_test_reduce_deconvolution_concat.cpp index 8a76b155c1359c..83eb58eb77712b 100644 --- a/src/plugins/intel_gpu/tests/functional/subgraph_tests/dynamic/dynamic_smoke_test_reduce_deconvolution_concat.cpp +++ b/src/plugins/intel_gpu/tests/functional/subgraph_tests/dynamic/dynamic_smoke_test_reduce_deconvolution_concat.cpp @@ -1,48 +1,42 @@ // Copyright (C) 2018-2023 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // -#include -#include -#include -#include -#include "ov_models/utils/ov_helpers.hpp" -#include "ov_models/builders.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include "shared_test_classes/single_layer/reduce_ops.hpp" -#include "shared_test_classes/single_layer/convolution_backprop_data.hpp" -#include -#include +#include "common_test_utils/ov_tensor_utils.hpp" +#include "common_test_utils/node_builders/reduce.hpp" +#include "common_test_utils/node_builders/convolution_backprop_data.hpp" -using namespace ngraph; -using namespace InferenceEngine; -using namespace ov::test; +#include "openvino/op/parameter.hpp" +#include "openvino/op/constant.hpp" +#include "openvino/op/result.hpp" +#include "openvino/op/concat.hpp" +#include "openvino/op/transpose.hpp" -namespace GPULayerTestsDefinitions { +namespace { +using ov::test::InputShape; typedef std::tuple< std::vector, // input shapes - ElementType, // Network precision - TargetDevice, // Device name - std::map // Additional network configuration + ov::element::Type, // Network precision + std::string // Device name > reduceDeconvConcatDynamicGPUTestParamsSet; -const std::vector netPrecisions = { - ElementType::f16, +const std::vector netPrecisions = { + ov::element::f16, }; // Reduce should have preferred format for ouput layout class ReduceDeconvConcatDynamicGPUTest : public testing::WithParamInterface, - virtual public SubgraphBaseTest { + virtual public ov::test::SubgraphBaseTest { public: static std::string getTestCaseName(const testing::TestParamInfo& obj) { reduceDeconvConcatDynamicGPUTestParamsSet basicParamsSet = obj.param; std::ostringstream result; std::vector inputShapes; - ElementType netType; - TargetDevice targetDevice; - std::map additionalConfig; + ov::element::Type model_type; + std::string targetDevice; - std::tie(inputShapes, netType, targetDevice, additionalConfig) = basicParamsSet; + std::tie(inputShapes, model_type, targetDevice) = basicParamsSet; result << "IS="; for (const auto& shape : inputShapes) { result << ov::test::utils::partialShape2str({shape.first}) << "_"; @@ -50,13 +44,13 @@ class ReduceDeconvConcatDynamicGPUTest : public testing::WithParamInterface reduce_axes = {5}; - auto reduceAxesNode = std::dynamic_pointer_cast( - std::make_shared(ngraph::element::Type_t::i64, ngraph::Shape({1}), reduce_axes)); - auto reduceOp = ngraph::builder::makeReduce(params[1], reduceAxesNode, false, ngraph::helpers::ReductionType::Max); + auto reduceAxesNode = std::make_shared(ov::element::i64, ov::Shape({1}), reduce_axes); + auto reduceOp = ov::test::utils::make_reduce(params[1], reduceAxesNode, false, ov::test::utils::ReductionType::Max); reduceOp->set_friendly_name("reduce"); auto concatOp = std::make_shared(ov::NodeVector{deconvOp, reduceOp}, 1); concatOp->set_friendly_name("concat"); std::vector transpose_order = {0, 1, 2, 4, 3}; - auto transposeOrderNode = std::dynamic_pointer_cast( - std::make_shared(ngraph::element::Type_t::i64, ngraph::Shape({5}), transpose_order)); - auto transposeOp = std::make_shared(concatOp, transposeOrderNode); + auto transposeOrderNode = std::make_shared(ov::element::i64, ov::Shape({5}), transpose_order); + auto transposeOp = std::make_shared(concatOp, transposeOrderNode); transposeOp->set_friendly_name("transpose"); - ngraph::ResultVector results = {std::make_shared(transposeOp)}; - function = std::make_shared(results, params, "transpose_out"); + ov::ResultVector results = {std::make_shared(transposeOp)}; + function = std::make_shared(results, params, "transpose_out"); } }; - -TEST_P(ReduceDeconvConcatDynamicGPUTest, CompareWithRefs) { - SKIP_IF_CURRENT_TEST_IS_DISABLED() +TEST_P(ReduceDeconvConcatDynamicGPUTest, Inference) { run(); } -namespace { -std::map emptyAdditionalConfig; const std::vector> dynInputShapes = { { // Input for Deconv @@ -128,10 +113,8 @@ const std::vector> dynInputShapes = { const auto testParams_smoke = ::testing::Combine(::testing::ValuesIn(dynInputShapes), ::testing::ValuesIn(netPrecisions), // netprec - ::testing::Values(ov::test::utils::DEVICE_GPU), - ::testing::Values(emptyAdditionalConfig)); + ::testing::Values(ov::test::utils::DEVICE_GPU)); INSTANTIATE_TEST_SUITE_P(smoke_dynamic_reduce_deconv_concat, ReduceDeconvConcatDynamicGPUTest, testParams_smoke, ReduceDeconvConcatDynamicGPUTest::getTestCaseName); } // namespace -} // namespace GPULayerTestsDefinitions diff --git a/src/plugins/intel_gpu/tests/functional/subgraph_tests/dynamic/dynamic_smoke_test_shape_of_activation.cpp b/src/plugins/intel_gpu/tests/functional/subgraph_tests/dynamic/dynamic_smoke_test_shape_of_activation.cpp index 1a611f1f3060e2..3e35dc0023937b 100644 --- a/src/plugins/intel_gpu/tests/functional/subgraph_tests/dynamic/dynamic_smoke_test_shape_of_activation.cpp +++ b/src/plugins/intel_gpu/tests/functional/subgraph_tests/dynamic/dynamic_smoke_test_shape_of_activation.cpp @@ -1,55 +1,47 @@ // Copyright (C) 2018-2023 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // -#include -#include -#include -#include -#include "ov_models/utils/ov_helpers.hpp" -#include "ov_models/builders.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include "shared_test_classes/single_layer/shape_of.hpp" -#include "shared_test_classes/single_layer/reshape.hpp" -#include "shared_test_classes/single_layer/gather.hpp" -#include "shared_test_classes/single_layer/activation.hpp" -#include +#include "common_test_utils/ov_tensor_utils.hpp" +#include "common_test_utils/node_builders/activation.hpp" -using namespace ngraph; -using namespace InferenceEngine; -using namespace ov::test; +#include "openvino/op/parameter.hpp" +#include "openvino/op/constant.hpp" +#include "openvino/op/result.hpp" +#include "openvino/op/reshape.hpp" +#include "openvino/op/shape_of.hpp" -namespace GPULayerTestsDefinitions { +namespace { +using ov::test::InputShape; typedef std::tuple< InputShape, // input shapes - ElementType, // Network precision - TargetDevice, // Device name - ngraph::helpers::ActivationTypes, // Activation type + ov::element::Type, // Network precision + std::string, // Device name + ov::test::utils::ActivationTypes, // Activation type std::vector, //inShape - std::vector, //constantValue - std::map // Additional network configuration + std::vector //constantValue > shapeofActivationDynamicGPUTestParamsSet; -const std::vector netPrecisions = { - ElementType::f16, - ElementType::f32, +const std::vector model_types = { + ov::element::f16, + ov::element::f32, }; class shapeofActivationDynamicGPUTest : public testing::WithParamInterface, - virtual public SubgraphBaseTest { + virtual public ov::test::SubgraphBaseTest { public: static std::string getTestCaseName(const testing::TestParamInfo& obj) { shapeofActivationDynamicGPUTestParamsSet basicParamsSet = obj.param; std::ostringstream result; InputShape inputShape; - ElementType netType; - TargetDevice targetDevice; - ngraph::helpers::ActivationTypes activationType; + ov::element::Type netType; + std::string targetDevice; + ov::test::utils::ActivationTypes activationType; std::vector inShape; std::vector constantValue; - std::map additionalConfig; - std::tie(inputShape, netType, targetDevice, activationType, inShape, constantValue, additionalConfig) = basicParamsSet; + std::tie(inputShape, netType, targetDevice, activationType, inShape, constantValue) = basicParamsSet; result << "IS="; result << ov::test::utils::partialShape2str({inputShape.first}) << "_"; for (const auto& actual_shape : inputShape.second) { @@ -64,7 +56,7 @@ class shapeofActivationDynamicGPUTest : public testing::WithParamInterface& targetInputStaticShapes) override { + void generate_inputs(const std::vector& targetInputStaticShapes) override { inputs.clear(); const auto& funcInputs = function->inputs(); for (size_t i = 0; i < funcInputs.size(); ++i) { @@ -82,12 +74,11 @@ class shapeofActivationDynamicGPUTest : public testing::WithParamInterfaceGetParam(); InputShape inputShape; - ElementType netType; - ngraph::helpers::ActivationTypes activationType; + ov::element::Type netType; + ov::test::utils::ActivationTypes activationType; std::vector inShape; std::vector constantValue; - std::map additionalConfig; - std::tie(inputShape, netType, targetDevice, activationType, inShape, constantValue, additionalConfig) = basicParamsSet; + std::tie(inputShape, netType, targetDevice, activationType, inShape, constantValue) = basicParamsSet; init_input_shapes({inputShape}); @@ -96,46 +87,40 @@ class shapeofActivationDynamicGPUTest : public testing::WithParamInterface(netType, shape)); std::vector shape_pattern = {0, 1, -1, 0}; - auto shapePatternsNode = std::dynamic_pointer_cast( - std::make_shared(ngraph::element::Type_t::i64, ngraph::Shape({4}), shape_pattern)); - auto reshapeOp = std::make_shared(params[0], shapePatternsNode, true); + auto shapePatternsNode = std::make_shared(ov::element::i64, ov::Shape({4}), shape_pattern); + auto reshapeOp = std::make_shared(params[0], shapePatternsNode, true); reshapeOp->set_friendly_name("reshape"); - auto shapeOfOp = std::make_shared(reshapeOp, ElementType::i32); + auto shapeOfOp = std::make_shared(reshapeOp, ov::element::i32); shapeOfOp->set_friendly_name("shapeof"); std::vector indices = {0}; - auto indicesNode = std::dynamic_pointer_cast( - std::make_shared(ngraph::element::Type_t::i32, ngraph::Shape({1}), indices)); + auto indicesNode = std::make_shared(ov::element::i32, ov::Shape({1}), indices); std::vector axis = {-1}; - auto axisNode = std::dynamic_pointer_cast( - std::make_shared(ngraph::element::Type_t::i32, ngraph::Shape({1}), axis)); + auto axisNode = std::make_shared(ov::element::i32, ov::Shape({1}), axis); auto gatherOp = std::make_shared(shapeOfOp, indicesNode, axisNode, 0); gatherOp->set_friendly_name("gather"); - auto convertOp = std::make_shared(gatherOp, ElementType::f32); + auto convertOp = std::make_shared(gatherOp, ov::element::f32); convertOp->set_friendly_name("convert"); - auto activationOp = ngraph::builder::makeActivation(convertOp, - netType, - activationType, - inShape, - constantValue); + auto activationOp = ov::test::utils::make_activation(convertOp, + netType, + activationType, + inShape, + constantValue); activationOp->set_friendly_name("sqrt"); - ngraph::ResultVector results = {std::make_shared(activationOp)}; - function = std::make_shared(results, params, "result"); + ov::ResultVector results = {std::make_shared(activationOp)}; + function = std::make_shared(results, params, "result"); } }; -TEST_P(shapeofActivationDynamicGPUTest, CompareWithRefs) { - SKIP_IF_CURRENT_TEST_IS_DISABLED() +TEST_P(shapeofActivationDynamicGPUTest, Inference) { run(); } -namespace { -std::map emptyAdditionalConfig; std::vector inShapesDynamic4d = { { {-1, -1, 1, 64}, @@ -159,15 +144,13 @@ std::vector inShape_sqrt = {}; std::vector constantValue_sqrt = {}; const auto testParams_sqrt = ::testing::Combine(::testing::ValuesIn(inShapesDynamic4d), - ::testing::ValuesIn(netPrecisions), // netprec + ::testing::ValuesIn(model_types), // netprec ::testing::Values(ov::test::utils::DEVICE_GPU), - ::testing::Values(ngraph::helpers::ActivationTypes::Sqrt), + ::testing::Values(ov::test::utils::ActivationTypes::Sqrt), ::testing::Values(inShape_sqrt), - ::testing::Values(constantValue_sqrt), - ::testing::Values(emptyAdditionalConfig)); + ::testing::Values(constantValue_sqrt)); // Activation type Sqrt should be supported in activation cpu_impl whic is selected after shapeOf INSTANTIATE_TEST_SUITE_P(smoke_dynamic_shapeof_activation_sqrt, shapeofActivationDynamicGPUTest, testParams_sqrt, shapeofActivationDynamicGPUTest::getTestCaseName); -} // namespace -} // namespace GPULayerTestsDefinitions +} // namespace \ No newline at end of file diff --git a/src/plugins/intel_gpu/tests/functional/subgraph_tests/dynamic/dynamic_smoke_test_shape_of_reduce_reshape.cpp b/src/plugins/intel_gpu/tests/functional/subgraph_tests/dynamic/dynamic_smoke_test_shape_of_reduce_reshape.cpp index 456c627c38facb..9965777b79896b 100644 --- a/src/plugins/intel_gpu/tests/functional/subgraph_tests/dynamic/dynamic_smoke_test_shape_of_reduce_reshape.cpp +++ b/src/plugins/intel_gpu/tests/functional/subgraph_tests/dynamic/dynamic_smoke_test_shape_of_reduce_reshape.cpp @@ -1,50 +1,44 @@ // Copyright (C) 2018-2023 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // -#include -#include -#include -#include -#include "ov_models/utils/ov_helpers.hpp" -#include "ov_models/builders.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include "shared_test_classes/single_layer/shape_of.hpp" -#include "shared_test_classes/single_layer/strided_slice.hpp" -#include -#include +#include "common_test_utils/ov_tensor_utils.hpp" +#include "common_test_utils/node_builders/eltwise.hpp" +#include "common_test_utils/node_builders/reduce.hpp" -using namespace ngraph; -using namespace InferenceEngine; -using namespace ov::test; +#include "openvino/op/parameter.hpp" +#include "openvino/op/constant.hpp" +#include "openvino/op/result.hpp" +#include "openvino/op/reshape.hpp" +#include "openvino/op/shape_of.hpp" -namespace GPULayerTestsDefinitions { +namespace { +using ov::test::InputShape; typedef std::tuple< std::vector, // input shapes - ElementType, // Network precision - TargetDevice, // Device name - std::map // Additional network configuration + ov::element::Type, // Network precision + std::string // Device name > shapeOfReshapeReduceDynamicGPUTestParamsSet; -const std::vector netPrecisions = { - ElementType::f16, - ElementType::f32, - ElementType::i32, - ElementType::i64, +const std::vector model_types = { + ov::element::f16, + ov::element::f32, + ov::element::i32, + ov::element::i64, }; class ShapeOfReshapeReduceDynamicGPUTest : public testing::WithParamInterface, - virtual public SubgraphBaseTest { + virtual public ov::test::SubgraphBaseTest { public: static std::string getTestCaseName(const testing::TestParamInfo& obj) { shapeOfReshapeReduceDynamicGPUTestParamsSet basicParamsSet = obj.param; std::ostringstream result; std::vector inputShapes; - ElementType netType; - TargetDevice targetDevice; - std::map additionalConfig; + ov::element::Type model_type; + std::string targetDevice; - std::tie(inputShapes, netType, targetDevice, additionalConfig) = basicParamsSet; + std::tie(inputShapes, model_type, targetDevice) = basicParamsSet; result << "IS="; for (const auto& shape : inputShapes) { result << ov::test::utils::partialShape2str({shape.first}) << "_"; @@ -52,13 +46,13 @@ class ShapeOfReshapeReduceDynamicGPUTest : public testing::WithParamInterface(params[0], ElementType::i64); + auto shapeOfOp1 = std::make_shared(params[0], ov::element::i64); shapeOfOp1->set_friendly_name("shapeof1"); std::vector reduce_axes = {0}; - auto reduceAxesNode = std::dynamic_pointer_cast( - std::make_shared(ngraph::element::Type_t::i64, ngraph::Shape({1}), reduce_axes)); - auto reduceOp = ngraph::builder::makeReduce(shapeOfOp1, reduceAxesNode, true, ngraph::helpers::ReductionType::Prod); + auto reduceAxesNode = std::make_shared(ov::element::i64, ov::Shape({1}), reduce_axes); + auto reduceOp = ov::test::utils::make_reduce(shapeOfOp1, reduceAxesNode, true, ov::test::utils::ReductionType::Prod); reduceOp->set_friendly_name("reduce"); std::vector shapePatternFill = {-1}; - auto reshapePatternComp = std::make_shared(ngraph::element::Type_t::i64, - ngraph::Shape{1}, shapePatternFill); + auto reshapePatternComp = std::make_shared(ov::element::i64, ov::Shape{1}, shapePatternFill); auto concatOp = std::make_shared(ov::NodeVector{reduceOp, reshapePatternComp}, 0); concatOp->set_friendly_name("concat"); - auto reshapeOp = std::make_shared(addOp, concatOp, false); + auto reshapeOp = std::make_shared(addOp, concatOp, false); - auto shapeOf2 = std::make_shared(reshapeOp, ElementType::i64); + auto shapeOf2 = std::make_shared(reshapeOp, ov::element::i64); shapeOf2->set_friendly_name("shapeof2"); - ngraph::ResultVector results = {std::make_shared(shapeOf2)}; - function = std::make_shared(results, params, "shapeof_out"); + ov::ResultVector results = {std::make_shared(shapeOf2)}; + function = std::make_shared(results, params, "shapeof_out"); } }; - -TEST_P(ShapeOfReshapeReduceDynamicGPUTest, CompareWithRefs) { - SKIP_IF_CURRENT_TEST_IS_DISABLED() +TEST_P(ShapeOfReshapeReduceDynamicGPUTest, Inference) { run(); } -namespace { -std::map emptyAdditionalConfig; const std::vector> dynInputShapes = { // 1D { @@ -152,13 +137,10 @@ const std::vector> dynInputShapes = { } }; - const auto testParams_smoke = ::testing::Combine(::testing::ValuesIn(dynInputShapes), - ::testing::ValuesIn(netPrecisions), // netprec - ::testing::Values(ov::test::utils::DEVICE_GPU), - ::testing::Values(emptyAdditionalConfig)); + ::testing::ValuesIn(model_types), // netprec + ::testing::Values(ov::test::utils::DEVICE_GPU)); INSTANTIATE_TEST_SUITE_P(smoke_dynamic_shapeof_reshape, ShapeOfReshapeReduceDynamicGPUTest, testParams_smoke, ShapeOfReshapeReduceDynamicGPUTest::getTestCaseName); } // namespace -} // namespace GPULayerTestsDefinitions 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 a85c6089461430..398eb1ab8ee429 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 @@ -1,48 +1,41 @@ // Copyright (C) 2023 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // -#include -#include -#include -#include -#include "ov_models/utils/ov_helpers.hpp" -#include "ov_models/builders.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include "shared_test_classes/single_layer/shape_of.hpp" -#include "shared_test_classes/single_layer/strided_slice.hpp" -#include -#include "shared_test_classes/single_layer/gather.hpp" -#include +#include "common_test_utils/ov_tensor_utils.hpp" -using namespace ngraph; -using namespace InferenceEngine; -using namespace ov::test; +#include "openvino/op/parameter.hpp" +#include "openvino/op/constant.hpp" +#include "openvino/op/result.hpp" +#include "openvino/op/shape_of.hpp" +#include "openvino/op/non_zero.hpp" +#include "openvino/op/squeeze.hpp" +#include "openvino/op/gather.hpp" -namespace GPULayerTestsDefinitions { +namespace { +using ov::test::InputShape; typedef std::tuple< std::vector, // input shapes - ElementType, // Network precision - TargetDevice, // Device name - std::map // Additional network configuration + ov::element::Type, // Network precision + std::string // Device name > emptyTensorTestParamsSet; -const std::vector netPrecisions = { - ElementType::i32, +const std::vector netPrecisions = { + ov::element::i32, }; class EmptyTensorDynamicGPUTest : public testing::WithParamInterface, - virtual public SubgraphBaseTest { + virtual public ov::test::SubgraphBaseTest { public: static std::string getTestCaseName(const testing::TestParamInfo& obj) { emptyTensorTestParamsSet basicParamsSet = obj.param; std::ostringstream result; std::vector inputShapes; - ElementType netType; - TargetDevice targetDevice; - std::map additionalConfig; + ov::element::Type netType; + std::string targetDevice; - std::tie(inputShapes, netType, targetDevice, additionalConfig) = basicParamsSet; + std::tie(inputShapes, netType, targetDevice) = basicParamsSet; result << "IS="; for (const auto& shape : inputShapes) { result << ov::test::utils::partialShape2str({shape.first}) << "_"; @@ -56,7 +49,7 @@ class EmptyTensorDynamicGPUTest : public testing::WithParamInterface& targetInputStaticShapes) override { + void generate_inputs(const std::vector& targetInputStaticShapes) override { inputs.clear(); const auto& funcInputs = function->inputs(); for (size_t i = 0; i < funcInputs.size(); ++i) { @@ -72,9 +65,7 @@ class EmptyTensorDynamicGPUTest : public testing::WithParamInterfaceGetParam(); std::vector inputShapes; - ElementType netType; - std::map additionalConfig; - std::tie(inputShapes, netType, targetDevice, additionalConfig) = basicParamsSet; + ov::element::Type netType; + std::tie(inputShapes, netType, targetDevice) = basicParamsSet; init_input_shapes(inputShapes); const auto AllZeroData = inputDynamicShapes[0]; @@ -94,10 +84,9 @@ class EmptyTensorDynamicGPUTest : public testing::WithParamInterface(netType, shape)); - const ElementType intInputsPrecision = ElementType::i32; - auto nonzeroEmptyResultOp = std::make_shared(params[0]); + auto nonzeroEmptyResultOp = std::make_shared(params[0]); - auto convertEmptyInputOp = std::make_shared(nonzeroEmptyResultOp, ElementType::i32); + auto convertEmptyInputOp = std::make_shared(nonzeroEmptyResultOp, ov::element::i32); auto concatPartialInputEmptyOp = std::make_shared(ov::NodeVector{convertEmptyInputOp, params[1], convertEmptyInputOp}, 1); // partially empty input / non empty output @@ -106,32 +95,28 @@ class EmptyTensorDynamicGPUTest : public testing::WithParamInterface squeezeDims = {0}; - auto squeezeDimsConst = - std::make_shared(ngraph::element::Type_t::i32, ngraph::Shape{1}, squeezeDims); + auto squeezeDimsConst = std::make_shared(ov::element::i32, ov::Shape{1}, squeezeDims); + + auto squeezeEmptyInputOp = std::make_shared(nonzeroEmptyResultOp, squeezeDimsConst); + + auto axisNode = std::make_shared(ov::element::i32, ov::Shape({1}), std::vector{0}); + auto gatherEmptyIndicesOp = std::make_shared(params[0], squeezeEmptyInputOp, axisNode, 0); - auto squeezeEmptyInputOp = std::make_shared(nonzeroEmptyResultOp, squeezeDimsConst); + auto shapeofEmptyInputOp = std::make_shared(gatherEmptyIndicesOp, ov::element::i32); - auto axisNode = ngraph::builder::makeConstant(intInputsPrecision, ov::Shape({1}), {0}); - auto gatherEmptyIndicesOp = - std::make_shared(params[0], squeezeEmptyInputOp, axisNode, 0); - auto shapeofEmptyInputOp = std::make_shared(gatherEmptyIndicesOp, ElementType::i32); - ngraph::ResultVector results = {std::make_shared(shapeofEmptyInputOp), - std::make_shared(concatPartialInputEmptyOp), - std::make_shared(concatEmptyInputEmptyOutputOp)}; - function = std::make_shared(results, params, "result"); + ov::ResultVector results = {std::make_shared(shapeofEmptyInputOp), + std::make_shared(concatPartialInputEmptyOp), + std::make_shared(concatEmptyInputEmptyOutputOp)}; + function = std::make_shared(results, params, "result"); - auto nonzero = std::make_shared(params[0]); + auto nonzero = std::make_shared(params[0]); } }; - -TEST_P(EmptyTensorDynamicGPUTest, CompareWithRefs) { - SKIP_IF_CURRENT_TEST_IS_DISABLED() +TEST_P(EmptyTensorDynamicGPUTest, Inference) { run(); } -namespace { -std::map emptyAdditionalConfig; const std::vector> dynInputShapes = { { // Input for NonZero @@ -141,13 +126,10 @@ const std::vector> dynInputShapes = { }, }; - const auto testParams_smoke = ::testing::Combine(::testing::ValuesIn(dynInputShapes), ::testing::ValuesIn(netPrecisions), // netprec - ::testing::Values(ov::test::utils::DEVICE_GPU), - ::testing::Values(emptyAdditionalConfig)); + ::testing::Values(ov::test::utils::DEVICE_GPU)); INSTANTIATE_TEST_SUITE_P(smoke_empty_tensor, EmptyTensorDynamicGPUTest, testParams_smoke, EmptyTensorDynamicGPUTest::getTestCaseName); } // namespace -} // namespace GPULayerTestsDefinitions 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 d3fea8828b2bd0..a347261d756d12 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 @@ -2,37 +2,31 @@ // SPDX-License-Identifier: Apache-2.0 // +#include "shared_test_classes/base/ov_subgraph.hpp" #include "common_test_utils/ov_tensor_utils.hpp" #include "common_test_utils/file_utils.hpp" -#include "openvino/core/node_vector.hpp" -#include "openvino/core/partial_shape.hpp" -#include "openvino/core/preprocess/pre_post_process.hpp" -#include "openvino/op/concat.hpp" -#include "openvino/op/matmul.hpp" -#include "openvino/op/parameter.hpp" -#include "openvino/op/transpose.hpp" -#include "shared_test_classes/base/layer_test_utils.hpp" -#include "shared_test_classes/base/ov_subgraph.hpp" -#include "shared_test_classes/base/utils/compare_results.hpp" -#include "transformations/rt_info/decompression.hpp" #include "subgraphs_builders.hpp" +#include "ov_models/utils/ov_helpers.hpp" +#include "shared_test_classes/base/utils/compare_results.hpp" -using namespace ov::test; +#include "openvino/op/parameter.hpp" +#include "openvino/op/result.hpp" +#include "openvino/op/convert.hpp" -namespace SubgraphTestsDefinitions { +namespace { +using ov::test::InputShape; using KVCacheTestParams = std::tuple, // input shapes - ov::element::Type, // in/out precision - std::map>; // additional config + ov::element::Type>; // in/out type -class KVCacheTest : public testing::WithParamInterface, public SubgraphBaseTest { +class KVCacheTest : public testing::WithParamInterface, + virtual public ov::test::SubgraphBaseTest { public: static std::string get_test_case_name(testing::TestParamInfo obj) { std::vector input_shapes; ov::element::Type element_type; - std::map additional_config; - std::tie(input_shapes, element_type, additional_config) = obj.param; + std::tie(input_shapes, element_type) = obj.param; std::ostringstream result; for (const auto& shape : input_shapes) { @@ -49,13 +43,7 @@ class KVCacheTest : public testing::WithParamInterface, publi } result << ")_"; } - result << "precision=" << element_type << "_"; - result << "config=("; - for (const auto& configEntry : additional_config) { - result << configEntry.first << ", " << configEntry.second << ":"; - } - result << ")"; - + result << "precision=" << element_type; return result.str(); } @@ -65,11 +53,9 @@ class KVCacheTest : public testing::WithParamInterface, publi std::vector input_shapes; ov::element::Type element_type; - std::map additional_config; - std::tie(input_shapes, element_type, additional_config) = GetParam(); + std::tie(input_shapes, element_type) = GetParam(); - configuration.insert(additional_config.begin(), additional_config.end()); init_input_shapes(input_shapes); inType = outType = element_type; @@ -78,14 +64,11 @@ class KVCacheTest : public testing::WithParamInterface, publi } }; -TEST_P(KVCacheTest, CompareWithRefs) { - SKIP_IF_CURRENT_TEST_IS_DISABLED() +TEST_P(KVCacheTest, Inference) { run(); } -TEST_P(KVCacheTest, CompareWithRefs_cached) { - SKIP_IF_CURRENT_TEST_IS_DISABLED() - +TEST_P(KVCacheTest, Inference_cached) { std::stringstream ss; ss << "gpu_model_cache_" << std::hash{}( std::string(::testing::UnitTest::GetInstance()->current_test_info()->test_suite_name()) + @@ -106,8 +89,6 @@ TEST_P(KVCacheTest, CompareWithRefs_cached) { } } -namespace { - const std::vector precisions = {ov::element::f32, ov::element::f16}; const std::vector> input_shapes_basic = { @@ -121,10 +102,8 @@ const std::vector> input_shapes_basic = { INSTANTIATE_TEST_SUITE_P(smoke_GPU_Dynamic, KVCacheTest, ::testing::Combine(::testing::ValuesIn(input_shapes_basic), - ::testing::ValuesIn(precisions), - ::testing::Values(std::map())), + ::testing::ValuesIn(precisions)), KVCacheTest::get_test_case_name); -} // namespace class KVCacheTests: public ::testing::Test { public: @@ -132,7 +111,7 @@ class KVCacheTests: public ::testing::Test { #if defined(ANDROID) GTEST_SKIP(); #endif - auto core = ov::Core(); + auto core = ov::test::utils::PluginCache::get().core(); std::string cacheDirName; if (is_caching_test) { @@ -144,7 +123,7 @@ class KVCacheTests: public ::testing::Test { 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)); + core->set_property(ov::cache_dir(cacheDirName)); } const size_t batch = 1; @@ -157,9 +136,9 @@ class KVCacheTests: public ::testing::Test { auto model = tests::make_llm_kv_cache_pattern(batch, n_heads, n_features, element_type); if (is_caching_test) { - core.compile_model(model, ov::test::utils::DEVICE_GPU, ov::hint::inference_precision(ov::element::f16)); + core->compile_model(model, ov::test::utils::DEVICE_GPU, ov::hint::inference_precision(ov::element::f16)); } - auto compiled_model = core.compile_model(model, ov::test::utils::DEVICE_GPU, ov::hint::inference_precision(ov::element::f16)); + auto compiled_model = core->compile_model(model, ov::test::utils::DEVICE_GPU, ov::hint::inference_precision(ov::element::f16)); auto input0 = model->get_parameters().at(0); auto input1 = model->get_parameters().at(1); @@ -167,13 +146,24 @@ class KVCacheTests: public ::testing::Test { auto output0 = model->get_results().at(0); auto output1 = model->get_results().at(1); - auto get_ref_results = [&model, &input0, &input1, &input2](const ov::Tensor& kv_cache, const ov::Tensor& new_token_data, + auto get_ref_results = [&](const ov::Tensor& kv_cache, const ov::Tensor& new_token_data, const ov::Tensor& matmul_data) { auto ref_model = model->clone(); ov::Tensor kv_cache_copy(kv_cache.get_element_type(), kv_cache.get_shape()); kv_cache.copy_to(kv_cache_copy); ngraph::helpers::resize_function(ref_model, {kv_cache_copy.get_shape(), new_token_data.get_shape(), matmul_data.get_shape()}); - return ngraph::helpers::interpretFunction(ref_model, {{input0, kv_cache_copy}, {input1, new_token_data}, {input2, matmul_data}}); + + auto compiled_model_ref = core->compile_model(ref_model, ov::test::utils::DEVICE_TEMPLATE); + auto inf_req_ref = compiled_model_ref.create_infer_request(); + inf_req_ref.set_tensor(input0, kv_cache_copy); + inf_req_ref.set_tensor(input1, new_token_data); + inf_req_ref.set_tensor(input2, matmul_data); + inf_req_ref.infer(); + std::vector results_ref; + for (auto&& output : ref_model->get_results()) { + results_ref.push_back(inf_req_ref.get_tensor(output)); + } + return results_ref; }; auto compare_tensors = [&model](const std::vector expected, const std::vector& actual) { @@ -187,7 +177,7 @@ class KVCacheTests: public ::testing::Test { std::shared_ptr inputNode = result->get_input_node_shared_ptr(i); if (std::dynamic_pointer_cast(inputNode)) { std::shared_ptr nextNodePtr = inputNode->get_input_node_shared_ptr(0); - if (!ngraph::is_type(nextNodePtr)) { + if (!ov::is_type(nextNodePtr)) { inputNode = nextNodePtr; } } @@ -263,7 +253,7 @@ class KVCacheTests: public ::testing::Test { #if defined(ANDROID) GTEST_SKIP(); #endif - auto core = ov::Core(); + auto core = ov::test::utils::PluginCache::get().core(); std::string cacheDirName; if (is_caching_test) { @@ -275,7 +265,7 @@ class KVCacheTests: public ::testing::Test { 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)); + core->set_property(ov::cache_dir(cacheDirName)); } const size_t batch = 1; @@ -289,20 +279,31 @@ class KVCacheTests: public ::testing::Test { auto model = tests::make_llm_kv_cache_pattern(batch, n_heads, n_features, element_type, true); auto ref_model = tests::make_llm_kv_cache_pattern(batch, n_heads, n_features, element_type, false); if (is_caching_test) { - core.compile_model(model, ov::test::utils::DEVICE_GPU, ov::hint::inference_precision(ov::element::f16)); + core->compile_model(model, ov::test::utils::DEVICE_GPU, ov::hint::inference_precision(ov::element::f16)); } - auto compiled_model = core.compile_model(model, ov::test::utils::DEVICE_GPU, ov::hint::inference_precision(ov::element::f16)); + auto compiled_model = core->compile_model(model, ov::test::utils::DEVICE_GPU, ov::hint::inference_precision(ov::element::f16)); auto input0 = model->get_parameters().at(0); auto input1 = model->get_parameters().at(1); auto output0 = model->get_results().at(0); - auto get_ref_results = [&ref_model](const ov::Tensor& kv_cache, const ov::Tensor& new_token_data, const ov::Tensor& matmul_data) { + auto get_ref_results = [&](const ov::Tensor& kv_cache, const ov::Tensor& new_token_data, const ov::Tensor& matmul_data) { auto input0 = ref_model->get_parameters().at(0); auto input1 = ref_model->get_parameters().at(1); auto input2 = ref_model->get_parameters().at(2); ngraph::helpers::resize_function(ref_model, {kv_cache.get_shape(), new_token_data.get_shape(), matmul_data.get_shape()}); - return ngraph::helpers::interpretFunction(ref_model, {{input0, kv_cache}, {input1, new_token_data}, {input2, matmul_data}}); + + auto compiled_model_ref = core->compile_model(ref_model, ov::test::utils::DEVICE_TEMPLATE); + auto inf_req_ref = compiled_model_ref.create_infer_request(); + inf_req_ref.set_tensor(input0, kv_cache); + inf_req_ref.set_tensor(input1, new_token_data); + inf_req_ref.set_tensor(input2, matmul_data); + inf_req_ref.infer(); + std::vector results_ref; + for (auto&& output : ref_model->get_results()) { + results_ref.push_back(inf_req_ref.get_tensor(output)); + } + return results_ref; }; auto compare_tensors = [&model](const std::vector expected, const std::vector& actual) { @@ -316,7 +317,7 @@ class KVCacheTests: public ::testing::Test { std::shared_ptr inputNode = result->get_input_node_shared_ptr(i); if (std::dynamic_pointer_cast(inputNode)) { std::shared_ptr nextNodePtr = inputNode->get_input_node_shared_ptr(0); - if (!ngraph::is_type(nextNodePtr)) { + if (!ov::is_type(nextNodePtr)) { inputNode = nextNodePtr; } } @@ -407,4 +408,4 @@ TEST_F(KVCacheTests, smoke_multipleIterations_stateful) { TEST_F(KVCacheTests, smoke_multipleIterations_stateful_cached) { this->test_smoke_multipleIterations_stateful(true); } -} // namespace SubgraphTestsDefinitions +} // namespace diff --git a/src/plugins/intel_gpu/tests/functional/subgraph_tests/dynamic/matmul_weights_decompression.cpp b/src/plugins/intel_gpu/tests/functional/subgraph_tests/dynamic/matmul_weights_decompression.cpp index 1830e07cda9a8a..d6c5dbe7353403 100644 --- a/src/plugins/intel_gpu/tests/functional/subgraph_tests/dynamic/matmul_weights_decompression.cpp +++ b/src/plugins/intel_gpu/tests/functional/subgraph_tests/dynamic/matmul_weights_decompression.cpp @@ -3,16 +3,21 @@ // #include "common_test_utils/ov_tensor_utils.hpp" -#include "openvino/op/constant.hpp" -#include "openvino/op/matmul.hpp" -#include "shared_test_classes/base/layer_test_utils.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" #include "transformations/rt_info/decompression.hpp" -using namespace ov; -using namespace ov::test; +#include "openvino/op/parameter.hpp" +#include "openvino/op/constant.hpp" +#include "openvino/op/result.hpp" +#include "openvino/op/matmul.hpp" +#include "openvino/op/reshape.hpp" +#include "openvino/op/convert.hpp" +#include "openvino/op/subtract.hpp" +#include "openvino/op/transpose.hpp" + +namespace { +using ov::test::InputShape; -namespace SubgraphTestsDefinitions { /* * Subtract_const(U8/NF4/U4/I4) * / @@ -44,26 +49,26 @@ struct ShapeParams { // Decompression group size. If the value is equal to -1, ordinary decompression is used int weights_group_size; }; + using MatmulWeightsDecompressionParams = std::tuple>; // additional config + bool>; // per-tensor zero-point -class MatmulWeightsDecompression : public testing::WithParamInterface, public SubgraphBaseTest { +class MatmulWeightsDecompression : public testing::WithParamInterface, + virtual public ov::test::SubgraphBaseTest { public: static std::string get_test_case_name(testing::TestParamInfo obj) { ShapeParams shape_params; - ov::test::ElementType weights_precision; - ov::test::ElementType activations_precision; + ov::element::Type weights_precision; + ov::element::Type activations_precision; bool transpose; bool decompression_sub; bool reshape_on_decompression; bool per_tensor_zp; - std::map additional_config; std::tie(shape_params, weights_precision, @@ -71,25 +76,22 @@ class MatmulWeightsDecompression : public testing::WithParamInterface(ov::NodeVector{mat_mul}, params, "MatmulWeightsDecompression"); } std::shared_ptr init_compressed_weights_subgraph(const ov::Shape& weights_shape, @@ -155,7 +157,7 @@ class MatmulWeightsDecompression : public testing::WithParamInterface(weights_tensor); weights->set_friendly_name("Compressed_weights"); - auto weights_convert = std::make_shared(weights, data_precision); + auto weights_convert = std::make_shared(weights, data_precision); std::shared_ptr mul_parent = weights_convert; auto output_channels = *weights_shape.rbegin(); @@ -181,13 +183,13 @@ class MatmulWeightsDecompression : public testing::WithParamInterface(shift_tensor.data())[0] = 0x88; } auto shift_const = std::make_shared(shift_tensor); - std::shared_ptr shift_convert = std::make_shared(shift_const, data_precision); + std::shared_ptr shift_convert = std::make_shared(shift_const, data_precision); if (reshape_on_decompression_constant && !per_tensor_zp) { - auto shift_reshape_const = ov::opset10::Constant::create(ov::element::i32, {scaleshift_target_shape.size()}, scaleshift_target_shape); - auto shift_reshape = std::make_shared(shift_convert, shift_reshape_const, false); + auto shift_reshape_const = ov::op::v0::Constant::create(ov::element::i32, {scaleshift_target_shape.size()}, scaleshift_target_shape); + auto shift_reshape = std::make_shared(shift_convert, shift_reshape_const, false); shift_convert = shift_reshape; } - mul_parent = std::make_shared(weights_convert, shift_convert); + mul_parent = std::make_shared(weights_convert, shift_convert); } auto scale_tensor = ov::test::utils::create_and_fill_tensor(data_precision, scaleshift_const_shape, 1, -0.5, 30000); @@ -199,25 +201,25 @@ class MatmulWeightsDecompression : public testing::WithParamInterface scale_const = std::make_shared(scale_tensor); if (reshape_on_decompression_constant) { - auto scale_reshape_const = ov::opset10::Constant::create(ov::element::i32, {scaleshift_target_shape.size()}, scaleshift_target_shape); - auto scale_reshape = std::make_shared(scale_const, scale_reshape_const, false); + auto scale_reshape_const = ov::op::v0::Constant::create(ov::element::i32, {scaleshift_target_shape.size()}, scaleshift_target_shape); + auto scale_reshape = std::make_shared(scale_const, scale_reshape_const, false); scale_const = scale_reshape; } - std::shared_ptr last_node = std::make_shared(mul_parent, scale_const); + std::shared_ptr last_node = std::make_shared(mul_parent, scale_const); if (group_decompression) { auto reshape_target_shape = transpose_weights ? std::vector{-1, static_cast(weights_shape[0])} : std::vector{static_cast(weights_shape[0]), -1}; - auto target_shape_node = ov::opset10::Constant::create(ov::element::i32, {reshape_target_shape.size()}, reshape_target_shape); - last_node = std::make_shared(last_node, target_shape_node, false); + auto target_shape_node = ov::op::v0::Constant::create(ov::element::i32, {reshape_target_shape.size()}, reshape_target_shape); + last_node = std::make_shared(last_node, target_shape_node, false); } if (transpose_weights) { const size_t rank = last_node->get_output_partial_shape(0).size(); std::vector order(rank); std::iota(order.begin(), order.end(), 0); std::swap(*order.rbegin(), *(order.rbegin() + 1)); - auto transpose_constant = ov::opset10::Constant::create(ov::element::i32, {rank}, order); - last_node = std::make_shared(last_node, transpose_constant); + auto transpose_constant = ov::op::v0::Constant::create(ov::element::i32, {rank}, order); + last_node = std::make_shared(last_node, transpose_constant); } return last_node; } @@ -226,13 +228,12 @@ class MatmulWeightsDecompression : public testing::WithParamInterface additional_config; std::tie(shape_params, weights_precision, @@ -240,10 +241,8 @@ class MatmulWeightsDecompression : public testing::WithParamInterface& target_input_static_shapes) override { + void generate_inputs(const std::vector& target_input_static_shapes) override { inputs.clear(); const auto& model_inputs = function->inputs(); for (size_t i = 0; i < model_inputs.size(); ++i) { const auto& model_input = model_inputs[i]; ov::Tensor tensor = ov::test::utils::create_and_fill_tensor(model_input.get_element_type(), target_input_static_shapes[i], - 2, - -1, - 10000); + 2, -1, 10000); inputs.insert({model_input.get_node_shared_ptr(), tensor}); } } void check_results() { const auto& test_param = GetParam(); - ov::test::ElementType weights_precision = std::get<1>(test_param); + ov::element::Type weights_precision = std::get<1>(test_param); 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), weights_precision); @@ -291,16 +288,13 @@ class MatmulWeightsDecompression : public testing::WithParamInterface activations_precisions = {ov::element::f32, ov::element::f16}; -const std::vector weights_precisions = {ov::element::u8, ov::element::u4, ov::element::i4}; +const std::vector activations_precisions = {ov::element::f32, ov::element::f16}; +const std::vector weights_precisions = {ov::element::u8, ov::element::u4, ov::element::i4}; const std::vector transpose_weights = {true, false}; const std::vector input_shapes_basic = { {{{-1, -1, -1}, {{1, 4, 16}, {10, 16, 16}}}, {16, 32}}, @@ -318,8 +312,7 @@ INSTANTIATE_TEST_SUITE_P(smoke_MatMulCompressedWeights_basic, ::testing::ValuesIn(transpose_weights), ::testing::Values(true), ::testing::Values(true), - ::testing::Values(false), - ::testing::Values(std::map())), + ::testing::Values(false)), MatmulWeightsDecompression::get_test_case_name); const std::vector input_shapes_corner_cases_basic = { @@ -347,8 +340,7 @@ INSTANTIATE_TEST_SUITE_P(smoke_MatMulCompressedWeights_corner_cases_basic, ::testing::ValuesIn(transpose_weights), ::testing::ValuesIn(add_decompression_sub), ::testing::ValuesIn(reshape_on_decompression), - ::testing::ValuesIn(per_tensor_zp), - ::testing::Values(std::map{})), + ::testing::ValuesIn(per_tensor_zp)), MatmulWeightsDecompression::get_test_case_name); INSTANTIATE_TEST_SUITE_P(MatMulCompressedWeights_corner_cases_big, @@ -359,9 +351,6 @@ INSTANTIATE_TEST_SUITE_P(MatMulCompressedWeights_corner_cases_big, ::testing::ValuesIn(transpose_weights), ::testing::ValuesIn(add_decompression_sub), ::testing::ValuesIn(reshape_on_decompression), - ::testing::ValuesIn(per_tensor_zp), - ::testing::Values(std::map{})), + ::testing::ValuesIn(per_tensor_zp)), MatmulWeightsDecompression::get_test_case_name); } // namespace - -} // namespace SubgraphTestsDefinitions diff --git a/src/plugins/intel_gpu/tests/functional/subgraph_tests/dynamic/read_value_assign.cpp b/src/plugins/intel_gpu/tests/functional/subgraph_tests/dynamic/read_value_assign.cpp index 25a6b3c23c1412..f45009a5365167 100644 --- a/src/plugins/intel_gpu/tests/functional/subgraph_tests/dynamic/read_value_assign.cpp +++ b/src/plugins/intel_gpu/tests/functional/subgraph_tests/dynamic/read_value_assign.cpp @@ -2,30 +2,30 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "openvino/opsets/opset1.hpp" -#include "common_test_utils/ov_tensor_utils.hpp" #include "common_test_utils/file_utils.hpp" -#include "ov_models/builders.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" -using namespace ngraph; -using namespace ov::test; -using namespace InferenceEngine; +#include "openvino/op/parameter.hpp" +#include "openvino/op/constant.hpp" +#include "openvino/op/result.hpp" +#include "openvino/op/add.hpp" +#include "openvino/op/read_value.hpp" +#include "openvino/op/assign.hpp" -namespace GPULayerTestsDefinitions { +namespace { +using ov::test::InputShape; using ReadValueAssignParams = std::tuple< - InputShape, // input shapes - ElementType // input precision + InputShape, // input shapes + ov::element::Type // input precision >; -class ReadValueAssignGPUTest : virtual public SubgraphBaseTest, public testing::WithParamInterface { +class ReadValueAssignGPUTest : virtual public ov::test::SubgraphBaseTest, + public testing::WithParamInterface { public: static std::string getTestCaseName(const testing::TestParamInfo& obj) { InputShape input_shapes; - ElementType input_precision; + ov::element::Type input_precision; std::tie(input_shapes, input_precision) = obj.param; std::ostringstream result; @@ -41,7 +41,7 @@ class ReadValueAssignGPUTest : virtual public SubgraphBaseTest, public testing:: protected: void SetUp() override { InputShape input_shapes; - ElementType input_precision; + ov::element::Type input_precision; std::tie(input_shapes, input_precision) = GetParam(); targetDevice = ov::test::utils::DEVICE_GPU; @@ -55,7 +55,7 @@ class ReadValueAssignGPUTest : virtual public SubgraphBaseTest, public testing:: auto add = std::make_shared(read_value, params.at(0)); auto assign = std::make_shared(add, "v0"); auto res = std::make_shared(add); - function = std::make_shared(ResultVector { res }, SinkVector { assign }, params); + function = std::make_shared(ov::ResultVector { res }, ov::SinkVector { assign }, params); } void generate_inputs(const std::vector& targetInputStaticShapes) override { @@ -71,14 +71,11 @@ class ReadValueAssignGPUTest : virtual public SubgraphBaseTest, public testing:: } }; -TEST_P(ReadValueAssignGPUTest, CompareWithRefs) { - SKIP_IF_CURRENT_TEST_IS_DISABLED() +TEST_P(ReadValueAssignGPUTest, Inference) { run(); } -TEST_P(ReadValueAssignGPUTest, CompareWithRefs_cached) { - SKIP_IF_CURRENT_TEST_IS_DISABLED() - +TEST_P(ReadValueAssignGPUTest, Inference_cached) { std::stringstream ss; ss << "gpu_model_cache_" << std::hash{}( std::string(::testing::UnitTest::GetInstance()->current_test_info()->test_suite_name()) + @@ -99,13 +96,12 @@ TEST_P(ReadValueAssignGPUTest, CompareWithRefs_cached) { } } -namespace { const std::vector input_shapes_dyn = { {{-1, -1, -1, -1}, {{7, 4, 20, 20}, {19, 4, 20, 20}}} }; INSTANTIATE_TEST_SUITE_P(smoke_ReadValueAssign_Static, ReadValueAssignGPUTest, - ::testing::Combine(::testing::ValuesIn(static_shapes_to_test_representation({{7, 4, 20, 20}})), + ::testing::Combine(::testing::ValuesIn(ov::test::static_shapes_to_test_representation({{7, 4, 20, 20}})), ::testing::Values(ov::element::i32)), ReadValueAssignGPUTest::getTestCaseName); @@ -114,4 +110,3 @@ INSTANTIATE_TEST_SUITE_P(smoke_ReadValueAssign_Dynamic, ReadValueAssignGPUTest, ::testing::Values(ov::element::i32)), ReadValueAssignGPUTest::getTestCaseName); } // namespace -} // namespace GPULayerTestsDefinitions diff --git a/src/plugins/intel_gpu/tests/functional/subgraph_tests/dynamic/rms_norm_decomposition.cpp b/src/plugins/intel_gpu/tests/functional/subgraph_tests/dynamic/rms_norm_decomposition.cpp index 60cc72020732f8..bf515ed78fec5a 100644 --- a/src/plugins/intel_gpu/tests/functional/subgraph_tests/dynamic/rms_norm_decomposition.cpp +++ b/src/plugins/intel_gpu/tests/functional/subgraph_tests/dynamic/rms_norm_decomposition.cpp @@ -2,16 +2,24 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "ov_models/builders.hpp" +#include "common_test_utils/ov_tensor_utils.hpp" #include "common_test_utils/file_utils.hpp" -#include "random_generator.hpp" -#include "shared_test_classes/base/layer_test_utils.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -using namespace ngraph; -using namespace ov::test; +#include "openvino/op/parameter.hpp" +#include "openvino/op/constant.hpp" +#include "openvino/op/result.hpp" +#include "openvino/op/convert.hpp" +#include "openvino/op/add.hpp" +#include "openvino/op/sqrt.hpp" +#include "openvino/op/divide.hpp" +#include "openvino/op/multiply.hpp" +#include "openvino/op/power.hpp" +#include "openvino/op/reduce_mean.hpp" + +namespace { +using ov::test::InputShape; -namespace SubgraphTestsDefinitions { /* * Input(F32) Const(F32) * | \ / @@ -33,17 +41,16 @@ namespace SubgraphTestsDefinitions { * Convert(F16) */ using RMSNormDecompositionParams = std::tuple, // input shapes - ov::test::ElementType, // input precision - std::map>; // additional config + ov::element::Type>; // input precision -class RMSNormDecomposition : public testing::WithParamInterface, public SubgraphBaseTest { +class RMSNormDecomposition : public testing::WithParamInterface, + virtual public ov::test::SubgraphBaseTest { public: static std::string getTestCaseName(testing::TestParamInfo obj) { std::vector input_shapes; - ElementType input_precision; - std::map additional_config; + ov::element::Type input_precision; - std::tie(input_shapes, input_precision, additional_config) = obj.param; + std::tie(input_shapes, input_precision) = obj.param; std::ostringstream result; result << "IS=("; @@ -61,14 +68,7 @@ class RMSNormDecomposition : public testing::WithParamInterface(mul2, ov::element::f16); + + return std::make_shared(ov::NodeVector{comp}, params, "RMSNormDecomposition"); } void SetUp() override { targetDevice = ov::test::utils::DEVICE_GPU; std::vector input_shapes; - ElementType input_precision; - std::map additional_config; + ov::element::Type input_precision; - std::tie(input_shapes, input_precision, additional_config) = GetParam(); + std::tie(input_shapes, input_precision) = GetParam(); - configuration.insert(additional_config.begin(), additional_config.end()); init_input_shapes(input_shapes); inType = outType = input_precision; @@ -128,14 +128,11 @@ class RMSNormDecomposition : public testing::WithParamInterface{}( std::string(::testing::UnitTest::GetInstance()->current_test_info()->test_suite_name()) + @@ -156,9 +153,7 @@ TEST_P(RMSNormDecomposition, CompareWithRefs_cached) { } } -namespace { - -const std::vector input_precisions = {ov::element::f32, ov::element::f16}; +const std::vector input_precisions = {ov::element::f32, ov::element::f16}; const std::vector> input_shapes_basic = { {{{-1, -1, 96}, {{1, 4, 96}}}}, @@ -170,9 +165,6 @@ const std::vector> input_shapes_basic = { INSTANTIATE_TEST_SUITE_P(smoke_RMSNormDecomposition_basic, RMSNormDecomposition, ::testing::Combine(::testing::ValuesIn(input_shapes_basic), - ::testing::ValuesIn(input_precisions), - ::testing::Values(std::map())), + ::testing::ValuesIn(input_precisions)), RMSNormDecomposition::getTestCaseName); } // namespace - -} // namespace SubgraphTestsDefinitions diff --git a/src/plugins/intel_gpu/tests/functional/subgraph_tests/loop.cpp b/src/plugins/intel_gpu/tests/functional/subgraph_tests/loop.cpp index 1ca60efa2ff1e6..8200700e0bd902 100644 --- a/src/plugins/intel_gpu/tests/functional/subgraph_tests/loop.cpp +++ b/src/plugins/intel_gpu/tests/functional/subgraph_tests/loop.cpp @@ -2,25 +2,19 @@ // SPDX-License-Identifier: Apache-2.0 // -#include -#include -#include -#include -#include "ov_models/utils/ov_helpers.hpp" -#include "shared_test_classes/base/layer_test_utils.hpp" -#include "ov_models/builders.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include "common_test_utils/test_constants.hpp" -#include "shared_test_classes/base/utils/ranges.hpp" -#include -#include "shared_test_classes/base/utils/compare_results.hpp" -#include "openvino/pass/constant_folding.hpp" -#include -using namespace InferenceEngine; -using namespace ov::test; +#include "openvino/op/parameter.hpp" +#include "openvino/op/constant.hpp" +#include "openvino/op/result.hpp" +#include "openvino/op/add.hpp" +#include "openvino/op/multiply.hpp" +#include "openvino/op/convert.hpp" +#include "openvino/op/loop.hpp" +#include "openvino/op/less.hpp" -namespace GPULayerTestsDefinitions { +namespace { +using ov::test::InputShape; using DynamicShapeLoopParams = typename std::tuple< bool, @@ -32,17 +26,15 @@ using DynamicShapeLoopParams = typename std::tuple< >, int64_t, InputShape, - InferenceEngine::Precision, - std::string, - ov::AnyMap - >; + ov::element::Type, + std::string>; /** * Test case with Dynamic SHAPE version of loop operation. * Total iteration count is dynamic. */ class DynamicShapeLoopTest : public testing::WithParamInterface, - virtual public SubgraphBaseTest { + virtual public ov::test::SubgraphBaseTest { public: static std::string getTestCaseName(const testing::TestParamInfo &obj) { bool static_iter_num; @@ -52,18 +44,16 @@ class DynamicShapeLoopTest : public testing::WithParamInterface std::shared_ptr { + ov::ParameterVector params{}; + auto cond_input_create = [¶ms] (ov::element::Type model_type, + const ov::PartialShape &shape, + int value = 0, + bool is_static = false) -> std::shared_ptr { if (is_static) - return std::make_shared(prc, shape.to_shape(), value); + return std::make_shared(model_type, shape.to_shape(), value); - auto input = std::make_shared(prc, shape); + auto input = std::make_shared(model_type, shape); params.push_back(input); return input; }; - auto start_add = cond_input_create(prc, inputShape, start_value); + auto start_add = cond_input_create(model_type, inputShape, start_value); start_add->set_friendly_name("start_add"); - auto start_mul = cond_input_create(prc, inputShape, 1); + auto start_mul = cond_input_create(model_type, inputShape, 1); start_mul->set_friendly_name("start_mul"); - auto count = cond_input_create(ngraph::element::i64, scalarShape, max_iter_num, static_iter_num); + auto count = cond_input_create(ov::element::i64, scalarShape, max_iter_num, static_iter_num); count->set_friendly_name("count"); - auto skip = cond_input_create(ngraph::element::boolean, scalarShape, true, static_continue_cond); + auto skip = cond_input_create(ov::element::boolean, scalarShape, true, static_continue_cond); skip->set_friendly_name("skip"); - auto b_indx = std::make_shared(ngraph::element::i64, ngraph::Shape{}); + auto b_indx = std::make_shared(ov::element::i64, ov::Shape{}); b_indx->set_friendly_name("body_index"); - auto b_data_add = std::make_shared(prc, inputShape); + auto b_data_add = std::make_shared(model_type, inputShape); b_data_add->set_friendly_name("b_data_add"); - auto b_data_mul = std::make_shared(prc, inputShape); + auto b_data_mul = std::make_shared(model_type, inputShape); b_data_mul->set_friendly_name("b_data_mul"); - auto b_indx_cast = std::make_shared(b_indx, prc); + auto b_indx_cast = std::make_shared(b_indx, model_type); b_indx_cast->set_friendly_name("body_index_cast"); - auto b_add = std::make_shared(b_data_add, b_indx_cast); + auto b_add = std::make_shared(b_data_add, b_indx_cast); b_add->set_friendly_name("body_add"); - auto b_mul = std::make_shared(b_data_mul, b_indx_cast); + auto b_mul = std::make_shared(b_data_mul, b_indx_cast); b_mul->set_friendly_name("body_mul"); - std::shared_ptr b_cond; + std::shared_ptr b_cond; if (dynamic_exit == -1) { - b_cond = std::make_shared(ngraph::element::boolean, ngraph::Shape{}, true); + b_cond = std::make_shared(ov::element::boolean, ov::Shape{}, true); b_cond->set_friendly_name("body_condition"); } else { - auto b_exit_value = std::make_shared(ngraph::element::i64, scalarShape, dynamic_exit); + auto b_exit_value = std::make_shared(ov::element::i64, scalarShape, dynamic_exit); b_exit_value->set_friendly_name("body_exit_value"); - b_cond = std::make_shared(b_indx, b_exit_value); + b_cond = std::make_shared(b_indx, b_exit_value); b_cond->set_friendly_name("body_condition_with_exit_value"); } - auto body = std::make_shared( - ngraph::OutputVector {b_cond, b_add, b_mul}, // TODO: check with reverse - ngraph::ParameterVector {b_indx, b_data_add, b_data_mul}); // TODO: check with reverse + auto body = std::make_shared( + ov::OutputVector {b_cond, b_add, b_mul}, // TODO: check with reverse + ov::ParameterVector {b_indx, b_data_add, b_data_mul}); // TODO: check with reverse body->set_friendly_name("body_network"); - auto loop = std::make_shared(count, skip); + auto loop = std::make_shared(count, skip); loop->set_friendly_name("loop"); loop->set_function(body); loop->set_special_body_ports({0, 0}); @@ -180,13 +169,13 @@ class DynamicShapeLoopTest : public testing::WithParamInterfaceget_concatenated_slices(b_mul, 0, 1, 1, -1, axis); } - ngraph::ResultVector results; + ov::ResultVector results; for (size_t i = 0; i < loop->get_output_size(); i++) { - auto res = std::make_shared(loop->output(i)); + auto res = std::make_shared(loop->output(i)); res->set_friendly_name("loop_output_" + std::to_string(i)); results.push_back(res); } - function = std::make_shared( + function = std::make_shared( results, params); function->set_friendly_name("outer_body_network"); @@ -194,18 +183,13 @@ class DynamicShapeLoopTest : public testing::WithParamInterface netPrecisions = { - InferenceEngine::Precision::FP32, - InferenceEngine::Precision::I32 -}; - -ov::AnyMap netConfigurations = { - {GPUConfigParams::KEY_GPU_ENABLE_LOOP_UNROLLING, PluginConfigParams::NO} +std::vector model_types = { + ov::element::f32, + ov::element::i32 }; static const std::vector> dynamic_loop_types_axis_0 { @@ -224,9 +208,8 @@ INSTANTIATE_TEST_SUITE_P(smoke_DynamicShapeLoop_axis_0, DynamicShapeLoopTest, /* args_pack */ testing::ValuesIn(dynamic_loop_types_axis_0), /* start_value */ testing::Values(0), /* data_shape */ testing::ValuesIn(inputs_0), - /* data_prc */ testing::ValuesIn(netPrecisions), - /* device */ testing::Values(ov::test::utils::DEVICE_GPU), - /* configuration */ testing::Values(netConfigurations)), + /* model_type */ testing::ValuesIn(model_types), + /* device */ testing::Values(ov::test::utils::DEVICE_GPU)), DynamicShapeLoopTest::getTestCaseName); static const std::vector> dynamic_loop_types_1 { @@ -245,9 +228,8 @@ INSTANTIATE_TEST_SUITE_P(smoke_DynamicShapeLoop_axis_1, DynamicShapeLoopTest, /* args_pack */ testing::ValuesIn(dynamic_loop_types_1), /* start_value */ testing::Values(0), /* data_shape */ testing::ValuesIn(inputs_1), - /* data_prc */ testing::ValuesIn(netPrecisions), - /* device */ testing::Values(ov::test::utils::DEVICE_GPU), - /* configuration */ testing::Values(netConfigurations)), + /* model_type */ testing::ValuesIn(model_types), + /* device */ testing::Values(ov::test::utils::DEVICE_GPU)), DynamicShapeLoopTest::getTestCaseName); static const std::vector> dynamic_loop_types_2 { @@ -266,9 +248,8 @@ INSTANTIATE_TEST_SUITE_P(smoke_DynamicShapeLoop_axis_2, DynamicShapeLoopTest, /* args_pack */ testing::ValuesIn(dynamic_loop_types_2), /* start_value */ testing::Values(0), /* data_shape */ testing::ValuesIn(inputs_2), - /* data_prc */ testing::ValuesIn(netPrecisions), - /* device */ testing::Values(ov::test::utils::DEVICE_GPU), - /* configuration */ testing::Values(netConfigurations)), + /* model_type */ testing::ValuesIn(model_types), + /* device */ testing::Values(ov::test::utils::DEVICE_GPU)), DynamicShapeLoopTest::getTestCaseName); static const std::vector> dynamic_loop_types_no_auto_concat { @@ -287,9 +268,8 @@ INSTANTIATE_TEST_SUITE_P(smoke_DynamicShapeLoop_no_auto_concat, DynamicShapeLoop /* args_pack */ testing::ValuesIn(dynamic_loop_types_no_auto_concat), /* start_value */ testing::Values(0), /* data_shape */ testing::ValuesIn(inputs_no_auto_concat), - /* data_prc */ testing::ValuesIn(netPrecisions), - /* device */ testing::Values(ov::test::utils::DEVICE_GPU), - /* configuration */ testing::Values(netConfigurations)), + /* model_type */ testing::ValuesIn(model_types), + /* device */ testing::Values(ov::test::utils::DEVICE_GPU)), DynamicShapeLoopTest::getTestCaseName); static const std::vector> dynamic_loop_types_dynamic_exit { @@ -310,9 +290,8 @@ INSTANTIATE_TEST_SUITE_P(smoke_DynamicShapeLoop_dynamic_exit, DynamicShapeLoopTe /* args_pack */ testing::ValuesIn(dynamic_loop_types_dynamic_exit), /* start_value */ testing::Values(0), /* data_shape */ testing::ValuesIn(inputs_dynamic_exit), - /* data_prc */ testing::ValuesIn(netPrecisions), - /* device */ testing::Values(ov::test::utils::DEVICE_GPU), - /* configuration */ testing::Values(netConfigurations)), + /* model_type */ testing::ValuesIn(model_types), + /* device */ testing::Values(ov::test::utils::DEVICE_GPU)), DynamicShapeLoopTest::getTestCaseName); -} // namespace GPULayerTestsDefinitions \ No newline at end of file +} // namespace \ No newline at end of file diff --git a/src/plugins/intel_gpu/tests/functional/subgraph_tests/shared_constant.cpp b/src/plugins/intel_gpu/tests/functional/subgraph_tests/shared_constant.cpp index 55e69e6d32ff4d..aed8fe5672987e 100644 --- a/src/plugins/intel_gpu/tests/functional/subgraph_tests/shared_constant.cpp +++ b/src/plugins/intel_gpu/tests/functional/subgraph_tests/shared_constant.cpp @@ -2,47 +2,52 @@ // SPDX-License-Identifier: Apache-2.0 // -#include -#include +#include "shared_test_classes/base/ov_subgraph.hpp" +#include "openvino/core/coordinate_diff.hpp" +#include "openvino/core/strides.hpp" -namespace { - -using namespace ngraph; +#include "openvino/op/parameter.hpp" +#include "openvino/op/constant.hpp" +#include "openvino/op/result.hpp" +#include "openvino/op/convolution.hpp" +#include "openvino/op/group_conv.hpp" +#include "openvino/op/multiply.hpp" +namespace { // Validate scenario where a single Constant has multiple users (like one constant is used for Convolution, ConvolutionBackpropData, Multiply, etc.) -class SharedConstant : virtual public LayerTestsUtils::LayerTestsCommon { +class SharedConstant : virtual public ov::test::SubgraphBaseStaticTest { protected: void SetUp() override { targetDevice = ov::test::utils::DEVICE_GPU; - auto type = element::f32; - Shape constShape{4, 1, 3, 3}; - Shape convInputShape{1, 1, 5, 5}; - Shape convBackpropInputShape{1, 4, 5, 5}; - Shape constGroupConvBackpropShape{2, 2, 3, 3, 3}; - auto constant = opset8::Constant::create(type, constShape, {1}); - auto input1 = std::make_shared(type, convInputShape); - auto conv = std::make_shared(input1, constant, Strides{1, 1}, CoordinateDiff{0, 0}, CoordinateDiff{0, 0}, Strides{1, 1}); - auto input2 = std::make_shared(type, convBackpropInputShape); - auto convBprop = std::make_shared(input2, constant, Strides{1, 1}, - CoordinateDiff{0, 0}, CoordinateDiff{0, 0}, Strides{1, 1}); - auto input3 = std::make_shared(type, convBackpropInputShape); - auto constantGroupConv = opset8::Constant::create(type, constGroupConvBackpropShape, {1}); - auto groupConvBprop = std::make_shared(input3, constantGroupConv, Strides{1, 1}, - CoordinateDiff{0, 0}, CoordinateDiff{0, 0}, Strides{1, 1}); - auto input4 = std::make_shared(type, constShape); - auto mul = std::make_shared(input4, constant); - auto input5 = std::make_shared(type, constGroupConvBackpropShape); - auto mul2 = std::make_shared(input5, constantGroupConv); + auto type = ov::element::f32; + ov::Shape constShape{4, 1, 3, 3}; + ov::Shape convInputShape{1, 1, 5, 5}; + ov::Shape convBackpropInputShape{1, 4, 5, 5}; + ov::Shape constGroupConvBackpropShape{2, 2, 3, 3, 3}; + auto constant = ov::op::v0::Constant::create(type, constShape, {1}); + auto input1 = std::make_shared(type, convInputShape); + auto conv = std::make_shared( + input1, constant, ov::Strides{1, 1}, ov::CoordinateDiff{0, 0}, ov::CoordinateDiff{0, 0}, ov::Strides{1, 1}); + auto input2 = std::make_shared(type, convBackpropInputShape); + auto convBprop = std::make_shared(input2, constant, ov::Strides{1, 1}, + ov::CoordinateDiff{0, 0}, ov::CoordinateDiff{0, 0}, ov::Strides{1, 1}); + auto input3 = std::make_shared(type, convBackpropInputShape); + auto constantGroupConv = ov::op::v0::Constant::create(type, constGroupConvBackpropShape, {1}); + auto groupConvBprop = std::make_shared(input3, constantGroupConv, ov::Strides{1, 1}, + ov::CoordinateDiff{0, 0}, ov::CoordinateDiff{0, 0}, ov::Strides{1, 1}); + auto input4 = std::make_shared(type, constShape); + auto mul = std::make_shared(input4, constant); + auto input5 = std::make_shared(type, constGroupConvBackpropShape); + auto mul2 = std::make_shared(input5, constantGroupConv); // explicitly set the output name, to avoid global conflict mul2->set_friendly_name("Multiply_0"); mul->set_friendly_name("Multiply_1"); - function = std::make_shared(NodeVector{convBprop, conv, groupConvBprop, mul2, mul}, - ParameterVector{input1, input2, input3, input4, input5}); + function = std::make_shared(ov::NodeVector{convBprop, conv, groupConvBprop, mul2, mul}, + ov::ParameterVector{input1, input2, input3, input4, input5}); } }; -TEST_F(SharedConstant, smoke_SharedConstant) { - Run(); +TEST_F(SharedConstant, Inference) { + run(); } - } // namespace diff --git a/src/plugins/intel_gpu/tests/functional/subgraph_tests/tensor_iterator.cpp b/src/plugins/intel_gpu/tests/functional/subgraph_tests/tensor_iterator.cpp index 628e26320f4087..dff05c614bb4fb 100644 --- a/src/plugins/intel_gpu/tests/functional/subgraph_tests/tensor_iterator.cpp +++ b/src/plugins/intel_gpu/tests/functional/subgraph_tests/tensor_iterator.cpp @@ -2,66 +2,55 @@ // SPDX-License-Identifier: Apache-2.0 // -#include -#include -#include -#include -#include "ov_models/utils/ov_helpers.hpp" -#include "shared_test_classes/base/layer_test_utils.hpp" -#include "ov_models/builders.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include "common_test_utils/test_constants.hpp" -#include "shared_test_classes/base/utils/ranges.hpp" -#include -#include "shared_test_classes/base/utils/compare_results.hpp" -#include "openvino/pass/constant_folding.hpp" -#include #include "shared_test_classes/base/utils/generate_inputs.hpp" -using namespace InferenceEngine; -using namespace ov::test; - -namespace GPULayerTestsDefinitions { +#include "openvino/op/parameter.hpp" +#include "openvino/op/constant.hpp" +#include "openvino/op/result.hpp" +#include "openvino/op/tensor_iterator.hpp" +namespace { +using ov::test::InputShape; /* * Generate TensorIterator with LSTMCell -* @param ngPrc precision of model +* @param model_type precision of model * @param initShape initial shape {N, L(sequence length), I} * @param N batch size * @param I input size * @param H hidden layer */ -static std::shared_ptr makeTIwithLSTMcell(ov::element::Type_t ngPRC, ov::PartialShape initShape, +static std::shared_ptr makeTIwithLSTMcell(ov::element::Type_t model_type, ov::PartialShape initShape, size_t N, size_t I, size_t H, size_t sequence_axis, - ngraph::op::RecurrentSequenceDirection seq_direction) { - auto SENT = std::make_shared(ngPRC, initShape); + ov::op::RecurrentSequenceDirection seq_direction) { + auto SENT = std::make_shared(model_type, initShape); SENT->set_friendly_name("SENT"); // initial_hidden_state - auto H_init = std::make_shared(ngPRC, ov::Shape{N, 1, H}); + auto H_init = std::make_shared(model_type, ov::Shape{N, 1, H}); H_init->set_friendly_name("H_init"); // initial_cell_state - auto C_init = std::make_shared(ngPRC, ov::Shape{N, 1, H}); + auto C_init = std::make_shared(model_type, ov::Shape{N, 1, H}); C_init->set_friendly_name("C_init"); - auto H_t = std::make_shared(ngPRC, ov::Shape{N, 1, H}); + auto H_t = std::make_shared(model_type, ov::Shape{N, 1, H}); H_t->set_friendly_name("H_t"); - auto C_t = std::make_shared(ngPRC, ov::Shape{N, 1, H}); + auto C_t = std::make_shared(model_type, ov::Shape{N, 1, H}); C_t->set_friendly_name("C_t"); // Body // input data - auto X = std::make_shared(ngPRC, ov::Shape{N, 1, I}); + auto X = std::make_shared(model_type, ov::Shape{N, 1, I}); X->set_friendly_name("X"); // the weights for matrix multiplication, gate order: fico std::vector dataW(4 * H * I, 0); - auto W_body = std::make_shared(ngPRC, ov::Shape{4 * H, I}, dataW); + auto W_body = std::make_shared(model_type, ov::Shape{4 * H, I}, dataW); W_body->set_friendly_name("W_body"); // the recurrence weights for matrix multiplication, gate order: fico std::vector dataR(4 * H * H, 0); - auto R_body = std::make_shared(ngPRC, ov::Shape{4 * H, H}, dataR); + auto R_body = std::make_shared(model_type, ov::Shape{4 * H, H}, dataR); R_body->set_friendly_name("R_body"); std::vector inShape = {N, H}; @@ -100,9 +89,9 @@ static std::shared_ptr makeTIwithLSTMcell(ov::element::Type_t ngPRC, tensor_iterator->set_merged_input(C_t, C_init, C_o); // Set PortMap - if (seq_direction == ngraph::op::RecurrentSequenceDirection::FORWARD) { + if (seq_direction == ov::op::RecurrentSequenceDirection::FORWARD) { tensor_iterator->set_sliced_input(X, SENT, 0, 1, 1, -1, sequence_axis); - } else if (seq_direction == ngraph::op::RecurrentSequenceDirection::REVERSE) { + } else if (seq_direction == ov::op::RecurrentSequenceDirection::REVERSE) { tensor_iterator->set_sliced_input(X, SENT, -1, -1, 1, 0, sequence_axis); } else { OPENVINO_THROW("Bidirectional case is not supported."); @@ -115,25 +104,25 @@ static std::shared_ptr makeTIwithLSTMcell(ov::element::Type_t ngPRC, auto results = ov::ResultVector{std::make_shared(out0), std::make_shared(out1)}; - auto fn_ptr = std::make_shared(results, ov::ParameterVector{SENT, H_init, C_init}); - fn_ptr->set_friendly_name("TIwithLSTMcell"); - return fn_ptr; + auto model = std::make_shared(results, ov::ParameterVector{SENT, H_init, C_init}); + model->set_friendly_name("TIwithLSTMcell"); + return model; } /* * Generate LSTMSequence -* @param ngPrc precision of model +* @param model_type precision of model * @param initShape initial shape {N, L(sequence length), I} * @param N batch size * @param I input size * @param H hidden layer */ -static std::shared_ptr makeLSTMSequence(ov::element::Type_t ngPRC, ov::PartialShape initShape, +static std::shared_ptr makeLSTMSequence(ov::element::Type_t model_type, ov::PartialShape initShape, size_t N, size_t I, size_t H, size_t sequence_axis, - ngraph::op::RecurrentSequenceDirection seq_direction) { - auto X = std::make_shared(ngPRC, initShape); - auto Y = std::make_shared(ngPRC, ov::Shape{N, 1, H}); - auto Z = std::make_shared(ngPRC, ov::Shape{N, 1, H}); + ov::op::RecurrentSequenceDirection seq_direction) { + auto X = std::make_shared(model_type, initShape); + auto Y = std::make_shared(model_type, ov::Shape{N, 1, H}); + auto Z = std::make_shared(model_type, ov::Shape{N, 1, H}); auto shape_of = std::make_shared(X); auto indices = ov::op::v0::Constant::create(ov::element::i32, {1}, {1}); auto axis = ov::op::v0::Constant::create(ov::element::i32, {}, {0}); @@ -142,9 +131,9 @@ static std::shared_ptr makeLSTMSequence(ov::element::Type_t ngPRC, ov auto w_val = std::vector(4 * H * I, 0); auto r_val = std::vector(4 * H * H, 0); auto b_val = std::vector(4 * H, 0); - auto W = ov::op::v0::Constant::create(ngPRC, ov::Shape{N, 4 * H, I}, w_val); - auto R = ov::op::v0::Constant::create(ngPRC, ov::Shape{N, 4 * H, H}, r_val); - auto B = ov::op::v0::Constant::create(ngPRC, ov::Shape{N, 4 * H}, b_val); + auto W = ov::op::v0::Constant::create(model_type, ov::Shape{N, 4 * H, I}, w_val); + auto R = ov::op::v0::Constant::create(model_type, ov::Shape{N, 4 * H, H}, r_val); + auto B = ov::op::v0::Constant::create(model_type, ov::Shape{N, 4 * H}, b_val); auto rnn_sequence = std::make_shared(X, Y, @@ -176,33 +165,29 @@ using DynamicTensorIteratorParams = typename std::tuple< LSTMType, // LSTM type (LSTMCell, LSTMSequence) InputShape, // input shapes (N[batch], L[seq_length], I[input_size]) int32_t, // hidden size - ngraph::op::RecurrentSequenceDirection, // sequence direction + ov::op::RecurrentSequenceDirection, // sequence direction std::string, // device name - InferenceEngine::Precision, // precision - ov::AnyMap // configuration - >; + ov::element::Type>; // type /** * Test case with Dynamic SHAPE version of loop operation. * Total iteration count is dynamic. */ class DynamicTensorIteratorTest : public testing::WithParamInterface, - virtual public SubgraphBaseTest { + virtual public ov::test::SubgraphBaseTest { public: static std::string getTestCaseName(const testing::TestParamInfo &obj) { LSTMType type; InputShape data_shapes; int32_t hidden_size; - ngraph::op::RecurrentSequenceDirection seq_direction; + ov::op::RecurrentSequenceDirection seq_direction; std::string target_device; - InferenceEngine::Precision data_precision; - ov::Any configuration; + ov::element::Type model_type; std::tie(type, data_shapes, hidden_size, seq_direction, target_device, - data_precision, - configuration) = obj.param; + model_type) = obj.param; std::ostringstream result; result << "TestType=" << (type == LSTMType::LSTMCell? "LSTMCell" : "LSTMSequence") << "_"; result << "IS=("; @@ -211,15 +196,15 @@ class DynamicTensorIteratorTest : public testing::WithParamInterface(init_shape[0].get_length()); input_size = static_cast(init_shape[init_shape.size()-1].get_length()); if (type == LSTMType::LSTMCell) - function = makeTIwithLSTMcell(ngPrc, init_shape, batch_size, input_size, hidden_size, sequence_axis, seq_direction); + function = makeTIwithLSTMcell(model_type, init_shape, batch_size, input_size, hidden_size, sequence_axis, seq_direction); else - function = makeLSTMSequence(ngPrc, init_shape, batch_size, input_size, hidden_size, sequence_axis, seq_direction); + function = makeLSTMSequence(model_type, init_shape, batch_size, input_size, hidden_size, sequence_axis, seq_direction); } - void generate_inputs(const std::vector& targetInputStaticShapes) override { + void generate_inputs(const std::vector& targetInputStaticShapes) override { inputs.clear(); ov::Shape default_shape{batch_size, 1, hidden_size}; auto inputMap = ov::test::utils::getInputMap(); @@ -283,8 +260,7 @@ class DynamicTensorIteratorTest : public testing::WithParamInterface hidden_sizes = { 128 }; -ov::AnyMap net_configuration = { - {GPUConfigParams::KEY_GPU_ENABLE_LOOP_UNROLLING, PluginConfigParams::NO} -}; - -std::vector net_precision = { - InferenceEngine::Precision::FP32, +std::vector model_types = { + ov::element::f32, }; -std::vector reccurent_sequence_direction = { - ngraph::op::RecurrentSequenceDirection::FORWARD, - ngraph::op::RecurrentSequenceDirection::REVERSE, +std::vector reccurent_sequence_direction = { + ov::op::RecurrentSequenceDirection::FORWARD, + ov::op::RecurrentSequenceDirection::REVERSE, }; INSTANTIATE_TEST_SUITE_P(smoke_DynamicTensorIterator_LSTMCell, DynamicTensorIteratorTest, @@ -320,8 +292,7 @@ INSTANTIATE_TEST_SUITE_P(smoke_DynamicTensorIterator_LSTMCell, DynamicTensorIter /* hidden_size */ testing::ValuesIn(hidden_sizes), /* direction */ testing::ValuesIn(reccurent_sequence_direction), /* device */ testing::Values(ov::test::utils::DEVICE_GPU), - /* data_prc */ testing::ValuesIn(net_precision), - /* configuration */ testing::Values(net_configuration)), + /* model_type */ testing::ValuesIn(model_types)), DynamicTensorIteratorTest::getTestCaseName); INSTANTIATE_TEST_SUITE_P(smoke_DynamicTensorIterator_LSTMSequence, DynamicTensorIteratorTest, @@ -331,7 +302,6 @@ INSTANTIATE_TEST_SUITE_P(smoke_DynamicTensorIterator_LSTMSequence, DynamicTensor /* hidden_size */ testing::ValuesIn(hidden_sizes), /* direction */ testing::ValuesIn(reccurent_sequence_direction), /* device */ testing::Values(ov::test::utils::DEVICE_GPU), - /* data_prc */ testing::ValuesIn(net_precision), - /* configuration */ testing::Values(net_configuration)), + /* model_type */ testing::ValuesIn(model_types)), DynamicTensorIteratorTest::getTestCaseName); -} // namespace GPULayerTestsDefinitions +} // namespace diff --git a/src/plugins/intel_gpu/tests/unit/fake_alignment/fc_fake_alignment_test.cpp b/src/plugins/intel_gpu/tests/unit/fake_alignment/fc_fake_alignment_test.cpp index 5fbcea60b3da49..56d5e59076f99a 100644 --- a/src/plugins/intel_gpu/tests/unit/fake_alignment/fc_fake_alignment_test.cpp +++ b/src/plugins/intel_gpu/tests/unit/fake_alignment/fc_fake_alignment_test.cpp @@ -38,9 +38,10 @@ TEST_P(fully_connected_fake_align_test, fake_alignment) { auto& engine = get_test_engine(); + auto input_size = p.input_layout.get_partial_shape().size(); auto input_layout_prim = std::make_shared("input", p.input_layout); auto weight_layout_prim = std::make_shared("weight", p.weight_layout); - auto fully_connected_prim = std::make_shared("output", input_info("input"), "weight", "", p.data_type); + auto fully_connected_prim = std::make_shared("output", input_info("input"), "weight", "", p.data_type, padding(), input_size); cldnn::program prog(engine); @@ -106,7 +107,51 @@ INSTANTIATE_TEST_SUITE_P(smoke, fully_connected_fake_align_test, layout{ov::PartialShape{-1, -1}, data_types::i8, format::bfyx}, // fake_aligned input layout_dgpu // dummy layout{ov::PartialShape{-1, -1}, data_types::f16, format::bfyx} // fake_aligned output layout_dgpu // dummy }, - + { + layout{ov::PartialShape{1, 55, 511}, data_types::f16, format::bfyx}, // input_layout + layout{ov::PartialShape{800, 511}, data_types::f16, format::bfyx}, // weight layout + data_types::f16, + layout{ov::PartialShape{64, 1, 511}, data_types::f16, format::bfyx}, // fake_aligned input layout_igpu + layout{ov::PartialShape{64, 1, 800}, data_types::f16, format::bfyx}, // fake_aligned output layout_igpu + layout{ov::PartialShape{56, 1, 511}, data_types::f16, format::bfyx}, // fake_aligned input layout_dgpu + layout{ov::PartialShape{56, 1, 800}, data_types::f16, format::bfyx} // fake_aligned output layout_dgpu + }, + { + layout{ov::PartialShape{2, 55, 511}, data_types::f16, format::bfyx}, // input_layout + layout{ov::PartialShape{800, 511}, data_types::f16, format::bfyx}, // weight layout + data_types::f16, + layout{ov::PartialShape{112, 1, 511}, data_types::f16, format::bfyx}, // fake_aligned input layout_igpu + layout{ov::PartialShape{112, 1, 800}, data_types::f16, format::bfyx}, // fake_aligned output layout_igpu + layout{ov::PartialShape{112, 1, 511}, data_types::f16, format::bfyx}, // fake_aligned input layout_dgpu + layout{ov::PartialShape{112, 1, 800}, data_types::f16, format::bfyx} // fake_aligned output layout_dgpu + }, + { + layout{ov::PartialShape{55, 1, 511}, data_types::f16, format::bfyx}, // input_layout + layout{ov::PartialShape{800, 511}, data_types::f16, format::bfyx}, // weight layout + data_types::f16, + layout{ov::PartialShape{64, 1, 511}, data_types::f16, format::bfyx}, // fake_aligned input layout_igpu + layout{ov::PartialShape{64, 1, 800}, data_types::f16, format::bfyx}, // fake_aligned output layout_igpu + layout{ov::PartialShape{56, 1, 511}, data_types::f16, format::bfyx}, // fake_aligned input layout_dgpu + layout{ov::PartialShape{56, 1, 800}, data_types::f16, format::bfyx} // fake_aligned output layout_dgpu + }, + { + layout{ov::PartialShape{55, 1, 511}, data_types::f16, format::bfyx, padding{{2,0,1,0}, 0}}, // input_layout + layout{ov::PartialShape{800, 511}, data_types::f16, format::bfyx}, // weight layout + data_types::f16, + layout{ov::PartialShape{64, 1, 511}, data_types::f16, format::bfyx, padding{{2,0,1,0}, 0}}, // fake_aligned input layout_igpu + layout{ov::PartialShape{64, 1, 800}, data_types::f16, format::bfyx}, // fake_aligned output layout_igpu + layout{ov::PartialShape{56, 1, 511}, data_types::f16, format::bfyx, padding{{2,0,1,0}, 0}}, // fake_aligned input layout_dgpu + layout{ov::PartialShape{56, 1, 800}, data_types::f16, format::bfyx} // fake_aligned output layout_dgpu + }, + { + layout{ov::PartialShape{55, 1, 511}, data_types::f16, format::bfyx, padding{{0,1,1,0}, 0}}, // input_layout + layout{ov::PartialShape{800, 511}, data_types::f16, format::bfyx}, // weight layout + data_types::f16, + layout{ov::PartialShape{55, 1, 511}, data_types::f16, format::bfyx, padding{{0,1,1,0}, 0}}, // fake_aligned input layout_igpu + layout{ov::PartialShape{55, 1, 800}, data_types::f16, format::bfyx}, // fake_aligned output layout_igpu + layout{ov::PartialShape{55, 1, 511}, data_types::f16, format::bfyx, padding{{0,1,1,0}, 0}}, // fake_aligned input layout_dgpu + layout{ov::PartialShape{55, 1, 800}, data_types::f16, format::bfyx} // fake_aligned output layout_dgpu + }, })); } // fake_alignment_tests 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 bf72af9c91837f..5f75f4e424b857 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 @@ -100,6 +100,7 @@ class EltwiseFusingTest : public ::BaseFusingTest { #define CASE_ELTWISE_FP32_5 { 1, 5, 4, 4 }, data_types::f32, data_types::f32, format::b_fs_yx_fsv4, data_types::f32, format::b_fs_yx_fsv4, eltwise_mode::sum #define CASE_ELTWISE_FP32_6 { 2, 32, 4, 8 }, data_types::f32, data_types::f32, format::b_fs_yx_fsv4, data_types::f32, format::b_fs_yx_fsv4, eltwise_mode::sum +#define CASE_ELTWISE_FP32_7 { 1, 8, 16, 1 }, data_types::f32, data_types::f32, format::bfyx, data_types::f32, format::bfwzyx, eltwise_mode::sum #define CASE_ELTWISE_FP16_5 { 2, 32, 4, 8 }, data_types::f16, data_types::f16, format::b_fs_yx_fsv4, data_types::f16, format::b_fs_yx_fsv4, eltwise_mode::sum #define CASE_ELTWISE_FP16_6 { 1, 32, 4, 8 }, data_types::f16, data_types::f16, format::byxf, data_types::f16, format::byxf, eltwise_mode::sum #define CASE_ELTWISE_I8_4 { 2, 16, 4, 4 }, data_types::i8, data_types::i8, format::b_fs_yx_fsv4, data_types::f32, format::b_fs_yx_fsv4, eltwise_mode::sum @@ -449,6 +450,28 @@ INSTANTIATE_TEST_SUITE_P(fusings_gpu, eltwise_fp32_fused_prims, ::testing::Value eltwise_test_params{ CASE_ELTWISE_U8_4, 3, 5 }, })); +class eltwise_reorder_eltwise_fp32_fused_prims : public EltwiseFusingTest {}; +TEST_P(eltwise_reorder_eltwise_fp32_fused_prims, eltwise_activation) { + auto p = GetParam(); + create_topologies( + data("const", get_mem(layout{ {p.input_size[2]}, p.input_type, p.input_format }, -10, 10)), // 1d const + data("const2", get_mem(layout{ {1, 1, 1, 1, 1, 1}, p.input_type, p.default_format }, -10, 10)), // 6d const + input_layout("input", get_input_layout(p)), + eltwise("eltwise1", { input_info("input"), input_info("const") }, p.mode, p.input_type), + reorder("reorder6d", input_info("eltwise1"), layout{ {p.input_size[0], p.input_size[1], 1, 1, p.input_size[2], p.input_size[3]}, p.input_type, p.default_format }), + eltwise("eltwise2", { input_info("reorder6d"), input_info("const2") }, eltwise_mode::prod, p.default_type), + activation("activation", input_info("eltwise2"), activation_func::abs), + reorder("out", input_info("activation"), p.default_format, data_types::f32) + ); + + tolerance = default_tolerance(p.input_type); + execute(p); +} + +INSTANTIATE_TEST_SUITE_P(fusings_gpu, eltwise_reorder_eltwise_fp32_fused_prims, ::testing::ValuesIn(std::vector{ + eltwise_test_params{ CASE_ELTWISE_FP32_7, 3, 4 }, +})); + class eltwise_fp32_scale : public EltwiseFusingTest {}; TEST_P(eltwise_fp32_scale, 6d) { auto p = GetParam(); diff --git a/src/plugins/intel_gpu/tests/unit/fusions/fully_connected_fusion_test.cpp b/src/plugins/intel_gpu/tests/unit/fusions/fully_connected_fusion_test.cpp index bcd5b096951def..76ce7077e76565 100644 --- a/src/plugins/intel_gpu/tests/unit/fusions/fully_connected_fusion_test.cpp +++ b/src/plugins/intel_gpu/tests/unit/fusions/fully_connected_fusion_test.cpp @@ -71,6 +71,17 @@ class FullyConnectedFusingTest : public ::BaseFusingTest{ + fully_connected_test_params{ CASE_FC_FP16_INT4_COMP_1, 2, 3 }, +})); + class fc_int8_eltwise : public FullyConnectedFusingTest {}; TEST_P(fc_int8_eltwise, basic) { auto p = GetParam(); diff --git a/src/plugins/intel_gpu/tests/unit/fusions/fusion_test_common.hpp b/src/plugins/intel_gpu/tests/unit/fusions/fusion_test_common.hpp index 06c6f7aac1c6a1..50eace0e091bf3 100644 --- a/src/plugins/intel_gpu/tests/unit/fusions/fusion_test_common.hpp +++ b/src/plugins/intel_gpu/tests/unit/fusions/fusion_test_common.hpp @@ -117,6 +117,9 @@ class BaseFusingTest : public ::testing::TestWithParam { if (l.data_type == data_types::i8 || l.data_type == data_types::u8) { VF rnd_vec = rg.generate_random_1d(s.count(), min_random, max_random); set_values(prim, rnd_vec); + } else if (l.data_type == data_types::i4 || l.data_type == data_types::u4) { + VF rnd_vec = rg.generate_random_1d(l.bytes_count(), min_random, max_random); + set_values(prim, rnd_vec); } else if (l.data_type == data_types::f16) { VF rnd_vec = rg.generate_random_1d(s.count(), -1, 1); set_values(prim, rnd_vec); diff --git a/src/plugins/intel_gpu/tests/unit/test_cases/condition_gpu_test.cpp b/src/plugins/intel_gpu/tests/unit/test_cases/condition_gpu_test.cpp index 75764e26ccb8f0..6b71388d11868a 100644 --- a/src/plugins/intel_gpu/tests/unit/test_cases/condition_gpu_test.cpp +++ b/src/plugins/intel_gpu/tests/unit/test_cases/condition_gpu_test.cpp @@ -902,3 +902,148 @@ TEST_F(condition_gpu_tests, empty_body) { TEST_F(condition_gpu_tests, empty_body_cached) { this->test_empty_body(true); } + +TEST(condition_gpu, empty_body_with_different_shapes) { + ov::PartialShape oned_pshape = ov::PartialShape{ 1 }; + ov::PartialShape const_pshape = ov::PartialShape{ }; + cldnn::layout const_layout = { const_pshape, data_types::f32, format::bfyx }; + auto& engine = get_test_engine(); + ExecutionConfig config = get_test_default_config(engine); + config.set_property(ov::intel_gpu::optimize_data(true)); + config.set_property(ov::intel_gpu::allow_new_shape_infer(true)); + auto input_mem = engine.allocate_memory({ oned_pshape, data_types::f32, format::bfyx }); + auto predicate_mem = engine.allocate_memory({ oned_pshape, data_types::u8, format::bfyx }); + auto const_mem = engine.allocate_memory({ oned_pshape, data_types::f32, format::bfyx }); + + primitive_id input_id1 = "input1"; + primitive_id input_id2 = "input2"; + primitive_id input_id3 = "input3"; + primitive_id pred_id = "predicate"; + primitive_id branch_input_id1 = "branch_input1"; + primitive_id branch_input_id2 = "branch_input2"; + primitive_id branch_input_id3 = "branch_input3"; + primitive_id cond_id = "condi"; + + condition::branch branch_true; + { + topology branch_true_topology; + branch_true_topology.add( + input_layout(branch_input_id1, { oned_pshape, data_types::f32, format::bfyx }), + input_layout(branch_input_id2, { oned_pshape, data_types::f32, format::bfyx }), + eltwise("eltwise", { input_info(branch_input_id1), input_info(branch_input_id2) }, eltwise_mode::sum) + ); + branch_true.inner_program = program::build_program(engine, branch_true_topology, config, false, false, true); + branch_true.input_map.insert({input_id1, branch_input_id1}); + branch_true.input_map.insert({input_id2, branch_input_id2}); + branch_true.output_map.insert({0, "eltwise"}); + } + + condition::branch branch_false; + { + topology branch_false_topology; + branch_false_topology.add( + input_layout(branch_input_id3, { const_pshape, data_types::f32, format::bfyx }), + reorder("result", input_info(branch_input_id3), format::bfyx, data_types::f32) + ); + branch_false.inner_program = program::build_program(engine, branch_false_topology, config, false, false, true); + branch_false.input_map.insert({input_id3, branch_input_id3}); + branch_false.output_map.insert({0, "result"}); + } + + topology topology; + topology.add(input_layout(input_id1, input_mem->get_layout())); + topology.add(input_layout(input_id2, input_mem->get_layout())); + topology.add(input_layout(input_id3, const_layout)); + topology.add(input_layout(pred_id, predicate_mem->get_layout())); + topology.add(condition(cond_id, {input_info(pred_id), input_info(input_id1), input_info(input_id2), input_info(input_id3)}, branch_true, branch_false) + ); + + network net(engine, topology, config); + ASSERT_FALSE(net.get_primitive(cond_id)->get_node().as().get_branch_true().inner_program->can_be_optimized()); + ASSERT_TRUE(net.get_primitive(cond_id)->get_node().as().get_branch_false().inner_program->can_be_optimized()); + + set_values(predicate_mem, { 0 }); + net.set_input_data(pred_id, predicate_mem); + set_values(input_mem, { 1 }); + net.set_input_data(input_id1, input_mem); + net.set_input_data(input_id2, input_mem); + set_values(const_mem, { 1 }); + auto const_zero_mem = engine.reinterpret_buffer(*const_mem, const_layout); + net.set_input_data(input_id3, const_zero_mem); + + auto outputs = net.execute(); + ASSERT_EQ(outputs.size(), 1); + auto output = outputs.begin()->second.get_memory(); + auto output_layout = output->get_layout(); + auto out_pshape = output_layout.get_partial_shape(); + ASSERT_EQ(out_pshape, oned_pshape); +} + +TEST(condition_gpu, set_empty_tensor) { + auto& engine = get_test_engine(); + ExecutionConfig config = get_test_default_config(engine); + config.set_property(ov::intel_gpu::optimize_data(true)); + config.set_property(ov::intel_gpu::allow_new_shape_infer(true)); + auto empty_mem = engine.allocate_memory({ { 1, 1, 1, 1 }, data_types::f16, format::bfyx }); + auto empty_input_mem = engine.reinterpret_buffer(*empty_mem, { { 1, 1, 0, 1 }, data_types::f16, format::bfyx }); + auto input_mem = engine.allocate_memory({ { 1, 1, 4, 1 }, data_types::f32, format::bfyx }); + auto predicate_mem = engine.allocate_memory({ { 1, 1, 1, 1 }, data_types::u8, format::bfyx }); + auto concat_data = engine.allocate_memory({ { 1, 1, 4, 1 }, data_types::f32, format::bfyx }); + + set_values(predicate_mem, {1}); + + primitive_id empty_input_id = "input1"; + primitive_id reorder_id = "reorder"; + primitive_id input_id = "input2"; + primitive_id pred_id = "predicate"; + primitive_id branch_input_id1 = "branch_input1"; + primitive_id branch_input_id2 = "branch_input2"; + primitive_id concat_data_id = "concat_data"; + primitive_id concat_id = "concat"; + primitive_id cond_id = "condi"; + + condition::branch branch_true; + { + topology branch_true_topology; + branch_true_topology.add( + input_layout(branch_input_id1, { { 1, 1, -1, 1 }, data_types::f32, format::bfyx }), + data(concat_data_id, concat_data), + concatenation(concat_id, { input_info(branch_input_id1), input_info(concat_data_id) }, 2) + ); + branch_true.inner_program = program::build_program(engine, branch_true_topology, config, false, false, true); + branch_true.input_map.insert({reorder_id, branch_input_id1}); + branch_true.output_map.insert({0, concat_id}); + } + + condition::branch branch_false; + { + topology branch_false_topology; + branch_false_topology.add( + input_layout(branch_input_id2, { { 1, 1, 4, 1 }, data_types::f32, format::bfyx }), + reorder("result", input_info(branch_input_id2), format::bfyx, data_types::f32) + ); + branch_false.inner_program = program::build_program(engine, branch_false_topology, config, false, false, true); + branch_false.input_map.insert({input_id, branch_input_id2}); + branch_false.output_map.insert({0, "result"}); + } + + auto empty_input_layout = layout({ 1, 1, -1, 1 }, data_types::f32, format::bfyx); + + topology topology; + topology.add(input_layout(pred_id, predicate_mem->get_layout())); + topology.add(input_layout(empty_input_id, empty_input_layout)); + topology.add(input_layout(input_id, input_mem->get_layout())); + topology.add(reorder(reorder_id, input_info(empty_input_id), format::bfyx, data_types::f32)); + topology.add(condition(cond_id, {input_info(pred_id), input_info(reorder_id), input_info(input_id)}, branch_true, branch_false)); + + network net(engine, topology, config); + ASSERT_TRUE(net.get_primitive(cond_id)->get_node().as().get_branch_false().inner_program->can_be_optimized()); + ASSERT_FALSE(net.get_primitive(cond_id)->get_node().as().get_branch_true().inner_program->can_be_optimized()); + + net.set_input_data(pred_id, predicate_mem); + net.set_input_data(empty_input_id, empty_input_mem); + net.set_input_data(input_id, input_mem); + + ASSERT_NO_THROW(net.execute()); + ASSERT_NO_THROW(net.get_output(cond_id).get_memory()); +} diff --git a/src/plugins/intel_gpu/tests/unit/test_cases/hash_key_gpu_test.cpp b/src/plugins/intel_gpu/tests/unit/test_cases/hash_key_gpu_test.cpp index 17447be4266141..b2871745b0bab3 100644 --- a/src/plugins/intel_gpu/tests/unit/test_cases/hash_key_gpu_test.cpp +++ b/src/plugins/intel_gpu/tests/unit/test_cases/hash_key_gpu_test.cpp @@ -50,11 +50,11 @@ class check_hash_value: public ::testing::Test { void test_fc_basic(bool is_caching_test) { auto& engine = get_test_engine(); - const int32_t b = 1, in_f = 128, in_x = 1, in_y = 1, out_f = 65; + const int32_t b = 1, in_f = 128, out_f = 65; - auto input_prim = engine.allocate_memory({ { b, in_f, in_y, in_x }, data_types::f32, format::bfyx }); - auto weights_prim = engine.allocate_memory({ { out_f, in_f, in_y, in_x }, data_types::f32, format::bfyx }); - auto bias_prim = engine.allocate_memory({ { 1, 1, out_f, 1 }, data_types::f32, format::bfyx }); + auto input_prim = engine.allocate_memory({ { b, in_f }, data_types::f32, format::bfyx }); + auto weights_prim = engine.allocate_memory({ { out_f, in_f }, data_types::f32, format::bfyx }); + auto bias_prim = engine.allocate_memory({ { out_f }, data_types::f32, format::bfyx }); const auto key_prim_id = "fc"; topology topology( @@ -72,10 +72,10 @@ class check_hash_value: public ::testing::Test { const auto params_hash = primitve->type->get_fake_aligned_params(*prim_inst->get_impl_params()).hash(); if (!engine.get_device_info().supports_immad) { ASSERT_EQ(primitive_hash, 14259723886449306729UL); - ASSERT_EQ(params_hash, 1637150664489130388UL); + ASSERT_EQ(params_hash, 3365957578641948513UL); } else { ASSERT_EQ(primitive_hash, 14259723886449306729UL); - ASSERT_EQ(params_hash, 6343702278017463925UL); + ASSERT_EQ(params_hash, 9831190959346679696UL); } } diff --git a/src/plugins/intel_gpu/tests/unit/test_cases/scatter_update_gpu_test.cpp b/src/plugins/intel_gpu/tests/unit/test_cases/scatter_update_gpu_test.cpp index facc98497043aa..d75290c0d51b5d 100644 --- a/src/plugins/intel_gpu/tests/unit/test_cases/scatter_update_gpu_test.cpp +++ b/src/plugins/intel_gpu/tests/unit/test_cases/scatter_update_gpu_test.cpp @@ -1872,3 +1872,89 @@ TEST(scatter_update_gpu_fp32, output_padding) { } } } + +TEST(scatter_update_gpu_fp32, d8111_axisB_first_iteration_kernel_check) { + // Dictionary : 8x1x1x1 + // Indexes : 4x1x1x1 + // Updates : 4x1x1x1 + // Axis : 0 + // Output : 8x1x1x1 + // Input values in fp32 + + // Indexes: + // 4.f, 3.f, 1.f, 7.f + // + // Updates: + // 9.f, 10.f, 11.f, 12.f + // + // Dictionary: + // 1.f, 2.f, 3.f, 4.f, 5.f, 6.f, 7.f, 8.f + // + // Output: + // 1.f, 11.f, 3.f, 10.f, 9.f, 6.f, 7.f, 12.f + + + auto& engine = get_test_engine(); + + for(const auto target_format : formats2D) { + auto input1 = engine.allocate_memory({data_types::f32, plain_2d_format, tensor{8, 1, 1, 1}}); // Dictionary + auto input2 = engine.allocate_memory({data_types::f32, plain_2d_format, tensor{1, 1, 1, 1}}); // Indexes + auto input3 = engine.allocate_memory({data_types::f32, plain_2d_format, tensor{1, 1, 1, 1}}); // Updates + auto axis = 0; + + set_values(input1, { + 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f + }); + + set_values(input2, { + 4.f + }); + + set_values(input3, { + 9.0f + }); + + topology topology; + topology.add(input_layout("InputDictionary", input1->get_layout())); + topology.add(input_layout("InputText", input2->get_layout())); + topology.add(input_layout("InputUpdates", input3->get_layout())); + topology.add(reorder("DictionaryReordered", input_info("InputDictionary"), target_format, data_types::f32)); + topology.add(reorder("TextReordered", input_info("InputText"), target_format, data_types::f32)); + topology.add(reorder("UpdatesReordered", input_info("InputUpdates"), target_format, data_types::f32)); + topology.add( + scatter_update("scatter_update", input_info("DictionaryReordered"), input_info("TextReordered"), input_info("UpdatesReordered"), axis) + ); + topology.add(reorder("out", input_info("scatter_update"), plain_2d_format, data_types::f32)); + + network network(engine, topology, get_test_default_config(engine)); + + + network.set_input_data("InputDictionary", input1); + network.set_input_data("InputText", input2); + network.set_input_data("InputUpdates", input3); + + // allocate new output memory + layout out_l = network.get_output_memory("out")->get_layout(); + //auto output_mem = engine.allocate_memory({data_types::f32, plain_2d_format, tensor{8, 1, 1, 1}}); + auto output_mem = engine.allocate_memory(out_l); + set_values(output_mem, { + -1.0f, -1.0f, -1.0f, -1.0f, -1.0f, -1.0f, -1.0f, -1.0f + }); + + network.set_output_memory("out", output_mem); + auto outputs = network.execute(); + + auto output = outputs.at("out").get_memory(); + ASSERT_TRUE(engine.is_the_same_buffer(*output_mem, *output)); + cldnn::mem_lock output_ptr(output, get_test_stream()); + + std::vector expected_results = { + 1.0f, 2.0f, 3.0f, 4.0f, 9.0f, 6.0f, 7.0f, 8.0f + }; + + for (size_t i = 0; i < expected_results.size(); ++i) { + ASSERT_EQ(expected_results[i], output_ptr[i]) + << "i=" << i << ", target_format=" << target_format; + } + } +} \ No newline at end of file diff --git a/src/plugins/proxy/src/plugin.cpp b/src/plugins/proxy/src/plugin.cpp index 3a7ce0170b008a..180bb4d1dba26e 100644 --- a/src/plugins/proxy/src/plugin.cpp +++ b/src/plugins/proxy/src/plugin.cpp @@ -394,6 +394,17 @@ std::shared_ptr ov::proxy::Plugin::compile_model(const std:: return std::make_shared(device_model, plugin, remote_context); } +std::shared_ptr ov::proxy::Plugin::compile_model(const std::string& model_path, + const ov::AnyMap& properties) const { + auto dev_name = get_fallback_device(get_device_from_config(properties)); + auto device_config = construct_device_config(dev_name, m_configs, properties); + std::shared_ptr plugin = shared_from_this(); + + auto device_model = get_core()->compile_model(model_path, dev_name, device_config); + auto remote_context = create_proxy_context(device_model, properties); + return std::make_shared(device_model, plugin, remote_context); +} + std::shared_ptr ov::proxy::Plugin::compile_model( const std::shared_ptr& model, const ov::AnyMap& properties, diff --git a/src/plugins/proxy/src/plugin.hpp b/src/plugins/proxy/src/plugin.hpp index 10abf1e00a81da..b9429f94d35974 100644 --- a/src/plugins/proxy/src/plugin.hpp +++ b/src/plugins/proxy/src/plugin.hpp @@ -25,6 +25,9 @@ class Plugin : public ov::IPlugin { std::shared_ptr compile_model(const std::shared_ptr& model, const ov::AnyMap& properties) const override; + std::shared_ptr compile_model(const std::string& model_path, + const ov::AnyMap& properties) const override; + std::shared_ptr compile_model(const std::shared_ptr& model, const ov::AnyMap& properties, const ov::SoPtr& context) const override; diff --git a/src/plugins/template/backend/int_executable.cpp b/src/plugins/template/backend/int_executable.cpp index 7bf130cad87b83..a8cada0e3041e8 100644 --- a/src/plugins/template/backend/int_executable.cpp +++ b/src/plugins/template/backend/int_executable.cpp @@ -123,19 +123,13 @@ bool ov::runtime::interpreter::INTExecutable::call(std::vector& outp std::vector op_outputs; for (size_t i = 0; i < op->get_output_size(); ++i) { auto tensor = op->output(i).get_tensor_ptr(); - ov::Tensor host_tensor; auto it = tensor_map.find(tensor); auto output = op->output(i); if (op::util::is_output(op) || it == tensor_map.end() || !it->second) { - OPENVINO_SUPPRESS_DEPRECATED_START - host_tensor = ov::Tensor( - output.get_element_type(), - output.get_partial_shape().is_dynamic() ? ov::util::make_dynamic_shape() : output.get_shape()); - OPENVINO_SUPPRESS_DEPRECATED_END + op_outputs.emplace_back(output); } else { - host_tensor = it->second; + op_outputs.push_back(it->second); } - op_outputs.push_back(host_tensor); } { diff --git a/src/plugins/template/backend/ops/if.cpp b/src/plugins/template/backend/ops/if.cpp index 2164d83bd58c04..874368d01ccfb6 100644 --- a/src/plugins/template/backend/ops/if.cpp +++ b/src/plugins/template/backend/ops/if.cpp @@ -103,14 +103,9 @@ void function(const std::shared_ptr& function, const ov::TensorVector " bytes"); } - const auto& results = function->get_results(); - outputs.reserve(results.size()); - for (size_t i = 0; i < results.size(); ++i) { - OPENVINO_SUPPRESS_DEPRECATED_START - ov::Shape res_shape = results[i]->get_output_partial_shape(0).is_static() ? results[i]->get_output_shape(0) - : ov::util::make_dynamic_shape(); - OPENVINO_SUPPRESS_DEPRECATED_END - outputs.push_back(ov::Tensor(results[i]->get_element_type(), res_shape)); + outputs.reserve(function->get_output_size()); + for (const auto& result : function->get_results()) { + outputs.emplace_back(result->output(0)); } call(outputs, inputs, function); } diff --git a/src/plugins/template/backend/ops/tensor_iterator.cpp b/src/plugins/template/backend/ops/tensor_iterator.cpp index d7398b5126fcb8..89dd7ce2ae96f4 100644 --- a/src/plugins/template/backend/ops/tensor_iterator.cpp +++ b/src/plugins/template/backend/ops/tensor_iterator.cpp @@ -6,7 +6,6 @@ #include "backend.hpp" #include "evaluate_node.hpp" -#include "tensor_conversion_util.hpp" namespace ti_v0 { ov::reference::custom_evaluate_function evaluate = diff --git a/src/plugins/template/tests/functional/op_reference/multinomial.cpp b/src/plugins/template/tests/functional/op_reference/multinomial.cpp index c7e5d9a7b7da45..1cbde76d05c58f 100644 --- a/src/plugins/template/tests/functional/op_reference/multinomial.cpp +++ b/src/plugins/template/tests/functional/op_reference/multinomial.cpp @@ -83,36 +83,37 @@ template std::vector generateMultinomialParams() { using vt = typename ov::element_type_traits::value_type; - const ov::Shape prob_2d_shape{2, 4}; - const ov::Shape prob_1d_shape{4}; const ov::Shape num_samples_shape{1}; - const ov::Shape prob_1d_shape_expand_small{2}; - const ov::Shape out_1d_shape_expand_big{16}; - reference_tests::Tensor num_samples(num_samples_shape, ov::element::Type_t::i32, std::vector{4}); reference_tests::Tensor num_samples_big(num_samples_shape, ov::element::Type_t::i32, std::vector{16}); + const ov::Shape prob_2d_shape{2, 4}; + const ov::Shape prob_pseudo_1d_shape{1, 4}; + const ov::Shape prob_pseudo_1d_shape_expand_small{1, 2}; reference_tests::Tensor probabilities_2d_no_log(prob_2d_shape, et, std::vector{0.001, 0.01, 0.1, 0.899, 0.899, 0.1, 0.01, 0.001}); reference_tests::Tensor probabilities_2d_log(prob_2d_shape, et, std::vector{1, 2, 3, 4, 2, 4, 6, 8}); - reference_tests::Tensor probabilities_1d_no_log(prob_1d_shape, et, std::vector{0.001, 0.01, 0.1, 0.899}); - reference_tests::Tensor probabilities_1d_log(prob_1d_shape, et, std::vector{1, 10, 7, 3}); - reference_tests::Tensor probabilities_1d_expand(prob_1d_shape_expand_small, et, std::vector{0.00001, 0.99999}); + reference_tests::Tensor probabilities_1d_no_log(prob_pseudo_1d_shape, et, std::vector{0.001, 0.01, 0.1, 0.899}); + reference_tests::Tensor probabilities_1d_log(prob_pseudo_1d_shape, et, std::vector{1, 10, 7, 3}); + reference_tests::Tensor probabilities_1d_expand(prob_pseudo_1d_shape_expand_small, + et, + std::vector{0.00001, 0.99999}); + const ov::Shape out_pseudo_1d_shape_expand{1, 16}; reference_tests::Tensor output_2d_no_log_replacement(prob_2d_shape, ov::element::Type_t::i32, std::vector{3, 3, 3, 3, 0, 0, 0, 0}); reference_tests::Tensor output_2d_log_replacement(prob_2d_shape, ov::element::Type_t::i32, std::vector{3, 3, 2, 3, 3, 3, 3, 3}); - reference_tests::Tensor output_1d_no_log_no_replacement(prob_1d_shape, + reference_tests::Tensor output_1d_no_log_no_replacement(prob_pseudo_1d_shape, ov::element::Type_t::i64, std::vector{3, 2, 1, 0}); - reference_tests::Tensor output_1d_log_no_replacement(prob_1d_shape, + reference_tests::Tensor output_1d_log_no_replacement(prob_pseudo_1d_shape, ov::element::Type_t::i64, std::vector{1, 2, 3, 0}); - reference_tests::Tensor output_1d_expand(out_1d_shape_expand_big, + reference_tests::Tensor output_1d_expand(out_pseudo_1d_shape_expand, ov::element::Type_t::i64, std::vector{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}); diff --git a/src/tests/functional/plugin/conformance/test_runner/conformance_infra/src/main.cpp b/src/tests/functional/plugin/conformance/test_runner/conformance_infra/src/main.cpp index 95b29fb8779938..420ea648aa7056 100644 --- a/src/tests/functional/plugin/conformance/test_runner/conformance_infra/src/main.cpp +++ b/src/tests/functional/plugin/conformance/test_runner/conformance_infra/src/main.cpp @@ -22,7 +22,7 @@ void RegisterTestCustomQueries(void) { std::map& extTestQueries = *::PostgreSQLLink::get_ext_test_queries(); std::map& extTestNames = *::PostgreSQLLink::get_ext_test_names(); - std::string testName("checkPluginImplementationCompileModel"); + std::string testName("checkPluginImplementation"); extTestQueries[testName + "_ON_START"] = "OpImplCheck_CheckPluginImpl($__test_id, '$opName', '$opSet', " "'$targetDevice', '$targetDeviceArch', '$targetDeviceName', '$config', $__is_temp)"; diff --git a/src/tests/functional/plugin/conformance/test_runner/op_conformance_runner/include/utils/models.hpp b/src/tests/functional/plugin/conformance/test_runner/op_conformance_runner/include/utils/models.hpp index 7c259c8960c191..a33c9bafdf6c2d 100644 --- a/src/tests/functional/plugin/conformance/test_runner/op_conformance_runner/include/utils/models.hpp +++ b/src/tests/functional/plugin/conformance/test_runner/op_conformance_runner/include/utils/models.hpp @@ -55,6 +55,12 @@ get_model_paths(const std::vector& conformance_ir_paths, //Save it in a list, first value - path, second - amout of tests with this path for (auto& val : tmp_buf) { bool is_op = false; +#ifdef _WIN32 + for (auto it = val.begin(); it != val.end(); ++it) { + if (*it == '/') + val.replace(it, it + 1, ov::test::utils::FileSeparator); + } +#endif for (const auto& path_item : ov::test::utils::splitStringByDelimiter(val, ov::test::utils::FileSeparator)) { auto tmp_path_item = path_item; auto pos = tmp_path_item.find('-'); 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 ab025592455daa..34201bdba90fe6 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 @@ -74,9 +74,9 @@ std::string ReadIRTest::getTestCaseName(const testing::TestParamInfo model_pair; std::tie(model_pair, targetDevice, configuration) = this->GetParam(); std::tie(path_to_model, path_to_ref_tensor) = model_pair; @@ -195,20 +192,23 @@ void ReadIRTest::SetUp() { // Try to resolve missing info if (splittedFilename.size() > 2) { auto pos = splittedFilename[2].find('-'); - std::string op_name = "", op_version = "opset"; + std::string op_name = "", op_version = ""; if (pos != std::string::npos) { op_name = splittedFilename[2].substr(0, pos); - op_version += splittedFilename[2].substr(pos + 1); - if (ov::test::op_conformance::unique_ops.find(op_name) != ov::test::op_conformance::unique_ops.end() && - std::find(ov::test::op_conformance::unique_ops[op_name].begin(), - ov::test::op_conformance::unique_ops[op_name].end(), - op_version) != ov::test::op_conformance::unique_ops[op_name].end()) { + op_version = splittedFilename[2].substr(pos + 1); + if (unique_ops.find(op_name) != unique_ops.end() && + std::find(unique_ops[op_name].begin(), + unique_ops[op_name].end(), + op_version) != unique_ops[op_name].end()) { pgLink->set_custom_field("opName", op_name, true); pgLink->set_custom_field("opSet", op_version, true); } + } else if (splittedFilename.size() > 3 && splittedFilename[3] == "subgraph") { + pgLink->set_custom_field("opName", splittedFilename[1], true); + pgLink->set_custom_field("opSet", "subgraph", true); } else { for (const auto& path_part : splittedFilename) { - if (ov::test::op_conformance::unique_ops.find(path_part) != ov::test::op_conformance::unique_ops.end()) { + if (unique_ops.find(path_part) != unique_ops.end()) { op_name = path_part; break; } diff --git a/src/tests/functional/plugin/shared/include/single_op_tests/multinomial.hpp b/src/tests/functional/plugin/shared/include/single_op_tests/multinomial.hpp new file mode 100644 index 00000000000000..3779b2e4333567 --- /dev/null +++ b/src/tests/functional/plugin/shared/include/single_op_tests/multinomial.hpp @@ -0,0 +1,15 @@ +// Copyright (C) 2022 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include "shared_test_classes/single_op/multinomial.hpp" + +namespace ov { +namespace test { +TEST_P(MultinomialLayerTest, Inference) { + run(); +}; +} // namespace test +} // namespace ov 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 6d23a1f615d95f..c205ec0c1f4e26 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 @@ -46,6 +46,18 @@ TEST_P(OVInferRequestIOTensorTest, failToSetNullptrForOutput) { ASSERT_THROW(req.set_tensor(output, {}), ov::Exception); } +TEST_P(OVInferRequestIOTensorTest, failToSetUninitializedInputTensor) { + ov::Tensor tensor; + OV_ASSERT_NO_THROW(req = execNet.create_infer_request()); + ASSERT_THROW(req.set_tensor(input, tensor), ov::Exception); +} + +TEST_P(OVInferRequestIOTensorTest, failToSetUninitializedOutputTensor) { + ov::Tensor tensor; + OV_ASSERT_NO_THROW(req = execNet.create_infer_request()); + ASSERT_THROW(req.set_tensor(output, tensor), ov::Exception); +} + TEST_P(OVInferRequestIOTensorTest, canSetAndGetInput) { auto tensor = utils::create_and_fill_tensor(input.get_element_type(), input.get_shape()); OV_ASSERT_NO_THROW(req.set_tensor(input, tensor)); @@ -175,6 +187,15 @@ TEST_P(OVInferRequestIOTensorTest, canInferAfterIOBlobReallocation) { OV_ASSERT_NO_THROW(req.get_tensor(output)); } +TEST_P(OVInferRequestIOTensorTest, canInferWithGetOut) { + ov::Tensor output_tensor; + OV_ASSERT_NO_THROW(output_tensor = req.get_tensor(output)); + OV_ASSERT_NO_THROW(req.infer()); + OV_ASSERT_NO_THROW(req.start_async()); + OV_ASSERT_NO_THROW(req.wait()); + OV_ASSERT_NO_THROW(req.get_tensor(output)); +} + TEST_P(OVInferRequestIOTensorTest, InferStaticNetworkSetChangedInputTensorThrow) { const ov::Shape shape1 = {1, 2, 32, 32}; const ov::Shape shape2 = {1, 2, 40, 40}; 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 34cdd1757b2f8e..b320b821675f23 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 @@ -607,6 +607,16 @@ TEST_P(OVGetMetricPropsTest, GetMetricAndPrintNoThrow_AVAILABLE_DEVICES) { OV_ASSERT_PROPERTY_SUPPORTED(ov::available_devices); } +TEST_P(OVGetMetricPropsTest, GetMetriDeviceFullNameWithoutAdditionalTerminatorChars) { + ov::Core core = createCoreWithTemplate(); + auto supported_properties = core.get_property(target_device, ov::supported_properties); + if (util::contains(supported_properties, ov::device::full_name)) { + std::string full_name; + OV_ASSERT_NO_THROW(full_name = core.get_property(target_device, ov::device::full_name)); + EXPECT_EQ(full_name.size(), strlen(full_name.c_str())); + } +} + TEST_P(OVGetMetricPropsTest, GetMetricAndPrintNoThrow_OPTIMIZATION_CAPABILITIES) { ov::Core ie = createCoreWithTemplate(); std::vector capabilities; diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_op/multinomial.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_op/multinomial.hpp new file mode 100644 index 00000000000000..3e2512ec0bd827 --- /dev/null +++ b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_op/multinomial.hpp @@ -0,0 +1,38 @@ +// Copyright (C) 2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include "openvino/runtime/tensor.hpp" +#include "shared_test_classes/base/ov_subgraph.hpp" + +namespace ov { +namespace test { + +typedef std::tuple, // global_op_seed + std::string // device_name + > + MultinomialTestParams; + +class MultinomialLayerTest : 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& target_shapes) override; + +private: + ov::Tensor m_probs; + ov::Tensor m_num_samples; +}; +} // namespace test +} // namespace ov diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/subgraph/reshape_permute_conv_permute_reshape_act.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/subgraph/reshape_permute_conv_permute_reshape_act.hpp index a7819ec1d27dde..4932b8769354e9 100644 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/subgraph/reshape_permute_conv_permute_reshape_act.hpp +++ b/src/tests/functional/shared_test_classes/include/shared_test_classes/subgraph/reshape_permute_conv_permute_reshape_act.hpp @@ -15,14 +15,14 @@ namespace ov { namespace test { - typedef std::tuple< - ov::element::Type, // Network Type - std::string, // Target Device - std::array, // Input shape - std::array, // Kernel shape - size_t, // Output channels - std::map // Configuration - > ConvReshapeActParams; +typedef std::tuple, // Input shape + std::array, // Kernel shape + size_t, // Output channels + ov::AnyMap // Configuration + > + ConvReshapeActParams; class ConvReshapeAct : public testing::WithParamInterface, virtual public ov::test::SubgraphBaseStaticTest { 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 b1c5eb9e9832ac..c33642d48d76f9 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 @@ -217,13 +217,14 @@ void SubgraphBaseTest::import_export() { std::stringstream strm; compiledModel.export_model(strm); ov::CompiledModel importedModel = core->import_model(strm, targetDevice, configuration); - auto importedFunction = importedModel.get_runtime_model()->clone(); + const auto importedFunction = importedModel.get_runtime_model()->clone(); + const auto runtimeModel = compiledModel.get_runtime_model()->clone(); auto comparator = FunctionsComparator::with_default() .enable(FunctionsComparator::ATTRIBUTES) .enable(FunctionsComparator::NAMES) .enable(FunctionsComparator::CONST_VALUES); - auto res = comparator.compare(importedFunction, function); + auto res = comparator.compare(importedFunction, runtimeModel); if (!res.valid) { throw std::runtime_error(res.message); } diff --git a/src/tests/functional/shared_test_classes/src/single_op/multinomial.cpp b/src/tests/functional/shared_test_classes/src/single_op/multinomial.cpp new file mode 100644 index 00000000000000..429ef11e5475fb --- /dev/null +++ b/src/tests/functional/shared_test_classes/src/single_op/multinomial.cpp @@ -0,0 +1,118 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "shared_test_classes/single_op/multinomial.hpp" + +#include "ov_models/builders.hpp" + +using namespace ov::test; + +namespace ov { +namespace test { +std::string MultinomialLayerTest::getTestCaseName(const testing::TestParamInfo& obj) { + std::string test_type; + ov::Tensor probs; + ov::Tensor num_samples; + ov::test::ElementType convert_type; + bool with_replacement; + bool log_probs; + std::pair global_op_seed; + std::string device_name; + + std::tie(test_type, probs, num_samples, convert_type, with_replacement, log_probs, global_op_seed, device_name) = + obj.param; + + uint64_t global_seed = global_op_seed.first; + uint64_t op_seed = global_op_seed.second; + + const char separator = '_'; + std::ostringstream result; + result << test_type << separator; + result << "probs_shape=" << probs.get_shape().to_string() << separator; + if (num_samples.get_element_type() == ov::test::ElementType::i32) { + result << "num_samples=" << static_cast(num_samples.data())[0] << separator; + } else { // i64 + result << "num_samples=" << static_cast(num_samples.data())[0] << separator; + } + result << "convert_type=" << convert_type << separator; + result << "replace=" << ov::test::utils::bool2str(with_replacement) << separator; + result << "log=" << ov::test::utils::bool2str(log_probs) << separator; + result << "seed_g=" << global_seed << separator; + result << "seed_o=" << op_seed << separator; + result << "device=" << device_name; + + return result.str(); +} + +void MultinomialLayerTest::SetUp() { + MultinomialTestParams test_params; + + std::string test_type; + ov::Tensor probs; + ov::Tensor num_samples; + ov::test::ElementType convert_type; + bool with_replacement; + bool log_probs; + std::pair global_op_seed; + + std::tie(test_type, probs, num_samples, convert_type, with_replacement, log_probs, global_op_seed, targetDevice) = + GetParam(); + + m_probs = probs; + m_num_samples = num_samples; + + uint64_t global_seed = global_op_seed.first; + uint64_t op_seed = global_op_seed.second; + + InputShape probs_shape; + InputShape num_samples_shape; + const ov::Shape probs_tensor_shape = probs.get_shape(); + const ov::Shape num_samples_tensor_shape = num_samples.get_shape(); + if (test_type == "static") { + probs_shape = {ov::PartialShape(probs_tensor_shape), {probs_tensor_shape}}; + num_samples_shape = {ov::PartialShape(num_samples_tensor_shape), {num_samples_tensor_shape}}; + } else { // dynamic + probs_shape = {ov::PartialShape::dynamic(ov::Rank(probs_tensor_shape.size())), {probs_tensor_shape}}; + num_samples_shape = {ov::PartialShape::dynamic(ov::Rank(num_samples_tensor_shape.size())), + {num_samples_tensor_shape}}; + } + init_input_shapes({probs_shape, num_samples_shape}); + + ov::ParameterVector params; + std::vector> inputs; + + auto probs_param = std::make_shared(probs.get_element_type(), probs_shape.first); + probs_param->set_friendly_name("probs"); + inputs.push_back(probs_param); + params.push_back(probs_param); + + auto num_samples_param = + std::make_shared(num_samples.get_element_type(), num_samples_shape.first); + num_samples_param->set_friendly_name("num_samples"); + inputs.push_back(num_samples_param); + params.push_back(num_samples_param); + + auto multinomial = std::make_shared(inputs[0], + inputs[1], + convert_type, + with_replacement, + log_probs, + global_seed, + op_seed); + + ov::ResultVector results{std::make_shared(multinomial)}; + function = std::make_shared(results, params, "Multinomial"); +} + +void MultinomialLayerTest::generate_inputs(const std::vector& target_shapes) { + inputs.clear(); + const auto& func_inputs = function->inputs(); + + auto& probs = func_inputs[0]; + inputs.insert({probs.get_node_shared_ptr(), m_probs}); + auto& num_samples = func_inputs[1]; + inputs.insert({num_samples.get_node_shared_ptr(), m_num_samples}); +} +} // namespace test +} // namespace ov diff --git a/src/tests/functional/shared_test_classes/src/subgraph/reshape_permute_conv_permute_reshape_act.cpp b/src/tests/functional/shared_test_classes/src/subgraph/reshape_permute_conv_permute_reshape_act.cpp index 13cc4af1d2d6d0..4239eab1e4ad6b 100644 --- a/src/tests/functional/shared_test_classes/src/subgraph/reshape_permute_conv_permute_reshape_act.cpp +++ b/src/tests/functional/shared_test_classes/src/subgraph/reshape_permute_conv_permute_reshape_act.cpp @@ -13,7 +13,7 @@ std::string ConvReshapeAct::getTestCaseName(const testing::TestParamInfo input_shape; std::array kernel_shape; size_t output_channels; - std::map configuration; + ov::AnyMap configuration; std::tie(model_type, targetName, input_shape, kernel_shape, output_channels, configuration) = obj.param; @@ -25,7 +25,7 @@ std::string ConvReshapeAct::getTestCaseName(const testing::TestParamInfo(); } return results.str(); } @@ -35,7 +35,7 @@ void ConvReshapeAct::SetUp() { std::array input_shape; std::array kernel_shape; size_t output_channels; - std::map additional_config; + ov::AnyMap additional_config; std::tie(model_type, targetDevice, input_shape, kernel_shape, output_channels, additional_config) = this->GetParam(); diff --git a/src/tests/ov_helpers/ov_snippets_models/src/subgraph_lowered.cpp b/src/tests/ov_helpers/ov_snippets_models/src/subgraph_lowered.cpp index 6dcf8621df3396..78f61752e66c81 100644 --- a/src/tests/ov_helpers/ov_snippets_models/src/subgraph_lowered.cpp +++ b/src/tests/ov_helpers/ov_snippets_models/src/subgraph_lowered.cpp @@ -15,7 +15,7 @@ std::shared_ptr AddFunctionLoweredBroadcast::initLowered() const { auto data0 = std::make_shared(precision, input_shapes[0]); std::shared_ptr add_input0 = nullptr; if (!broadcast_shapes[0].empty() && broadcast_shapes[0].back() != input_shapes[0].rbegin()->get_length()) { - add_input0 = std::make_shared(data0, broadcast_shapes[0]); + add_input0 = std::make_shared(data0, *broadcast_shapes[0].rbegin()); } else { add_input0 = std::make_shared(data0); } @@ -23,7 +23,7 @@ std::shared_ptr AddFunctionLoweredBroadcast::initLowered() const { auto data1 = std::make_shared(precision, input_shapes[1]); std::shared_ptr add_input1 = nullptr; if (!broadcast_shapes[1].empty() && broadcast_shapes[1].back() != input_shapes[1].rbegin()->get_length()) { - add_input1 = std::make_shared(data1, broadcast_shapes[1]); + add_input1 = std::make_shared(data1, *broadcast_shapes[1].rbegin()); } else { add_input1 = std::make_shared(data1); } @@ -45,13 +45,13 @@ std::shared_ptr EltwiseThreeInputsLoweredFunction::initLowered() cons } else { // The last dim is processed by vector Tile, so BroadcastLoad is required if the last dim being broadcasted if (input_shapes[i].rbegin()->get_length() == 1 && broadcast_shapes[i].back() != 1) { - return std::make_shared(input_params[i], broadcast_shapes[i]); + return std::make_shared(input_params[i], *broadcast_shapes[i].rbegin()); // Todo: Cover this logics with functional tests, Review FakeBroadcast Emitter // Broadcasting of other dims is handled by BroadcastMove. Strictly speaking, broadcasting is achieved via // appropriate pointer arithmetics in this case. } else { auto load = std::make_shared(input_params[i]); - return std::make_shared(load, broadcast_shapes[i]); + return std::make_shared(load, *broadcast_shapes[i].rbegin()); } } }; @@ -66,7 +66,7 @@ std::shared_ptr EltwiseThreeInputsLoweredFunction::initLowered() cons if (broadcast_shapes[2].empty()) sub_out = sub; else - sub_out = std::make_shared(sub, broadcast_shapes[2]); + sub_out = std::make_shared(sub, *broadcast_shapes[2].rbegin()); auto mul = std::make_shared(add, sub_out); auto store = std::make_shared(mul); return std::make_shared(NodeVector{store}, input_params); @@ -119,9 +119,7 @@ std::shared_ptr BroadcastAddLoweredFunction::initLowered() const { ov::NodeVector loads(datas.size(), nullptr); for (auto i = 0; i < datas.size(); i++) { if (input_shapes[i].get_shape().back() != last_dim) { - auto new_shape = input_shapes[i]; - new_shape[new_shape.size() - 1] = last_dim; - loads[i] = std::make_shared(datas[i], new_shape); + loads[i] = std::make_shared(datas[i], ov::Dimension(last_dim)); } else { loads[i] = std::make_shared(datas[i]); } diff --git a/src/tests/test_utils/common_test_utils/include/common_test_utils/node_builders/activation.hpp b/src/tests/test_utils/common_test_utils/include/common_test_utils/node_builders/activation.hpp index 70e5fcce77cf7a..5a6b13d422bd81 100644 --- a/src/tests/test_utils/common_test_utils/include/common_test_utils/node_builders/activation.hpp +++ b/src/tests/test_utils/common_test_utils/include/common_test_utils/node_builders/activation.hpp @@ -2,6 +2,8 @@ // SPDX-License-Identifier: Apache-2.0 // +#pragma once + #include "common_test_utils/test_enums.hpp" #include "openvino/core/node.hpp" diff --git a/src/tests/test_utils/common_test_utils/include/common_test_utils/node_builders/augru_cell.hpp b/src/tests/test_utils/common_test_utils/include/common_test_utils/node_builders/augru_cell.hpp index 7d02653066c98c..4c35345db5178f 100644 --- a/src/tests/test_utils/common_test_utils/include/common_test_utils/node_builders/augru_cell.hpp +++ b/src/tests/test_utils/common_test_utils/include/common_test_utils/node_builders/augru_cell.hpp @@ -2,6 +2,8 @@ // SPDX-License-Identifier: Apache-2.0 // +#pragma once + #include "common_test_utils/test_enums.hpp" #include "openvino/core/node.hpp" diff --git a/src/tests/test_utils/common_test_utils/include/common_test_utils/node_builders/binary_convolution.hpp b/src/tests/test_utils/common_test_utils/include/common_test_utils/node_builders/binary_convolution.hpp index 3b769443056472..9cb3f8d56714cd 100644 --- a/src/tests/test_utils/common_test_utils/include/common_test_utils/node_builders/binary_convolution.hpp +++ b/src/tests/test_utils/common_test_utils/include/common_test_utils/node_builders/binary_convolution.hpp @@ -2,6 +2,8 @@ // SPDX-License-Identifier: Apache-2.0 // +#pragma once + #include "openvino/core/node.hpp" namespace ov { diff --git a/src/tests/test_utils/common_test_utils/include/common_test_utils/node_builders/comparison.hpp b/src/tests/test_utils/common_test_utils/include/common_test_utils/node_builders/comparison.hpp index 3cf7095f161b9e..24e6abffae1131 100644 --- a/src/tests/test_utils/common_test_utils/include/common_test_utils/node_builders/comparison.hpp +++ b/src/tests/test_utils/common_test_utils/include/common_test_utils/node_builders/comparison.hpp @@ -2,6 +2,8 @@ // SPDX-License-Identifier: Apache-2.0 // +#pragma once + #include "common_test_utils/test_enums.hpp" #include "openvino/core/node.hpp" diff --git a/src/tests/test_utils/common_test_utils/include/common_test_utils/node_builders/convolution.hpp b/src/tests/test_utils/common_test_utils/include/common_test_utils/node_builders/convolution.hpp index 9060fd132a8a39..34d29174bcca7f 100644 --- a/src/tests/test_utils/common_test_utils/include/common_test_utils/node_builders/convolution.hpp +++ b/src/tests/test_utils/common_test_utils/include/common_test_utils/node_builders/convolution.hpp @@ -2,6 +2,8 @@ // SPDX-License-Identifier: Apache-2.0 // +#pragma once + #include "openvino/core/node.hpp" namespace ov { diff --git a/src/tests/test_utils/common_test_utils/include/common_test_utils/node_builders/convolution_backprop_data.hpp b/src/tests/test_utils/common_test_utils/include/common_test_utils/node_builders/convolution_backprop_data.hpp index c0ae90df18b286..4362ea90720fb9 100644 --- a/src/tests/test_utils/common_test_utils/include/common_test_utils/node_builders/convolution_backprop_data.hpp +++ b/src/tests/test_utils/common_test_utils/include/common_test_utils/node_builders/convolution_backprop_data.hpp @@ -2,6 +2,8 @@ // SPDX-License-Identifier: Apache-2.0 // +#pragma once + #include "openvino/core/node.hpp" namespace ov { diff --git a/src/tests/test_utils/common_test_utils/include/common_test_utils/node_builders/dft.hpp b/src/tests/test_utils/common_test_utils/include/common_test_utils/node_builders/dft.hpp index 85b7958d5051e6..c90259bbe2f800 100644 --- a/src/tests/test_utils/common_test_utils/include/common_test_utils/node_builders/dft.hpp +++ b/src/tests/test_utils/common_test_utils/include/common_test_utils/node_builders/dft.hpp @@ -2,6 +2,8 @@ // SPDX-License-Identifier: Apache-2.0 // +#pragma once + #include "common_test_utils/test_enums.hpp" #include "openvino/core/node.hpp" diff --git a/src/tests/test_utils/common_test_utils/include/common_test_utils/node_builders/eltwise.hpp b/src/tests/test_utils/common_test_utils/include/common_test_utils/node_builders/eltwise.hpp index 8b28f345b0d589..8e491be7144bc4 100644 --- a/src/tests/test_utils/common_test_utils/include/common_test_utils/node_builders/eltwise.hpp +++ b/src/tests/test_utils/common_test_utils/include/common_test_utils/node_builders/eltwise.hpp @@ -2,6 +2,8 @@ // SPDX-License-Identifier: Apache-2.0 // +#pragma once + #include "common_test_utils/test_enums.hpp" #include "openvino/core/node.hpp" diff --git a/src/tests/test_utils/common_test_utils/include/common_test_utils/node_builders/embedding_bag_offsets_sum.hpp b/src/tests/test_utils/common_test_utils/include/common_test_utils/node_builders/embedding_bag_offsets_sum.hpp index f05fba41f1b931..281022fd74fe04 100644 --- a/src/tests/test_utils/common_test_utils/include/common_test_utils/node_builders/embedding_bag_offsets_sum.hpp +++ b/src/tests/test_utils/common_test_utils/include/common_test_utils/node_builders/embedding_bag_offsets_sum.hpp @@ -2,6 +2,8 @@ // SPDX-License-Identifier: Apache-2.0 // +#pragma once + #include "openvino/core/node.hpp" namespace ov { diff --git a/src/tests/test_utils/common_test_utils/include/common_test_utils/node_builders/embedding_bag_packed_sum.hpp b/src/tests/test_utils/common_test_utils/include/common_test_utils/node_builders/embedding_bag_packed_sum.hpp index 735027efb6875d..05ecb45b95a792 100644 --- a/src/tests/test_utils/common_test_utils/include/common_test_utils/node_builders/embedding_bag_packed_sum.hpp +++ b/src/tests/test_utils/common_test_utils/include/common_test_utils/node_builders/embedding_bag_packed_sum.hpp @@ -2,6 +2,8 @@ // SPDX-License-Identifier: Apache-2.0 // +#pragma once + #include "openvino/core/node.hpp" namespace ov { diff --git a/src/tests/test_utils/common_test_utils/include/common_test_utils/node_builders/embedding_segments_sum.hpp b/src/tests/test_utils/common_test_utils/include/common_test_utils/node_builders/embedding_segments_sum.hpp index 8c8aefd9dc7931..ad36485b0b306e 100644 --- a/src/tests/test_utils/common_test_utils/include/common_test_utils/node_builders/embedding_segments_sum.hpp +++ b/src/tests/test_utils/common_test_utils/include/common_test_utils/node_builders/embedding_segments_sum.hpp @@ -2,6 +2,8 @@ // SPDX-License-Identifier: Apache-2.0 // +#pragma once + #include "openvino/core/node.hpp" namespace ov { diff --git a/src/tests/test_utils/common_test_utils/include/common_test_utils/node_builders/fully_connected.hpp b/src/tests/test_utils/common_test_utils/include/common_test_utils/node_builders/fully_connected.hpp index be4b0b7a993fee..59449b6a6d57c3 100644 --- a/src/tests/test_utils/common_test_utils/include/common_test_utils/node_builders/fully_connected.hpp +++ b/src/tests/test_utils/common_test_utils/include/common_test_utils/node_builders/fully_connected.hpp @@ -2,6 +2,8 @@ // SPDX-License-Identifier: Apache-2.0 // +#pragma once + #include "common_test_utils/test_enums.hpp" #include "openvino/core/node.hpp" diff --git a/src/tests/test_utils/common_test_utils/include/common_test_utils/node_builders/gather_nd.hpp b/src/tests/test_utils/common_test_utils/include/common_test_utils/node_builders/gather_nd.hpp index f264312dbd0a4f..ee4041eac628d9 100644 --- a/src/tests/test_utils/common_test_utils/include/common_test_utils/node_builders/gather_nd.hpp +++ b/src/tests/test_utils/common_test_utils/include/common_test_utils/node_builders/gather_nd.hpp @@ -2,6 +2,8 @@ // SPDX-License-Identifier: Apache-2.0 // +#pragma once + #include "openvino/core/node.hpp" namespace ov { diff --git a/src/tests/test_utils/common_test_utils/include/common_test_utils/node_builders/group_convolution.hpp b/src/tests/test_utils/common_test_utils/include/common_test_utils/node_builders/group_convolution.hpp index 347025f2addd01..5790a7769d7ec3 100644 --- a/src/tests/test_utils/common_test_utils/include/common_test_utils/node_builders/group_convolution.hpp +++ b/src/tests/test_utils/common_test_utils/include/common_test_utils/node_builders/group_convolution.hpp @@ -2,6 +2,8 @@ // SPDX-License-Identifier: Apache-2.0 // +#pragma once + #include "openvino/core/node.hpp" namespace ov { diff --git a/src/tests/test_utils/common_test_utils/include/common_test_utils/node_builders/group_convolution_backprop_data.hpp b/src/tests/test_utils/common_test_utils/include/common_test_utils/node_builders/group_convolution_backprop_data.hpp index 14283a8a15511a..190e367b6f2a85 100644 --- a/src/tests/test_utils/common_test_utils/include/common_test_utils/node_builders/group_convolution_backprop_data.hpp +++ b/src/tests/test_utils/common_test_utils/include/common_test_utils/node_builders/group_convolution_backprop_data.hpp @@ -2,6 +2,8 @@ // SPDX-License-Identifier: Apache-2.0 // +#pragma once + #include "openvino/core/node.hpp" namespace ov { diff --git a/src/tests/test_utils/common_test_utils/include/common_test_utils/node_builders/gru_cell.hpp b/src/tests/test_utils/common_test_utils/include/common_test_utils/node_builders/gru_cell.hpp index 71eef86d4f57f9..3e2a06e6e47379 100644 --- a/src/tests/test_utils/common_test_utils/include/common_test_utils/node_builders/gru_cell.hpp +++ b/src/tests/test_utils/common_test_utils/include/common_test_utils/node_builders/gru_cell.hpp @@ -2,6 +2,8 @@ // SPDX-License-Identifier: Apache-2.0 // +#pragma once + #include "common_test_utils/test_enums.hpp" #include "openvino/core/node.hpp" diff --git a/src/tests/test_utils/common_test_utils/include/common_test_utils/node_builders/logical.hpp b/src/tests/test_utils/common_test_utils/include/common_test_utils/node_builders/logical.hpp index 8617c9ab4295dc..eb5d6684cb3297 100644 --- a/src/tests/test_utils/common_test_utils/include/common_test_utils/node_builders/logical.hpp +++ b/src/tests/test_utils/common_test_utils/include/common_test_utils/node_builders/logical.hpp @@ -2,6 +2,8 @@ // SPDX-License-Identifier: Apache-2.0 // +#pragma once + #include "common_test_utils/test_enums.hpp" #include "openvino/core/node.hpp" diff --git a/src/tests/test_utils/common_test_utils/include/common_test_utils/node_builders/lstm_cell.hpp b/src/tests/test_utils/common_test_utils/include/common_test_utils/node_builders/lstm_cell.hpp index 0aa1f4b29da218..058b92388b5bb4 100644 --- a/src/tests/test_utils/common_test_utils/include/common_test_utils/node_builders/lstm_cell.hpp +++ b/src/tests/test_utils/common_test_utils/include/common_test_utils/node_builders/lstm_cell.hpp @@ -2,6 +2,8 @@ // SPDX-License-Identifier: Apache-2.0 // +#pragma once + #include "common_test_utils/test_enums.hpp" #include "openvino/core/node.hpp" diff --git a/src/tests/test_utils/common_test_utils/include/common_test_utils/node_builders/rdft.hpp b/src/tests/test_utils/common_test_utils/include/common_test_utils/node_builders/rdft.hpp index fc416f00f8992e..425b6cb30bab8d 100644 --- a/src/tests/test_utils/common_test_utils/include/common_test_utils/node_builders/rdft.hpp +++ b/src/tests/test_utils/common_test_utils/include/common_test_utils/node_builders/rdft.hpp @@ -2,6 +2,8 @@ // SPDX-License-Identifier: Apache-2.0 // +#pragma once + #include "common_test_utils/test_enums.hpp" #include "openvino/core/node.hpp" diff --git a/src/tests/test_utils/common_test_utils/include/common_test_utils/node_builders/reduce.hpp b/src/tests/test_utils/common_test_utils/include/common_test_utils/node_builders/reduce.hpp index 171887dcbb1cff..06c062460c306a 100644 --- a/src/tests/test_utils/common_test_utils/include/common_test_utils/node_builders/reduce.hpp +++ b/src/tests/test_utils/common_test_utils/include/common_test_utils/node_builders/reduce.hpp @@ -2,6 +2,8 @@ // SPDX-License-Identifier: Apache-2.0 // +#pragma once + #include "common_test_utils/test_enums.hpp" #include "openvino/core/node.hpp" diff --git a/src/tests/test_utils/common_test_utils/include/common_test_utils/node_builders/rnn_cell.hpp b/src/tests/test_utils/common_test_utils/include/common_test_utils/node_builders/rnn_cell.hpp index b4943e50d8967d..463a4930f5c27f 100644 --- a/src/tests/test_utils/common_test_utils/include/common_test_utils/node_builders/rnn_cell.hpp +++ b/src/tests/test_utils/common_test_utils/include/common_test_utils/node_builders/rnn_cell.hpp @@ -2,6 +2,8 @@ // SPDX-License-Identifier: Apache-2.0 // +#pragma once + #include "common_test_utils/test_enums.hpp" #include "openvino/core/node.hpp" diff --git a/src/tests/test_utils/common_test_utils/src/postgres_helpers.cpp b/src/tests/test_utils/common_test_utils/src/postgres_helpers.cpp index d31605a154bb2d..6a76b1aedcb1cc 100644 --- a/src/tests/test_utils/common_test_utils/src/postgres_helpers.cpp +++ b/src/tests/test_utils/common_test_utils/src/postgres_helpers.cpp @@ -480,10 +480,22 @@ void add_pair(std::map& keyValues, const std::string& keyValues["opSet"] = value.substr(dPos + 1); } } + // Defining a subgraph extractors as an operations + if (key == "Extractor") { + keyValues["opName"] = value; + keyValues["opSet"] = "subgraph"; // Need to set later + } // Parse IR for opName and hash if (key == "IR") { - keyValues["hashXml"] = value; - keyValues["pathXml"] = value + ".xml"; + if ((dPos = value.find_last_of('/')) != std::string::npos || + (dPos = value.find_last_of('\\')) != std::string::npos) { + dPos += 1; // Ignores slash + keyValues["hashXml"] = value.substr(dPos, value.length() - dPos - 4); // exclude extension + keyValues["pathXml"] = value.substr(dPos); + } else { + keyValues["hashXml"] = value; + keyValues["pathXml"] = value + ".xml"; + } return; } // Parse Function for opName and opSet diff --git a/src/tests/test_utils/functional_test_utils/include/functional_test_utils/summary/op_summary.hpp b/src/tests/test_utils/functional_test_utils/include/functional_test_utils/summary/op_summary.hpp index 44cf995f7184c8..f10e8532fc60d4 100644 --- a/src/tests/test_utils/functional_test_utils/include/functional_test_utils/summary/op_summary.hpp +++ b/src/tests/test_utils/functional_test_utils/include/functional_test_utils/summary/op_summary.hpp @@ -30,19 +30,17 @@ class OpSummary : public virtual Summary { static OpSummary* p_instance; static bool extractBody; std::map opsStats = {}; - unsigned short int downgrade_coefficient; std::string get_opset_number(const std::string& opset_full_name); protected: - OpSummary(unsigned short int downgrade_coefficient = 1); - static OpSummary& createInstance(unsigned short int downgrade_coefficient = 1); + OpSummary(); + static OpSummary& createInstance(); static OpSummaryDestroyer destroyer; friend class OpSummaryDestroyer; public: static OpSummary& getInstance(); - static void setDowngradeCoefficient(unsigned short int downgrade_coefficient = 1); std::map getOPsStats() { return opsStats; diff --git a/src/tests/test_utils/functional_test_utils/layer_tests_summary/data/default_re_to_find_models.lst b/src/tests/test_utils/functional_test_utils/layer_tests_summary/data/default_re_to_find_models.lst index e7c64cbe45dc75..37551cc69f5111 100644 --- a/src/tests/test_utils/functional_test_utils/layer_tests_summary/data/default_re_to_find_models.lst +++ b/src/tests/test_utils/functional_test_utils/layer_tests_summary/data/default_re_to_find_models.lst @@ -1,5 +1,5 @@ ww*_dynamic* ww*_pytorch* ww*_static* -ww42*tfhub* -# ww42*tflite* \ No newline at end of file +ww*_tfhub* +# ww*_tflite* \ No newline at end of file diff --git a/src/tests/test_utils/functional_test_utils/layer_tests_summary/run_parallel.py b/src/tests/test_utils/functional_test_utils/layer_tests_summary/run_parallel.py index 5916290b6abd52..27f276fdee97d8 100644 --- a/src/tests/test_utils/functional_test_utils/layer_tests_summary/run_parallel.py +++ b/src/tests/test_utils/functional_test_utils/layer_tests_summary/run_parallel.py @@ -219,7 +219,7 @@ def init_worker(self): self._process_list.append( Popen( args, - shell=constants.IS_WIN, + shell=False, stdout=log_file, stderr=log_file, ) @@ -527,9 +527,6 @@ def __generate_test_lists(self, test_dict_cache: dict, test_dict_runtime: dict): def __prepare_smart_filters(self, proved_test_dict: dict): def_length = len(self._command) + len(" --gtest_filter=") - if constants.IS_WIN: - # subprocess add cmd.exe to the command line on Windows if shell=True - def_length += len(f'{os.environ.get("COMSPEC", "cmd.exe")} /C ') longest_device = "" for device in self._available_devices: @@ -873,7 +870,7 @@ def __save_log(logs_dir, dir, test_name): ) if os.path.isfile(interapted_log_path): test_cnt_real_saved_now += 1 - if self._is_save_cache and os.path.isfile(self._cache_path): + if self._is_save_cache: test_times.sort(reverse=True) with open(self._cache_path, "w", encoding=constants.ENCODING) as cache_file: cache_file.writelines( diff --git a/src/tests/test_utils/functional_test_utils/layer_tests_summary/utils/stat_update_utils.py b/src/tests/test_utils/functional_test_utils/layer_tests_summary/utils/stat_update_utils.py index 634eee35560b6b..454dcff7ca0920 100644 --- a/src/tests/test_utils/functional_test_utils/layer_tests_summary/utils/stat_update_utils.py +++ b/src/tests/test_utils/functional_test_utils/layer_tests_summary/utils/stat_update_utils.py @@ -21,7 +21,8 @@ def update_passrates(results: ET.SubElement, rel_weights={}): passed_tests = 0 total_tests = 0 rel_passed_tests = None - rel_all_tests = None + rel_all_tests_expected = None + rel_all_tests_actual = None for attrib in op.attrib: if attrib == "passrate" or attrib == "relative_passrate": continue @@ -34,13 +35,14 @@ def update_passrates(results: ET.SubElement, rel_weights={}): continue elif attrib == "relative_all": if op.tag in rel_weights.keys(): - rel_all_tests = rel_weights[op.tag] - else: - rel_all_tests = float(op.attrib.get(attrib)) + rel_all_tests_expected = rel_weights[op.tag] + rel_all_tests_actual = float(op.attrib.get(attrib)) continue total_tests += int(float(op.attrib.get(attrib))) passrate = float(passed_tests * 100 / total_tests) if total_tests != 0 else 0 - rel_passrate = float(rel_passed_tests * 100 / rel_all_tests) if rel_all_tests != None and rel_all_tests != 0 else 0 + rel_all_tests = rel_all_tests_actual if rel_all_tests_expected is None else rel_all_tests_expected + k = 1 if rel_all_tests_expected is None else round(rel_all_tests_actual / rel_all_tests_expected) + rel_passrate = float(rel_passed_tests * 100 / (k * rel_all_tests)) if rel_all_tests != None and rel_all_tests != 0 else 0 op.set("passrate", "%.2f"%passrate) if rel_all_tests != None and rel_passed_tests != None: op.set("relative_passrate", "%.2f"%rel_passrate) diff --git a/src/tests/test_utils/functional_test_utils/src/summary/op_summary.cpp b/src/tests/test_utils/functional_test_utils/src/summary/op_summary.cpp index 1e9c9684ca7d4d..f78e923c37f6e7 100644 --- a/src/tests/test_utils/functional_test_utils/src/summary/op_summary.cpp +++ b/src/tests/test_utils/functional_test_utils/src/summary/op_summary.cpp @@ -28,14 +28,13 @@ void OpSummaryDestroyer::initialize(OpSummary* p) { p_instance = p; } -OpSummary::OpSummary(unsigned short int in_downgrade_coefficient) { +OpSummary::OpSummary() { reportFilename = ov::test::utils::OP_REPORT_FILENAME; - downgrade_coefficient = in_downgrade_coefficient; } -OpSummary& OpSummary::createInstance(unsigned short int in_downgrade_coefficient) { +OpSummary& OpSummary::createInstance() { if (!p_instance) { - p_instance = new OpSummary(in_downgrade_coefficient); + p_instance = new OpSummary(); destroyer.initialize(p_instance); } return *p_instance; @@ -45,13 +44,6 @@ OpSummary& OpSummary::getInstance() { return createInstance(); } -void OpSummary::setDowngradeCoefficient(unsigned short int in_downgrade_coefficient) { - if (p_instance && p_instance->downgrade_coefficient != in_downgrade_coefficient) { - p_instance->downgrade_coefficient = in_downgrade_coefficient; - } - auto& summary_instance = createInstance(in_downgrade_coefficient); -} - void OpSummary::updateOPsStats(const ov::NodeTypeInfo& op, const PassRate::Statuses& status, double rel_influence_coef) { @@ -313,9 +305,6 @@ void OpSummary::saveReport() { pugi::xml_node currentDeviceNode = resultsNode.append_child(summary.deviceName.c_str()); std::unordered_set opList; for (auto& it : stats) { - it.second.rel_passed /= downgrade_coefficient; - it.second.rel_all /= downgrade_coefficient; - std::string name = functional::get_node_version(it.first); opList.insert(name); pugi::xml_node entry = currentDeviceNode.append_child(name.c_str()); diff --git a/tests/conditional_compilation/requirements.txt b/tests/conditional_compilation/requirements.txt index beee047d1cfe30..0a75d85a8c1040 100644 --- a/tests/conditional_compilation/requirements.txt +++ b/tests/conditional_compilation/requirements.txt @@ -1,5 +1,6 @@ -c ../constraints.txt numpy +protobuf pytest pytest-dependency pytest-html diff --git a/tests/conditional_compilation/tools/infer_tool.py b/tests/conditional_compilation/tools/infer_tool.py index c52f5b773ffcc3..b669b9a7349866 100644 --- a/tests/conditional_compilation/tools/infer_tool.py +++ b/tests/conditional_compilation/tools/infer_tool.py @@ -14,20 +14,20 @@ from pathlib import Path import numpy as np -from openvino.inference_engine import IECore +from openvino import Core log.basicConfig(format="[ %(levelname)s ] %(message)s", level=log.INFO, stream=sys.stdout) -def input_preparation(net): +def input_preparation(model): """ Function to prepare reproducible from run to run input data - :param net: IENetwork object + :param model: OpenVINO Model object :return: Dict where keys are layers' names and values are numpy arrays with layers' shapes """ feed_dict = {} - for layer_name, layer_data in net.input_info.items(): + for layer_name, layer_data in model.input_info.items(): feed_dict.update({layer_name: np.ones(shape=layer_data.input_data.shape)}) return feed_dict @@ -40,17 +40,16 @@ def infer(ir_path, device): :return: Dict containing out blob name and out data """ - bin_path = os.path.splitext(ir_path)[0] + '.bin' - ie = IECore() - net = ie.read_network(model=ir_path, weights=bin_path) - exec_net = ie.load_network(net, device) - res = exec_net.infer(inputs=input_preparation(net)) + core = Core() + model = core.read_model(ir_path) + compiled_model = core.compile_model(model, device) + res = compiled_model(input_preparation(model)) - del net - # It's important to delete executable network first to avoid double free in plugin offloading. + del model + # It's important to delete compiled model first to avoid double free in plugin offloading. # Issue relates ony for hetero and Myriad plugins - del exec_net - del ie + del compiled_model + del core return res diff --git a/tests/constraints.txt b/tests/constraints.txt index ec8bb52521cbbf..4e3455dd1b8b27 100644 --- a/tests/constraints.txt +++ b/tests/constraints.txt @@ -16,6 +16,7 @@ test-generator==0.1.2 requests>=2.25.1 opencv-python>=4.5 paddlepaddle==2.5.0 +protobuf>=3.18.1,<4.0.0 py>=1.9.0 pytest>=5.0,<7.5 pytest-dependency==0.5.1 diff --git a/tests/layer_tests/mo_python_api_tests/test_mo_convert_pytorch.py b/tests/layer_tests/mo_python_api_tests/test_mo_convert_pytorch.py index 949910cad8c6f2..47bf252eed295b 100644 --- a/tests/layer_tests/mo_python_api_tests/test_mo_convert_pytorch.py +++ b/tests/layer_tests/mo_python_api_tests/test_mo_convert_pytorch.py @@ -1027,8 +1027,8 @@ class DataModel(torch.nn.Module): def __init__(self): super(DataModel, self).__init__() self.data = torch.tensor([1, 2, 3, 4]) - - def forward(self, x): + + def forward(self, x): return self.data, x data_model = DataModel() @@ -1051,13 +1051,13 @@ def forward(self, x): def test_sharing_memory_switched_on(self, ie_device, precision, ir_version, temp_dir): from openvino.tools.ovc import convert_model from openvino.runtime import Core - + class DataModel(torch.nn.Module): def __init__(self): super(DataModel, self).__init__() self.data = torch.tensor([1, 2, 3, 4]) - - def forward(self, x): + + def forward(self, x): return self.data, x data_model = DataModel() @@ -1236,8 +1236,10 @@ class TestPrecisionSensitive(): @pytest.mark.parametrize("create_model", test_data) @pytest.mark.nightly @pytest.mark.precommit - @pytest.mark.xfail(condition=platform.system() == 'Darwin' and platform.machine() == 'arm64', - reason='Ticket - 122714') + @pytest.mark.xfail(condition=platform.system() in ('Darwin', 'Linux') and platform.machine() in ('arm', 'armv7l', + 'aarch64', + 'arm64', 'ARM64'), + reason='Ticket - 122714, 122710') def test_precision_sensitive(self, create_model, ie_device, precision, ir_version, temp_dir, use_new_frontend, use_old_api): import numpy.testing as npt from pathlib import Path diff --git a/tests/layer_tests/onnx_tests/test_reduce_lp.py b/tests/layer_tests/onnx_tests/test_reduce_lp.py index 73cd86a2bbbc6f..fc9ba16859799d 100644 --- a/tests/layer_tests/onnx_tests/test_reduce_lp.py +++ b/tests/layer_tests/onnx_tests/test_reduce_lp.py @@ -234,8 +234,10 @@ def create_reduce_lp_const(self, shape, axes, keep_dims, reduce_p, ir_version): @pytest.mark.parametrize("keep_dims", [True, False]) @pytest.mark.parametrize("reduce_p", [1, 2]) @pytest.mark.precommit - @pytest.mark.xfail(condition=platform.system() == 'Darwin' and platform.machine() == 'arm64', - reason='Ticket - 122846') + @pytest.mark.xfail(condition=platform.system() in ('Darwin', 'Linux') and platform.machine() in ('arm', 'armv7l', + 'aarch64', + 'arm64', 'ARM64'), + reason='Ticket - 122846, 122783, 126312') def test_reduce_lp_precommit(self, params, keep_dims, reduce_p, ie_device, precision, ir_version, temp_dir, use_old_api): self._test(*self.create_reduce_lp(**params, keep_dims=keep_dims, reduce_p=reduce_p, diff --git a/tests/layer_tests/onnx_tests/test_roi_align.py b/tests/layer_tests/onnx_tests/test_roi_align.py index a29ddc4c1d1213..88e6e9aef27808 100644 --- a/tests/layer_tests/onnx_tests/test_roi_align.py +++ b/tests/layer_tests/onnx_tests/test_roi_align.py @@ -136,8 +136,10 @@ def create_net(self, input_shape, rois_shape, indices_shape, output_shape, @pytest.mark.nightly @pytest.mark.precommit @pytest.mark.xfail(condition=platform.system() == 'Windows', reason="Ticket - 122731") - @pytest.mark.xfail(condition=platform.system() == 'Darwin' and platform.machine() == 'arm64', - reason='Ticket - 122846') + @pytest.mark.xfail(condition=platform.system() in ('Linux', 'Darwin') and platform.machine() in ('arm', 'armv7l', + 'aarch64', + 'arm64', 'ARM64'), + reason='Ticket - 122846, 122783, 126312') def test_roi_alignv10(self, params, ie_device, precision, ir_version, temp_dir, use_old_api): # TODO: ticket for investigating GPU failures: CVS-86300 if ie_device != "GPU": diff --git a/tests/layer_tests/pytorch_tests/test_all.py b/tests/layer_tests/pytorch_tests/test_all.py index c8b79ee0ff5e3b..f4c2ed71ed4b54 100644 --- a/tests/layer_tests/pytorch_tests/test_all.py +++ b/tests/layer_tests/pytorch_tests/test_all.py @@ -73,7 +73,9 @@ def test_all_noparams(self, input_shape, d_type, ie_device, precision, ir_versio ]) @pytest.mark.nightly @pytest.mark.precommit - @pytest.mark.xfail(condition=platform.system() == 'Darwin' and platform.machine() == 'arm64', + @pytest.mark.xfail(condition=platform.system() in ('Darwin', 'Linux') and platform.machine() in ('arm', 'armv7l', + 'aarch64', + 'arm64', 'ARM64'), reason='Ticket - 122715') def test_all(self, input_shape, d_type, keepdim, ie_device, precision, ir_version): if type(input_shape) is list: diff --git a/tests/layer_tests/pytorch_tests/test_argmax_argmin.py b/tests/layer_tests/pytorch_tests/test_argmax_argmin.py index 80ed6fcb872b5f..80f035667565c3 100644 --- a/tests/layer_tests/pytorch_tests/test_argmax_argmin.py +++ b/tests/layer_tests/pytorch_tests/test_argmax_argmin.py @@ -73,7 +73,9 @@ def forward(self, x): @pytest.mark.parametrize("dtype", ["float32", "int32", "int64"]) @pytest.mark.nightly @pytest.mark.precommit - @pytest.mark.xfail(condition=platform.system() == 'Darwin' and platform.machine() == 'arm64', + @pytest.mark.xfail(condition=platform.system() in ('Darwin', 'Linux') and platform.machine() in ('arm', 'armv7l', + 'aarch64', + 'arm64', 'ARM64'), reason='Ticket - 122715') def test_argmin_argmax(self, axes, keep_dims, op_type, dtype, ie_device, precision, ir_version): self._test(*self.create_model(op_type, axes, keep_dims), diff --git a/tests/layer_tests/pytorch_tests/test_clamp.py b/tests/layer_tests/pytorch_tests/test_clamp.py index 5c860f9be65ff1..3a4ce5c6c8de37 100644 --- a/tests/layer_tests/pytorch_tests/test_clamp.py +++ b/tests/layer_tests/pytorch_tests/test_clamp.py @@ -42,7 +42,7 @@ def forward_clip_(self, x): return aten_clamp(minimum, maximum, as_tensors, op_type), ref_net, op_name @pytest.mark.parametrize("minimum,maximum", - [(0., 1.), (-0.5, 1.5), (None, 10.), (None, -10.), (10., None), (-10., None), (100, 200)]) + [(0., 1.), (-0.5, 1.5), (None, 10.), (None, -10.), (10., None), (-10., None), (100, 200), (1.0, 0.0)]) @pytest.mark.parametrize("as_tensors", [True, False]) @pytest.mark.parametrize("op_type", ["clamp", "clamp_"]) @pytest.mark.nightly @@ -50,11 +50,6 @@ def test_clamp(self, minimum, maximum, as_tensors, op_type, ie_device, precision self._test(*self.create_model(minimum, maximum, as_tensors, op_type), ie_device, precision, ir_version) - @pytest.mark.xfail(reason='OpenVINO clamp does not support min > max') - def test_clamp_min_greater(self, ie_device, precision, ir_version): - self._test(*self.create_model(1.0, 0.0), - ie_device, precision, ir_version) - class TestClampMin(PytorchLayerTest): def _prepare_input(self): diff --git a/tests/layer_tests/pytorch_tests/test_copy.py b/tests/layer_tests/pytorch_tests/test_copy.py index b78af602712b75..6b4969c0277e8c 100644 --- a/tests/layer_tests/pytorch_tests/test_copy.py +++ b/tests/layer_tests/pytorch_tests/test_copy.py @@ -31,3 +31,36 @@ def forward(self, x): @pytest.mark.parametrize("value", [1, [2.5], range(224)]) def test_copy_(self, value, ie_device, precision, ir_version): self._test(*self.create_model(value), ie_device, precision, ir_version) + + +class TestAliasCopy(PytorchLayerTest): + def _prepare_input(self, out): + import numpy as np + if not out: + return (np.random.randn(1, 3, 224, 224).astype(np.float32),) + return (np.random.randn(1, 3, 224, 224).astype(np.float32), np.zeros((1, 3, 224, 224), dtype=np.float32)) + + def create_model(self, out): + import torch + + class aten_copy(torch.nn.Module): + def __init__(self, out): + super(aten_copy, self).__init__() + if out: + self.forward = self.forward_out + + def forward(self, x): + return torch.alias_copy(x) + + def forward_out(self, x, y): + return torch.alias_copy(x, out=y), y + + ref_net = None + + return aten_copy(out), ref_net, "aten::alias_copy" + + @pytest.mark.nightly + @pytest.mark.precommit + @pytest.mark.parametrize("out", [True, False]) + def test_copy_(self, out, ie_device, precision, ir_version): + self._test(*self.create_model(out), ie_device, precision, ir_version, kwargs_to_prepare_input={"out": out}) \ No newline at end of file diff --git a/tests/layer_tests/pytorch_tests/test_cross.py b/tests/layer_tests/pytorch_tests/test_cross.py new file mode 100644 index 00000000000000..ff953881138869 --- /dev/null +++ b/tests/layer_tests/pytorch_tests/test_cross.py @@ -0,0 +1,122 @@ +# Copyright (C) 2018-2023 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +# Copyright (C) 2018-2023 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import pytest + +from pytorch_layer_test_class import PytorchLayerTest + + +class TestLinalgCross(PytorchLayerTest): + def _prepare_input(self, x_shape, y_shape, out, dtype): + import numpy as np + x = np.random.randn(*x_shape).astype(dtype) + y = np.random.randn(*y_shape).astype(dtype) + if not out: + return (x, y) + return (x, y, np.zeros(np.maximum(np.array(x_shape), np.array(y_shape)).tolist(), dtype=dtype)) + + def create_model(self, dim, out): + import torch + + class aten_linalg_cross(torch.nn.Module): + def __init__(self, dim, out): + super(aten_linalg_cross, self).__init__() + if dim is None: + self.forward = self.forward_no_dim_no_out if not out else self.forward_no_dim_out + elif out: + self.forward = self.forward_out + self.dim = dim + + def forward(self, x, y): + return torch.linalg.cross(x, y, dim=self.dim) + + def forward_out(self, x, y, out): + return torch.linalg.cross(x, y, dim=self.dim, out=out), out + + def forward_no_dim_out(self, x, y, out): + return torch.linalg.cross(x, y, out=out), out + + def forward_no_dim_no_out(self, x, y): + return torch.linalg.cross(x, y) + + ref_net = None + + return aten_linalg_cross(dim, out), ref_net, "aten::linalg_cross" + + @pytest.mark.nightly + @pytest.mark.precommit + @pytest.mark.parametrize("x_shape,y_shape,dim", [ + ((4, 3), (4, 3), None), + ((1, 3), (4, 3), -1), + ((4, 3), (1, 3), 1), + ((3, 5), (3, 5), 0), + ((2, 3, 4), (2, 3, 4), 1) + ]) + @pytest.mark.parametrize('dtype', ['float32', 'float64']) + @pytest.mark.parametrize("out", [True, False]) + def test_linalg_cross(self, x_shape, y_shape, dim, out, dtype, ie_device, precision, ir_version): + self._test( + *self.create_model(dim, out), ie_device, precision, ir_version, use_convert_model=True, + kwargs_to_prepare_input={"x_shape":x_shape, "y_shape": y_shape, "out": out, 'dtype': dtype}) + + +class TestCross(PytorchLayerTest): + def _prepare_input(self, x_shape, y_shape, out, dtype): + import numpy as np + x = np.random.randn(*x_shape).astype(dtype) + y = np.random.randn(*y_shape).astype(dtype) + if not out: + return (x, y) + return (x, y, np.zeros(np.maximum(np.array(x_shape), np.array(y_shape)).tolist(), dtype=dtype)) + + def create_model(self, dim, out, shape): + import torch + + class aten_cross(torch.nn.Module): + def __init__(self, dim, out, shape): + super(aten_cross, self).__init__() + if dim is None: + self.forward = self.forward_no_dim_no_out if not out else self.forward_no_dim_out + elif out: + self.forward = self.forward_out + self.dim = dim + self.shape = shape + + def forward(self, x, y): + return torch.cross(x, y, dim=self.dim) + + def forward_out(self, x, y, out): + return torch.cross(x, y, dim=self.dim, out=out), out + + def forward_no_dim_out(self, x, y, out): + x = torch.reshape(x, self.shape) + return torch.cross(x, y, out=out), out + + def forward_no_dim_no_out(self, x, y): + x = torch.reshape(x, self.shape) + return torch.cross(x, y) + + ref_net = None + + return aten_cross(dim, out, shape), ref_net, "aten::cross" + + @pytest.mark.nightly + @pytest.mark.precommit + @pytest.mark.parametrize("x_shape,y_shape,dim", [ + ((1, 3), (4, 3), -1), + ((4, 3), (1, 3), 1), + ((3, 5), (3, 5), 0), + ((2, 3, 4), (2, 3, 4), 1), + ((3, 1), (3, 4), None), + ((4, 3), (4, 3), None), + ((2, 3, 4), (2, 3, 4), None), + ]) + @pytest.mark.parametrize("out", [True, False]) + @pytest.mark.parametrize('dtype', ['float32', 'float64']) + def test_linalg_cross(self, x_shape, y_shape, dim, out, dtype, ie_device, precision, ir_version): + self._test(*self.create_model(dim, out, x_shape), ie_device, precision, ir_version, + use_convert_model=True, + kwargs_to_prepare_input={"x_shape":x_shape, "y_shape": y_shape, "out": out, "dtype": dtype}) \ No newline at end of file diff --git a/tests/layer_tests/pytorch_tests/test_div.py b/tests/layer_tests/pytorch_tests/test_div.py index 564cb2915c8686..22243e1a591698 100644 --- a/tests/layer_tests/pytorch_tests/test_div.py +++ b/tests/layer_tests/pytorch_tests/test_div.py @@ -118,7 +118,9 @@ def forward3(self, lhs, rhs): ])) @pytest.mark.nightly @pytest.mark.precommit - @pytest.mark.xfail(condition=platform.system() == 'Darwin' and platform.machine() == 'arm64', + @pytest.mark.xfail(condition=platform.system() in ('Darwin', 'Linux') and platform.machine() in ('arm', 'armv7l', + 'aarch64', + 'arm64', 'ARM64'), reason='Ticket - 122715') def test_div_types(self, ie_device, precision, ir_version, lhs_type, lhs_shape, rhs_type, rhs_shape, rounding_mode): self.lhs_type = lhs_type diff --git a/tests/layer_tests/pytorch_tests/test_listunpack.py b/tests/layer_tests/pytorch_tests/test_listunpack.py index 39d72bfe54c6e9..6f3df968eb921d 100644 --- a/tests/layer_tests/pytorch_tests/test_listunpack.py +++ b/tests/layer_tests/pytorch_tests/test_listunpack.py @@ -126,6 +126,7 @@ def test_listconstruct_getitem_listunpack( use_convert_model=True, ) + class TestMeshgridListUnpack(PytorchLayerTest): def _prepare_input(self): return ( @@ -189,7 +190,8 @@ def __init__(self, idx): super(prim_listunpack, self).__init__() def forward(self, in1, in2, in3, in4): - a, b, c, d = torch.meshgrid(in1, in2, in3, in4, indexing=self.idx) + a, b, c, d = torch.meshgrid( + in1, in2, in3, in4, indexing=self.idx) return a, b, c, d ref_net = None @@ -215,7 +217,8 @@ def create_model(self): class meshgrid_model(torch.nn.Module): def forward(self, x): h, w = x.shape - coords1, coords2 = torch.meshgrid(torch.arange(h), torch.arange(w), indexing="ij") + coords1, coords2 = torch.meshgrid( + torch.arange(h), torch.arange(w), indexing="ij") coords = torch.stack([coords2, coords1], dim=0) return coords.float() @@ -225,3 +228,102 @@ def forward(self, x): @pytest.mark.precommit def test_meshgrid_subgraph(self, ie_device, precision, ir_version): self._test(*self.create_model(), ie_device, precision, ir_version) + + +class TestListUnpackParameterSingle(PytorchLayerTest): + def _prepare_input(self): + def tensor_gen(): + return np.random.uniform(0, 50, (1, 2, 10)).astype(np.float32) + return ((tensor_gen(), tensor_gen()), ) + + def create_model(self): + import torch + from typing import List + + class model(torch.nn.Module): + + def forward(self, x: List[torch.Tensor]): + x1, x2 = x + return x1, x2 + + return model(), None, ["prim::ListUnpack"] + + @pytest.mark.nightly + def test(self, ie_device, precision, ir_version): + self._test(*self.create_model(), ie_device, precision, ir_version) + + +class TestListUnpackParameterSingleMixed(PytorchLayerTest): + def _prepare_input(self): + def tensor_gen(): + return np.random.uniform(0, 50, (1, 2, 10)).astype(np.float32) + # generate tensor with a different shape for easier mismatch detection in case of mixed input order + + def tensor_gen_2(): + return np.random.uniform(0, 50, (2, 3)).astype(np.float32) + return (tensor_gen_2(), (tensor_gen(), tensor_gen()), tensor_gen_2()) + + def create_model(self): + import torch + from typing import List + + class model(torch.nn.Module): + + def forward(self, y1, x: List[torch.Tensor], y2): + x1, x2 = x + return x1, x2, y1, y2 + + return model(), None, ["prim::ListUnpack"] + + @pytest.mark.nightly + def test(self, ie_device, precision, ir_version): + self._test(*self.create_model(), ie_device, precision, ir_version) + + +class TestListUnpackParameterNested(PytorchLayerTest): + def _prepare_input(self): + def tensor_gen(): + return np.random.uniform(0, 50, (1, 2, 10)).astype(np.float32) + return (((tensor_gen(), tensor_gen()), (tensor_gen(), tensor_gen())), ) + + def create_model(self): + import torch + from typing import List + + class model(torch.nn.Module): + + def forward(self, x: List[List[torch.Tensor]]): + x1, x2 = x + y1, y2 = x1 + y3, y4 = x2 + return y1, y2, y3, y4 + + return model(), None, ["prim::ListUnpack"] + + @pytest.mark.nightly + def test(self, ie_device, precision, ir_version): + self._test(*self.create_model(), ie_device, precision, ir_version) + + +class TestListUnpackParameterMultiple(PytorchLayerTest): + def _prepare_input(self): + def tensor_gen(): + return np.random.uniform(0, 50, (1, 2, 10)).astype(np.float32) + return ((tensor_gen(), tensor_gen()), (tensor_gen(), tensor_gen())) + + def create_model(self): + import torch + from typing import List + + class model(torch.nn.Module): + + def forward(self, x: List[torch.Tensor], y: List[torch.Tensor]): + z1, z2 = x + z3, z4 = y + return z1, z2, z3, z4 + + return model(), None, ["prim::ListUnpack"] + + @pytest.mark.nightly + def test(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_native_multi_head_attention.py b/tests/layer_tests/pytorch_tests/test_native_multi_head_attention.py index 26b7cdbd14812b..213a6e97ef78f8 100644 --- a/tests/layer_tests/pytorch_tests/test_native_multi_head_attention.py +++ b/tests/layer_tests/pytorch_tests/test_native_multi_head_attention.py @@ -76,7 +76,9 @@ def _prepare_input(self): ["need_weights", "average_attn_weights"], [[False, False], [True, False], [True, True]] ) - @pytest.mark.xfail(condition=platform.system() == 'Darwin' and platform.machine() == 'arm64', + @pytest.mark.xfail(condition=platform.system() in ('Darwin', 'Linux') and platform.machine() in ('arm', 'armv7l', + 'aarch64', + 'arm64', 'ARM64'), reason='Ticket - 122715') def test_native_multi_head_attention(self, ie_device, precision, ir_version, mask, need_weights, average_attn_weights): self._test(aten_native_multi_head_attention(mask, need_weights, average_attn_weights), diff --git a/tests/layer_tests/pytorch_tests/test_norm.py b/tests/layer_tests/pytorch_tests/test_norm.py index c884e6c17ff042..e3517bdf1ce874 100644 --- a/tests/layer_tests/pytorch_tests/test_norm.py +++ b/tests/layer_tests/pytorch_tests/test_norm.py @@ -263,7 +263,9 @@ def forward_out(self, x, y): @pytest.mark.parametrize("dtype", ["float32", "float64", None]) @pytest.mark.parametrize("out", [True, False]) @pytest.mark.parametrize("prim_dtype", [True, False]) - @pytest.mark.xfail(condition=platform.system() == 'Darwin' and platform.machine() == 'arm64', + @pytest.mark.xfail(condition=platform.system() in ('Darwin', 'Linux') and platform.machine() in ('arm', 'armv7l', + 'aarch64', + 'arm64', 'ARM64'), reason='Ticket - 122715') def test_linalg_matrix_norm(self, p, dim, keepdim, dtype, out, prim_dtype, ie_device, precision, ir_version): self._test(*self.create_model(p, dim, keepdim, dtype, out, prim_dtype), diff --git a/tests/layer_tests/pytorch_tests/test_rand.py b/tests/layer_tests/pytorch_tests/test_rand.py index 75677992fb6da2..08f6201cdb323c 100644 --- a/tests/layer_tests/pytorch_tests/test_rand.py +++ b/tests/layer_tests/pytorch_tests/test_rand.py @@ -88,3 +88,57 @@ def test_inplace_normal(self, model, inputs, ie_device, precision, ir_version): self.inputs = inputs self._test(model, None, "aten::normal", ie_device, precision, ir_version, custom_eps=1e30) + + +class TestStatistics(): + class aten_normal(torch.nn.Module): + def forward(self, mean, std): + return torch.normal(mean, std) + + class aten_randn(torch.nn.Module): + def forward(self, size): + return torch.randn(*size) + + @pytest.mark.nightly + @pytest.mark.precommit + @pytest.mark.parametrize("fw_model,inputs", [ + (aten_normal(), (0, 1, (1000000,))), + (aten_normal(), (0, 1, (10000, 100))), + (aten_normal(), (0, 3, (100000, 100))), + (aten_normal(), (1, 6, (100000, 100))), + (aten_normal(), (-20, 2, (10000, 100))), + (aten_normal(), (-20, 100, (10000, 100))), + + (aten_randn(), (0, 1, (1000000,))), + (aten_randn(), (0, 1, (10000, 100))), + (aten_randn(), (0, 1, (100000, 100))), + ]) + def test_normal_statistics(self, fw_model, inputs, ie_device, precision): + import numpy.testing as npt + import numpy as np + import openvino as ov + mean_scalar, std_scalar, size = inputs + mean = torch.full(size, mean_scalar, dtype=torch.float32) + std = torch.full(size, std_scalar, dtype=torch.float32) + + if isinstance(fw_model, self.aten_randn): + example_input = (torch.tensor(size), ) + input_size = [len(size)] + else: + example_input = (mean, std) + input_size = [size, size] + + ov_model = ov.convert_model(input_model=fw_model, example_input=example_input, input=input_size) + if ie_device == 'GPU' and precision == 'FP32': + config = {'INFERENCE_PRECISION_HINT': 'f32'} + else: + config = {} + compiled_model = ov.Core().compile_model(ov_model, ie_device, config) + + fw_res = fw_model(*example_input) + ov_res = compiled_model(example_input)[0] + + x_min, x_max = mean_scalar - 2 * std_scalar, mean_scalar + 2 * std_scalar + hist_fw, _ = np.histogram(fw_res.numpy(), bins=100, range=(x_min, x_max)) + hist_ov, _ = np.histogram(ov_res, bins=100, range=(x_min, x_max)) + npt.assert_allclose(hist_fw, hist_ov, atol=0.2, rtol=0.2) diff --git a/tests/layer_tests/requirements.txt b/tests/layer_tests/requirements.txt index fd15d8bf32405d..fc55322ccb8b32 100644 --- a/tests/layer_tests/requirements.txt +++ b/tests/layer_tests/requirements.txt @@ -8,5 +8,5 @@ torchvision transformers pytest tensorflow-addons; python_version <= '3.10' -jax; sys_platform == "linux" -jaxlib; sys_platform == "linux" +jax; sys_platform == "linux" and platform_machine == "x86_64" # https://jax.readthedocs.io/en/latest/installation.html#pip-installation-cpu - wheels are for "x86_64" only +jaxlib; sys_platform == "linux" and platform_machine == "x86_64" # https://jax.readthedocs.io/en/latest/installation.html#pip-installation-cpu - wheels are for "x86_64" only diff --git a/tests/layer_tests/tensorflow2_keras_tests/test_tf2_keras_conv_lstm_2d.py b/tests/layer_tests/tensorflow2_keras_tests/test_tf2_keras_conv_lstm_2d.py index d9166d0b069cb2..35f440c38234d8 100644 --- a/tests/layer_tests/tensorflow2_keras_tests/test_tf2_keras_conv_lstm_2d.py +++ b/tests/layer_tests/tensorflow2_keras_tests/test_tf2_keras_conv_lstm_2d.py @@ -15,19 +15,11 @@ def _prepare_input(self, inputs_info): assert len(input_names) == 1, "Test expects only one input" x_shape = inputs_info[input_names[0]] inputs_data = {} - inputs_data[input_names[0]] = np.random.uniform(-1, 1, x_shape) + inputs_data[input_names[0]] = np.random.uniform(-1, 1, x_shape).astype(np.float32) return inputs_data def create_keras_conv_lstm_2d_net(self, params, input_shapes): - activation_func_structure = { - "relu": tf.nn.relu, - "swish": tf.nn.swish, - "elu": tf.nn.elu, - } - if "activation" in params: - params["activation"] = activation_func_structure[params["activation"]] - # create TensorFlow 2 model with Keras ConvLSTM2D operation tf.keras.backend.clear_session() @@ -38,43 +30,31 @@ def create_keras_conv_lstm_2d_net(self, params, input_shapes): return tf2_net, None test_data_basic = [ - pytest.param(dict(params=dict(filters=4, kernel_size=(3, 3), padding='same', return_sequences=False, - activation="swish"), - input_shapes=[[2, 5, 20, 30, 2]]), marks=pytest.mark.skip(reason="*-108786")), - pytest.param(dict(params=dict(filters=6, kernel_size=(2, 3), padding='valid', dilation_rate=3, - recurrent_activation="elu", return_sequences=True, use_bias=True, - data_format="channels_first"), - input_shapes=[[2, 5, 1, 40, 30]]), marks=pytest.mark.skip(reason="110006")), - ] - - @pytest.mark.parametrize("params", test_data_basic) - @pytest.mark.precommit_tf_fe - @pytest.mark.nightly - def test_keras_conv_lstm_2d_basic(self, params, ie_device, precision, ir_version, temp_dir, - use_old_api, use_new_frontend): - self._test(*self.create_keras_conv_lstm_2d_net(**params), ie_device, - precision, - temp_dir=temp_dir, use_old_api=use_old_api, ir_version=ir_version, - use_new_frontend=use_new_frontend, **params) - - test_data_others = [ + dict(params=dict(filters=4, kernel_size=(3, 3), padding='same', return_sequences=False, + activation=tf.nn.swish), + input_shapes=[[2, 5, 20, 30, 2]]), + dict(params=dict(filters=6, kernel_size=(2, 3), padding='valid', dilation_rate=3, + recurrent_activation=tf.nn.elu, return_sequences=True, use_bias=True, + data_format="channels_first"), + input_shapes=[[2, 5, 1, 40, 30]]), dict(params=dict(filters=3, kernel_size=(3, 3), padding='valid', return_sequences=False), input_shapes=[[2, 5, 20, 30, 1]]), - dict(params=dict(filters=2, kernel_size=(2, 2), padding='same', return_sequences=False, activation="swish"), + dict(params=dict(filters=2, kernel_size=(2, 2), padding='same', return_sequences=False, activation=tf.nn.swish), input_shapes=[[2, 5, 25, 15, 3]]), dict(params=dict(filters=3, kernel_size=(3, 3), padding='valid', strides=(2, 2), return_sequences=True), input_shapes=[[2, 5, 10, 15, 2]]), dict(params=dict(filters=5, kernel_size=(2, 2), padding='valid', dilation_rate=3, - activation="relu", return_sequences=False, use_bias=True, + activation=tf.nn.relu, return_sequences=False, use_bias=True, data_format="channels_last"), input_shapes=[[2, 5, 18, 17, 1]]) ] - @pytest.mark.parametrize("params", test_data_others) + @pytest.mark.parametrize("params", test_data_basic) + @pytest.mark.precommit_tf_fe @pytest.mark.nightly - def test_keras_conv_lstm_2d_others(self, params, ie_device, precision, ir_version, temp_dir, - use_old_api, use_new_frontend): + def test_keras_conv_lstm_2d_basic(self, params, ie_device, precision, ir_version, temp_dir, + use_old_api, use_new_frontend): self._test(*self.create_keras_conv_lstm_2d_net(**params), ie_device, precision, temp_dir=temp_dir, use_old_api=use_old_api, ir_version=ir_version, diff --git a/tests/layer_tests/tensorflow_tests/test_tf_AddTypes.py b/tests/layer_tests/tensorflow_tests/test_tf_AddTypes.py new file mode 100644 index 00000000000000..76d61b3d3a936e --- /dev/null +++ b/tests/layer_tests/tensorflow_tests/test_tf_AddTypes.py @@ -0,0 +1,51 @@ +# Copyright (C) 2018-2023 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 + +rng = np.random.default_rng() + + +class TestAddTypes(CommonTFLayerTest): + def _prepare_input(self, inputs_info): + assert 'x' in inputs_info, "Test error: inputs_info must contain `x`" + x_shape = inputs_info['x'] + inputs_data = {} + if np.issubdtype(self.input_type, np.signedinteger): + inputs_data['x'] = rng.integers(-8, 8, x_shape).astype(self.input_type) + else: + inputs_data['x'] = rng.integers(0, 8, x_shape).astype(self.input_type) + return inputs_data + + def create_add_types_net(self, const_shape, input_type): + self.input_type = input_type + tf.compat.v1.reset_default_graph() + # Create the graph and model + with tf.compat.v1.Session() as sess: + x = tf.compat.v1.placeholder(input_type, [], 'x') + if np.issubdtype(self.input_type, np.signedinteger): + const_value = rng.integers(-8, 8, const_shape).astype(self.input_type) + else: + const_value = rng.integers(0, 8, const_shape).astype(self.input_type) + const_input = tf.constant(const_value, dtype=input_type) + tf.raw_ops.Add(x=x, y=const_input) + tf.compat.v1.global_variables_initializer() + + tf_net = sess.graph_def + + return tf_net, None + + @pytest.mark.parametrize("const_shape", [[], [2], [3, 4], [3, 2, 1, 4]]) + @pytest.mark.parametrize("input_type", [np.int8, np.uint8, np.int16, + np.int32, np.int64, + np.float16, np.float32, np.float64]) + @pytest.mark.precommit_tf_fe + @pytest.mark.nightly + def test_add_types(self, const_shape, input_type, ie_device, precision, ir_version, temp_dir, + use_new_frontend, use_old_api): + self._test(*self.create_add_types_net(const_shape, input_type), + ie_device, precision, ir_version, temp_dir=temp_dir, + use_new_frontend=use_new_frontend, use_old_api=use_old_api) diff --git a/tests/layer_tests/tensorflow_tests/test_tf_ArgMinMax.py b/tests/layer_tests/tensorflow_tests/test_tf_ArgMinMax.py index ca4f7f051e1079..da60c1ef21a79e 100644 --- a/tests/layer_tests/tensorflow_tests/test_tf_ArgMinMax.py +++ b/tests/layer_tests/tensorflow_tests/test_tf_ArgMinMax.py @@ -1,6 +1,8 @@ # Copyright (C) 2022 Intel Corporation # SPDX-License-Identifier: Apache-2.0 +import platform + import numpy as np import pytest import tensorflow as tf @@ -50,6 +52,10 @@ def create_argmin_max_net(self, input_shape, dimension, input_type, output_type, @pytest.mark.parametrize("op_type", [tf.raw_ops.ArgMax, tf.raw_ops.ArgMin]) @pytest.mark.precommit_tf_fe @pytest.mark.nightly + @pytest.mark.xfail(condition=platform.system() == 'Linux' and platform.machine() in ['arm', 'armv7l', + 'aarch64', + 'arm64', 'ARM64'], + reason='Ticket - 126314') def test_argmin_max_net(self, params, input_type, output_type, op_type, ie_device, precision, ir_version, temp_dir, use_new_frontend, use_old_api): self._test(*self.create_argmin_max_net(**params, input_type=input_type, diff --git a/tests/layer_tests/tensorflow_tests/test_tf_Atan2.py b/tests/layer_tests/tensorflow_tests/test_tf_Atan2.py new file mode 100644 index 00000000000000..4c5ed9e3a3bded --- /dev/null +++ b/tests/layer_tests/tensorflow_tests/test_tf_Atan2.py @@ -0,0 +1,46 @@ +# Copyright (C) 2018-2023 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 + + +class TestAtan2(CommonTFLayerTest): + def _prepare_input(self, inputs_info): + assert 'y' in inputs_info + assert 'x' in inputs_info + y_shape = inputs_info['y'] + x_shape = inputs_info['x'] + inputs_data = {} + inputs_data['y'] = np.random.rand(*y_shape).astype(self.input_type) - np.random.rand(*y_shape).astype(self.input_type) + inputs_data['x'] = np.random.rand(*x_shape).astype(self.input_type) - np.random.rand(*x_shape).astype(self.input_type) + return inputs_data + + def create_atan2_net(self, input_shape, input_type): + self.input_type = input_type + tf.compat.v1.reset_default_graph() + # Create the graph and model + with tf.compat.v1.Session() as sess: + y = tf.compat.v1.placeholder(input_type, input_shape, 'y') + x = tf.compat.v1.placeholder(input_type, input_shape, 'x') + tf.raw_ops.Atan2(y=y, x=x) + tf.compat.v1.global_variables_initializer() + tf_net = sess.graph_def + + return tf_net, None + + test_data_basic = [ + dict(input_shape=[1, 2], input_type=np.float32), + dict(input_shape=[2, 3, 4], input_type=np.float32), + ] + + @pytest.mark.parametrize("params", test_data_basic) + @pytest.mark.precommit_tf_fe + @pytest.mark.nightly + def test_atan2_basic(self, params, ie_device, precision, ir_version, temp_dir, + use_new_frontend, use_old_api): + self._test(*self.create_atan2_net(**params), + ie_device, precision, ir_version, temp_dir=temp_dir, + use_new_frontend=use_new_frontend, use_old_api=use_old_api) diff --git a/tests/layer_tests/tensorflow_tests/test_tf_ComplexFFT.py b/tests/layer_tests/tensorflow_tests/test_tf_ComplexFFT.py index 18d23b593abba1..5624d2c2984ad0 100644 --- a/tests/layer_tests/tensorflow_tests/test_tf_ComplexFFT.py +++ b/tests/layer_tests/tensorflow_tests/test_tf_ComplexFFT.py @@ -1,6 +1,8 @@ # Copyright (C) 2018-2023 Intel Corporation # SPDX-License-Identifier: Apache-2.0 +import platform + import numpy as np import pytest import tensorflow as tf @@ -54,6 +56,10 @@ def create_complex_fft_net(self, input_shape, shift_roll, axis_roll, fft_op): @pytest.mark.parametrize("params", test_data_basic) @pytest.mark.precommit_tf_fe @pytest.mark.nightly + @pytest.mark.xfail(condition=platform.system() == 'Linux' and platform.machine() in ['arm', 'armv7l', + 'aarch64', + 'arm64', 'ARM64'], + reason='Ticket - 126314') def test_complex_fft_basic(self, params, fft_op, ie_device, precision, ir_version, temp_dir, use_new_frontend, use_old_api): diff --git a/tests/layer_tests/tensorflow_tests/test_tf_MaxPoolWithArgmax.py b/tests/layer_tests/tensorflow_tests/test_tf_MaxPoolWithArgmax.py index f08995f3c09d11..1805863b8c221b 100644 --- a/tests/layer_tests/tensorflow_tests/test_tf_MaxPoolWithArgmax.py +++ b/tests/layer_tests/tensorflow_tests/test_tf_MaxPoolWithArgmax.py @@ -61,8 +61,10 @@ def create_max_pool_with_argmax_net(self, input_shape, ksize, strides, input_typ ]) @pytest.mark.precommit_tf_fe @pytest.mark.nightly - @pytest.mark.xfail(condition=platform.system() == 'Darwin' and platform.machine() == 'arm64', - reason='Ticket - 122716') + @pytest.mark.xfail(condition=platform.system() in ('Linux', 'Darwin') and platform.machine() in ('arm', 'armv7l', + 'aarch64', + 'arm64', 'ARM64'), + reason='Ticket - 126314, 122716') def test_max_pool_with_argmax_basic(self, params, input_type, padding, targmax, include_batch_in_index, with_second_output, ie_device, precision, ir_version, temp_dir, diff --git a/tests/layer_tests/tensorflow_tests/test_tf_MulNoNan.py b/tests/layer_tests/tensorflow_tests/test_tf_MulNoNan.py new file mode 100644 index 00000000000000..3472147215c991 --- /dev/null +++ b/tests/layer_tests/tensorflow_tests/test_tf_MulNoNan.py @@ -0,0 +1,47 @@ +# Copyright (C) 2018-2023 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 + +class TestMulNoNan(CommonTFLayerTest): + def _prepare_input(self, inputs_info): + assert 'x' in inputs_info + assert 'y' in inputs_info + x_shape = inputs_info['x'] + y_shape = inputs_info['y'] + inputs_data = {} + inputs_data['x'] = np.random.randint(-10, 10, x_shape).astype(self.input_type) + inputs_data['x'] = mix_array_with_value(inputs_data['x'], np.inf) + inputs_data['x'] = mix_array_with_value(inputs_data['x'], np.nan) + inputs_data['y'] = np.random.randint(-10, 10, y_shape).astype(self.input_type) * \ + np.random.choice([0.0], y_shape).astype(self.input_type) + return inputs_data + + def create_mul_no_nan_net(self, input_shape, input_type): + self.input_type = input_type + tf.compat.v1.reset_default_graph() + with tf.compat.v1.Session() as sess: + x = tf.compat.v1.placeholder(input_type, input_shape, 'x') + y = tf.compat.v1.placeholder(input_type, input_shape, 'y') + tf.raw_ops.MulNoNan(x=x, y=y) + tf.compat.v1.global_variables_initializer() + tf_net = sess.graph_def + return tf_net, None + + test_data_basic = [ + dict(input_shape=[10, 10], input_type=np.float32), + dict(input_shape=[2, 3, 4], input_type=np.float32), + ] + + @pytest.mark.parametrize("params", test_data_basic) + @pytest.mark.precommit_tf_fe + @pytest.mark.nightly + def test_mul_no_nan_basic(self, params, ie_device, precision, ir_version, temp_dir, + use_new_frontend, use_old_api): + self._test(*self.create_mul_no_nan_net(**params), + ie_device, precision, ir_version, temp_dir=temp_dir, + use_new_frontend=use_new_frontend, use_old_api=use_old_api) \ No newline at end of file diff --git a/tests/layer_tests/tensorflow_tests/test_tf_NormalizeL2.py b/tests/layer_tests/tensorflow_tests/test_tf_NormalizeL2.py index 5de76778d1d837..cfd06c7d3f32fe 100644 --- a/tests/layer_tests/tensorflow_tests/test_tf_NormalizeL2.py +++ b/tests/layer_tests/tensorflow_tests/test_tf_NormalizeL2.py @@ -32,8 +32,10 @@ def create_normalize_l2_net(shape, axes): @pytest.mark.precommit @pytest.mark.precommit_tf_fe @pytest.mark.nightly - @pytest.mark.xfail(condition=platform.system() == 'Darwin' and platform.machine() == 'arm64', - reason='Ticket - 122716') + @pytest.mark.xfail(condition=platform.system() in ('Linux', 'Darwin') and platform.machine() in ('arm', 'armv7l', + 'aarch64', + 'arm64', 'ARM64'), + reason='Ticket - 126314, 122716') def test_normalize_l2_basic(self, params, ie_device, precision, ir_version, temp_dir, use_new_frontend, use_old_api): self._test(*self.create_normalize_l2_net(**params), diff --git a/tests/layer_tests/tensorflow_tests/test_tf_Pad.py b/tests/layer_tests/tensorflow_tests/test_tf_Pad.py index eb84c6b19f1ecc..27899f9f5069c4 100644 --- a/tests/layer_tests/tensorflow_tests/test_tf_Pad.py +++ b/tests/layer_tests/tensorflow_tests/test_tf_Pad.py @@ -1,14 +1,15 @@ # Copyright (C) 2018-2023 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 class TestPad(CommonTFLayerTest): def create_pad_net(self, input_shape, pads_values, const_value, pad_mode, pad_op): - import tensorflow as tf + tf.compat.v1.reset_default_graph() with tf.compat.v1.Session() as sess: paddings = tf.constant(pads_values, dtype=tf.int32) @@ -43,3 +44,48 @@ def test_pad_basic(self, params, ie_device, precision, ir_version, temp_dir, use self._test(*self.create_pad_net(**params), ie_device, precision, ir_version, temp_dir=temp_dir, use_new_frontend=use_new_frontend, use_old_api=use_old_api) + + +class TestComplexPad(CommonTFLayerTest): + def _prepare_input(self, inputs_info): + rng = np.random.default_rng() + assert 'param_real' in inputs_info + assert 'param_imag' in inputs_info + param_real_shape = inputs_info['param_real'] + param_imag_shape = inputs_info['param_imag'] + inputs_data = {} + inputs_data['param_real'] = 4 * rng.random(param_real_shape).astype(np.float32) - 2 + inputs_data['param_imag'] = 4 * rng.random(param_imag_shape).astype(np.float32) - 2 + return inputs_data + + def create_pad_complex_net(self, input_shape, pads_values): + tf.compat.v1.reset_default_graph() + # Create the graph and model + with tf.compat.v1.Session() as sess: + param_real = tf.compat.v1.placeholder(np.float32, input_shape, 'param_real') + param_imag = tf.compat.v1.placeholder(np.float32, input_shape, 'param_imag') + complex = tf.raw_ops.Complex(real=param_real, imag=param_imag) + paddings = tf.constant(pads_values, dtype=tf.int32) + pad = tf.raw_ops.Pad(input=complex, paddings=paddings, name='pad') + real = tf.raw_ops.Real(input=pad) + imag = tf.raw_ops.Imag(input=pad) + tf.raw_ops.Pack(values=[real, imag], axis=-1) + tf.compat.v1.global_variables_initializer() + tf_net = sess.graph_def + + return tf_net, None + + test_data_basic = [ + dict(input_shape=[1, 50], pads_values=[[0, 1], [2, 3]]), + dict(input_shape=[2, 20, 10], pads_values=[[0, 1], [2, 3], [4, 0]]), + dict(input_shape=[1, 5, 10, 3], pads_values=[[1, 1], [0, 0], [4, 0], [1, 1]]), + ] + + @pytest.mark.parametrize("params", test_data_basic) + @pytest.mark.precommit_tf_fe + @pytest.mark.nightly + def test_pad_complex(self, params, ie_device, precision, ir_version, temp_dir, use_new_frontend, + use_old_api): + self._test(*self.create_pad_complex_net(**params), + ie_device, precision, ir_version, temp_dir=temp_dir, + use_new_frontend=use_new_frontend, use_old_api=use_old_api) diff --git a/tests/layer_tests/tensorflow_tests/test_tf_TopKV2.py b/tests/layer_tests/tensorflow_tests/test_tf_TopKV2.py index 73efaf490b23dd..737675de84dac8 100644 --- a/tests/layer_tests/tensorflow_tests/test_tf_TopKV2.py +++ b/tests/layer_tests/tensorflow_tests/test_tf_TopKV2.py @@ -48,8 +48,10 @@ def create_topk_v2_net(self, input_shape, input_type, k, sorted, is_first_output @pytest.mark.parametrize("params", test_basic) @pytest.mark.precommit_tf_fe @pytest.mark.nightly - @pytest.mark.xfail(condition=platform.system() == 'Darwin' and platform.machine() == 'arm64', - reason='Ticket - 122716') + @pytest.mark.xfail(condition=platform.system() in ('Linux', 'Darwin') and platform.machine() in ('arm', 'armv7l', + 'aarch64', + 'arm64', 'ARM64'), + reason='Ticket - 126314, 122716') def test_topk_v2_basic(self, params, ie_device, precision, ir_version, temp_dir, use_new_frontend, use_old_api): self._test(*self.create_topk_v2_net(**params), diff --git a/tests/layer_tests/tensorflow_tests/test_tf_TruncateDiv.py b/tests/layer_tests/tensorflow_tests/test_tf_TruncateDiv.py index 18440dbcd7f44a..55859e62eca12d 100644 --- a/tests/layer_tests/tensorflow_tests/test_tf_TruncateDiv.py +++ b/tests/layer_tests/tensorflow_tests/test_tf_TruncateDiv.py @@ -44,8 +44,10 @@ def create_truncate_div_net(self, input_shape, input_type): @pytest.mark.parametrize("params", test_data_basic) @pytest.mark.precommit_tf_fe @pytest.mark.nightly - @pytest.mark.xfail(condition=platform.system() == 'Darwin' and platform.machine() == 'arm64', - reason='Ticket - 122716') + @pytest.mark.xfail(condition=platform.system() in ('Linux', 'Darwin') and platform.machine() in ('arm', 'armv7l', + 'aarch64', + 'arm64', 'ARM64'), + reason='Ticket - 126314, 122716') def test_truncate_div_basic(self, params, ie_device, precision, ir_version, temp_dir, use_new_frontend, use_old_api): self._test(*self.create_truncate_div_net(**params), diff --git a/tests/model_hub_tests/models_hub_common/constants.py b/tests/model_hub_tests/models_hub_common/constants.py index 5c9d1c600c9e7c..8830543ed8bec2 100644 --- a/tests/model_hub_tests/models_hub_common/constants.py +++ b/tests/model_hub_tests/models_hub_common/constants.py @@ -5,6 +5,18 @@ import os import tempfile +''' +@brief Time in seconds of measurement performance on each of the networks. This time doesn't include +loading and heating and includes measurement only one of 2 models - got through convert and read_model. +Both "converted" and "read_model" modes will be 2 * runtime_measure_duration +''' +runtime_measure_duration = os.environ.get('RUNTIME_MEASURE_DURATION', '60') +''' +@brief Time in seconds of heating before measurement +''' +runtime_heat_duration = os.environ.get('RUNTIME_HEAT_DURATION', '5') + + tf_hub_cache_dir = os.environ.get('TFHUB_CACHE_DIR', os.path.join(tempfile.gettempdir(), "tfhub_modules")) os.environ['TFHUB_CACHE_DIR'] = tf_hub_cache_dir diff --git a/tests/model_hub_tests/models_hub_common/test_performance_model.py b/tests/model_hub_tests/models_hub_common/test_performance_model.py index ec51a23e4291a0..90704aa0d6939f 100644 --- a/tests/model_hub_tests/models_hub_common/test_performance_model.py +++ b/tests/model_hub_tests/models_hub_common/test_performance_model.py @@ -3,9 +3,14 @@ import sys -import time import traceback +import time from enum import Enum +import pytest +from openvino.runtime.utils.types import openvino_to_numpy_types_map +import models_hub_common.utils as utils +import models_hub_common.constants as const + import numpy as np import openvino as ov @@ -43,29 +48,24 @@ class Status(Enum): LARGE_INFER_TIME_DIFF_WITH_LARGE_VAR = 9 +class ModelResults: + def __init__(self): + self.infer_mean_time = 0.0 + self.infer_variance = 0.0 + + class Results: def __init__(self): - self.converted_infer_time = 0.0 - self.converted_model_time_variance = 0.0 - self.read_model_infer_time = 0.0 - self.read_model_infer_time_variance = 0.0 + self.converted_model_results = ModelResults() + self.read_model_results = ModelResults() self.infer_time_ratio = 0.0 self.error_message = '' self.status = None -def wrap_timer(func, args): - t0 = time.time() - retval = func(*args) - t1 = time.time() - return retval, t1 - t0 - - class TestModelPerformance: infer_timeout = 600 threshold_ratio = 0.1 - num_heat_runs = 100 - num_measure_runs = 500 threshold_var = 10.0 def load_model(self, model_name, model_link): @@ -116,78 +116,73 @@ def get_inputs_info(self, model_path: str): inputs_info.append((param.get_node().get_friendly_name(), input_shape, param.get_element_type())) return inputs_info - def get_converted_model(self, model_path: str): - return ov.convert_model(model_path) - def get_read_model(self, model_path: str): core = ov.Core() return core.read_model(model=model_path) - def infer_model(self, ov_model, inputs): - infer_step_t0 = time.time() - # heat run - for _ in range(0, TestModelPerformance.num_heat_runs): - ov_model(inputs) - # measure - results = [] - for _ in range(0, TestModelPerformance.num_measure_runs): - t0 = time.time() - ov_model(inputs) - t1 = time.time() - results.append(t1 - t0) - mean = np.mean(results) - var = np.std(results, ddof=1) * 100 / mean - infer_step_t1 = time.time() - print('inference measurement done in {} secs'.format(infer_step_t1 - infer_step_t0)) - return mean, var + def heat_hardware(self, ov_model, inputs) -> None: + _, heat_n_repeats, _ = utils.measure(utils.nano_secs(const.runtime_heat_duration), ov_model, (inputs,)) + print('heat done in {} repeats'.format(heat_n_repeats)) + + def measure_inference(self, ov_model, inputs) -> ModelResults: + time_slices, infer_n_repeats, real_runtime = utils.measure(utils.nano_secs(const.runtime_measure_duration), + ov_model, + (inputs,)) + print('measurement done in {} repeats'.format(infer_n_repeats)) + infer_throughput = float(infer_n_repeats * (10 ** 9)) / real_runtime + infer_mean_time_ns = np.mean(time_slices) + infer_mean_time = infer_mean_time_ns / (10 ** 9) + infer_variance = (np.std(time_slices, ddof=1) * 100) / infer_mean_time_ns + utils.print_stat('model time infer {} secs', infer_mean_time) + utils.print_stat('model time infer var {}', infer_variance) + utils.print_stat('model time infer throughput {}', infer_throughput) + results = ModelResults() + results.infer_mean_time = infer_mean_time + results.infer_variance = infer_variance + return results + + def infer_model(self, ov_model, inputs) -> ModelResults: + self.heat_hardware(ov_model, inputs) + return self.measure_inference(ov_model, inputs) def compile_model(self, model, ie_device): core = ov.Core() return core.compile_model(model, ie_device) - def _run(self, model_name, model_link, ie_device): + def __run(self, model_name, model_link, ie_device): results = Results() results.status = None try: - print("Load the model {} (url: {})".format(model_name, model_link)) results.status = Status.LOAD_MODEL - model_obj, timedelta = wrap_timer(self.load_model, (model_name, model_link)) - print('Model {} loaded in {} secs'.format(model_name, timedelta)) - print("Retrieve inputs info") + model_obj = utils.call_with_timer('Load model', self.load_model, (model_name, model_link)) results.status = Status.GET_INPUTS_INFO - inputs_info, timedelta = wrap_timer(self.get_inputs_info, (model_obj,)) - print('Got inputs info in {} secs'.format(timedelta)) - print("Prepare input data") + inputs_info = utils.call_with_timer('Retrieve model inputs', self.get_inputs_info, (model_obj,)) results.status = Status.PREPARE_INPUTS inputs = self.prepare_inputs(inputs_info) - print("Convert the model into ov::Model") results.status = Status.GET_CONVERTED_MODEL - converted_model = self.compile_model(self.get_converted_model(model_obj), ie_device) - print("read the model into ov::Model") + model = utils.call_with_timer('Convert model', ov.convert_model, (model_obj,)) + converted_model = utils.call_with_timer('Compile converted model', self.compile_model, (model, ie_device)) results.status = Status.GET_READ_MODEL - read_model = self.compile_model(self.get_read_model(model_obj), ie_device) - print("Infer the converted model") + model = utils.call_with_timer('Read model', self.get_read_model, (model_obj,)) + read_model = utils.call_with_timer('Compile read model', self.compile_model, (model, ie_device)) results.status = Status.INFER_CONVERTED_MODEL - converted_model_time, converted_model_time_variance = self.infer_model(converted_model, inputs) - print('converted model time infer {}'.format(converted_model_time)) - print('converted model time infer var {}'.format(converted_model_time_variance)) - print("Infer read model") + results.converted_model_results = utils.call_with_timer('Infer converted model', + self.infer_model, + (converted_model, inputs)) results.status = Status.INFER_READ_MODEL - read_model_time, read_model_time_variance = self.infer_model(read_model, inputs) - print('read model time infer {}'.format(read_model_time)) - print('read model time infer var {}'.format(read_model_time_variance)) + results.read_model_results = utils.call_with_timer('Infer read model', + self.infer_model, + (read_model, inputs)) - infer_time_ratio = converted_model_time / read_model_time + infer_time_ratio = (results.converted_model_results.infer_mean_time / + results.read_model_results.infer_mean_time) + utils.print_stat('infer ratio converted_model_time/read_model_time {}', infer_time_ratio) - results.converted_infer_time = converted_model_time - results.converted_model_time_variance = converted_model_time_variance - results.read_model_infer_time = read_model_time - results.read_model_infer_time_variance = read_model_time_variance results.infer_time_ratio = infer_time_ratio if abs(infer_time_ratio - 1) > TestModelPerformance.threshold_ratio: - if (read_model_time_variance > TestModelPerformance.threshold_var - or converted_model_time_variance > TestModelPerformance.threshold_var): + if (results.read_model_results.infer_variance > TestModelPerformance.threshold_var + or results.converted_model_results.infer_variance > TestModelPerformance.threshold_var): results.status = Status.LARGE_INFER_TIME_DIFF_WITH_LARGE_VAR results.error_message = "too large ratio {} with large variance".format(infer_time_ratio) else: @@ -204,10 +199,10 @@ def _run(self, model_name, model_link, ie_device): def run(self, model_name, model_link, ie_device): self.result = Results() t0 = time.time() - self.result = multiprocessing_run(self._run, [model_name, model_link, ie_device], model_name, + self.result = multiprocessing_run(self.__run, [model_name, model_link, ie_device], model_name, self.infer_timeout) t1 = time.time() - print('test running time {}'.format(t1 - t0)) + utils.print_stat('test run time {} secs', (t1 - t0)) if self.result.status == Status.OK: return err_message = "\n{func} running failed: \n{msg}".format(func=model_name, msg=self.result.error_message) diff --git a/tests/model_hub_tests/models_hub_common/utils.py b/tests/model_hub_tests/models_hub_common/utils.py index bf714c86279061..a45d9aa77d1784 100644 --- a/tests/model_hub_tests/models_hub_common/utils.py +++ b/tests/model_hub_tests/models_hub_common/utils.py @@ -4,6 +4,7 @@ import itertools import os import shutil +import time import numpy as np from models_hub_common.constants import test_device @@ -53,6 +54,8 @@ def get_params(ie_device=None): def cleanup_dir(dir: str): + if not os.path.exists(dir): + return # remove all downloaded files from cache for file_name in os.listdir(dir): file_path = os.path.join(dir, file_name) @@ -63,3 +66,45 @@ def cleanup_dir(dir: str): shutil.rmtree(file_path) except Exception as e: pass + + +def round_num(n: float) -> str: + if 0.1 < n < 1: + return str(n)[:4] + s = '{:.2E}'.format(n) + if s.endswith('E+00'): + return s[:-4] + return s + + +def nano_secs(secs): + return float(secs) * (10 ** 9) + + +def measure(max_time_nano_secs: float, func, args): + left_time_ns = float(max_time_nano_secs) + time_slices = [] + n_repeats = 0 + while left_time_ns > 0: + t0 = time.perf_counter_ns() + func(*args) + t1 = time.perf_counter_ns() + timedelta = t1 - t0 + time_slices.append(timedelta) + left_time_ns -= timedelta + n_repeats += 1 + real_runtime_nano_secs = max_time_nano_secs - left_time_ns + return time_slices, n_repeats, real_runtime_nano_secs + + +def call_with_timer(timer_label: str, func, args): + print('{} ...'.format(timer_label)) + t0 = time.time() + ret_value = func(*args) + t1 = time.time() + print('{} is done in {} secs'.format(timer_label, round_num(t1 - t0))) + return ret_value + + +def print_stat(s: str, value: float): + print(s.format(round_num(value))) diff --git a/tests/model_hub_tests/performance_tests/conftest.py b/tests/model_hub_tests/performance_tests/conftest.py index 09c55569c4d66d..28b96b716829ed 100644 --- a/tests/model_hub_tests/performance_tests/conftest.py +++ b/tests/model_hub_tests/performance_tests/conftest.py @@ -6,6 +6,7 @@ import pytest from models_hub_common.utils import get_params from py.xml import html +from models_hub_common.utils import round_num def pytest_generate_tests(metafunc): @@ -18,35 +19,24 @@ def pytest_generate_tests(metafunc): def pytest_runtest_makereport(item, call): outcome = yield report = outcome.get_result() - if call.when == 'teardown' and getattr(item.obj.__self__, 'result', None) is not None: + if getattr(item.obj.__self__, 'result', None) is not None: results = item.obj.__self__.result report._results = results @pytest.mark.optionalhook def pytest_html_results_table_header(cells): - cells.insert(2, html.th('status', class_="sortable")) - cells.insert(3, html.th('converted model infer time')) - cells.insert(4, html.th('converted model infer time variance')) - cells.insert(5, html.th('read model infer time')) - cells.insert(6, html.th('read model infer time variance')) - cells.insert(7, html.th('model infer time ratio converted_model_time/read_model_time')) - - -def round_num(n: float) -> str: - s = '{:.4E}'.format(n) - if s.endswith('E+00'): - return s[:-4] - return s + cells.insert(3, html.th('Status', class_="sortable")) + cells.insert(4, html.th('convert_model Pipeline Inference Time, sec.')) + cells.insert(5, html.th('read_model Pipeline Inference Time, sec.')) + cells.insert(6, html.th('Inference Time Ratio (convert_model vs. read_model)')) @pytest.mark.optionalhook def pytest_html_results_table_row(report, cells): - if not getattr(report, '_results', None): + if getattr(report, '_results', None) is None: return - cells.insert(2, html.td(report._results.status)) - cells.insert(3, html.td(round_num(report._results.converted_infer_time))) - cells.insert(4, html.td(round_num(report._results.converted_model_time_variance))) - cells.insert(5, html.td(round_num(report._results.read_model_infer_time))) - cells.insert(6, html.td(round_num(report._results.read_model_infer_time_variance))) - cells.insert(7, html.td(round_num(report._results.infer_time_ratio))) + cells.insert(3, html.td(str(report._results.status)[7:])) + cells.insert(4, html.td(round_num(report._results.converted_model_results.infer_mean_time))) + cells.insert(5, html.td(round_num(report._results.read_model_results.infer_mean_time))) + cells.insert(6, html.td(round_num(report._results.infer_time_ratio))) diff --git a/tests/model_hub_tests/performance_tests/test_tf_hub_performance_model.py b/tests/model_hub_tests/performance_tests/test_tf_hub_performance_model.py index d24831ce5fac44..08b4c785a2019b 100644 --- a/tests/model_hub_tests/performance_tests/test_tf_hub_performance_model.py +++ b/tests/model_hub_tests/performance_tests/test_tf_hub_performance_model.py @@ -12,6 +12,7 @@ from models_hub_common.constants import tf_hub_cache_dir from models_hub_common.test_performance_model import TestModelPerformance from models_hub_common.utils import get_models_list +from models_hub_common.utils import cleanup_dir def clean_cache(): @@ -35,7 +36,7 @@ def load_model(self, model_name, model_link): def teardown_method(self): if not no_clean_cache_dir: - clean_cache() + cleanup_dir(tf_hub_cache_dir) # deallocate memory after each test case gc.collect() diff --git a/tests/model_hub_tests/torch_tests/hf_transformers_models b/tests/model_hub_tests/torch_tests/hf_transformers_models index cf699be62892f3..5c09c1d3b54797 100644 --- a/tests/model_hub_tests/torch_tests/hf_transformers_models +++ b/tests/model_hub_tests/torch_tests/hf_transformers_models @@ -65,7 +65,7 @@ EleutherAI/pythia-6.9b,gpt_neox facebook/bart-large-mnli,bart facebook/convnextv2-tiny-22k-384,convnextv2 facebook/detr-resnet-50,detr -facebook/dinov2-base,dinov2,skip,Load problem +facebook/dinov2-base,dinov2,xfail,Tracing error: Please check correctness of provided example_input (but eval was correct) facebook/dpr-question_encoder-single-nq-base,dpr facebook/encodec_24khz,encodec,xfail,Unsupported op aten::lstm facebook/esm2_t6_8M_UR50D,esm @@ -168,7 +168,7 @@ HJHGJGHHG/GAU-Base-Full,gau,skip,Load problem huggingface/autoformer-tourism-monthly,autoformer,skip,Load problem huggingface/informer-tourism-monthly,informer,skip,Load problem huggingface/time-series-transformer-tourism-monthly,time_series_transformer,skip,Load problem -HuggingFaceM4/tiny-random-idefics,idefics,skip,Load problem +HuggingFaceM4/tiny-random-idefics,idefics,xfail,tracing error: Please check correctness of provided example_input (eval was correct but trace failed with incommatible tuples and tensors) HuggingFaceM4/tiny-random-vllama-clip,vllama,skip,Load problem HuggingFaceM4/tiny-random-vopt-clip,vopt,skip,Load problem HuiHuang/gpt3-damo-base-zh,gpt3,skip,Load problem @@ -243,12 +243,12 @@ microsoft/conditional-detr-resnet-50,conditional_detr microsoft/deberta-base,deberta microsoft/git-large-coco,git,skip,Load problem microsoft/layoutlm-base-uncased,layoutlm -microsoft/layoutlmv2-base-uncased,layoutlmv2,skip,Load problem +microsoft/layoutlmv2-base-uncased,layoutlmv2,xfail,Tracing error: Please check correctness of provided example_input (but eval was correct) microsoft/layoutlmv3-base,layoutlmv3 microsoft/markuplm-base,markuplm microsoft/resnet-50,resnet microsoft/speecht5_hifigan,hifigan,skip,Load problem -microsoft/speecht5_tts,speecht5,skip,Load problem +microsoft/speecht5_tts,speecht5,xfail,Tracing error: hangs with no error (probably because of infinite while inside generate) microsoft/swinv2-tiny-patch4-window8-256,swinv2 microsoft/table-transformer-detection,table-transformer microsoft/wavlm-large,wavlm,skip,Load problem @@ -294,6 +294,7 @@ openai-gpt,openai-gpt OpenAssistant/oasst-rm-2-pythia-6.9b-epoch-1,gpt_neox_reward_model,skip,Load problem openmmlab/upernet-convnext-small,upernet,skip,Load problem openMUSE/clip-vit-large-patch14-text-enc,clip_text_model,skip,Load problem +OpenVINO/opt-125m-gptq,opt PatrickHaller/ngme-llama-264M,ngme,skip,Load problem patrickvonplaten/bert2gpt2-cnn_dailymail-fp16,encoder_decoder,skip,Load problem paulhindemith/test-zeroshot,test-zeroshot,skip,Load problem @@ -316,7 +317,7 @@ sahasrarjn/interbert,BERT,skip,Load problem saibo/genkalm-medium-gpt2,genkalm,skip,Load problem SajjadAyoubi/clip-fa-vision,clip_vision_model Salesforce/blip2-flan-t5-xl,blip-2,skip,Load problem -Salesforce/blip-image-captioning-large,blip,skip,Load problem +Salesforce/blip-image-captioning-large,blip Salesforce/instructblip-vicuna-7b,instructblip,skip,Load problem SamLowe/roberta-base-go_emotions,roberta sanchit-gandhi/enhanced_direct_s2st_en_to_es,speech-to-speech,skip,Load problem diff --git a/tests/model_hub_tests/torch_tests/requirements.txt b/tests/model_hub_tests/torch_tests/requirements.txt index 5954a485759153..af6f4cf22128af 100644 --- a/tests/model_hub_tests/torch_tests/requirements.txt +++ b/tests/model_hub_tests/torch_tests/requirements.txt @@ -1,10 +1,12 @@ -c ../../constraints.txt --extra-index-url https://download.pytorch.org/whl/cpu +auto-gptq>=0.5.1 av basicsr datasets facexlib numpy +optimum pandas protobuf pyctcdecode @@ -16,6 +18,7 @@ soundfile super-image timm torch +torchaudio torchvision transformers wheel 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 e13fa5a6b9c183..3c735b90aad159 100644 --- a/tests/model_hub_tests/torch_tests/test_hf_transformers.py +++ b/tests/model_hub_tests/torch_tests/test_hf_transformers.py @@ -12,6 +12,61 @@ from torch_utils import TestTorchConvertModel from torch_utils import process_pytest_marks +def is_gptq_model(config): + config_dict = config.to_dict() if not isinstance(config, dict) else config + quantization_config = config_dict.get("quantization_config", None) + return quantization_config and quantization_config["quant_method"] == "gptq" + + +def patch_gptq(): + orig_cuda_check = torch.cuda.is_available + orig_post_init_model = None + torch.set_default_dtype(torch.float32) + torch.cuda.is_available = lambda: True + + from optimum.gptq import GPTQQuantizer + + orig_post_init_model = GPTQQuantizer.post_init_model + + def post_init_model(self, model): + from auto_gptq import exllama_set_max_input_length + + class StoreAttr(object): + pass + + model.quantize_config = StoreAttr() + model.quantize_config.desc_act = self.desc_act + if self.desc_act and not self.disable_exllama and self.max_input_length is not None: + model = exllama_set_max_input_length(model, self.max_input_length) + return model + + GPTQQuantizer.post_init_model = post_init_model + return orig_cuda_check, orig_post_init_model + + +def unpatch_gptq(orig_cuda_check, orig_post_init_model): + from optimum.gptq import GPTQQuantizer + torch.cuda.is_available = orig_cuda_check + GPTQQuantizer.post_init_model = orig_post_init_model + + +def flattenize_tuples(list_input): + unpacked_pt_res = [] + for r in list_input: + if isinstance(r, (tuple, list)): + unpacked_pt_res.extend(flattenize_tuples(r)) + else: + unpacked_pt_res.append(r) + return unpacked_pt_res + + +def flattenize_outputs(outputs): + if not isinstance(outputs, dict): + outputs = flattenize_tuples(outputs) + return [i.numpy(force=True) for i in outputs] + else: + return dict((k, v.numpy(force=True)) for k, v in outputs.items()) + def filter_example(model, example): try: @@ -41,12 +96,23 @@ def setup_class(self): url = "http://images.cocodataset.org/val2017/000000039769.jpg" self.image = Image.open(requests.get(url, stream=True).raw) + self.cuda_available, self.gptq_postinit = None, None def load_model(self, name, type): + from transformers import AutoConfig mi = model_info(name) auto_processor = None model = None example = None + try: + config = AutoConfig.from_pretrained(name) + except Exception: + config = {} + is_gptq = is_gptq_model(config) + model_kwargs = {"torchscript": True} + if is_gptq: + self.cuda_available, self.gptq_postinit = patch_gptq() + model_kwargs["torch_dtype"] = torch.float32 try: auto_model = mi.transformersInfo['auto_model'] if "processor" in mi.transformersInfo: @@ -73,7 +139,7 @@ def load_model(self, name, type): elif "vit-gpt2" in name: from transformers import VisionEncoderDecoderModel, ViTImageProcessor model = VisionEncoderDecoderModel.from_pretrained( - name, torchscript=True) + name, **model_kwargs) feature_extractor = ViTImageProcessor.from_pretrained(name) encoded_input = feature_extractor( images=[self.image], return_tensors="pt") @@ -88,9 +154,97 @@ def forward(self, x): model = VIT_GPT2_Model(model) example = (encoded_input.pixel_values,) + elif 'idefics' in mi.tags: + from transformers import IdeficsForVisionText2Text, AutoProcessor + model = IdeficsForVisionText2Text.from_pretrained(name) + processor = AutoProcessor.from_pretrained(name) + + prompts = [[ + "User: What is in this image?", + "https://upload.wikimedia.org/wikipedia/commons/8/86/Id%C3%A9fix.JPG", + "", + + "\nAssistant: This picture depicts Idefix, the dog of Obelix in Asterix and Obelix. Idefix is running on the ground.", + + "\nUser:", + "https://static.wikia.nocookie.net/asterix/images/2/25/R22b.gif/revision/latest?cb=20110815073052", + "And who is that?", + + "\nAssistant:", + ]] + + inputs = processor(prompts, add_end_of_utterance_token=False, return_tensors="pt") + exit_condition = processor.tokenizer("", add_special_tokens=False).input_ids + bad_words_ids = processor.tokenizer(["", ""], add_special_tokens=False).input_ids + + example = dict(inputs) + example.update({ + 'eos_token_id': exit_condition, + 'bad_words_ids': bad_words_ids, + }) + + class Decorator(torch.nn.Module): + def __init__(self, model): + super().__init__() + self.model = model + def forward(self, input_ids, attention_mask, pixel_values, image_attention_mask, eos_token_id, bad_words_ids): + return self.model.generate( + input_ids=input_ids, + attention_mask=attention_mask, + pixel_values=pixel_values, + image_attention_mask=image_attention_mask, + eos_token_id=eos_token_id, + bad_words_ids=bad_words_ids, + max_length=100 + ) + model = Decorator(model) + elif 'blip' in mi.tags and 'text2text-generation' in mi.tags: + from transformers import BlipProcessor, BlipForConditionalGeneration + + processor = BlipProcessor.from_pretrained(name) + model = BlipForConditionalGeneration.from_pretrained(name) + text = "a photography of" + inputs = processor(self.image, text, return_tensors="pt") + + class DecoratorForBlipForConditional(torch.nn.Module): + def __init__(self, model): + super().__init__() + self.model = model + + def forward(self, pixel_values, input_ids, attention_mask): + return self.model.generate(pixel_values, input_ids, attention_mask) + + model = DecoratorForBlipForConditional(model) + example = dict(inputs) + elif 'speecht5' in mi.tags: + from transformers import SpeechT5Processor, SpeechT5ForTextToSpeech, SpeechT5HifiGan + from datasets import load_dataset + processor = SpeechT5Processor.from_pretrained(name) + model = SpeechT5ForTextToSpeech.from_pretrained(name) + + inputs = processor(text="Hello, my dog is cute.", return_tensors="pt") + # load xvector containing speaker's voice characteristics from a dataset + embeddings_dataset = load_dataset("Matthijs/cmu-arctic-xvectors", split="validation") + speaker_embeddings = torch.tensor(embeddings_dataset[7306]["xvector"]).unsqueeze(0) + + example = {'input_ids': inputs["input_ids"], 'speaker_embeddings': speaker_embeddings} + class DecoratorModelForSeq2SeqLM(torch.nn.Module): + def __init__(self, model): + super().__init__() + self.model = model + def forward(self, input_ids, speaker_embeddings): + return self.model.generate_speech(input_ids=input_ids, speaker_embeddings=speaker_embeddings) #, vocoder=vocoder) + model = DecoratorModelForSeq2SeqLM(model) + elif 'layoutlmv2' in mi.tags: + from transformers import LayoutLMv2Processor + processor = LayoutLMv2Processor.from_pretrained(name) + + question = "What's the content of this image?" + encoding = processor(self.image, question, max_length=512, truncation=True, return_tensors="pt") + example = dict(encoding) elif 'pix2struct' in mi.tags: from transformers import AutoProcessor, Pix2StructForConditionalGeneration - model = Pix2StructForConditionalGeneration.from_pretrained(name) + model = Pix2StructForConditionalGeneration.from_pretrained(name, **model_kwargs) processor = AutoProcessor.from_pretrained(name) import requests @@ -112,7 +266,7 @@ def forward(self, flattened_patches, attention_mask): # mms-lid model config does not have auto_model attribute, only direct loading available from transformers import Wav2Vec2ForSequenceClassification, AutoFeatureExtractor model = Wav2Vec2ForSequenceClassification.from_pretrained( - name, torchscript=True) + name, **model_kwargs) processor = AutoFeatureExtractor.from_pretrained(name) input_values = processor(torch.randn(16000).numpy(), sampling_rate=16_000, @@ -178,7 +332,7 @@ def forward(self, flattened_patches, attention_mask): elif 'musicgen' in mi.tags: from transformers import AutoProcessor, AutoModelForTextToWaveform processor = AutoProcessor.from_pretrained(name) - model = AutoModelForTextToWaveform.from_pretrained(name, torchscript=True) + model = AutoModelForTextToWaveform.from_pretrained(name, **model_kwargs) inputs = processor( text=["80s pop track with bassy drums and synth"], @@ -193,10 +347,10 @@ def forward(self, flattened_patches, attention_mask): else: try: if auto_model == "AutoModelForCausalLM": - from transformers import AutoTokenizer, AutoModelForCausalLM + from transformers import AutoConfig, AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained(name) model = AutoModelForCausalLM.from_pretrained( - name, torchscript=True) + name, **model_kwargs) text = "Replace me by any text you'd like." encoded_input = tokenizer(text, return_tensors='pt') inputs_dict = dict(encoded_input) @@ -207,7 +361,7 @@ def forward(self, flattened_patches, attention_mask): from transformers import AutoTokenizer, AutoModelForMaskedLM tokenizer = AutoTokenizer.from_pretrained(name) model = AutoModelForMaskedLM.from_pretrained( - name, torchscript=True) + name, **model_kwargs) text = "Replace me by any text you'd like." encoded_input = tokenizer(text, return_tensors='pt') example = dict(encoded_input) @@ -215,7 +369,7 @@ def forward(self, flattened_patches, attention_mask): from transformers import AutoProcessor, AutoModelForImageClassification processor = AutoProcessor.from_pretrained(name) model = AutoModelForImageClassification.from_pretrained( - name, torchscript=True) + name, **model_kwargs) encoded_input = processor( images=self.image, return_tensors="pt") example = dict(encoded_input) @@ -223,7 +377,7 @@ def forward(self, flattened_patches, attention_mask): from transformers import AutoTokenizer, AutoModelForSeq2SeqLM tokenizer = AutoTokenizer.from_pretrained(name) model = AutoModelForSeq2SeqLM.from_pretrained( - name, torchscript=True) + name, **model_kwargs) inputs = tokenizer( "Studies have been shown that owning a dog is good for you", return_tensors="pt") decoder_inputs = tokenizer( @@ -238,7 +392,7 @@ def forward(self, flattened_patches, attention_mask): from datasets import load_dataset processor = AutoProcessor.from_pretrained(name) model = AutoModelForSpeechSeq2Seq.from_pretrained( - name, torchscript=True) + name, **model_kwargs) inputs = processor(torch.randn(1000).numpy(), sampling_rate=16000, return_tensors="pt") @@ -248,7 +402,7 @@ def forward(self, flattened_patches, attention_mask): from datasets import load_dataset processor = AutoProcessor.from_pretrained(name) model = AutoModelForCTC.from_pretrained( - name, torchscript=True) + name, **model_kwargs) input_values = processor(torch.randn(1000).numpy(), return_tensors="pt") example = dict(input_values) @@ -257,7 +411,7 @@ def forward(self, flattened_patches, attention_mask): from transformers import AutoTokenizer, AutoModelForTableQuestionAnswering tokenizer = AutoTokenizer.from_pretrained(name) model = AutoModelForTableQuestionAnswering.from_pretrained( - name, torchscript=True) + name, **model_kwargs) data = {"Actors": ["Brad Pitt", "Leonardo Di Caprio", "George Clooney"], "Number of movies": ["87", "53", "69"]} queries = ["What is the name of the first actor?", @@ -287,7 +441,7 @@ def forward(self, flattened_patches, attention_mask): pass if model is None: from transformers import AutoModel - model = AutoModel.from_pretrained(name, torchscript=True) + model = AutoModel.from_pretrained(name, **model_kwargs) if hasattr(model, "set_default_language"): model.set_default_language("en_XX") if example is None: @@ -307,6 +461,10 @@ def forward(self, flattened_patches, attention_mask): def teardown_method(self): # remove all downloaded files from cache cleanup_dir(hf_hub_cache_dir) + # restore after gptq patching + if self.cuda_available is not None: + unpatch_gptq(self.cuda_available, self.gptq_postinit) + self.cuda_available, self.gptq_postinit = None, None super().teardown_method() @pytest.mark.parametrize("name,type", [("allenai/led-base-16384", "led"), @@ -314,7 +472,8 @@ def teardown_method(self): ("google/flan-t5-base", "t5"), ("google/tapas-large-finetuned-wtq", "tapas"), ("gpt2", "gpt2"), - ("openai/clip-vit-large-patch14", "clip") + ("openai/clip-vit-large-patch14", "clip"), + ("OpenVINO/opt-125m-gptq", 'opt') ]) @pytest.mark.precommit def test_convert_model_precommit(self, name, type, ie_device): diff --git a/tests/model_hub_tests/torch_tests/test_torchbench.py b/tests/model_hub_tests/torch_tests/test_torchbench.py new file mode 100644 index 00000000000000..425862d14cd6f3 --- /dev/null +++ b/tests/model_hub_tests/torch_tests/test_torchbench.py @@ -0,0 +1,59 @@ +# Copyright (C) 2018-2023 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import os +import sys +import subprocess +import pytest +import torch +import tempfile +from torch_utils import process_pytest_marks, get_models_list, TestTorchConvertModel + + +# To make tests reproducible we seed the random generator +torch.manual_seed(0) + + +class TestTorchbenchmarkConvertModel(TestTorchConvertModel): + _model_list_path = os.path.join( + os.path.dirname(__file__), "torchbench_models") + + def setup_class(self): + super().setup_class(self) + # sd model doesn't need token but torchbench need it to be specified + os.environ['HUGGING_FACE_HUB_TOKEN'] = 'x' + torch.set_grad_enabled(False) + + self.repo_dir = tempfile.TemporaryDirectory() + os.system( + f"git clone https://github.com/pytorch/benchmark.git {self.repo_dir.name}") + subprocess.check_call( + ["git", "checkout", "850364ac2678b2363f086b7549254b6cb7df2e4d"], cwd=self.repo_dir.name) + m_list = get_models_list(self._model_list_path) + m_processed_list = [m for m, _, mark, _ in m_list if mark != "skip"] + subprocess.check_call( + [sys.executable, "install.py"]+m_processed_list, cwd=self.repo_dir.name) + + def load_model(self, model_name, model_link): + sys.path.append(self.repo_dir.name) + from torchbenchmark import load_model_by_name + try: + model_cls = load_model_by_name( + model_name)("eval", "cpu", jit=False) + except: + model_cls = load_model_by_name(model_name)("eval", "cpu") + model, self.example = model_cls.get_module() + self.inputs = self.example + # initialize selected models + if model_name in ["BERT_pytorch", "yolov3"]: + model(*self.example) + return model + + def teardown_class(self): + # cleanup tmpdir + self.repo_dir.cleanup() + + @pytest.mark.parametrize("name", process_pytest_marks(_model_list_path)) + @pytest.mark.nightly + def test_convert_model_all_models(self, name, ie_device): + self.run(name, None, ie_device) diff --git a/tests/model_hub_tests/torch_tests/torchbench_models b/tests/model_hub_tests/torch_tests/torchbench_models new file mode 100644 index 00000000000000..1817aa54657c62 --- /dev/null +++ b/tests/model_hub_tests/torch_tests/torchbench_models @@ -0,0 +1,99 @@ +BERT_pytorch,None +Background_Matting,None +#DALLE2_pytorch,None - Not Supported on CPU +LearningToPaint,None +Super_SloMo,None,xfail,Unsupported ops aten::l1_loss aten::mse_loss +#alexnet,None - Already tested by torchvision tests +basic_gnn_edgecnn,None,xfail,Accuracy validation failed +basic_gnn_gcn,None,xfail,Unsupported ops aten::pow_ aten::scatter_add_ +basic_gnn_gin,None,xfail,Unsupported op aten::scatter_add_ +basic_gnn_sage,None,xfail,Unsupported op aten::scatter_add_ +#cm3leon_generate,None,skip,No install.py is found +dcgan,None +demucs,None,xfail,Unsupported op aten::lstm +#densenet121,None - Already tested by torchvision tests +#detectron2_fasterrcnn_r_101_c4,None - Already tested by det2 tests +#detectron2_fasterrcnn_r_101_dc5,None - Already tested by det2 tests +#detectron2_fasterrcnn_r_101_fpn,None - Already tested by det2 tests +#detectron2_fasterrcnn_r_50_c4,None - Already tested by det2 tests +#detectron2_fasterrcnn_r_50_dc5,None - Already tested by det2 tests +#detectron2_fasterrcnn_r_50_fpn,None - Already tested by det2 tests +#detectron2_fcos_r_50_fpn,None - Already tested by det2 tests +#detectron2_maskrcnn,None - Already tested by det2 tests +#detectron2_maskrcnn_r_101_c4,None - Already tested by det2 tests +#detectron2_maskrcnn_r_101_fpn,None - Already tested by det2 tests +#detectron2_maskrcnn_r_50_c4,None - Already tested by det2 tests +#detectron2_maskrcnn_r_50_fpn,None - Already tested by det2 tests +dlrm,None,xfail,Conversion is failed for: prim::Constant - None +#doctr_det_predictor,None - No module named 'tf2onnx' +#doctr_reco_predictor,None - No module named 'tf2onnx' +drq,None,skip,Tracer cannot infer type of SquashedNormal() +fastNLP_Bert,None,skip,tuple expected at most 1 argument got 2 +functorch_dp_cifar10,None +functorch_maml_omniglot,None +#hf_Albert,None - Already tested by hf tests +#hf_Bart,None - Already tested by hf tests +#hf_Bert,None - Already tested by hf tests +#hf_Bert_large,None - Already tested by hf tests +#hf_BigBird,None - Already tested by hf tests +#hf_DistilBert,None - Already tested by hf tests +#hf_GPT2,None - Already tested by hf tests +#hf_GPT2_large,None - Already tested by hf tests +#hf_Longformer,None - Already tested by hf tests +#hf_Reformer,None - Already tested by hf tests +#hf_T5,None - Already tested by hf tests +#hf_T5_base,None - Already tested by hf tests +#hf_T5_generate,None,skip,No install.py is found +#hf_T5_large,None - Already tested by hf tests +hf_Whisper,None +#hf_clip,None,skip,No install.py is found +lennard_jones,None +llama,None,skip,Type 'Tuple[Tensor int]' cannot be traced +llama_v2_7b_16h,None,skip,Tracer cannot infer type of CausalLMOutputWithPast +maml,None,skip,element 0 of tensors does not require grad and does not have a grad_fn +maml_omniglot,None +mnasnet1_0,None +#mobilenet_v2,None - Already tested by torchvision tests +mobilenet_v2_quantized_qat,None +#mobilenet_v3_large,None - Already tested by torchvision tests +#moco,None - DistributedDataParallel/allgather requires cuda +#nanogpt,None,skip,No install.py is found +nvidia_deeprecommender,None +opacus_cifar10,None,skip,Modules that have backward hooks assigned can't be compiled +phi_1_5,None +phlippe_densenet,None +phlippe_resnet,None +pyhpc_equation_of_state,None,xfail,Accuracy validation failed +pyhpc_isoneutral_mixing,None,xfail,Accuracy validation failed +pyhpc_turbulent_kinetic_energy,None,xfail,Unsupported op aten::empty_like +pytorch_CycleGAN_and_pix2pix,None +pytorch_stargan,None,xfail,CPU plugin error: Unsupported operation of type: BatchNormInference +pytorch_unet,None +#resnet152,None - Already tested by torchvision tests +#resnet18,None - Already tested by torchvision tests +#resnet50,None - Already tested by torchvision tests +resnet50_quantized_qat,None,xfail,Accuracy validation failed +#resnext50_32x4d,None - Already tested by torchvision tests +sam,None,xfail,Unexpected type of example_input +#shufflenet_v2_x1_0,None - Already tested by torchvision tests +#simple_gpt,None,skip,No install.py is found +#simple_gpt_tp_manual,None,skip,No install.py is found +soft_actor_critic,None,skip,Tracer cannot infer type of SquashedNormal +speech_transformer,None +#squeezenet1_1,None - Already tested by torchvision tests +stable_diffusion_text_encoder,None +stable_diffusion_unet,None +tacotron2,None,skip,Can't be loaded without CUDA +#timm_efficientdet,None - Already tested by timm tests +#timm_efficientnet,None - Already tested by timm tests +#timm_nfnet,None - Already tested by timm tests +#timm_regnet,None - Already tested by timm tests +#timm_resnest,None - Already tested by timm tests +#timm_vision_transformer,None - Already tested by timm tests +#timm_vision_transformer_large,None - Already tested by timm tests +#timm_vovnet,None - Already tested by timm tests +torch_multimodal_clip,None,skip,Can't be traced +tts_angular,None,xfail,Unsupported op aten::lstm +#vgg16,None - Already tested by torchvision tests +#vision_maskrcnn,None,skip,Only tensors, lists, tuples of tensors, or dictionary of tensors can be output from traced functions +yolov3,None \ No newline at end of file diff --git a/tests/samples_tests/smoke_tests/test_speech_sample.py b/tests/samples_tests/smoke_tests/test_speech_sample.py index ff3649662d2207..5d67d2e868a2f9 100644 --- a/tests/samples_tests/smoke_tests/test_speech_sample.py +++ b/tests/samples_tests/smoke_tests/test_speech_sample.py @@ -12,6 +12,7 @@ """ import os import pytest +import platform import sys import logging as log from common.samples_common_test_class import SamplesCommonTestClass @@ -56,7 +57,8 @@ def setup_class(cls): super().setup_class() @pytest.mark.parametrize("param", test_data) - @pytest.mark.skipif(sys.platform == 'darwin', reason="GNA is not available on macOS") + @pytest.mark.skipif(condition=platform.system() == 'Darwin' or platform.machine() == 'aarch64', + reason="GNA is not available on macOS or aarch64") def test_speech_sample_nthreads(self, param): stdout = self._test(param).split('\n') @@ -65,7 +67,8 @@ def test_speech_sample_nthreads(self, param): assert avg_error <= self.threshold @pytest.mark.parametrize("param", new_format_test_data) - @pytest.mark.skipif(sys.platform == 'darwin', reason="GNA is not available on macOS") + @pytest.mark.skipif(condition=platform.system() == 'Darwin' or platform.machine() == 'aarch64', + reason="GNA is not available on macOS or aarch64") def test_speech_sample_new_format(self, param): stdout = self._test(param, complete_path=False).split('\n') diff --git a/tests/stress_tests/common/ie_pipelines/pipelines.cpp b/tests/stress_tests/common/ie_pipelines/pipelines.cpp index 6960799a475218..deb655f4ab5d6f 100644 --- a/tests/stress_tests/common/ie_pipelines/pipelines.cpp +++ b/tests/stress_tests/common/ie_pipelines/pipelines.cpp @@ -123,7 +123,7 @@ inference_with_streams(const std::string &model, const std::string &target_devic ie_api_wrapper->read_network(model); ie_api_wrapper->load_network(target_device); try { - nireq = ie_api_wrapper->get_property(METRIC_KEY(OPTIMAL_NUMBER_OF_INFER_REQUESTS)); + nireq = ie_api_wrapper->get_property(ov::optimal_number_of_infer_requests.name()); } catch (const std::exception &ex) { log_err("Failed to query OPTIMAL_NUMBER_OF_INFER_REQUESTS"); } diff --git a/tests/stress_tests/memcheck_tests/tests.cpp b/tests/stress_tests/memcheck_tests/tests.cpp index ce72b969c4ddc9..672a9456673ef6 100644 --- a/tests/stress_tests/memcheck_tests/tests.cpp +++ b/tests/stress_tests/memcheck_tests/tests.cpp @@ -114,7 +114,7 @@ TEST_P(MemCheckTestSuite, inference_with_streams) { ie_api_wrapper->read_network(model); ie_api_wrapper->load_network(device); try { - nireq = ie_api_wrapper->get_property(METRIC_KEY(OPTIMAL_NUMBER_OF_INFER_REQUESTS)); + nireq = ie_api_wrapper->get_property(ov::optimal_number_of_infer_requests.name()); } catch (const std::exception &ex) { log_err("Failed to query OPTIMAL_NUMBER_OF_INFER_REQUESTS"); } diff --git a/tests/time_tests/include/timetests_helper/utils.h b/tests/time_tests/include/timetests_helper/utils.h index a823127d16934d..d10e6086344ed8 100644 --- a/tests/time_tests/include/timetests_helper/utils.h +++ b/tests/time_tests/include/timetests_helper/utils.h @@ -41,14 +41,14 @@ void setPerformanceConfig(InferenceEngine::Core ie, const std::string &device) { * @brief Function that enables Latency performance hint for specified device (OV API 2) */ void setPerformanceConfig(ov::Core ie, const std::string &device) { - auto supported_config_keys = ie.get_property(device, METRIC_KEY(SUPPORTED_CONFIG_KEYS)).as>(); + auto supported_config_keys = ie.get_property(device, ov::supported_properties); - if (std::find(supported_config_keys.begin(), supported_config_keys.end(), "PERFORMANCE_HINT") == + if (std::find(supported_config_keys.begin(), supported_config_keys.end(), ov::hint::performance_mode) == supported_config_keys.end()) { - std::cerr << "Device " << device << " doesn't support config key 'PERFORMANCE_HINT'!\n" + std::cerr << "Device " << device << " doesn't support " << ov::hint::performance_mode.name() << " property!\n" << "Performance config was not set."; } else - ie.set_property(device, {{CONFIG_KEY(PERFORMANCE_HINT), CONFIG_VALUE(LATENCY)}}); + ie.set_property(device, ov::hint::performance_mode(ov::hint::PerformanceMode::LATENCY)); } } diff --git a/thirdparty/onnx/CMakeLists.txt b/thirdparty/onnx/CMakeLists.txt index c9752a833f7b7c..fb41a383bcef41 100644 --- a/thirdparty/onnx/CMakeLists.txt +++ b/thirdparty/onnx/CMakeLists.txt @@ -70,5 +70,6 @@ if(NOT ENABLE_SYSTEM_PROTOBUF AND NOT BUILD_SHARED_LIBS) endif() install(TARGETS ${protobuf_target_name} EXPORT ONNXTargets - ARCHIVE DESTINATION ${OV_CPACK_ARCHIVEDIR} COMPONENT ${OV_CPACK_COMP_CORE}) + ARCHIVE DESTINATION ${OV_CPACK_ARCHIVEDIR} COMPONENT ${OV_CPACK_COMP_CORE} + ${OV_CPACK_COMP_CORE_EXCLUDE_ALL}) endif() diff --git a/tools/mo/openvino/tools/mo/convert_impl.py b/tools/mo/openvino/tools/mo/convert_impl.py index 3a6df79daa69ab..3c5514d57fee9b 100644 --- a/tools/mo/openvino/tools/mo/convert_impl.py +++ b/tools/mo/openvino/tools/mo/convert_impl.py @@ -41,7 +41,7 @@ from openvino.tools.mo.utils.error import Error, FrameworkError from openvino.tools.mo.utils.get_ov_update_message import get_ov_update_message, get_ov_api20_message, \ - get_tf_fe_message, get_compression_message # pylint: disable=no-name-in-module,import-error + get_tf_fe_message, get_compression_message, get_ovc_message # pylint: disable=no-name-in-module,import-error from openvino.tools.mo.utils.get_ov_update_message import get_try_legacy_fe_message from openvino.tools.mo.utils.model_analysis import AnalysisResults from openvino.tools.mo.utils.version import VersionChecker @@ -908,10 +908,14 @@ def _convert(cli_parser: argparse.ArgumentParser, framework, args, python_api_us ov_update_message = get_ov_update_message() ov_api20_message = get_ov_api20_message() + ovc_message = get_ovc_message() + _, is_caffe, is_mxnet, is_kaldi, _ = deduce_legacy_frontend_by_namespace(argv) if ov_update_message is not None: print(ov_update_message) if ov_api20_message is not None and ov_model is not None: print(ov_api20_message) + if ovc_message is not None and not is_caffe and not is_mxnet and not is_kaldi: + print(ovc_message) is_fallback = getattr(argv, 'is_fallback', False) if not argv.use_legacy_frontend and framework_is_tf(args, argv) and not is_fallback: # now TF FE is default frontend for TensorFlow models conversion diff --git a/tools/mo/openvino/tools/mo/utils/get_ov_update_message.py b/tools/mo/openvino/tools/mo/utils/get_ov_update_message.py index 0bb1ac74bd2c15..e3b30947c30e99 100644 --- a/tools/mo/openvino/tools/mo/utils/get_ov_update_message.py +++ b/tools/mo/openvino/tools/mo/utils/get_ov_update_message.py @@ -47,3 +47,13 @@ def get_compression_message(): def get_try_legacy_fe_message(): message = '[ INFO ] You can also try to use legacy TensorFlow Frontend by using argument --use_legacy_frontend.\n' return message + + +def get_ovc_message(): + link = "https://docs.openvino.ai/2023.2/openvino_docs_OV_Converter_UG_prepare_model_convert_model_MO_OVC_transition.html" + message = '[ INFO ] MO command line tool is considered as the legacy conversion API as of OpenVINO 2023.2 release. ' \ + 'Please use OpenVINO Model Converter (OVC). ' \ + 'OVC represents a lightweight alternative of MO and provides simplified model conversion API. \n' \ + 'Find more information about transition from MO to OVC at {}'.format(link) + + return message