From 20ec04bfcc50be49ede6df5c60b4fbfef5b83a89 Mon Sep 17 00:00:00 2001 From: Ilya Lavrenov Date: Thu, 28 Sep 2023 12:03:46 +0400 Subject: [PATCH 01/57] Try to use vcpkg cache (#20102) --- .github/workflows/android_arm64.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/android_arm64.yml b/.github/workflows/android_arm64.yml index 96f686a8d94777..e4360eb08d3850 100644 --- a/.github/workflows/android_arm64.yml +++ b/.github/workflows/android_arm64.yml @@ -43,13 +43,15 @@ jobs: OPENVINO_REPO: '/__w/openvino/openvino/openvino' VCPKG_ROOT: '/__w/openvino/openvino/vcpkg' BUILD_DIR: '/__w/openvino/openvino/build' - INSTALL_DIR: '/__w/openvino/openvino/install' ANDROID_TOOLS: '/__w/openvino/openvino/android_tools' ANDROID_NDK_HOME: '/__w/openvino/openvino/android_tools/ndk-bundle' ANDROID_SDK_VERSION: 29 ANDROID_ABI_CONFIG: arm64-v8a + VCPKG_DEFAULT_BINARY_CACHE: '/mount/caches/ccache/android_arm64/vcpkg_cache' + VCPKG_FORCE_SYSTEM_BINARIES: '1' CCACHE_DIR: '/mount/caches/ccache/android_arm64' CCACHE_TEMPDIR: '/__w/openvino/openvino/ccache_temp' + CCACHE_COMPILERCHECK: 'content' CCACHE_MAXSIZE: 50G steps: - name: Install git @@ -106,6 +108,7 @@ jobs: - name: Build vcpkg run: | + mkdir -p ${VCPKG_DEFAULT_BINARY_CACHE} ${VCPKG_ROOT}/bootstrap-vcpkg.sh # patch vcpkg default toolchain to build only Release configuration echo "set(VCPKG_BUILD_TYPE release)" >> ${VCPKG_ROOT}/triplets/arm64-android.cmake From 1be993dd39c146800947e3c8b2e6fd27fb0bba6e Mon Sep 17 00:00:00 2001 From: Ilya Lavrenov Date: Thu, 28 Sep 2023 12:11:14 +0400 Subject: [PATCH 02/57] [GHA] Don't build documentation in post-commit (#20099) --- .github/workflows/build_doc.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/build_doc.yml b/.github/workflows/build_doc.yml index 9e61875f563073..b7e688d55f8c4a 100644 --- a/.github/workflows/build_doc.yml +++ b/.github/workflows/build_doc.yml @@ -1,10 +1,6 @@ name: Documentation on: pull_request: - push: - branches: - - 'master' - - 'releases/**' env: DOXY_VER: '1.9.6' From fea6db1a5f595128bd338facc6c99d5347ad41a3 Mon Sep 17 00:00:00 2001 From: Maxim Vafin Date: Thu, 28 Sep 2023 10:52:09 +0200 Subject: [PATCH 03/57] [PT FE] Fix issue when cat input is folded to tensor (#20090) * [PT FE] Fix issue when cat input is folded to tensor * CHeck real first input * Update src/frontends/pytorch/src/op/cat.cpp --- src/frontends/pytorch/src/input_model.cpp | 4 +-- src/frontends/pytorch/src/op/cat.cpp | 31 +++++++++++++++---- .../layer_tests/pytorch_tests/test_linear.py | 28 +++++++++++++++++ 3 files changed, 55 insertions(+), 8 deletions(-) diff --git a/src/frontends/pytorch/src/input_model.cpp b/src/frontends/pytorch/src/input_model.cpp index 78400ad91785f7..bce1937151d92d 100644 --- a/src/frontends/pytorch/src/input_model.cpp +++ b/src/frontends/pytorch/src/input_model.cpp @@ -141,7 +141,7 @@ void InputModel::override_all_inputs(const std::vector& inputs) { "Number of inputs provided is incorrect. Graph modification is not supported for " "this model. Expected number of inputs: ", m_inputs.size() - 1, - " recieved ", + " received ", inputs.size()); auto self_place = m_inputs[0]; // Verify that no same place already in vector @@ -158,7 +158,7 @@ void InputModel::override_all_inputs(const std::vector& inputs) { "Number of inputs provided is incorrect. Graph modification is not supported for " "this model. Expected number of inputs: ", m_inputs.size(), - " recieved ", + " received ", inputs.size()); m_inputs = inputs; } diff --git a/src/frontends/pytorch/src/op/cat.cpp b/src/frontends/pytorch/src/op/cat.cpp index 7c2a43f0c38ff5..63e61734544333 100644 --- a/src/frontends/pytorch/src/op/cat.cpp +++ b/src/frontends/pytorch/src/op/cat.cpp @@ -5,6 +5,10 @@ #include "openvino/frontend/pytorch/node_context.hpp" #include "openvino/op/concat.hpp" #include "openvino/op/parameter.hpp" +#include "openvino/op/reshape.hpp" +#include "openvino/op/scatter_elements_update.hpp" +#include "openvino/op/shape_of.hpp" +#include "openvino/op/slice.hpp" #include "pt_framework_node.hpp" #include "utils.hpp" #include "utils_quantize.hpp" @@ -28,12 +32,27 @@ OutputVector translate_cat_common(const NodeContext& context, attrs["axis"] = std::to_string(axis); fw_node->set_attrs(attrs); return {context.mark_node(fw_node)}; - } else { - auto first_elem = list_elems.front().get_node_shared_ptr(); - FRONT_END_OP_CONVERSION_CHECK( - list_elems.size() > 1 || !ov::as_type_ptr(first_elem), - "::cat is located inside body while inputs are located outside of the body. " - "This case is not supported."); + } + auto first_node = list_elems.front().get_node_shared_ptr(); + FRONT_END_OP_CONVERSION_CHECK( + list_elems.size() > 1 || !ov::as_type_ptr(first_node), + "::cat is located inside body while inputs are located outside of the body. " + "This case is not supported."); + if (list_elems.size() == 1 && + !std::dynamic_pointer_cast(context.get_input(0).get_node_shared_ptr())) { + // Case when list was merged into tensor + auto tensor = list_elems[0]; + auto shape = context.mark_node(std::make_shared(tensor, element::i32)); + auto zero = context.mark_node(v0::Constant::create(element::i32, Shape{}, {0})); + auto neg_1 = context.mark_node(v0::Constant::create(element::i32, Shape{1}, {-1})); + auto axis_const = context.mark_node(v0::Constant::create(element::i32, Shape{1}, {axis})); + auto one = context.mark_node(v0::Constant::create(element::i32, Shape{1}, {1})); + auto int_max = + context.mark_node(v0::Constant::create(element::i32, Shape{1}, {std::numeric_limits().max()})); + auto shape_sliced = context.mark_node(std::make_shared(shape, one, int_max, one)); + auto new_shape = + context.mark_node(std::make_shared(shape_sliced, axis_const, neg_1, zero)); + return {context.mark_node(std::make_shared(tensor, new_shape, false))}; } auto concat = std::make_shared(OutputVector(list_elems.begin(), list_elems.end()), axis); return {context.mark_node(concat)}; diff --git a/tests/layer_tests/pytorch_tests/test_linear.py b/tests/layer_tests/pytorch_tests/test_linear.py index 4b7d9d58b1b458..7093eb507ddaba 100644 --- a/tests/layer_tests/pytorch_tests/test_linear.py +++ b/tests/layer_tests/pytorch_tests/test_linear.py @@ -48,3 +48,31 @@ def forward2(self, m1, m2, bias): def test_matmul(self, kwargs_to_prepare_input, ie_device, precision, ir_version): self._test(*self.create_model(len(kwargs_to_prepare_input) == 3), ie_device, precision, ir_version, kwargs_to_prepare_input=kwargs_to_prepare_input) + + +class TestLinearBiasList(PytorchLayerTest): + def _prepare_input(self): + import numpy as np + return (np.random.randn(1, 15, 10).astype(np.float32), np.random.randn(66, 10).astype(np.float32)) + + def create_model(self): + import torch + + class aten_mm(torch.nn.Module): + def __init__(self): + super(aten_mm, self).__init__() + self.bias = [torch.randn(22), + torch.randn(22), + torch.randn(22)] + + def forward(self, m1, m2): + m2 = m2.reshape([66, -1]) + return torch.nn.functional.linear(m1, m2, torch.cat(self.bias, 0)) + + return aten_mm(), None, "aten::linear" + + @pytest.mark.nightly + @pytest.mark.precommit + def test_linear_bias_list(self, ie_device, precision, ir_version): + self._test(*self.create_model(), ie_device, precision, ir_version, + trace_model=True, freeze_model=False) From b0507b99184dc732fa063ad20f4ba4b34b139a89 Mon Sep 17 00:00:00 2001 From: Maciej Smyk Date: Thu, 28 Sep 2023 11:03:58 +0200 Subject: [PATCH 04/57] Update release_notes.md (#20113) --- docs/articles_en/about_openvino/release_notes.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/articles_en/about_openvino/release_notes.md b/docs/articles_en/about_openvino/release_notes.md index 0392a84c975082..9d7427f919d6ad 100644 --- a/docs/articles_en/about_openvino/release_notes.md +++ b/docs/articles_en/about_openvino/release_notes.md @@ -4,7 +4,7 @@ .. raw:: html - + .. toctree:: @@ -12,7 +12,7 @@ prerelease_information -The official OpenVINO Release Notes are published at `www.intel.com `__ +The official OpenVINO Release Notes are published at `www.intel.com `__ @endsphinxdirective \ No newline at end of file From 7dd5d9720c78e05e63d4eb1ac7ffea3f37a49b98 Mon Sep 17 00:00:00 2001 From: Sebastian Golebiewski Date: Thu, 28 Sep 2023 11:09:14 +0200 Subject: [PATCH 05/57] Changing file structure of documentation gapi section of docs (#20107) --- .../documentation}/media_processing_cv_libraries.md | 0 .../documentation/media_processing_cv_libraries}/dlstreamer.md | 0 .../documentation/media_processing_cv_libraries}/gapi_intro.md | 0 .../gapi_intro}/face_beautification.md | 0 .../gapi_intro}/gapi_face_analytics_pipeline.md | 0 .../media_processing_cv_libraries/gapi_intro}/kernel_api.md | 0 6 files changed, 0 insertions(+), 0 deletions(-) rename docs/{Documentation => articles_en/documentation}/media_processing_cv_libraries.md (100%) rename docs/{ => articles_en/documentation/media_processing_cv_libraries}/dlstreamer.md (100%) rename docs/{gapi => articles_en/documentation/media_processing_cv_libraries}/gapi_intro.md (100%) rename docs/{gapi => articles_en/documentation/media_processing_cv_libraries/gapi_intro}/face_beautification.md (100%) rename docs/{gapi => articles_en/documentation/media_processing_cv_libraries/gapi_intro}/gapi_face_analytics_pipeline.md (100%) rename docs/{gapi => articles_en/documentation/media_processing_cv_libraries/gapi_intro}/kernel_api.md (100%) diff --git a/docs/Documentation/media_processing_cv_libraries.md b/docs/articles_en/documentation/media_processing_cv_libraries.md similarity index 100% rename from docs/Documentation/media_processing_cv_libraries.md rename to docs/articles_en/documentation/media_processing_cv_libraries.md diff --git a/docs/dlstreamer.md b/docs/articles_en/documentation/media_processing_cv_libraries/dlstreamer.md similarity index 100% rename from docs/dlstreamer.md rename to docs/articles_en/documentation/media_processing_cv_libraries/dlstreamer.md diff --git a/docs/gapi/gapi_intro.md b/docs/articles_en/documentation/media_processing_cv_libraries/gapi_intro.md similarity index 100% rename from docs/gapi/gapi_intro.md rename to docs/articles_en/documentation/media_processing_cv_libraries/gapi_intro.md diff --git a/docs/gapi/face_beautification.md b/docs/articles_en/documentation/media_processing_cv_libraries/gapi_intro/face_beautification.md similarity index 100% rename from docs/gapi/face_beautification.md rename to docs/articles_en/documentation/media_processing_cv_libraries/gapi_intro/face_beautification.md diff --git a/docs/gapi/gapi_face_analytics_pipeline.md b/docs/articles_en/documentation/media_processing_cv_libraries/gapi_intro/gapi_face_analytics_pipeline.md similarity index 100% rename from docs/gapi/gapi_face_analytics_pipeline.md rename to docs/articles_en/documentation/media_processing_cv_libraries/gapi_intro/gapi_face_analytics_pipeline.md diff --git a/docs/gapi/kernel_api.md b/docs/articles_en/documentation/media_processing_cv_libraries/gapi_intro/kernel_api.md similarity index 100% rename from docs/gapi/kernel_api.md rename to docs/articles_en/documentation/media_processing_cv_libraries/gapi_intro/kernel_api.md From 7761fc754cefde0e76a8528a1a87a28dccd477b6 Mon Sep 17 00:00:00 2001 From: Roman Kazantsev Date: Thu, 28 Sep 2023 13:10:39 +0400 Subject: [PATCH 06/57] [Hub Tests] Move TF Hub tests to AKS runners (#20049) * [Hub Tests] Move Hub tests to self-host runners Signed-off-by: Kazantsev, Roman * Not all directories possible to clean up * Move Hub models tests to AKS nodes * Add install actions python setup * Add ca-certificate deps to install * Fix bug for PT models * Update .github/workflows/linux.yml Co-authored-by: Ilya Lavrenov * Update .github/workflows/linux.yml * Revert changes for PT models tests Signed-off-by: Kazantsev, Roman * Install correct version of OV --------- Signed-off-by: Kazantsev, Roman Co-authored-by: Ilya Lavrenov --- .github/workflows/linux.yml | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 60dc3d8c7c7be7..51b550e6e960a1 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -874,7 +874,11 @@ jobs: defaults: run: shell: bash - runs-on: ${{ github.event_name == 'schedule' && 'ubuntu-20.04-8-cores' || 'ubuntu-20.04'}} + runs-on: ${{ github.event_name == 'schedule' && 'aks-linux-16-cores' || 'aks-linux-4-cores'}} + container: + image: openvinogithubactions.azurecr.io/dockerhub/ubuntu:20.04 + volumes: + - /mount/caches:/mount/caches env: INSTALL_DIR: ${{ github.workspace }}/install INSTALL_TEST_DIR: ${{ github.workspace }}/install/tests @@ -882,7 +886,10 @@ jobs: steps: - name: Create Directories - run: mkdir -p ${{ env.INSTALL_DIR }} ${{ env.INSTALL_TEST_DIR }} + run: mkdir -p ${INSTALL_DIR} ${INSTALL_TEST_DIR} + + - 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: @@ -902,26 +909,25 @@ jobs: - name: Extract OpenVINO packages run: | - pushd ${{ env.INSTALL_DIR }} - tar -xzf openvino_package.tar.gz -C ${{ env.INSTALL_DIR }} && rm openvino_package.tar.gz || exit 1 + pushd ${INSTALL_DIR} + tar -xzf openvino_package.tar.gz -C ${INSTALL_DIR} && rm openvino_package.tar.gz || exit 1 popd - pushd ${{ env.INSTALL_TEST_DIR }} - tar -xzf openvino_tests.tar.gz -C ${{ env.INSTALL_DIR }} && rm openvino_tests.tar.gz || exit 1 + pushd ${INSTALL_TEST_DIR} + tar -xzf openvino_tests.tar.gz -C ${INSTALL_DIR} && rm openvino_tests.tar.gz || exit 1 popd - name: Install OpenVINO Python wheels - run: | - python3 -m pip install openvino --find-links=${{ env.INSTALL_DIR }}/tools + run: python3 -m pip install ${INSTALL_DIR}/tools/openvino-* - name: Install TF Hub tests requirements run: | - python3 -m pip install -r ${{ env.MODEL_HUB_TESTS_INSTALL_DIR }}/tf_hub_tests/requirements.txt + python3 -m pip install -r ${MODEL_HUB_TESTS_INSTALL_DIR}/tf_hub_tests/requirements.txt - name: TensorFlow Hub Tests - TF FE run: | - export PYTHONPATH=${{ env.MODEL_HUB_TESTS_INSTALL_DIR }}:$PYTHONPATH - python3 -m pytest ${{ env.MODEL_HUB_TESTS_INSTALL_DIR }}/tf_hub_tests/ -m ${{ env.TYPE }} --html=${{ env.INSTALL_TEST_DIR }}/TEST-tf_hub_tf_fe.html --self-contained-html + export PYTHONPATH=${MODEL_HUB_TESTS_INSTALL_DIR}:$PYTHONPATH + python3 -m pytest ${MODEL_HUB_TESTS_INSTALL_DIR}/tf_hub_tests/ -m ${TYPE} --html=${INSTALL_TEST_DIR}/TEST-tf_hub_tf_fe.html --self-contained-html -v env: TYPE: ${{ github.event_name == 'schedule' && 'nightly' || 'precommit'}} TEST_DEVICE: CPU From 886be26c0bfea099eee3644c2c362aca7e05c61a Mon Sep 17 00:00:00 2001 From: Sergey Shlyapnikov Date: Thu, 28 Sep 2023 13:39:41 +0400 Subject: [PATCH 07/57] [GPU] Add handling of unsupported simd8 for PVC (#20093) --- .../convolution_kernel_b_fs_yx_fsv_16_32_imad_dw.cpp | 3 +++ .../kernel_selector/kernels/gemm/gemm_kernel_mmad_int8.cpp | 4 ++++ .../kernels/gemm/gemm_kernel_mmad_int8_slm.cpp | 3 +++ .../kernel_selector/kernels/gemm/gemm_kernel_tiled_opt.cpp | 2 +- 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_b_fs_yx_fsv_16_32_imad_dw.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_b_fs_yx_fsv_16_32_imad_dw.cpp index c7d80a8c8096ce..105930edb9423c 100644 --- a/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_b_fs_yx_fsv_16_32_imad_dw.cpp +++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_b_fs_yx_fsv_16_32_imad_dw.cpp @@ -213,6 +213,9 @@ bool ConvolutionKernel_b_fs_yx_fsv_16_32_imad_dw::ValidateAutoTuneParams(const c const AutoTuneParams& tparams) const { bool valid_tune_params = true; + if (!IsSIMDSizeSupported(params.engineInfo, tparams.simd)) + return false; + auto total_lws = tparams.simd * tparams.lws0 * tparams.lws1; valid_tune_params &= total_lws <= params.engineInfo.maxWorkGroupSize; diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/gemm/gemm_kernel_mmad_int8.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/gemm/gemm_kernel_mmad_int8.cpp index 1fab54da075335..0f67b5b99e2884 100644 --- a/src/plugins/intel_gpu/src/kernel_selector/kernels/gemm/gemm_kernel_mmad_int8.cpp +++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/gemm/gemm_kernel_mmad_int8.cpp @@ -183,6 +183,10 @@ bool GemmKernelMMADint8::Validate(const Params& params, const optional_params& o (input1_type != Datatype::UINT8 && input1_type != Datatype::INT8)) return false; + GemmTuningData tuning_data = SetTuningParams(gmm_params); + if (!IsSIMDSizeSupported(params.engineInfo, tuning_data.simd_size)) + return false; + return true; } } // namespace kernel_selector diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/gemm/gemm_kernel_mmad_int8_slm.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/gemm/gemm_kernel_mmad_int8_slm.cpp index 16119fd5b72440..b7c8100189fcec 100644 --- a/src/plugins/intel_gpu/src/kernel_selector/kernels/gemm/gemm_kernel_mmad_int8_slm.cpp +++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/gemm/gemm_kernel_mmad_int8_slm.cpp @@ -161,6 +161,9 @@ bool GemmKernelMMADslmInt8::Validate(const Params& params, const optional_params if (HasLeftovers(tuning_data)) return false; + if (!IsSIMDSizeSupported(params.engineInfo, tuning_data.simd_size)) + return false; + if ((input0_type != Datatype::UINT8 && input0_type != Datatype::INT8) || (input1_type != Datatype::UINT8 && input1_type != Datatype::INT8)) return false; diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/gemm/gemm_kernel_tiled_opt.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/gemm/gemm_kernel_tiled_opt.cpp index e0c4eabaeab18e..7d8a1dceb178c8 100644 --- a/src/plugins/intel_gpu/src/kernel_selector/kernels/gemm/gemm_kernel_tiled_opt.cpp +++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/gemm/gemm_kernel_tiled_opt.cpp @@ -83,7 +83,7 @@ GemmKernelTiledOpt::GemmTuningData GemmKernelTiledOpt::SetTuningParams(const gem bool leftovers = m_size % tuning_data.tile_m_size || k_size % tuning_data.tile_k_size || n_size % tuning_data.tile_n_size; - if (leftovers || total_batches > 1 || params.transpose_input0 || params.transpose_input1) { + if (leftovers || total_batches > 1 || params.transpose_input0 || params.transpose_input1 || !IsSIMDSizeSupported(params.engineInfo, 8)) { tuning_data.simd_size = 16; tuning_data.tile_n_size = tuning_data.simd_size; tuning_data.tile_k_size = tuning_data.simd_size; From f9678a285c9373e86ac459fd4d4c103e91036b9d Mon Sep 17 00:00:00 2001 From: Sergey Shlyapnikov Date: Thu, 28 Sep 2023 13:53:51 +0400 Subject: [PATCH 08/57] [GPU] Do not use usm_host memory buffers for PVC as a device inputs (#19767) --- .../src/plugin/sync_infer_request.cpp | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) 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 2e6699333070f9..d5ee5d423fcd13 100644 --- a/src/plugins/intel_gpu/src/plugin/sync_infer_request.cpp +++ b/src/plugins/intel_gpu/src/plugin/sync_infer_request.cpp @@ -28,6 +28,19 @@ namespace { +inline bool can_use_usm_host(const cldnn::engine& engine) { + auto can_use_usm = engine.use_unified_shared_memory(); + + // WA: Disable USM host memory for infer request`s tensors for PVC as + // it has performance issues in case of host <-> device data transfers inside kernels + // Use unsupported SIMD8 as unique attribute of PVC + auto supported_simd_sizes = engine.get_device_info().supported_simd_sizes; + if (std::find(supported_simd_sizes.begin(), supported_simd_sizes.end(), 8) == supported_simd_sizes.end()) + can_use_usm = false; + + return can_use_usm; +} + inline std::string get_port_name(const ov::Output& port, const bool is_legacy_api) { std::string name; // TODO: Should use tensor name as the port name, but many legacy tests still use legacy name @@ -480,6 +493,10 @@ std::shared_ptr SyncInferRequest::create_device_tensor(const ov::Sh tensor_type = TensorType::BT_BUF_INTERNAL; } + // Create OpenCL buffer for PVC if lockable memory is needed due to performance issue with usm host + if (!can_use_usm_host(m_graph->get_engine()) && need_lockable_memory) + tensor_type = TensorType::BT_BUF_INTERNAL; + // Currently, clDeviceMemAllocINTEL returns memory address allocated to other input blob if the current blob is empty // W/A for this issue: // Allocate with non-empty shape and then reinterprete with original shape @@ -512,7 +529,9 @@ TensorWrapper SyncInferRequest::create_or_share_device_tensor(const TensorWrappe auto input_ptr = user_tensor->data(); const auto alloc_type = m_graph->get_engine().detect_usm_allocation_type(input_ptr); const auto is_usm_host = alloc_type == cldnn::allocation_type::usm_host; - bool can_share = is_usm_host && !is_convert_required(user_tensor->get_element_type(), element_type); + bool can_share = is_usm_host && + !is_convert_required(user_tensor->get_element_type(), element_type) && + can_use_usm_host(m_graph->get_engine()); if (can_share) { // For USM case we create host blob using custom USM host allocator From 197e954846aa8d434f9bb86672d4b138d2b34bd1 Mon Sep 17 00:00:00 2001 From: Pawel Raasz Date: Thu, 28 Sep 2023 12:12:21 +0200 Subject: [PATCH 09/57] [core]Migrate reduce ops max min mean prod sum evaluate to new API (#19756) * Migrate ReduceL1, ReduceL2 to new API - add some new utils which are deprecated * Hide helper functions from public API * Migrate reductions ops to new API * Migrate get_constant_from_source to dev API * Rename ref max to reduce_max * Rename ref min to reduce_min * Rename ref mean to reduce_mean * Rename ref sum to reduce_sum * Rename ref product to reduce_prod - minor optimization in ReduceProd operator * Restore custom isfinite for ov float types * Fix type name in reduce_max.hpp * Add missing include in shape_util.hpp * Make count same type as data type in reduce mean * Correct reduce sum doxy comment --- src/core/dev_api/validation_util.hpp | 9 ++ src/core/include/openvino/op/reduce_max.hpp | 4 +- src/core/include/openvino/op/reduce_mean.hpp | 4 +- src/core/include/openvino/op/reduce_min.hpp | 4 +- src/core/include/openvino/op/reduce_prod.hpp | 4 +- src/core/include/openvino/op/reduce_sum.hpp | 4 +- .../reference/group_normalization.hpp | 8 +- .../openvino/reference/log_softmax.hpp | 8 +- .../include/openvino/reference/max.hpp | 46 ------ .../include/openvino/reference/mean.hpp | 58 -------- .../include/openvino/reference/min.hpp | 51 ------- .../include/openvino/reference/mvn.hpp | 12 +- .../openvino/reference/normalize_l2.hpp | 4 +- .../include/openvino/reference/product.hpp | 39 ----- .../include/openvino/reference/reduce_l1.hpp | 2 +- .../include/openvino/reference/reduce_max.hpp | 46 ++++++ .../openvino/reference/reduce_mean.hpp | 36 +++++ .../include/openvino/reference/reduce_min.hpp | 46 ++++++ .../openvino/reference/reduce_prod.hpp | 42 ++++++ .../include/openvino/reference/reduce_sum.hpp | 94 +++++++++++++ .../include/openvino/reference/softmax.hpp | 8 +- .../include/openvino/reference/sum.hpp | 84 ----------- src/core/reference/src/op/einsum.cpp | 6 +- src/core/shape_inference/include/utils.hpp | 9 +- src/core/src/op/reduce_l1.cpp | 4 +- src/core/src/op/reduce_l2.cpp | 2 +- src/core/src/op/reduce_max.cpp | 109 ++++++-------- src/core/src/op/reduce_mean.cpp | 104 ++++++-------- src/core/src/op/reduce_min.cpp | 108 ++++++-------- src/core/src/op/reduce_prod.cpp | 133 ++++++++---------- src/core/src/op/reduce_sum.cpp | 105 ++++++-------- src/core/src/op/util/axes_util.cpp | 2 +- src/core/src/op/util/reduction_base.cpp | 11 +- src/core/src/validation_util.cpp | 24 +++- 34 files changed, 567 insertions(+), 663 deletions(-) delete mode 100644 src/core/reference/include/openvino/reference/max.hpp delete mode 100644 src/core/reference/include/openvino/reference/mean.hpp delete mode 100644 src/core/reference/include/openvino/reference/min.hpp delete mode 100644 src/core/reference/include/openvino/reference/product.hpp create mode 100644 src/core/reference/include/openvino/reference/reduce_max.hpp create mode 100644 src/core/reference/include/openvino/reference/reduce_mean.hpp create mode 100644 src/core/reference/include/openvino/reference/reduce_min.hpp create mode 100644 src/core/reference/include/openvino/reference/reduce_prod.hpp create mode 100644 src/core/reference/include/openvino/reference/reduce_sum.hpp delete mode 100644 src/core/reference/include/openvino/reference/sum.hpp diff --git a/src/core/dev_api/validation_util.hpp b/src/core/dev_api/validation_util.hpp index 452445a055b8a5..fe607828c80148 100644 --- a/src/core/dev_api/validation_util.hpp +++ b/src/core/dev_api/validation_util.hpp @@ -38,5 +38,14 @@ OPENVINO_API int64_t clip(const int64_t& value, const int64_t& min, const int64_ /// /// \return Constant node or nullptr if unable to constantfold the subgraph OPENVINO_API std::shared_ptr constantfold_subgraph(const Output& subgraph_sink); + +/** + * @brief Runs an estimation of source tensor. If it succeeded to calculate both bounds and + * they are the same returns Constant operation from the resulting bound, otherwise nullptr. + * + * @param source Node output used to get its tensor data as constant. + * @return Shared pointer to constant data or nullptr. + */ +OPENVINO_API std::shared_ptr get_constant_from_source(const Output& source); } // namespace util } // namespace ov diff --git a/src/core/include/openvino/op/reduce_max.hpp b/src/core/include/openvino/op/reduce_max.hpp index 594450d69d9532..1e8e508b30c637 100644 --- a/src/core/include/openvino/op/reduce_max.hpp +++ b/src/core/include/openvino/op/reduce_max.hpp @@ -26,9 +26,7 @@ class OPENVINO_API ReduceMax : public util::ArithmeticReductionKeepDims { 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; bool evaluate_lower(TensorVector& outputs) const override; bool evaluate_upper(TensorVector& outputs) const override; diff --git a/src/core/include/openvino/op/reduce_mean.hpp b/src/core/include/openvino/op/reduce_mean.hpp index 7b50dd57b7dafc..f8c4bb9bf91eb2 100644 --- a/src/core/include/openvino/op/reduce_mean.hpp +++ b/src/core/include/openvino/op/reduce_mean.hpp @@ -24,9 +24,7 @@ class OPENVINO_API ReduceMean : public util::ArithmeticReductionKeepDims { 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; }; } // namespace v1 diff --git a/src/core/include/openvino/op/reduce_min.hpp b/src/core/include/openvino/op/reduce_min.hpp index 830021a0bb2ae0..0fe90c35caf7ec 100644 --- a/src/core/include/openvino/op/reduce_min.hpp +++ b/src/core/include/openvino/op/reduce_min.hpp @@ -26,9 +26,7 @@ class OPENVINO_API ReduceMin : public util::ArithmeticReductionKeepDims { 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; bool evaluate_lower(TensorVector& outputs) const override; bool evaluate_upper(TensorVector& outputs) const override; diff --git a/src/core/include/openvino/op/reduce_prod.hpp b/src/core/include/openvino/op/reduce_prod.hpp index 4a9af6339b6797..d53ba7ca4049a2 100644 --- a/src/core/include/openvino/op/reduce_prod.hpp +++ b/src/core/include/openvino/op/reduce_prod.hpp @@ -27,9 +27,7 @@ class OPENVINO_API ReduceProd : public util::ArithmeticReductionKeepDims { 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; bool evaluate_lower(TensorVector& outputs) const override; bool evaluate_upper(TensorVector& outputs) const override; diff --git a/src/core/include/openvino/op/reduce_sum.hpp b/src/core/include/openvino/op/reduce_sum.hpp index 7a3221c68e52ef..8a210c60986fdf 100644 --- a/src/core/include/openvino/op/reduce_sum.hpp +++ b/src/core/include/openvino/op/reduce_sum.hpp @@ -73,9 +73,7 @@ class OPENVINO_API ReduceSum : public util::ArithmeticReductionKeepDims { 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; }; } // namespace v1 diff --git a/src/core/reference/include/openvino/reference/group_normalization.hpp b/src/core/reference/include/openvino/reference/group_normalization.hpp index 35a215b7123757..d6e5602a586742 100644 --- a/src/core/reference/include/openvino/reference/group_normalization.hpp +++ b/src/core/reference/include/openvino/reference/group_normalization.hpp @@ -8,8 +8,8 @@ #include #include "openvino/core/shape.hpp" -#include "openvino/reference/mean.hpp" -#include "openvino/reference/sum.hpp" +#include "openvino/reference/reduce_mean.hpp" +#include "openvino/reference/reduce_sum.hpp" namespace ov { namespace reference { @@ -38,11 +38,11 @@ void group_normalization(const T* const data, const auto group_begin = data + n * batch_size + g * group_size; const auto group_end = group_begin + group_size; std::vector mean_value(1); - mean(group_begin, mean_value.data(), Shape{group_size}, {0}); + reduce_mean(group_begin, mean_value.data(), Shape{group_size}, {0}); T mean = mean_value[0]; T variance = 0, err = 0; for_each(group_begin, group_end, [&](const T d) { - return details::kahan_summation(static_cast(pow(d - mean, 2)), err, variance); + variance = details::kahan_summation(static_cast(pow(d - mean, 2)), variance, err); }); variance /= group_size; const T standard_deviation = sqrt(variance + eps); diff --git a/src/core/reference/include/openvino/reference/log_softmax.hpp b/src/core/reference/include/openvino/reference/log_softmax.hpp index fb5d455b28a330..7335bd36989b18 100644 --- a/src/core/reference/include/openvino/reference/log_softmax.hpp +++ b/src/core/reference/include/openvino/reference/log_softmax.hpp @@ -7,8 +7,8 @@ #include #include "ngraph/shape_util.hpp" -#include "openvino/reference/max.hpp" -#include "openvino/reference/sum.hpp" +#include "openvino/reference/reduce_max.hpp" +#include "openvino/reference/reduce_sum.hpp" #include "openvino/reference/utils/coordinate_transform.hpp" namespace ov { @@ -21,7 +21,7 @@ void log_softmax(const T* arg, T* out, const Shape& shape, const AxisSet& axes) auto temp_max = std::vector(temp_elements, 0); auto temp_sum = std::vector(temp_elements, 0); - max(arg, temp_max.data(), shape, axes); + reduce_max(arg, temp_max.data(), shape, axes); CoordinateTransform transform(shape); CoordinateTransform temp_transform(temp_shape); @@ -31,7 +31,7 @@ void log_softmax(const T* arg, T* out, const Shape& shape, const AxisSet& axes) static_cast(std::exp(arg[transform.index(coord)] - temp_max[temp_transform.index(temp_coord)])); } - sum(out, temp_sum.data(), shape, axes); + reduce_sum(out, temp_sum.data(), shape, axes); for (const Coordinate& coord : transform) { Coordinate temp_coord = ngraph::reduce(coord, axes, true); diff --git a/src/core/reference/include/openvino/reference/max.hpp b/src/core/reference/include/openvino/reference/max.hpp deleted file mode 100644 index 0cbb810ecafbe5..00000000000000 --- a/src/core/reference/include/openvino/reference/max.hpp +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include -#include -#include - -#include "ngraph/shape_util.hpp" -#include "openvino/reference/utils/coordinate_transform.hpp" - -namespace ov { -namespace reference { -template -void max(const T* arg, T* out, const Shape& in_shape, const AxisSet& reduction_axes) { - T minval = std::numeric_limits::lowest(); - - constexpr bool dont_keep_dims_in_output = false; - OPENVINO_SUPPRESS_DEPRECATED_START - const auto out_shape = ngraph::reduce(in_shape, reduction_axes, dont_keep_dims_in_output); - std::fill(out, out + shape_size(out_shape), minval); - - const auto in_strides = row_major_strides(in_shape); - const auto out_strides = row_major_strides(out_shape); - - CoordinateTransformBasic input_transform(in_shape); - for (const Coordinate& input_coord : input_transform) { - const Coordinate output_coord = ngraph::reduce(input_coord, reduction_axes, dont_keep_dims_in_output); - - const size_t in_idx = - std::inner_product(input_coord.begin(), input_coord.end(), in_strides.begin(), uint64_t(0)); - const size_t out_idx = - std::inner_product(output_coord.begin(), output_coord.end(), out_strides.begin(), uint64_t(0)); - - const T x = arg[in_idx]; - const T max = out[out_idx]; - if (x > max) { - out[out_idx] = x; - } - } - OPENVINO_SUPPRESS_DEPRECATED_END -} -} // namespace reference -} // namespace ov diff --git a/src/core/reference/include/openvino/reference/mean.hpp b/src/core/reference/include/openvino/reference/mean.hpp deleted file mode 100644 index 85fe10eddcf6bd..00000000000000 --- a/src/core/reference/include/openvino/reference/mean.hpp +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include -#include -#include -#include - -#include "ngraph/shape_util.hpp" -#include "ngraph/type/bfloat16.hpp" -#include "ngraph/type/float16.hpp" -#include "openvino/reference/sum.hpp" -#include "openvino/reference/utils/coordinate_transform.hpp" - -namespace ov { -namespace reference { -template -void mean(const T* arg, T* out, const Shape& in_shape, const AxisSet& reduction_axes) { - constexpr bool dont_keep_dims_in_output = false; - OPENVINO_SUPPRESS_DEPRECATED_START - const auto out_shape = ngraph::reduce(in_shape, reduction_axes, dont_keep_dims_in_output); - std::vector cs(shape_size(out_shape), 0); - std::fill(out, out + shape_size(out_shape), T(0)); - - const auto in_strides = row_major_strides(in_shape); - const auto out_strides = row_major_strides(out_shape); - - CoordinateTransformBasic input_transform(in_shape); - std::map index_to_count_map; - - for (const Coordinate& input_coord : input_transform) { - const Coordinate output_coord = ngraph::reduce(input_coord, reduction_axes, dont_keep_dims_in_output); - - const size_t in_idx = - std::inner_product(input_coord.begin(), input_coord.end(), in_strides.begin(), uint64_t(0)); - const size_t out_idx = - std::inner_product(output_coord.begin(), output_coord.end(), out_strides.begin(), uint64_t(0)); - - details::kahan_summation(arg[in_idx], cs[out_idx], out[out_idx]); - - if (index_to_count_map.find(out_idx) == index_to_count_map.end()) { - index_to_count_map[out_idx] = 1; - } else { - index_to_count_map[out_idx]++; - } - } - OPENVINO_SUPPRESS_DEPRECATED_END - - for (size_t i = 0; i < shape_size(out_shape); ++i) { - auto count = index_to_count_map[i]; - out[i] = out[i] / count; - } -} -} // namespace reference -} // namespace ov diff --git a/src/core/reference/include/openvino/reference/min.hpp b/src/core/reference/include/openvino/reference/min.hpp deleted file mode 100644 index 6d6c3e05df3ed1..00000000000000 --- a/src/core/reference/include/openvino/reference/min.hpp +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include -#include -#include - -#include "ngraph/shape_util.hpp" -#include "openvino/reference/utils/coordinate_transform.hpp" - -#ifdef _WIN32 -# undef min -#endif - -namespace ov { -namespace reference { -template -void min(const T* arg, T* out, const Shape& in_shape, const AxisSet& reduction_axes) { - T minval = - std::numeric_limits::has_infinity ? std::numeric_limits::infinity() : std::numeric_limits::max(); - - constexpr bool dont_keep_dims_in_output = false; - OPENVINO_SUPPRESS_DEPRECATED_START - const auto out_shape = ngraph::reduce(in_shape, reduction_axes, dont_keep_dims_in_output); - std::fill(out, out + shape_size(out_shape), minval); - - const auto in_strides = row_major_strides(in_shape); - const auto out_strides = row_major_strides(out_shape); - - CoordinateTransformBasic input_transform(in_shape); - for (const Coordinate& input_coord : input_transform) { - const Coordinate output_coord = ngraph::reduce(input_coord, reduction_axes, dont_keep_dims_in_output); - - const size_t in_idx = - std::inner_product(input_coord.begin(), input_coord.end(), in_strides.begin(), uint64_t(0)); - const size_t out_idx = - std::inner_product(output_coord.begin(), output_coord.end(), out_strides.begin(), uint64_t(0)); - - const T x = arg[in_idx]; - const T min = out[out_idx]; - if (x < min) { - out[out_idx] = x; - } - } - OPENVINO_SUPPRESS_DEPRECATED_END -} -} // namespace reference -} // namespace ov diff --git a/src/core/reference/include/openvino/reference/mvn.hpp b/src/core/reference/include/openvino/reference/mvn.hpp index cd171fe73f24d5..8bcce83295e5eb 100644 --- a/src/core/reference/include/openvino/reference/mvn.hpp +++ b/src/core/reference/include/openvino/reference/mvn.hpp @@ -10,11 +10,11 @@ #include "openvino/reference/add.hpp" #include "openvino/reference/divide.hpp" -#include "openvino/reference/mean.hpp" #include "openvino/reference/multiply.hpp" +#include "openvino/reference/reduce_mean.hpp" +#include "openvino/reference/reduce_sum.hpp" #include "openvino/reference/sqrt.hpp" #include "openvino/reference/subtract.hpp" -#include "openvino/reference/sum.hpp" namespace ov { namespace reference { @@ -28,13 +28,13 @@ void mvn(const T* arg, const double eps) { auto reduced_shape = ngraph::reduce(in_shape, reduction_axes, true); std::vector tmp_buffer(shape_size(in_shape)); - mean(arg, tmp_buffer.data(), in_shape, reduction_axes); + reduce_mean(arg, tmp_buffer.data(), in_shape, reduction_axes); subtract(arg, tmp_buffer.data(), out, in_shape, reduced_shape, op::AutoBroadcastType::NUMPY); if (normalize_variance) { multiply(out, out, tmp_buffer.data(), shape_size(in_shape)); std::vector mean_value(shape_size(reduced_shape)); - mean(tmp_buffer.data(), mean_value.data(), in_shape, reduction_axes); + reduce_mean(tmp_buffer.data(), mean_value.data(), in_shape, reduction_axes); add(mean_value.data(), std::vector(shape_size(reduced_shape), static_cast(eps)).data(), @@ -58,13 +58,13 @@ void mvn_6(const T* arg, op::MVNEpsMode eps_mode) { auto reduced_shape = ngraph::reduce(in_shape, reduction_axes, true); std::vector tmp_buffer(shape_size(in_shape)); - mean(arg, tmp_buffer.data(), in_shape, reduction_axes); + reduce_mean(arg, tmp_buffer.data(), in_shape, reduction_axes); subtract(arg, tmp_buffer.data(), out, in_shape, reduced_shape, op::AutoBroadcastType::NUMPY); if (normalize_variance) { multiply(out, out, tmp_buffer.data(), shape_size(in_shape)); std::vector mean_value(shape_size(reduced_shape)); - mean(tmp_buffer.data(), mean_value.data(), in_shape, reduction_axes); + reduce_mean(tmp_buffer.data(), mean_value.data(), in_shape, reduction_axes); if (eps_mode == op::MVNEpsMode::INSIDE_SQRT) { add(mean_value.data(), diff --git a/src/core/reference/include/openvino/reference/normalize_l2.hpp b/src/core/reference/include/openvino/reference/normalize_l2.hpp index ce737f652afc7c..69c0cff34fdc34 100644 --- a/src/core/reference/include/openvino/reference/normalize_l2.hpp +++ b/src/core/reference/include/openvino/reference/normalize_l2.hpp @@ -7,7 +7,7 @@ #include #include "openvino/reference/autobroadcast_binop.hpp" -#include "openvino/reference/sum.hpp" +#include "openvino/reference/reduce_sum.hpp" namespace ov { namespace reference { @@ -38,7 +38,7 @@ void normalize_l2(const T* data, } std::vector sum_data(shape_size(reduce_shape)); - sum(sqr_data.data(), sum_data.data(), data_shape, reduction_axes); + reduce_sum(sqr_data.data(), sum_data.data(), data_shape, reduction_axes); autobroadcast_binop(data, sum_data.data(), out, diff --git a/src/core/reference/include/openvino/reference/product.hpp b/src/core/reference/include/openvino/reference/product.hpp deleted file mode 100644 index 41ce4cf3b1d841..00000000000000 --- a/src/core/reference/include/openvino/reference/product.hpp +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include -#include - -#include "ngraph/shape_util.hpp" -#include "openvino/reference/utils/coordinate_transform.hpp" - -namespace ov { -namespace reference { -template -void product(const T* arg, T* out, const Shape& in_shape, const AxisSet& reduction_axes) { - constexpr bool dont_keep_dims_in_output = false; - OPENVINO_SUPPRESS_DEPRECATED_START - const auto out_shape = ngraph::reduce(in_shape, reduction_axes, dont_keep_dims_in_output); - std::fill(out, out + shape_size(out_shape), T(1)); - - const auto in_strides = row_major_strides(in_shape); - const auto out_strides = row_major_strides(out_shape); - - CoordinateTransformBasic input_transform(in_shape); - for (const Coordinate& input_coord : input_transform) { - const Coordinate output_coord = ngraph::reduce(input_coord, reduction_axes, dont_keep_dims_in_output); - - const size_t in_idx = - std::inner_product(input_coord.begin(), input_coord.end(), in_strides.begin(), uint64_t(0)); - const size_t out_idx = - std::inner_product(output_coord.begin(), output_coord.end(), out_strides.begin(), uint64_t(0)); - - out[out_idx] = out[out_idx] * arg[in_idx]; - } - OPENVINO_SUPPRESS_DEPRECATED_END -} -} // namespace reference -} // namespace ov diff --git a/src/core/reference/include/openvino/reference/reduce_l1.hpp b/src/core/reference/include/openvino/reference/reduce_l1.hpp index 50228962f334cf..c729f97490890b 100644 --- a/src/core/reference/include/openvino/reference/reduce_l1.hpp +++ b/src/core/reference/include/openvino/reference/reduce_l1.hpp @@ -9,7 +9,7 @@ #include "openvino/core/shape_util.hpp" #include "openvino/reference/abs.hpp" -#include "openvino/reference/sum.hpp" +#include "openvino/reference/reduce_sum.hpp" #include "openvino/reference/utils/type_util.hpp" namespace ov { diff --git a/src/core/reference/include/openvino/reference/reduce_max.hpp b/src/core/reference/include/openvino/reference/reduce_max.hpp new file mode 100644 index 00000000000000..3d16d343de79e0 --- /dev/null +++ b/src/core/reference/include/openvino/reference/reduce_max.hpp @@ -0,0 +1,46 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include +#include +#include + +#include "openvino/core/shape_util.hpp" +#include "openvino/reference/utils/coordinate_index.hpp" +#include "openvino/reference/utils/coordinate_transform.hpp" + +namespace ov { +namespace reference { + +/** + * @brief Reference implementation of ReduceMax operator. + * + * @param in Input pointer to data. + * @param out Output pointer to results. + * @param in_shape Input shape. + * @param reduction_axes Axes on which reduction is applied. + */ +template +void reduce_max(const T* in, T* out, const Shape& in_shape, const AxisSet& reduction_axes) { + constexpr auto min_value = std::numeric_limits::lowest(); + + const auto out_shape = util::reduce(in_shape, reduction_axes); + std::fill(out, std::next(out, shape_size(out_shape)), min_value); + + const auto in_strides = row_major_strides(in_shape); + const auto out_strides = row_major_strides(out_shape); + + CoordinateTransformBasic input_transform(in_shape); + for (const auto& in_coord : input_transform) { + const auto out_coord = util::reduce(in_coord, reduction_axes); + const auto in_idx = coordinate_offset(in_coord, in_strides); + const auto out_idx = coordinate_offset(out_coord, out_strides); + + out[out_idx] = std::max(out[out_idx], in[in_idx]); + } +} +} // namespace reference +} // namespace ov diff --git a/src/core/reference/include/openvino/reference/reduce_mean.hpp b/src/core/reference/include/openvino/reference/reduce_mean.hpp new file mode 100644 index 00000000000000..e7dfd1b9766404 --- /dev/null +++ b/src/core/reference/include/openvino/reference/reduce_mean.hpp @@ -0,0 +1,36 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include +#include + +#include "openvino/core/shape_util.hpp" +#include "openvino/reference/reduce_sum.hpp" + +namespace ov { +namespace reference { + +/** + * @brief Reference implementation of ReduceMean operator. + * + * @param in Input pointer to data. + * @param out Output pointer to results. + * @param in_shape Input shape. + * @param reduction_axes Axes on which reduction is applied. + */ +template +void reduce_mean(const T* in, T* out, const Shape& in_shape, const AxisSet& reduction_axes) { + reduce_sum(in, out, in_shape, reduction_axes); + + const auto out_shape = util::reduce(in_shape, reduction_axes); + const auto out_size = shape_size(out_shape); + const auto count = static_cast(shape_size(in_shape) / out_size); + std::transform(out, std::next(out, out_size), out, [count](const T value) { + return value / count; + }); +} +} // namespace reference +} // namespace ov diff --git a/src/core/reference/include/openvino/reference/reduce_min.hpp b/src/core/reference/include/openvino/reference/reduce_min.hpp new file mode 100644 index 00000000000000..1acc4c29a55f7c --- /dev/null +++ b/src/core/reference/include/openvino/reference/reduce_min.hpp @@ -0,0 +1,46 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include +#include +#include + +#include "openvino/core/shape_util.hpp" +#include "openvino/reference/utils/coordinate_index.hpp" +#include "openvino/reference/utils/coordinate_transform.hpp" + +namespace ov { +namespace reference { +/** + * @brief Reference implementation of ReduceMin operator. + * + * @param in Input pointer to data. + * @param out Output pointer to results. + * @param in_shape Input shape. + * @param reduction_axes Axes on which reduction is applied. + */ +template +void reduce_min(const T* in, T* out, const Shape& in_shape, const AxisSet& reduction_axes) { + constexpr auto max_value = + std::numeric_limits::has_infinity ? std::numeric_limits::infinity() : std::numeric_limits::max(); + + const auto out_shape = util::reduce(in_shape, reduction_axes); + std::fill(out, out + shape_size(out_shape), max_value); + + const auto in_strides = row_major_strides(in_shape); + const auto out_strides = row_major_strides(out_shape); + + CoordinateTransformBasic input_transform(in_shape); + for (const auto& in_coord : input_transform) { + const auto out_coord = util::reduce(in_coord, reduction_axes); + const auto in_idx = coordinate_offset(in_coord, in_strides); + const auto out_idx = coordinate_offset(out_coord, out_strides); + + out[out_idx] = std::min(out[out_idx], in[in_idx]); + } +} +} // namespace reference +} // namespace ov diff --git a/src/core/reference/include/openvino/reference/reduce_prod.hpp b/src/core/reference/include/openvino/reference/reduce_prod.hpp new file mode 100644 index 00000000000000..32741036e8cf22 --- /dev/null +++ b/src/core/reference/include/openvino/reference/reduce_prod.hpp @@ -0,0 +1,42 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include +#include + +#include "openvino/core/shape_util.hpp" +#include "openvino/reference/utils/coordinate_index.hpp" +#include "openvino/reference/utils/coordinate_transform.hpp" + +namespace ov { +namespace reference { +/** + * @brief Reference implementation of ReduceProduct operator. + * + * @param in Input pointer to data. + * @param out Output pointer to results. + * @param in_shape Input shape. + * @param reduction_axes Axes on which reduction is applied. + */ +template +void reduce_prod(const T* arg, T* out, const Shape& in_shape, const AxisSet& reduction_axes) { + const auto out_shape = util::reduce(in_shape, reduction_axes); + std::fill(out, out + shape_size(out_shape), T(1)); + + const auto in_strides = row_major_strides(in_shape); + const auto out_strides = row_major_strides(out_shape); + + CoordinateTransformBasic input_transform(in_shape); + for (const auto& in_coord : input_transform) { + const auto out_coord = util::reduce(in_coord, reduction_axes); + const auto in_idx = coordinate_offset(in_coord, in_strides); + const auto out_idx = coordinate_offset(out_coord, out_strides); + + out[out_idx] *= arg[in_idx]; + } +} +} // namespace reference +} // namespace ov diff --git a/src/core/reference/include/openvino/reference/reduce_sum.hpp b/src/core/reference/include/openvino/reference/reduce_sum.hpp new file mode 100644 index 00000000000000..c7d9ecf98bf2af --- /dev/null +++ b/src/core/reference/include/openvino/reference/reduce_sum.hpp @@ -0,0 +1,94 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include +#include + +#include "openvino/core/shape_util.hpp" +#include "openvino/core/type/bfloat16.hpp" +#include "openvino/core/type/float16.hpp" +#include "openvino/reference/utils/coordinate_index.hpp" +#include "openvino/reference/utils/coordinate_transform.hpp" +#include "openvino/reference/utils/type_util.hpp" + +namespace ov { +namespace reference { +namespace details { + +template ::value, bool>::type = true> +bool isfinite(T x) { + return std::isfinite(x); +} + +template < + typename T, + typename std::enable_if::value || std::is_same::value, bool>::type = true> +bool isfinite(T x) { + return std::isfinite(static_cast(x)); +} + +/** + * @brief Performs one element summation based on Kahan algorithm to significantly reduce (integral types). + * + * @param in Value to add with previous value of summation. + * @param prev_sum Previous value of summation (accumulator). + * @return Compensate sum. + */ +template ::value>::type* = nullptr> +constexpr T kahan_summation(const T in, const T prev_sum, T&) { + return in + prev_sum; +} + +/** + * @brief Performs one element summation based on Kahan algorithm to significantly reduce (floating point types). + * + * @param in Value to add with previous value of summation. + * @param prev_sum Previous value of summation (accumulator). + * @param compensation Accumulates the summation error. + * @return Compensate sum. + */ +template ()>::type* = nullptr> +T kahan_summation(const T in, const T prev_sum, T& compensation) { + if (isfinite(in) && isfinite(prev_sum)) { + T temp = prev_sum + (in - compensation); + compensation = (temp - prev_sum) - (in - compensation); + return temp; + } else { + return in + prev_sum; + } +} +} // namespace details + +/** + * @brief Reference implementation of ReduceSum operator. + * + * @param in Input pointer to data. + * @param out Output pointer to results. + * @param in_shape Input shape. + * @param reduction_axes Axes on which reduction is applied. + */ +template +void reduce_sum(const T* in, T* out, const Shape& in_shape, const AxisSet& reduction_axes) { + const auto out_shape = util::reduce(in_shape, reduction_axes); + + const auto out_size = shape_size(out_shape); + std::vector cs(out_size, T{0}); + std::fill(out, std::next(out, out_size), T{0}); + + const auto in_strides = row_major_strides(in_shape); + const auto out_strides = row_major_strides(out_shape); + + CoordinateTransformBasic input_transform(in_shape); + for (const auto& in_coord : input_transform) { + const auto out_coord = util::reduce(in_coord, reduction_axes); + const auto in_idx = coordinate_offset(in_coord, in_strides); + const auto out_idx = coordinate_offset(out_coord, out_strides); + + out[out_idx] = details::kahan_summation(in[in_idx], out[out_idx], cs[out_idx]); + } +} +} // namespace reference +} // namespace ov diff --git a/src/core/reference/include/openvino/reference/softmax.hpp b/src/core/reference/include/openvino/reference/softmax.hpp index d4cbf5bbaff63f..69ea583fbc6a2a 100644 --- a/src/core/reference/include/openvino/reference/softmax.hpp +++ b/src/core/reference/include/openvino/reference/softmax.hpp @@ -7,8 +7,8 @@ #include #include "ngraph/shape_util.hpp" -#include "openvino/reference/max.hpp" -#include "openvino/reference/sum.hpp" +#include "openvino/reference/reduce_max.hpp" +#include "openvino/reference/reduce_sum.hpp" #include "openvino/reference/utils/coordinate_transform.hpp" namespace ov { @@ -20,7 +20,7 @@ void softmax(const T* arg, T* out, const Shape& shape, const AxisSet& axes) { auto temp_elements = shape_size(temp_shape); auto temp_ptr = new T[temp_elements]; - max(arg, temp_ptr, shape, axes); + reduce_max(arg, temp_ptr, shape, axes); CoordinateTransform transform(shape); CoordinateTransform temp_transform(temp_shape); @@ -30,7 +30,7 @@ void softmax(const T* arg, T* out, const Shape& shape, const AxisSet& axes) { std::exp(arg[transform.index(coord)] - temp_ptr[temp_transform.index(temp_coord)]); } - sum(out, temp_ptr, shape, axes); + reduce_sum(out, temp_ptr, shape, axes); for (const Coordinate& coord : transform) { Coordinate temp_coord = ngraph::reduce(coord, axes, true); diff --git a/src/core/reference/include/openvino/reference/sum.hpp b/src/core/reference/include/openvino/reference/sum.hpp deleted file mode 100644 index 3f811b3d566f43..00000000000000 --- a/src/core/reference/include/openvino/reference/sum.hpp +++ /dev/null @@ -1,84 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include -#include - -#include "ngraph/shape_util.hpp" -#include "ngraph/type/bfloat16.hpp" -#include "ngraph/type/float16.hpp" -#include "openvino/reference/utils/coordinate_transform.hpp" - -namespace ov { -namespace reference { -namespace details { -// Windows doesn't seem to like it if we directly use std::isfinite on integer -// types, so we will roll our own thing here. -template ::value, bool>::type = true> -bool is_finite(T x) { - return std::isfinite(x); -} - -template < - typename T, - typename std::enable_if::value || std::is_same::value, bool>::type = true> -bool is_finite(T x) { - return std::isfinite(static_cast(x)); -} - -template ::value, bool>::type = true> -bool is_finite(T /* x */) { - return true; -} - -/// -/// \brief Performs one element summation based on Kahan algorithm to -/// significantly reduce -/// the numerical error. -/// -/// \param[in] elem Element to add into the accumulator. -/// \param compensation Variable that accumulates the error. -/// \param sum Result of compensated summation. -/// -template -void kahan_summation(const T& elem, T& compensation, T& sum) { - if (is_finite(elem) && is_finite(sum)) { - T temp = sum + (elem - compensation); - compensation = (temp - sum) - (elem - compensation); - sum = temp; - } else { - sum = sum + elem; - } -} -} // namespace details - -template -void sum(const T* arg, T* out, const Shape& in_shape, const AxisSet& reduction_axes) { - constexpr bool dont_keep_dims_in_output = false; - NGRAPH_SUPPRESS_DEPRECATED_START - const auto out_shape = ngraph::reduce(in_shape, reduction_axes, dont_keep_dims_in_output); - - std::vector cs(shape_size(out_shape), 0); - std::fill(out, out + shape_size(out_shape), T(0)); - - const auto in_strides = row_major_strides(in_shape); - const auto out_strides = row_major_strides(out_shape); - - CoordinateTransformBasic input_transform(in_shape); - for (const Coordinate& input_coord : input_transform) { - const Coordinate output_coord = ngraph::reduce(input_coord, reduction_axes, dont_keep_dims_in_output); - - const size_t in_idx = - std::inner_product(input_coord.begin(), input_coord.end(), in_strides.begin(), uint64_t(0)); - const size_t out_idx = - std::inner_product(output_coord.begin(), output_coord.end(), out_strides.begin(), uint64_t(0)); - - details::kahan_summation(arg[in_idx], cs[out_idx], out[out_idx]); - } - NGRAPH_SUPPRESS_DEPRECATED_END -} -} // namespace reference -} // namespace ov diff --git a/src/core/reference/src/op/einsum.cpp b/src/core/reference/src/op/einsum.cpp index 125e33e3aa6b49..a48dc998495286 100644 --- a/src/core/reference/src/op/einsum.cpp +++ b/src/core/reference/src/op/einsum.cpp @@ -10,8 +10,8 @@ #include "openvino/reference/broadcast.hpp" #include "openvino/reference/matmul.hpp" #include "openvino/reference/multiply.hpp" +#include "openvino/reference/reduce_sum.hpp" #include "openvino/reference/reshape.hpp" -#include "openvino/reference/sum.hpp" #include "openvino/reference/transpose.hpp" #include "openvino/reference/utils/span.hpp" @@ -352,7 +352,7 @@ void reduce_input(ov::TensorVector& inputs, auto output_ptr = ov::Tensor(input_ptr.get_element_type(), output_shape); - reference::sum(input_ptr.data(), output_ptr.data(), input_shape, reduced_axes); + reference::reduce_sum(input_ptr.data(), output_ptr.data(), input_shape, reduced_axes); // update a vector of inputs and input subscripts inputs[input_ind] = output_ptr; @@ -595,7 +595,7 @@ void extract_diagonal(ov::TensorVector& inputs, std::vector& input_ ov::op::AutoBroadcastType::NUMPY); auto result = ov::Tensor(input_ptr.get_element_type(), result_shape); - reference::sum(mul_output.data(), result.data(), mul_output.get_shape(), reduced_axes); + reference::reduce_sum(mul_output.data(), result.data(), mul_output.get_shape(), reduced_axes); inputs[input_ind] = result; input_subscripts[input_ind] = resultant_subscript; } diff --git a/src/core/shape_inference/include/utils.hpp b/src/core/shape_inference/include/utils.hpp index 7a1193f3a25a10..360c4eaa5f7b58 100644 --- a/src/core/shape_inference/include/utils.hpp +++ b/src/core/shape_inference/include/utils.hpp @@ -14,6 +14,7 @@ #include "ov_optional.hpp" #include "shape_infer_type_utils.hpp" #include "tensor_data_accessor.hpp" +#include "validation_util.hpp" namespace ov { @@ -277,10 +278,8 @@ std::unique_ptr get_input_const_data_as(const ov::Node* op, UnaryOperation&& func = ov::util::Cast()) { if (auto t = tensor_accessor(idx)) { return std::unique_ptr(new TRes(get_tensor_data_as(t, std::forward(func)))); - OPENVINO_SUPPRESS_DEPRECATED_START } else if (const auto& constant = - (idx < op->get_input_size()) ? ov::get_constant_from_source(op->input_value(idx)) : nullptr) { - OPENVINO_SUPPRESS_DEPRECATED_END + (idx < op->get_input_size()) ? ov::util::get_constant_from_source(op->input_value(idx)) : nullptr) { const auto& et = constant->get_element_type(); const auto& shape = constant->get_shape(); return std::unique_ptr(new TRes(get_raw_data_as(et, @@ -358,9 +357,7 @@ ov::optional get_input_const_data_as_shape(const ov::Node* op, inline element::Type get_input_const_element_type(const ov::Node* const op, size_t port, const ITensorAccessor& ta) { if (auto t = ta(port)) { return t.get_element_type(); - OPENVINO_SUPPRESS_DEPRECATED_START - } else if (const auto& constant = ov::get_constant_from_source(op->input_value(port))) { - OPENVINO_SUPPRESS_DEPRECATED_END + } else if (const auto& constant = ov::util::get_constant_from_source(op->input_value(port))) { return constant->get_element_type(); } else { return element::undefined; diff --git a/src/core/src/op/reduce_l1.cpp b/src/core/src/op/reduce_l1.cpp index 5670ae4609890b..75f8a000580bc3 100644 --- a/src/core/src/op/reduce_l1.cpp +++ b/src/core/src/op/reduce_l1.cpp @@ -21,7 +21,7 @@ struct Evaluate : element::NoAction { template static result_type visit(const Tensor& in0, Tensor& out, const AxisSet& reduction_axes) { using T = fundamental_type_for; - reference::reduce_l1(in0.data(), out.data(), in0.get_shape(), reduction_axes); + reference::reduce_l1(in0.data(), out.data(), in0.get_shape(), reduction_axes); return true; } }; @@ -48,7 +48,7 @@ bool ReduceL1::evaluate(TensorVector& outputs, const TensorVector& inputs) const outputs[0].set_shape(ov::util::reduce(inputs[0].get_shape(), reduction_axes, get_keep_dims())); using namespace ov::element; - return IfTypeOf::apply(inputs[0].get_element_type(), + return IfTypeOf::apply(inputs[0].get_element_type(), inputs[0], outputs[0], reduction_axes); diff --git a/src/core/src/op/reduce_l2.cpp b/src/core/src/op/reduce_l2.cpp index 1e7669ce625f48..5477a56986be16 100644 --- a/src/core/src/op/reduce_l2.cpp +++ b/src/core/src/op/reduce_l2.cpp @@ -20,7 +20,7 @@ struct Evaluate : element::NoAction { template static result_type visit(const Tensor& in0, Tensor& out, const AxisSet& reduction_axes) { using T = fundamental_type_for; - reference::reduce_l2(in0.data(), out.data(), in0.get_shape(), reduction_axes); + reference::reduce_l2(in0.data(), out.data(), in0.get_shape(), reduction_axes); return true; } }; diff --git a/src/core/src/op/reduce_max.cpp b/src/core/src/op/reduce_max.cpp index 35f2216bac8bfc..989f0a771f2b1c 100644 --- a/src/core/src/op/reduce_max.cpp +++ b/src/core/src/op/reduce_max.cpp @@ -2,98 +2,81 @@ // SPDX-License-Identifier: Apache-2.0 // -#include +#include "openvino/op/reduce_max.hpp" #include "bound_evaluate.hpp" +#include "element_visitor.hpp" #include "itt.hpp" -#include "ngraph/graph_util.hpp" -#include "ngraph/op/max.hpp" -#include "ngraph/op/util/evaluate_helpers.hpp" -#include "ngraph/runtime/host_tensor.hpp" -#include "ngraph/shape_util.hpp" -#include "openvino/reference/max.hpp" +#include "openvino/core/shape_util.hpp" +#include "openvino/op/util/axes_util.hpp" +#include "openvino/reference/reduce_max.hpp" -using namespace std; -using namespace ngraph; +namespace ov { +namespace op { +namespace reduce_max { +struct Evaluate : element::NoAction { + using element::NoAction::visit; -OPENVINO_SUPPRESS_DEPRECATED_START -namespace maxop { -namespace { -template -bool evaluate(const HostTensorPtr& arg, const HostTensorPtr& out, const AxisSet& axes, bool keep_dims) { - OPENVINO_SUPPRESS_DEPRECATED_START - out->set_shape(reduce(arg->get_shape(), axes, keep_dims)); - OPENVINO_SUPPRESS_DEPRECATED_END - ov::reference::max(arg->get_data_ptr(), out->get_data_ptr(), arg->get_shape(), axes); - return true; -} - -bool evaluate_max(const HostTensorPtr& arg, const HostTensorPtr& out, const AxisSet& axes, bool keep_dims) { - bool rc = true; - switch (arg->get_element_type()) { - NGRAPH_TYPE_CASE(evaluate_max, i32, arg, out, axes, keep_dims); - NGRAPH_TYPE_CASE(evaluate_max, i64, arg, out, axes, keep_dims); - NGRAPH_TYPE_CASE(evaluate_max, u32, arg, out, axes, keep_dims); - NGRAPH_TYPE_CASE(evaluate_max, u64, arg, out, axes, keep_dims); - NGRAPH_TYPE_CASE(evaluate_max, f16, arg, out, axes, keep_dims); - NGRAPH_TYPE_CASE(evaluate_max, f32, arg, out, axes, keep_dims); - NGRAPH_TYPE_CASE(evaluate_max, u8, arg, out, axes, keep_dims); - NGRAPH_TYPE_CASE(evaluate_max, i8, arg, out, axes, keep_dims); - default: - rc = false; - break; + template + static result_type visit(const Tensor& in0, Tensor& out, const AxisSet& reduction_axes) { + using T = fundamental_type_for; + reference::reduce_max(in0.data(), out.data(), in0.get_shape(), reduction_axes); + return true; } - return rc; -} -} // namespace -} // namespace maxop +}; +} // namespace reduce_max +namespace v1 { -op::v1::ReduceMax::ReduceMax(const Output& arg, const Output& reduction_axes, bool keep_dims) +ReduceMax::ReduceMax(const Output& arg, const Output& reduction_axes, bool keep_dims) : ArithmeticReductionKeepDims(arg, reduction_axes, keep_dims) { constructor_validate_and_infer_types(); } -shared_ptr op::v1::ReduceMax::clone_with_new_inputs(const OutputVector& new_args) const { +std::shared_ptr ReduceMax::clone_with_new_inputs(const OutputVector& new_args) const { OV_OP_SCOPE(v1_ReduceMax_clone_with_new_inputs); check_new_args_count(this, new_args); - return make_shared(new_args.at(0), new_args.at(1), get_keep_dims()); + return std::make_shared(new_args.at(0), new_args.at(1), get_keep_dims()); } -bool op::v1::ReduceMax::evaluate(const HostTensorVector& outputs, const HostTensorVector& inputs) const { +bool ReduceMax::evaluate(TensorVector& outputs, const TensorVector& inputs) const { OV_OP_SCOPE(v1_ReduceMax_evaluate); - OPENVINO_SUPPRESS_DEPRECATED_START - OPENVINO_ASSERT(validate_host_tensor_vector(inputs, 2)); - OPENVINO_ASSERT(validate_host_tensor_vector(outputs, 1)); + OPENVINO_ASSERT(outputs.size() == 1); + OPENVINO_ASSERT(inputs.size() == 2); - const auto reduction_axes = - get_normalized_axes_from_tensor(inputs[1], inputs[0]->get_partial_shape().rank(), get_friendly_name()); - OPENVINO_SUPPRESS_DEPRECATED_END + const auto reduction_axes = get_normalized_axes_from_tensor(this, inputs[1], inputs[0].get_shape().size()); + outputs[0].set_shape(ov::util::reduce(inputs[0].get_shape(), reduction_axes, get_keep_dims())); - return maxop::evaluate_max(inputs[0], outputs[0], reduction_axes, get_keep_dims()); + using namespace ov::element; + return IfTypeOf::apply(inputs[0].get_element_type(), + inputs[0], + outputs[0], + reduction_axes); } -bool op::v1::ReduceMax::has_evaluate() const { +bool ReduceMax::has_evaluate() const { OV_OP_SCOPE(v1_ReduceMax_has_evaluate); switch (get_input_element_type(0)) { - case ngraph::element::i32: - case ngraph::element::i64: - case ngraph::element::u32: - case ngraph::element::u64: - case ngraph::element::f16: - case ngraph::element::f32: - case ngraph::element::i8: - case ngraph::element::u8: + case element::i32: + case element::i64: + case element::u32: + case element::u64: + case element::f16: + case element::f32: + case element::i8: + case element::u8: return true; default: - break; + return false; } - return false; } -bool op::v1::ReduceMax::evaluate_lower(ov::TensorVector& output_values) const { +bool ReduceMax::evaluate_lower(ov::TensorVector& output_values) const { return input_value(1).get_tensor().has_and_set_bound() && default_lower_bound_evaluator(this, output_values); } -bool op::v1::ReduceMax::evaluate_upper(ov::TensorVector& output_values) const { +bool ReduceMax::evaluate_upper(ov::TensorVector& output_values) const { return input_value(1).get_tensor().has_and_set_bound() && default_upper_bound_evaluator(this, output_values); } +} // namespace v1 +} // namespace op +} // namespace ov diff --git a/src/core/src/op/reduce_mean.cpp b/src/core/src/op/reduce_mean.cpp index bc425fa0c2095c..762bc1c09719ee 100644 --- a/src/core/src/op/reduce_mean.cpp +++ b/src/core/src/op/reduce_mean.cpp @@ -2,87 +2,69 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "ngraph/op/reduce_mean.hpp" - -#include +#include "openvino/op/reduce_mean.hpp" +#include "element_visitor.hpp" #include "itt.hpp" -#include "ngraph/graph_util.hpp" -#include "ngraph/op/broadcast.hpp" -#include "ngraph/op/util/evaluate_helpers.hpp" -#include "ngraph/runtime/host_tensor.hpp" -#include "ngraph/shape_util.hpp" -#include "openvino/reference/mean.hpp" +#include "openvino/core/shape_util.hpp" +#include "openvino/op/util/axes_util.hpp" +#include "openvino/reference/reduce_mean.hpp" -using namespace std; -using namespace ngraph; +namespace ov { +namespace op { +namespace reduce_mean { +struct Evaluate : element::NoAction { + using element::NoAction::visit; -op::v1::ReduceMean::ReduceMean(const Output& arg, const Output& reduction_axes, bool keep_dims) + template + static result_type visit(const Tensor& in0, Tensor& out, const AxisSet& reduction_axes) { + using T = fundamental_type_for; + reference::reduce_mean(in0.data(), out.data(), in0.get_shape(), reduction_axes); + return true; + } +}; +} // namespace reduce_mean +namespace v1 { +ReduceMean::ReduceMean(const Output& arg, const Output& reduction_axes, bool keep_dims) : ArithmeticReductionKeepDims(arg, reduction_axes, keep_dims) { constructor_validate_and_infer_types(); } -shared_ptr op::v1::ReduceMean::clone_with_new_inputs(const OutputVector& new_args) const { +std::shared_ptr ReduceMean::clone_with_new_inputs(const OutputVector& new_args) const { OV_OP_SCOPE(v1_ReduceMean_clone_with_new_inputs); check_new_args_count(this, new_args); - return make_shared(new_args.at(0), new_args.at(1), get_keep_dims()); -} - -OPENVINO_SUPPRESS_DEPRECATED_START -namespace mean { -namespace { -template -bool evaluate(const HostTensorPtr& arg, const HostTensorPtr& out, const AxisSet& axes, bool keep_dims) { - OPENVINO_SUPPRESS_DEPRECATED_START - out->set_shape(reduce(arg->get_shape(), axes, keep_dims)); - OPENVINO_SUPPRESS_DEPRECATED_END - ov::reference::mean(arg->get_data_ptr(), out->get_data_ptr(), arg->get_shape(), axes); - return true; -} - -bool evaluate_mean(const HostTensorPtr& arg, const HostTensorPtr& out, const AxisSet& axes, bool keep_dims) { - bool rc = true; - switch (arg->get_element_type()) { - NGRAPH_TYPE_CASE(evaluate_mean, i32, arg, out, axes, keep_dims); - NGRAPH_TYPE_CASE(evaluate_mean, i64, arg, out, axes, keep_dims); - NGRAPH_TYPE_CASE(evaluate_mean, u32, arg, out, axes, keep_dims); - NGRAPH_TYPE_CASE(evaluate_mean, u64, arg, out, axes, keep_dims); - NGRAPH_TYPE_CASE(evaluate_mean, f16, arg, out, axes, keep_dims); - NGRAPH_TYPE_CASE(evaluate_mean, f32, arg, out, axes, keep_dims); - default: - rc = false; - break; - } - return rc; + return std::make_shared(new_args.at(0), new_args.at(1), get_keep_dims()); } -} // namespace -} // namespace mean -bool op::v1::ReduceMean::evaluate(const HostTensorVector& outputs, const HostTensorVector& inputs) const { +bool ReduceMean::evaluate(TensorVector& outputs, const TensorVector& inputs) const { OV_OP_SCOPE(v1_ReduceMean_evaluate); - OPENVINO_SUPPRESS_DEPRECATED_START - OPENVINO_ASSERT(validate_host_tensor_vector(inputs, 2)); - OPENVINO_ASSERT(validate_host_tensor_vector(outputs, 1)); + OPENVINO_ASSERT(outputs.size() == 1); + OPENVINO_ASSERT(inputs.size() == 2); - const auto reduction_axes = - get_normalized_axes_from_tensor(inputs[1], inputs[0]->get_partial_shape().rank(), get_friendly_name()); - OPENVINO_SUPPRESS_DEPRECATED_END + const auto reduction_axes = get_normalized_axes_from_tensor(this, inputs[1], inputs[0].get_shape().size()); + outputs[0].set_shape(ov::util::reduce(inputs[0].get_shape(), reduction_axes, get_keep_dims())); - return mean::evaluate_mean(inputs[0], outputs[0], reduction_axes, get_keep_dims()); + using namespace ov::element; + return IfTypeOf::apply(inputs[0].get_element_type(), + inputs[0], + outputs[0], + reduction_axes); } -bool op::v1::ReduceMean::has_evaluate() const { +bool ReduceMean::has_evaluate() const { OV_OP_SCOPE(v1_ReduceMean_has_evaluate); switch (get_input_element_type(0)) { - case ngraph::element::i32: - case ngraph::element::i64: - case ngraph::element::u32: - case ngraph::element::u64: - case ngraph::element::f16: - case ngraph::element::f32: + case element::f16: + case element::f32: + case element::i32: + case element::i64: + case element::u32: + case element::u64: return true; default: - break; + return false; } - return false; } +} // namespace v1 +} // namespace op +} // namespace ov diff --git a/src/core/src/op/reduce_min.cpp b/src/core/src/op/reduce_min.cpp index 7f6e927748bb56..3334b02d5fa3ea 100644 --- a/src/core/src/op/reduce_min.cpp +++ b/src/core/src/op/reduce_min.cpp @@ -2,97 +2,79 @@ // SPDX-License-Identifier: Apache-2.0 // -#include +#include "openvino/op/reduce_min.hpp" #include "bound_evaluate.hpp" +#include "element_visitor.hpp" #include "itt.hpp" -#include "ngraph/op/min.hpp" -#include "ngraph/op/util/evaluate_helpers.hpp" -#include "ngraph/runtime/host_tensor.hpp" -#include "ngraph/shape_util.hpp" -#include "openvino/reference/min.hpp" +#include "openvino/op/util/axes_util.hpp" +#include "openvino/reference/reduce_min.hpp" -using namespace std; -using namespace ngraph; +namespace ov { +namespace op { +namespace reduce_min { +struct Evaluate : element::NoAction { + using element::NoAction::visit; -OPENVINO_SUPPRESS_DEPRECATED_START -namespace minop { -namespace { -template -bool evaluate(const HostTensorPtr& arg, const HostTensorPtr& out, const AxisSet& axes, const bool keep_dims) { - OPENVINO_SUPPRESS_DEPRECATED_START - out->set_shape(reduce(arg->get_shape(), axes, keep_dims)); - OPENVINO_SUPPRESS_DEPRECATED_END - ov::reference::min(arg->get_data_ptr(), out->get_data_ptr(), arg->get_shape(), axes); - return true; -} - -bool evaluate_min(const HostTensorPtr& arg, const HostTensorPtr& out, const AxisSet& axes, const bool keep_dims) { - bool rc = true; - switch (arg->get_element_type()) { - NGRAPH_TYPE_CASE(evaluate_min, i32, arg, out, axes, keep_dims); - NGRAPH_TYPE_CASE(evaluate_min, i64, arg, out, axes, keep_dims); - NGRAPH_TYPE_CASE(evaluate_min, u32, arg, out, axes, keep_dims); - NGRAPH_TYPE_CASE(evaluate_min, u64, arg, out, axes, keep_dims); - NGRAPH_TYPE_CASE(evaluate_min, f16, arg, out, axes, keep_dims); - NGRAPH_TYPE_CASE(evaluate_min, f32, arg, out, axes, keep_dims); - NGRAPH_TYPE_CASE(evaluate_min, i8, arg, out, axes, keep_dims); - NGRAPH_TYPE_CASE(evaluate_min, u8, arg, out, axes, keep_dims); - default: - rc = false; - break; + template + static result_type visit(const Tensor& in0, Tensor& out, const AxisSet& reduction_axes) { + using T = fundamental_type_for; + reference::reduce_min(in0.data(), out.data(), in0.get_shape(), reduction_axes); + return true; } - return rc; -} -} // namespace -} // namespace minop - -op::v1::ReduceMin::ReduceMin(const Output& arg, const Output& reduction_axes, bool keep_dims) +}; +} // namespace reduce_min +namespace v1 { +ReduceMin::ReduceMin(const Output& arg, const Output& reduction_axes, bool keep_dims) : ArithmeticReductionKeepDims(arg, reduction_axes, keep_dims) { constructor_validate_and_infer_types(); } -shared_ptr op::v1::ReduceMin::clone_with_new_inputs(const OutputVector& new_args) const { +std::shared_ptr ReduceMin::clone_with_new_inputs(const OutputVector& new_args) const { OV_OP_SCOPE(v1_ReduceMin_clone_with_new_inputs); check_new_args_count(this, new_args); - return make_shared(new_args.at(0), new_args.at(1), get_keep_dims()); + return std::make_shared(new_args.at(0), new_args.at(1), get_keep_dims()); } -bool op::v1::ReduceMin::evaluate(const HostTensorVector& outputs, const HostTensorVector& inputs) const { +bool ReduceMin::evaluate(TensorVector& outputs, const TensorVector& inputs) const { OV_OP_SCOPE(v1_ReduceMin_evaluate); - OPENVINO_SUPPRESS_DEPRECATED_START - OPENVINO_ASSERT(validate_host_tensor_vector(inputs, 2)); - OPENVINO_ASSERT(validate_host_tensor_vector(outputs, 1)); + OPENVINO_ASSERT(outputs.size() == 1); + OPENVINO_ASSERT(inputs.size() == 2); - const auto reduction_axes = - get_normalized_axes_from_tensor(inputs[1], inputs[0]->get_partial_shape().rank(), get_friendly_name()); - OPENVINO_SUPPRESS_DEPRECATED_END + const auto reduction_axes = get_normalized_axes_from_tensor(this, inputs[1], inputs[0].get_shape().size()); + outputs[0].set_shape(ov::util::reduce(inputs[0].get_shape(), reduction_axes, get_keep_dims())); - return minop::evaluate_min(inputs[0], outputs[0], reduction_axes, get_keep_dims()); + using namespace ov::element; + return IfTypeOf::apply(inputs[0].get_element_type(), + inputs[0], + outputs[0], + reduction_axes); } -bool op::v1::ReduceMin::has_evaluate() const { +bool ReduceMin::has_evaluate() const { OV_OP_SCOPE(v1_ReduceMin_has_evaluate); switch (get_input_element_type(0)) { - case ngraph::element::i8: - case ngraph::element::u8: - case ngraph::element::i32: - case ngraph::element::i64: - case ngraph::element::u32: - case ngraph::element::u64: - case ngraph::element::f16: - case ngraph::element::f32: + case element::i8: + case element::u8: + case element::i32: + case element::i64: + case element::u32: + case element::u64: + case element::f16: + case element::f32: return true; default: - break; + return false; } - return false; } -bool op::v1::ReduceMin::evaluate_lower(ov::TensorVector& output_values) const { +bool ReduceMin::evaluate_lower(ov::TensorVector& output_values) const { return input_value(1).get_tensor().has_and_set_bound() && default_lower_bound_evaluator(this, output_values); } -bool op::v1::ReduceMin::evaluate_upper(ov::TensorVector& output_values) const { +bool ReduceMin::evaluate_upper(ov::TensorVector& output_values) const { return input_value(1).get_tensor().has_and_set_bound() && default_upper_bound_evaluator(this, output_values); } +} // namespace v1 +} // namespace op +} // namespace ov diff --git a/src/core/src/op/reduce_prod.cpp b/src/core/src/op/reduce_prod.cpp index dd915427b2415d..9d345ae63cf301 100644 --- a/src/core/src/op/reduce_prod.cpp +++ b/src/core/src/op/reduce_prod.cpp @@ -2,105 +2,90 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "ngraph/op/reduce_prod.hpp" +#include "openvino/op/reduce_prod.hpp" #include "bound_evaluate.hpp" +#include "element_visitor.hpp" #include "itt.hpp" -#include "ngraph/graph_util.hpp" -#include "ngraph/op/util/evaluate_helpers.hpp" -#include "ngraph/runtime/host_tensor.hpp" -#include "ngraph/shape_util.hpp" -#include "openvino/reference/product.hpp" +#include "openvino/core/shape_util.hpp" +#include "openvino/op/util/axes_util.hpp" +#include "openvino/reference/reduce_prod.hpp" -using namespace std; -using namespace ngraph; +namespace ov { +namespace op { +namespace reduce_prod { +namespace { +bool has_positive_bounds_on_data(const Node* const op) { + const auto& lb = op->get_input_tensor(0).get_lower_value(); + const auto& ub = op->get_input_tensor(0).get_upper_value(); + + return lb && ub && tensor_is_positive(lb) && tensor_is_positive(ub); +} +} // namespace + +struct Evaluate : element::NoAction { + using element::NoAction::visit; + + template + static result_type visit(const Tensor& in0, Tensor& out, const AxisSet& reduction_axes) { + using T = fundamental_type_for; + reference::reduce_prod(in0.data(), out.data(), in0.get_shape(), reduction_axes); + return true; + } +}; +} // namespace reduce_prod +namespace v1 { -op::v1::ReduceProd::ReduceProd(const Output& arg, const Output& reduction_axes, bool keep_dims) +ReduceProd::ReduceProd(const Output& arg, const Output& reduction_axes, bool keep_dims) : ArithmeticReductionKeepDims(arg, reduction_axes, keep_dims) { constructor_validate_and_infer_types(); } -shared_ptr op::v1::ReduceProd::clone_with_new_inputs(const OutputVector& new_args) const { +std::shared_ptr ReduceProd::clone_with_new_inputs(const OutputVector& new_args) const { OV_OP_SCOPE(v1_ReduceProd_clone_with_new_inputs); check_new_args_count(this, new_args); - return make_shared(new_args.at(0), new_args.at(1), get_keep_dims()); -} - -OPENVINO_SUPPRESS_DEPRECATED_START -namespace reduce_prod { -namespace { -template -bool evaluate(const HostTensorPtr& arg, const HostTensorPtr& out, const AxisSet& axes, bool keep_dims) { - OPENVINO_SUPPRESS_DEPRECATED_START - out->set_shape(reduce(arg->get_shape(), axes, keep_dims)); - OPENVINO_SUPPRESS_DEPRECATED_END - ov::reference::product(arg->get_data_ptr(), out->get_data_ptr(), arg->get_shape(), axes); - return true; + return std::make_shared(new_args.at(0), new_args.at(1), get_keep_dims()); } -bool evaluate_product(const HostTensorPtr& arg, const HostTensorPtr& out, const AxisSet& axes, bool keep_dims) { - bool rc = true; - switch (arg->get_element_type()) { - NGRAPH_TYPE_CASE(evaluate_product, i32, arg, out, axes, keep_dims); - NGRAPH_TYPE_CASE(evaluate_product, i64, arg, out, axes, keep_dims); - NGRAPH_TYPE_CASE(evaluate_product, u32, arg, out, axes, keep_dims); - NGRAPH_TYPE_CASE(evaluate_product, u64, arg, out, axes, keep_dims); - NGRAPH_TYPE_CASE(evaluate_product, f16, arg, out, axes, keep_dims); - NGRAPH_TYPE_CASE(evaluate_product, f32, arg, out, axes, keep_dims); - default: - rc = false; - break; - } - return rc; -} // namespace -} // namespace -} // namespace reduce_prod - -bool op::v1::ReduceProd::evaluate(const HostTensorVector& outputs, const HostTensorVector& inputs) const { +bool ReduceProd::evaluate(TensorVector& outputs, const TensorVector& inputs) const { OV_OP_SCOPE(v1_ReduceProd_evaluate); - OPENVINO_SUPPRESS_DEPRECATED_START - OPENVINO_ASSERT(validate_host_tensor_vector(inputs, 2)); - OPENVINO_ASSERT(validate_host_tensor_vector(outputs, 1)); + OPENVINO_ASSERT(outputs.size() == 1); + OPENVINO_ASSERT(inputs.size() == 2); - const auto reduction_axes = - get_normalized_axes_from_tensor(inputs[1], inputs[0]->get_partial_shape().rank(), get_friendly_name()); - OPENVINO_SUPPRESS_DEPRECATED_END + const auto reduction_axes = get_normalized_axes_from_tensor(this, inputs[1], inputs[0].get_shape().size()); + outputs[0].set_shape(ov::util::reduce(inputs[0].get_shape(), reduction_axes, get_keep_dims())); - return reduce_prod::evaluate_product(inputs[0], outputs[0], reduction_axes, get_keep_dims()); + using namespace ov::element; + return IfTypeOf::apply(inputs[0].get_element_type(), + inputs[0], + outputs[0], + reduction_axes); } -bool op::v1::ReduceProd::has_evaluate() const { +bool ReduceProd::has_evaluate() const { OV_OP_SCOPE(v1_ReduceProd_has_evaluate); switch (get_input_element_type(0)) { - case ngraph::element::i32: - case ngraph::element::i64: - case ngraph::element::u32: - case ngraph::element::u64: - case ngraph::element::f16: - case ngraph::element::f32: + case element::i32: + case element::i64: + case element::u32: + case element::u64: + case element::f16: + case element::f32: return true; default: - break; + return false; } - return false; } -bool op::v1::ReduceProd::evaluate_lower(ov::TensorVector& output_values) const { - if (!input_value(1).get_tensor().has_and_set_bound()) - return false; - - const auto &lb = input_value(0).get_tensor().get_lower_value(), ub = input_value(0).get_tensor().get_upper_value(); - if (!lb || !ub || !tensor_is_positive(lb) || !tensor_is_positive(ub)) - return false; - return default_lower_bound_evaluator(this, output_values); +bool ReduceProd::evaluate_lower(ov::TensorVector& output_values) const { + return reduce_prod::has_positive_bounds_on_data(this) && get_input_tensor(1).has_and_set_bound() && + default_lower_bound_evaluator(this, output_values); } -bool op::v1::ReduceProd::evaluate_upper(ov::TensorVector& output_values) const { - if (!input_value(1).get_tensor().has_and_set_bound()) - return false; - - const auto &lb = input_value(0).get_tensor().get_lower_value(), ub = input_value(0).get_tensor().get_upper_value(); - if (!lb || !ub || !tensor_is_positive(lb) || !tensor_is_positive(ub)) - return false; - return default_upper_bound_evaluator(this, output_values); +bool ReduceProd::evaluate_upper(ov::TensorVector& output_values) const { + return reduce_prod::has_positive_bounds_on_data(this) && get_input_tensor(1).has_and_set_bound() && + default_upper_bound_evaluator(this, output_values); } +} // namespace v1 +} // namespace op +} // namespace ov diff --git a/src/core/src/op/reduce_sum.cpp b/src/core/src/op/reduce_sum.cpp index 54797693251ae1..33e7ced8204faf 100644 --- a/src/core/src/op/reduce_sum.cpp +++ b/src/core/src/op/reduce_sum.cpp @@ -2,88 +2,69 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "ngraph/op/reduce_sum.hpp" - -#include +#include "openvino/op/reduce_sum.hpp" +#include "element_visitor.hpp" #include "itt.hpp" -#include "ngraph/graph_util.hpp" -#include "ngraph/op/broadcast.hpp" -#include "ngraph/op/util/evaluate_helpers.hpp" -#include "ngraph/op/util/op_types.hpp" -#include "ngraph/runtime/host_tensor.hpp" -#include "ngraph/shape_util.hpp" -#include "openvino/reference/sum.hpp" +#include "openvino/core/shape_util.hpp" +#include "openvino/op/util/axes_util.hpp" +#include "openvino/reference/reduce_sum.hpp" -using namespace std; -using namespace ngraph; +namespace ov { +namespace op { +namespace reduce_sum { +struct Evaluate : element::NoAction { + using element::NoAction::visit; -op::v1::ReduceSum::ReduceSum(const Output& arg, const Output& reduction_axes, bool keep_dims) + template + static result_type visit(const Tensor& in0, Tensor& out, const AxisSet& reduction_axes) { + using T = fundamental_type_for; + reference::reduce_sum(in0.data(), out.data(), in0.get_shape(), reduction_axes); + return true; + } +}; +} // namespace reduce_sum +namespace v1 { +ReduceSum::ReduceSum(const Output& arg, const Output& reduction_axes, bool keep_dims) : ArithmeticReductionKeepDims(arg, reduction_axes, keep_dims) { constructor_validate_and_infer_types(); } -shared_ptr op::v1::ReduceSum::clone_with_new_inputs(const OutputVector& new_args) const { +std::shared_ptr ReduceSum::clone_with_new_inputs(const OutputVector& new_args) const { OV_OP_SCOPE(v1_ReduceSum_clone_with_new_inputs); check_new_args_count(this, new_args); - return make_shared(new_args.at(0), new_args.at(1), get_keep_dims()); -} - -OPENVINO_SUPPRESS_DEPRECATED_START -namespace reduce_sum { -namespace { -template -bool evaluate(const HostTensorPtr& arg, const HostTensorPtr& out, const AxisSet& axes, bool keep_dims) { - OPENVINO_SUPPRESS_DEPRECATED_START - out->set_shape(reduce(arg->get_shape(), axes, keep_dims)); - OPENVINO_SUPPRESS_DEPRECATED_END - ov::reference::sum(arg->get_data_ptr(), out->get_data_ptr(), arg->get_shape(), axes); - return true; + return std::make_shared(new_args.at(0), new_args.at(1), get_keep_dims()); } -bool evaluate_sum(const HostTensorPtr& arg, const HostTensorPtr& out, const AxisSet& axes, bool keep_dims) { - bool rc = true; - switch (arg->get_element_type()) { - NGRAPH_TYPE_CASE(evaluate_reduce_sum, i32, arg, out, axes, keep_dims); - NGRAPH_TYPE_CASE(evaluate_reduce_sum, i64, arg, out, axes, keep_dims); - NGRAPH_TYPE_CASE(evaluate_reduce_sum, u32, arg, out, axes, keep_dims); - NGRAPH_TYPE_CASE(evaluate_reduce_sum, u64, arg, out, axes, keep_dims); - NGRAPH_TYPE_CASE(evaluate_reduce_sum, f16, arg, out, axes, keep_dims); - NGRAPH_TYPE_CASE(evaluate_reduce_sum, f32, arg, out, axes, keep_dims); - default: - rc = false; - break; - } - return rc; -} // namespace -} // namespace -} // namespace reduce_sum - -bool op::v1::ReduceSum::evaluate(const HostTensorVector& outputs, const HostTensorVector& inputs) const { +bool ReduceSum::evaluate(TensorVector& outputs, const TensorVector& inputs) const { OV_OP_SCOPE(v1_ReduceSum_evaluate); - OPENVINO_SUPPRESS_DEPRECATED_START - OPENVINO_ASSERT(validate_host_tensor_vector(inputs, 2)); - OPENVINO_ASSERT(validate_host_tensor_vector(outputs, 1)); + OPENVINO_ASSERT(outputs.size() == 1); + OPENVINO_ASSERT(inputs.size() == 2); - const auto reduction_axes = - get_normalized_axes_from_tensor(inputs[1], inputs[0]->get_partial_shape().rank(), get_friendly_name()); - OPENVINO_SUPPRESS_DEPRECATED_END + const auto reduction_axes = get_normalized_axes_from_tensor(this, inputs[1], inputs[0].get_shape().size()); + outputs[0].set_shape(ov::util::reduce(inputs[0].get_shape(), reduction_axes, get_keep_dims())); - return reduce_sum::evaluate_sum(inputs[0], outputs[0], reduction_axes, get_keep_dims()); + using namespace ov::element; + return IfTypeOf::apply(inputs[0].get_element_type(), + inputs[0], + outputs[0], + reduction_axes); } -bool op::v1::ReduceSum::has_evaluate() const { +bool ReduceSum::has_evaluate() const { OV_OP_SCOPE(v1_ReduceSum_has_evaluate); switch (get_input_element_type(0)) { - case ngraph::element::i32: - case ngraph::element::i64: - case ngraph::element::u32: - case ngraph::element::u64: - case ngraph::element::f16: - case ngraph::element::f32: + case element::i32: + case element::i64: + case element::u32: + case element::u64: + case element::f16: + case element::f32: return true; default: - break; + return false; } - return false; } +} // namespace v1 +} // namespace op +} // namespace ov diff --git a/src/core/src/op/util/axes_util.cpp b/src/core/src/op/util/axes_util.cpp index d5921edf6f580f..1736025527f71e 100644 --- a/src/core/src/op/util/axes_util.cpp +++ b/src/core/src/op/util/axes_util.cpp @@ -11,7 +11,7 @@ namespace ov { namespace op { namespace util { AxisSet get_normalized_axes_from_tensor(const Node* const node, const Tensor& tensor, const Rank& rank) { - const auto axes = ov::get_tensor_data_as(tensor, ov::util::Cast()); + const auto axes = ov::get_tensor_data_as(tensor); OPENVINO_SUPPRESS_DEPRECATED_START return {normalize_axes(node->get_friendly_name(), axes, rank)}; diff --git a/src/core/src/op/util/reduction_base.cpp b/src/core/src/op/util/reduction_base.cpp index dbe7cb4b5228b9..30d56715c248e3 100644 --- a/src/core/src/op/util/reduction_base.cpp +++ b/src/core/src/op/util/reduction_base.cpp @@ -6,6 +6,7 @@ #include "openvino/op/constant.hpp" #include "reduce_shape_inference.hpp" +#include "validation_util.hpp" ov::op::util::ReductionBase::ReductionBase() = default; @@ -24,18 +25,16 @@ bool ov::op::util::ReductionBase::reduction_axes_constant() const { } const ov::AxisSet ov::op::util::ReductionBase::get_reduction_axes() const { - AxisSet axes; - OPENVINO_SUPPRESS_DEPRECATED_START - if (const auto& const_op = get_constant_from_source(input_value(1))) { - OPENVINO_SUPPRESS_DEPRECATED_END + if (const auto& const_op = ov::util::get_constant_from_source(input_value(1))) { const auto const_data = const_op->cast_vector(); const auto input_data_rank = get_input_partial_shape(0).rank(); OPENVINO_SUPPRESS_DEPRECATED_START const auto normalized_axes = ov::normalize_axes(get_friendly_name(), const_data, input_data_rank); OPENVINO_SUPPRESS_DEPRECATED_END - axes = AxisSet{normalized_axes}; + return {normalized_axes}; + } else { + return {}; } - return axes; } void ov::op::util::ReductionBase::set_reduction_axes(const AxisSet& reduction_axes) { diff --git a/src/core/src/validation_util.cpp b/src/core/src/validation_util.cpp index d44e6b0bf5b718..b1f03d198f1152 100644 --- a/src/core/src/validation_util.cpp +++ b/src/core/src/validation_util.cpp @@ -1295,13 +1295,7 @@ std::shared_ptr ngraph::get_constant_lowest_of_type(el } shared_ptr ov::get_constant_from_source(const Output& source) { - if (!has_and_set_equal_bounds(source)) - return nullptr; - if (const auto& c = ov::as_type_ptr(source.get_node_shared_ptr())) - return c; - - const auto t = source.get_tensor().get_upper_value(); - return std::make_shared(t.get_element_type(), t.get_shape(), t.data()); + return ov::util::get_constant_from_source(source); } bool ngraph::validate_host_tensor_vector(const HostTensorVector& tensor_vector, const size_t& size) { @@ -1370,3 +1364,19 @@ std::shared_ptr ov::util::constantfold_subgraph(const Outp return nullptr; return ov::as_type_ptr(outputs[subgraph_sink.get_index()].get_node_shared_ptr()); } + +namespace ov { +namespace util { +using ov::op::v0::Constant; + +std::shared_ptr get_constant_from_source(const Output& source) { + if (const auto& c = ov::as_type_ptr(source.get_node_shared_ptr())) { + return c; + } else if (has_and_set_equal_bounds(source)) { + return std::make_shared(source.get_tensor().get_upper_value()); + } else { + return {}; + } +} +} // namespace util +} // namespace ov From 76851516acc32914167510d318d111b83ae6170c Mon Sep 17 00:00:00 2001 From: Mikhail Ryzhov Date: Mon, 25 Sep 2023 13:24:06 +0200 Subject: [PATCH 10/57] switched PyTorch_Models --- .github/workflows/linux.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 51b550e6e960a1..c11cae778e03b9 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -946,10 +946,15 @@ jobs: defaults: run: shell: bash - runs-on: ${{ github.event_name == 'schedule' && 'ubuntu-20.04-8-cores' || 'ubuntu-20.04'}} + runs-on: ${{ github.event_name == 'schedule' && 'aks-linux-8-cores' || 'aks-linux-4-cores'}} + container: + image: openvinogithubactions.azurecr.io/dockerhub/ubuntu:20.04 + volumes: + - /mount/caches:/mount/caches env: INSTALL_DIR: ${{ github.workspace }}/install INSTALL_TEST_DIR: ${{ github.workspace }}/install/tests + PIP_CACHE_DIR: /mount/caches/pip/linux MODEL_HUB_TESTS_INSTALL_DIR: ${{ github.workspace }}/install/tests/model_hub_tests steps: @@ -962,7 +967,7 @@ jobs: df -h - name: Create Directories - run: mkdir -p ${{ env.INSTALL_DIR }} ${{ env.INSTALL_TEST_DIR }} + run: mkdir -p ${{ env.INSTALL_DIR }} ${{ env.INSTALL_TEST_DIR }} ${{ env.PIP_CACHE_DIR }} - uses: actions/setup-python@v4 with: @@ -988,6 +993,7 @@ jobs: pushd ${{ env.INSTALL_TEST_DIR }} tar -xzf openvino_tests.tar.gz -C ${{ env.INSTALL_DIR }} && rm openvino_tests.tar.gz || exit 1 popd + - name: Install Python wheels run: | python3 -m pip install openvino --find-links=${{ env.INSTALL_DIR }}/tools From c438d1ed3f63cd0efb30c262ca4283b584fa2d13 Mon Sep 17 00:00:00 2001 From: Mikhail Ryzhov Date: Mon, 25 Sep 2023 13:45:08 +0200 Subject: [PATCH 11/57] fixed root issue --- .github/workflows/linux.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index c11cae778e03b9..5123cea46d854b 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -958,6 +958,9 @@ jobs: MODEL_HUB_TESTS_INSTALL_DIR: ${{ github.workspace }}/install/tests/model_hub_tests steps: + - name: Check sudo + run: if [ "$(id -u)" -eq 0 ]; then apt update && apt --assume-yes install sudo; fi + - name: Maximize build space run: | sudo rm -rf /usr/local/lib/android # will release about 10 GB if you don't need Android From d617822571c5fb69b7d77451f4aa16173fc09b59 Mon Sep 17 00:00:00 2001 From: Mikhail Ryzhov Date: Mon, 25 Sep 2023 15:13:31 +0200 Subject: [PATCH 12/57] upgrade pip --- .github/workflows/linux.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 5123cea46d854b..cf47a270e42b3e 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -972,10 +972,6 @@ jobs: - name: Create Directories run: mkdir -p ${{ env.INSTALL_DIR }} ${{ env.INSTALL_TEST_DIR }} ${{ env.PIP_CACHE_DIR }} - - uses: actions/setup-python@v4 - with: - python-version: '3.11' - - name: Download OpenVINO package uses: actions/download-artifact@v3 with: @@ -997,8 +993,13 @@ jobs: tar -xzf openvino_tests.tar.gz -C ${{ env.INSTALL_DIR }} && rm openvino_tests.tar.gz || exit 1 popd + - uses: actions/setup-python@v4 + with: + python-version: '3.11' + - name: Install Python wheels run: | + python3 -m pip install --upgrade pip python3 -m pip install openvino --find-links=${{ env.INSTALL_DIR }}/tools - name: Install PyTorch tests requirements From f6d9887cf824fcac9e380d5ffeded72c5aaefb59 Mon Sep 17 00:00:00 2001 From: Mikhail Ryzhov Date: Mon, 25 Sep 2023 18:25:15 +0200 Subject: [PATCH 13/57] set bash environments --- .github/workflows/linux.yml | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index cf47a270e42b3e..95d4033365087e 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -857,7 +857,7 @@ jobs: - name: Upload Test Results uses: actions/upload-artifact@v3 - if: ${{ always() }} + if: ${{ always() && !cancelled()}} with: name: test-results-functional-cpu path: | @@ -970,7 +970,7 @@ jobs: df -h - name: Create Directories - run: mkdir -p ${{ env.INSTALL_DIR }} ${{ env.INSTALL_TEST_DIR }} ${{ env.PIP_CACHE_DIR }} + run: mkdir -p ${INSTALL_DIR} ${INSTALL_TEST_DIR} ${PIP_CACHE_DIR} - name: Download OpenVINO package uses: actions/download-artifact@v3 @@ -986,11 +986,11 @@ jobs: - name: Extract OpenVINO packages run: | - pushd ${{ env.INSTALL_DIR }} - tar -xzf openvino_package.tar.gz -C ${{ env.INSTALL_DIR }} && rm openvino_package.tar.gz || exit 1 + pushd ${INSTALL_DIR} + tar -xzf openvino_package.tar.gz -C ${INSTALL_DIR} && rm openvino_package.tar.gz || exit 1 popd - pushd ${{ env.INSTALL_TEST_DIR }} - tar -xzf openvino_tests.tar.gz -C ${{ env.INSTALL_DIR }} && rm openvino_tests.tar.gz || exit 1 + pushd ${INSTALL_TEST_DIR} + tar -xzf openvino_tests.tar.gz -C ${INSTALL_DIR} && rm openvino_tests.tar.gz || exit 1 popd - uses: actions/setup-python@v4 @@ -1000,12 +1000,12 @@ jobs: - name: Install Python wheels run: | python3 -m pip install --upgrade pip - python3 -m pip install openvino --find-links=${{ env.INSTALL_DIR }}/tools + python3 -m pip install openvino --find-links=${INSTALL_DIR}/tools - name: Install PyTorch tests requirements run: | - python3 -m pip install -r ${{ env.MODEL_HUB_TESTS_INSTALL_DIR }}/torch_tests/requirements.txt - python3 -m pip install -r ${{ env.MODEL_HUB_TESTS_INSTALL_DIR }}/torch_tests/requirements_secondary.txt + python3 -m pip install -r ${MODEL_HUB_TESTS_INSTALL_DIR}/torch_tests/requirements.txt + python3 -m pip install -r ${MODEL_HUB_TESTS_INSTALL_DIR}/torch_tests/requirements_secondary.txt python3 -m pip cache purge echo "Available storage:" df -h @@ -1013,8 +1013,8 @@ jobs: - name: PyTorch Models Tests run: | - export PYTHONPATH=${{ env.MODEL_HUB_TESTS_INSTALL_DIR }}:$PYTHONPATH - python3 -m pytest ${{ env.MODEL_HUB_TESTS_INSTALL_DIR }}/torch_tests/ -m ${{ env.TYPE }} --html=${{ env.INSTALL_TEST_DIR }}/TEST-torch_model_tests.html --self-contained-html -v + export PYTHONPATH=${MODEL_HUB_TESTS_INSTALL_DIR}:$PYTHONPATH + python3 -m pytest ${MODEL_HUB_TESTS_INSTALL_DIR}/torch_tests/ -m ${TYPE} --html=${INSTALL_TEST_DIR}/TEST-torch_model_tests.html --self-contained-html -v env: TYPE: ${{ github.event_name == 'schedule' && 'nightly' || 'precommit'}} TEST_DEVICE: CPU From 5e4638e2106ad2df90878d31cbccaeea67d325c9 Mon Sep 17 00:00:00 2001 From: Mikhail Ryzhov Date: Mon, 25 Sep 2023 18:47:04 +0200 Subject: [PATCH 14/57] install pip deps --- .github/workflows/linux.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 95d4033365087e..cd3a45e573a863 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -961,6 +961,11 @@ jobs: - name: Check sudo run: if [ "$(id -u)" -eq 0 ]; then apt update && apt --assume-yes install sudo; fi + - name: Install dependencies + run: | + # libssl1.1 - 'python3 -m pip' in self-hosted runner + sudo apt install --assume-yes --no-install-recommends libssl1.1 + - name: Maximize build space run: | sudo rm -rf /usr/local/lib/android # will release about 10 GB if you don't need Android From efbdef519b9dae401d0d6a0b8949ea377e3622fc Mon Sep 17 00:00:00 2001 From: Mikhail Ryzhov Date: Mon, 25 Sep 2023 19:14:26 +0200 Subject: [PATCH 15/57] added git installation --- .github/workflows/linux.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index cd3a45e573a863..e73add6245daf6 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -965,6 +965,8 @@ jobs: run: | # libssl1.1 - 'python3 -m pip' in self-hosted runner sudo apt install --assume-yes --no-install-recommends libssl1.1 + # install git + sudo apt-get install --assume-yes --no-install-recommends git ca-certificates - name: Maximize build space run: | From 488c08f5c246c74672fa2917d1b1e981a7f418ac Mon Sep 17 00:00:00 2001 From: Mikhail Ryzhov Date: Mon, 25 Sep 2023 19:41:34 +0200 Subject: [PATCH 16/57] added g++ deps --- .github/workflows/linux.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index e73add6245daf6..845661fcfb4c46 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -965,8 +965,9 @@ jobs: run: | # libssl1.1 - 'python3 -m pip' in self-hosted runner sudo apt install --assume-yes --no-install-recommends libssl1.1 - # install git - sudo apt-get install --assume-yes --no-install-recommends git ca-certificates + # install git (requeried to build pip deps from the sources) + # install g++ to build 'detectron2' and 'natten' wheels + sudo apt-get install --assume-yes --no-install-recommends g++ git ca-certificates - name: Maximize build space run: | From a7d532f256c22bb722190f2a380304a21f0df0ee Mon Sep 17 00:00:00 2001 From: Mikhail Ryzhov Date: Mon, 25 Sep 2023 20:02:08 +0200 Subject: [PATCH 17/57] added python-dev package --- .github/workflows/linux.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 845661fcfb4c46..db733501e70d89 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -966,8 +966,8 @@ jobs: # libssl1.1 - 'python3 -m pip' in self-hosted runner sudo apt install --assume-yes --no-install-recommends libssl1.1 # install git (requeried to build pip deps from the sources) - # install g++ to build 'detectron2' and 'natten' wheels - sudo apt-get install --assume-yes --no-install-recommends g++ git ca-certificates + # install 'g++' and 'python3-dev' to build 'detectron2' and 'natten' wheels + sudo apt-get install --assume-yes --no-install-recommends g++ python3-dev git ca-certificates - name: Maximize build space run: | From cde65e6dcf4f713628387eae00e579cb6eb3fdf8 Mon Sep 17 00:00:00 2001 From: Mikhail Ryzhov Date: Mon, 25 Sep 2023 21:27:27 +0200 Subject: [PATCH 18/57] get particular python-dev package --- .github/workflows/linux.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index db733501e70d89..82a010778a2aaa 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -966,8 +966,8 @@ jobs: # libssl1.1 - 'python3 -m pip' in self-hosted runner sudo apt install --assume-yes --no-install-recommends libssl1.1 # install git (requeried to build pip deps from the sources) - # install 'g++' and 'python3-dev' to build 'detectron2' and 'natten' wheels - sudo apt-get install --assume-yes --no-install-recommends g++ python3-dev git ca-certificates + # install 'g++' and 'libpython3.11-dev' to build 'detectron2' and 'natten' wheels + sudo apt-get install --assume-yes --no-install-recommends g++ libpython3.11-dev git ca-certificates - name: Maximize build space run: | From 1182422bbc9ed13a71075eef93240ced0b9a67db Mon Sep 17 00:00:00 2001 From: Mikhail Ryzhov Date: Mon, 25 Sep 2023 21:48:51 +0200 Subject: [PATCH 19/57] fixed package name --- .github/workflows/linux.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 82a010778a2aaa..06b8af319f47d4 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -966,8 +966,8 @@ jobs: # libssl1.1 - 'python3 -m pip' in self-hosted runner sudo apt install --assume-yes --no-install-recommends libssl1.1 # install git (requeried to build pip deps from the sources) - # install 'g++' and 'libpython3.11-dev' to build 'detectron2' and 'natten' wheels - sudo apt-get install --assume-yes --no-install-recommends g++ libpython3.11-dev git ca-certificates + # install 'g++' and 'python3.11-dev' to build 'detectron2' and 'natten' wheels + sudo apt-get install --assume-yes --no-install-recommends g++ python3.11-dev git ca-certificates - name: Maximize build space run: | From 6fee31f8b7d86bb4ffec0d56258f04db8abbc711 Mon Sep 17 00:00:00 2001 From: Mikhail Ryzhov Date: Tue, 26 Sep 2023 10:45:32 +0200 Subject: [PATCH 20/57] removed python-dev --- .github/workflows/linux.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 06b8af319f47d4..0d242400ac2756 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -966,8 +966,8 @@ jobs: # libssl1.1 - 'python3 -m pip' in self-hosted runner sudo apt install --assume-yes --no-install-recommends libssl1.1 # install git (requeried to build pip deps from the sources) - # install 'g++' and 'python3.11-dev' to build 'detectron2' and 'natten' wheels - sudo apt-get install --assume-yes --no-install-recommends g++ python3.11-dev git ca-certificates + # install 'g++' to build 'detectron2' and 'natten' wheels + sudo apt-get install --assume-yes --no-install-recommends g++ git ca-certificates - name: Maximize build space run: | From 9514897fe95e6a1a7c47fea3cefaef7c0a89ad3a Mon Sep 17 00:00:00 2001 From: Mikhail Ryzhov Date: Tue, 26 Sep 2023 11:45:47 +0200 Subject: [PATCH 21/57] cython dep --- .github/workflows/linux.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 0d242400ac2756..a864f09b7a5f11 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -1003,12 +1003,13 @@ jobs: - uses: actions/setup-python@v4 with: - python-version: '3.11' + python-version: '3.11-dev' - name: Install Python wheels run: | python3 -m pip install --upgrade pip python3 -m pip install openvino --find-links=${INSTALL_DIR}/tools + python3 -m pip install Cython - name: Install PyTorch tests requirements run: | From 3ca57f47733776a8c0f1165333b14e0645be0ca9 Mon Sep 17 00:00:00 2001 From: Mikhail Ryzhov Date: Tue, 26 Sep 2023 12:23:38 +0200 Subject: [PATCH 22/57] debug --- .github/workflows/linux.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index a864f09b7a5f11..7321457c00357e 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -1003,16 +1003,17 @@ jobs: - uses: actions/setup-python@v4 with: - python-version: '3.11-dev' + python-version: '3.11' - name: Install Python wheels run: | python3 -m pip install --upgrade pip python3 -m pip install openvino --find-links=${INSTALL_DIR}/tools - python3 -m pip install Cython - name: Install PyTorch tests requirements run: | + export CPLUS_INCLUDE_PATH=${AGENT_TOOLSDIRECTORY}/include/python3.11 + echo $AGENT_TOOLSDIRECTORY python3 -m pip install -r ${MODEL_HUB_TESTS_INSTALL_DIR}/torch_tests/requirements.txt python3 -m pip install -r ${MODEL_HUB_TESTS_INSTALL_DIR}/torch_tests/requirements_secondary.txt python3 -m pip cache purge From 81af378943cbfc1ee2038f477d90e5c081d5a05a Mon Sep 17 00:00:00 2001 From: Mikhail Ryzhov Date: Tue, 26 Sep 2023 12:45:05 +0200 Subject: [PATCH 23/57] fixed inlude path --- .github/workflows/linux.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 7321457c00357e..8d049879094fb0 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -1012,7 +1012,7 @@ jobs: - name: Install PyTorch tests requirements run: | - export CPLUS_INCLUDE_PATH=${AGENT_TOOLSDIRECTORY}/include/python3.11 + export CPLUS_INCLUDE_PATH=${Python_ROOT_DIR}/include/python3.11 echo $AGENT_TOOLSDIRECTORY python3 -m pip install -r ${MODEL_HUB_TESTS_INSTALL_DIR}/torch_tests/requirements.txt python3 -m pip install -r ${MODEL_HUB_TESTS_INSTALL_DIR}/torch_tests/requirements_secondary.txt From 14b685de5d4e9dd80ddfb86c69b7e5e3ecc293bf Mon Sep 17 00:00:00 2001 From: Mikhail Ryzhov Date: Tue, 26 Sep 2023 13:56:13 +0200 Subject: [PATCH 24/57] test cache --- .github/workflows/linux.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 8d049879094fb0..ed8d30039a658c 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -1012,14 +1012,16 @@ jobs: - name: Install PyTorch tests requirements run: | - export CPLUS_INCLUDE_PATH=${Python_ROOT_DIR}/include/python3.11 - echo $AGENT_TOOLSDIRECTORY + # export CPLUS_INCLUDE_PATH=${Python_ROOT_DIR}/include/python3.11 python3 -m pip install -r ${MODEL_HUB_TESTS_INSTALL_DIR}/torch_tests/requirements.txt python3 -m pip install -r ${MODEL_HUB_TESTS_INSTALL_DIR}/torch_tests/requirements_secondary.txt - python3 -m pip cache purge + # python3 -m pip cache purge echo "Available storage:" df -h - du -h -d0 ~/.cache ~/* + du -h -d0 ${PIP_CACHE_DIR} ~/* + env: + CPLUS_INCLUDE_PATH: ${{ env.Python_ROOT_DIR }}/include/python3.11 + - name: PyTorch Models Tests run: | From 9800a416a6d6086fcae57acf252bec7846f629c7 Mon Sep 17 00:00:00 2001 From: Mikhail Ryzhov Date: Tue, 26 Sep 2023 15:03:18 +0200 Subject: [PATCH 25/57] set home dir --- .github/workflows/linux.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index ed8d30039a658c..22155e04ed8286 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -1018,7 +1018,7 @@ jobs: # python3 -m pip cache purge echo "Available storage:" df -h - du -h -d0 ${PIP_CACHE_DIR} ~/* + du -h -d0 ${PIP_CACHE_DIR} ${HOME}/* env: CPLUS_INCLUDE_PATH: ${{ env.Python_ROOT_DIR }}/include/python3.11 From 3cde062bc9a243772f868274820f8c0c8e4f0228 Mon Sep 17 00:00:00 2001 From: Mikhail Ryzhov Date: Tue, 26 Sep 2023 16:32:57 +0200 Subject: [PATCH 26/57] changed disk space calculation --- .github/workflows/linux.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 22155e04ed8286..0d46d76ea7d0a8 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -1018,7 +1018,7 @@ jobs: # python3 -m pip cache purge echo "Available storage:" df -h - du -h -d0 ${PIP_CACHE_DIR} ${HOME}/* + du -h -d0 ${PIP_CACHE_DIR} ${HOME} env: CPLUS_INCLUDE_PATH: ${{ env.Python_ROOT_DIR }}/include/python3.11 @@ -1035,7 +1035,7 @@ jobs: run: | echo "Available storage:" df -h - du -h -d0 ~/.cache ~/* + du -h -d0 ${PIP_CACHE_DIR} ${HOME} - name: Upload Test Results uses: actions/upload-artifact@v3 From a344fd51be009cb4a85c2e36f25b0127652513b8 Mon Sep 17 00:00:00 2001 From: Mikhail Ryzhov Date: Tue, 26 Sep 2023 17:47:46 +0200 Subject: [PATCH 27/57] crosspipeline pip cache --- .github/workflows/linux.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 0d46d76ea7d0a8..dee168e04de705 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -55,6 +55,8 @@ jobs: CCACHE_DIR: /mount/caches/ccache/ubuntu20_x86_64_Release CCACHE_TEMPDIR: /__w/openvino/openvino/ccache_temp CCACHE_MAXSIZE: 50G + PIP_CACHE_DIR: /mount/caches/pip/linux + steps: - name: Install git run: | @@ -116,9 +118,8 @@ jobs: # Build # - - name: Setup ccache - run: | - mkdir -p $CCACHE_DIR + - name: Setup cache dirs + run: mkdir -p ${CCACHE_DIR} ${PIP_CACHE_DIR} - name: CMake configure - OpenVINO run: | @@ -579,10 +580,11 @@ jobs: INSTALL_DIR: /__w/openvino/openvino/install INSTALL_TEST_DIR: /__w/openvino/openvino/install/tests LAYER_TESTS_INSTALL_DIR: /__w/openvino/openvino/install/tests/layer_tests + PIP_CACHE_DIR: /mount/caches/pip/linux steps: - name: Create Directories - run: mkdir -p ${INSTALL_DIR} ${INSTALL_TEST_DIR} + run: mkdir -p ${INSTALL_DIR} ${INSTALL_TEST_DIR} ${PIP_CACHE_DIR} - name: Install git run: | From aa0cbec867002d60d698b26f2822cc52fde821b1 Mon Sep 17 00:00:00 2001 From: Mikhail Ryzhov Date: Tue, 26 Sep 2023 17:58:42 +0200 Subject: [PATCH 28/57] added tag for source builded deps --- tests/model_hub_tests/torch_tests/requirements_secondary.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/model_hub_tests/torch_tests/requirements_secondary.txt b/tests/model_hub_tests/torch_tests/requirements_secondary.txt index f37ba0e81008ae..bdc6d301f5cb73 100644 --- a/tests/model_hub_tests/torch_tests/requirements_secondary.txt +++ b/tests/model_hub_tests/torch_tests/requirements_secondary.txt @@ -1,4 +1,4 @@ -c ../../constraints.txt # This file contains requirements dependednt from modules in requirements.txt -git+https://github.com/facebookresearch/detectron2.git +git+https://github.com/facebookresearch/detectron2.git#v0.6 natten From 66ab6c97229cc806758d6145ccee44c9cf4b9f68 Mon Sep 17 00:00:00 2001 From: Mikhail Ryzhov Date: Tue, 26 Sep 2023 18:28:55 +0200 Subject: [PATCH 29/57] immutable deps --- tests/model_hub_tests/torch_tests/requirements_secondary.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/model_hub_tests/torch_tests/requirements_secondary.txt b/tests/model_hub_tests/torch_tests/requirements_secondary.txt index bdc6d301f5cb73..1de0d3418eafb4 100644 --- a/tests/model_hub_tests/torch_tests/requirements_secondary.txt +++ b/tests/model_hub_tests/torch_tests/requirements_secondary.txt @@ -1,4 +1,4 @@ -c ../../constraints.txt # This file contains requirements dependednt from modules in requirements.txt -git+https://github.com/facebookresearch/detectron2.git#v0.6 +git+https://github.com/facebookresearch/detectron2.git@015da5b4e612a6eeaee9a92be7878770c7836156 natten From fc16251647e4058d9cceeaf0da5b404c033133ce Mon Sep 17 00:00:00 2001 From: Mikhail Ryzhov Date: Tue, 26 Sep 2023 19:23:17 +0200 Subject: [PATCH 30/57] use commit id instead of tag --- tests/model_hub_tests/torch_tests/requirements_secondary.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/model_hub_tests/torch_tests/requirements_secondary.txt b/tests/model_hub_tests/torch_tests/requirements_secondary.txt index 1de0d3418eafb4..9e49bfa05a41ec 100644 --- a/tests/model_hub_tests/torch_tests/requirements_secondary.txt +++ b/tests/model_hub_tests/torch_tests/requirements_secondary.txt @@ -1,4 +1,5 @@ -c ../../constraints.txt # This file contains requirements dependednt from modules in requirements.txt -git+https://github.com/facebookresearch/detectron2.git@015da5b4e612a6eeaee9a92be7878770c7836156 +# get immutable commit for tag v0.6 +git+https://github.com/facebookresearch/detectron2.git@d1e04565d3bec8719335b88be9e9b961bf3ec464 natten From f620e12a289f5514f2b7302ece77022a438b67f7 Mon Sep 17 00:00:00 2001 From: Mikhail Ryzhov Date: Wed, 27 Sep 2023 08:33:38 +0200 Subject: [PATCH 31/57] Update .github/workflows/linux.yml Co-authored-by: Ilya Lavrenov --- .github/workflows/linux.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index dee168e04de705..f0e0010012ee7c 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -967,7 +967,7 @@ jobs: run: | # libssl1.1 - 'python3 -m pip' in self-hosted runner sudo apt install --assume-yes --no-install-recommends libssl1.1 - # install git (requeried to build pip deps from the sources) + # install git (required to build pip deps from the sources) # install 'g++' to build 'detectron2' and 'natten' wheels sudo apt-get install --assume-yes --no-install-recommends g++ git ca-certificates From a69081f24ab74f5bc422536dab7d17f26bbcecd1 Mon Sep 17 00:00:00 2001 From: Mikhail Ryzhov Date: Wed, 27 Sep 2023 09:16:11 +0200 Subject: [PATCH 32/57] fixed logs upload condition --- .github/workflows/linux.yml | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index f0e0010012ee7c..5f771dd7f23555 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -368,7 +368,7 @@ jobs: - name: Upload Test Results uses: actions/upload-artifact@v3 - if: ${{ always() }} + if: ${{ always() && !cancelled()}} with: name: test-results-cpp path: ${{ env.INSTALL_TEST_DIR }}/TEST*.xml @@ -561,7 +561,7 @@ jobs: - name: Upload Test Results uses: actions/upload-artifact@v3 - if: ${{ always() }} + if: ${{ always() && !cancelled()}} with: name: test-results-cpp path: ${{ env.INSTALL_TEST_DIR }}/TEST*.xml @@ -575,6 +575,8 @@ jobs: runs-on: aks-linux-4-cores container: image: openvinogithubactions.azurecr.io/dockerhub/ubuntu:20.04 + volumes: + - /mount/caches:/mount/caches env: OPENVINO_REPO: /__w/openvino/openvino/openvino INSTALL_DIR: /__w/openvino/openvino/install @@ -776,7 +778,7 @@ jobs: - name: Upload Test Results uses: actions/upload-artifact@v3 - if: ${{ always() }} + if: ${{ always() && !cancelled()}} with: name: test-results-python path: | @@ -936,7 +938,7 @@ jobs: - name: Upload Test Results uses: actions/upload-artifact@v3 - if: ${{ always() }} + if: ${{ always() && !cancelled()}} with: name: test-results-tensorflow-hub-models path: | @@ -1041,7 +1043,7 @@ jobs: - name: Upload Test Results uses: actions/upload-artifact@v3 - if: ${{ always() }} + if: ${{ always() && !cancelled()}} with: name: test-results-torch-models path: | From 9b1a95292d84b0829e8e0d24ed830e96a71efeb3 Mon Sep 17 00:00:00 2001 From: Mikhail Ryzhov Date: Wed, 27 Sep 2023 09:19:41 +0200 Subject: [PATCH 33/57] removed pip upgrade --- .github/workflows/linux.yml | 1 - src/plugins/intel_cpu/thirdparty/onednn | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 5f771dd7f23555..cd6f4c87ef905f 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -1011,7 +1011,6 @@ jobs: - name: Install Python wheels run: | - python3 -m pip install --upgrade pip python3 -m pip install openvino --find-links=${INSTALL_DIR}/tools - name: Install PyTorch tests requirements diff --git a/src/plugins/intel_cpu/thirdparty/onednn b/src/plugins/intel_cpu/thirdparty/onednn index 36c2060a0dc85b..3767662f257270 160000 --- a/src/plugins/intel_cpu/thirdparty/onednn +++ b/src/plugins/intel_cpu/thirdparty/onednn @@ -1 +1 @@ -Subproject commit 36c2060a0dc85b4def72ea30823936c2ef861b82 +Subproject commit 3767662f257270921b64ec9a40e45a46b4ef048c From 1eb26ce6d3663b82cc3e7d8b5f1fa727ae4999aa Mon Sep 17 00:00:00 2001 From: Mikhail Ryzhov Date: Wed, 27 Sep 2023 09:56:18 +0200 Subject: [PATCH 34/57] changed detectotron version --- tests/model_hub_tests/torch_tests/requirements_secondary.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/model_hub_tests/torch_tests/requirements_secondary.txt b/tests/model_hub_tests/torch_tests/requirements_secondary.txt index 9e49bfa05a41ec..af7e38ae585b6c 100644 --- a/tests/model_hub_tests/torch_tests/requirements_secondary.txt +++ b/tests/model_hub_tests/torch_tests/requirements_secondary.txt @@ -1,5 +1,5 @@ -c ../../constraints.txt # This file contains requirements dependednt from modules in requirements.txt -# get immutable commit for tag v0.6 -git+https://github.com/facebookresearch/detectron2.git@d1e04565d3bec8719335b88be9e9b961bf3ec464 +# get immutable commit to be ebale to use pip cache +git+https://github.com/facebookresearch/detectron2.git@1a4df4d954089534daebbd7a0a45f08ece87056e natten From 3d7874f947439bdb38867cbabc2474922d259ab0 Mon Sep 17 00:00:00 2001 From: Mikhail Ryzhov Date: Wed, 27 Sep 2023 09:59:44 +0200 Subject: [PATCH 35/57] Update tests/model_hub_tests/torch_tests/requirements_secondary.txt Co-authored-by: Ilya Lavrenov --- tests/model_hub_tests/torch_tests/requirements_secondary.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/model_hub_tests/torch_tests/requirements_secondary.txt b/tests/model_hub_tests/torch_tests/requirements_secondary.txt index af7e38ae585b6c..803c3c4b839006 100644 --- a/tests/model_hub_tests/torch_tests/requirements_secondary.txt +++ b/tests/model_hub_tests/torch_tests/requirements_secondary.txt @@ -1,5 +1,5 @@ -c ../../constraints.txt # This file contains requirements dependednt from modules in requirements.txt -# get immutable commit to be ebale to use pip cache +# get immutable commit to be able to use pip cache git+https://github.com/facebookresearch/detectron2.git@1a4df4d954089534daebbd7a0a45f08ece87056e natten From 108864cf4a4eae8147c007e5f172928eb9fdfa4e Mon Sep 17 00:00:00 2001 From: Mikhail Ryzhov Date: Wed, 27 Sep 2023 10:12:19 +0200 Subject: [PATCH 36/57] changed wheel installation way --- .github/workflows/linux.yml | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index cd6f4c87ef905f..c93bdbeb908ef3 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -1009,16 +1009,13 @@ jobs: with: python-version: '3.11' - - name: Install Python wheels - run: | - python3 -m pip install openvino --find-links=${INSTALL_DIR}/tools + - name: Install OpenVINO Python wheels + run: python3 -m pip install ${INSTALL_DIR}/tools/openvino-* - name: Install PyTorch tests requirements run: | # export CPLUS_INCLUDE_PATH=${Python_ROOT_DIR}/include/python3.11 - python3 -m pip install -r ${MODEL_HUB_TESTS_INSTALL_DIR}/torch_tests/requirements.txt - python3 -m pip install -r ${MODEL_HUB_TESTS_INSTALL_DIR}/torch_tests/requirements_secondary.txt - # python3 -m pip cache purge + python3 -m pip install -r ${MODEL_HUB_TESTS_INSTALL_DIR}/torch_tests/requirements.txt -r ${MODEL_HUB_TESTS_INSTALL_DIR}/torch_tests/requirements_secondary.txt echo "Available storage:" df -h du -h -d0 ${PIP_CACHE_DIR} ${HOME} From f6da38f078e4c327f27463e4d92d88ac2b2cb93d Mon Sep 17 00:00:00 2001 From: Mikhail Ryzhov Date: Wed, 27 Sep 2023 11:02:40 +0200 Subject: [PATCH 37/57] added cleanup workload --- .github/workflows/cleanup_pip_cache.yml | 37 +++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 .github/workflows/cleanup_pip_cache.yml diff --git a/.github/workflows/cleanup_pip_cache.yml b/.github/workflows/cleanup_pip_cache.yml new file mode 100644 index 00000000000000..517c45e4fd58c8 --- /dev/null +++ b/.github/workflows/cleanup_pip_cache.yml @@ -0,0 +1,37 @@ +name: Cleanup PIP caches +on: + schedule: + # at 00:00 on the 1st day of every month + # - cron: '0 0 1 * *' + # Every 10 minutes (to test only) + - cron: '*/5 * * * *' + +jobs: + Cleanup_Linux_Cache: + runs-on: aks-linux-2-cores + container: + image: openvinogithubactions.azurecr.io/dockerhub/ubuntu:20.04 + volumes: + - /mount/caches:/mount/caches + env: + PIP_CACHE_DIR: /mount/caches/pip/linux + + steps: + - uses: actions/setup-python@v4 + with: + python-version: '3.11' + + - name: Pre-Collecting Cache Info + run: | + echo "Cache path: " + python3 -m pip cache dir + echo "Cache info: " + python3 -m pip cache info + + - name: Cleanup cache + run: python3 -m pip cache purge + + - name: Post-Collecting Cache Info + run: | + echo "Cache info: " + python3 -m pip cache info From e57cc9e38c9f849f10589a103be4d371f100782d Mon Sep 17 00:00:00 2001 From: Mikhail Ryzhov Date: Wed, 27 Sep 2023 10:02:05 +0200 Subject: [PATCH 38/57] reset onednn --- src/plugins/intel_cpu/thirdparty/onednn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/intel_cpu/thirdparty/onednn b/src/plugins/intel_cpu/thirdparty/onednn index 3767662f257270..36c2060a0dc85b 160000 --- a/src/plugins/intel_cpu/thirdparty/onednn +++ b/src/plugins/intel_cpu/thirdparty/onednn @@ -1 +1 @@ -Subproject commit 3767662f257270921b64ec9a40e45a46b4ef048c +Subproject commit 36c2060a0dc85b4def72ea30823936c2ef861b82 From f0c6cf53e1683eb431433e7edcd15b709f548e93 Mon Sep 17 00:00:00 2001 From: Mikhail Ryzhov Date: Wed, 27 Sep 2023 12:01:16 +0200 Subject: [PATCH 39/57] cleanup test --- .github/workflows/linux.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index c93bdbeb908ef3..885401713b2e58 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -1014,7 +1014,6 @@ jobs: - name: Install PyTorch tests requirements run: | - # export CPLUS_INCLUDE_PATH=${Python_ROOT_DIR}/include/python3.11 python3 -m pip install -r ${MODEL_HUB_TESTS_INSTALL_DIR}/torch_tests/requirements.txt -r ${MODEL_HUB_TESTS_INSTALL_DIR}/torch_tests/requirements_secondary.txt echo "Available storage:" df -h @@ -1022,7 +1021,6 @@ jobs: env: CPLUS_INCLUDE_PATH: ${{ env.Python_ROOT_DIR }}/include/python3.11 - - name: PyTorch Models Tests run: | export PYTHONPATH=${MODEL_HUB_TESTS_INSTALL_DIR}:$PYTHONPATH @@ -1039,7 +1037,7 @@ jobs: - name: Upload Test Results uses: actions/upload-artifact@v3 - if: ${{ always() && !cancelled()}} + if: ${{ !cancelled() }} with: name: test-results-torch-models path: | From cc6051c7619cafbb95abde905f1e8da836d984c1 Mon Sep 17 00:00:00 2001 From: Mikhail Ryzhov Date: Wed, 27 Sep 2023 12:47:07 +0200 Subject: [PATCH 40/57] fixed reqs install --- .github/workflows/linux.yml | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 885401713b2e58..a598eeb0d2f4ef 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -368,7 +368,7 @@ jobs: - name: Upload Test Results uses: actions/upload-artifact@v3 - if: ${{ always() && !cancelled()}} + if: ${{ !cancelled() }} with: name: test-results-cpp path: ${{ env.INSTALL_TEST_DIR }}/TEST*.xml @@ -561,7 +561,7 @@ jobs: - name: Upload Test Results uses: actions/upload-artifact@v3 - if: ${{ always() && !cancelled()}} + if: ${{ !cancelled() }} with: name: test-results-cpp path: ${{ env.INSTALL_TEST_DIR }}/TEST*.xml @@ -778,7 +778,7 @@ jobs: - name: Upload Test Results uses: actions/upload-artifact@v3 - if: ${{ always() && !cancelled()}} + if: ${{ !cancelled() }} with: name: test-results-python path: | @@ -861,7 +861,7 @@ jobs: - name: Upload Test Results uses: actions/upload-artifact@v3 - if: ${{ always() && !cancelled()}} + if: ${{ !cancelled() }} with: name: test-results-functional-cpu path: | @@ -938,7 +938,7 @@ jobs: - name: Upload Test Results uses: actions/upload-artifact@v3 - if: ${{ always() && !cancelled()}} + if: ${{ !cancelled() }} with: name: test-results-tensorflow-hub-models path: | @@ -1014,7 +1014,8 @@ jobs: - name: Install PyTorch tests requirements run: | - python3 -m pip install -r ${MODEL_HUB_TESTS_INSTALL_DIR}/torch_tests/requirements.txt -r ${MODEL_HUB_TESTS_INSTALL_DIR}/torch_tests/requirements_secondary.txt + python3 -m pip install -r ${MODEL_HUB_TESTS_INSTALL_DIR}/torch_tests/requirements.txt + python3 -m pip install -r ${MODEL_HUB_TESTS_INSTALL_DIR}/torch_tests/requirements_secondary.txt echo "Available storage:" df -h du -h -d0 ${PIP_CACHE_DIR} ${HOME} From c2b40e25f43eee546090b9616a7b27067611eaa7 Mon Sep 17 00:00:00 2001 From: Mikhail Ryzhov Date: Wed, 27 Sep 2023 14:03:27 +0200 Subject: [PATCH 41/57] test cache depending on pip version --- .github/workflows/linux.yml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index a598eeb0d2f4ef..5f97266967975a 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -96,6 +96,11 @@ jobs: with: python-version: '3.11' + - name: Set pip cache path + run: | + export PIP_VER = $(python3 -m pip --version | grep -o '[0-9]*[.][0-9]*[.][0-9]*') + echo "PIP_CACHE_DIR=${PIP_CACHE_DIR}/${PIP_VER} >> $GITHUB_ENV + - name: Install python dependencies run: | # For Python API: build and wheel packaging @@ -950,7 +955,7 @@ jobs: defaults: run: shell: bash - runs-on: ${{ github.event_name == 'schedule' && 'aks-linux-8-cores' || 'aks-linux-4-cores'}} + runs-on: ${{ github.event_name == 'schedule' && 'aks-linux-16-cores' || 'aks-linux-8-cores'}} container: image: openvinogithubactions.azurecr.io/dockerhub/ubuntu:20.04 volumes: @@ -1009,6 +1014,11 @@ jobs: with: python-version: '3.11' + - name: Set pip cache path + run: | + export PIP_VER = $(python3 -m pip --version | grep -o '[0-9]*[.][0-9]*[.][0-9]*') + echo "PIP_CACHE_DIR=${PIP_CACHE_DIR}/${PIP_VER} >> $GITHUB_ENV + - name: Install OpenVINO Python wheels run: python3 -m pip install ${INSTALL_DIR}/tools/openvino-* From 050ccc12e41dcc965a0978eee0ff4c549c3d528d Mon Sep 17 00:00:00 2001 From: Mikhail Ryzhov Date: Wed, 27 Sep 2023 14:10:39 +0200 Subject: [PATCH 42/57] syntax fix --- .github/workflows/linux.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 5f97266967975a..939045b16cc6e7 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -98,8 +98,8 @@ jobs: - name: Set pip cache path run: | - export PIP_VER = $(python3 -m pip --version | grep -o '[0-9]*[.][0-9]*[.][0-9]*') - echo "PIP_CACHE_DIR=${PIP_CACHE_DIR}/${PIP_VER} >> $GITHUB_ENV + export PIP_VER=$(python3 -m pip --version | grep -o '[0-9]*[.][0-9]*[.][0-9]*') + echo "PIP_CACHE_DIR=${PIP_CACHE_DIR}/${PIP_VER}" >> $GITHUB_ENV - name: Install python dependencies run: | From af828fc3b8ff24ee610411668aa53795692fe598 Mon Sep 17 00:00:00 2001 From: Mikhail Ryzhov Date: Wed, 27 Sep 2023 14:24:29 +0200 Subject: [PATCH 43/57] env overwriting test --- .github/workflows/linux.yml | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 939045b16cc6e7..84f0adbdacbabc 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -29,6 +29,9 @@ concurrency: group: ${{ github.event_name == 'push' && github.run_id || github.ref }}-linux cancel-in-progress: true +env: + PIP_CACHE_DIR: /mount/caches/pip/linux + jobs: Build: defaults: @@ -55,7 +58,6 @@ jobs: CCACHE_DIR: /mount/caches/ccache/ubuntu20_x86_64_Release CCACHE_TEMPDIR: /__w/openvino/openvino/ccache_temp CCACHE_MAXSIZE: 50G - PIP_CACHE_DIR: /mount/caches/pip/linux steps: - name: Install git @@ -99,7 +101,9 @@ jobs: - name: Set pip cache path run: | export PIP_VER=$(python3 -m pip --version | grep -o '[0-9]*[.][0-9]*[.][0-9]*') - echo "PIP_CACHE_DIR=${PIP_CACHE_DIR}/${PIP_VER}" >> $GITHUB_ENV + export PIP_CACHE_DIR=${PIP_CACHE_DIR}/${PIP_VER} + env: + PIP_CACHE_DIR: ${{ env.PIP_CACHE_DIR }} - name: Install python dependencies run: | @@ -1016,8 +1020,8 @@ jobs: - name: Set pip cache path run: | - export PIP_VER = $(python3 -m pip --version | grep -o '[0-9]*[.][0-9]*[.][0-9]*') - echo "PIP_CACHE_DIR=${PIP_CACHE_DIR}/${PIP_VER} >> $GITHUB_ENV + export PIP_VER=$(python3 -m pip --version | grep -o '[0-9]*[.][0-9]*[.][0-9]*') + echo "PIP_CACHE_DIR=${PIP_CACHE_DIR}/${PIP_VER}" >> $GITHUB_ENV - name: Install OpenVINO Python wheels run: python3 -m pip install ${INSTALL_DIR}/tools/openvino-* From 811cff4e264e04112eedb3131050c33e0ae345b5 Mon Sep 17 00:00:00 2001 From: Mikhail Ryzhov Date: Wed, 27 Sep 2023 14:30:17 +0200 Subject: [PATCH 44/57] test env output --- .github/workflows/linux.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 84f0adbdacbabc..7d658f116eb7cb 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -101,9 +101,7 @@ jobs: - name: Set pip cache path run: | export PIP_VER=$(python3 -m pip --version | grep -o '[0-9]*[.][0-9]*[.][0-9]*') - export PIP_CACHE_DIR=${PIP_CACHE_DIR}/${PIP_VER} - env: - PIP_CACHE_DIR: ${{ env.PIP_CACHE_DIR }} + echo "PIP_CACHE_DIR=${PIP_CACHE_DIR}/${PIP_VER}" >> $GITHUB_ENV - name: Install python dependencies run: | From a8c743a272deb1692d96dd9ac1667c627bf08a7b Mon Sep 17 00:00:00 2001 From: Mikhail Ryzhov Date: Wed, 27 Sep 2023 14:36:37 +0200 Subject: [PATCH 45/57] fixed set env step --- .github/workflows/linux.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 7d658f116eb7cb..d1fa5775454e4d 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -99,9 +99,7 @@ jobs: python-version: '3.11' - name: Set pip cache path - run: | - export PIP_VER=$(python3 -m pip --version | grep -o '[0-9]*[.][0-9]*[.][0-9]*') - echo "PIP_CACHE_DIR=${PIP_CACHE_DIR}/${PIP_VER}" >> $GITHUB_ENV + run: echo "PIP_CACHE_DIR=${PIP_CACHE_DIR}/$(python3 -m pip --version | grep -o '[0-9]*[.][0-9]*[.][0-9]*')" >> $GITHUB_ENV - name: Install python dependencies run: | From fd16ec9b0bdcbf6c606232f339ff41870cef9c2f Mon Sep 17 00:00:00 2001 From: Mikhail Ryzhov Date: Wed, 27 Sep 2023 14:50:53 +0200 Subject: [PATCH 46/57] move pip cahc initialization to step --- .github/workflows/linux.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index d1fa5775454e4d..3fff37b03c3176 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -98,11 +98,12 @@ jobs: with: python-version: '3.11' - - name: Set pip cache path - run: echo "PIP_CACHE_DIR=${PIP_CACHE_DIR}/$(python3 -m pip --version | grep -o '[0-9]*[.][0-9]*[.][0-9]*')" >> $GITHUB_ENV - - name: Install python dependencies run: | + # set pip cache + export PIP_CACHE_DIR=${PIP_CACHE_DIR}/$(python3 -m pip --version | grep -o '[0-9]*[.][0-9]*[.][0-9]*') + echo ${PIP_CACHE_DIR} + # For Python API: build and wheel packaging python3 -m pip install -r ${OPENVINO_REPO}/src/bindings/python/wheel/requirements-dev.txt python3 -m pip install -r ${OPENVINO_REPO}/src/bindings/python/src/compatibility/openvino/requirements-dev.txt From c4cdbf5d21b3385c9ed5377a27237ab63dc9058a Mon Sep 17 00:00:00 2001 From: Mikhail Ryzhov Date: Wed, 27 Sep 2023 15:10:58 +0200 Subject: [PATCH 47/57] changed pip ver regexp --- .github/workflows/linux.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 3fff37b03c3176..e95704f2f02576 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -98,13 +98,13 @@ jobs: with: python-version: '3.11' + - name: Set pip cache path + run: echo "PIP_CACHE_DIR=${PIP_CACHE_DIR}/$(python3 -m pip --version | grep -o 'pip [0-9]*[.][0-9]*[.][0-9]*' | grep -o '[0-9].*')" >> $GITHUB_ENV + - name: Install python dependencies run: | - # set pip cache - export PIP_CACHE_DIR=${PIP_CACHE_DIR}/$(python3 -m pip --version | grep -o '[0-9]*[.][0-9]*[.][0-9]*') - echo ${PIP_CACHE_DIR} - # For Python API: build and wheel packaging + echo $PIP_CACHE_DIR python3 -m pip install -r ${OPENVINO_REPO}/src/bindings/python/wheel/requirements-dev.txt python3 -m pip install -r ${OPENVINO_REPO}/src/bindings/python/src/compatibility/openvino/requirements-dev.txt From 0a2f778f945f479b9767ffd2bd9dc14651a9c2ca Mon Sep 17 00:00:00 2001 From: Mikhail Ryzhov Date: Wed, 27 Sep 2023 15:25:57 +0200 Subject: [PATCH 48/57] set custom pip cahce for each step --- .github/workflows/linux.yml | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index e95704f2f02576..998c6a20c82f55 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -30,7 +30,7 @@ concurrency: cancel-in-progress: true env: - PIP_CACHE_DIR: /mount/caches/pip/linux + PIP_CACHE_PATH: /mount/caches/pip/linux jobs: Build: @@ -97,14 +97,12 @@ jobs: - uses: actions/setup-python@v4 with: python-version: '3.11' - - - name: Set pip cache path - run: echo "PIP_CACHE_DIR=${PIP_CACHE_DIR}/$(python3 -m pip --version | grep -o 'pip [0-9]*[.][0-9]*[.][0-9]*' | grep -o '[0-9].*')" >> $GITHUB_ENV + - name: Set PIP Cache Dir + run: echo "PIP_CACHE_DIR=${PIP_CACHE_PATH}/$(python3 -m pip --version | grep -o 'pip [0-9]*[.][0-9]*[.][0-9]*' | grep -o '[0-9].*')" >> $GITHUB_ENV - name: Install python dependencies run: | # For Python API: build and wheel packaging - echo $PIP_CACHE_DIR python3 -m pip install -r ${OPENVINO_REPO}/src/bindings/python/wheel/requirements-dev.txt python3 -m pip install -r ${OPENVINO_REPO}/src/bindings/python/src/compatibility/openvino/requirements-dev.txt @@ -125,7 +123,7 @@ jobs: # - name: Setup cache dirs - run: mkdir -p ${CCACHE_DIR} ${PIP_CACHE_DIR} + run: mkdir -p ${CCACHE_DIR} - name: CMake configure - OpenVINO run: | @@ -588,11 +586,10 @@ jobs: INSTALL_DIR: /__w/openvino/openvino/install INSTALL_TEST_DIR: /__w/openvino/openvino/install/tests LAYER_TESTS_INSTALL_DIR: /__w/openvino/openvino/install/tests/layer_tests - PIP_CACHE_DIR: /mount/caches/pip/linux steps: - name: Create Directories - run: mkdir -p ${INSTALL_DIR} ${INSTALL_TEST_DIR} ${PIP_CACHE_DIR} + run: mkdir -p ${INSTALL_DIR} ${INSTALL_TEST_DIR} - name: Install git run: | @@ -611,6 +608,8 @@ jobs: - uses: actions/setup-python@v4 with: python-version: '3.11' + - name: Set PIP Cache Dir + run: echo "PIP_CACHE_DIR=${PIP_CACHE_PATH}/$(python3 -m pip --version | grep -o 'pip [0-9]*[.][0-9]*[.][0-9]*' | grep -o '[0-9].*')" >> $GITHUB_ENV - name: Install Python API tests dependencies run: | @@ -964,7 +963,6 @@ jobs: env: INSTALL_DIR: ${{ github.workspace }}/install INSTALL_TEST_DIR: ${{ github.workspace }}/install/tests - PIP_CACHE_DIR: /mount/caches/pip/linux MODEL_HUB_TESTS_INSTALL_DIR: ${{ github.workspace }}/install/tests/model_hub_tests steps: @@ -988,7 +986,7 @@ jobs: df -h - name: Create Directories - run: mkdir -p ${INSTALL_DIR} ${INSTALL_TEST_DIR} ${PIP_CACHE_DIR} + run: mkdir -p ${INSTALL_DIR} ${INSTALL_TEST_DIR} - name: Download OpenVINO package uses: actions/download-artifact@v3 @@ -1014,11 +1012,8 @@ jobs: - uses: actions/setup-python@v4 with: python-version: '3.11' - - - name: Set pip cache path - run: | - export PIP_VER=$(python3 -m pip --version | grep -o '[0-9]*[.][0-9]*[.][0-9]*') - echo "PIP_CACHE_DIR=${PIP_CACHE_DIR}/${PIP_VER}" >> $GITHUB_ENV + - name: Set PIP Cache Dir + run: echo "PIP_CACHE_DIR=${PIP_CACHE_PATH}/$(python3 -m pip --version | grep -o 'pip [0-9]*[.][0-9]*[.][0-9]*' | grep -o '[0-9].*')" >> $GITHUB_ENV - name: Install OpenVINO Python wheels run: python3 -m pip install ${INSTALL_DIR}/tools/openvino-* From 9f295b78a8dbc7d9a934eb3d27a9c28281d1e33e Mon Sep 17 00:00:00 2001 From: Mikhail Ryzhov Date: Wed, 27 Sep 2023 16:02:21 +0200 Subject: [PATCH 49/57] cleanup code and enabled test cleanup job --- .github/workflows/cleanup_pip_cache.yml | 22 ++++++----------- .github/workflows/linux.yml | 33 ++++++++++++++++++++++--- 2 files changed, 37 insertions(+), 18 deletions(-) diff --git a/.github/workflows/cleanup_pip_cache.yml b/.github/workflows/cleanup_pip_cache.yml index 517c45e4fd58c8..8574dea7b2e51a 100644 --- a/.github/workflows/cleanup_pip_cache.yml +++ b/.github/workflows/cleanup_pip_cache.yml @@ -2,36 +2,30 @@ name: Cleanup PIP caches on: schedule: # at 00:00 on the 1st day of every month - # - cron: '0 0 1 * *' - # Every 10 minutes (to test only) - - cron: '*/5 * * * *' + - cron: '0 0 1 * *' jobs: - Cleanup_Linux_Cache: + Cleanup_PIP_Caches: runs-on: aks-linux-2-cores container: image: openvinogithubactions.azurecr.io/dockerhub/ubuntu:20.04 volumes: - /mount/caches:/mount/caches env: - PIP_CACHE_DIR: /mount/caches/pip/linux + PIP_CACHE_PATH: /mount/caches/pip steps: - - uses: actions/setup-python@v4 - with: - python-version: '3.11' - - name: Pre-Collecting Cache Info run: | - echo "Cache path: " - python3 -m pip cache dir echo "Cache info: " - python3 -m pip cache info + du -h -d0 ${PIP_CACHE_PATH} - name: Cleanup cache - run: python3 -m pip cache purge + run: | + echo "Removing pip caches" + [ ! -z "${PIP_CACHE_PATH}" ] && rm -r ${PIP_CACHE_PATH}/* - name: Post-Collecting Cache Info run: | echo "Cache info: " - python3 -m pip cache info + du -h -d0 ${PIP_CACHE_PATH} diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 998c6a20c82f55..fcaa292606503a 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -97,7 +97,7 @@ jobs: - uses: actions/setup-python@v4 with: python-version: '3.11' - - name: Set PIP Cache Dir + - name: Setup pip cache dir run: echo "PIP_CACHE_DIR=${PIP_CACHE_PATH}/$(python3 -m pip --version | grep -o 'pip [0-9]*[.][0-9]*[.][0-9]*' | grep -o '[0-9].*')" >> $GITHUB_ENV - name: Install python dependencies @@ -122,7 +122,7 @@ jobs: # Build # - - name: Setup cache dirs + - name: Setup ccache dir run: mkdir -p ${CCACHE_DIR} - name: CMake configure - OpenVINO @@ -608,7 +608,7 @@ jobs: - uses: actions/setup-python@v4 with: python-version: '3.11' - - name: Set PIP Cache Dir + - name: Setup pip cache dir run: echo "PIP_CACHE_DIR=${PIP_CACHE_PATH}/$(python3 -m pip --version | grep -o 'pip [0-9]*[.][0-9]*[.][0-9]*' | grep -o '[0-9].*')" >> $GITHUB_ENV - name: Install Python API tests dependencies @@ -1012,7 +1012,7 @@ jobs: - uses: actions/setup-python@v4 with: python-version: '3.11' - - name: Set PIP Cache Dir + - name: Setup pip cache dir run: echo "PIP_CACHE_DIR=${PIP_CACHE_PATH}/$(python3 -m pip --version | grep -o 'pip [0-9]*[.][0-9]*[.][0-9]*' | grep -o '[0-9].*')" >> $GITHUB_ENV - name: Install OpenVINO Python wheels @@ -1050,3 +1050,28 @@ jobs: path: | ${{ env.INSTALL_TEST_DIR }}/TEST*.html if-no-files-found: 'error' + + Cleanup_PIP_Caches: + runs-on: aks-linux-2-cores + container: + image: openvinogithubactions.azurecr.io/dockerhub/ubuntu:20.04 + volumes: + - /mount/caches:/mount/caches + env: + PIP_CACHE_PATH: /mount/caches/pip + + steps: + - name: Pre-Collecting Cache Info + run: | + echo "Cache info: " + du -h -d0 ${PIP_CACHE_PATH} + + - name: Cleanup cache + run: | + echo "Removing pip caches" + [ ! -z "${PIP_CACHE_PATH}" ] && rm -r ${PIP_CACHE_PATH}/* + + - name: Post-Collecting Cache Info + run: | + echo "Cache info: " + du -h -d0 ${PIP_CACHE_PATH} \ No newline at end of file From 1cc01ebf73b340c5354c93b94b001d06f2bca3ac Mon Sep 17 00:00:00 2001 From: Mikhail Ryzhov Date: Wed, 27 Sep 2023 16:21:51 +0200 Subject: [PATCH 50/57] test cleanup 2 --- .github/workflows/cleanup_pip_cache.yml | 6 +++--- .github/workflows/linux.yml | 8 +++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/.github/workflows/cleanup_pip_cache.yml b/.github/workflows/cleanup_pip_cache.yml index 8574dea7b2e51a..21e564952fcd4b 100644 --- a/.github/workflows/cleanup_pip_cache.yml +++ b/.github/workflows/cleanup_pip_cache.yml @@ -18,14 +18,14 @@ jobs: - name: Pre-Collecting Cache Info run: | echo "Cache info: " - du -h -d0 ${PIP_CACHE_PATH} + du -h -d2 ${PIP_CACHE_PATH} - name: Cleanup cache run: | echo "Removing pip caches" - [ ! -z "${PIP_CACHE_PATH}" ] && rm -r ${PIP_CACHE_PATH}/* + [ ! -z "${PIP_CACHE_PATH}" ] && rm -rv ${PIP_CACHE_PATH}/* - name: Post-Collecting Cache Info run: | echo "Cache info: " - du -h -d0 ${PIP_CACHE_PATH} + du -h -d2 ${PIP_CACHE_PATH} diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index fcaa292606503a..5ab7fa83595050 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -1052,6 +1052,7 @@ jobs: if-no-files-found: 'error' Cleanup_PIP_Caches: + needs: Build runs-on: aks-linux-2-cores container: image: openvinogithubactions.azurecr.io/dockerhub/ubuntu:20.04 @@ -1064,14 +1065,15 @@ jobs: - name: Pre-Collecting Cache Info run: | echo "Cache info: " - du -h -d0 ${PIP_CACHE_PATH} + du -h -d2 ${PIP_CACHE_PATH} - name: Cleanup cache run: | echo "Removing pip caches" - [ ! -z "${PIP_CACHE_PATH}" ] && rm -r ${PIP_CACHE_PATH}/* + [ ! -z "${PIP_CACHE_PATH}" ] && rm -rv ${PIP_CACHE_PATH}/* - name: Post-Collecting Cache Info + if: ${{ !cancelled() }} run: | echo "Cache info: " - du -h -d0 ${PIP_CACHE_PATH} \ No newline at end of file + du -h -d2 ${PIP_CACHE_PATH} \ No newline at end of file From c71aafea25a0126b02d3aabeeae66f14779bd966 Mon Sep 17 00:00:00 2001 From: Mikhail Ryzhov Date: Wed, 27 Sep 2023 17:12:07 +0200 Subject: [PATCH 51/57] speedup removal --- .github/workflows/linux.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 5ab7fa83595050..61ab0e40286c9e 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -1052,7 +1052,6 @@ jobs: if-no-files-found: 'error' Cleanup_PIP_Caches: - needs: Build runs-on: aks-linux-2-cores container: image: openvinogithubactions.azurecr.io/dockerhub/ubuntu:20.04 @@ -1060,20 +1059,23 @@ jobs: - /mount/caches:/mount/caches env: PIP_CACHE_PATH: /mount/caches/pip + PIP_CACHE_TMP_PATH: /mount/caches/.pip steps: - name: Pre-Collecting Cache Info run: | - echo "Cache info: " + echo "Cache info:" du -h -d2 ${PIP_CACHE_PATH} - name: Cleanup cache run: | echo "Removing pip caches" - [ ! -z "${PIP_CACHE_PATH}" ] && rm -rv ${PIP_CACHE_PATH}/* + [ ! -z "${PIP_CACHE_TMP_PATH}" ] && rm -rv ${PIP_CACHE_TMP_PATH} + mv ${PIP_CACHE_PATH} ${PIP_CACHE_TMP_PATH} + [ ! -z "${PIP_CACHE_TMP_PATH}" ] && rm -rv ${PIP_CACHE_TMP_PATH} - name: Post-Collecting Cache Info if: ${{ !cancelled() }} run: | - echo "Cache info: " + echo "Cache info:" du -h -d2 ${PIP_CACHE_PATH} \ No newline at end of file From e206c28f24c0022eff6f885a7c33a3d594c48378 Mon Sep 17 00:00:00 2001 From: Mikhail Ryzhov Date: Wed, 27 Sep 2023 18:56:11 +0200 Subject: [PATCH 52/57] check existed dir --- .github/workflows/linux.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 61ab0e40286c9e..cbd8ed97bf11be 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -1070,7 +1070,7 @@ jobs: - name: Cleanup cache run: | echo "Removing pip caches" - [ ! -z "${PIP_CACHE_TMP_PATH}" ] && rm -rv ${PIP_CACHE_TMP_PATH} + [ -d "${PIP_CACHE_TMP_PATH}" ] && rm -rv ${PIP_CACHE_TMP_PATH} mv ${PIP_CACHE_PATH} ${PIP_CACHE_TMP_PATH} [ ! -z "${PIP_CACHE_TMP_PATH}" ] && rm -rv ${PIP_CACHE_TMP_PATH} From 2f18ad84458eca5b570cbb19c29e72d8d3fdeec8 Mon Sep 17 00:00:00 2001 From: Mikhail Ryzhov Date: Wed, 27 Sep 2023 19:01:31 +0200 Subject: [PATCH 53/57] Enabled cache for samples job --- .github/workflows/linux.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index cbd8ed97bf11be..b3a41d8d2f4bc3 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -327,6 +327,8 @@ jobs: - uses: actions/setup-python@v4 with: python-version: '3.11' + - name: Setup pip cache dir + run: echo "PIP_CACHE_DIR=${PIP_CACHE_PATH}/$(python3 -m pip --version | grep -o 'pip [0-9]*[.][0-9]*[.][0-9]*' | grep -o '[0-9].*')" >> $GITHUB_ENV - name: Install OpenVINO dependencies run: ${INSTALL_DIR}/install_dependencies/install_openvino_dependencies.sh -c=core -c=dev -y From 2b392009ea72ddb8a8e42442a08b51a1ffd4856d Mon Sep 17 00:00:00 2001 From: Mikhail Ryzhov Date: Wed, 27 Sep 2023 19:08:55 +0200 Subject: [PATCH 54/57] removed debug job --- .github/workflows/linux.yml | 31 +------------------------------ 1 file changed, 1 insertion(+), 30 deletions(-) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index b3a41d8d2f4bc3..ac10cbd4f21a04 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -1051,33 +1051,4 @@ jobs: name: test-results-torch-models path: | ${{ env.INSTALL_TEST_DIR }}/TEST*.html - if-no-files-found: 'error' - - Cleanup_PIP_Caches: - runs-on: aks-linux-2-cores - container: - image: openvinogithubactions.azurecr.io/dockerhub/ubuntu:20.04 - volumes: - - /mount/caches:/mount/caches - env: - PIP_CACHE_PATH: /mount/caches/pip - PIP_CACHE_TMP_PATH: /mount/caches/.pip - - steps: - - name: Pre-Collecting Cache Info - run: | - echo "Cache info:" - du -h -d2 ${PIP_CACHE_PATH} - - - name: Cleanup cache - run: | - echo "Removing pip caches" - [ -d "${PIP_CACHE_TMP_PATH}" ] && rm -rv ${PIP_CACHE_TMP_PATH} - mv ${PIP_CACHE_PATH} ${PIP_CACHE_TMP_PATH} - [ ! -z "${PIP_CACHE_TMP_PATH}" ] && rm -rv ${PIP_CACHE_TMP_PATH} - - - name: Post-Collecting Cache Info - if: ${{ !cancelled() }} - run: | - echo "Cache info:" - du -h -d2 ${PIP_CACHE_PATH} \ No newline at end of file + if-no-files-found: 'error' \ No newline at end of file From a45231e26a21a13d0e770ca045dd7b5688a87249 Mon Sep 17 00:00:00 2001 From: Mikhail Ryzhov Date: Thu, 28 Sep 2023 10:09:49 +0200 Subject: [PATCH 55/57] changed way how to get pip ver --- .github/workflows/linux.yml | 5 ++++- thirdparty/open_model_zoo | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index ac10cbd4f21a04..a9948e1b8d8971 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -98,7 +98,10 @@ jobs: with: python-version: '3.11' - name: Setup pip cache dir - run: echo "PIP_CACHE_DIR=${PIP_CACHE_PATH}/$(python3 -m pip --version | grep -o 'pip [0-9]*[.][0-9]*[.][0-9]*' | grep -o '[0-9].*')" >> $GITHUB_ENV + 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 dependencies run: | diff --git a/thirdparty/open_model_zoo b/thirdparty/open_model_zoo index d831efe10e7af4..f08b9b080b240b 160000 --- a/thirdparty/open_model_zoo +++ b/thirdparty/open_model_zoo @@ -1 +1 @@ -Subproject commit d831efe10e7af426ceba0b6ad65dbb5e5fc82beb +Subproject commit f08b9b080b240b4abd08830542ef532deeaf1da3 From 354de66bb73c3934446660580b5902437329194c Mon Sep 17 00:00:00 2001 From: Mikhail Ryzhov Date: Thu, 28 Sep 2023 10:20:46 +0200 Subject: [PATCH 56/57] improved pip version extration --- .github/workflows/linux.yml | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index a9948e1b8d8971..9bf02de6a1ff4f 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -331,7 +331,10 @@ jobs: with: python-version: '3.11' - name: Setup pip cache dir - run: echo "PIP_CACHE_DIR=${PIP_CACHE_PATH}/$(python3 -m pip --version | grep -o 'pip [0-9]*[.][0-9]*[.][0-9]*' | grep -o '[0-9].*')" >> $GITHUB_ENV + 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 OpenVINO dependencies run: ${INSTALL_DIR}/install_dependencies/install_openvino_dependencies.sh -c=core -c=dev -y @@ -614,7 +617,10 @@ jobs: with: python-version: '3.11' - name: Setup pip cache dir - run: echo "PIP_CACHE_DIR=${PIP_CACHE_PATH}/$(python3 -m pip --version | grep -o 'pip [0-9]*[.][0-9]*[.][0-9]*' | grep -o '[0-9].*')" >> $GITHUB_ENV + 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: | @@ -1018,7 +1024,10 @@ jobs: with: python-version: '3.11' - name: Setup pip cache dir - run: echo "PIP_CACHE_DIR=${PIP_CACHE_PATH}/$(python3 -m pip --version | grep -o 'pip [0-9]*[.][0-9]*[.][0-9]*' | grep -o '[0-9].*')" >> $GITHUB_ENV + 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 OpenVINO Python wheels run: python3 -m pip install ${INSTALL_DIR}/tools/openvino-* From 16694d3b21d97501a5c2033156ac4bacd47be0e5 Mon Sep 17 00:00:00 2001 From: Mikhail Ryzhov Date: Thu, 28 Sep 2023 12:21:37 +0200 Subject: [PATCH 57/57] revert omz --- thirdparty/open_model_zoo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/thirdparty/open_model_zoo b/thirdparty/open_model_zoo index f08b9b080b240b..d831efe10e7af4 160000 --- a/thirdparty/open_model_zoo +++ b/thirdparty/open_model_zoo @@ -1 +1 @@ -Subproject commit f08b9b080b240b4abd08830542ef532deeaf1da3 +Subproject commit d831efe10e7af426ceba0b6ad65dbb5e5fc82beb