diff --git a/.ci/azure/windows.yml b/.ci/azure/windows.yml index 9a6aba6a88971e..144c605995e367 100644 --- a/.ci/azure/windows.yml +++ b/.ci/azure/windows.yml @@ -243,7 +243,7 @@ jobs: - script: call $(SETUPVARS) && $(INSTALL_TEST_DIR)\ov_onnx_frontend_tests --gtest_print_time=1 --gtest_filter=-*IE_GPU* --gtest_output=xml:$(INSTALL_TEST_DIR)\TEST-ONNXFrontend.xml displayName: 'ONNX Frontend Tests' - # TODO Reenable PDPD after paddlepaddle==2.5.1 with compliant protobuf is released (ticket 95904) + # TODO Reenable PDPD after paddlepaddle==2.5.2 with compliant protobuf is released (ticket 95904) - script: call $(SETUPVARS) && $(INSTALL_TEST_DIR)\paddle_tests --gtest_print_time=1 --gtest_output=xml:$(INSTALL_TEST_DIR)\TEST-Paddle.xml displayName: 'Paddle Frontend UT' enabled: 'false' diff --git a/.github/workflows/android_arm64.yml b/.github/workflows/android_arm64.yml index fb4b36c69f5a55..34487b04903d70 100644 --- a/.github/workflows/android_arm64.yml +++ b/.github/workflows/android_arm64.yml @@ -27,6 +27,7 @@ concurrency: jobs: Build: + timeout-minutes: 15 defaults: run: shell: bash diff --git a/.github/workflows/fedora.yml b/.github/workflows/fedora.yml index f398b1a3623fc1..3bb6b69c76d1f1 100644 --- a/.github/workflows/fedora.yml +++ b/.github/workflows/fedora.yml @@ -28,6 +28,7 @@ concurrency: jobs: Build: + timeout-minutes: 150 defaults: run: shell: bash @@ -172,6 +173,7 @@ jobs: RPM_Packages: needs: Build + timeout-minutes: 5 defaults: run: shell: bash diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 9050ab3d161509..ae512a64393a19 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -35,6 +35,7 @@ env: jobs: Build: + timeout-minutes: 150 defaults: run: shell: bash @@ -105,6 +106,13 @@ jobs: PIP_VER=$(python3 -c "import pip; print(pip.__version__)") echo "Using pip version: ${PIP_VER}" echo "PIP_CACHE_DIR=${PIP_CACHE_PATH}/${PIP_VER}" >> $GITHUB_ENV + - name: Get pip cache info + run: | + echo "Cache size: " + du -h -d2 ${PIP_CACHE_DIR} + echo "Cache info: " + python -m pip cache info + continue-on-error: true - name: Install python dependencies run: | @@ -245,6 +253,7 @@ jobs: Debian_Packages: name: Debian Packages needs: Build + timeout-minutes: 5 defaults: run: shell: bash @@ -298,6 +307,7 @@ jobs: Samples: needs: Build + timeout-minutes: 10 defaults: run: shell: bash @@ -397,6 +407,7 @@ jobs: Conformance: needs: Build + timeout-minutes: ${{ matrix.TEST_TYPE == 'API' && 5 || 15 }} defaults: run: shell: bash @@ -493,6 +504,7 @@ jobs: ONNX_Runtime: name: ONNX Runtime Integration needs: Build + timeout-minutes: 10 defaults: run: shell: bash @@ -628,6 +640,7 @@ jobs: CXX_Unit_Tests: name: C++ unit tests needs: Build + timeout-minutes: 15 defaults: run: shell: bash @@ -850,6 +863,7 @@ jobs: Python_Unit_Tests: name: Python unit tests needs: Build + timeout-minutes: 40 defaults: run: shell: bash @@ -865,38 +879,9 @@ jobs: LAYER_TESTS_INSTALL_DIR: /__w/openvino/openvino/install/tests/layer_tests steps: - - name: Install git - run: | - apt update - apt install --assume-yes --no-install-recommends git ca-certificates - - - name: Clone OpenVINO - uses: actions/checkout@v4 - with: - path: 'openvino' - # # Initialize OpenVINO # - - - uses: actions/setup-python@v4 - with: - python-version: ${{ env.PYTHON_VERSION }} - - - name: Setup pip cache dir - run: | - PIP_VER=$(python3 -c "import pip; print(pip.__version__)") - echo "Using pip version: ${PIP_VER}" - echo "PIP_CACHE_DIR=${PIP_CACHE_PATH}/${PIP_VER}" >> $GITHUB_ENV - - - name: Install Python API tests dependencies - run: | - # For torchvision to OpenVINO preprocessing converter - python3 -m pip install -r ${OPENVINO_REPO}/src/bindings/python/src/openvino/preprocess/torchvision/requirements.txt - - # TODO: replace with Python API tests requirements - python3 -m pip install -r ${OPENVINO_REPO}/tools/mo/requirements_dev.txt - - name: Download OpenVINO package uses: actions/download-artifact@v3 with: @@ -919,6 +904,20 @@ jobs: tar -xzf openvino_tests.tar.gz -C ${INSTALL_DIR} popd + - name: Install 'actions/setup-python@v4' dependencies + run: apt-get update && apt-get install -y libssl1.1 ca-certificates + - uses: actions/setup-python@v4 + with: + python-version: ${{ env.PYTHON_VERSION }} + env: + PIP_CACHE_DIR: ${{ env.PIP_CACHE_PATH }} + - name: Setup pip cache dir + run: | + PIP_VER=$(python3 -c "import pip; print(pip.__version__)") + echo "Using pip version: ${PIP_VER}" + echo "PIP_CACHE_DIR=${PIP_CACHE_PATH}/${PIP_VER}" >> $GITHUB_ENV + echo "PIP_INSTALL_PATH=${Python_ROOT_DIR}/lib/python${PYTHON_VERSION}/site-packages" >> $GITHUB_ENV + - name: Install OpenVINO Python wheels run: | # Install the core OV wheel @@ -930,6 +929,16 @@ jobs: 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 # @@ -945,19 +954,10 @@ jobs: 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: Docs Python snippets - run: | - # to find 'snippets' module in docs - export PYTHONPATH=${OPENVINO_REPO}/docs/:$PYTHONPATH - # for 'template' extension - export LD_LIBRARY_PATH=${INSTALL_TEST_DIR}:$LD_LIBRARY_PATH - python3 ${OPENVINO_REPO}/docs/snippets/main.py - - name: Model Optimizer unit tests run: | # required for MxNet @@ -966,19 +966,57 @@ jobs: python3 -m pytest -s ${INSTALL_TEST_DIR}/mo/unit_tests \ --junitxml=${INSTALL_TEST_DIR}/TEST-ModelOptimizer.xml - - name: PyTorch Layer Tests + - name: Python ONNX operators tests + 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 + 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 - python3 -m pytest ${LAYER_TESTS_INSTALL_DIR}/pytorch_tests -m precommit --junitxml=${INSTALL_TEST_DIR}/TEST-pytorch.xml + + - name: MO Python API Tests + 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 + 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 + 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 + 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: FP16 - name: ONNX Layer Tests run: | - python3 -m pip install -r ${LAYER_TESTS_INSTALL_DIR}/requirements.txt # requires 'unit_tests' from 'tools/mo' - export PYTHONPATH=${OPENVINO_REPO}/tools/mo/:$PYTHONPATH + 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 @@ -986,9 +1024,8 @@ jobs: - name: TensorFlow 1 Layer Tests - TF FE run: | - python3 -m pip install -r ${LAYER_TESTS_INSTALL_DIR}/requirements.txt - # requires 'unit_tests' from 'tools/mo' - export PYTHONPATH=${OPENVINO_REPO}/tools/mo/:$PYTHONPATH + # 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 @@ -996,85 +1033,47 @@ jobs: - name: TensorFlow 2 Layer Tests - TF FE run: | - python3 -m pip install -r ${LAYER_TESTS_INSTALL_DIR}/requirements.txt - # requires 'unit_tests' from 'tools/mo' - export PYTHONPATH=${OPENVINO_REPO}/tools/mo/:$PYTHONPATH + # 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 - run: | - python3 -m pip install -r ${LAYER_TESTS_INSTALL_DIR}/requirements.txt - python3 -m pytest ${LAYER_TESTS_INSTALL_DIR}/jax_tests/ -m precommit --junitxml=${INSTALL_TEST_DIR}/TEST-jax.xml + 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 - run: | - python3 -m pip install -r ${LAYER_TESTS_INSTALL_DIR}/requirements.txt - python3 -m pytest ${LAYER_TESTS_INSTALL_DIR}/tensorflow_tests/test_tf_Roll.py --ir_version=10 --junitxml=${INSTALL_TEST_DIR}/TEST-tf_Roll.xml + 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 - run: | - python3 -m pip install -r ${LAYER_TESTS_INSTALL_DIR}/requirements.txt - python3 -m pytest ${LAYER_TESTS_INSTALL_DIR}/tensorflow2_keras_tests/test_tf2_keras_activation.py \ - --ir_version=11 --junitxml=${INSTALL_TEST_DIR}/TEST-tf2_Activation.xml -k "sigmoid" + 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 - run: | - python3 -m pip install -r ${LAYER_TESTS_INSTALL_DIR}/requirements.txt - 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: Python ONNX operators tests - 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 ${OPENVINO_REPO}/src/frontends/onnx/tests -k 'not cuda' \ - --junitxml=${INSTALL_TEST_DIR}/TEST-onnx_frontend.xml \ - --ignore=${OPENVINO_REPO}/src/frontends/onnx/tests/test_python/test_zoo_models.py - - - name: MO Python API Tests - run: | - python3 -m pip install -r ${LAYER_TESTS_INSTALL_DIR}/requirements.txt - # TODO: remove setupvars.sh from here; currently, it's used for 'test_utils' installed in '/python/openvino' - source ${INSTALL_DIR}/setupvars.sh - bash ${INSTALL_DIR}/install_dependencies/install_openvino_dependencies.sh -c=core -y - - python3 -m pytest ${LAYER_TESTS_INSTALL_DIR}/mo_python_api_tests --junitxml=${INSTALL_TEST_DIR}/TEST-test_mo_convert.xml + 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: OVC Python API Tests - run: | - python3 -m pip install -r ${LAYER_TESTS_INSTALL_DIR}/requirements.txt - # TODO: remove setupvars.sh from here; currently, it's used for 'test_utils' installed in '/python/openvino' - source ${INSTALL_DIR}/setupvars.sh - bash ${INSTALL_DIR}/install_dependencies/install_openvino_dependencies.sh -c=core -y - - 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: Clone API snippets + uses: actions/checkout@v4 + with: + sparse-checkout: openvino/docs/snippets + path: ${{ env.OPENVINO_REPO }} + submodules: 'false' - - name: Python Frontend tests + - name: Docs Python snippets run: | - python3 -m pip install -r ${LAYER_TESTS_INSTALL_DIR}/requirements.txt - # to allow 'libtest_builtin_extensions.so' to find 'libopenvino_onnx_frontend.so' - source ${INSTALL_DIR}/setupvars.sh - - python3 -m pytest ${LAYER_TESTS_INSTALL_DIR}/py_frontend_tests --junitxml=${INSTALL_TEST_DIR}/TEST-test_py_fontend.xml - - # TODO: install to 'tests' component via cpack - - name: OVC unit tests - run: python3 -m pytest -s ${OPENVINO_REPO}/tools/ovc/unit_tests --junitxml=${INSTALL_TEST_DIR}/TEST-OpenVinoConversion.xml + # 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 @@ -1089,6 +1088,7 @@ jobs: CPU_Functional_Tests: name: CPU functional tests needs: Build + timeout-minutes: 25 defaults: run: shell: bash @@ -1148,7 +1148,7 @@ jobs: 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: 40 + timeout-minutes: 20 - name: Save tests execution time uses: actions/cache/save@v3 @@ -1180,6 +1180,7 @@ jobs: 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' && 300 || 5 }} # TODO: Switch back to self-hosted runners # container: # image: openvinogithubactions.azurecr.io/dockerhub/ubuntu:20.04 @@ -1256,6 +1257,7 @@ jobs: PyTorch_Models_Tests: name: PyTorch Models tests needs: Build + timeout-minutes: ${{ github.event_name == 'schedule' && 300 || 30 }} defaults: run: shell: bash @@ -1327,7 +1329,7 @@ jobs: - 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 + 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 @@ -1349,6 +1351,7 @@ jobs: NVIDIA_Plugin: name: NVIDIA plugin needs: Build + timeout-minutes: 15 defaults: run: shell: bash diff --git a/.github/workflows/linux_conditional_compilation.yml b/.github/workflows/linux_conditional_compilation.yml index 15acba9d441696..74bfd4e2e203ce 100644 --- a/.github/workflows/linux_conditional_compilation.yml +++ b/.github/workflows/linux_conditional_compilation.yml @@ -31,6 +31,7 @@ env: jobs: Build: + timeout-minutes: 150 defaults: run: shell: bash @@ -115,9 +116,6 @@ jobs: # For running Paddle frontend unit tests python3 -m pip install -r ${OPENVINO_REPO}/src/frontends/paddle/tests/requirements.txt - # see https://github.com/PaddlePaddle/Paddle/issues/55597#issuecomment-1718131420 - wget http://nz2.archive.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.1_1.1.1f-1ubuntu2.19_amd64.deb - apt-get install ./libssl1.1_1.1.1f-1ubuntu2.19_amd64.deb # # Build @@ -201,6 +199,7 @@ jobs: CC_Build: name: Conditional Compilation needs: Build + timeout-minutes: 10 defaults: run: shell: bash @@ -296,6 +295,7 @@ jobs: CPU_Functional_Tests: name: CPU functional tests needs: Build + timeout-minutes: 25 defaults: run: shell: bash @@ -341,7 +341,7 @@ jobs: - 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: 40 + timeout-minutes: 20 - name: Upload Test Results uses: actions/upload-artifact@v3 diff --git a/.github/workflows/linux_riscv.yml b/.github/workflows/linux_riscv.yml index 927b10ea80120c..0b181c3c8ff0ed 100644 --- a/.github/workflows/linux_riscv.yml +++ b/.github/workflows/linux_riscv.yml @@ -31,6 +31,7 @@ concurrency: jobs: Build: + timeout-minutes: 30 defaults: run: shell: bash diff --git a/.github/workflows/mac.yml b/.github/workflows/mac.yml index 487536f615a8a6..c39df9691fd78b 100644 --- a/.github/workflows/mac.yml +++ b/.github/workflows/mac.yml @@ -34,6 +34,7 @@ env: jobs: Build: + timeout-minutes: 150 defaults: run: shell: bash @@ -142,7 +143,7 @@ jobs: 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 + cmake -DCMAKE_INSTALL_PREFIX=${{ env.INSTALL_DIR }} -DCOMPONENT=python_wheels -P ${{ env.BUILD_DIR }}/cmake_install.cmake - name: Pack Artifacts run: | @@ -187,6 +188,7 @@ jobs: Samples: needs: Build + timeout-minutes: 5 defaults: run: shell: bash @@ -227,7 +229,7 @@ jobs: 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 @@ -279,6 +281,7 @@ jobs: CXX_Unit_Tests: name: C++ Unit tests needs: Build + timeout-minutes: 20 defaults: run: shell: bash @@ -510,6 +513,7 @@ jobs: Python_Unit_Tests: name: Python unit tests needs: Build + timeout-minutes: 55 defaults: run: shell: bash @@ -652,9 +656,9 @@ jobs: - name: ONNX Layer Tests run: | python3 -m pip install -r ${{ env.LAYER_TESTS_INSTALL_DIR }}/requirements.txt - + export PYTHONPATH=${{ env.OPENVINO_REPO }}/tools/mo/:${{ env.LAYER_TESTS_INSTALL_DIR }}:$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 @@ -740,6 +744,7 @@ jobs: CPU_Functional_Tests: name: CPU functional tests needs: Build + timeout-minutes: 25 defaults: run: shell: bash diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index e6763d2a696377..84e9209aecb092 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -1,9 +1,9 @@ -name: Windows (VS 2022, Python 3.11) +name: Windows (VS 2019, Python 3.11) on: + workflow_dispatch: schedule: # at 00:00 on workdays - cron: '0 0 * * 1,2,3,4,5' -# workflow_dispatch: # pull_request: # paths-ignore: # - '**/docs/**' @@ -33,10 +33,11 @@ env: jobs: Build: + timeout-minutes: 180 defaults: run: shell: pwsh - runs-on: windows-latest-8-cores + runs-on: windows-2019-16-core env: CMAKE_BUILD_TYPE: 'Release' CMAKE_GENERATOR: 'Ninja Multi-Config' @@ -115,7 +116,7 @@ jobs: cmake -G "${{ env.CMAKE_GENERATOR }}" ` -DENABLE_CPPLINT=OFF ` -DBUILD_nvidia_plugin=OFF ` - -DBUILD_SHARED_LIBS=OFF ` + -DBUILD_SHARED_LIBS=ON ` -DENABLE_TESTS=ON ` -DCMAKE_COMPILE_WARNING_AS_ERROR=OFF ` -DENABLE_STRICT_DEPENDENCIES=OFF ` @@ -180,10 +181,11 @@ jobs: Samples: needs: Build + timeout-minutes: 10 defaults: run: shell: pwsh - runs-on: windows-latest-8-cores + runs-on: windows-2019 env: INSTALL_DIR: "${{ github.workspace }}\\install" INSTALL_TEST_DIR: "${{ github.workspace }}\\install\\tests" @@ -248,10 +250,11 @@ jobs: Python_Unit_Tests: name: Python unit tests needs: Build + timeout-minutes: 75 defaults: run: shell: pwsh - runs-on: windows-latest + runs-on: windows-2019 env: OPENVINO_REPO: "${{ github.workspace }}\\openvino" OPENVINO_CONTRIB_REPO: "${{ github.workspace }}\\openvino_contrib" @@ -448,10 +451,11 @@ jobs: CXX_Unit_Tests: name: C++ unit tests needs: Build + timeout-minutes: 15 defaults: run: shell: pwsh - runs-on: windows-latest + runs-on: windows-2019 env: INSTALL_DIR: "${{ github.workspace }}\\install" INSTALL_TEST_DIR: "${{ github.workspace }}\\install\\tests" @@ -565,10 +569,13 @@ jobs: 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 - name: SubgraphsDumper tests + shell: cmd run: | call "${{ env.INSTALL_DIR }}\\setupvars.bat" && ${{ env.INSTALL_TEST_DIR }}/subgraphsDumperTests --gtest_print_time=1 --gtest_print_time=1 --device=TEMPLATE --gtest_filter="*OpImpl*" --gtest_output=xml:${{ env.INSTALL_TEST_DIR }}/TEST-SubgraphsDumperTests.xml - name: Template OpImpl tests + if: ${{ 'false' }} # Ticket: 123572 + shell: cmd run: | call "${{ env.INSTALL_DIR }}\\setupvars.bat" && ${{ env.INSTALL_TEST_DIR }}/conformanceTests --gtest_output=xml:${{ env.INSTALL_TEST_DIR }}/TEST-TemplateOpImplTests.xml @@ -598,6 +605,7 @@ jobs: 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 - name: OpenVINO C API tests + if: ${{ 'false' }} # Ticket: 123594 shell: cmd run: | 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 @@ -638,10 +646,11 @@ jobs: CPU_Functional_Tests: name: CPU functional tests needs: Build + timeout-minutes: 30 defaults: run: shell: pwsh - runs-on: windows-latest-8-cores + runs-on: windows-2019-8-core env: INSTALL_DIR: "${{ github.workspace }}\\install" INSTALL_TEST_DIR: "${{ github.workspace }}\\install\\tests" @@ -690,7 +699,7 @@ jobs: shell: cmd run: | call "${{ env.INSTALL_DIR }}\\setupvars.bat" && python3 ${{ env.PARALLEL_TEST_SCRIPT }} -e ${{ env.INSTALL_TEST_DIR }}\ov_cpu_func_tests.exe -c ${{ env.PARALLEL_TEST_CACHE }} -w ${{ env.INSTALL_TEST_DIR }} -s suite -- --gtest_filter=*smoke*" - timeout-minutes: 45 + timeout-minutes: 25 - name: Save tests execution time uses: actions/cache/save@v3 diff --git a/.github/workflows/windows_conditional_compilation.yml b/.github/workflows/windows_conditional_compilation.yml index f0a9741aee9537..d506272d0ad510 100644 --- a/.github/workflows/windows_conditional_compilation.yml +++ b/.github/workflows/windows_conditional_compilation.yml @@ -33,6 +33,7 @@ env: jobs: Build: + timeout-minutes: 180 defaults: run: shell: pwsh diff --git a/cmake/dependencies.cmake b/cmake/dependencies.cmake index 257263f663bec6..c90309ab294553 100644 --- a/cmake/dependencies.cmake +++ b/cmake/dependencies.cmake @@ -104,10 +104,10 @@ function(ov_download_tbb) elseif(LINUX AND X86_64 AND OV_GLIBC_VERSION VERSION_GREATER_EQUAL 2.17) # build oneTBB 2021.2.1 with gcc 4.8 (glibc 2.17) RESOLVE_DEPENDENCY(TBB - ARCHIVE_LIN "oneapi-tbb-2021.2.3-lin-20231012.tgz" + ARCHIVE_LIN "oneapi-tbb-2021.2.4-lin.tgz" TARGET_PATH "${TEMP}/tbb" ENVIRONMENT "TBBROOT" - SHA256 "6f39d18783b37fdcc15ca137fbf70bc78206848af1a510cada806279fae49718" + SHA256 "6523661559a340e88131472ea9a595582c306af083e55293b7357d11b8015546" USE_NEW_LOCATION TRUE) elseif(YOCTO_AARCH64) RESOLVE_DEPENDENCY(TBB diff --git a/src/bindings/python/CMakeLists.txt b/src/bindings/python/CMakeLists.txt index a2e8945a807776..58ff9b74302059 100644 --- a/src/bindings/python/CMakeLists.txt +++ b/src/bindings/python/CMakeLists.txt @@ -403,6 +403,14 @@ endif() if(ENABLE_TESTS) add_subdirectory(tests/mock/mock_py_frontend) add_subdirectory(tests/mock/pyngraph_fe_mock_api) + install(FILES constraints.txt + DESTINATION tests/bindings/python + COMPONENT tests + EXCLUDE_FROM_ALL) + install(FILES src/openvino/preprocess/torchvision/requirements.txt + DESTINATION tests/python/preprocess/torchvision + COMPONENT tests + EXCLUDE_FROM_ALL) endif() if(OpenVINODeveloperPackage_FOUND) diff --git a/src/bindings/python/constraints.txt b/src/bindings/python/constraints.txt index 20e888bde84984..914e48ed444c97 100644 --- a/src/bindings/python/constraints.txt +++ b/src/bindings/python/constraints.txt @@ -16,7 +16,7 @@ patchelf<=0.17.2.1 # Frontends docopt~=0.6.2 -paddlepaddle==2.5.1 +paddlepaddle==2.5.2 tensorflow>=1.15.5,<2.15.0 six~=1.16.0 protobuf>=3.18.1,<4.0.0 diff --git a/src/bindings/python/src/openvino/runtime/utils/decorators.py b/src/bindings/python/src/openvino/runtime/utils/decorators.py index a4b4d33fe6a00d..b980c4c7e50f06 100644 --- a/src/bindings/python/src/openvino/runtime/utils/decorators.py +++ b/src/bindings/python/src/openvino/runtime/utils/decorators.py @@ -9,7 +9,7 @@ from openvino.runtime.utils.types import NodeInput, as_node, as_nodes -def _set_node_friendly_name(node: Node, **kwargs: Any) -> Node: +def _set_node_friendly_name(node: Node, /, **kwargs: Any) -> Node: if "name" in kwargs: node.friendly_name = kwargs["name"] return node diff --git a/src/bindings/python/src/pyopenvino/test_utils/CMakeLists.txt b/src/bindings/python/src/pyopenvino/test_utils/CMakeLists.txt index 4b0c8df9c24c26..c63a30a30e7fef 100644 --- a/src/bindings/python/src/pyopenvino/test_utils/CMakeLists.txt +++ b/src/bindings/python/src/pyopenvino/test_utils/CMakeLists.txt @@ -50,10 +50,10 @@ ov_add_clang_format_target(${TARGET_NAME}_clang FOR_TARGETS ${TARGET_NAME} install(TARGETS ${TARGET_NAME} RUNTIME DESTINATION ${OV_CPACK_PYTHONDIR}/openvino/test_utils COMPONENT tests EXCLUDE_FROM_ALL - LIBRARY DESTINATION ${OV_CPACK_PYTHONDIR}/openvino/test_utils + LIBRARY DESTINATION tests/${OV_CPACK_PYTHONDIR}/openvino/test_utils COMPONENT tests EXCLUDE_FROM_ALL) install(PROGRAMS ${OpenVINOPython_SOURCE_DIR}/src/openvino/test_utils/__init__.py - DESTINATION ${OV_CPACK_PYTHONDIR}/openvino/test_utils + DESTINATION tests/${OV_CPACK_PYTHONDIR}/openvino/test_utils COMPONENT tests EXCLUDE_FROM_ALL) diff --git a/src/bindings/python/tests/test_graph/test_reduction.py b/src/bindings/python/tests/test_graph/test_reduction.py index 7480bb2009ae5f..9747af0b926834 100644 --- a/src/bindings/python/tests/test_graph/test_reduction.py +++ b/src/bindings/python/tests/test_graph/test_reduction.py @@ -154,3 +154,9 @@ def test_normalize_l2(): assert node.get_output_size() == 1 assert node.get_type_name() == "NormalizeL2" assert list(node.get_output_shape(0)) == input_shape + + +def test_reduce_with_keywork(): + const = ov.constant([-1], np.int64) + min_op = ov.reduce_min(node=const, reduction_axes=0) + assert min_op.get_output_size() == 1 diff --git a/src/cmake/openvino.cmake b/src/cmake/openvino.cmake index 7fb6e2fd77bd6b..ad73269d475748 100644 --- a/src/cmake/openvino.cmake +++ b/src/cmake/openvino.cmake @@ -31,6 +31,8 @@ add_library(${TARGET_NAME} add_library(openvino::runtime ALIAS ${TARGET_NAME}) set_target_properties(${TARGET_NAME} PROPERTIES EXPORT_NAME runtime) +target_compile_features(${TARGET_NAME} PUBLIC cxx_std_11) + ov_add_vs_version_file(NAME ${TARGET_NAME} FILEDESCRIPTION "OpenVINO runtime library") target_include_directories(${TARGET_NAME} PUBLIC diff --git a/src/core/include/openvino/op/space_to_depth.hpp b/src/core/include/openvino/op/space_to_depth.hpp index 3b5515503502b6..41582981d39ae4 100644 --- a/src/core/include/openvino/op/space_to_depth.hpp +++ b/src/core/include/openvino/op/space_to_depth.hpp @@ -55,9 +55,7 @@ class OPENVINO_API SpaceToDepth : public Op { void validate_and_infer_types() override; std::shared_ptr clone_with_new_inputs(const OutputVector& new_args) const override; - 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 has_evaluate() const override; protected: diff --git a/src/core/src/op/space_to_depth.cpp b/src/core/src/op/space_to_depth.cpp index ccaa4d43c0d0b9..b6ba80403445be 100644 --- a/src/core/src/op/space_to_depth.cpp +++ b/src/core/src/op/space_to_depth.cpp @@ -2,40 +2,40 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "ngraph/op/space_to_depth.hpp" +#include "openvino/op/space_to_depth.hpp" #include #include #include #include -#include #include "itt.hpp" -#include "ngraph/attribute_visitor.hpp" -#include "ngraph/builder/reshape.hpp" -#include "ngraph/shape.hpp" +#include "openvino/core/attribute_visitor.hpp" +#include "openvino/core/shape.hpp" #include "openvino/reference/space_to_depth.hpp" +#include "space_to_depth_shape_inference.hpp" -using namespace ngraph; - -ov::op::v0::SpaceToDepth::SpaceToDepth(const Output& data, const SpaceToDepthMode& mode, size_t block_size) +namespace ov { +namespace op { +namespace v0 { +SpaceToDepth::SpaceToDepth(const Output& data, const SpaceToDepthMode& mode, size_t block_size) : Op({data}), m_blocksize(block_size), m_mode(mode) { constructor_validate_and_infer_types(); } -ov::op::v0::SpaceToDepth::SpaceToDepth(const Output& data, const std::string& mode, size_t block_size) +SpaceToDepth::SpaceToDepth(const Output& data, const std::string& mode, size_t block_size) : SpaceToDepth(data, as_enum(mode), block_size) {} -bool ngraph::op::v0::SpaceToDepth::visit_attributes(AttributeVisitor& visitor) { +bool SpaceToDepth::visit_attributes(AttributeVisitor& visitor) { OV_OP_SCOPE(v0_SpaceToDepth_visit_attributes); visitor.on_attribute("block_size", m_blocksize); visitor.on_attribute("mode", m_mode); return true; } -std::shared_ptr ov::op::v0::SpaceToDepth::clone_with_new_inputs(const OutputVector& new_args) const { +std::shared_ptr SpaceToDepth::clone_with_new_inputs(const OutputVector& new_args) const { OV_OP_SCOPE(v0_SpaceToDepth_clone_with_new_inputs); if (new_args.size() != 1) { OPENVINO_THROW("Incorrect number of new arguments"); @@ -43,7 +43,7 @@ std::shared_ptr ov::op::v0::SpaceToDepth::clone_with_new_inputs(const Outp return std::make_shared(new_args.at(0), m_mode, m_blocksize); } -void ngraph::op::v0::SpaceToDepth::validate_and_infer_types() { +void SpaceToDepth::validate_and_infer_types() { OV_OP_SCOPE(v0_SpaceToDepth_validate_and_infer_types); OPENVINO_SUPPRESS_DEPRECATED_START @@ -52,61 +52,48 @@ void ngraph::op::v0::SpaceToDepth::validate_and_infer_types() { set_output_type(0, get_input_element_type(0), output_shape); } -OPENVINO_SUPPRESS_DEPRECATED_START -namespace { -bool evaluate_space_to_depth(const HostTensorVector& outputs, - const HostTensorVector& inputs, - const std::size_t block_size, - const ov::op::v0::SpaceToDepth::SpaceToDepthMode mode) { +bool SpaceToDepth::evaluate(TensorVector& outputs, const TensorVector& inputs) const { + OV_OP_SCOPE(v0_SpaceToDepth_evaluate); + OPENVINO_ASSERT(outputs.size() == 1); + const auto& in = inputs[0]; const auto& out = outputs[0]; - size_t elem_size = in->get_element_type().size(); - - if (in->get_partial_shape().is_dynamic()) { - return false; - } - - ov::reference::space_to_depth(in->get_data_ptr(), - in->get_shape(), - out->get_data_ptr(), - out->get_shape(), - block_size, - mode, - elem_size); + reference::space_to_depth(static_cast(in.data()), + in.get_shape(), + static_cast(out.data()), + out.get_shape(), + m_blocksize, + m_mode, + in.get_element_type().size()); return true; } -} // namespace -bool ngraph::op::v0::SpaceToDepth::evaluate(const HostTensorVector& outputs, const HostTensorVector& inputs) const { - OV_OP_SCOPE(v0_SpaceToDepth_evaluate); - return evaluate_space_to_depth(outputs, inputs, m_blocksize, m_mode); -} - -bool ngraph::op::v0::SpaceToDepth::has_evaluate() const { +bool SpaceToDepth::has_evaluate() const { OV_OP_SCOPE(v0_SpaceToDepth_has_evaluate); return !get_input_partial_shape(0).is_dynamic(); } -void op::v0::SpaceToDepth::set_block_size(size_t block_size) { +void SpaceToDepth::set_block_size(size_t block_size) { m_blocksize = block_size; } -void op::v0::SpaceToDepth::set_mode(SpaceToDepthMode mode) { +void SpaceToDepth::set_mode(SpaceToDepthMode mode) { m_mode = mode; } +} // namespace v0 +} // namespace op -std::ostream& ov::operator<<(std::ostream& s, const op::v0::SpaceToDepth::SpaceToDepthMode& type) { +std::ostream& operator<<(std::ostream& s, const op::v0::SpaceToDepth::SpaceToDepthMode& type) { return s << as_string(type); } -namespace ov { template <> -NGRAPH_API EnumNames& -EnumNames::get() { - static auto enum_names = EnumNames( +OPENVINO_API EnumNames& +EnumNames::get() { + static auto enum_names = EnumNames( "op::v0::SpaceToDepth::SpaceToDepthMode", - {{"blocks_first", ngraph::op::v0::SpaceToDepth::SpaceToDepthMode::BLOCKS_FIRST}, - {"depth_first", ngraph::op::v0::SpaceToDepth::SpaceToDepthMode::DEPTH_FIRST}}); + {{"blocks_first", op::v0::SpaceToDepth::SpaceToDepthMode::BLOCKS_FIRST}, + {"depth_first", op::v0::SpaceToDepth::SpaceToDepthMode::DEPTH_FIRST}}); return enum_names; } } // namespace ov diff --git a/src/frontends/onnx/tests/CMakeLists.txt b/src/frontends/onnx/tests/CMakeLists.txt index f0f8891b4a4945..76e7893efef623 100644 --- a/src/frontends/onnx/tests/CMakeLists.txt +++ b/src/frontends/onnx/tests/CMakeLists.txt @@ -165,6 +165,14 @@ target_include_directories(ov_onnx_frontend_tests PRIVATE install(TARGETS ov_onnx_frontend_tests RUNTIME DESTINATION tests COMPONENT tests EXCLUDE_FROM_ALL) +install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + DESTINATION tests/onnx + COMPONENT tests EXCLUDE_FROM_ALL + FILES_MATCHING + PATTERN "*.py" + PATTERN "*.onnx" + PATTERN "*.data") + add_custom_command(TARGET ov_onnx_frontend_tests POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_SOURCE_DIR}/unit_test.manifest" "${TEST_MODEL_ZOO_OUTPUT_DIR}/onnx/unit_test.manifest" diff --git a/src/frontends/pytorch/src/transforms/tuple_unpack_replacer.cpp b/src/frontends/pytorch/src/transforms/tuple_unpack_replacer.cpp index 9352d148e823f7..5884ae6d590eaf 100644 --- a/src/frontends/pytorch/src/transforms/tuple_unpack_replacer.cpp +++ b/src/frontends/pytorch/src/transforms/tuple_unpack_replacer.cpp @@ -176,7 +176,7 @@ bool TupleUnpackInBodyReplacer::run_on_model(const std::shared_ptr& model } if (const auto multiSubGraph = ov::as_type_ptr(op)) { for (size_t i = 0; i < multiSubGraph->get_internal_subgraphs_size(); i++) - result = result || run_on_model(multiSubGraph->get_function(i)); + result = run_on_model(multiSubGraph->get_function(i)) || result; } } diff --git a/src/inference/dev_api/ie_ngraph_utils.hpp b/src/inference/dev_api/ie_ngraph_utils.hpp index aeaa0b4d9b0ba2..2786fc4abf4198 100644 --- a/src/inference/dev_api/ie_ngraph_utils.hpp +++ b/src/inference/dev_api/ie_ngraph_utils.hpp @@ -53,6 +53,8 @@ INFERENCE_ENGINE_1_0_DEPRECATED inline ::ngraph::element::Type convertPrecision( return ::ngraph::element::Type(::ngraph::element::Type_t::boolean); case Precision::BIN: return ::ngraph::element::Type(::ngraph::element::Type_t::u1); + case Precision::NF4: + return ::ngraph::element::Type(::ngraph::element::Type_t::nf4); case Precision::Q78: case Precision::MIXED: case Precision::CUSTOM: diff --git a/src/inference/src/dev/threading/thread_affinity.cpp b/src/inference/src/dev/threading/thread_affinity.cpp index 887e89237b5dd7..a91052f893858b 100644 --- a/src/inference/src/dev/threading/thread_affinity.cpp +++ b/src/inference/src/dev/threading/thread_affinity.cpp @@ -114,7 +114,7 @@ bool pin_current_thread_to_socket(int socket) { std::tuple get_process_mask() { DWORD_PTR pro_mask, sys_mask; if (0 != GetProcessAffinityMask(GetCurrentProcess(), &pro_mask, &sys_mask)) { - CpuSet mask(new DWORD_PTR(pro_mask)); + CpuSet mask = std::make_unique(pro_mask); return std::make_tuple(std::move(mask), 0); } return std::make_tuple(nullptr, 0); @@ -130,7 +130,7 @@ bool pin_thread_to_vacant_core(int thrIdx, return 0 != SetThreadAffinityMask(GetCurrentThread(), DWORD_PTR(1) << cpu_ids[thrIdx]); } bool pin_current_thread_by_mask(int ncores, const CpuSet& procMask) { - DWORD_PTR mask = static_cast(*procMask.get()); + DWORD_PTR mask = *procMask.get(); return 0 != SetThreadAffinityMask(GetCurrentThread(), mask); } bool pin_current_thread_to_socket(int socket) { diff --git a/src/inference/src/dev/threading/thread_affinity.hpp b/src/inference/src/dev/threading/thread_affinity.hpp index 20c0f7d513a59b..6d31989148de92 100644 --- a/src/inference/src/dev/threading/thread_affinity.hpp +++ b/src/inference/src/dev/threading/thread_affinity.hpp @@ -53,7 +53,11 @@ struct ReleaseProcessMaskDeleter { * @brief A unique pointer to CPU set structure with the ReleaseProcessMaskDeleter deleter * @ingroup ov_dev_api_threading */ +#if defined(_WIN32) +using CpuSet = std::unique_ptr; +#else using CpuSet = std::unique_ptr; +#endif /** * @brief Get the cores affinity mask for the current process diff --git a/src/plugins/intel_cpu/src/dnnl_extension_utils.cpp b/src/plugins/intel_cpu/src/dnnl_extension_utils.cpp index 1cef0551d1eb08..1185a79f31c086 100644 --- a/src/plugins/intel_cpu/src/dnnl_extension_utils.cpp +++ b/src/plugins/intel_cpu/src/dnnl_extension_utils.cpp @@ -21,19 +21,18 @@ namespace intel_cpu { uint8_t DnnlExtensionUtils::sizeOfDataType(dnnl::memory::data_type dataType) { switch (dataType) { case dnnl::memory::data_type::f32: - return 4; case dnnl::memory::data_type::s32: return 4; case dnnl::memory::data_type::bf16: + case dnnl::memory::data_type::f16: return 2; case dnnl::memory::data_type::s8: - return 1; case dnnl::memory::data_type::u8: - return 1; case dnnl::memory::data_type::bin: + case dnnl::memory::data_type::nf4: + case dnnl::memory::data_type::s4: + case dnnl::memory::data_type::u4: return 1; - case dnnl::memory::data_type::f16: - return 2; case dnnl::memory::data_type::undef: return 0; default: @@ -58,6 +57,12 @@ memory::data_type DnnlExtensionUtils::IEPrecisionToDataType(const InferenceEngin return memory::data_type::bin; case InferenceEngine::Precision::FP16: return memory::data_type::f16; + case InferenceEngine::Precision::NF4: + return memory::data_type::nf4; + case InferenceEngine::Precision::I4: + return memory::data_type::s4; + case InferenceEngine::Precision::U4: + return memory::data_type::u4; case InferenceEngine::Precision::UNSPECIFIED: return memory::data_type::undef; default: { @@ -82,6 +87,12 @@ InferenceEngine::Precision DnnlExtensionUtils::DataTypeToIEPrecision(memory::dat return InferenceEngine::Precision::BIN; case memory::data_type::f16: return InferenceEngine::Precision::FP16; + case memory::data_type::nf4: + return InferenceEngine::Precision::NF4; + case memory::data_type::s4: + return InferenceEngine::Precision::I4; + case memory::data_type::u4: + return InferenceEngine::Precision::U4; case memory::data_type::undef: return InferenceEngine::Precision::UNSPECIFIED; default: { diff --git a/src/plugins/intel_cpu/src/dnnl_postops_composer.cpp b/src/plugins/intel_cpu/src/dnnl_postops_composer.cpp index 1f85dd1f3ffbc6..865a1033a2c6e7 100644 --- a/src/plugins/intel_cpu/src/dnnl_postops_composer.cpp +++ b/src/plugins/intel_cpu/src/dnnl_postops_composer.cpp @@ -251,48 +251,58 @@ void DnnlPostOpsComposer::appendClip(const std::vector& low, const std::v } } -MemoryPtr DnnlPostOpsComposer::prepackDecompressionParams(const MemoryCPtr& params_ptr, size_t icBlock) { - // Prepacking params from [oc] to [oc, icBlock] layout, where for each icBlock corresponding parameter is duplicated +MemoryPtr DnnlPostOpsComposer::prepackDecompressionParams(const MemoryCPtr& params_ptr, bool needTranspose) { const auto shape = params_ptr->getShape().getStaticDims(); - const size_t elements_count = std::accumulate(shape.begin(), shape.end(), 1, std::multiplies()); - DnnlBlockedMemoryDesc memoryDesc(InferenceEngine::Precision::FP32, Shape({icBlock * elements_count})); - auto mem = std::make_shared(engine, memoryDesc); - size_t dstIdx = 0; - auto decomp_scales_data = static_cast(params_ptr->getData()); - auto decomp_scales_buf = static_cast(mem->getData()); - for (size_t oc = 0; oc < elements_count; oc++) { - for (size_t intIdx = 0; intIdx < icBlock; intIdx++) { - decomp_scales_buf[dstIdx] = decomp_scales_data[oc]; + MemoryPtr mem; + + auto params_data = static_cast(params_ptr->getData()); + + if (needTranspose) { + VectorDims dnnlShape = {shape[0], shape[1]}; + DnnlBlockedMemoryDesc memoryDesc(InferenceEngine::Precision::FP32, Shape(dnnlShape)); + mem = std::make_shared(engine, memoryDesc); + auto memory_buf = static_cast(mem->getData()); + + // oi -> io + for (size_t oc = 0; oc < dnnlShape[0]; oc++) { + for (size_t ic = 0; ic < dnnlShape[1]; ic++) { + memory_buf[ic * dnnlShape[0] + oc] = params_data[oc * dnnlShape[1] + ic]; + } + } + } else { + VectorDims dnnlShape = {shape[shape.size() - 1], shape[0]}; + DnnlBlockedMemoryDesc memoryDesc(InferenceEngine::Precision::FP32, Shape(dnnlShape)); + mem = std::make_shared(engine, memoryDesc); + auto memory_buf = static_cast(mem->getData()); + const size_t elements_count = std::accumulate(shape.begin(), shape.end(), 1, std::multiplies()); + + // io -> io + size_t dstIdx = 0; + for (size_t oc = 0; oc < elements_count; oc++) { + memory_buf[dstIdx] = params_data[oc]; dstIdx++; } } + return mem; } -void DnnlPostOpsComposer::appendDecompressionScales(const MemoryCPtr& scales_ptr, size_t icBlock) { +void DnnlPostOpsComposer::appendDecompressionScales(const MemoryCPtr& scales_ptr, bool needTranspose) { if (scales_ptr == nullptr) return; - const auto shape = scales_ptr->getShape().getStaticDims(); - const auto elements_count = std::accumulate(shape.begin(), shape.end(), 1, std::multiplies()); - int mask = elements_count > 1 ? weightScaleMaskPerChannel : 0; - DEBUG_LOG("Set weights scales mask ", "DNNL_ARG: ", DNNL_ARG_WEIGHTS, " mask: ", mask); - attr.set_scales_mask(DNNL_ARG_WEIGHTS, mask); - - args[DNNL_ARG_ATTR_SCALES | DNNL_ARG_WEIGHTS] = prepackDecompressionParams(scales_ptr, icBlock); + auto scalesMem = prepackDecompressionParams(scales_ptr, needTranspose); + attr.set_scales_dims(DNNL_ARG_WEIGHTS, DnnlExtensionUtils::convertToDnnlDims(scalesMem->getStaticDims())); + args[DNNL_ARG_ATTR_SCALES | DNNL_ARG_WEIGHTS] = scalesMem; } -void DnnlPostOpsComposer::appendDecompressionZeroPoints(const MemoryCPtr& zero_points_ptr, size_t icBlock) { +void DnnlPostOpsComposer::appendDecompressionZeroPoints(const MemoryCPtr& zero_points_ptr, bool needTranspose) { if (zero_points_ptr == nullptr) return; - const auto shape = zero_points_ptr->getShape().getStaticDims(); - const auto elements_count = std::accumulate(shape.begin(), shape.end(), 1, std::multiplies()); - int mask = elements_count > 1 ? weightScaleMaskPerChannel : 0; - DEBUG_LOG("Set weights zero points mask ", "DNNL_ARG: ", DNNL_ARG_WEIGHTS, " mask: ", mask); - attr.set_zero_points_mask(DNNL_ARG_WEIGHTS, mask); - - args[DNNL_ARG_ATTR_ZERO_POINTS | DNNL_ARG_WEIGHTS] = prepackDecompressionParams(zero_points_ptr, icBlock); + auto zeroPointsMem = prepackDecompressionParams(zero_points_ptr, needTranspose); + attr.set_zero_points_dims(DNNL_ARG_WEIGHTS, DnnlExtensionUtils::convertToDnnlDims(zeroPointsMem->getStaticDims())); + args[DNNL_ARG_ATTR_ZERO_POINTS | DNNL_ARG_WEIGHTS] = zeroPointsMem; } } // namespace intel_cpu diff --git a/src/plugins/intel_cpu/src/dnnl_postops_composer.h b/src/plugins/intel_cpu/src/dnnl_postops_composer.h index fd52863ed7a9bd..d31fe6bc852fce 100644 --- a/src/plugins/intel_cpu/src/dnnl_postops_composer.h +++ b/src/plugins/intel_cpu/src/dnnl_postops_composer.h @@ -42,8 +42,8 @@ class DnnlPostOpsComposer { bool appendLinear(const std::vector& scale, const std::vector& shift, bool isLastPostOp, bool allowBinary = true); void appendClip(const std::vector& low, const std::vector& high); - void appendDecompressionScales(const MemoryCPtr& scales_ptr, size_t icBlock); - void appendDecompressionZeroPoints(const MemoryCPtr& zero_points_ptr, size_t icBlock); + void appendDecompressionScales(const MemoryCPtr& scales_ptr, bool needTranspose); + void appendDecompressionZeroPoints(const MemoryCPtr& zero_points_ptr, bool needTranspose); const VectorDims& getOutputDims() { return outputDims; @@ -69,7 +69,7 @@ class DnnlPostOpsComposer { void updateWeiScales(); void updateDestScales(); - MemoryPtr prepackDecompressionParams(const MemoryCPtr& params_ptr, size_t icBlock); + MemoryPtr prepackDecompressionParams(const MemoryCPtr& params_ptr, bool needTranspose); }; } // namespace intel_cpu diff --git a/src/plugins/intel_cpu/src/graph_optimizer.cpp b/src/plugins/intel_cpu/src/graph_optimizer.cpp index 770527c09aa334..cf79a5b79f299d 100644 --- a/src/plugins/intel_cpu/src/graph_optimizer.cpp +++ b/src/plugins/intel_cpu/src/graph_optimizer.cpp @@ -286,7 +286,8 @@ void GraphOptimizer::FuseConvMatmulFCDeconvAndDQScales(Graph &graph) { } void GraphOptimizer::FuseFCAndWeightsDecompression(Graph &graph) { - std::set supportedWeightsPrecisions{InferenceEngine::Precision::U8, InferenceEngine::Precision::NF4}; + std::set supportedWeightsPrecisions{InferenceEngine::Precision::U8, InferenceEngine::Precision::NF4, + InferenceEngine::Precision::U4, InferenceEngine::Precision::I4}; const std::set supportedDataPrecisions{InferenceEngine::Precision::FP32, InferenceEngine::Precision::BF16}; auto expectedNode = [](NodePtr node, Type expectedType) { return node->getType() == expectedType && node->getChildEdges().size() == 1; @@ -335,7 +336,28 @@ void GraphOptimizer::FuseFCAndWeightsDecompression(Graph &graph) { continue; } - const auto convertNode = withSubtract ? subtractNode->getParentEdgesAtPort(0)[0]->getParent() : mulParent; + const bool withPowerStatic = mulParent->getAlgorithm() == Algorithm::EltwisePowerStatic; + NodePtr powerStaticNode; + if (withPowerStatic) { + powerStaticNode = mulParent; + if (auto *eltwiseNode = dynamic_cast(powerStaticNode.get())) { + if (eltwiseNode->getAlpha() != 1 || eltwiseNode->getBeta() != 1) + continue; + } else { + continue; + } + } + + // Both operations fallbacks on IP zero-point attribute and cannot be combined + if (withSubtract && withPowerStatic) + continue; + + auto convertNode = mulParent; + if (withSubtract) + convertNode = subtractNode->getParentEdgesAtPort(0)[0]->getParent(); + if (withPowerStatic) + convertNode = powerStaticNode->getParentEdgesAtPort(0)[0]->getParent(); + if (!expectedNode(convertNode, Type::Convert)) continue; const auto weightsNode = convertNode->getParentEdgesAtPort(0)[0]->getParent(); @@ -347,6 +369,8 @@ void GraphOptimizer::FuseFCAndWeightsDecompression(Graph &graph) { continue; if (withSubtract && subtractConstNode->getOriginalOutputPrecisionAtPort(0) != Precision::FP32) continue; + if (withPowerStatic && powerStaticNode->getOriginalOutputPrecisionAtPort(0) != Precision::FP32) + continue; if (supportedDataPrecisions.find(fcNode->getOriginalInputPrecisionAtPort(0)) == supportedDataPrecisions.end()) continue; if (supportedWeightsPrecisions.find(weightsNode->getOriginalOutputPrecisionAtPort(0)) == supportedWeightsPrecisions.end()) @@ -361,6 +385,7 @@ void GraphOptimizer::FuseFCAndWeightsDecompression(Graph &graph) { VectorDims decompressionConstShape; const auto fcInputWeightsShape = fcNode->getInputShapeAtPort(1); + int groupNum = 1; // Ordinary case: one decompression group if (fcInputWeightsShape.getRank() == weightsShape.getRank()) { const auto& out_channels = fcInputWeightsShape.getDims()[0]; @@ -377,6 +402,7 @@ void GraphOptimizer::FuseFCAndWeightsDecompression(Graph &graph) { const auto& O = withTranspose ? *weights_dims.rbegin() : *(weights_dims.rbegin() + 2); // Group decompression is applied by O and N dims decompressionConstShape = withTranspose ? VectorDims{N, 1, O} : VectorDims{O, N, 1}; + groupNum = N; } if (multiplyConstNode->getOutputShapeAtPort(0).getDims() != decompressionConstShape) continue; @@ -384,7 +410,8 @@ void GraphOptimizer::FuseFCAndWeightsDecompression(Graph &graph) { continue; // HW specific shape limitations - if (impl::cpu::x64::mayiuse(impl::cpu::x64::avx512_core_amx)) { + if (impl::cpu::x64::mayiuse(impl::cpu::x64::avx512_core_amx) && + fcNode->getOriginalInputPrecisionAtPort(0) == InferenceEngine::Precision::BF16) { // OneDNN AMX IP implementation has limited shapes support due to performance considerations. As a current solution conditions below are copied // from OneDNN to make sure correct IP impl will be used since fallback one doesn't support weights decompression feature. size_t OC = fcInputWeightsShape.getDims()[0]; @@ -398,10 +425,38 @@ void GraphOptimizer::FuseFCAndWeightsDecompression(Graph &graph) { continue; } + size_t IC = fcInputWeightsShape.getDims()[1]; + // OneDNN IP primitive provides limited decompression params support + if (IC % groupNum != 0 || IC / groupNum < 4) { + continue; + } + // Fusion processing - fcNode->fuseDecompressionMultiply(multiplyConstNode); - if (withSubtract) - fcNode->fuseDecompressionSubtract(subtractConstNode); + auto *multiplyInputNode = dynamic_cast(multiplyConstNode.get()); + if (!multiplyInputNode) { + IE_THROW() << "Cannot cast " << multiplyInputNode->getName() << " to Input node"; + } + fcNode->fuseDecompressionMultiply(multiplyInputNode->getMemoryPtr()); + + if (withSubtract) { + auto *subtractInputNode = dynamic_cast(subtractConstNode.get()); + if (!subtractInputNode) { + IE_THROW() << "Cannot cast " << subtractInputNode->getName() << " to Input node"; + } + fcNode->fuseDecompressionSubtract(subtractInputNode->getMemoryPtr()); + } + if (withPowerStatic) { + auto *eltwiseNode = dynamic_cast(powerStaticNode.get()); + if (!eltwiseNode) { + IE_THROW() << "Cannot cast " << eltwiseNode->getName() << " to Eltwise node"; + } + + VectorDims memoryDims(decompressionConstShape.size(), 1); + CpuBlockedMemoryDesc memoryDesc(Precision::FP32, Shape(memoryDims)); + auto memory = std::make_shared(graph.getEngine(), memoryDesc, nullptr, false); + (static_cast(memory->getData()))[0] = -1.f * eltwiseNode->getGamma(); + fcNode->fuseDecompressionSubtract(memory); + } fcNode->addOriginalLayer(multiplyNode->getOriginalLayers()); fcNode->addOriginalLayer(convertNode->getOriginalLayers()); @@ -411,12 +466,18 @@ void GraphOptimizer::FuseFCAndWeightsDecompression(Graph &graph) { auto subtractConstEdge = subtractConstNode->getChildEdges()[0].lock(); graph.RemoveEdge(subtractConstEdge); } + if (withPowerStatic) { + fcNode->addOriginalLayer(powerStaticNode->getOriginalLayers()); + } + auto multiplyConstEdge = multiplyConstNode->getChildEdges()[0].lock(); graph.RemoveEdge(multiplyConstEdge); graph.DropNode(convertNode); if (withSubtract) graph.DropNode(subtractNode); + if (withPowerStatic) + graph.DropNode(powerStaticNode); graph.DropNode(multiplyNode); const auto& weightsPrecision = weightsNode->getOriginalOutputPrecisionAtPort(0); @@ -2481,6 +2542,8 @@ void GraphOptimizer::MergeTransposeAndReorder(Graph &graph) { std::string reorderlayerName = parentParentNode->getName() + "_" + Reorder::getReorderArgs(*reorderInDesc, *reorderOutDesc) + "_" + "fake"; + DEBUG_LOG("mergeTransposeAndReorder ", parentNode->getName(), " and ", childNode->getName(), " -> ", reorderlayerName); + EdgePtr edge; for (auto &childEdge : parentParentNode->getChildEdges()) { if (childEdge.lock()->getChild() == childChildNode) { @@ -2494,16 +2557,18 @@ void GraphOptimizer::MergeTransposeAndReorder(Graph &graph) { std::vector srcPerm; auto configReorder = [&]() { - // transposeNode support blocked input & non-blocked output, in the case, the reorder + // case 1. transposeNode support blocked input & non-blocked output, in the case, the reorder // cannot be optimized + // case 2. Transpose and Reorder do opposite permutation to each other as expected, but isOptimized is already set false + // due to some preliminarily checks. We need to reinterpret layout Transpose input without physical change of the memory. auto* transposeNode = dynamic_cast(parentNode.get()); if (transposeNode == nullptr) { IE_THROW() << "[CPU] parent node of type:" << parentNode->getTypeStr() << " with name: " << parentNode->getName() << " is not a transpose node"; } auto inOrder = transposeNode->getSelectedPrimitiveDescriptor()->getConfig().inConfs[0].getMemDesc()->as()->getOrder(); - - if (inOrder.size() > reorderOutDesc->as()->getOrder().size()) { + auto outOrder = reorderOutDesc->as()->getOrder(); + if (!isOptimized || inOrder.size() > outOrder.size()) { isOptimized = false; // inDesc should be permuted before calling reorder auto & ord = transposeNode->getOrder(); diff --git a/src/plugins/intel_cpu/src/nodes/fullyconnected.cpp b/src/plugins/intel_cpu/src/nodes/fullyconnected.cpp index 3add267195ae34..d90cbfd8017321 100644 --- a/src/plugins/intel_cpu/src/nodes/fullyconnected.cpp +++ b/src/plugins/intel_cpu/src/nodes/fullyconnected.cpp @@ -208,7 +208,8 @@ void FullyConnected::getSupportedDescriptors() { useSparseWeights = useSparseWeightsDecompression(); useWeightsDecompressionImpl = dnnl::impl::cpu::x64::mayiuse(dnnl::impl::cpu::x64::avx2) && one_of(inputDataType, memory::data_type::f32, memory::data_type::bf16) && - weightsDataType == memory::data_type::u8; + one_of(weightsDataType, memory::data_type::u8, memory::data_type::nf4, + memory::data_type::u4, memory::data_type::s4); // revert back outputDataType on special cases if (inputDataType == memory::data_type::f32) { @@ -724,15 +725,10 @@ void FullyConnected::setPostOps(dnnl::primitive_attr& attr, const VectorDims& di NodeDesc *selected_pd = getSelectedPrimitiveDescriptor(); if (selected_pd == nullptr) IE_THROW() << "Preferable primitive descriptor is not set for node " << getName() << "."; - // OneDNN API doesn't provide an abilitiy to query optimal layout for runtime attributes - // As workaround we assume that all AMX IP implementations use equal internal IC block size for weights layout - // and prepack runtime attributes accordingly for better performance - bool withAMX = selected_pd->getImplementationType() & impl_desc_type::amx; - int icBlock = withAMX ? 2 : 1; if (decompressionMultiplyPtr) - dnnlpoc.appendDecompressionScales(decompressionMultiplyPtr, icBlock); + dnnlpoc.appendDecompressionScales(decompressionMultiplyPtr, !weightsNonTransposed); if (decompressionSubtractPtr) - dnnlpoc.appendDecompressionZeroPoints(decompressionSubtractPtr, icBlock); + dnnlpoc.appendDecompressionZeroPoints(decompressionSubtractPtr, !weightsNonTransposed); for (size_t i = 0; i < fusedWith.size(); ++i) { auto& node = fusedWith[i]; @@ -1132,30 +1128,25 @@ bool FullyConnected::useSparseWeightsDecompression() { return true; } -void FullyConnected::fuseDecompressionMultiply(const NodePtr& constData) { - fuseDecompressionConstant(constData, decompressionMultiplyPtr); +void FullyConnected::fuseDecompressionMultiply(const MemoryCPtr& memory) { + fuseDecompressionConstant(memory, decompressionMultiplyPtr); } -void FullyConnected::fuseDecompressionSubtract(const NodePtr& constData) { - fuseDecompressionConstant(constData, decompressionSubtractPtr); +void FullyConnected::fuseDecompressionSubtract(const MemoryCPtr& memory) { + fuseDecompressionConstant(memory, decompressionSubtractPtr); } -void FullyConnected::fuseDecompressionConstant(const NodePtr& constData, MemoryCPtr& decompressionValuesPtr) { - auto *constInputNode = dynamic_cast(constData.get()); - if (!constInputNode) { - IE_THROW() << "Cannot cast " << constData->getName() << " to Input"; - } +void FullyConnected::fuseDecompressionConstant(const MemoryCPtr& memory, MemoryCPtr& decompressionValuesPtr) { const auto decompression_prc = InferenceEngine::Precision::FP32; - if (constInputNode->getOriginalOutputPrecisionAtPort(0) == decompression_prc) { - decompressionValuesPtr = constInputNode->getMemoryPtr(); + if (memory->getDesc().getPrecision() == decompression_prc) { + decompressionValuesPtr = memory; } else { - const auto constBlob = constInputNode->getMemoryPtr(); - DnnlBlockedMemoryDesc memoryDesc(decompression_prc, constBlob->getShape()); + DnnlBlockedMemoryDesc memoryDesc(decompression_prc, memory->getShape()); decompressionValuesPtr = std::make_shared(getEngine(), memoryDesc, nullptr, false); - const auto elementsCount = constBlob->getDescWithType()->getPaddedElementsCount(); - cpu_convert(constBlob->getData(), + const auto elementsCount = memory->getDescWithType()->getPaddedElementsCount(); + cpu_convert(memory->getData(), decompressionValuesPtr->getData(), - DnnlExtensionUtils::DataTypeToIEPrecision(constBlob->getDataType()), + DnnlExtensionUtils::DataTypeToIEPrecision(memory->getDataType()), Precision::FP32, elementsCount); } diff --git a/src/plugins/intel_cpu/src/nodes/fullyconnected.h b/src/plugins/intel_cpu/src/nodes/fullyconnected.h index 956767bcea1219..5bbdbc141742a3 100644 --- a/src/plugins/intel_cpu/src/nodes/fullyconnected.h +++ b/src/plugins/intel_cpu/src/nodes/fullyconnected.h @@ -60,8 +60,8 @@ class FullyConnected : public Node { this->weightsNonTransposed = weightsNonTransposed; } - void fuseDecompressionMultiply(const NodePtr& constData); - void fuseDecompressionSubtract(const NodePtr& constData); + void fuseDecompressionMultiply(const MemoryCPtr& memory); + void fuseDecompressionSubtract(const MemoryCPtr& memory); private: void createDescriptorInternal(const dnnl::memory::desc &inputDesc, @@ -99,7 +99,7 @@ class FullyConnected : public Node { const dnnl::engine& engine); bool canBeExecutedInConv1x1() const; - void fuseDecompressionConstant(const NodePtr& constData, MemoryCPtr& decompressionValuesPtr); + void fuseDecompressionConstant(const MemoryCPtr& memory, MemoryCPtr& decompressionValuesPtr); // sparse weights bool useSparseWeights = false; diff --git a/src/plugins/intel_cpu/src/nodes/reorder.h b/src/plugins/intel_cpu/src/nodes/reorder.h index 5e6a125ca94346..29bab1ecdf72f1 100644 --- a/src/plugins/intel_cpu/src/nodes/reorder.h +++ b/src/plugins/intel_cpu/src/nodes/reorder.h @@ -53,6 +53,10 @@ class Reorder : public Node { this->isOptimized = isOptimized; } + bool getOptimized() const { + return isOptimized; + } + bool canBeInPlace() const override { return false; } diff --git a/src/plugins/intel_cpu/src/transformations/transformation_pipeline.cpp b/src/plugins/intel_cpu/src/transformations/transformation_pipeline.cpp index f87bfb4f1b055f..d67c5047b992e0 100644 --- a/src/plugins/intel_cpu/src/transformations/transformation_pipeline.cpp +++ b/src/plugins/intel_cpu/src/transformations/transformation_pipeline.cpp @@ -201,11 +201,16 @@ void Transformations::PreLpt(const std::vector& defaultPrecis } else { // We need to fuse Transpose to MatMul to have a simpler callback for the next transformation CPU_REGISTER_PASS_COMMON(manager, ov::pass::TransposeMatMul); - const ov::element::TypeVector decompression_precisions{ - ov::element::u8, - // TODO: Uncomment when group decompression is supported - // ov::element::nf4 + ov::element::TypeVector decompression_precisions{ + ov::element::u8 }; + // We don't have BF16/FP16 FullyConnected kernels to work with 4bits compressed weights + // Convert node doesn't support 4bit precisions -> fallback on constant folding + if (inferencePrecision == ov::element::f32) { + decompression_precisions.push_back(ov::element::u4); + decompression_precisions.push_back(ov::element::i4); + decompression_precisions.push_back(ov::element::nf4); + } // MarkDequantizationSubgraph is used even in non-LPT pipeline on X64 platforms // in order to keep compressed MatMul weights with decompression operations as is CPU_REGISTER_PASS_X64(manager, ov::pass::MarkDequantizationSubgraph, decompression_precisions, true); @@ -223,15 +228,13 @@ void Transformations::PreLpt(const std::vector& defaultPrecis 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; + } } - // TODO: Uncomment when group decompression is supported - // if (ov::is_type(consumer)) { - // consumer = get_single_consumer(consumer); - // if (consumer != nullptr && ov::is_type(consumer)) { - // return false; - // } - // } - if (ov::is_type(consumer)) { + if (consumer != nullptr && ov::is_type(consumer)) { consumer = get_single_consumer(consumer); if (consumer != nullptr && ov::is_type(consumer)) { return false; diff --git a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/range.cpp b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/range.cpp index 35c017ebd2bfac..9a7b29484d3c9b 100644 --- a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/range.cpp +++ b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/range.cpp @@ -4,10 +4,10 @@ #include -#include "single_layer_tests/range.hpp" +#include "single_op_tests/range.hpp" #include "common_test_utils/test_constants.hpp" -using namespace LayerTestsDefinitions; +using ov::test::RangeLayerTest; namespace { @@ -15,9 +15,9 @@ const std::vector start = { 1.0f, 1.2f }; const std::vector stop = { 5.0f, 5.2f }; const std::vector step = { 1.0f, 0.1f }; -const std::vector netPrecisions = { - InferenceEngine::Precision::FP32, - InferenceEngine::Precision::FP16 +const std::vector model_types = { + ov::element::f32, + ov::element::f16 }; INSTANTIATE_TEST_SUITE_P(smoke_Basic, RangeLayerTest, @@ -25,11 +25,7 @@ INSTANTIATE_TEST_SUITE_P(smoke_Basic, RangeLayerTest, ::testing::ValuesIn(start), ::testing::ValuesIn(stop), ::testing::ValuesIn(step), - ::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(model_types), ::testing::Values(ov::test::utils::DEVICE_CPU)), RangeLayerTest::getTestCaseName); } // namespace diff --git a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/rdft.cpp b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/rdft.cpp index a9c97e92f15954..05131c5eca3e5e 100644 --- a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/rdft.cpp +++ b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/rdft.cpp @@ -4,42 +4,43 @@ #include -#include "single_layer_tests/rdft.hpp" +#include "single_op_tests/rdft.hpp" +#include "common_test_utils/test_enums.hpp" #include "common_test_utils/test_constants.hpp" -using namespace LayerTestsDefinitions; +using ov::test::RDFTLayerTest; -const std::vector opTypes = { - ngraph::helpers::DFTOpType::FORWARD, - ngraph::helpers::DFTOpType::INVERSE +const std::vector op_types = { + ov::test::utils::DFTOpType::FORWARD, + ov::test::utils::DFTOpType::INVERSE }; -static const std::vector inputPrecision = { - InferenceEngine::Precision::FP32, +static const std::vector model_types = { + ov::element::f32, }; -const std::vector> shapesForward1d = { +const std::vector> shapes_forward_1d = { {10}, {64}, {100}, }; -const std::vector> signalSizes1d = { +const std::vector> signal_sizes_1d = { {}, {10}, }; //1D case doesn't work yet on reference implementation INSTANTIATE_TEST_SUITE_P(DISABLED_smoke_RDFT_1d, RDFTLayerTest, ::testing::Combine( - ::testing::ValuesIn(shapesForward1d), - ::testing::ValuesIn(inputPrecision), + ::testing::ValuesIn(shapes_forward_1d), + ::testing::ValuesIn(model_types), ::testing::Values(std::vector{0}), - ::testing::ValuesIn(signalSizes1d), - ::testing::Values(ngraph::helpers::DFTOpType::FORWARD), + ::testing::ValuesIn(signal_sizes_1d), + ::testing::Values(ov::test::utils::DFTOpType::FORWARD), ::testing::Values(ov::test::utils::DEVICE_CPU)), RDFTLayerTest::getTestCaseName); -const std::vector> shapesInverse1d = { +const std::vector> shapes_inverse_1d = { {10, 2}, {64, 2}, {100, 2}, @@ -47,38 +48,38 @@ const std::vector> shapesInverse1d = { INSTANTIATE_TEST_SUITE_P(DISABLED_smoke_IRDFT_1d, RDFTLayerTest, ::testing::Combine( - ::testing::ValuesIn(shapesInverse1d), - ::testing::ValuesIn(inputPrecision), + ::testing::ValuesIn(shapes_inverse_1d), + ::testing::ValuesIn(model_types), ::testing::Values(std::vector{0}), - ::testing::ValuesIn(signalSizes1d), - ::testing::Values(ngraph::helpers::DFTOpType::INVERSE), + ::testing::ValuesIn(signal_sizes_1d), + ::testing::Values(ov::test::utils::DFTOpType::INVERSE), ::testing::Values(ov::test::utils::DEVICE_CPU)), RDFTLayerTest::getTestCaseName); -const std::vector> shapesForward2d = { +const std::vector> shapes_forward_2d = { {10, 15}, {64, 32}, {100, 16}, }; -const std::vector> axes2d = { +const std::vector> axes_2d = { {0, 1}, {1, 0}, {-2, -1}, }; -const std::vector> signalSizes2d = { +const std::vector> signal_sizes_2d = { {}, {10, 10}, }; INSTANTIATE_TEST_SUITE_P(smoke_RDFT_2d, RDFTLayerTest, ::testing::Combine( - ::testing::ValuesIn(shapesForward2d), - ::testing::ValuesIn(inputPrecision), - ::testing::ValuesIn(axes2d), - ::testing::ValuesIn(signalSizes2d), - ::testing::Values(ngraph::helpers::DFTOpType::FORWARD), + ::testing::ValuesIn(shapes_forward_2d), + ::testing::ValuesIn(model_types), + ::testing::ValuesIn(axes_2d), + ::testing::ValuesIn(signal_sizes_2d), + ::testing::Values(ov::test::utils::DFTOpType::FORWARD), ::testing::Values(ov::test::utils::DEVICE_CPU)), RDFTLayerTest::getTestCaseName); -const std::vector> shapesInverse2d = { +const std::vector> shapes_inverse_2d = { {10, 15, 2}, {64, 32, 2}, {100, 32, 2}, @@ -86,71 +87,71 @@ const std::vector> shapesInverse2d = { INSTANTIATE_TEST_SUITE_P(smoke_IRDFT_2d, RDFTLayerTest, ::testing::Combine( - ::testing::ValuesIn(shapesInverse2d), - ::testing::ValuesIn(inputPrecision), - ::testing::ValuesIn(axes2d), - ::testing::ValuesIn(signalSizes2d), - ::testing::Values(ngraph::helpers::DFTOpType::INVERSE), + ::testing::ValuesIn(shapes_inverse_2d), + ::testing::ValuesIn(model_types), + ::testing::ValuesIn(axes_2d), + ::testing::ValuesIn(signal_sizes_2d), + ::testing::Values(ov::test::utils::DFTOpType::INVERSE), ::testing::Values(ov::test::utils::DEVICE_CPU)), RDFTLayerTest::getTestCaseName); -const std::vector> shapesForward4d = { +const std::vector> shapes_forward_4d = { {1, 3, 10, 15}, {1, 4, 64, 32}, }; -const std::vector> axes4d = { +const std::vector> axes_4d = { {0, 1, 2, 3}, {1, 0, -2, -1} }; -const std::vector> signalSizes4d = { +const std::vector> signal_sizes_4d = { {}, }; INSTANTIATE_TEST_SUITE_P(smoke_RDFT_4d, RDFTLayerTest, ::testing::Combine( - ::testing::ValuesIn(shapesForward4d), - ::testing::ValuesIn(inputPrecision), - ::testing::ValuesIn(axes4d), - ::testing::ValuesIn(signalSizes4d), - ::testing::Values(ngraph::helpers::DFTOpType::FORWARD), + ::testing::ValuesIn(shapes_forward_4d), + ::testing::ValuesIn(model_types), + ::testing::ValuesIn(axes_4d), + ::testing::ValuesIn(signal_sizes_4d), + ::testing::Values(ov::test::utils::DFTOpType::FORWARD), ::testing::Values(ov::test::utils::DEVICE_CPU)), RDFTLayerTest::getTestCaseName); -const std::vector> axes4d_2d = { +const std::vector> axes_4d_2d = { {2, 3}, {1, -1} }; INSTANTIATE_TEST_SUITE_P(smoke_RDFT_4d_axes_2d, RDFTLayerTest, ::testing::Combine( - ::testing::ValuesIn(shapesForward4d), - ::testing::ValuesIn(inputPrecision), - ::testing::ValuesIn(axes4d_2d), + ::testing::ValuesIn(shapes_forward_4d), + ::testing::ValuesIn(model_types), + ::testing::ValuesIn(axes_4d_2d), ::testing::Values(std::vector{}), - ::testing::Values(ngraph::helpers::DFTOpType::FORWARD), + ::testing::Values(ov::test::utils::DFTOpType::FORWARD), ::testing::Values(ov::test::utils::DEVICE_CPU)), RDFTLayerTest::getTestCaseName); -const std::vector> shapesInverse4d = { +const std::vector> shapes_inverse_4d = { {1, 3, 10, 15, 2}, {1, 4, 64, 32, 2}, }; INSTANTIATE_TEST_SUITE_P(smoke_IRDFT_4d, RDFTLayerTest, ::testing::Combine( - ::testing::ValuesIn(shapesInverse4d), - ::testing::ValuesIn(inputPrecision), - ::testing::ValuesIn(axes4d), - ::testing::ValuesIn(signalSizes4d), - ::testing::Values(ngraph::helpers::DFTOpType::INVERSE), + ::testing::ValuesIn(shapes_inverse_4d), + ::testing::ValuesIn(model_types), + ::testing::ValuesIn(axes_4d), + ::testing::ValuesIn(signal_sizes_4d), + ::testing::Values(ov::test::utils::DFTOpType::INVERSE), ::testing::Values(ov::test::utils::DEVICE_CPU)), RDFTLayerTest::getTestCaseName); INSTANTIATE_TEST_SUITE_P(smoke_IRDFT_4d_axes_2d, RDFTLayerTest, ::testing::Combine( - ::testing::ValuesIn(shapesInverse4d), - ::testing::ValuesIn(inputPrecision), - ::testing::ValuesIn(axes4d_2d), + ::testing::ValuesIn(shapes_inverse_4d), + ::testing::ValuesIn(model_types), + ::testing::ValuesIn(axes_4d_2d), ::testing::Values(std::vector{}), - ::testing::Values(ngraph::helpers::DFTOpType::INVERSE), + ::testing::Values(ov::test::utils::DFTOpType::INVERSE), ::testing::Values(ov::test::utils::DEVICE_CPU)), RDFTLayerTest::getTestCaseName); diff --git a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/reduce_ops.cpp b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/reduce_ops.cpp index 27ff1b475e38c3..1079a43b8fc792 100644 --- a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/reduce_ops.cpp +++ b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/reduce_ops.cpp @@ -4,31 +4,32 @@ #include -#include "single_layer_tests/reduce_ops.hpp" +#include "single_op_tests/reduce_ops.hpp" #include "common_test_utils/test_constants.hpp" -using namespace LayerTestsDefinitions; +using ov::test::ReduceOpsLayerTest; +using ov::test::ReduceOpsLayerWithSpecificInputTest; namespace { -const std::vector netPrecisions = { - InferenceEngine::Precision::FP32, - InferenceEngine::Precision::FP16, - InferenceEngine::Precision::I64, - InferenceEngine::Precision::I32, - InferenceEngine::Precision::U64 +const std::vector model_types = { + ov::element::f32, + ov::element::f16, + ov::element::i64, + ov::element::i32, + ov::element::u64 }; -const std::vector keepDims = { +const std::vector keep_dims = { true, false, }; -const std::vector> inputShapes = { +const std::vector> input_shapes = { std::vector{10, 20, 30, 40}, std::vector{3, 5, 7, 9}, }; -const std::vector> inputShapesOneAxis = { +const std::vector> input_shapes_one_axis = { std::vector{10, 20, 30, 40}, std::vector{3, 5, 7, 9}, std::vector{10}, @@ -53,108 +54,90 @@ const std::vector> axes = { {1, -1} }; -std::vector opTypes = { +std::vector op_types = { ov::test::utils::OpType::SCALAR, ov::test::utils::OpType::VECTOR, }; -const std::vector reductionTypes = { - ngraph::helpers::ReductionType::Mean, - ngraph::helpers::ReductionType::Min, - ngraph::helpers::ReductionType::Max, - ngraph::helpers::ReductionType::Sum, - ngraph::helpers::ReductionType::Prod, - ngraph::helpers::ReductionType::L1, - ngraph::helpers::ReductionType::L2, +const std::vector reduction_types = { + ov::test::utils::ReductionType::Mean, + ov::test::utils::ReductionType::Min, + ov::test::utils::ReductionType::Max, + ov::test::utils::ReductionType::Sum, + ov::test::utils::ReductionType::Prod, + ov::test::utils::ReductionType::L1, + ov::test::utils::ReductionType::L2, }; -const std::vector reductionLogicalTypes = { - ngraph::helpers::ReductionType::LogicalOr, - ngraph::helpers::ReductionType::LogicalAnd +const std::vector reduction_logical_types = { + ov::test::utils::ReductionType::LogicalOr, + ov::test::utils::ReductionType::LogicalAnd }; -const auto paramsOneAxis = testing::Combine( +const auto params_one_axis = testing::Combine( testing::Values(std::vector{0}), - testing::ValuesIn(opTypes), - testing::ValuesIn(keepDims), - testing::ValuesIn(reductionTypes), - testing::Values(netPrecisions[0]), - testing::Values(InferenceEngine::Precision::UNSPECIFIED), - testing::Values(InferenceEngine::Precision::UNSPECIFIED), - testing::Values(InferenceEngine::Layout::ANY), - testing::ValuesIn(inputShapesOneAxis), + testing::ValuesIn(op_types), + testing::ValuesIn(keep_dims), + testing::ValuesIn(reduction_types), + testing::Values(model_types[0]), + testing::ValuesIn(input_shapes_one_axis), testing::Values(ov::test::utils::DEVICE_CPU) ); -const auto paramsOneAxisLogical = testing::Combine( +const auto params_one_axis_logical = testing::Combine( testing::Values(std::vector{0}), - testing::ValuesIn(opTypes), - testing::ValuesIn(keepDims), - testing::ValuesIn(reductionLogicalTypes), - testing::Values(InferenceEngine::Precision::BOOL), - testing::Values(InferenceEngine::Precision::UNSPECIFIED), - testing::Values(InferenceEngine::Precision::UNSPECIFIED), - testing::Values(InferenceEngine::Layout::ANY), - testing::ValuesIn(inputShapesOneAxis), + testing::ValuesIn(op_types), + testing::ValuesIn(keep_dims), + testing::ValuesIn(reduction_logical_types), + testing::Values(ov::element::boolean), + testing::ValuesIn(input_shapes_one_axis), testing::Values(ov::test::utils::DEVICE_CPU) ); -const auto params_Precisions = testing::Combine( +const auto params_model_types = testing::Combine( testing::Values(std::vector{1, 3}), - testing::Values(opTypes[1]), - testing::ValuesIn(keepDims), - testing::Values(ngraph::helpers::ReductionType::Max, - ngraph::helpers::ReductionType::Mean, - ngraph::helpers::ReductionType::Min, - ngraph::helpers::ReductionType::Sum, - ngraph::helpers::ReductionType::Prod), - testing::ValuesIn(netPrecisions), - testing::Values(InferenceEngine::Precision::UNSPECIFIED), - testing::Values(InferenceEngine::Precision::UNSPECIFIED), - testing::Values(InferenceEngine::Layout::ANY), + testing::Values(op_types[1]), + testing::ValuesIn(keep_dims), + testing::Values(ov::test::utils::ReductionType::Max, + ov::test::utils::ReductionType::Mean, + ov::test::utils::ReductionType::Min, + ov::test::utils::ReductionType::Sum, + ov::test::utils::ReductionType::Prod), + testing::ValuesIn(model_types), testing::Values(std::vector{2, 2, 2, 2}), testing::Values(ov::test::utils::DEVICE_CPU) ); -const auto params_Precisions_ReduceL1 = testing::Combine( +const auto params_model_types_ReduceL1 = testing::Combine( testing::Values(std::vector{1, 3}), - testing::Values(opTypes[1]), - testing::ValuesIn(keepDims), - testing::Values(ngraph::helpers::ReductionType::L1), - testing::Values(InferenceEngine::Precision::FP32, - InferenceEngine::Precision::FP16, - InferenceEngine::Precision::I64, - InferenceEngine::Precision::I32), - testing::Values(InferenceEngine::Precision::UNSPECIFIED), - testing::Values(InferenceEngine::Precision::UNSPECIFIED), - testing::Values(InferenceEngine::Layout::ANY), + testing::Values(op_types[1]), + testing::ValuesIn(keep_dims), + testing::Values(ov::test::utils::ReductionType::L1), + testing::Values(ov::element::f32, + ov::element::f16, + ov::element::i64, + ov::element::i32), testing::Values(std::vector{2, 2, 2, 2}), testing::Values(ov::test::utils::DEVICE_CPU) ); -const auto params_Precisions_ReduceL2 = testing::Combine( +const auto params_model_types_ReduceL2 = testing::Combine( testing::Values(std::vector{1, 3}), - testing::Values(opTypes[1]), - testing::ValuesIn(keepDims), - testing::Values(ngraph::helpers::ReductionType::L2), - testing::Values(InferenceEngine::Precision::FP32, - InferenceEngine::Precision::FP16), - testing::Values(InferenceEngine::Precision::UNSPECIFIED), - testing::Values(InferenceEngine::Precision::UNSPECIFIED), - testing::Values(InferenceEngine::Layout::ANY), + testing::Values(op_types[1]), + testing::ValuesIn(keep_dims), + testing::Values(ov::test::utils::ReductionType::L2), + testing::Values(ov::element::f32, + ov::element::f16), testing::Values(std::vector{2, 2, 2, 2}), testing::Values(ov::test::utils::DEVICE_CPU) ); -const auto params_InputShapes = testing::Combine( +const auto params_input_shapes = testing::Combine( testing::Values(std::vector{0}), - testing::Values(opTypes[1]), - testing::ValuesIn(keepDims), - testing::Values(ngraph::helpers::ReductionType::Mean), - testing::Values(netPrecisions[0]), - testing::Values(InferenceEngine::Precision::UNSPECIFIED), - testing::Values(InferenceEngine::Precision::UNSPECIFIED), - testing::Values(InferenceEngine::Layout::ANY), + testing::Values(op_types[1]), + testing::ValuesIn(keep_dims), + testing::Values(ov::test::utils::ReductionType::Mean), + testing::Values(model_types[0]), testing::Values(std::vector{3}, std::vector{3, 5}, std::vector{2, 4, 6}, @@ -164,54 +147,42 @@ const auto params_InputShapes = testing::Combine( testing::Values(ov::test::utils::DEVICE_CPU) ); -const auto params_Axes = testing::Combine( +const auto params_axes = testing::Combine( testing::ValuesIn(axes), - testing::Values(opTypes[1]), - testing::ValuesIn(keepDims), - testing::Values(ngraph::helpers::ReductionType::Mean), - testing::Values(netPrecisions[0]), - testing::Values(InferenceEngine::Precision::UNSPECIFIED), - testing::Values(InferenceEngine::Precision::UNSPECIFIED), - testing::Values(InferenceEngine::Layout::ANY), - testing::ValuesIn(inputShapes), + testing::Values(op_types[1]), + testing::ValuesIn(keep_dims), + testing::Values(ov::test::utils::ReductionType::Mean), + testing::Values(model_types[0]), + testing::ValuesIn(input_shapes), testing::Values(ov::test::utils::DEVICE_CPU) ); -const auto params_ReductionTypes = testing::Combine( +const auto params_reduction_types = testing::Combine( testing::Values(std::vector{0, 1, 3}), - testing::Values(opTypes[1]), - testing::ValuesIn(keepDims), - testing::ValuesIn(reductionTypes), - testing::Values(netPrecisions[0]), - testing::Values(InferenceEngine::Precision::UNSPECIFIED), - testing::Values(InferenceEngine::Precision::UNSPECIFIED), - testing::Values(InferenceEngine::Layout::ANY), + testing::Values(op_types[1]), + testing::ValuesIn(keep_dims), + testing::ValuesIn(reduction_types), + testing::Values(model_types[0]), testing::Values(std::vector{2, 9, 2, 9}), testing::Values(ov::test::utils::DEVICE_CPU) ); -const auto params_ReductionTypesLogical = testing::Combine( +const auto params_reduction_types_logical = testing::Combine( testing::Values(std::vector{0, 1, 3}), - testing::Values(opTypes[1]), - testing::ValuesIn(keepDims), - testing::ValuesIn(reductionLogicalTypes), - testing::Values(InferenceEngine::Precision::BOOL), - testing::Values(InferenceEngine::Precision::UNSPECIFIED), - testing::Values(InferenceEngine::Precision::UNSPECIFIED), - testing::Values(InferenceEngine::Layout::ANY), + testing::Values(op_types[1]), + testing::ValuesIn(keep_dims), + testing::ValuesIn(reduction_logical_types), + testing::Values(ov::element::boolean), testing::Values(std::vector{2, 9, 2, 9}), testing::Values(ov::test::utils::DEVICE_CPU) ); const auto params_ReduceSum_accuracy = testing::Combine( testing::Values(std::vector{0}), - testing::Values(opTypes[1]), + testing::Values(op_types[1]), testing::Values(true), - testing::Values(ngraph::helpers::ReductionType::Sum), - testing::Values(InferenceEngine::Precision::FP32), - testing::Values(InferenceEngine::Precision::UNSPECIFIED), - testing::Values(InferenceEngine::Precision::UNSPECIFIED), - testing::Values(InferenceEngine::Layout::ANY), + testing::Values(ov::test::utils::ReductionType::Sum), + testing::Values(ov::element::f32), testing::Values(std::vector{1000000}), testing::Values(ov::test::utils::DEVICE_CPU) ); @@ -226,63 +197,63 @@ INSTANTIATE_TEST_SUITE_P( INSTANTIATE_TEST_SUITE_P( smoke_ReduceOneAxis, ReduceOpsLayerTest, - paramsOneAxis, + params_one_axis, ReduceOpsLayerTest::getTestCaseName ); INSTANTIATE_TEST_SUITE_P( smoke_ReduceLogicalOneAxis, ReduceOpsLayerTest, - paramsOneAxisLogical, + params_one_axis_logical, ReduceOpsLayerTest::getTestCaseName ); INSTANTIATE_TEST_SUITE_P( smoke_Reduce_Precisions, ReduceOpsLayerTest, - params_Precisions, + params_model_types, ReduceOpsLayerTest::getTestCaseName ); INSTANTIATE_TEST_SUITE_P( smoke_Reduce_Precisions_L1, ReduceOpsLayerTest, - params_Precisions_ReduceL1, + params_model_types_ReduceL1, ReduceOpsLayerTest::getTestCaseName ); INSTANTIATE_TEST_SUITE_P( smoke_Reduce_Precisions_L2, ReduceOpsLayerTest, - params_Precisions_ReduceL2, + params_model_types_ReduceL2, ReduceOpsLayerTest::getTestCaseName ); INSTANTIATE_TEST_SUITE_P( smoke_Reduce_InputShapes, ReduceOpsLayerTest, - params_InputShapes, + params_input_shapes, ReduceOpsLayerTest::getTestCaseName ); INSTANTIATE_TEST_SUITE_P( smoke_Reduce_Axes, ReduceOpsLayerTest, - params_Axes, + params_axes, ReduceOpsLayerTest::getTestCaseName ); INSTANTIATE_TEST_SUITE_P( smoke_Reduce_ReductionTypes, ReduceOpsLayerTest, - params_ReductionTypes, + params_reduction_types, ReduceOpsLayerTest::getTestCaseName ); INSTANTIATE_TEST_SUITE_P( smoke_ReduceLogical_ReductionTypes, ReduceOpsLayerTest, - params_ReductionTypesLogical, + params_reduction_types_logical, ReduceOpsLayerTest::getTestCaseName ); @@ -291,14 +262,11 @@ INSTANTIATE_TEST_SUITE_P( ReduceOpsLayerWithSpecificInputTest, testing::Combine( testing::ValuesIn(decltype(axes) {{0}, {1}}), - testing::Values(opTypes[1]), + testing::Values(op_types[1]), testing::Values(true), - testing::Values(ngraph::helpers::ReductionType::Sum), - testing::Values(InferenceEngine::Precision::FP32, - InferenceEngine::Precision::I32), - testing::Values(InferenceEngine::Precision::UNSPECIFIED), - testing::Values(InferenceEngine::Precision::UNSPECIFIED), - testing::Values(InferenceEngine::Layout::ANY), + testing::Values(ov::test::utils::ReductionType::Sum), + testing::Values(ov::element::f32, + ov::element::i32), testing::Values(std::vector {2, 10}), testing::Values(ov::test::utils::DEVICE_CPU)), ReduceOpsLayerWithSpecificInputTest::getTestCaseName 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 8d568dfabdf1c6..927c06ed13400d 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 @@ -22,8 +22,6 @@ std::vector disabledTestPatterns() { // TODO: Issue 33886 R"(.*(QuantGroupConv2D).*)", R"(.*(QuantGroupConv3D).*)", - // TODO: Issue: 34518 - R"(.*RangeLayerTest.*)", R"(.*(RangeAddSubgraphTest).*Start=1.2.*Stop=(5.2|-5.2).*Step=(0.1|-0.1).*ET=f16.*)", R"(.*(RangeNumpyAddSubgraphTest).*ET=f16.*)", // TODO: Issue: 43793 @@ -195,6 +193,8 @@ std::vector disabledTestPatterns() { R"(.*RandomUniformLayerTestCPU.*OutPrc=i64.*)", // Issue: 123321 R"(.*smoke_RNNSequenceCommonZeroClip/RNNSequenceTest.Inference.*hidden_size=10.*relu.*)", + // Issue: 123427 + R"(.*RDFTLayerTest.*SignalSize=().*)", }; #if defined(OPENVINO_ARCH_X86) diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/matmul_weights_decompression.cpp b/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/matmul_weights_decompression.cpp index b107b406cd833a..35eb91d3fff04e 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/matmul_weights_decompression.cpp +++ b/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/matmul_weights_decompression.cpp @@ -142,7 +142,8 @@ class MatmulWeightsDecompression : public testing::WithParamInterface(weights_precision, transformed_weights_shape, {}, true); + + auto weights = ngraph::builder::makeConstant(weights_precision, transformed_weights_shape, {}, true, 7); weights->set_friendly_name("Compressed_weights"); auto weights_convert = std::make_shared(weights, decompression_precision); @@ -164,7 +165,7 @@ class MatmulWeightsDecompression : public testing::WithParamInterface(weights_precision, scaleshift_const_shape, {}, true); + auto shift_const = ngraph::builder::makeConstant(weights_precision, scaleshift_const_shape, {}, true, 7); 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); @@ -268,10 +269,7 @@ class MatmulWeightsDecompression : public testing::WithParamInterface(test_param); - // TODO: remove this condition when group decompression is supported - if (weights_precision == ov::element::nf4 || std::get<0>(test_param).weights_group_size != -1) { - return; - } + bool weights_found = false; for (const auto& n : compiledModel.get_runtime_model()->get_ordered_ops()) { if (n->get_friendly_name() == "Compressed_weights") { @@ -301,48 +299,37 @@ std::vector> filterAdditionalConfigBasic() { std::vector> additional_config = {CPUTestUtils::cpuEmptyPluginConfig}; return additional_config; } -std::vector> filterAdditionalConfigBig() { - std::vector> additional_config = {CPUTestUtils::cpuEmptyPluginConfig}; +std::vector> filterAdditionalConfigAMX() { + std::vector> additional_config = {}; if (with_cpu_x86_avx512_core_amx()) additional_config.push_back({{PluginConfigParams::KEY_ENFORCE_BF16, PluginConfigParams::YES}}); return additional_config; } -bool shouldUseDecompressionKernelBig() { - // No decompression support on non-avx systems - if (!with_cpu_x86_avx2()) - return false; - - return true; -} - -bool shouldUseDecompressionKernelBasic() { - // AMX decompression support has shape limitations - if (with_cpu_x86_avx512_core_amx()) - return false; - - return shouldUseDecompressionKernelBig(); -} - -const std::vector weights_precisions = {ov::element::u8, ov::element::nf4}; const std::vector decompression_precisions = {ov::element::f32}; +const std::vector weights_precisions_basic = {ov::element::u8, + ov::element::u4, + ov::element::i4, + ov::element::nf4}; +const std::vector weights_precisions_amx = {ov::element::u8}; + const std::vector input_shapes_basic = { {{{-1, -1, -1}, {{1, 4, 16}, {10, 16, 16}}}, {16, 32}}, - {{{}, {{1, 4, 16}}}, {16, 32}, 2ul}, + {{{}, {{1, 8, 16}}}, {16, 32}, 4ul}, {{{}, {{1, 4, 16}}}, {1, 16, 32}}, {{{}, {{10, 40, 496}}}, {1, 496, 240}}, {{{}, {{1, 4, 48}}}, {48, 256}}, - {{{}, {{11, 339, 377}}}, {377, 335}}, + {{{}, {{1, 11, 154}}}, {154, 77}, 154ul}, + {{{-1, -1, -1}, {{10, 40, 480}, {11, 40, 480}}}, {1, 480, 256}}, }; -const std::vector input_shapes_big = { +const std::vector input_shapes_amx = { {{{-1, -1, -1}, {{10, 40, 480}, {11, 40, 480}}}, {1, 480, 256}}, - {{{-1, 1, 4096}, {{1, 1, 4096}}}, {4096, 3840}, 128ul}, {{{}, {{1, 4, 32}}}, {32, 256}}, - {{{}, {{1, 4, 512}}}, {512, 256}}, {{{}, {{1, 16, 32}}}, {32, 64}}, {{{}, {{2, 4, 32}}}, {32, 65}}, {{{}, {{3, 12, 768}}}, {768, 1024}}, {{{}, {{11, 339, 577}}}, {577, 335}}, + {{{}, {{1, 1, 256}}}, {256, 128}, 64ul}, }; const std::vector fusingParamsSet { emptyFusingSpec, @@ -352,35 +339,36 @@ const std::vector fusingParamsSet { INSTANTIATE_TEST_SUITE_P(smoke_MatMulCompressedWeights_basic, MatmulWeightsDecompression, ::testing::Combine(::testing::ValuesIn(input_shapes_basic), - ::testing::ValuesIn(weights_precisions), + ::testing::ValuesIn(weights_precisions_basic), ::testing::ValuesIn(decompression_precisions), ::testing::Values(true), ::testing::Values(true), ::testing::Values(true), ::testing::ValuesIn(filterAdditionalConfigBasic()), ::testing::ValuesIn(fusingParamsSet), - ::testing::Values(shouldUseDecompressionKernelBasic())), + ::testing::Values(true)), MatmulWeightsDecompression::getTestCaseName); -INSTANTIATE_TEST_SUITE_P(smoke_MatMulCompressedWeights_big, +INSTANTIATE_TEST_SUITE_P(smoke_MatMulCompressedWeights_amx, MatmulWeightsDecompression, - ::testing::Combine(::testing::ValuesIn(input_shapes_big), - ::testing::ValuesIn(weights_precisions), + ::testing::Combine(::testing::ValuesIn(input_shapes_amx), + ::testing::ValuesIn(weights_precisions_amx), ::testing::ValuesIn(decompression_precisions), ::testing::Values(true), ::testing::Values(true), ::testing::Values(true), - ::testing::ValuesIn(filterAdditionalConfigBig()), + ::testing::ValuesIn(filterAdditionalConfigAMX()), ::testing::ValuesIn(fusingParamsSet), - ::testing::Values(shouldUseDecompressionKernelBig())), + ::testing::Values(true)), MatmulWeightsDecompression::getTestCaseName); const std::vector input_shapes_corner_cases_basic = { {{{-1, -1, -1}, {{1, 4, 16}}}, {1, 16, 32}}, {{{-1, -1, -1}, {{1, 4, 16}}}, {16, 32}}, {{{-1, -1, -1}, {{1, 4, 16}}}, {16, 32}, 4ul}, + {{{-1, -1, -1}, {{1, 1, 4096}}}, {4096, 4096}, 128ul}, }; -const std::vector input_shapes_corner_cases_big = { +const std::vector input_shapes_corner_cases_amx = { {{{-1, -1, -1}, {{10, 40, 480}, {11, 40, 480}}}, {1, 480, 256}}, {{{-1, -1, -1}, {{1, 1, 4096}}}, {4096, 4096}, 128ul}, }; @@ -393,27 +381,27 @@ const std::vector decompression_precisions_corner_cases = INSTANTIATE_TEST_SUITE_P(smoke_MatMulCompressedWeights_corner_cases_basic, MatmulWeightsDecompression, ::testing::Combine(::testing::ValuesIn(input_shapes_corner_cases_basic), - ::testing::ValuesIn(weights_precisions), + ::testing::ValuesIn(weights_precisions_basic), ::testing::ValuesIn(decompression_precisions_corner_cases), ::testing::ValuesIn(transpose_weights), ::testing::ValuesIn(add_decompression_sub), ::testing::ValuesIn(reshape_on_decompression), ::testing::ValuesIn(filterAdditionalConfigBasic()), ::testing::Values(emptyFusingSpec), - ::testing::Values(shouldUseDecompressionKernelBasic())), + ::testing::Values(true)), MatmulWeightsDecompression::getTestCaseName); -INSTANTIATE_TEST_SUITE_P(smoke_MatMulCompressedWeights_corner_cases_big, +INSTANTIATE_TEST_SUITE_P(smoke_MatMulCompressedWeights_corner_cases_amx, MatmulWeightsDecompression, - ::testing::Combine(::testing::ValuesIn(input_shapes_corner_cases_big), - ::testing::ValuesIn(weights_precisions), + ::testing::Combine(::testing::ValuesIn(input_shapes_corner_cases_amx), + ::testing::ValuesIn(weights_precisions_amx), ::testing::ValuesIn(decompression_precisions_corner_cases), ::testing::ValuesIn(transpose_weights), ::testing::ValuesIn(add_decompression_sub), ::testing::ValuesIn(reshape_on_decompression), - ::testing::ValuesIn(filterAdditionalConfigBig()), + ::testing::ValuesIn(filterAdditionalConfigAMX()), ::testing::Values(emptyFusingSpec), - ::testing::Values(shouldUseDecompressionKernelBig())), + ::testing::Values(true)), MatmulWeightsDecompression::getTestCaseName); } // namespace } // namespace SubgraphTestsDefinitions diff --git a/src/plugins/intel_cpu/tests/unit/graph/merge_transpose_reorder_test.cpp b/src/plugins/intel_cpu/tests/unit/graph/merge_transpose_reorder_test.cpp new file mode 100644 index 00000000000000..fa2ece2195a25f --- /dev/null +++ b/src/plugins/intel_cpu/tests/unit/graph/merge_transpose_reorder_test.cpp @@ -0,0 +1,226 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// +#include + +#include "node.h" +#include "nodes/reorder.h" +#include "nodes/input.h" +#include "nodes/transpose.h" +#include "graph.h" +#include "edge.h" + +#include "ov_models/builders.hpp" +#include +#include "ie_ngraph_utils.hpp" + +using namespace ov::intel_cpu; + +namespace MergeTransposeReorderCPUTest { +class DummyNode : public Node { +public: + DummyNode(const std::shared_ptr& op, const GraphContext::CPtr context) : + Node(op, context, PassThroughShapeInferFactory()) { + OPENVINO_THROW("Can't create DummyNode from ngraph node"); + } + DummyNode(const ov::Shape& shape, + const ov::element::Type_t& prc, + const std::string& name, + const std::string& type, + const GraphContext::CPtr context) : + Node(type, name, context) { + // dummy node of the same shape and precision to both input and output. + outputShapes.emplace_back(shape); + inputShapes.emplace_back(shape); + addOriginalOutputPrecision(InferenceEngine::details::convertPrecision(prc)); + addOriginalInputPrecision(InferenceEngine::details::convertPrecision(prc)); + } + + void getSupportedDescriptors() override { + if (getParentEdges().size() != 1) + OPENVINO_THROW("Incorrect number of input edges for layer " + getName()); + if (getChildEdges().empty()) + OPENVINO_THROW("Incorrect number of output edges for layer " + getName()); + } + + void initSupportedPrimitiveDescriptors() override { + if (!supportedPrimitiveDescriptors.empty()) + return; + + NodeConfig config; + config.inConfs.resize(1); + config.outConfs.resize(1); + + config.inConfs[0].inPlace(m_inplace & Edge::LOOK::LOOK_DOWN ? 0 : -1); + config.inConfs[0].constant(false); + config.outConfs[0].inPlace(m_inplace & Edge::LOOK::LOOK_UP ? 0 : -1); + config.outConfs[0].constant(false); + + auto layoutCreator = BlockedDescCreator::getCommonCreators().at(m_layout); + auto& originInputPrecisions = getOriginalInputPrecisions(); + config.inConfs[0].setMemDesc(layoutCreator->createSharedDesc(originInputPrecisions[0], getInputShapeAtPort(0))); + config.outConfs[0].setMemDesc(layoutCreator->createSharedDesc(originInputPrecisions[0], getOutputShapeAtPort(0))); + + supportedPrimitiveDescriptors.emplace_back(config, impl_desc_type::undef); + }; + + void setLayout(LayoutType layout) {m_layout = layout;} + void setInplaceDirection(Edge::LOOK look) {m_inplace = look;} + + bool isExecutable() const override {return false;} + void execute(dnnl::stream strm) override {}; + bool created() const override {return true;} + +private: + LayoutType m_layout = LayoutType::ncsp; + Edge::LOOK m_inplace = Edge::LOOK::LOOK_UP; +}; +} // namespace MergeTransposeReorderCPUTest + +using namespace MergeTransposeReorderCPUTest; + +/* + * MergeTransposeReorderIsOptimizedCPUTest to test the CPU plugin-in MergeTransposeReorder graph optimizer + * under the circumstance that the upstream node or downstream node is inPlaced thereby the inserted Reorder + * cannot be optimized. + */ +class MergeTransposeReorderIsOptimizedCPUTest : public ::testing::Test { +public: + void Validate() const { + CheckTransposeCount(0); + CheckReorderOptimized(std::string("_fake"), false); // the fused node is of name "reshape_abcd_acdb_fake" + } + + void SetUp() override { + CreateGraph(); + } + +protected: + /* graph typology + --------- + |Input | + --------- + | + ---------- + | Dummy | <*NOTE: fake node with laytout NCSP, and inplace from upstream*> + ---------- + | + |---------------| + | ---------- | + | |Transpose| | + | --------- | + | | | + | --------- | + | |Reorder | | <*NOTE: Reorder is inheristically inserted since Multiply is asking NSPC input.*> + | --------- | + |---------------| + | + ----------- + | Dummy | <*NOTE: fake node with laytout NSPC, and inplace from downstream*> + ----------- + | + --------- + |Output | + --------- + */ + void CreateGraph() { + // + Config conf; + conf.rtCacheCapacity = 100; + auto context = std::make_shared(conf, nullptr, nullptr, false); + const dnnl::engine cpuEngine = context->getEngine(); + + m_graph = std::unique_ptr(new Graph()); + + // ov::Model with only a transpose node + ov::ParameterVector params{std::make_shared(testPrec, ov::Shape(testShape))}; + auto order = std::vector{0, 3, 1, 2}; + auto constOrder = ngraph::builder::makeConstant(ngraph::element::i32, {order.size()}, order); + auto transpose = std::make_shared(params[0], constOrder); + ov::ResultVector results{std::make_shared(transpose)}; + + // Replicate + auto replicate = [&](std::vector &nodes, std::vector &edges) -> void { + std::unordered_set nodesSet; + + auto addEdge = [&](const NodePtr& parent, const NodePtr& child, size_t parentPort, size_t childPort) -> void { + auto edge = std::make_shared(parent, child, parentPort, childPort); + child->addEdge(edge); + edges.push_back(edge); + nodesSet.insert(parent); + nodesSet.insert(child); + }; + + auto inputNode = std::make_shared(params[0], context); + + // dummy ncsp + inPlace LOOK_UP + auto dummyNode1 = std::make_shared(testShape, testPrec, "reshape", "DummyNode", context); + dummyNode1->setLayout(LayoutType::ncsp); + dummyNode1->setInplaceDirection(Edge::LOOK::LOOK_UP); + + auto orderNode = std::make_shared(constOrder, context); // const order + auto transposeNode = std::make_shared(transpose, context); + transposeNode->filterSupportedPrimitiveDescriptors(); + + // dummy nspc + inPlace LOOK_DOWN + const ov::Shape shape_tranpose{testShape[0], testShape[3], testShape[1], testShape[2]}; // shape after transpose + auto dummyNode2 = std::make_shared(shape_tranpose, testPrec, "multiply", "DummyNode", context); + dummyNode2->setLayout(LayoutType::nspc); + dummyNode2->setInplaceDirection(Edge::LOOK::LOOK_DOWN); + + auto outputNode = std::make_shared(results[0], context); + + addEdge(inputNode, dummyNode1, 0, 0); + addEdge(dummyNode1, transposeNode, 0, 0); + addEdge(orderNode, transposeNode, 0, 1); + addEdge(transposeNode, dummyNode2, 0, 0); + addEdge(dummyNode2, outputNode, 0, 0); + + for (auto &node : nodesSet) nodes.emplace_back(node); + }; + + std::vector graphNodes; + std::vector graphEdges; + replicate(graphNodes, graphEdges); + + m_graph->CreateGraph(graphNodes, graphEdges, context, "fused_graph"); + } + + // helper to check if Transpose node is fused. + void CheckTransposeCount(const size_t expectedTransposeCount) const { + const std::vector& graph_nodes = m_graph->GetNodes(); + size_t actualTransposeCount = 0; + for (auto &node : graph_nodes) { + if (node->getType() == Type::Transpose) { + actualTransposeCount++; + } + } + + ASSERT_EQ(expectedTransposeCount, actualTransposeCount); + } + + // helper to check isOptimized of Reorder node with a part of its name + void CheckReorderOptimized(const std::string &patial_name, const bool expectedOptimized) const { + const std::vector& graph_nodes = m_graph->GetNodes(); + size_t actualCount = 0; + for (auto &node : graph_nodes) { + auto reorder_node = std::dynamic_pointer_cast(node); + if (reorder_node && node->getName().find(patial_name) != std::string::npos) { + ASSERT_EQ(expectedOptimized, reorder_node->getOptimized()); + actualCount++; + } + } + + ASSERT_EQ(1, actualCount); + } + +private: + const ov::element::Type_t testPrec = ov::element::Type_t::f32; + const ov::Shape testShape{1, 3, 8, 16}; + + std::unique_ptr m_graph; +}; // class MergeTransposeReorderIsOptimizedCPUTest + +TEST_F(MergeTransposeReorderIsOptimizedCPUTest, smoke_Run_MergeTransposeReorder_isOptimized) { + Validate(); +} \ No newline at end of file diff --git a/src/plugins/intel_cpu/thirdparty/onednn b/src/plugins/intel_cpu/thirdparty/onednn index 36c2060a0dc85b..ff9205a8b42238 160000 --- a/src/plugins/intel_cpu/thirdparty/onednn +++ b/src/plugins/intel_cpu/thirdparty/onednn @@ -1 +1 @@ -Subproject commit 36c2060a0dc85b4def72ea30823936c2ef861b82 +Subproject commit ff9205a8b42238e1fba992fad2429b722c4cfed0 diff --git a/src/plugins/intel_gpu/include/intel_gpu/plugin/sync_infer_request.hpp b/src/plugins/intel_gpu/include/intel_gpu/plugin/sync_infer_request.hpp index 3050846e2c2354..24109144496df6 100644 --- a/src/plugins/intel_gpu/include/intel_gpu/plugin/sync_infer_request.hpp +++ b/src/plugins/intel_gpu/include/intel_gpu/plugin/sync_infer_request.hpp @@ -25,8 +25,17 @@ enum class TensorOwner : uint8_t { }; struct TensorWrapper { + TensorWrapper(const std::shared_ptr& _ptr, TensorOwner _owner) + : ptr(_ptr) + , owner(_owner) + , actual_size(_ptr ? _ptr->get_byte_size() : 0) {} + + TensorWrapper(const TensorWrapper& other) = default; + TensorWrapper() = default; + std::shared_ptr ptr; TensorOwner owner; + size_t actual_size; }; class SyncInferRequest : public ov::ISyncInferRequest { diff --git a/src/plugins/intel_gpu/src/plugin/sync_infer_request.cpp b/src/plugins/intel_gpu/src/plugin/sync_infer_request.cpp index 9c097d222fdc1b..574d78e3a5332d 100644 --- a/src/plugins/intel_gpu/src/plugin/sync_infer_request.cpp +++ b/src/plugins/intel_gpu/src/plugin/sync_infer_request.cpp @@ -3,6 +3,8 @@ // #include "intel_gpu/plugin/usm_host_tensor.hpp" +#include "intel_gpu/runtime/memory.hpp" +#include "intel_gpu/runtime/memory_caps.hpp" #include "openvino/runtime/make_tensor.hpp" #include "openvino/core/preprocess/input_tensor_info.hpp" #include "openvino/core/parallel.hpp" @@ -415,11 +417,13 @@ void SyncInferRequest::wait() { OV_ITT_SCOPED_TASK(itt::domains::intel_gpu_plugin, "SyncInferRequest::wait"); OPENVINO_ASSERT(!m_internal_outputs.empty(), "[GPU] Inference was not started!\n"); + auto& network = *m_graph->get_network(); + // wait for completion & collect outputs as requested by the model // for in_order_queue, it is enough to call finish only once - bool do_sync_per_output = (m_graph->get_network()->get_stream().get_queue_type() == QueueTypes::in_order) ? false : true; + bool do_sync_per_output = (network.get_stream().get_queue_type() == QueueTypes::in_order) ? false : true; if (!do_sync_per_output) - m_graph->get_network()->get_stream().finish(); + network.get_stream().finish(); std::vector copy_events; @@ -442,6 +446,7 @@ void SyncInferRequest::wait() { auto output_tensor = output_tensor_wrapper.ptr; auto remote_ptr = std::dynamic_pointer_cast(output_tensor); bool is_remote = remote_ptr != nullptr; + bool is_dynamic = port.get_partial_shape().is_dynamic(); if (is_remote) { GPU_DEBUG_TRACE_DETAIL << name << " handle output tensor (remote): " << remote_ptr->get_original_memory()->buffer_ptr() << std::endl; @@ -449,6 +454,10 @@ void SyncInferRequest::wait() { GPU_DEBUG_TRACE_DETAIL << name << " handle output tensor (host): " << output_tensor->data() << std::endl; } + OPENVINO_ASSERT(output_tensor_wrapper.owner == TensorOwner::PLUGIN || output_tensor_wrapper.actual_size >= output_memory->size(), + "[GPU] Output tensor set by user has smaller size (", output_tensor->get_byte_size(), ") ", + "than required (", output_memory->size(), ")"); + bool need_output_update = output_layout.bytes_count() == 0 || (output_memory && output_tensor->get_byte_size() != output_memory->size()); if (need_output_update) { OV_ITT_SCOPED_TASK(itt::domains::intel_gpu_plugin, "SyncInferRequest::wait::update_output"); @@ -460,7 +469,7 @@ void SyncInferRequest::wait() { OPENVINO_ASSERT(ov::shape_size(port.get_shape()) == ov::shape_size(mem_shape), "[GPU] Unexpected elements count for output tensor"); mem_shape = port.get_shape(); } - if (port.get_partial_shape().is_dynamic()) { + if (is_dynamic) { bool need_reallocate = true; auto usm_host_tensor = std::dynamic_pointer_cast(output_tensor); if (usm_host_tensor && output_memory) @@ -488,11 +497,23 @@ void SyncInferRequest::wait() { copy_events.push_back(ev); } } + } else if (is_remote && is_dynamic) { + auto& stream = m_graph->get_network()->get_stream(); + auto user_mem = remote_ptr->get_original_memory(); + if (user_mem->get_allocation_type() == cldnn::allocation_type::cl_mem && output_memory->get_allocation_type() != cldnn::allocation_type::cl_mem) { + // WA: Copy between cl_mem and usm memory may fail for some reason (driver bug?) + // so this explicit memcpy is used to provide correct output for cl_mem output in dynamic cases + cldnn::mem_lock lock_dst(user_mem, stream); + cldnn::mem_lock lock_src(output_memory, stream); + std::memcpy(lock_dst.data(), lock_src.data(), output_memory->size()); + } else { + copy_events.push_back(output_memory->copy_to(stream, *user_mem, false)); + } } } if (!copy_events.empty()) { - auto& stream = m_graph->get_network()->get_stream(); + auto& stream = network.get_stream(); if (stream.get_queue_type() == QueueTypes::in_order) { // wait only the last one stream.wait_for_events({copy_events.back()}); @@ -831,7 +852,7 @@ std::vector SyncInferRequest::prepare_output(const std::strin auto device_tensor_et = convert_to_supported_device_type(element_type); bool convert_needed = is_convert_required(device_tensor_et, element_type); cldnn::primitive_id internal_name = m_output_names_map.at(name); - if (is_remote && !convert_needed) { + if (is_remote && !convert_needed && !is_dynamic) { m_plugin_outputs[name] = user_tensor_wrapper; } diff --git a/src/plugins/intel_gpu/tests/functional/remote_blob_tests/gpu_remote_tensor_tests.cpp b/src/plugins/intel_gpu/tests/functional/remote_blob_tests/gpu_remote_tensor_tests.cpp index f4b16858551ea4..6b98f98d44a228 100644 --- a/src/plugins/intel_gpu/tests/functional/remote_blob_tests/gpu_remote_tensor_tests.cpp +++ b/src/plugins/intel_gpu/tests/functional/remote_blob_tests/gpu_remote_tensor_tests.cpp @@ -7,21 +7,25 @@ #include #include -#include "common_test_utils/test_assertions.hpp" +#include "openvino/core/dimension.hpp" #include "openvino/core/except.hpp" +#include "openvino/core/model.hpp" +#include "openvino/core/preprocess/pre_post_process.hpp" #include "openvino/runtime/intel_gpu/ocl/ocl.hpp" #include "openvino/runtime/core.hpp" #include "openvino/runtime/intel_gpu/properties.hpp" +#include "openvino/runtime/properties.hpp" +#include "openvino/runtime/remote_tensor.hpp" -#include -#include -#include +#include "remote_blob_tests/remote_blob_helpers.hpp" +#include "common_test_utils/test_assertions.hpp" +#include "common_test_utils/ov_tensor_utils.hpp" +#include "common_test_utils/test_common.hpp" #include "base/ov_behavior_test_utils.hpp" #include "ov_models/subgraph_builders.hpp" #include "functional_test_utils/blob_utils.hpp" -#include "openvino/core/preprocess/pre_post_process.hpp" +#include "subgraphs_builders.hpp" #include "transformations/utils/utils.hpp" -#include "common_test_utils/ov_tensor_utils.hpp" using namespace ::testing; @@ -35,6 +39,7 @@ class OVRemoteTensor_Test : public ov::test::TestsCommon { }; namespace { +std::vector ov_dynamic {true, false}; std::vector ov_with_auto_batching {true, false}; enum class RemoteTensorSharingType { USER_CL_TENSOR = 0, @@ -61,7 +66,7 @@ std::ostream& operator<<(std::ostream& stream, RemoteTensorSharingType sharing_t } } // namespace -using RemoteTensorSharingTestOptionsParams = std::tuple; +using RemoteTensorSharingTestOptionsParams = std::tuple; class OVRemoteTensorInputBlob_Test : public OVRemoteTensor_Test, public testing::WithParamInterface { @@ -75,7 +80,8 @@ class OVRemoteTensorInputBlob_Test : public OVRemoteTensor_Test, deviceName = ov::test::utils::DEVICE_GPU; RemoteTensorSharingType sharing_type; bool with_auto_batching; - std::tie(sharing_type, with_auto_batching) = this->GetParam(); + bool is_dynamic; + std::tie(sharing_type, with_auto_batching, is_dynamic) = this->GetParam(); if (with_auto_batching) { config = {ov::hint::performance_mode(ov::hint::PerformanceMode::THROUGHPUT), @@ -84,17 +90,24 @@ class OVRemoteTensorInputBlob_Test : public OVRemoteTensor_Test, }; } fn_ptr = ov::test::behavior::getDefaultNGraphFunctionForTheDevice(); + if (is_dynamic) { + std::map target_shape = {{0, ov::PartialShape::dynamic(4)}}; + fn_ptr->reshape(target_shape); + } } static std::string getTestCaseName(const testing::TestParamInfo& obj) { RemoteTensorSharingType sharing_type; bool with_auto_batching; - std::tie(sharing_type, with_auto_batching) = obj.param; + bool is_dynamic; + std::tie(sharing_type, with_auto_batching, is_dynamic) = obj.param; std::ostringstream result; result << "OVRemoteTensorInputBlob_Test_"; result << sharing_type; if (with_auto_batching) result << "_WITH_AUTO_BATCHING"; + if (is_dynamic) + result << "_DYNAMIC"; return result.str(); } }; @@ -102,8 +115,9 @@ class OVRemoteTensorInputBlob_Test : public OVRemoteTensor_Test, TEST_P(OVRemoteTensorInputBlob_Test, smoke_cantCreateBlobWithInvalidSize) { RemoteTensorSharingType sharing_type; bool with_auto_batching; - std::tie(sharing_type, with_auto_batching) = GetParam(); - if (with_auto_batching) + bool is_dynamic; + std::tie(sharing_type, with_auto_batching, is_dynamic) = GetParam(); + if (with_auto_batching || is_dynamic) GTEST_SKIP(); if (sharing_type == RemoteTensorSharingType::PLUGIN_CL_TENSOR || @@ -164,7 +178,8 @@ TEST_P(OVRemoteTensorInputBlob_Test, smoke_canInputRemoteTensor) { auto function = p.build(); RemoteTensorSharingType sharing_type; bool with_auto_batching; - std::tie(sharing_type, with_auto_batching) = GetParam(); + bool is_dynamic; + std::tie(sharing_type, with_auto_batching, is_dynamic) = GetParam(); // auto-batching relies on availability of the lock() for the tensor (and the *USM_DEVICE is not lockable) if (with_auto_batching @@ -173,12 +188,13 @@ TEST_P(OVRemoteTensorInputBlob_Test, smoke_canInputRemoteTensor) { GTEST_SKIP(); auto exec_net = ie.compile_model(function, deviceName, config); + ov::Shape input_shape{1, 2, 32, 32}; // regular inference auto inf_req_regular = exec_net.create_infer_request(); auto input = function->get_parameters().at(0); auto output = function->get_results().at(0); - auto fakeImageData = ov::test::utils::create_and_fill_tensor(input->get_element_type(), input->get_shape()); + auto fakeImageData = ov::test::utils::create_and_fill_tensor(input->get_element_type(), input_shape); inf_req_regular.set_tensor(input, fakeImageData); @@ -192,7 +208,7 @@ TEST_P(OVRemoteTensorInputBlob_Test, smoke_canInputRemoteTensor) { auto ocl_instance = std::make_shared(ctx); cl_int err; - auto imSize = ov::shape_size(input->get_shape()); + auto imSize = ov::shape_size(input_shape); switch (sharing_type) { case RemoteTensorSharingType::USER_CL_TENSOR: { @@ -202,7 +218,7 @@ TEST_P(OVRemoteTensorInputBlob_Test, smoke_canInputRemoteTensor) { ocl_instance->_queue.enqueueWriteBuffer(shared_buffer, true, 0, imSize, buffer); } - auto cldnn_tensor = cldnn_context.create_tensor(input->get_element_type(), input->get_shape(), shared_buffer); + auto cldnn_tensor = cldnn_context.create_tensor(input->get_element_type(), input_shape, shared_buffer); inf_req_shared.set_tensor(input, cldnn_tensor); inf_req_shared.infer(); @@ -220,7 +236,7 @@ TEST_P(OVRemoteTensorInputBlob_Test, smoke_canInputRemoteTensor) { FAIL() << "Failed to copy data from host buffer to USM device"; } - auto cldnn_tensor = cldnn_context.create_tensor(input->get_element_type(), input->get_shape(), shared_buffer); + auto cldnn_tensor = cldnn_context.create_tensor(input->get_element_type(), input_shape, shared_buffer); inf_req_shared.set_tensor(input, cldnn_tensor); inf_req_shared.infer(); @@ -238,7 +254,7 @@ TEST_P(OVRemoteTensorInputBlob_Test, smoke_canInputRemoteTensor) { std::memcpy(shared_buffer, buffer, imSize); } - auto cldnn_tensor = cldnn_context.create_tensor(input->get_element_type(), input->get_shape(), shared_buffer); + auto cldnn_tensor = cldnn_context.create_tensor(input->get_element_type(), input_shape, shared_buffer); inf_req_shared.set_tensor(input, cldnn_tensor); inf_req_shared.infer(); @@ -247,7 +263,7 @@ TEST_P(OVRemoteTensorInputBlob_Test, smoke_canInputRemoteTensor) { break; } case RemoteTensorSharingType::PLUGIN_CL_TENSOR: { - auto cldnn_tensor = cldnn_context.create_tensor(input->get_element_type(), input->get_shape()); + auto cldnn_tensor = cldnn_context.create_tensor(input->get_element_type(), input_shape); ASSERT_TRUE(cldnn_tensor.is()); auto cl_tensor = cldnn_tensor.as(); { @@ -263,7 +279,7 @@ TEST_P(OVRemoteTensorInputBlob_Test, smoke_canInputRemoteTensor) { if (!ocl_instance->supports_usm()) GTEST_SKIP(); - auto cldnn_tensor = cldnn_context.create_usm_host_tensor(input->get_element_type(), input->get_shape()); + auto cldnn_tensor = cldnn_context.create_usm_host_tensor(input->get_element_type(), input_shape); ASSERT_TRUE(cldnn_tensor.is()); { auto cl_tensor = cldnn_tensor.as(); @@ -282,7 +298,7 @@ TEST_P(OVRemoteTensorInputBlob_Test, smoke_canInputRemoteTensor) { if (!ocl_instance->supports_usm()) GTEST_SKIP(); - auto cldnn_tensor = cldnn_context.create_usm_device_tensor(input->get_element_type(), input->get_shape()); + auto cldnn_tensor = cldnn_context.create_usm_device_tensor(input->get_element_type(), input_shape); ASSERT_TRUE(cldnn_tensor.is()); { auto cl_tensor = cldnn_tensor.as(); @@ -300,7 +316,7 @@ TEST_P(OVRemoteTensorInputBlob_Test, smoke_canInputRemoteTensor) { break; } case RemoteTensorSharingType::PLUGIN_HOST_TENSOR: { - auto cldnn_tensor = cldnn_context.create_host_tensor(input->get_element_type(), input->get_shape()); + auto cldnn_tensor = cldnn_context.create_host_tensor(input->get_element_type(), input_shape); { ASSERT_NO_THROW(cldnn_tensor.data()); void* shared_buffer = cldnn_tensor.data(); @@ -331,6 +347,277 @@ TEST_P(OVRemoteTensorInputBlob_Test, smoke_canInputRemoteTensor) { } } +TEST_P(OVRemoteTensorInputBlob_Test, smoke_canInputOutputRemoteTensor) { +#if defined(ANDROID) + GTEST_SKIP(); +#endif + auto ie = ov::Core(); + + using namespace ov::preprocess; + auto p = PrePostProcessor(fn_ptr); + p.input().tensor().set_element_type(ov::element::i8); + p.input().preprocess().convert_element_type(ov::element::f32); + + auto model = p.build(); + RemoteTensorSharingType sharing_type; + bool with_auto_batching; + bool is_dynamic; + std::tie(sharing_type, with_auto_batching, is_dynamic) = GetParam(); + + // auto-batching relies on availability of the lock() for the tensor (and the *USM_DEVICE is not lockable) + if (with_auto_batching) + GTEST_SKIP(); + + auto compiled_model = ie.compile_model(model, deviceName, config); + + ov::Shape input_shape{1, 2, 32, 32}; + ov::Shape output_shape{1, 2, 32, 32}; + // regular inference + auto inf_req_regular = compiled_model.create_infer_request(); + auto input = model->get_parameters().at(0); + auto output = model->get_results().at(0); + + auto input_data = ov::test::utils::create_and_fill_tensor(input->get_element_type(), input_shape); + + inf_req_regular.set_tensor(input, input_data); + + inf_req_regular.infer(); + auto output_tensor_regular = inf_req_regular.get_tensor(output); + + // inference using remote tensor + auto inf_req_shared = compiled_model.create_infer_request(); + auto gpu_context = compiled_model.get_context().as(); + cl_context ctx = gpu_context; + auto ocl_instance = std::make_shared(ctx); + cl_int err; + + auto allocated_out_shape = output_shape; + if (is_dynamic) { + // In dynamic case we allocate more than required to check that out tensor is reshaped correctly + allocated_out_shape[1]++; + } + + auto in_size = ov::shape_size(input_shape); + auto out_size = ov::shape_size(output_shape) * output->get_output_element_type(0).bitwidth() / 8; + auto allocated_out_size = ov::shape_size(allocated_out_shape) * output->get_output_element_type(0).bitwidth() / 8; + auto output_tensor_shared = ov::test::utils::create_and_fill_tensor(output->get_output_element_type(0), output_shape); + + switch (sharing_type) { + case RemoteTensorSharingType::USER_CL_TENSOR: { + cl::Buffer shared_input_buffer(ocl_instance->_context, CL_MEM_READ_WRITE, in_size, NULL, &err); + cl::Buffer shared_output_buffer(ocl_instance->_context, CL_MEM_READ_WRITE, allocated_out_size, NULL, &err); + { + void* buffer = input_data.data(); + ocl_instance->_queue.enqueueWriteBuffer(shared_input_buffer, true, 0, in_size, buffer); + } + + auto input_remote_tensor = gpu_context.create_tensor(input->get_element_type(), input_shape, shared_input_buffer); + auto output_remote_tensor = gpu_context.create_tensor(output->get_output_element_type(0), allocated_out_shape, shared_output_buffer); + inf_req_shared.set_tensor(input, input_remote_tensor); + inf_req_shared.set_tensor(output, output_remote_tensor); + inf_req_shared.infer(); + + { + void* buffer = output_tensor_shared.data(); + auto out_tensor = inf_req_shared.get_output_tensor(); + ASSERT_EQ(out_tensor.get_shape(), output_shape); + ocl_instance->_queue.enqueueReadBuffer(shared_output_buffer, true, 0, out_size, buffer); + } + + break; + } + case RemoteTensorSharingType::USER_USM_DEVICE_TENSOR: { + if (!ocl_instance->supports_usm()) + GTEST_SKIP(); + + void* shared_input_buffer = ocl_instance->allocate_usm_device_buffer(in_size); + void* shared_output_buffer = ocl_instance->allocate_usm_device_buffer(allocated_out_size); + { + void* buffer = input_data.data(); + err = ocl_instance->memcpy(ocl_instance->_queue, shared_input_buffer, buffer, in_size, true, nullptr, nullptr); + if (err != CL_SUCCESS) + FAIL() << "Failed to copy data from host buffer to USM device"; + } + + auto input_remote_tensor = gpu_context.create_tensor(input->get_element_type(), input_shape, shared_input_buffer); + auto output_remote_tensor = gpu_context.create_tensor(output->get_output_element_type(0), allocated_out_shape, shared_output_buffer); + inf_req_shared.set_tensor(input, input_remote_tensor); + inf_req_shared.set_tensor(output, output_remote_tensor); + inf_req_shared.infer(); + + { + void* buffer = output_tensor_shared.data(); + auto out_tensor = inf_req_shared.get_output_tensor(); + ASSERT_EQ(out_tensor.get_shape(), output_shape); + err = ocl_instance->memcpy(ocl_instance->_queue, buffer, shared_output_buffer, out_size, true, nullptr, nullptr); + if (err != CL_SUCCESS) + FAIL() << "Failed to copy data from USM device to host buffer"; + } + + + ocl_instance->free_mem(shared_input_buffer); + ocl_instance->free_mem(shared_output_buffer); + + break; + } + case RemoteTensorSharingType::USER_USM_HOST_TENSOR: { + if (!ocl_instance->supports_usm()) + GTEST_SKIP(); + + void* shared_input_buffer = ocl_instance->allocate_usm_host_buffer(in_size); + void* shared_output_buffer = ocl_instance->allocate_usm_host_buffer(allocated_out_size); + { + void* buffer = input_data.data(); + std::memcpy(shared_input_buffer, buffer, in_size); + } + + auto input_remote_tensor = gpu_context.create_tensor(input->get_element_type(), input_shape, shared_input_buffer); + auto output_remote_tensor = gpu_context.create_tensor(output->get_output_element_type(0), allocated_out_shape, shared_output_buffer); + inf_req_shared.set_tensor(input, input_remote_tensor); + inf_req_shared.set_tensor(output, output_remote_tensor); + inf_req_shared.infer(); + + { + void* buffer = output_tensor_shared.data(); + auto out_tensor = inf_req_shared.get_output_tensor(); + ASSERT_EQ(out_tensor.get_shape(), output_shape); + err = ocl_instance->memcpy(ocl_instance->_queue, buffer, shared_output_buffer, out_size, true, nullptr, nullptr); + if (err != CL_SUCCESS) + FAIL() << "Failed to copy data from USM host to host buffer"; + } + + ocl_instance->free_mem(shared_input_buffer); + ocl_instance->free_mem(shared_output_buffer); + + break; + } + case RemoteTensorSharingType::PLUGIN_CL_TENSOR: { + auto input_remote_tensor = gpu_context.create_tensor(input->get_element_type(), input_shape); + auto output_remote_tensor = gpu_context.create_tensor(output->get_output_element_type(0), allocated_out_shape); + ASSERT_TRUE(input_remote_tensor.is()); + auto cl_tensor = input_remote_tensor.as(); + { + cl::Buffer shared_buffer = cl_tensor; + void* buffer = input_data.data(); + ocl_instance->_queue.enqueueWriteBuffer(shared_buffer, true, 0, in_size, buffer); + } + inf_req_shared.set_tensor(input, input_remote_tensor); + inf_req_shared.set_tensor(output, output_remote_tensor); + inf_req_shared.infer(); + + { + auto out_cl_tensor = output_remote_tensor.as(); + + void* buffer = output_tensor_shared.data(); + auto out_tensor = inf_req_shared.get_output_tensor(); + ASSERT_EQ(out_tensor.get_shape(), output_shape); + ocl_instance->_queue.enqueueReadBuffer(out_cl_tensor, true, 0, out_size, buffer); + } + + break; + } + case RemoteTensorSharingType::PLUGIN_USM_HOST_TENSOR: { + if (!ocl_instance->supports_usm()) + GTEST_SKIP(); + + auto input_remote_tensor = gpu_context.create_usm_host_tensor(input->get_element_type(), input_shape); + auto output_remote_tensor = gpu_context.create_usm_host_tensor(output->get_output_element_type(0), allocated_out_shape); + ASSERT_TRUE(input_remote_tensor.is()); + { + auto cl_tensor = input_remote_tensor.as(); + void* shared_buffer = cl_tensor.get(); + ASSERT_EQ(ocl_instance->get_allocation_type(shared_buffer), CL_MEM_TYPE_HOST_INTEL); + void* buffer = input_data.data(); + std::memcpy(shared_buffer, buffer, in_size); + } + + inf_req_shared.set_tensor(input, input_remote_tensor); + inf_req_shared.set_tensor(output, output_remote_tensor); + inf_req_shared.infer(); + + { + void* buffer = output_tensor_shared.data(); + auto out_tensor = inf_req_shared.get_output_tensor(); + auto cl_tensor = out_tensor.as(); + void* shared_output_buffer = cl_tensor.get(); + ASSERT_EQ(ocl_instance->get_allocation_type(shared_output_buffer), CL_MEM_TYPE_HOST_INTEL); + ASSERT_EQ(out_tensor.get_shape(), output_shape); + std::memcpy(buffer, shared_output_buffer, out_size); + } + + break; + } + case RemoteTensorSharingType::PLUGIN_USM_DEVICE_TENSOR: { + if (!ocl_instance->supports_usm()) + GTEST_SKIP(); + + auto input_remote_tensor = gpu_context.create_usm_device_tensor(input->get_element_type(), input_shape); + auto output_remote_tensor = gpu_context.create_usm_device_tensor(output->get_output_element_type(0), allocated_out_shape); + ASSERT_TRUE(input_remote_tensor.is()); + { + auto cl_tensor = input_remote_tensor.as(); + void* shared_buffer = cl_tensor.get(); + ASSERT_EQ(ocl_instance->get_allocation_type(shared_buffer), CL_MEM_TYPE_DEVICE_INTEL); + void* buffer = input_data.data(); + err = ocl_instance->memcpy(ocl_instance->_queue, shared_buffer, buffer, in_size, true, nullptr, nullptr); + if (err != CL_SUCCESS) + FAIL() << "Failed to copy data from host buffer to USM device"; + } + + inf_req_shared.set_tensor(input, input_remote_tensor); + inf_req_shared.set_tensor(output, output_remote_tensor); + inf_req_shared.infer(); + + { + auto cl_tensor = output_remote_tensor.as(); + void* shared_output_buffer = cl_tensor.get(); + + void* buffer = output_tensor_shared.data(); + auto out_tensor = inf_req_shared.get_output_tensor(); + ASSERT_EQ(out_tensor.get_shape(), output_shape); + err = ocl_instance->memcpy(ocl_instance->_queue, buffer, shared_output_buffer, out_size, true, nullptr, nullptr); + } + + break; + } + case RemoteTensorSharingType::PLUGIN_HOST_TENSOR: { + auto input_tensor = gpu_context.create_host_tensor(input->get_element_type(), input_shape); + auto output_tensor = gpu_context.create_host_tensor(output->get_output_element_type(0), allocated_out_shape); + { + ASSERT_NO_THROW(input_tensor.data()); + void* shared_buffer = input_tensor.data(); + if (ocl_instance->supports_usm()) { + ASSERT_EQ(ocl_instance->get_allocation_type(shared_buffer), CL_MEM_TYPE_HOST_INTEL); + } + void* buffer = input_data.data(); + std::memcpy(shared_buffer, buffer, in_size); + } + + inf_req_shared.set_tensor(input, input_tensor); + inf_req_shared.set_tensor(output, output_tensor); + inf_req_shared.infer(); + + { + void* buffer = output_tensor_shared.data(); + auto out_tensor = inf_req_shared.get_output_tensor(); + ASSERT_EQ(out_tensor.get_shape(), output_shape); + err = ocl_instance->memcpy(ocl_instance->_queue, buffer, output_tensor.data(), out_size, true, nullptr, nullptr); + } + break; + } + } + + // compare results + { + ASSERT_EQ(output->get_element_type(), ov::element::f32); + ASSERT_EQ(output_tensor_regular.get_size(), output_tensor_shared.get_size()); + auto thr = FuncTestUtils::GetComparisonThreshold(InferenceEngine::Precision::FP32); + ASSERT_NO_THROW(output_tensor_regular.data()); + ASSERT_NO_THROW(output_tensor_shared.data()); + ov::test::utils::compare(output_tensor_regular, output_tensor_shared, thr); + } +} + INSTANTIATE_TEST_SUITE_P( smoke_GPU, OVRemoteTensorInputBlob_Test, @@ -342,9 +629,125 @@ INSTANTIATE_TEST_SUITE_P( RemoteTensorSharingType::PLUGIN_USM_HOST_TENSOR, RemoteTensorSharingType::PLUGIN_USM_DEVICE_TENSOR, RemoteTensorSharingType::PLUGIN_HOST_TENSOR}), - ::testing::ValuesIn(ov_with_auto_batching)), + ::testing::ValuesIn(ov_with_auto_batching), + ::testing::ValuesIn(ov_dynamic)), OVRemoteTensorInputBlob_Test::getTestCaseName); +TEST(OVRemoteTensorTests, smoke_MixedTensorTypes) { +#if defined(ANDROID) + GTEST_SKIP(); +#endif + auto core = ov::Core(); + auto model = ov::test::behavior::getDefaultNGraphFunctionForTheDevice(); + std::map dynamic_shape = {{0, ov::PartialShape::dynamic(4)}}; + model->reshape(dynamic_shape); + + auto dynamic_compiled_model = core.compile_model(model, ov::test::utils::DEVICE_GPU); + + auto input = model->get_parameters().at(0); + auto output = model->get_results().at(0); + + auto gpu_context = dynamic_compiled_model.get_context().as(); + cl_context ctx = gpu_context; + auto ocl_instance = std::make_shared(ctx); + + ov::Shape output_shape_allocated{1, 3, 32, 32}; + auto user_output_tensor = gpu_context.create_tensor(output->get_element_type(), output_shape_allocated); + ov::Tensor output_tensor_copy_0(output->get_element_type(), output_shape_allocated); + ov::Tensor output_tensor_copy_1(output->get_element_type(), output_shape_allocated); + + { + auto infer_request = dynamic_compiled_model.create_infer_request(); + { + // Run infer request with user's input & output tensor + // Output tensor size is larger than required + ov::Shape input_shape{1, 2, 32, 32}; + auto input_tensor = gpu_context.create_tensor(input->get_element_type(), input_shape); + ov::Shape output_shape_actual{1, 2, 32, 32}; + + infer_request.set_tensor(input, input_tensor); + infer_request.set_tensor(output, user_output_tensor); + infer_request.infer(); + auto output_tensor = infer_request.get_tensor(output); + + ASSERT_TRUE(output_tensor.is()); + ASSERT_TRUE(user_output_tensor.is()); + auto t1 = output_tensor.as(); + auto t2 = user_output_tensor.as(); + + ASSERT_EQ(t1.get(), t2.get()); + ASSERT_EQ(output_tensor.get_shape(), output_shape_actual); + } + + { + // Keep same output, but use larger input + // In that case user tensor is not enough to store the result and the plugin throws exception + ov::Shape input_shape{1, 4, 32, 32}; + auto input_tensor = gpu_context.create_tensor(input->get_element_type(), input_shape); + + infer_request.set_tensor(input, input_tensor); + OV_EXPECT_THROW(infer_request.infer(), ov::Exception, HasSubstr("Output tensor set by user has smaller size")); + } + + { + // Now try to increase buffer size comparing to the 1st run + // User output buffer is supposed to be the same + ov::Shape input_shape{1, 3, 32, 32}; + ov::Shape output_shape_actual{1, 3, 32, 32}; + auto input_tensor_1 = gpu_context.create_tensor(input->get_element_type(), input_shape); + auto data = ov::test::utils::create_and_fill_tensor(input->get_element_type(), input_shape); + ASSERT_TRUE(input_tensor_1.is()); + auto cl_tensor = input_tensor_1.as(); + cl::Buffer shared_buffer = cl_tensor; + void* buffer = data.data(); + ocl_instance->_queue.enqueueWriteBuffer(shared_buffer, true, 0, ov::shape_size(input_shape), buffer); + + infer_request.set_tensor(input, input_tensor_1); + infer_request.infer(); + auto output_tensor = infer_request.get_tensor(output); + ASSERT_TRUE(output_tensor.is()); + ASSERT_TRUE(user_output_tensor.is()); + auto t1 = output_tensor.as(); + auto t2 = user_output_tensor.as(); + + // inference result of this iteration is stored to output_tensor_copy_0 for further values check + ocl_instance->_queue.enqueueReadBuffer(t2, true, 0, user_output_tensor.get_byte_size(), output_tensor_copy_0.data()); + ASSERT_EQ(t1.get(), t2.get()); + ASSERT_EQ(output_tensor.get_shape(), output_shape_actual); + } + } + + { + auto infer_request = dynamic_compiled_model.create_infer_request(); + ov::Shape input_shape_0{1, 2, 32, 32}; + ov::Shape output_shape_actual_0{1, 2, 32, 32}; + auto input_tensor_0 = gpu_context.create_tensor(input->get_element_type(), input_shape_0); + auto data = ov::test::utils::create_and_fill_tensor(input->get_element_type(), input_shape_0); + ASSERT_TRUE(input_tensor_0.is()); + auto cl_tensor = input_tensor_0.as(); + cl::Buffer shared_buffer = cl_tensor; + void* buffer = data.data(); + ocl_instance->_queue.enqueueWriteBuffer(shared_buffer, true, 0, ov::shape_size(input_shape_0), buffer); + + infer_request.set_tensor(input, input_tensor_0); + infer_request.infer(); + + auto output_tensor = infer_request.get_tensor(output); + + ASSERT_FALSE(output_tensor.is()); + ASSERT_EQ(output_tensor.get_shape(), output_shape_actual_0); + } + + // Finally, check that last result stored in user output tensor is not corrupted when we run after one more iteration with another output buffer + ASSERT_TRUE(user_output_tensor.is()); + auto t2 = user_output_tensor.as(); + ocl_instance->_queue.enqueueReadBuffer(t2, true, 0, user_output_tensor.get_byte_size(), output_tensor_copy_1.data()); + + for (size_t i = 0; i < output_tensor_copy_0.get_size(); i++) { + ASSERT_EQ(output_tensor_copy_0.data()[i], output_tensor_copy_1.data()[i]) << " i = " << i; + } +} + class OVRemoteTensor_TestsWithContext : public OVRemoteTensor_Test, public testing::WithParamInterface { protected: std::shared_ptr fn_ptr; diff --git a/src/plugins/intel_gpu/tests/functional/shared_tests_instances/single_layer_tests/random_uniform.cpp b/src/plugins/intel_gpu/tests/functional/shared_tests_instances/single_layer_tests/random_uniform.cpp index cd3937f9681a21..eb95642e301023 100644 --- a/src/plugins/intel_gpu/tests/functional/shared_tests_instances/single_layer_tests/random_uniform.cpp +++ b/src/plugins/intel_gpu/tests/functional/shared_tests_instances/single_layer_tests/random_uniform.cpp @@ -2,19 +2,17 @@ // SPDX-License-Identifier: Apache-2.0 // -#include -#include #include "common_test_utils/test_constants.hpp" -#include "single_layer_tests/random_uniform.hpp" +#include "single_op_tests/random_uniform.hpp" -using namespace LayerTestsDefinitions; +using ov::test::RandomUniformLayerTest; namespace { -const std::vector random_uniform_type_specific_params = { - {InferenceEngine::Precision::I32, -100, 100}, - {InferenceEngine::Precision::FP32, 0.0f, 1.0f}, - {InferenceEngine::Precision::FP16, -10.0, 10.0} +const std::vector random_uniform_type_specific_params = { + {ov::element::i32, -100, 100}, + {ov::element::f32, 0.0f, 1.0f}, + {ov::element::f16, -10.0, 10.0} }; diff --git a/src/plugins/intel_gpu/tests/functional/shared_tests_instances/single_layer_tests/range.cpp b/src/plugins/intel_gpu/tests/functional/shared_tests_instances/single_layer_tests/range.cpp index d648cb18fa649c..12eab5a0039f06 100644 --- a/src/plugins/intel_gpu/tests/functional/shared_tests_instances/single_layer_tests/range.cpp +++ b/src/plugins/intel_gpu/tests/functional/shared_tests_instances/single_layer_tests/range.cpp @@ -2,34 +2,30 @@ // SPDX-License-Identifier: Apache-2.0 // -#include +#include -#include -#include +#include "single_op_tests/range.hpp" +#include "common_test_utils/test_constants.hpp" +using ov::test::RangeLayerTest; namespace { -const std::initializer_list start { 1.0, 1.2 }; -const std::initializer_list stop { 5.0, 5.2 }; -const std::initializer_list step { 1.0, 0.1 }; +const std::vector start = { 1.0f, 1.2f }; +const std::vector stop = { 5.0f, 5.2f }; +const std::vector step = { 1.0f, 0.1f }; -const std::initializer_list netPrecisions { - InferenceEngine::Precision::FP32, - InferenceEngine::Precision::FP16 +const std::vector model_types = { + ov::element::f32, + ov::element::f16 }; -using LayerTestsDefinitions::RangeLayerTest; INSTANTIATE_TEST_SUITE_P(smoke_Basic, RangeLayerTest, ::testing::Combine( ::testing::ValuesIn(start), ::testing::ValuesIn(stop), ::testing::ValuesIn(step), - ::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(model_types), ::testing::Values(ov::test::utils::DEVICE_GPU)), RangeLayerTest::getTestCaseName); } // namespace diff --git a/src/plugins/intel_gpu/tests/functional/shared_tests_instances/skip_tests_config.cpp b/src/plugins/intel_gpu/tests/functional/shared_tests_instances/skip_tests_config.cpp index 23699ee8aa75e9..70e397e665b886 100644 --- a/src/plugins/intel_gpu/tests/functional/shared_tests_instances/skip_tests_config.cpp +++ b/src/plugins/intel_gpu/tests/functional/shared_tests_instances/skip_tests_config.cpp @@ -56,8 +56,6 @@ std::vector disabledTestPatterns() { R"(smoke_PrePostProcess.*resize_dynamic.*)", // Dynamic batch allocates output using upper bound R"(.*smoke_BehaviorTests.*InferUpperBoundNetworkWithGetTensor.*)", - // need dynamic shapes - R"(.*RangeLayerTest.*)", // need dynamic rank R"(.*smoke.*BehaviorTests.*InferFullyDynamicNetworkWith(S|G)etTensor.*)", R"(.*smoke.*BehaviorTests.*DynamicOutputToDynamicInput.*)", @@ -119,5 +117,7 @@ std::vector disabledTestPatterns() { R"(.*GroupNormalizationTest.*CompareWithRefs.*NetType=f16.*)", // Issue: 123507 R"(.*ReverseLayerTest.*mask.*f16.*)", + // Issue: 123516 + R"(.*RandomUniformLayerTest.*f16.*)", }; } diff --git a/src/tests/functional/plugin/shared/include/single_op_tests/random_uniform.hpp b/src/tests/functional/plugin/shared/include/single_op_tests/random_uniform.hpp new file mode 100644 index 00000000000000..8c396788ff0ccf --- /dev/null +++ b/src/tests/functional/plugin/shared/include/single_op_tests/random_uniform.hpp @@ -0,0 +1,16 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include "shared_test_classes/single_op/random_uniform.hpp" + +namespace ov { +namespace test { +TEST_P(RandomUniformLayerTest, Inference) { + run(); +} +} // namespace test +} // namespace ov + diff --git a/src/tests/functional/plugin/shared/include/single_op_tests/range.hpp b/src/tests/functional/plugin/shared/include/single_op_tests/range.hpp new file mode 100644 index 00000000000000..bd919c46790a13 --- /dev/null +++ b/src/tests/functional/plugin/shared/include/single_op_tests/range.hpp @@ -0,0 +1,15 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include "shared_test_classes/single_op/range.hpp" + +namespace ov { +namespace test { +TEST_P(RangeLayerTest, Inference) { + run(); +} +} // namespace test +} // namespace ov diff --git a/src/tests/functional/plugin/shared/include/single_op_tests/rdft.hpp b/src/tests/functional/plugin/shared/include/single_op_tests/rdft.hpp new file mode 100644 index 00000000000000..e40bc93700d6ba --- /dev/null +++ b/src/tests/functional/plugin/shared/include/single_op_tests/rdft.hpp @@ -0,0 +1,15 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include "shared_test_classes/single_op/rdft.hpp" + +namespace ov { +namespace test { +TEST_P(RDFTLayerTest, Inference) { + run(); +} +} // namespace test +} // namespace ov diff --git a/src/tests/functional/plugin/shared/include/single_op_tests/reduce_ops.hpp b/src/tests/functional/plugin/shared/include/single_op_tests/reduce_ops.hpp new file mode 100644 index 00000000000000..df8cee8dc950d4 --- /dev/null +++ b/src/tests/functional/plugin/shared/include/single_op_tests/reduce_ops.hpp @@ -0,0 +1,19 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include "shared_test_classes/single_op/reduce_ops.hpp" + +namespace ov { +namespace test { +TEST_P(ReduceOpsLayerTest, Inference) { + run(); +} + +TEST_P(ReduceOpsLayerWithSpecificInputTest, 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 344f0e57daf5d0..6d23a1f615d95f 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 @@ -219,6 +219,24 @@ TEST_P(OVInferRequestIOTensorTest, InferStaticNetworkSetChangedOutputTensorThrow ASSERT_ANY_THROW(req.infer()); } +TEST_P(OVInferRequestIOTensorTest, CheckInferIsNotChangeInput) { + ov::Tensor input_tensor = utils::create_and_fill_tensor(input.get_element_type(), input.get_shape()); + OV_ASSERT_NO_THROW(req.set_tensor(input, input_tensor)); + OV_ASSERT_NO_THROW(req.get_tensor(input)); + + OV_ASSERT_NO_THROW(req.infer()); + + ov::Tensor input_after_infer; + OV_ASSERT_NO_THROW(input_after_infer = req.get_tensor(input)); + ov::test::utils::compare(input_tensor, input_after_infer); + + OV_ASSERT_NO_THROW(req.infer()); + + ov::Tensor input_after_several_infer; + OV_ASSERT_NO_THROW(input_after_several_infer = req.get_tensor(input)); + ov::test::utils::compare(input_tensor, input_after_several_infer); +} + std::string OVInferRequestIOTensorSetPrecisionTest::getTestCaseName(const testing::TestParamInfo& obj) { element::Type type; std::string target_device; diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/base/utils/ranges.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/base/utils/ranges.hpp index 339c2a98845d54..e134bd7f018fd9 100644 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/base/utils/ranges.hpp +++ b/src/tests/functional/shared_test_classes/include/shared_test_classes/base/utils/ranges.hpp @@ -117,7 +117,7 @@ static std::map>> i { ov::op::v1::FloorMod::get_type_info_static(), {{{2, 4}}, {{2, 2, 128}}} }, { ov::op::v1::Mod::get_type_info_static(), {{{2, 4}}, {{2, 2, 128}}} }, { ov::op::v1::ReduceMax::get_type_info_static(), {{{0, 5}}, {{-5, 5, 1000}}} }, - { ov::op::v1::ReduceMean::get_type_info_static(), {{{0, 5}}, {{0, 5, 1000}}} }, + { ov::op::v1::ReduceMean::get_type_info_static(), {{{0, 5, 1000}}, {{0, 5, 1000}}} }, { ov::op::v1::ReduceMin::get_type_info_static(), {{{0, 5}}, {{0, 5, 1000}}} }, { ov::op::v1::ReduceProd::get_type_info_static(), {{{0, 5}}, {{0, 5, 1000}}} }, { ov::op::v1::ReduceSum::get_type_info_static(), {{{0, 5}}, {{0, 5, 1000}}} }, diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_op/random_uniform.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_op/random_uniform.hpp new file mode 100644 index 00000000000000..d3ce9a087170c8 --- /dev/null +++ b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_op/random_uniform.hpp @@ -0,0 +1,40 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include +#include +#include +#include + +#include "shared_test_classes/base/ov_subgraph.hpp" + +namespace ov { +namespace test { +struct RandomUniformTypeSpecificParams { + ov::element::Type model_type; // Model type + double min_value; // Min value constant, will be cast to the needed precision + double max_value; // Max value constant, will be cast to the needed precision +}; + +using RandomUniformParamsTuple = typename std::tuple< + ov::Shape, // Input shape + RandomUniformTypeSpecificParams, // Parameters which depends on output type + int64_t, // Global seed + int64_t, // Operation seed + ov::test::TargetDevice // Device name +>; + +class RandomUniformLayerTest : public testing::WithParamInterface, + virtual public ov::test::SubgraphBaseStaticTest { +public: + static std::string getTestCaseName(const testing::TestParamInfo &obj); + +protected: + void SetUp() override; +}; +} // namespace test +} // namespace ov + diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_op/range.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_op/range.hpp new file mode 100644 index 00000000000000..acfd8fbc6496bc --- /dev/null +++ b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_op/range.hpp @@ -0,0 +1,33 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include +#include +#include +#include + +#include "shared_test_classes/base/ov_subgraph.hpp" + +namespace ov { +namespace test { +using RangeParams = std::tuple< + float, // Start + float, // Stop + float, // Step + ov::element::Type, // Model type + ov::test::TargetDevice // Device name +>; + +class RangeLayerTest : public testing::WithParamInterface, + virtual public ov::test::SubgraphBaseStaticTest { +public: + static std::string getTestCaseName(const testing::TestParamInfo& obj); + +protected: + void SetUp() override; +}; +} // namespace test +} // namespace ov diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_op/rdft.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_op/rdft.hpp new file mode 100644 index 00000000000000..83675c0e0fb0a4 --- /dev/null +++ b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_op/rdft.hpp @@ -0,0 +1,33 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include +#include + +#include "shared_test_classes/base/ov_subgraph.hpp" +#include "common_test_utils/test_enums.hpp" + +namespace ov { +namespace test { +using RDFTParams = std::tuple< + std::vector, // Input shape + ov::element::Type, // Model type + std::vector, // Axes + std::vector, // Signal size + ov::test::utils::DFTOpType, + ov::test::TargetDevice // Device name +>; + +class RDFTLayerTest : public testing::WithParamInterface, + virtual public ov::test::SubgraphBaseStaticTest { +public: + static std::string getTestCaseName(const testing::TestParamInfo& obj); + +protected: + void SetUp() override; +}; +} // namespace test +} // namespace ov diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_op/reduce_ops.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_op/reduce_ops.hpp new file mode 100644 index 00000000000000..10d82a526b7296 --- /dev/null +++ b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_op/reduce_ops.hpp @@ -0,0 +1,41 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include +#include +#include +#include + +#include "shared_test_classes/base/ov_subgraph.hpp" +#include "common_test_utils/test_enums.hpp" + +namespace ov { +namespace test { +using reduceOpsParams = std::tuple< + std::vector, // Axis to reduce order + ov::test::utils::OpType, // Scalar or vector type axis + bool, // Keep dims + ov::test::utils::ReductionType, // Reduce operation type + ov::element::Type, // Model type + std::vector, // Input shape + ov::test::TargetDevice // Device name +>; + +class ReduceOpsLayerTest : public testing::WithParamInterface, + virtual public ov::test::SubgraphBaseStaticTest { +public: + static std::string getTestCaseName(const testing::TestParamInfo& obj); + +protected: + void SetUp() override; +}; + +class ReduceOpsLayerWithSpecificInputTest : public ReduceOpsLayerTest { +protected: + void generate_inputs(const std::vector& targetInputStaticShapes) override; +}; +} // namespace test +} // namespace ov diff --git a/src/tests/functional/shared_test_classes/src/single_op/random_uniform.cpp b/src/tests/functional/shared_test_classes/src/single_op/random_uniform.cpp new file mode 100644 index 00000000000000..e5abec2a7d0ff7 --- /dev/null +++ b/src/tests/functional/shared_test_classes/src/single_op/random_uniform.cpp @@ -0,0 +1,78 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "shared_test_classes/single_op/random_uniform.hpp" +#include "openvino/core/type/element_type_traits.hpp" + + +namespace ov { +namespace test { +std::string RandomUniformLayerTest::getTestCaseName(const testing::TestParamInfo &obj) { + RandomUniformTypeSpecificParams random_uniform_params; + ov::Shape input_shape; + int64_t global_seed; + int64_t op_seed; + std::string target_device; + std::tie(input_shape, random_uniform_params, global_seed, op_seed, target_device) = obj.param; + + std::ostringstream result; + result << "IS=" << ov::test::utils::vec2str(input_shape) << "_"; + result << "global_seed=" << global_seed << "_"; + result << "op_seed=" << op_seed << "_"; + result << "min_val=" << random_uniform_params.min_value << "_"; + result << "max_val=" << random_uniform_params.max_value << "_"; + result << "modelType=" << random_uniform_params.model_type.to_string() << "_"; + result << "trgDev=" << target_device; + return result.str(); +} + +void RandomUniformLayerTest::SetUp() { + RandomUniformTypeSpecificParams random_uniform_params; + ov::Shape input_shape; + int64_t global_seed; + int64_t op_seed; + std::tie(input_shape, random_uniform_params, global_seed, op_seed, targetDevice) = this->GetParam(); + auto model_type = random_uniform_params.model_type; + + // Use Parameter as input with desired model_type to properly configure execution configuration + // in CoreConfiguration() function + auto input = std::make_shared(model_type, input_shape); + auto shape_of = std::make_shared(input); + + std::shared_ptr min_value, max_value; + if (model_type == ov::element::f32) { + auto min_val = static_cast>(random_uniform_params.min_value); + auto max_val = static_cast>(random_uniform_params.max_value); + min_value = std::make_shared(model_type, ov::Shape{1}, + std::vector>{min_val}); + max_value = std::make_shared(model_type, ov::Shape{1}, + std::vector>{max_val}); + } else if (model_type == ov::element::f16) { + auto min_val = static_cast>(random_uniform_params.min_value); + auto max_val = static_cast>(random_uniform_params.max_value); + min_value = std::make_shared(model_type, ov::Shape{1}, + std::vector>{min_val}); + max_value = std::make_shared(model_type, ov::Shape{1}, + std::vector>{max_val}); + } else if (model_type == ov::element::i32) { + auto min_val = static_cast>(random_uniform_params.min_value); + auto max_val = static_cast>(random_uniform_params.max_value); + min_value = std::make_shared(model_type, ov::Shape{1}, + std::vector>{min_val}); + max_value = std::make_shared(model_type, ov::Shape{1}, + std::vector>{max_val}); + } else { + GTEST_FAIL() << model_type << " type isn't supported by the test"; + } + auto random_uniform = std::make_shared(shape_of, + min_value, + max_value, + model_type, + global_seed, + op_seed); + + function = std::make_shared(random_uniform->outputs(), ov::ParameterVector{input}, "random_uniform"); +} +} // namespace test +} // namespace ov diff --git a/src/tests/functional/shared_test_classes/src/single_op/range.cpp b/src/tests/functional/shared_test_classes/src/single_op/range.cpp new file mode 100644 index 00000000000000..5bb4917e3ec636 --- /dev/null +++ b/src/tests/functional/shared_test_classes/src/single_op/range.cpp @@ -0,0 +1,41 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "shared_test_classes/single_op/range.hpp" + + +namespace ov { +namespace test { +std::string RangeLayerTest::getTestCaseName(const testing::TestParamInfo& obj) { + ov::element::Type model_type; + float start, stop, step; + std::string target_device; + std::tie(start, stop, step, model_type, target_device) = obj.param; + + std::ostringstream result; + const char separator = '_'; + result << "Start=" << start << separator; + result << "Stop=" << stop << separator; + result << "Step=" << step << separator; + result << "modelType=" << model_type.to_string() << separator; + result << "trgDev=" << target_device; + return result.str(); +} + +void RangeLayerTest::SetUp() { + ov::element::Type model_type; + float start, stop, step; + tie(start, stop, step, model_type, targetDevice) = GetParam(); + + ov::ParameterVector params{std::make_shared(model_type, ov::Shape()), + std::make_shared(model_type, ov::Shape()), + std::make_shared(model_type, ov::Shape())}; + params[0]->set_friendly_name("start"); + params[1]->set_friendly_name("stop"); + params[2]->set_friendly_name("step"); + auto range = std::make_shared(params[0], params[1], params[2], model_type); + function = std::make_shared(range->outputs(), params, "Range"); +} +} // namespace test +} // namespace ov diff --git a/src/tests/functional/shared_test_classes/src/single_op/rdft.cpp b/src/tests/functional/shared_test_classes/src/single_op/rdft.cpp new file mode 100644 index 00000000000000..d54b9961613e7d --- /dev/null +++ b/src/tests/functional/shared_test_classes/src/single_op/rdft.cpp @@ -0,0 +1,42 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "shared_test_classes/single_op/rdft.hpp" +#include "ov_models/builders.hpp" + +namespace ov { +namespace test { +std::string RDFTLayerTest::getTestCaseName(const testing::TestParamInfo& obj) { + std::vector input_shape; + ov::element::Type model_type; + std::vector axes; + std::vector signal_size; + ov::test::utils::DFTOpType op_type; + std::string target_device; + std::tie(input_shape, model_type, axes, signal_size, op_type, target_device) = obj.param; + + std::ostringstream result; + result << "IS=" << ov::test::utils::vec2str(input_shape) << "_"; + result << "modelType=" << model_type.to_string() << "_"; + result << "Axes=" << ov::test::utils::vec2str(axes) << "_"; + result << "SignalSize=" << ov::test::utils::vec2str(signal_size) << "_"; + result << "Inverse=" << (op_type == ov::test::utils::DFTOpType::INVERSE) << "_"; + result << "trgDev=" << target_device; + return result.str(); +} + +void RDFTLayerTest::SetUp() { + std::vector input_shape; + ov::element::Type model_type; + std::vector axes; + std::vector signal_size; + ov::test::utils::DFTOpType op_type; + std::tie(input_shape, model_type, axes, signal_size, op_type, targetDevice) = this->GetParam(); + + auto param = std::make_shared(model_type, ov::Shape(input_shape)); + auto rdft = ngraph::builder::makeRDFT(param, axes, signal_size, op_type); + function = std::make_shared(rdft->outputs(), ov::ParameterVector{param}, "RDFT"); +} +} // namespace test +} // namespace ov \ No newline at end of file diff --git a/src/tests/functional/shared_test_classes/src/single_op/reduce_ops.cpp b/src/tests/functional/shared_test_classes/src/single_op/reduce_ops.cpp new file mode 100644 index 00000000000000..af23a65322fb5a --- /dev/null +++ b/src/tests/functional/shared_test_classes/src/single_op/reduce_ops.cpp @@ -0,0 +1,79 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "shared_test_classes/single_op/reduce_ops.hpp" +#include "common_test_utils/data_utils.hpp" +#include "ov_models/builders.hpp" + +namespace ov { +namespace test { +std::string ReduceOpsLayerTest::getTestCaseName(const testing::TestParamInfo& obj) { + std::vector input_shape; + ov::element::Type model_type; + bool keep_dims; + ov::test::utils::ReductionType reduction_type; + std::vector axes; + ov::test::utils::OpType op_type; + std::string target_device; + std::tie(axes, op_type, keep_dims, reduction_type, model_type, input_shape, target_device) = obj.param; + std::ostringstream result; + result << "IS=" << ov::test::utils::vec2str(input_shape) << "_"; + result << "axes=" << ov::test::utils::vec2str(axes) << "_"; + result << "opType=" << op_type << "_"; + result << "type=" << reduction_type << "_"; + if (keep_dims) result << "KeepDims_"; + result << "modelType=" << model_type.to_string() << "_"; + result << "trgDev=" << target_device; + return result.str(); +} + +void ReduceOpsLayerTest::SetUp() { + std::vector input_shape; + ov::element::Type model_type; + bool keep_dims; + ov::test::utils::ReductionType reduction_type; + std::vector axes; + ov::test::utils::OpType op_type; + std::tie(axes, op_type, keep_dims, reduction_type, model_type, input_shape, targetDevice) = GetParam(); + + auto param = std::make_shared(model_type, ov::Shape(input_shape)); + + std::vector shape_axes; + switch (op_type) { + case ov::test::utils::OpType::SCALAR: { + if (axes.size() > 1) + FAIL() << "In reduce op if op type is scalar, 'axis' input's must contain 1 element"; + break; + } + case ov::test::utils::OpType::VECTOR: { + shape_axes.push_back(axes.size()); + break; + } + default: + FAIL() << "Reduce op doesn't support operation type: " << op_type; + } + auto reduction_axes_node = std::make_shared(ov::element::i64, ov::Shape(shape_axes), axes); + + const auto reduce = ngraph::builder::makeReduce(param, reduction_axes_node, keep_dims, reduction_type); + function = std::make_shared(reduce->outputs(), ov::ParameterVector{param}, "Reduce"); +} + +void ReduceOpsLayerWithSpecificInputTest::generate_inputs(const std::vector& targetInputStaticShapes) { + inputs.clear(); + auto param = function->get_parameters()[0]; + auto axes = std::get<0>(GetParam()); + auto axis = axes[0]; + auto dims = targetInputStaticShapes[0]; + + // Slice of tensor through axis is {1, 0, 0, ....}, the mean value is 1/slice_size + auto raw_values = std::vector(dims[axis], 0); + raw_values[0] = 1; + + auto tensor = ov::Tensor(param->get_element_type(), dims); + ov::test::utils::fill_data_with_broadcast(tensor, axis, raw_values); + + inputs.insert({param, tensor}); +} +} // namespace test +} // namespace ov diff --git a/src/tests/ov_helpers/ov_models/include/ov_models/builders.hpp b/src/tests/ov_helpers/ov_models/include/ov_models/builders.hpp index 7fa2e675372f26..15588fe27465fb 100644 --- a/src/tests/ov_helpers/ov_models/include/ov_models/builders.hpp +++ b/src/tests/ov_helpers/ov_models/include/ov_models/builders.hpp @@ -71,6 +71,8 @@ std::shared_ptr makeConstant(const ov::element::Type& type, makeNode(ov::element::Type_t::u64); makeNode(ov::element::Type_t::boolean); makeNode(ov::element::Type_t::nf4); + makeNode(ov::element::Type_t::u4); + makeNode(ov::element::Type_t::i4); #undef makeNode default: throw std::runtime_error("Unhandled precision"); diff --git a/src/tests/test_utils/functional_test_utils/layer_tests_summary/conformance_helper_tools/find_models_for_subgraphs_dumper.py b/src/tests/test_utils/functional_test_utils/layer_tests_summary/conformance_helper_tools/find_models_for_subgraphs_dumper.py new file mode 100644 index 00000000000000..3016f8c48c80aa --- /dev/null +++ b/src/tests/test_utils/functional_test_utils/layer_tests_summary/conformance_helper_tools/find_models_for_subgraphs_dumper.py @@ -0,0 +1,108 @@ +# Copyright (C) 2023 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import os + +from argparse import ArgumentParser +from pathlib import Path +import sys +sys.path.append(os.path.join(os.path.dirname(__file__), '..')) +from utils.file_utils import prepare_filelist, find_latest_dir +from utils.conformance_utils import get_logger +from utils.constants import SUPPORTED_MODEL_EXTENSION + +logger = get_logger("prepare_model_list") + +def get_default_re_path(is_take_all_models = False): + SCRIPT_DIR_PATH, _ = os.path.split(os.path.abspath(__file__)) + return os.path.join(SCRIPT_DIR_PATH, "..", "data", "custom_re_to_find_models.lst") if is_take_all_models else os.path.join(SCRIPT_DIR_PATH, "..", "data", "default_re_to_find_models.lst") + +def parse_arguments(): + parser = ArgumentParser() + + model_help = "Path to model directories path file to prepare filelist. Separator is `,`" + output_help = "Path to output dir to save model list file" + filename_help = "Output filename to save model list file" + latest_only_help = "Use only latest directory matched reg exp. In other case all directories will be taken from the dir" + + parser.add_argument("-m", "--model_dirs", type=str, help=model_help, required=True) + parser.add_argument("-o", "--output_dir", type=str, help=output_help, required=False, default=".") + parser.add_argument("-f", "--filename", type=str, help=filename_help, required=False, default="model_filelist") + parser.add_argument("-l", "--latest_only", type=bool, help=latest_only_help, required=False, default=False) + + return parser.parse_args() + + +def str_to_dir_list(input_str: str): + dir_path_list = [] + while True: + separator_pos = input_str.find(',') + dir_path = "" + if separator_pos == -1: + if len(input_str) > 0: + dir_path = input_str + input_str = "" + else: + break + else: + dir_path = input_str[:separator_pos:] + input_str = input_str[separator_pos+1::] + separator_pos = input_str.find(',') + if os.path.isdir(dir_path): + dir_path_list.append(dir_path) + logger.info(f"Model dir list: {dir_path_list}") + return dir_path_list + + +def read_dir_re_exp(re_exp_file_path: str): + dir_re_exps = [] + if os.path.isfile(re_exp_file_path): + with open(re_exp_file_path, "r") as re_exp_file: + for line in re_exp_file.readlines(): + if "#" in line: + continue + dir_re_exps.append(line.replace('\n', '')) + if len(dir_re_exps) == 0: + dir_re_exps.append('*') + logger.info(f"Model dir re exp list: {dir_re_exps}") + return dir_re_exps + + +def generate_model_list_file(input_str: str, re_exp_file_path: str, output_file_path: os.path, is_latest_only: bool): + with open(output_file_path, 'w', newline='\n') as output_file: + model_dir_paths = str_to_dir_list(input_str) + dir_re_exps = read_dir_re_exp(re_exp_file_path) + model_list = list() + for model_dir_path in model_dir_paths: + for dir_re_exp in dir_re_exps: + dirs = [model_dir_path] + if dir_re_exp != "*": + if is_latest_only: + dirs = [find_latest_dir(model_dir_path, dir_re_exp)] + else: + dirs = Path(model_dir_path).glob(dir_re_exp) + for dir in dirs: + try: + logger.info(f"Processing dir: {dir}") + model_list.extend(prepare_filelist(str(dir), SUPPORTED_MODEL_EXTENSION, is_save_to_file=False)) + if is_latest_only: + break + except: + pass + for line in model_list: + output_file.write(f"{line}\n") + output_file.close() + +if __name__ == "__main__": + args = parse_arguments() + os.makedirs(args.output_dir, exist_ok=True) + logger.info(f"[ ARGUMENTS ] --model_dirs={args.model_dirs}") + logger.info(f"[ ARGUMENTS ] --output_dir={args.output_dir}") + logger.info(f"[ ARGUMENTS ] --filename={args.filename}") + logger.info(f"[ ARGUMENTS ] --latest_only={args.latest_only}") + re_file = get_default_re_path(not args.latest_only) + if not args.latest_only: + logger.warning(f"{re_file} will be taken to get all models from the dirs") + output_model_list_file = os.path.join(args.output_dir, f"{args.filename}.lst") + generate_model_list_file(args.model_dirs, re_file, output_model_list_file, args.latest_only) + logger.info(f"Model file list is saved to {output_model_list_file}") diff --git a/src/tests/test_utils/functional_test_utils/layer_tests_summary/data/custom_re_to_find_models.lst b/src/tests/test_utils/functional_test_utils/layer_tests_summary/data/custom_re_to_find_models.lst new file mode 100644 index 00000000000000..72e8ffc0db8aad --- /dev/null +++ b/src/tests/test_utils/functional_test_utils/layer_tests_summary/data/custom_re_to_find_models.lst @@ -0,0 +1 @@ +* 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 new file mode 100644 index 00000000000000..e7c64cbe45dc75 --- /dev/null +++ b/src/tests/test_utils/functional_test_utils/layer_tests_summary/data/default_re_to_find_models.lst @@ -0,0 +1,5 @@ +ww*_dynamic* +ww*_pytorch* +ww*_static* +ww42*tfhub* +# ww42*tflite* \ No newline at end of file diff --git a/src/tests/test_utils/functional_test_utils/layer_tests_summary/run_conformance.py b/src/tests/test_utils/functional_test_utils/layer_tests_summary/run_conformance.py index d3e128e7b89a1e..70cd6fad7667b0 100644 --- a/src/tests/test_utils/functional_test_utils/layer_tests_summary/run_conformance.py +++ b/src/tests/test_utils/functional_test_utils/layer_tests_summary/run_conformance.py @@ -164,8 +164,7 @@ def __dump_subgraph(self): rmtree(conformance_ir_path) os.mkdir(conformance_ir_path) self._model_path = file_utils.prepare_filelist(self._model_path, - ["*.onnx", "*.pdmodel", "*.__model__", "*.pb", "*.xml", - "*.tflite"]) + constants.SUPPORTED_MODEL_EXTENSION) logger.info(f"Stating model dumping from {self._model_path}") cmd = f'{subgraph_dumper_path} --input_folders="{self._model_path}" --output_folder="{conformance_ir_path}"' process = Popen(cmd, shell=True) diff --git a/src/tests/test_utils/functional_test_utils/layer_tests_summary/skip_configs/CPU/expected_failures_API.csv b/src/tests/test_utils/functional_test_utils/layer_tests_summary/skip_configs/CPU/expected_failures_API.csv index 7e956981216699..db8f560869e79c 100644 --- a/src/tests/test_utils/functional_test_utils/layer_tests_summary/skip_configs/CPU/expected_failures_API.csv +++ b/src/tests/test_utils/functional_test_utils/layer_tests_summary/skip_configs/CPU/expected_failures_API.csv @@ -124,6 +124,7 @@ ov_infer_request_mandatory/OVInferRequestIOTensorTest.canInferWithGetIn/targetDe ov_infer_request_mandatory/OVInferRequestIOTensorTest.canInferAfterIOBlobReallocation/targetDevice=BATCH.CPU_,1.0 ov_infer_request_mandatory/OVInferRequestIOTensorTest.InferStaticNetworkSetChangedOutputTensorThrow/targetDevice=BATCH.CPU_,1.0 ov_infer_request_mandatory/OVInferRequestIOTensorTest.InferStaticNetworkSetChangedInputTensorThrow/targetDevice=BATCH.CPU_,1.0 +ov_infer_request_mandatory/OVInferRequestIOTensorTest.CheckInferIsNotChangeInput/targetDevice=BATCH.CPU_,1.0 ov_infer_request_mandatory/OVInferRequestIOTensorSetPrecisionTest.CanSetOutBlobWithDifferentPrecision/type=u8_target_device=BATCH.CPU_,1.0 ov_infer_request_mandatory/OVInferRequestIOTensorSetPrecisionTest.CanSetOutBlobWithDifferentPrecision/type=u64_target_device=BATCH.CPU_,1.0 ov_infer_request_mandatory/OVInferRequestIOTensorSetPrecisionTest.CanSetOutBlobWithDifferentPrecision/type=u32_target_device=BATCH.CPU_,1.0 diff --git a/src/tests/test_utils/functional_test_utils/layer_tests_summary/utils/constants.py b/src/tests/test_utils/functional_test_utils/layer_tests_summary/utils/constants.py index 05018f1cbfda21..8d381f2758a2d5 100644 --- a/src/tests/test_utils/functional_test_utils/layer_tests_summary/utils/constants.py +++ b/src/tests/test_utils/functional_test_utils/layer_tests_summary/utils/constants.py @@ -56,3 +56,16 @@ META_EXTENSION = ".meta" XML_EXTENSION = ".xml" BIN_EXTENSION = ".bin" + +SUPPORTED_MODEL_EXTENSION = [ + # ONNX + "*.onnx", + #PDPD + "*.pdmodel", + # TF + "*.pb", + # OV IR + "*.xml", + # TFLITE + "*.tflite", +] diff --git a/src/tests/test_utils/functional_test_utils/layer_tests_summary/utils/file_utils.py b/src/tests/test_utils/functional_test_utils/layer_tests_summary/utils/file_utils.py index 002d7b91a7751b..edd74d330751d5 100644 --- a/src/tests/test_utils/functional_test_utils/layer_tests_summary/utils/file_utils.py +++ b/src/tests/test_utils/functional_test_utils/layer_tests_summary/utils/file_utils.py @@ -13,7 +13,7 @@ from . import conformance_utils # generates file list file inside directory. Returns path to saved filelist -def prepare_filelist(input_dir: os.path, patterns: list): +def prepare_filelist(input_dir: os.path, patterns: list, is_save_to_file = True): filelist_path = input_dir if os.path.isdir(filelist_path): filelist_path = os.path.join(input_dir, "conformance_ir_files.lst") @@ -24,15 +24,17 @@ def prepare_filelist(input_dir: os.path, patterns: list): conformance_utils.UTILS_LOGGER.info(f"{filelist_path} is exists! The script will update it!") model_list = list() for pattern in patterns: - for model in Path(input_dir).rglob(pattern): - model_list.append(model) - try: - with open(filelist_path, 'w') as file: - for xml in model_list: - file.write(str(xml) + '\n') - file.close() - except: - conformance_utils.UTILS_LOGGER.warning(f"Impossible to update {filelist_path}! Something going is wrong!") + model_list.extend(Path(input_dir).rglob(pattern)) + if is_save_to_file: + try: + with open(filelist_path, 'w') as file: + for xml in model_list: + file.write(str(xml) + '\n') + file.close() + except: + conformance_utils.UTILS_LOGGER.warning(f"Impossible to update {filelist_path}! Something going is wrong!") + else: + return model_list return filelist_path def is_archieve(input_path: os.path): @@ -68,27 +70,22 @@ def unzip_archieve(zip_path: os.path, dst_path: os.path): return dst_dir # find latest changed directory -def find_latest_dir(in_dir: Path, pattern_list = list()): - get_latest_dir = lambda path: sorted(Path(path).iterdir(), key=os.path.getmtime) +def find_latest_dir(in_dir: Path, pattern = "*"): + get_latest_dir = lambda path: sorted(Path(path).glob(pattern), key=os.path.getmtime) entities = get_latest_dir(in_dir) entities.reverse() for entity in entities: if entity.is_dir(): - if not pattern_list: - return entity - else: - for pattern in pattern_list: - if pattern in str(os.fspath(PurePath(entity))): - return entity - conformance_utils.UTILS_LOGGER.error(f"{in_dir} does not contain applicable directories to patterns: {pattern_list}") + return entity + conformance_utils.UTILS_LOGGER.error(f"{in_dir} does not contain applicable directories to pattern: {pattern}") exit(-1) def get_ov_path(script_dir_path: os.path, ov_dir=None, is_bin=False): if ov_dir is None or not os.path.isdir(ov_dir): ov_dir = os.path.abspath(script_dir_path)[:os.path.abspath(script_dir_path).find(constants.OPENVINO_NAME) + len(constants.OPENVINO_NAME)] if is_bin: - ov_dir = os.path.join(ov_dir, find_latest_dir(ov_dir, ['bin'])) + ov_dir = os.path.join(ov_dir, find_latest_dir(ov_dir, 'bin')) ov_dir = os.path.join(ov_dir, find_latest_dir(ov_dir)) ov_dir = os.path.join(ov_dir, find_latest_dir(ov_dir, [constants.DEBUG_DIR, constants.RELEASE_DIR])) return ov_dir diff --git a/tests/layer_tests/pytorch_tests/test_adaptive_avg_pool.py b/tests/layer_tests/pytorch_tests/test_adaptive_avg_pool.py index f50dc8a4051519..bedd9beb0d4bcf 100644 --- a/tests/layer_tests/pytorch_tests/test_adaptive_avg_pool.py +++ b/tests/layer_tests/pytorch_tests/test_adaptive_avg_pool.py @@ -8,13 +8,12 @@ from pytorch_layer_test_class import PytorchLayerTest -@pytest.mark.parametrize('input_tensor', (np.random.randn(1, 2, 8, 9, 10).astype(np.float32), - np.random.randn(2, 8, 9, 10).astype(np.float32))) -@pytest.mark.parametrize('output_size', ([5, 7, 9], 7)) +@pytest.mark.parametrize('input_tensor', [[1, 2, 8, 9, 10], [2, 8, 9, 10]]) +@pytest.mark.parametrize('output_size', [[5, 7, 9], 7]) class TestAdaptiveAvgPool3D(PytorchLayerTest): def _prepare_input(self): - return (self.input_tensor,) + return (self.input_tensor, ) def create_model(self, output_size): class aten_adaptive_avg_pool3d(torch.nn.Module): @@ -35,16 +34,16 @@ def forward(self, input_tensor): @pytest.mark.precommit_ts_backend @pytest.mark.precommit_fx_backend def test_adaptive_avg_pool3d(self, ie_device, precision, ir_version, input_tensor, output_size): - self.input_tensor = input_tensor + self.input_tensor = np.random.randn(*input_tensor).astype(np.float32) self._test(*self.create_model(output_size), ie_device, precision, ir_version) -@pytest.mark.parametrize('input_tensor', [np.random.randn(2, 8, 9, 10).astype(np.float32), np.random.randn(8, 9, 10).astype(np.float32)]) -@pytest.mark.parametrize('output_size', ([7, 9], 7)) +@pytest.mark.parametrize('input_shape', [[2, 8, 9, 10], [8, 9, 10]]) +@pytest.mark.parametrize('output_size', [[7, 9], 7]) class TestAdaptiveAvgPool2D(PytorchLayerTest): def _prepare_input(self): - return (self.input_tensor,) + return (self.input_tensor, ) def create_model(self, output_size): class aten_adaptive_avg_pool2d(torch.nn.Module): @@ -64,17 +63,17 @@ def forward(self, input_tensor): @pytest.mark.precommit @pytest.mark.precommit_ts_backend @pytest.mark.precommit_fx_backend - def test_adaptive_avg_pool2d(self, ie_device, precision, ir_version, input_tensor, output_size): - self.input_tensor = input_tensor + def test_adaptive_avg_pool2d(self, ie_device, precision, ir_version, input_shape, output_size): + self.input_tensor = np.random.randn(*input_shape).astype(np.float32) self._test(*self.create_model(output_size), ie_device, precision, ir_version) -@pytest.mark.parametrize('input_tensor', [np.random.randn(8, 9, 10).astype(np.float32), np.random.randn(9, 10).astype(np.float32)] ) -@pytest.mark.parametrize('output_size', ( 7, )) +@pytest.mark.parametrize('input_shape', [[8, 9, 10], [9, 10]]) +@pytest.mark.parametrize('output_size', [7, ]) class TestAdaptiveAvgPool1D(PytorchLayerTest): def _prepare_input(self): - return (self.input_tensor,) + return (self.input_tensor, ) def create_model(self, output_size): class aten_adaptive_avg_pool1d(torch.nn.Module): @@ -94,8 +93,8 @@ def forward(self, input_tensor): @pytest.mark.precommit @pytest.mark.precommit_ts_backend @pytest.mark.precommit_fx_backend - def test_adaptive_avg_pool1d(self, ie_device, precision, ir_version, input_tensor, output_size): - self.input_tensor = input_tensor + def test_adaptive_avg_pool1d(self, ie_device, precision, ir_version, input_shape, output_size): + self.input_tensor = np.random.randn(*input_shape).astype(np.float32) self._test(*self.create_model(output_size), ie_device, precision, ir_version) diff --git a/tests/layer_tests/pytorch_tests/test_adaptive_max_pool.py b/tests/layer_tests/pytorch_tests/test_adaptive_max_pool.py index 09be641a0fb96e..b80a82a4a9dee7 100644 --- a/tests/layer_tests/pytorch_tests/test_adaptive_max_pool.py +++ b/tests/layer_tests/pytorch_tests/test_adaptive_max_pool.py @@ -34,11 +34,9 @@ def forward(self, input_tensor): return aten_adaptive_max_pool3d(output_size, return_indices), ref_net, "aten::adaptive_max_pool3d" - @pytest.mark.parametrize('input_tensor', ([ - np.random.randn(2, 1, 1, 4, 4).astype(np.float32), - np.random.randn(4, 1, 3, 32, 32).astype(np.float32), - np.random.randn(1, 3, 32, 32).astype(np.float32) - ])) + @pytest.mark.parametrize('input_shape', [[2, 1, 1, 4, 4], + [4, 1, 3, 32, 32], + [1, 3, 32, 32]]) @pytest.mark.parametrize('output_size', ([ [2, 2, 2], [4, 4, 4], @@ -53,8 +51,8 @@ def forward(self, input_tensor): @pytest.mark.precommit_fx_backend @pytest.mark.xfail(condition=platform.system() == 'Darwin' and platform.machine() == 'arm64', reason='Ticket - 122715') - def test_adaptive_max_pool3d(self, ie_device, precision, ir_version, input_tensor, output_size, return_indices): - self.input_tensor = input_tensor + def test_adaptive_max_pool3d(self, ie_device, precision, ir_version, input_shape, output_size, return_indices): + self.input_tensor = np.random.randn(*input_shape).astype(np.float32) self._test(*self.create_model(output_size, return_indices), ie_device, precision, ir_version) @@ -81,11 +79,9 @@ def forward(self, input_tensor): return aten_adaptive_max_pool2d(output_size, return_indices), ref_net, "aten::adaptive_max_pool2d" - @pytest.mark.parametrize('input_tensor', ([ - np.random.randn(2, 1, 4, 4).astype(np.float32), - np.random.randn(1, 3, 32, 32).astype(np.float32), - np.random.randn(3, 32, 32).astype(np.float32) - ])) + @pytest.mark.parametrize('input_shape', [[2, 1, 4, 4], + [1, 3, 32, 32], + [3, 32, 32]]) @pytest.mark.parametrize('output_size', ([ [2, 2], [4, 4], @@ -100,8 +96,8 @@ def forward(self, input_tensor): @pytest.mark.precommit_fx_backend @pytest.mark.xfail(condition=platform.system() == 'Darwin' and platform.machine() == 'arm64', reason='Ticket - 122715') - def test_adaptive_max_pool2d(self, ie_device, precision, ir_version, input_tensor, output_size, return_indices): - self.input_tensor = input_tensor + def test_adaptive_max_pool2d(self, ie_device, precision, ir_version, input_shape, output_size, return_indices): + self.input_tensor = np.random.randn(*input_shape).astype(np.float32) self._test(*self.create_model(output_size, return_indices), ie_device, precision, ir_version) @@ -128,11 +124,11 @@ def forward(self, input_tensor): return aten_adaptive_max_pool1d(output_size, return_indices), ref_net, "aten::adaptive_max_pool1d" - @pytest.mark.parametrize('input_tensor', ([ - np.random.randn(1, 4, 4).astype(np.float32), - np.random.randn(3, 32, 32).astype(np.float32), - np.random.randn(16, 8).astype(np.float32), - ])) + @pytest.mark.parametrize('input_shape', [ + [1, 4, 4], + [3, 32, 32], + [16, 8] + ]) @pytest.mark.parametrize('output_size', ([ 2, 4, @@ -147,6 +143,6 @@ def forward(self, input_tensor): @pytest.mark.precommit_fx_backend @pytest.mark.xfail(condition=platform.system() == 'Darwin' and platform.machine() == 'arm64', reason='Ticket - 122715') - def test_adaptive_max_pool1d(self, ie_device, precision, ir_version, input_tensor, output_size, return_indices): - self.input_tensor = input_tensor + def test_adaptive_max_pool1d(self, ie_device, precision, ir_version, input_shape, output_size, return_indices): + self.input_tensor = np.random.randn(*input_shape).astype(np.float32) self._test(*self.create_model(output_size, return_indices), ie_device, precision, ir_version) \ No newline at end of file diff --git a/tests/layer_tests/pytorch_tests/test_add.py b/tests/layer_tests/pytorch_tests/test_add.py index d89a05420eb7e1..f2b3897a68ed47 100644 --- a/tests/layer_tests/pytorch_tests/test_add.py +++ b/tests/layer_tests/pytorch_tests/test_add.py @@ -9,10 +9,11 @@ @pytest.mark.parametrize('alpha', (-0.5, 0, 0.5, 1, 2)) -@pytest.mark.parametrize('input_rhs', (np.random.randn(2, 5, 3, 4).astype(np.float32), - np.random.randn( - 1, 5, 3, 4).astype(np.float32), - np.random.randn(1).astype(np.float32))) +@pytest.mark.parametrize('input_shape_rhs', [ + [2, 5, 3, 4], + [1, 5, 3, 4], + [1] +]) class TestAdd(PytorchLayerTest): def _prepare_input(self): @@ -41,8 +42,8 @@ def forward2(self, lhs, rhs): @pytest.mark.precommit_ts_backend @pytest.mark.precommit_fx_backend @pytest.mark.parametrize("op_type", ["add", "add_"]) - def test_add(self, ie_device, precision, ir_version, alpha, input_rhs, op_type): - self.input_rhs = input_rhs + def test_add(self, ie_device, precision, ir_version, alpha, input_shape_rhs, op_type): + self.input_rhs = np.random.randn(*input_shape_rhs).astype(np.float32) self._test(*self.create_model(alpha, op_type), ie_device, precision, ir_version, use_convert_model=True) diff --git a/tests/layer_tests/pytorch_tests/test_all.py b/tests/layer_tests/pytorch_tests/test_all.py index ca9b734c1ad1dd..c8b79ee0ff5e3b 100644 --- a/tests/layer_tests/pytorch_tests/test_all.py +++ b/tests/layer_tests/pytorch_tests/test_all.py @@ -24,10 +24,10 @@ def __init__(self, dim, keepdim) -> None: def forward(self, input_tensor): return torch.all( - input_tensor, + input_tensor, dim = self.dim ) if self.keepdim is None else torch.all( - input_tensor, + input_tensor, dim = self.dim, keepdim = self.keepdim ) @@ -36,32 +36,35 @@ class TestAll(PytorchLayerTest): def _prepare_input(self): return (self.input_tensor,) - @pytest.mark.parametrize("input_tensor", [ - np.eye(5,5), - np.zeros((5, 5)), - np.zeros((9,8)) + 1, - np.random.randint(0, 2, (5, 9, 7)), - np.random.randint(0, 2, (10, 13, 11)), - np.random.randint(0, 2, (8, 7, 6, 5, 4)), - np.random.randint(0, 2, (11, 11), dtype=np.uint8), - np.random.randint(0, 2, (7, 7), dtype=np.uint8), + @pytest.mark.parametrize("input_shape, d_type", [ + (np.eye(5,5), np.int64), + (np.zeros((5, 5)), np.int64), + (np.zeros((9,8)) + 1, np.int64), + ([5, 9, 7], np.int64), + ([10, 13, 11], np.int64), + ([8, 7, 6, 5, 4], np.int64), + ([11, 11], np.uint8), + ([7, 7], np.uint8) ]) @pytest.mark.nightly @pytest.mark.precommit - def test_all_noparams(self, input_tensor, ie_device, precision, ir_version): - self.input_tensor = input_tensor - self._test(aten_all_noparam(), None, "aten::all", + def test_all_noparams(self, input_shape, d_type, ie_device, precision, ir_version): + if type(input_shape) is list: + self.input_tensor = np.random.randint(0, 2, input_shape, dtype=d_type) + else: + self.input_tensor = input_shape + self._test(aten_all_noparam(), None, "aten::all", ie_device, precision, ir_version, trace_model=True, freeze_model=False) - - @pytest.mark.parametrize("input_tensor", [ - np.eye(5,5), - np.zeros((5, 5)), - np.zeros((9,8)) + 1, - np.random.randint(0, 2, (5, 9, 7)), - np.random.randint(0, 2, (10, 13, 11)), - np.random.randint(0, 2, (8, 7, 6, 5, 4)), - np.random.randint(0, 2, (11, 11), dtype=np.uint8), - np.random.randint(0, 2, (7, 7), dtype=np.uint8), + + @pytest.mark.parametrize("input_shape, d_type", [ + (np.eye(5,5), np.int64), + (np.zeros((5, 5)), np.int64), + (np.zeros((9,8)) + 1, np.int64), + ([5, 9, 7], np.int64), + ([10, 13, 11], np.int64), + ([8, 7, 6, 5, 4], np.int64), + ([11, 11], np.uint8), + ([7, 7], np.uint8) ]) @pytest.mark.parametrize("keepdim", [ True, @@ -72,8 +75,11 @@ def test_all_noparams(self, input_tensor, ie_device, precision, ir_version): @pytest.mark.precommit @pytest.mark.xfail(condition=platform.system() == 'Darwin' and platform.machine() == 'arm64', reason='Ticket - 122715') - def test_all(self, input_tensor, keepdim, ie_device, precision, ir_version): - self.input_tensor = input_tensor - for dim in range(len(input_tensor.shape)): - self._test(aten_all(dim, keepdim), None, "aten::all", + def test_all(self, input_shape, d_type, keepdim, ie_device, precision, ir_version): + if type(input_shape) is list: + self.input_tensor = np.random.randint(0, 2, input_shape, dtype=d_type) + else: + self.input_tensor = input_shape + for dim in range(len(self.input_tensor.shape)): + self._test(aten_all(dim, keepdim), None, "aten::all", ie_device, precision, ir_version, trace_model=True, freeze_model=False) diff --git a/tests/layer_tests/pytorch_tests/test_argsort.py b/tests/layer_tests/pytorch_tests/test_argsort.py index 667edc5f8a0091..6468e553381513 100644 --- a/tests/layer_tests/pytorch_tests/test_argsort.py +++ b/tests/layer_tests/pytorch_tests/test_argsort.py @@ -22,24 +22,24 @@ def __init__(self, dim, descending, stable) -> None: def forward(self, input_tensor): if self.stable is not None: - return torch.argsort(input_tensor, - dim = self.dim, - descending = self.descending, + return torch.argsort(input_tensor, + dim = self.dim, + descending = self.descending, stable = self.stable ) else: - return torch.argsort(input_tensor, - dim = self.dim, + return torch.argsort(input_tensor, + dim = self.dim, descending = self.descending - ) + ) ref_net = None return aten_argsort(dim, descending, stable), ref_net, "aten::argsort" @pytest.mark.parametrize("tensor_stable_pair", [ - (np.random.rand(1, 4), False), - (np.random.rand(4, 4), False), - (np.random.rand(4, 4, 4), False), + ([1, 4], False), + ([4, 4], False), + ([4, 4, 4], False), (np.array([1, 2, 4, 6, 5, 8, 7]), False), (np.array([6, 5, 4, 2, 3, 0, 1]), False), (np.array([1, 1, 1, 2, 1, 3, 1, 4, 2, 5, 1, 2, 4, 4, 0]), True), @@ -49,20 +49,20 @@ def forward(self, input_tensor): (np.array([[9, 8, 8], [8, 7, 7], [7, 5, 6], [8, 8, 9], [7, 7, 8], [6, 5, 7], [8, 9, 8], [7, 8, 7], [5, 6, 7]]), True), - (np.array([[[1, 2, 3], [4, 5, 6], [7, 8, 9]], - [[5, 2, 4], [4, 9, 0], [7, 7, 9]], + (np.array([[[1, 2, 3], [4, 5, 6], [7, 8, 9]], + [[5, 2, 4], [4, 9, 0], [7, 7, 9]], [[5, 2, 4], [4, 9, 0], [7, 7, 9]]]), True), - (np.array([[[3, 2, 2], [1, 2, 1], [3, 2, 2]], - [[1, 2, 1], [4, 3, 4], [3, 2, 2]], + (np.array([[[3, 2, 2], [1, 2, 1], [3, 2, 2]], + [[1, 2, 1], [4, 3, 4], [3, 2, 2]], [[3, 2, 2], [1, 2, 1], [7, 9, 9]]]), True), - (np.array([[[2, 1, 3], [3, 2, 1], [1, 2, 3]], - [[2, 0, 2], [1, 2, 1], [3, 2, 8]], + (np.array([[[2, 1, 3], [3, 2, 1], [1, 2, 3]], + [[2, 0, 2], [1, 2, 1], [3, 2, 8]], [[3, 2, 2], [3, 2, 1], [1, 2, 3]], - [[2, 1, 3], [3, 2, 1], [1, 2, 3]], - [[2, 0, 2], [1, 2, 1], [3, 2, 8]], + [[2, 1, 3], [3, 2, 1], [1, 2, 3]], + [[2, 0, 2], [1, 2, 1], [3, 2, 8]], [[3, 2, 2], [3, 2, 1], [1, 2, 3]], - [[2, 1, 3], [3, 2, 1], [1, 2, 3]], - [[2, 0, 2], [1, 2, 1], [3, 2, 8]], + [[2, 1, 3], [3, 2, 1], [1, 2, 3]], + [[2, 0, 2], [1, 2, 1], [3, 2, 8]], [[3, 2, 2], [3, 2, 1], [1, 2, 3]]]), True) ]) @pytest.mark.parametrize("descending", [ @@ -72,7 +72,11 @@ def forward(self, input_tensor): @pytest.mark.nightly @pytest.mark.precommit def test_argsort(self, tensor_stable_pair, descending, ie_device, precision, ir_version): - self.input_tensor, stable = tensor_stable_pair + input_shape, stable = tensor_stable_pair + if type(input_shape) is list: + self.input_tensor = np.random.randn(*input_shape).astype(np.float32) + else: + self.input_tensor = input_shape dims = len(self.input_tensor.shape) for dim in range(-dims, dims): stable_values = [True] if stable else [True, False, None] diff --git a/tests/layer_tests/pytorch_tests/test_floor_divide.py b/tests/layer_tests/pytorch_tests/test_floor_divide.py index 0cdc46333b2651..40d1eb5afa7fed 100644 --- a/tests/layer_tests/pytorch_tests/test_floor_divide.py +++ b/tests/layer_tests/pytorch_tests/test_floor_divide.py @@ -41,41 +41,59 @@ def forward(self, input_tensor, other_tensor): return aten_floor_divide(), ref_net, "aten::floor_divide" - @pytest.mark.parametrize('input_tensor', ([ - np.random.randn(5).astype(np.float32), - np.random.randn(5, 5, 1).astype(np.float32), - np.random.randn(1, 1, 5, 5).astype(np.float32), + @pytest.mark.parametrize('input_tensor', + ([ + [5], [5, 5, 1], [1, 1, 5, 5], ])) - @pytest.mark.parametrize('other_tensor', ([ - np.array([[0.5]]).astype(np.float32), - np.random.randn(5).astype(np.float32), - np.random.randn(5, 1).astype(np.float32), - np.random.randn(1, 5).astype(np.float32), + @pytest.mark.parametrize('other_tensor', + ([ + np.array([[0.5]]).astype(np.float32), [5], [5, 1], [1, 5] ])) @pytest.mark.nightly @pytest.mark.precommit @pytest.mark.xfail(condition=platform.system() == 'Darwin' and platform.machine() == 'arm64', reason='Ticket - 122715') def test_floor_divide(self, input_tensor, other_tensor, ie_device, precision, ir_version): - self.input_tensor = input_tensor - self.other_tensor = other_tensor + if type(input_tensor) is list: + self.input_tensor = np.random.randn(*input_tensor).astype(np.float32) + else: + self.input_tensor = input_tensor + if type(other_tensor) is list: + self.other_tensor = np.random.randn(*other_tensor).astype(np.float32) + else: + self.other_tensor = other_tensor self._test(*self.create_model(), ie_device, precision, ir_version, trace_model=True, use_convert_model=True) - @pytest.mark.parametrize('input_tensor', ([ - np.random.randint(low=0, high=10, size=5).astype(np.float32), - np.random.randint(low=1, high=10, size=(5, 5, 1)).astype(np.float32), - np.random.randint(low=1, high=10, size=(1, 1, 5, 5)).astype(np.float32), - ])) - @pytest.mark.parametrize('other_tensor', ([ - np.array([[2]]).astype(np.float32), - np.random.randint(low=1, high=10, size=5).astype(np.float32), - np.random.randint(low=1, high=10, size=(5, 1)).astype(np.float32), - np.random.randint(low=1, high=10, size=(1, 5)).astype(np.float32), - ])) + @pytest.mark.parametrize('input_data', + [ + { "tensor": [5], "low": 0, "high": 10 }, + { "tensor": [5, 5, 1], "low": 1, "high": 10 }, + { "tensor": [1, 1, 5, 5], "low": 1, "high": 10 } + ]) + @pytest.mark.parametrize('other_data', + [ + { "tensor": np.array([[2]]).astype(np.float32) }, + { "tensor": [5], "low": 1, "high": 10 }, + { "tensor": [5, 1], "low": 1, "high": 10 }, + { "tensor": [5, 1], "low": 1, "high": 10 } + ]) @pytest.mark.nightly @pytest.mark.precommit - def test_floor_divide_int(self, input_tensor, other_tensor, ie_device, precision, ir_version): - self.input_tensor = input_tensor - self.other_tensor = other_tensor + def test_floor_divide_int(self, input_data, other_data, ie_device, precision, ir_version): + input_tensor = input_data["tensor"] + if type(input_tensor) is list: + self.input_tensor = np.random.randint(low=input_data["low"], + high=input_data["high"], + size=input_tensor).astype(np.float32) + else: + self.input_tensor = input_tensor + + other_tensor = other_data["tensor"] + if type(other_tensor) is list: + self.other_tensor = np.random.randint(low=other_data["low"], + high=other_data["high"], + size=other_tensor).astype(np.float32) + else: + self.other_tensor = other_tensor self.create_model = self.create_model_int self._test(*self.create_model(), ie_device, precision, ir_version) diff --git a/tests/layer_tests/pytorch_tests/test_index_put_.py b/tests/layer_tests/pytorch_tests/test_index_put_.py index 6f94a0912d4df2..68eaed216261d6 100644 --- a/tests/layer_tests/pytorch_tests/test_index_put_.py +++ b/tests/layer_tests/pytorch_tests/test_index_put_.py @@ -32,10 +32,10 @@ def forward(self, input_tensor, values): "input_data", ( { - "input_tensor": np.random.randn(5).astype(np.float32), + "input_shape": [5], "values": np.array(11).astype(np.float32)}, { - "input_tensor": np.random.randn(3, 3).astype(np.float32), + "input_shape": [3, 3], "values": np.array([10, 11, 12]).astype(np.float32), }, ), @@ -54,7 +54,7 @@ def forward(self, input_tensor, values): @pytest.mark.nightly @pytest.mark.precommit def test_index_put_single_indices(self, ie_device, precision, ir_version, input_data, indices, accumulate): - self.input_tensor = input_data["input_tensor"] + self.input_tensor = np.random.randn(*input_data["input_shape"]).astype(np.float32) self.values = input_data["values"] self._test(*self.create_model(indices, accumulate), ie_device, precision, ir_version) @@ -83,11 +83,11 @@ def forward(self, input_tensor, values): "input_data", ( { - "input_tensor": np.random.randn(3, 3).astype(np.float32), + "input_shape": [3, 3], "values": np.array(12).astype(np.float32) }, { - "input_tensor": np.random.randn(3, 3, 3).astype(np.float32), + "input_shape": [3, 3, 3], "values": np.array([10, 11, 12]).astype(np.float32), }, ), @@ -107,7 +107,7 @@ def forward(self, input_tensor, values): @pytest.mark.nightly @pytest.mark.precommit def test_index_put_many_indices(self, ie_device, precision, ir_version, input_data, indices, accumulate): - self.input_tensor = input_data["input_tensor"] + self.input_tensor = np.random.randn(*input_data["input_shape"]).astype(np.float32) self.values = input_data["values"] self._test(*self.create_model(indices, accumulate), ie_device, precision, ir_version) @@ -135,11 +135,11 @@ def forward(self, input_tensor, values, indices_0, indices_1): "input_data", ( { - "input_tensor": np.random.randn(3).astype(np.float32), + "input_shape": [3], "values": np.array(11).astype(np.float32), }, { - "input_tensor": np.random.randn(3, 3).astype(np.float32), + "input_shape": [3, 3], "values": np.array([10, 11, 12]).astype(np.float32), }, ), @@ -147,19 +147,22 @@ def forward(self, input_tensor, values, indices_0, indices_1): @pytest.mark.parametrize( "indices", ( - (np.random.randint(low=0, high=2, size=(1,)), np.random.randint(low=0, high=2, size=(1,))), - (np.random.randint(low=0, high=2, size=(2,)), np.random.randint(low=0, high=2, size=(2,))), - (np.array([0, 1, 0]), np.array([1, 1, 0])), - (np.ones(shape=(3,)), np.ones(shape=(3,))), - (np.ones(shape=(3,)), np.zeros(shape=(3,))), + [[1, ], [1, ]], + [[2, ], [2, ]], + [np.array([0, 1, 0]), np.array([1, 1, 0])], + [np.ones(shape=(3,)), np.ones(shape=(3,))], + [np.ones(shape=(3,)), np.zeros(shape=(3,))], ), ) @pytest.mark.parametrize("accumulate", (False, True)) @pytest.mark.nightly @pytest.mark.precommit def test_nonzero_index_put_(self, ie_device, precision, ir_version, input_data, indices, accumulate): - self.input_tensor = input_data["input_tensor"] + self.input_tensor = np.random.randn(*input_data["input_shape"]).astype(np.float32) self.values = input_data["values"] + for i in range(len(indices)): + if type(indices[i]) is list: + indices[i] = np.random.randint(0, 2, indices[i]) self.indices_0 = indices[0] self.indices_1 = indices[1] self._test(*self.create_model(accumulate), ie_device, precision, ir_version, trace_model=True, use_convert_model=True) @@ -167,7 +170,7 @@ def test_nonzero_index_put_(self, ie_device, precision, ir_version, input_data, class TestMask_IndexPut(PytorchLayerTest): def _prepare_input(self): return (np.random.randn(100, 5).astype(np.float32),np.random.randn(100, 5).astype(np.float32)) - + def create_model(self): class aten_index_put_mask(torch.nn.Module): def forward(self, x, y): diff --git a/tests/layer_tests/pytorch_tests/test_len.py b/tests/layer_tests/pytorch_tests/test_len.py index 7aa5f020b9c7fc..9443f2576efc77 100644 --- a/tests/layer_tests/pytorch_tests/test_len.py +++ b/tests/layer_tests/pytorch_tests/test_len.py @@ -8,8 +8,10 @@ from pytorch_layer_test_class import PytorchLayerTest -@pytest.mark.parametrize('input_tensor', (np.random.randn(2, 1, 3), np.random.randn(3, 7), - np.random.randn(1, 1, 4, 4))) +@pytest.mark.parametrize('input_tensor', +[ + [2, 1, 3], [3, 7], [1, 1, 4, 4] +]) class TestLen(PytorchLayerTest): def _prepare_input(self): @@ -40,13 +42,13 @@ def forward(self, input_tensor): @pytest.mark.nightly @pytest.mark.precommit def test_len(self, ie_device, precision, ir_version, input_tensor): - self.input_tensor = input_tensor + self.input_tensor = np.random.randn(*input_tensor).astype(np.float32) self._test(*self.create_model(), ie_device, precision, ir_version) @pytest.mark.nightly @pytest.mark.precommit def test_len_int_list(self, ie_device, precision, ir_version, input_tensor): - self.input_tensor = input_tensor + self.input_tensor = np.random.randn(*input_tensor).astype(np.float32) self._test(*self.create_model_int_list(), ie_device, precision, ir_version, use_convert_model=True) diff --git a/tests/layer_tests/pytorch_tests/test_narrow.py b/tests/layer_tests/pytorch_tests/test_narrow.py index 9197492553e5af..c472e4f225a1cf 100644 --- a/tests/layer_tests/pytorch_tests/test_narrow.py +++ b/tests/layer_tests/pytorch_tests/test_narrow.py @@ -23,8 +23,8 @@ def forward(self, input_tensor, dim: int, start, length: int): return aten_narrow(), ref_net, "aten::narrow" - @pytest.mark.parametrize("input_tensor", [ - np.random.randn(3, 3), np.random.randn(3, 4, 5) + @pytest.mark.parametrize("input_shape", [ + [3, 3], [3, 4, 5] ]) @pytest.mark.parametrize("dim", [ np.array(0).astype(np.int32), np.array(1).astype(np.int32), np.array(-1).astype(np.int32) @@ -37,8 +37,8 @@ def forward(self, input_tensor, dim: int, start, length: int): ]) @pytest.mark.nightly @pytest.mark.precommit - def test_narrow(self, input_tensor, dim, start, length, ie_device, precision, ir_version): - self.input_tensor = input_tensor + def test_narrow(self, input_shape, dim, start, length, ie_device, precision, ir_version): + self.input_tensor = np.random.randn(*input_shape).astype(np.float32) self.dim = dim self.start = start self.length = length diff --git a/tests/layer_tests/pytorch_tests/test_remainder.py b/tests/layer_tests/pytorch_tests/test_remainder.py index 05ad2d3b1387fe..d295fe3ad0fe6d 100644 --- a/tests/layer_tests/pytorch_tests/test_remainder.py +++ b/tests/layer_tests/pytorch_tests/test_remainder.py @@ -8,12 +8,12 @@ @pytest.mark.parametrize( - "input_rhs", - ( - np.random.randn(2, 5, 3, 4).astype(np.float32), - np.random.randn(1, 5, 3, 4).astype(np.float32), - np.random.randn(1).astype(np.float32), - ), + "input_shape_rhs", + [ + [2, 5, 3, 4], + [1, 5, 3, 4], + [1] + ] ) class TestRemainder(PytorchLayerTest): def _prepare_input(self): @@ -30,8 +30,8 @@ def forward(self, lhs, rhs): @pytest.mark.nightly @pytest.mark.precommit - def test_remainder(self, ie_device, precision, ir_version, input_rhs): - self.input_rhs = input_rhs + def test_remainder(self, ie_device, precision, ir_version, input_shape_rhs): + self.input_rhs = np.random.randn(*input_shape_rhs).astype(np.float32) self._test(*self.create_model(), ie_device, precision, ir_version, use_convert_model=True) diff --git a/tests/layer_tests/pytorch_tests/test_repeat_interleave.py b/tests/layer_tests/pytorch_tests/test_repeat_interleave.py index dc937a7d27d784..3df1ae1b421c02 100644 --- a/tests/layer_tests/pytorch_tests/test_repeat_interleave.py +++ b/tests/layer_tests/pytorch_tests/test_repeat_interleave.py @@ -12,9 +12,8 @@ {'repeats': 2, 'dim': 2}, {'repeats': [2, 3], 'dim': 1}, {'repeats': [3, 2, 1], 'dim': 3}, - {'repeats': [3, 2, 1], 'dim': 3}, {'repeats': 2, 'dim': None}, - {'repeats': [random.randint(1, 5) for _ in range(36)], 'dim': None})) + {'repeats': [36], 'dim': None})) class TestRepeatInterleaveConstRepeats(PytorchLayerTest): def _prepare_input(self): @@ -39,6 +38,9 @@ def forward(self, input_tensor): @pytest.mark.precommit def test_repeat_interleave_const_repeats(self, ie_device, precision, ir_version, input_data): repeats = input_data['repeats'] + if type(repeats) is list and len(repeats) == 1: + repeats = [random.randint(1, 5) for _ in range(repeats[0])] + dim = input_data['dim'] self._test(*self.create_model_const_repeat(repeats, dim), ie_device, precision, ir_version) diff --git a/tests/layer_tests/pytorch_tests/test_roi_align.py b/tests/layer_tests/pytorch_tests/test_roi_align.py index fb03c51b0914e0..574741aaa26db0 100644 --- a/tests/layer_tests/pytorch_tests/test_roi_align.py +++ b/tests/layer_tests/pytorch_tests/test_roi_align.py @@ -39,7 +39,9 @@ def forward(self, input_tensor, rois): return (torchvision_roi_align(output_size, spatial_scale, sampling_ratio, aligned), ref_net, "torchvision::roi_align") - @pytest.mark.parametrize('input_tensor', (np.random.randn(4, 5, 6, 7).astype(np.float32),)) + @pytest.mark.parametrize('input_shape', [ + [4, 5, 6, 7], + ]) @pytest.mark.parametrize('boxes', (np.array([[1, 2, 2, 3, 3]]).astype(np.float32), np.array([[0, 1, 2, 5, 4], [2, 1, 2, 5, 4], @@ -50,9 +52,9 @@ def forward(self, input_tensor, rois): @pytest.mark.parametrize('aligned', (True, False)) @pytest.mark.nightly @pytest.mark.precommit - def test_roi_align(self, ie_device, precision, ir_version, input_tensor, boxes, output_size, + def test_roi_align(self, ie_device, precision, ir_version, input_shape, boxes, output_size, spatial_scale, sampling_ratio, aligned): - self.input_tensor = input_tensor + self.input_tensor = np.random.randn(*input_shape).astype(np.float32) self.boxes = boxes self._test(*self.create_model(output_size, spatial_scale, sampling_ratio, aligned), ie_device, precision, ir_version, trace_model=True) diff --git a/tests/layer_tests/pytorch_tests/test_rsub.py b/tests/layer_tests/pytorch_tests/test_rsub.py index 9c144ad4da247b..68e36f8abd2167 100644 --- a/tests/layer_tests/pytorch_tests/test_rsub.py +++ b/tests/layer_tests/pytorch_tests/test_rsub.py @@ -34,24 +34,34 @@ def forward(self, x, y:int, alpha: float): return model(), ref_net, "aten::rsub" - @pytest.mark.parametrize('input_data', [(np.random.randn(2, 3, 4).astype(np.float32), - np.array(5).astype(np.float32), - np.random.randn(1)),]) - + @pytest.mark.parametrize('input_data', + [ + [[2, 3, 4], np.array(5).astype(np.float32), [1]] + ]) @pytest.mark.nightly @pytest.mark.precommit - def test_rsub_f(self, ie_device, precision, ir_version, input_data): - self.input_data = input_data + def test_rsub(self, ie_device, precision, ir_version, input_data): + self.input_data = [] + for input in input_data: + if type(input) is list: + self.input_data.append(np.random.randn(*input).astype(np.float32)) + else: + self.input_data.append(input) self._test(*self.create_model(second_type="float"), ie_device, precision, ir_version, use_convert_model=True) - @pytest.mark.parametrize('input_data', [(np.random.randn(2, 3, 4).astype(np.float32), - np.array(5).astype(int), - np.random.randn(1)),]) - + @pytest.mark.parametrize('input_data', + [ + [[2, 3, 4], np.array(5).astype(int), [1]] + ]) @pytest.mark.nightly @pytest.mark.precommit - def test_rsub_i(self, ie_device, precision, ir_version, input_data): - self.input_data = input_data + def test_rsub(self, ie_device, precision, ir_version, input_data): + self.input_data = [] + for input in input_data: + if type(input) is list: + self.input_data.append(np.random.randn(*input).astype(np.float32)) + else: + self.input_data.append(input) self._test(*self.create_model(second_type="int"), ie_device, precision, ir_version, use_convert_model=True) diff --git a/tests/layer_tests/pytorch_tests/test_sort.py b/tests/layer_tests/pytorch_tests/test_sort.py index c2f6243bb81a63..28ff2b7d485e56 100644 --- a/tests/layer_tests/pytorch_tests/test_sort.py +++ b/tests/layer_tests/pytorch_tests/test_sort.py @@ -36,11 +36,11 @@ def forward(self, input_tensor): ref_net = None return aten_sort(dim, descending, stable), ref_net, "aten::sort" - @pytest.mark.parametrize("input_tensor", [ - np.random.rand(16), - np.random.rand(1, 4), - np.random.rand(4, 4), - np.random.rand(4, 4, 4), + @pytest.mark.parametrize("input_shape", [ + [16], + [1, 4], + [4, 4], + [4, 4, 4], np.array([1, 2, 4, 6, 5, 8, 7]), np.array([6, 5, 4, 2, 3, 0, 1]), np.array([1, 1, 1, 2, 1, 3, 1, 4, 2, 5, 1, 2, 4, 4, 0]), @@ -78,9 +78,13 @@ def forward(self, input_tensor): ]) @pytest.mark.nightly @pytest.mark.precommit - def test_sort(self, input_tensor, descending, stable, ie_device, precision, ir_version): - self.input_tensor = input_tensor - dims = len(input_tensor.shape) + def test_sort(self, input_shape, descending, stable, ie_device, precision, ir_version): + self.input_tensor = [] + if type(input_shape) is list: + self.input_tensor = np.random.randn(*input_shape).astype(np.float32) + else: + self.input_tensor = input_shape + dims = len(self.input_tensor.shape) for dim in range(-dims, dims): self._test(*self.create_model(dim, descending, stable), ie_device, precision, ir_version) diff --git a/tests/layer_tests/pytorch_tests/test_stack.py b/tests/layer_tests/pytorch_tests/test_stack.py index 670033c7b294c1..50b44251e27ada 100644 --- a/tests/layer_tests/pytorch_tests/test_stack.py +++ b/tests/layer_tests/pytorch_tests/test_stack.py @@ -17,7 +17,7 @@ def create_model(self, dim): class aten_stack(torch.nn.Module): def __init__(self, dim): super(aten_stack, self).__init__() - self.dim = dim + self.dim = dim def forward(self, x, y): inputs = [x, y] @@ -27,18 +27,22 @@ def forward(self, x, y): return aten_stack(dim), ref_net, "aten::stack" - @pytest.mark.parametrize("input_tensor", ([ - [np.random.rand(1, 3, 3), np.random.rand(1, 3, 3)], - [np.random.rand(4, 4, 2), np.random.rand(4, 4, 2)], - [np.random.rand(8, 1, 1, 9), np.random.rand(8, 1, 1, 9)] - ])) + @pytest.mark.parametrize("input_shape", + [ + [1, 3, 3], + [4, 4, 2], + [8, 1, 1, 9] + ]) @pytest.mark.parametrize("dim", ([ 0, 1, 2, ])) @pytest.mark.nightly @pytest.mark.precommit - def test_stack2D(self, input_tensor, dim, ie_device, precision, ir_version): - self.input_tensors = input_tensor + def test_stack2D(self, input_shape, dim, ie_device, precision, ir_version): + self.input_tensors = [ + np.random.randn(*input_shape).astype(np.float32), + np.random.randn(*input_shape).astype(np.float32), + ] self._test(*self.create_model(dim), ie_device, precision, ir_version) @@ -52,7 +56,7 @@ def create_model(self, dim): class aten_stack(torch.nn.Module): def __init__(self, dim): super(aten_stack, self).__init__() - self.dim = dim + self.dim = dim def forward(self, x, y, z): inputs = [x, y, z] @@ -62,16 +66,21 @@ def forward(self, x, y, z): return aten_stack(dim), ref_net, "aten::stack" - @pytest.mark.parametrize("input_tensor", ([ - [np.random.rand(1, 3, 3), np.random.rand(1, 3, 3), np.random.rand(1, 3, 3)], - [np.random.rand(4, 4, 2), np.random.rand(4, 4, 2), np.random.rand(4, 4, 2)], - [np.random.rand(8, 1, 1, 9), np.random.rand(8, 1, 1, 9), np.random.rand(8, 1, 1, 9)] - ])) + @pytest.mark.parametrize("input_shape", + [ + [1, 3, 3], + [4, 4, 2], + [8, 1, 1, 9] + ]) @pytest.mark.parametrize("dim", ([ 0, 1, 2, ])) @pytest.mark.nightly @pytest.mark.precommit - def test_stack3D(self, input_tensor, dim, ie_device, precision, ir_version): - self.input_tensors = input_tensor + def test_stack3D(self, input_shape, dim, ie_device, precision, ir_version): + self.input_tensors = [ + np.random.randn(*input_shape).astype(np.float32), + np.random.randn(*input_shape).astype(np.float32), + np.random.randn(*input_shape).astype(np.float32) + ] self._test(*self.create_model(dim), ie_device, precision, ir_version) diff --git a/tests/layer_tests/pytorch_tests/test_sub.py b/tests/layer_tests/pytorch_tests/test_sub.py index 381d1672454cbe..5ba3f1a5506053 100644 --- a/tests/layer_tests/pytorch_tests/test_sub.py +++ b/tests/layer_tests/pytorch_tests/test_sub.py @@ -37,19 +37,22 @@ def _forward_inplace(self, x, y, alpha: float): return aten_sub(inplace), ref_net, op_name - @pytest.mark.parametrize('input_data', [(np.random.randn(2, 3, 4).astype(np.float32), - np.random.randn( - 2, 3, 4).astype(np.float32), - np.random.randn(1)), - (np.random.randn(4, 2, 3).astype(np.float32), - np.random.randn( - 1, 2, 3).astype(np.float32), - np.random.randn(1)), ]) + @pytest.mark.parametrize('input_shapes', + [ + [ + [2, 3, 4], [2, 3, 4], [1] + ], + [ + [4, 2, 3], [1, 2, 3], [1] + ] + ]) @pytest.mark.parametrize("inplace", [True, False]) @pytest.mark.nightly @pytest.mark.precommit - def test_sub(self, ie_device, precision, ir_version, input_data, inplace): - self.input_data = input_data + def test_sub(self, ie_device, precision, ir_version, input_shapes, inplace): + self.input_data = [] + for input_shape in input_shapes: + self.input_data.append(np.random.randn(*input_shape).astype(np.float32)) self._test(*self.create_model(inplace), ie_device, precision, ir_version, use_convert_model=True) diff --git a/tests/layer_tests/pytorch_tests/test_topk.py b/tests/layer_tests/pytorch_tests/test_topk.py index 675f7e1e98ec56..1b657f25ade1a5 100644 --- a/tests/layer_tests/pytorch_tests/test_topk.py +++ b/tests/layer_tests/pytorch_tests/test_topk.py @@ -32,9 +32,9 @@ def forward(self, input_tensor): return aten_topk(k, dim, largest, sort), ref_net, "aten::topk" - @pytest.mark.parametrize(("input_tensor"), [ - np.random.rand(7, 5, 5, 4), - np.random.rand(5, 6, 6, 7, 8), + @pytest.mark.parametrize(("input_shape"), [ + [7, 5, 5, 4], + [5, 6, 6, 7, 8] ]) @pytest.mark.parametrize(("k"), [ @@ -62,6 +62,6 @@ def forward(self, input_tensor): @pytest.mark.nightly @pytest.mark.precommit @pytest.mark.skipif(os.getenv("GITHUB_ACTIONS") == 'true', reason="Ticket - 115085") - def test_topK(self, input_tensor, k, dim, largest, sort, ie_device, precision, ir_version): - self.input_tensor = input_tensor + def test_topK(self, input_shape, k, dim, largest, sort, ie_device, precision, ir_version): + self.input_tensor = np.random.randn(*input_shape).astype(np.float32) self._test(*self.create_model(k, dim, largest, sort), ie_device, precision, ir_version) diff --git a/tests/layer_tests/pytorch_tests/test_unary_ops.py b/tests/layer_tests/pytorch_tests/test_unary_ops.py index 2f1e75753b1ebb..04346bdef48ef5 100644 --- a/tests/layer_tests/pytorch_tests/test_unary_ops.py +++ b/tests/layer_tests/pytorch_tests/test_unary_ops.py @@ -7,6 +7,44 @@ from pytorch_layer_test_class import PytorchLayerTest +OPS = { + "aten::rsqrt": torch.rsqrt, + "aten::sqrt": torch.sqrt, + "aten::exp": torch.exp, + "aten::exp_": torch.exp_, + "aten::relu": torch.relu, + "aten::relu_": torch.relu_, + "aten::ceil": torch.ceil, + "aten::ceil_": torch.ceil_, + "aten::floor": torch.floor, + "aten::floor_": torch.floor_, + "aten::sigmoid": torch.sigmoid, + "aten::sigmoid_": torch.sigmoid_, + "aten::cos": torch.cos, + "aten::cos_": torch.cos_, + "aten::sin": torch.sin, + "aten::sin_": torch.sin_, + "aten::tan": torch.tan, + "aten::tan_": torch.tan_, + "aten::cosh": torch.cosh, + "aten::cosh_": torch.cosh_, + "aten::sinh": torch.sinh, + "aten::sinh_": torch.sinh_, + "aten::tanh": torch.tanh, + "aten::tanh_": torch.tanh_, + "aten::acos": torch.acos, + "aten::acos_": torch.acos_, + "aten::asin": torch.asin, + "aten::asin_": torch.asin_, + "aten::atan": torch.atan, + "aten::atan_": torch.atan_, + "aten::acosh": torch.acosh, + "aten::acosh_": torch.acosh_, + "aten::asinh": torch.asinh, + "aten::asinh_": torch.asinh_, + "aten::atanh": torch.atanh, + "aten::atanh_": torch.atanh_ +} class unary_op_net(torch.nn.Module): def __init__(self, op, dtype): @@ -29,60 +67,62 @@ def _prepare_input(self): @pytest.mark.nightly @pytest.mark.precommit @pytest.mark.parametrize("dtype", [torch.float32, torch.float64, torch.int8, torch.uint8, torch.int32, torch.int64]) - @pytest.mark.parametrize("op,op_type", [ - (torch.rsqrt, "aten::rsqrt"), - (torch.sqrt, "aten::sqrt"), - (torch.exp, "aten::exp"), - (torch.relu, "aten::relu"), - (torch.relu_, "aten::relu_"), - (torch.ceil, "aten::ceil"), - (torch.ceil_, "aten::ceil_"), - (torch.floor, "aten::floor"), - (torch.floor_, "aten::floor_"), - (torch.sigmoid, "aten::sigmoid"), + @pytest.mark.parametrize("op_type", + [ + "aten::rsqrt", + "aten::sqrt", + "aten::exp", + "aten::relu", + "aten::relu_", + "aten::ceil", + "aten::ceil_", + "aten::floor", + "aten::floor_", + "aten::sigmoid", # trigonometry - (torch.cos, "aten::cos"), - (torch.sin, "aten::sin"), - (torch.tan, "aten::tan"), - (torch.cosh, "aten::cosh"), - (torch.sinh, "aten::sinh"), - (torch.tanh, "aten::tanh"), - (torch.acos, "aten::acos"), - (torch.asin, "aten::asin"), - (torch.atan, "aten::atan"), - (torch.acosh, "aten::acosh"), - (torch.asinh, "aten::asinh"), - (torch.atanh, "aten::atanh"), + "aten::cos", + "aten::sin", + "aten::tan", + "aten::cosh", + "aten::sinh", + "aten::tanh", + "aten::acos", + "aten::asin", + "aten::atan", + "aten::acosh", + "aten::asinh", + "aten::atanh" ]) - def test_unary_op(self, op, op_type, dtype, ie_device, precision, ir_version): + def test_unary_op(self, op_type, dtype, ie_device, precision, ir_version): self.dtype = dtype - self._test(unary_op_net(op, dtype), None, op_type, + self._test(unary_op_net(OPS[op_type], dtype), None, op_type, ie_device, precision, ir_version) @pytest.mark.nightly @pytest.mark.precommit @pytest.mark.parametrize("dtype", [torch.float32, torch.float64]) - @pytest.mark.parametrize("op,op_type", [ + @pytest.mark.parametrize("op_type", + [ # some pytorch inplace ops do not support int - (torch.exp_, "aten::exp_"), - (torch.sigmoid_, "aten::sigmoid_"), + "aten::exp_", + "aten::sigmoid_", # trigonometry - (torch.cos_, "aten::cos_"), - (torch.sin_, "aten::sin_"), - (torch.tan_, "aten::tan_"), - (torch.cosh_, "aten::cosh_"), - (torch.sinh_, "aten::sinh_"), - (torch.tanh_, "aten::tanh_"), - (torch.acos_, "aten::acos_"), - (torch.asin_, "aten::asin_"), - (torch.atan_, "aten::atan_"), - (torch.acosh_, "aten::acosh_"), - (torch.asinh_, "aten::asinh_"), - (torch.atanh_, "aten::atanh_"), + "aten::cos_", + "aten::sin_", + "aten::tan_", + "aten::cosh_", + "aten::sinh_", + "aten::tanh_", + "aten::acos_", + "aten::asin_", + "aten::atan_", + "aten::acosh_", + "aten::asinh_", + "aten::atanh_" ]) - def test_unary_op_float(self, op, op_type, dtype, ie_device, precision, ir_version): + def test_unary_op_float(self, op_type, dtype, ie_device, precision, ir_version): self.dtype = dtype - self._test(unary_op_net(op, dtype), None, op_type, + self._test(unary_op_net(OPS[op_type], dtype), None, op_type, ie_device, precision, ir_version) diff --git a/tests/layer_tests/pytorch_tests/test_unfold.py b/tests/layer_tests/pytorch_tests/test_unfold.py index b5d6ec787470b1..b4138fa772bb02 100644 --- a/tests/layer_tests/pytorch_tests/test_unfold.py +++ b/tests/layer_tests/pytorch_tests/test_unfold.py @@ -11,9 +11,10 @@ @pytest.mark.parametrize('dimension', (0, 1, 2)) @pytest.mark.parametrize('size', (1, 2)) @pytest.mark.parametrize('step', (1, 2, 3, 4)) -@pytest.mark.parametrize('input_tensor', (np.random.randn(2, 2, 5).astype(np.float32), - np.random.randn(3, 3, 3, 3).astype(np.float32), - np.random.randn(2, 3, 4, 5).astype(np.float32))) +@pytest.mark.parametrize('input_shape', +[ + [2, 2, 5], [3, 3, 3, 3], [2, 3, 4, 5] +]) class TestUnfold(PytorchLayerTest): def _prepare_input(self): @@ -37,7 +38,7 @@ def forward(self, input_tensor): @pytest.mark.nightly @pytest.mark.precommit - def test_unfold(self, ie_device, precision, ir_version, dimension, size, step, input_tensor): - self.input_tensor = input_tensor + def test_unfold(self, ie_device, precision, ir_version, dimension, size, step, input_shape): + self.input_tensor = np.random.randn(*input_shape).astype(np.float32) self._test(*self.create_model(dimension, size, step), ie_device, precision, ir_version) diff --git a/tests/layer_tests/pytorch_tests/test_view.py b/tests/layer_tests/pytorch_tests/test_view.py index 2d2c80633f7397..2b77c46f184a3f 100644 --- a/tests/layer_tests/pytorch_tests/test_view.py +++ b/tests/layer_tests/pytorch_tests/test_view.py @@ -8,8 +8,15 @@ from pytorch_layer_test_class import PytorchLayerTest -@pytest.mark.parametrize('input_data', [(np.random.randn(2, 3, 2), np.array(2), np.array(6)), - (np.random.randn(4), np.array(2), np.array(2))]) +@pytest.mark.parametrize('input_shapes', +[ + [ + [2, 3, 2], np.array(2), np.array(6) + ], + [ + [4], np.array(2), np.array(2) + ] +]) class TestViewListConstruct(PytorchLayerTest): def _prepare_input(self): @@ -27,11 +34,21 @@ def forward(self, input_tensor, dim1: int, dim2: int): @pytest.mark.nightly @pytest.mark.precommit - def test_view_list_construct(self, ie_device, precision, ir_version, input_data): - self.input_data = input_data + def test_view_list_construct(self, ie_device, precision, ir_version, input_shapes): + self.input_data = [] + for input_shape in input_shapes: + if type(input_shape) is list: + self.input_data.append(np.random.randn(*input_shape).astype(np.float32)) + else: + self.input_data.append(input_shape) self._test(*self.create_model(), ie_device, precision, ir_version) -@pytest.mark.parametrize('input_data', [(np.random.randn(4), np.array(2))]) +@pytest.mark.parametrize('input_shapes', +[ + [ + [4], np.array(2) + ] +]) class TestViewDtype(PytorchLayerTest): def _prepare_input(self): @@ -49,12 +66,22 @@ def forward(self, input_tensor, dtype): @pytest.mark.nightly @pytest.mark.precommit - def test_view_dtype(self, ie_device, precision, ir_version, input_data): - self.input_data = input_data + def test_view_dtype(self, ie_device, precision, ir_version, input_shapes): + self.input_data = [] + for input_shape in input_shapes: + if type(input_shape) is list: + self.input_data.append(np.random.randn(*input_shape).astype(np.float32)) + else: + self.input_data.append(input_shape) self._test(*self.create_model(), ie_device, precision, ir_version) -@pytest.mark.parametrize('input_data', [(np.random.randn(4), np.random.randn(2, 2))]) +@pytest.mark.parametrize('input_shapes', +[ + [ + [4], [2, 2] + ] +]) class TestViewSize(PytorchLayerTest): def _prepare_input(self): @@ -72,13 +99,27 @@ def forward(self, input_tensor, input_size): @pytest.mark.nightly @pytest.mark.precommit - def test_view_size(self, ie_device, precision, ir_version, input_data): - self.input_data = input_data + def test_view_size(self, ie_device, precision, ir_version, input_shapes): + self.input_data = [] + for input_shape in input_shapes: + if type(input_shape) is list: + self.input_data.append(np.random.randn(*input_shape).astype(np.float32)) + else: + self.input_data.append(input_shape) self._test(*self.create_model(), ie_device, precision, ir_version) -@pytest.mark.parametrize('input_data', [(np.random.randn(2, 3, 2), 2, 6), - (np.random.randn(4), 2, 2), - (np.random.randn(4), 2, 2.1)]) +@pytest.mark.parametrize('input_shapes', +[ + [ + [2, 3, 2], 2, 6 + ], + [ + [4], 2, 2 + ], + [ + [4], 2, 2.1 + ] +]) class TestView(PytorchLayerTest): def _prepare_input(self): @@ -101,6 +142,11 @@ def forward(self, input_tensor): @pytest.mark.nightly @pytest.mark.precommit - def test_view(self, ie_device, precision, ir_version, input_data): - self.input_data = input_data + def test_view(self, ie_device, precision, ir_version, input_shapes): + self.input_data = [] + for input_shape in input_shapes: + if type(input_shape) is list: + self.input_data.append(np.random.randn(*input_shape).astype(np.float32)) + else: + self.input_data.append(input_shape) self._test(*self.create_model(), ie_device, precision, ir_version) diff --git a/tools/ovc/CMakeLists.txt b/tools/ovc/CMakeLists.txt index cea078768604f7..959cc5d00bc720 100644 --- a/tools/ovc/CMakeLists.txt +++ b/tools/ovc/CMakeLists.txt @@ -35,6 +35,16 @@ install(DIRECTORY ${OpenVINOConverter_SOURCE_DIR}/openvino ${OV_CPACK_COMP_OVC_EXCLUDE_ALL} USE_SOURCE_PERMISSIONS) +# +# Tests +# +if(ENABLE_TESTS) + install(DIRECTORY unit_tests + DESTINATION tests/ovc + COMPONENT tests + EXCLUDE_FROM_ALL) +endif() + # # Cpack #