From 09aece638d4fb713199e5053faf3a0138cb157da Mon Sep 17 00:00:00 2001 From: Przemyslaw Wysocki Date: Mon, 18 Sep 2023 09:53:45 +0200 Subject: [PATCH 01/30] Fix typo in Good First Issue template (#19898) * Add gfi * Minor change * Fix linter * fix typo * Fix typo' --- .github/ISSUE_TEMPLATE/good_first_issue.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE/good_first_issue.yml b/.github/ISSUE_TEMPLATE/good_first_issue.yml index c48d0ee6394b9a..658e1bb00a9739 100644 --- a/.github/ISSUE_TEMPLATE/good_first_issue.yml +++ b/.github/ISSUE_TEMPLATE/good_first_issue.yml @@ -27,7 +27,7 @@ body: - type: textarea id: example_prs attributes: - label: Exmaple Pull Requests + label: Example Pull Requests description: | Provide example Pull requests, if there are any. validations: From e9aaf9aa1be6faece796feb129ee55768ba99d72 Mon Sep 17 00:00:00 2001 From: "mei, yang" Date: Mon, 18 Sep 2023 16:39:11 +0800 Subject: [PATCH 02/30] [CPU] Fix Interpolate impl bug and add related test case (#19783) --- src/plugins/intel_cpu/src/nodes/bin_conv.cpp | 2 +- src/plugins/intel_cpu/src/nodes/interpolate.cpp | 2 +- .../functional/single_layer_tests/interpolate.cpp | 10 +++++++--- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/plugins/intel_cpu/src/nodes/bin_conv.cpp b/src/plugins/intel_cpu/src/nodes/bin_conv.cpp index ab8694b6669511..f37c9a51946c0a 100644 --- a/src/plugins/intel_cpu/src/nodes/bin_conv.cpp +++ b/src/plugins/intel_cpu/src/nodes/bin_conv.cpp @@ -586,8 +586,8 @@ struct jit_uni_bin_conv_kernel_f32 : public jit_uni_bin_conv_kernel, public jit_ add(reg_d_weights, jcp_.oc_block * sizeof(float)); } - depthwise_inj_idx++; post_ops_data_offset += depthwise_injectors[depthwise_inj_idx]->memoryStep(); + depthwise_inj_idx++; push(reg_oc_off); } else if (post_op.is_sum(false)) { diff --git a/src/plugins/intel_cpu/src/nodes/interpolate.cpp b/src/plugins/intel_cpu/src/nodes/interpolate.cpp index 60a1259f43aba4..4292b85724cf94 100644 --- a/src/plugins/intel_cpu/src/nodes/interpolate.cpp +++ b/src/plugins/intel_cpu/src/nodes/interpolate.cpp @@ -1519,8 +1519,8 @@ struct jit_uni_interpolate_kernel_f32 : public jit_uni_interpolate_kernel, publi depthwise_injectors[depthwise_inj_idx]->compute_vector_range( vmm_val.getIdx(), vmm_val.getIdx() + 1, reg_d_weights, reg_d_weights, is_broadcast); - depthwise_inj_idx++; post_ops_data_offset += depthwise_injectors[depthwise_inj_idx]->memoryStep(); + depthwise_inj_idx++; } else if (post_op.is_quantization()) { bool do_dequantization = post_op.quantization.alg == alg_kind::quantization_quantize_dequantize; bool do_rounding = do_dequantization || dst_prc == Precision::FP32 || i != p.len() - 1; diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/interpolate.cpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/interpolate.cpp index 7cb20b34e6667f..3256a232233566 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/interpolate.cpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/interpolate.cpp @@ -462,13 +462,18 @@ const std::vector shapeParams4D_fixed_C = { }; #if defined(OPENVINO_ARCH_X86) || defined(OPENVINO_ARCH_X86_64) +const std::vector interpolateFusingParamsSet_fixed_C{ + fusingFakeQuantizePerChannelRelu, + fusingMultiplyPerChannel, +}; + INSTANTIATE_TEST_SUITE_P(smoke_InterpolateNN_Layout_PerChannelFuse_Test, InterpolateLayerCPUTest, ::testing::Combine( interpolateCasesNN_Smoke, ::testing::ValuesIn(shapeParams4D_fixed_C), ::testing::Values(ElementType::f32), ::testing::ValuesIn(filterCPUInfoForDevice()), - ::testing::Values(fusingFakeQuantizePerChannelRelu), + ::testing::ValuesIn(interpolateFusingParamsSet_fixed_C), ::testing::ValuesIn(filterAdditionalConfig())), InterpolateLayerCPUTest::getTestCaseName); @@ -478,7 +483,7 @@ INSTANTIATE_TEST_SUITE_P(InterpolateNN_Layout_PerChannelFuse_Test, InterpolateLa ::testing::ValuesIn(shapeParams4D_fixed_C), ::testing::Values(ElementType::f32), ::testing::ValuesIn(filterCPUInfoForDevice()), - ::testing::Values(fusingFakeQuantizePerChannelRelu), + ::testing::ValuesIn(interpolateFusingParamsSet_fixed_C), ::testing::ValuesIn(filterAdditionalConfig())), InterpolateLayerCPUTest::getTestCaseName); #endif @@ -1015,5 +1020,4 @@ INSTANTIATE_TEST_SUITE_P(smoke_InterpolateBicubicPillow_LayoutAlign_Test, Interp InterpolateLayerCPUTest::getTestCaseName); } // namespace - } // namespace CPULayerTestsDefinitions From 253ca8c746425afd9c2e570d6882f797f44c0834 Mon Sep 17 00:00:00 2001 From: Ilya Lavrenov Date: Mon, 18 Sep 2023 13:58:20 +0400 Subject: [PATCH 03/30] Fixed GPU plugin static build with oneDNN (#19811) * Fixed GPU plugin static build with oneDNN * Fixed issue with absolute paths inside installed OpenVINOConfig.cmake * Fixed absolute paths in installed OpenVINOConfig.cmake * Changed components for installation --- cmake/developer_package/plugins/plugins.cmake | 4 ++ cmake/features.cmake | 2 +- cmake/templates/OpenVINOConfig.cmake.in | 63 +++++++++++++++---- src/cmake/openvino.cmake | 15 ++--- .../intel_cpu/thirdparty/CMakeLists.txt | 8 +-- .../intel_gpu/src/graph/CMakeLists.txt | 2 +- .../src/kernel_selector/CMakeLists.txt | 14 ++++- .../intel_gpu/src/runtime/CMakeLists.txt | 2 +- .../intel_gpu/thirdparty/CMakeLists.txt | 29 ++++++--- src/plugins/template/backend/CMakeLists.txt | 2 +- src/plugins/template/src/CMakeLists.txt | 4 +- thirdparty/ocl/CMakeLists.txt | 2 +- 12 files changed, 108 insertions(+), 39 deletions(-) diff --git a/cmake/developer_package/plugins/plugins.cmake b/cmake/developer_package/plugins/plugins.cmake index 4138aed19f4e77..4ab78f5cfabd00 100644 --- a/cmake/developer_package/plugins/plugins.cmake +++ b/cmake/developer_package/plugins/plugins.cmake @@ -117,6 +117,10 @@ function(ov_add_plugin) # install rules if(NOT OV_PLUGIN_SKIP_INSTALL OR NOT BUILD_SHARED_LIBS) string(TOLOWER "${OV_PLUGIN_DEVICE_NAME}" install_component) + if(NOT BUILD_SHARED_LIBS) + # in case of static libs everything is installed to 'core' + set(install_component ${OV_CPACK_COMP_CORE}) + endif() if(OV_PLUGIN_PSEUDO_DEVICE) set(plugin_hidden HIDDEN) diff --git a/cmake/features.cmake b/cmake/features.cmake index 5dca5b7b21bef1..070d5a6ad73e9b 100644 --- a/cmake/features.cmake +++ b/cmake/features.cmake @@ -23,7 +23,7 @@ endif() ie_dependent_option (ENABLE_INTEL_GPU "GPU OpenCL-based plugin for OpenVINO Runtime" ${ENABLE_INTEL_GPU_DEFAULT} "X86_64 OR AARCH64;NOT APPLE;NOT WINDOWS_STORE;NOT WINDOWS_PHONE" OFF) -if (ANDROID OR MINGW OR (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.0) OR NOT BUILD_SHARED_LIBS) +if (ANDROID OR MINGW OR (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.0) OR (NOT BUILD_SHARED_LIBS AND ENABLE_INTEL_CPU)) # oneDNN doesn't support old compilers and android builds for now, so we'll build GPU plugin without oneDNN # also, in case of static build CPU's and GPU's oneDNNs will conflict, so we are disabling GPU's one in this case set(ENABLE_ONEDNN_FOR_GPU_DEFAULT OFF) diff --git a/cmake/templates/OpenVINOConfig.cmake.in b/cmake/templates/OpenVINOConfig.cmake.in index 9eb1cfdd35837b..7dda80d8a312fd 100644 --- a/cmake/templates/OpenVINOConfig.cmake.in +++ b/cmake/templates/OpenVINOConfig.cmake.in @@ -223,6 +223,10 @@ macro(_ov_find_tbb) PATHS ${_tbb_bind_dir} NO_CMAKE_FIND_ROOT_PATH NO_DEFAULT_PATH) + if(TARGET TBBbind::tbbbind_2_5) + # To solve https://cmake.org/cmake/help/latest/policy/CMP0111.html warnings + set_property(TARGET TBBbind::tbbbind_2_5 PROPERTY IMPORTED_CONFIGURATIONS RELEASE DEBUG) + endif() unset(_tbb_bind_dir) endif() unset(install_tbbbind) @@ -343,11 +347,15 @@ endmacro() macro(_ov_find_intel_cpu_dependencies) set(_OV_ENABLE_CPU_ACL "@DNNL_USE_ACL@") if(_OV_ENABLE_CPU_ACL) - set(_ov_in_install_tree "@PACKAGE_ARM_COMPUTE_LIB_DIR@") + set(_ov_in_install_tree "@PACKAGE_OPENVINO_LIB_DIR@") if(_ov_in_install_tree) - set_and_check(ARM_COMPUTE_LIB_DIR "@PACKAGE_ARM_COMPUTE_LIB_DIR@") + set_and_check(ARM_COMPUTE_LIB_DIR "@PACKAGE_OPENVINO_LIB_DIR@") set(ACL_DIR "${CMAKE_CURRENT_LIST_DIR}") else() + if(NOT TARGET arm_compute::arm_compute) + # for case when build tree is used separately, e.g. OpenVINODeveloperPackageConfig.cmake + set_and_check(ARM_COMPUTE_LIB_DIR "@PACKAGE_CMAKE_ARCHIVE_OUTPUT_DIRECTORY@") + endif() set_and_check(ACL_DIR "@PACKAGE_FIND_ACL_PATH@") endif() @@ -363,16 +371,50 @@ macro(_ov_find_intel_gpu_dependencies) set(_OV_ENABLE_INTEL_GPU "@ENABLE_INTEL_GPU@") set(_OV_ENABLE_SYSTEM_OPENCL "@ENABLE_SYSTEM_OPENCL@") if(_OV_ENABLE_INTEL_GPU AND _OV_ENABLE_SYSTEM_OPENCL) - set(_OV_OpenCLICDLoader_FOUND "@OpenCLICDLoader_FOUND@") - if(_OV_OpenCLICDLoader_FOUND) - _ov_find_dependency(OpenCLICDLoader) - else() - _ov_find_dependency(OpenCL) - endif() - unset(_OV_OpenCLICDLoader_FOUND) + _ov_find_dependency(OpenCL) endif() unset(_OV_ENABLE_INTEL_GPU) unset(_OV_ENABLE_SYSTEM_OPENCL) + + set(_OV_ENABLE_ONEDNN_FOR_GPU "@ENABLE_ONEDNN_FOR_GPU@") + if(_OV_ENABLE_ONEDNN_FOR_GPU AND NOT TARGET onednn_gpu_tgt) + set(_OV_DNNL_GPU_LIBRARY_NAME "@DNNL_GPU_LIBRARY_NAME@") + + set(_ov_in_install_tree "@PACKAGE_OPENVINO_LIB_DIR@") + if(_ov_in_install_tree) + set(onednn_gpu_lib "${CMAKE_STATIC_LIBRARY_PREFIX}${_OV_DNNL_GPU_LIBRARY_NAME}${CMAKE_STATIC_LIBRARY_SUFFIX}") + set_and_check(onednn_gpu_lib_root "@PACKAGE_OPENVINO_LIB_DIR@") + if(WIN32) + if(OV_GENERATOR_MULTI_CONFIG) + set(extra_args PATH_SUFFIXES ${CMAKE_CONFIGURATION_TYPES}) + else() + set(extra_args PATH_SUFFIXES ${CMAKE_BUILD_TYPE}) + endif() + endif() + + find_library(onednn_gpu_lib_path + NAMES ${_OV_DNNL_GPU_LIBRARY_NAME} + PATHS ${onednn_gpu_lib_root} + ${extra_args}) + + if(NOT onednn_gpu_lib_path) + message(FATAL_ERROR "Internal error: failed to find '${_OV_DNNL_GPU_LIBRARY_NAME}' in '${onednn_gpu_lib_root}'") + endif() + + unset(extra_args) + unset(onednn_gpu_lib) + else() + set_and_check(onednn_gpu_lib_path "@PACKAGE_ONEDNN_GPU_LIB_PATH@") + endif() + + set_target_properties(openvino::onednn_gpu_tgt PROPERTIES + INTERFACE_LINK_LIBRARIES "${onednn_gpu_lib_path}") + + unset(onednn_gpu_lib_path) + unset(_ov_in_install_tree) + unset(_OV_DNNL_GPU_LIBRARY_NAME) + endif() + unset(_OV_ENABLE_ONEDNN_FOR_GPU) endmacro() macro(_ov_find_intel_gna_dependencies) @@ -455,6 +497,7 @@ set(_OV_ENABLE_OPENVINO_BUILD_SHARED "@BUILD_SHARED_LIBS@") if(NOT TARGET openvino) set(_ov_as_external_package ON) + include("${CMAKE_CURRENT_LIST_DIR}/OpenVINOTargets.cmake") endif() if(NOT _OV_ENABLE_OPENVINO_BUILD_SHARED) @@ -487,8 +530,6 @@ set(_ov_imported_libs openvino::runtime openvino::runtime::c openvino::frontend::pytorch openvino::frontend::tensorflow_lite) if(_ov_as_external_package) - include("${CMAKE_CURRENT_LIST_DIR}/OpenVINOTargets.cmake") - foreach(target IN LISTS _ov_imported_libs) if(TARGET ${target}) get_target_property(imported_configs ${target} IMPORTED_CONFIGURATIONS) diff --git a/src/cmake/openvino.cmake b/src/cmake/openvino.cmake index 14eb6515d27e06..302c263b024e7e 100644 --- a/src/cmake/openvino.cmake +++ b/src/cmake/openvino.cmake @@ -157,9 +157,12 @@ if(ENABLE_INTEL_GNA) list(APPEND PATH_VARS "GNA_PATH") endif() if(DNNL_USE_ACL) - list(APPEND BUILD_PATH_VARS "FIND_ACL_PATH") + list(APPEND BUILD_PATH_VARS "FIND_ACL_PATH;CMAKE_ARCHIVE_OUTPUT_DIRECTORY") set(FIND_ACL_PATH "${intel_cpu_thirdparty_SOURCE_DIR}") endif() +if(ENABLE_ONEDNN_FOR_GPU) + list(APPEND BUILD_PATH_VARS "ONEDNN_GPU_LIB_PATH") +endif() set(PUBLIC_HEADERS_DIR "${OpenVINO_SOURCE_DIR}/src/inference/include") set(IE_INCLUDE_DIR "${PUBLIC_HEADERS_DIR}/ie") @@ -177,12 +180,10 @@ configure_package_config_file("${OpenVINO_SOURCE_DIR}/cmake/templates/OpenVINOCo # install tree -if(DNNL_USE_ACL) - list(APPEND INSTALL_PATH_VARS "ARM_COMPUTE_LIB_DIR") - # remove generator expression at the end, because searching in Release / Debug will be - # done by ACLConfig.cmake itself - string(REPLACE "$" "" ARM_COMPUTE_LIB_DIR "${OV_CPACK_LIBRARYDIR}") -endif() +list(APPEND INSTALL_PATH_VARS "OPENVINO_LIB_DIR") +# remove generator expression at the end, because searching in Release / Debug +# will be done by inside OpenVINOConfig.cmak / ACLConfig.cmake +string(REPLACE "$" "" OPENVINO_LIB_DIR "${OV_CPACK_LIBRARYDIR}") set(IE_INCLUDE_DIR "${OV_CPACK_INCLUDEDIR}/ie") set(IE_TBB_DIR "${IE_TBB_DIR_INSTALL}") diff --git a/src/plugins/intel_cpu/thirdparty/CMakeLists.txt b/src/plugins/intel_cpu/thirdparty/CMakeLists.txt index 29c298acb109fd..4c17e2e32373ec 100644 --- a/src/plugins/intel_cpu/thirdparty/CMakeLists.txt +++ b/src/plugins/intel_cpu/thirdparty/CMakeLists.txt @@ -117,7 +117,7 @@ function(ov_add_onednn) add_subdirectory(onednn EXCLUDE_FROM_ALL) # install static libraries - ov_install_static_lib(dnnl cpu) + ov_install_static_lib(dnnl ${OV_CPACK_COMP_CORE}) if(DNNL_USE_ACL AND NOT BUILD_SHARED_LIBS) # use ACLConfig.cmake in OpenVINOConfig.cmake in case of static build @@ -125,16 +125,16 @@ function(ov_add_onednn) # but for this we need to install library files install(FILES $ DESTINATION ${OV_CPACK_ARCHIVEDIR} - COMPONENT cpu) + COMPONENT ${OV_CPACK_COMP_CORE}) install(FILES "${intel_cpu_thirdparty_SOURCE_DIR}/ACLConfig.cmake" DESTINATION ${OV_CPACK_OPENVINO_CMAKEDIR} - COMPONENT core_dev) + COMPONENT ${OV_CPACK_COMP_CORE_DEV}) endif() endfunction() if(ENABLE_MLAS_FOR_CPU) add_subdirectory(mlas) - ov_install_static_lib(mlas cpu) + ov_install_static_lib(mlas ${OV_CPACK_COMP_CORE}) endif() ov_add_onednn() diff --git a/src/plugins/intel_gpu/src/graph/CMakeLists.txt b/src/plugins/intel_gpu/src/graph/CMakeLists.txt index 3831742ace55f6..dd3ddb87d1016e 100644 --- a/src/plugins/intel_gpu/src/graph/CMakeLists.txt +++ b/src/plugins/intel_gpu/src/graph/CMakeLists.txt @@ -58,7 +58,7 @@ elseif((NOT ANDROID) AND (UNIX)) target_link_libraries(${TARGET_NAME} PRIVATE pthread) endif() -ov_install_static_lib(${TARGET_NAME} gpu) +ov_install_static_lib(${TARGET_NAME} ${OV_CPACK_COMP_CORE}) if(ENABLE_SSE42) ie_sse42_optimization_flags(sse4_2_flags) diff --git a/src/plugins/intel_gpu/src/kernel_selector/CMakeLists.txt b/src/plugins/intel_gpu/src/kernel_selector/CMakeLists.txt index 4e4aa260520a06..99ebf5331ab305 100644 --- a/src/plugins/intel_gpu/src/kernel_selector/CMakeLists.txt +++ b/src/plugins/intel_gpu/src/kernel_selector/CMakeLists.txt @@ -91,8 +91,16 @@ add_custom_command( TARGET ${TARGET_NAME} POST_BUILD COMMAND "${CMAKE_COMMAND}" -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/cache/cache.json ${TUNING_CACHE_PATH}/cache.json) +if(BUILD_SHARED_LIBS) + set(CACHE_JSON_INSTALL_DIR ${OV_CPACK_PLUGINSDIR}) + set(CACHE_JSON_COMPONENT gpu) +else() + set(CACHE_JSON_INSTALL_DIR ${OV_CPACK_ARCHIVEDIR}) + set(CACHE_JSON_COMPONENT ${OV_CPACK_COMP_CORE}) +endif() + install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/cache/cache.json - DESTINATION ${OV_CPACK_PLUGINSDIR} - COMPONENT gpu) + DESTINATION ${CACHE_JSON_INSTALL_DIR} + COMPONENT ${CACHE_JSON_COMPONENT}) -ov_install_static_lib(${TARGET_NAME} gpu) +ov_install_static_lib(${TARGET_NAME} ${OV_CPACK_COMP_CORE}) diff --git a/src/plugins/intel_gpu/src/runtime/CMakeLists.txt b/src/plugins/intel_gpu/src/runtime/CMakeLists.txt index 47c9139a4f9f8b..f1de561105c0ca 100644 --- a/src/plugins/intel_gpu/src/runtime/CMakeLists.txt +++ b/src/plugins/intel_gpu/src/runtime/CMakeLists.txt @@ -64,4 +64,4 @@ elseif((NOT ANDROID) AND (UNIX)) target_link_libraries(${TARGET_NAME} PRIVATE pthread) endif() -ov_install_static_lib(${TARGET_NAME} gpu) +ov_install_static_lib(${TARGET_NAME} ${OV_CPACK_COMP_CORE}) diff --git a/src/plugins/intel_gpu/thirdparty/CMakeLists.txt b/src/plugins/intel_gpu/thirdparty/CMakeLists.txt index 1d71dc6e2a2a17..4fdbbc39f3d08f 100644 --- a/src/plugins/intel_gpu/thirdparty/CMakeLists.txt +++ b/src/plugins/intel_gpu/thirdparty/CMakeLists.txt @@ -9,11 +9,12 @@ if(ENABLE_ONEDNN_FOR_GPU) function(build_onednn_gpu) include(ExternalProject) - set(ONEDNN_BUILD_DIR "${CMAKE_CURRENT_BINARY_DIR}/onednn_gpu_build/") - set(ONEDNN_INSTALL_DIR "${CMAKE_CURRENT_BINARY_DIR}/onednn_gpu_install/") + set(ONEDNN_BUILD_DIR "${CMAKE_CURRENT_BINARY_DIR}/onednn_gpu_build") + set(ONEDNN_INSTALL_DIR "${CMAKE_CURRENT_BINARY_DIR}/onednn_gpu_install" CACHE PATH "Installation path for oneDNN GPU library") set(ONEDNN_PREFIX_DIR "${CMAKE_CURRENT_BINARY_DIR}/onednn_gpu_root") set(ONEDNN_ENABLED_PRIMITIVES "CONCAT;CONVOLUTION;DECONVOLUTION;INNER_PRODUCT;MATMUL;REORDER;POOLING;REDUCTION") set(ONEDNN_ENABLED_ISA "XEHP;XEHPG;XEHPC") + set(DNNL_GPU_LIBRARY_NAME "openvino_onednn_gpu" CACHE STRING "Name of oneDNN library for Intel GPU Plugin") if(X86_64) set(ONEDNN_TARGET_ARCH "X64" CACHE STRING "" FORCE) @@ -79,6 +80,9 @@ if(ENABLE_ONEDNN_FOR_GPU) list(APPEND cmake_extra_args "-DOpenCL_INCLUDE_DIR=${OpenCL_INCLUDE_DIR}") endif() + set(onednn_gpu_lib "${CMAKE_STATIC_LIBRARY_PREFIX}${DNNL_GPU_LIBRARY_NAME}${CMAKE_STATIC_LIBRARY_SUFFIX}") + set(ONEDNN_GPU_LIB_PATH ${ONEDNN_INSTALL_DIR}/lib/${onednn_gpu_lib} CACHE FILEPATH "Path to oneDNN GPU library") + ExternalProject_Add(onednn_gpu_build # Directory Options: PREFIX "${ONEDNN_PREFIX_DIR}" @@ -99,7 +103,7 @@ if(ENABLE_ONEDNN_FOR_GPU) "-DDNNL_TARGET_ARCH=${ONEDNN_TARGET_ARCH}" "-DDNNL_CPU_RUNTIME=NONE" "-DDNNL_GPU_RUNTIME=OCL" - "-DDNNL_LIBRARY_NAME=openvino_onednn_gpu" + "-DDNNL_LIBRARY_NAME=${DNNL_GPU_LIBRARY_NAME}" "-DCMAKE_INSTALL_PREFIX=${ONEDNN_INSTALL_DIR}" "-DDNNL_ENABLE_CONCURRENT_EXEC=ON" "-DDNNL_ENABLE_PRIMITIVE_CACHE=OFF" @@ -124,18 +128,29 @@ if(ENABLE_ONEDNN_FOR_GPU) # Thus we pass it via CMAKE_CACHE_ARGS "-DDNNL_ENABLE_PRIMITIVE:STRING=${ONEDNN_ENABLED_PRIMITIVES}" "-DDNNL_ENABLE_PRIMITIVE_GPU_ISA:STRING=${ONEDNN_ENABLED_ISA}" + # Build Step Options: + BUILD_BYPRODUCTS ${ONEDNN_GPU_LIB_PATH} # Target Options: EXCLUDE_FROM_ALL ON ) + add_library(onednn_gpu_tgt INTERFACE) set_target_properties(onednn_gpu_tgt PROPERTIES - INTERFACE_LINK_DIRECTORIES "${ONEDNN_INSTALL_DIR}/lib" - INTERFACE_LINK_LIBRARIES "openvino_onednn_gpu" - INTERFACE_INCLUDE_DIRECTORIES "${ONEDNN_INSTALL_DIR}/include" + INTERFACE_LINK_LIBRARIES $ + INTERFACE_INCLUDE_DIRECTORIES $ INTERFACE_COMPILE_DEFINITIONS ENABLE_ONEDNN_FOR_GPU ) add_dependencies(onednn_gpu_tgt onednn_gpu_build) - # TODO: install onednn_gpu in static builds + + if(NOT BUILD_SHARED_LIBS) + ov_install_static_lib(onednn_gpu_tgt ${OV_CPACK_COMP_CORE}) + + # we need to install library explicitly and set_target_properties in OpenVINOConfig.cmake for 'onednn_gpu_tgt' + # to point to installation location of this file + install(FILES "${ONEDNN_GPU_LIB_PATH}" + DESTINATION ${OV_CPACK_ARCHIVEDIR} + COMPONENT ${OV_CPACK_COMP_CORE}) + endif() endfunction() build_onednn_gpu() endif() diff --git a/src/plugins/template/backend/CMakeLists.txt b/src/plugins/template/backend/CMakeLists.txt index 7b945216c95898..74e10c01863dfe 100644 --- a/src/plugins/template/backend/CMakeLists.txt +++ b/src/plugins/template/backend/CMakeLists.txt @@ -51,4 +51,4 @@ openvino_developer_export_targets(COMPONENT core TARGETS interpreter_backend) # install -ov_install_static_lib(interpreter_backend template) +ov_install_static_lib(interpreter_backend ${OV_CPACK_COMP_CORE}) diff --git a/src/plugins/template/src/CMakeLists.txt b/src/plugins/template/src/CMakeLists.txt index 2409bb10e0c152..f382f90d11b450 100644 --- a/src/plugins/template/src/CMakeLists.txt +++ b/src/plugins/template/src/CMakeLists.txt @@ -28,7 +28,7 @@ target_include_directories(${TARGET_NAME} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}" "${TEMPLATE_PLUGIN_SOURCE_DIR}/include") -# link common Inference Engine libraries +# link common OpenVINO Runtime libraries target_link_libraries(${TARGET_NAME} PRIVATE openvino::interpreter_backend openvino::reference) @@ -42,4 +42,4 @@ endif() # [cmake:plugin] install(TARGETS ${TARGET_NAME} - LIBRARY DESTINATION tests COMPONENT tests EXCLUDE_FROM_ALL) + LIBRARY DESTINATION tests COMPONENT tests EXCLUDE_FROM_ALL) diff --git a/thirdparty/ocl/CMakeLists.txt b/thirdparty/ocl/CMakeLists.txt index f31519467f3f64..0ebe3fd6d1df39 100644 --- a/thirdparty/ocl/CMakeLists.txt +++ b/thirdparty/ocl/CMakeLists.txt @@ -58,4 +58,4 @@ set(opencl_root_hints "${OpenCL_INCLUDE_DIR}" PARENT_SCOPE) # installation -ov_install_static_lib(OpenCL gpu) +ov_install_static_lib(OpenCL ${OV_CPACK_COMP_CORE}) From 49df8fa45e9d1e729b879d79f561a9f63444e416 Mon Sep 17 00:00:00 2001 From: Karol Blaszczak Date: Mon, 18 Sep 2023 12:22:54 +0200 Subject: [PATCH 04/30] [DOCS] updated archives for 2023.1 port master (#19896) (#19902) port: https://github.com/openvinotoolkit/openvino/pull/19896 --- docs/Documentation/openvino_ecosystem.md | 1 + .../deployment/local-distribution.md | 1 + docs/get_started/get_started_demos.md | 2 +- .../--installing-model-dev-tools.md | 2 +- .../install_guides/installing-openvino-apt.md | 10 ++- .../installing-openvino-brew.md | 2 +- .../installing-openvino-conda.md | 6 +- .../installing-openvino-from-archive-linux.md | 88 +++++++++---------- .../installing-openvino-from-archive-macos.md | 20 ++--- ...nstalling-openvino-from-archive-windows.md | 18 ++-- .../install_guides/installing-openvino-pip.md | 2 +- .../installing-openvino-vcpkg.md | 24 +++-- .../install_guides/installing-openvino-yum.md | 5 +- docs/snippets/export_compiled_model.cpp | 8 +- 14 files changed, 99 insertions(+), 90 deletions(-) diff --git a/docs/Documentation/openvino_ecosystem.md b/docs/Documentation/openvino_ecosystem.md index 2a1c7c9cfc8f88..733e6870eb9f30 100644 --- a/docs/Documentation/openvino_ecosystem.md +++ b/docs/Documentation/openvino_ecosystem.md @@ -27,6 +27,7 @@ More resources: * :doc:`Documentation ` * `GitHub `__ * `PyPI `__ +* `Conda Forge `__ **OpenVINO™ Training Extensions** diff --git a/docs/OV_Runtime_UG/deployment/local-distribution.md b/docs/OV_Runtime_UG/deployment/local-distribution.md index 397e10bdde6a47..7dfa3fea0f1dcf 100644 --- a/docs/OV_Runtime_UG/deployment/local-distribution.md +++ b/docs/OV_Runtime_UG/deployment/local-distribution.md @@ -137,6 +137,7 @@ OpenVINO Runtime uses frontend libraries dynamically to read models in different - ``openvino_tensorflow_lite_frontend`` is used to read the TensorFlow Lite file format. - ``openvino_onnx_frontend`` is used to read the ONNX file format. - ``openvino_paddle_frontend`` is used to read the Paddle file format. +- ``openvino_pytorch_frontend`` is used to convert PyTorch model via ``openvino.convert_model`` API. Depending on the model format types that are used in the application in `ov::Core::read_model `__, select the appropriate libraries. diff --git a/docs/get_started/get_started_demos.md b/docs/get_started/get_started_demos.md index 0ec61b0f0c3e1f..c7d940c676c8e2 100644 --- a/docs/get_started/get_started_demos.md +++ b/docs/get_started/get_started_demos.md @@ -58,7 +58,7 @@ To install OpenVINO Development Tools, follow the :doc:`instructions for C++ dev Build Samples +++++++++++++ -To build OpenVINO samples, follow the build instructions for your operating system on the :doc:`OpenVINO Samples ` page. The build will take about 5-10 minutes, depending on your system. +To build OpenVINO samples, follow the build instructions for your operating system on the :doc:`OpenVINO Samples ` page. The build will take about 1-2 minutes, depending on your system. .. _download-models: diff --git a/docs/install_guides/--installing-model-dev-tools.md b/docs/install_guides/--installing-model-dev-tools.md index 84b7d0069a0525..366034bafcac43 100644 --- a/docs/install_guides/--installing-model-dev-tools.md +++ b/docs/install_guides/--installing-model-dev-tools.md @@ -149,7 +149,7 @@ For example, to install and configure dependencies required for working with Ten Model conversion API support for TensorFlow 1.x environment has been deprecated. Use the ``tensorflow2`` parameter to install a TensorFlow 2.x environment that can convert both TensorFlow 1.x and 2.x models. If your model isn't compatible with the TensorFlow 2.x environment, use the `tensorflow` parameter to install the TensorFlow 1.x environment. The TF 1.x environment is provided only for legacy compatibility reasons. -For more details on the openvino-dev PyPI package, see `pypi.org `__ . +For more details on the openvino-dev PyPI package, see `pypi.org `__ . Step 5. Test the Installation +++++++++++++++++++++++++++++ diff --git a/docs/install_guides/installing-openvino-apt.md b/docs/install_guides/installing-openvino-apt.md index 9b4119239b9579..6dee8f9f19e2d8 100644 --- a/docs/install_guides/installing-openvino-apt.md +++ b/docs/install_guides/installing-openvino-apt.md @@ -13,7 +13,6 @@ * offers both C/C++ and Python APIs * does not offer support for GNA and NPU inference * additionally includes code samples - * is dedicated to Linux users. .. tab-set:: @@ -146,7 +145,7 @@ Step 2: Install OpenVINO Runtime Using the APT Package Manager .. code-block:: sh - sudo apt install openvino-2023.0.0 + sudo apt install openvino-2023.1.0 .. note:: @@ -188,6 +187,11 @@ For C++ and C, just run the ``build_samples.sh`` script: /usr/share/openvino/samples/c/build_samples.sh +Python samples can run as following: + +.. code-block:: sh + + python3 /usr/share/openvino/samples/python/hello_query_device/hello_query_device.py Uninstalling OpenVINO Runtime ####################################### @@ -214,7 +218,7 @@ To uninstall OpenVINO Runtime via APT, run the following command based on your n .. code-block:: sh - sudo apt autoremove openvino-2023.0.0 + sudo apt autoremove openvino-2023.1.0 What's Next? diff --git a/docs/install_guides/installing-openvino-brew.md b/docs/install_guides/installing-openvino-brew.md index 6a27a688b930e0..93f20e2ae26063 100644 --- a/docs/install_guides/installing-openvino-brew.md +++ b/docs/install_guides/installing-openvino-brew.md @@ -12,7 +12,7 @@ * offers both C/C++ and Python APIs * does not offer support for GNA and NPU inference - * is dedicated to macOS and Linux users. + * is dedicated to macOS (both arm64 and x86_64) and Linux (x86_64 only) users. .. tab-set:: diff --git a/docs/install_guides/installing-openvino-conda.md b/docs/install_guides/installing-openvino-conda.md index 29303de40c2afb..dd76f8b980cfe0 100644 --- a/docs/install_guides/installing-openvino-conda.md +++ b/docs/install_guides/installing-openvino-conda.md @@ -13,7 +13,7 @@ * offers both C/C++ and Python APIs * does not offer support for GNA and NPU inference - * is dedicated to users of all major OSs: Windows, Linux, macOS. + * is dedicated to users of all major OSs: Windows, Linux, macOS and x86_64 / arm64 architectures .. tab-set:: @@ -62,7 +62,7 @@ Installing OpenVINO Runtime with Anaconda Package Manager .. code-block:: sh - conda install -c conda-forge openvino=2023.0.1 + conda install -c conda-forge openvino=2023.1.0 Congratulations! You've just Installed OpenVINO! For some use cases you may still need to install additional components. Check the description below, as well as the @@ -100,7 +100,7 @@ with the proper OpenVINO version number: .. code-block:: sh - conda remove openvino=2023.0.1 + conda remove openvino=2023.1.0 What's Next? diff --git a/docs/install_guides/installing-openvino-from-archive-linux.md b/docs/install_guides/installing-openvino-from-archive-linux.md index d7cfdf8d224787..ace3fd5a424459 100644 --- a/docs/install_guides/installing-openvino-from-archive-linux.md +++ b/docs/install_guides/installing-openvino-from-archive-linux.md @@ -12,8 +12,8 @@ Note that the Archive distribution: * offers both C/C++ and Python APIs - * additionally includes code samples - * is dedicated to users of all major OSs: Windows, Linux, macOS + * additionally includes code samples + * is dedicated to users of all major OSs: Windows, Linux, macOS and x86_64 / arm64 architectures * may offer different hardware support under different operating systems (see the drop-down below for more details). @@ -119,7 +119,7 @@ Step 1: Download and Install the OpenVINO Core Components cd /Downloads -4. Download the `OpenVINO Runtime archive file for your system `_, extract the files, rename the extracted folder and move it to the desired path: +4. Download the `OpenVINO Runtime archive file for your system `_, extract the files, rename the extracted folder and move it to the desired path: .. tab-set:: @@ -132,71 +132,71 @@ Step 1: Download and Install the OpenVINO Core Components :sync: ubuntu-22 .. code-block:: sh - - curl -L https://storage.openvinotoolkit.org/repositories/openvino/packages/2023.0.1/linux/l_openvino_toolkit_ubuntu22_2023.0.1.11005.fa1c41994f3_x86_64.tgz --output openvino_2023.0.1.tgz - tar -xf openvino_2023.0.1.tgz - sudo mv l_openvino_toolkit_ubuntu22_2023.0.1.11005.fa1c41994f3_x86_64 /opt/intel/openvino_2023.0.1 - + + curl -L https://storage.openvinotoolkit.org/repositories/openvino/packages/2023.1/linux/l_openvino_toolkit_ubuntu22_2023.1.0.12185.47b736f63ed_x86_64.tgz --output openvino_2023.1.0.tgz + tar -xf openvino_2023.1.0.tgz + sudo mv l_openvino_toolkit_ubuntu22_2023.1.0.12185.47b736f63ed_x86_64 /opt/intel/openvino_2023.1.0 + .. tab-item:: Ubuntu 20.04 :sync: ubuntu-20 .. code-block:: sh - - curl -L https://storage.openvinotoolkit.org/repositories/openvino/packages/2023.0.1/linux/l_openvino_toolkit_ubuntu20_2023.0.1.11005.fa1c41994f3_x86_64.tgz --output openvino_2023.0.1.tgz - tar -xf openvino_2023.0.1.tgz - sudo mv l_openvino_toolkit_ubuntu20_2023.0.1.11005.fa1c41994f3_x86_64 /opt/intel/openvino_2023.0.1 - + + curl -L https://storage.openvinotoolkit.org/repositories/openvino/packages/2023.1/linux/l_openvino_toolkit_ubuntu20_2023.1.0.12185.47b736f63ed_x86_64.tgz --output openvino_2023.1.0.tgz + tar -xf openvino_2023.1.0.tgz + sudo mv l_openvino_toolkit_ubuntu20_2023.1.0.12185.47b736f63ed_x86_64 /opt/intel/openvino_2023.1.0 + .. tab-item:: Ubuntu 18.04 :sync: ubuntu-18 .. code-block:: sh - - curl -L https://storage.openvinotoolkit.org/repositories/openvino/packages/2023.0.1/linux/l_openvino_toolkit_ubuntu18_2023.0.1.11005.fa1c41994f3_x86_64.tgz --output openvino_2023.0.1.tgz - tar -xf openvino_2023.0.1.tgz - sudo mv l_openvino_toolkit_ubuntu18_2023.0.1.11005.fa1c41994f3_x86_64 /opt/intel/openvino_2023.0.1 - + + curl -L https://storage.openvinotoolkit.org/repositories/openvino/packages/2023.1/linux/l_openvino_toolkit_ubuntu18_2023.1.0.12185.47b736f63ed_x86_64.tgz --output openvino_2023.1.0.tgz + tar -xf openvino_2023.1.0.tgz + sudo mv l_openvino_toolkit_ubuntu18_2023.1.0.12185.47b736f63ed_x86_64 /opt/intel/openvino_2023.1.0 + .. tab-item:: RHEL 8 :sync: rhel-8 .. code-block:: sh - - curl -L https://storage.openvinotoolkit.org/repositories/openvino/packages/2023.0.1/linux/l_openvino_toolkit_rhel8_2023.0.1.11005.fa1c41994f3_x86_64.tgz --output openvino_2023.0.1.tgz - tar -xf openvino_2023.0.1.tgz - sudo mv l_openvino_toolkit_rhel8_2023.0.1.11005.fa1c41994f3_x86_64 /opt/intel/openvino_2023.0.1 - + + curl -L https://storage.openvinotoolkit.org/repositories/openvino/packages/2023.1/linux/l_openvino_toolkit_rhel8_2023.1.0.12185.47b736f63ed_x86_64.tgz --output openvino_2023.1.0.tgz + tar -xf openvino_2023.1.0.tgz + sudo mv l_openvino_toolkit_rhel8_2023.1.0.12185.47b736f63ed_x86_64 /opt/intel/openvino_2023.1.0 + .. tab-item:: CentOS 7 :sync: centos-7 .. code-block:: sh - - curl -L https://storage.openvinotoolkit.org/repositories/openvino/packages/2023.0.1/linux/l_openvino_toolkit_centos7_2023.0.1.11005.fa1c41994f3_x86_64.tgz --output openvino_2023.0.1.tgz - tar -xf openvino_2023.0.1.tgz - sudo mv l_openvino_toolkit_centos7_2023.0.1.11005.fa1c41994f3_x86_64 /opt/intel/openvino_2023.0.1 - + + curl -L https://storage.openvinotoolkit.org/repositories/openvino/packages/2023.1/linux/l_openvino_toolkit_centos7_2023.1.0.12185.47b736f63ed_x86_64.tgz --output openvino_2023.1.0.tgz + tar -xf openvino_2023.1.0.tgz + sudo mv l_openvino_toolkit_centos7_2023.1.0.12185.47b736f63ed_x86_64 /opt/intel/openvino_2023.1.0 + .. tab-item:: ARM 64-bit :sync: arm-64 .. code-block:: sh - - curl -L https://storage.openvinotoolkit.org/repositories/openvino/packages/2023.0.1/linux/l_openvino_toolkit_debian9_2023.0.1.11005.fa1c41994f3_arm64.tgz -O openvino_2023.0.1.tgz - tar -xf openvino_2023.0.1.tgz - sudo mv l_openvino_toolkit_debian9_2023.0.1.11005.fa1c41994f3_arm64 /opt/intel/openvino_2023.0.1 - + + curl -L https://storage.openvinotoolkit.org/repositories/openvino/packages/2023.1/linux/l_openvino_toolkit_debian9_2023.1.0.12185.47b736f63ed_arm64.tgz -O openvino_2023.1.0.tgz + tar -xf openvino_2023.1.0.tgz + sudo mv l_openvino_toolkit_debian9_2023.1.0.12185.47b736f63ed_arm64 /opt/intel/openvino_2023.1.0 + .. tab-item:: ARM 32-bit :sync: arm-32 .. code-block:: sh - - curl -L https://storage.openvinotoolkit.org/repositories/openvino/packages/2023.0.1/linux/l_openvino_toolkit_debian9_2023.0.1.11005.fa1c41994f3_armhf.tgz -O openvino_2023.0.1.tgz - tar -xf openvino_2023.0.1.tgz - sudo mv l_openvino_toolkit_debian9_2023.0.1.11005.fa1c41994f3_armhf /opt/intel/openvino_2023.0.1 - - + + curl -L https://storage.openvinotoolkit.org/repositories/openvino/packages/2023.1/linux/l_openvino_toolkit_debian9_2023.1.0.12185.47b736f63ed_armhf.tgz -O openvino_2023.1.0.tgz + tar -xf openvino_2023.1.0.tgz + sudo mv l_openvino_toolkit_debian9_2023.1.0.12185.47b736f63ed_armhf /opt/intel/openvino_2023.1.0 + + 5. Install required system dependencies on Linux. To do this, OpenVINO provides a script in the extracted installation directory. Run the following command: .. code-block:: sh - cd /opt/intel/openvino_2023.0.1 + cd /opt/intel/openvino_2023.1.0 sudo -E ./install_dependencies/install_openvino_dependencies.sh 6. (Optional) Install *numpy* Python Library: @@ -205,11 +205,11 @@ Step 1: Download and Install the OpenVINO Core Components This step is required only when you decide to use Python API. - You can use the ``requirements.txt`` file from the ``/opt/intel/openvino_2023.0.1/python`` folder: + You can use the ``requirements.txt`` file from the ``/opt/intel/openvino_2023.1.0/python`` folder: .. code-block:: sh - cd /opt/intel/openvino_2023.0.1 + cd /opt/intel/openvino_2023.1.0 python3 -m pip install -r ./python/requirements.txt 7. For simplicity, it is useful to create a symbolic link as below: @@ -217,8 +217,8 @@ Step 1: Download and Install the OpenVINO Core Components .. code-block:: sh cd /opt/intel - sudo ln -s openvino_2023.0.1 openvino_2023 - + sudo ln -s openvino_2023.1.0 openvino_2023 + .. note:: If you have already installed a previous release of OpenVINO 2023, a symbolic link to the ``openvino_2023`` folder may already exist. Unlink the previous link with ``sudo unlink openvino_2023``, and then re-run the command above. diff --git a/docs/install_guides/installing-openvino-from-archive-macos.md b/docs/install_guides/installing-openvino-from-archive-macos.md index ac5150e1329138..c2d95fa7180012 100644 --- a/docs/install_guides/installing-openvino-from-archive-macos.md +++ b/docs/install_guides/installing-openvino-from-archive-macos.md @@ -60,7 +60,7 @@ Step 1: Install OpenVINO Core Components cd /Downloads -4. Download the `OpenVINO Runtime archive file for macOS `__, extract the files, rename the extracted folder and move it to the desired path: +4. Download the `OpenVINO Runtime archive file for macOS `__, extract the files, rename the extracted folder and move it to the desired path: .. tab-set:: @@ -69,18 +69,18 @@ Step 1: Install OpenVINO Core Components .. code-block:: sh - curl -L https://storage.openvinotoolkit.org/repositories/openvino/packages/2023.0.1/macos/m_openvino_toolkit_macos_10_15_2023.0.1.11005.fa1c41994f3_x86_64.tgz --output openvino_2023.0.1.tgz - tar -xf openvino_2023.0.1.tgz - sudo mv m_openvino_toolkit_macos_10_15_2023.0.1.11005.fa1c41994f3_x86_64 /opt/intel/openvino_2023.0.1 + curl -L https://storage.openvinotoolkit.org/repositories/openvino/packages/2023.1/macos/m_openvino_toolkit_macos_10_15_2023.1.0.12185.47b736f63ed_x86_64.tgz --output openvino_2023.1.0.tgz + tar -xf openvino_2023.1.0.tgz + sudo mv m_openvino_toolkit_macos_10_15_2023.1.0.12185.47b736f63ed_x86_64 /opt/intel/openvino_2023.1.0 .. tab-item:: ARM, 64-bit :sync: arm-64 .. code-block:: sh - curl -L https://storage.openvinotoolkit.org/repositories/openvino/packages/2023.0.1/macos/m_openvino_toolkit_macos_11_0_2023.0.1.11005.fa1c41994f3_arm64.tgz --output openvino_2023.0.1.tgz - tar -xf openvino_2023.0.1.tgz - sudo mv m_openvino_toolkit_macos_11_0_2023.0.1.11005.fa1c41994f3_arm64 /opt/intel/openvino_2023.0.1 + curl -L https://storage.openvinotoolkit.org/repositories/openvino/packages/2023.1/macos/m_openvino_toolkit_macos_11_0_2023.1.0.12185.47b736f63ed_arm64.tgz --output openvino_2023.1.0.tgz + tar -xf openvino_2023.1.0.tgz + sudo mv m_openvino_toolkit_macos_11_0_2023.1.0.12185.47b736f63ed_arm64 /opt/intel/openvino_2023.1.0 5. (Optional) Install *numpy* Python Library: @@ -88,18 +88,18 @@ Step 1: Install OpenVINO Core Components This step is required only when you decide to use Python API. - You can use the ``requirements.txt`` file from the ``/opt/intel/openvino_2023.0.1/python`` folder: + You can use the ``requirements.txt`` file from the ``/opt/intel/openvino_2023.1.0/python`` folder: .. code-block:: sh - cd /opt/intel/openvino_2023.0.1 + cd /opt/intel/openvino_2023.1.0 python3 -m pip install -r ./python/requirements.txt 6. For simplicity, it is useful to create a symbolic link as below: .. code-block:: sh - sudo ln -s /opt/intel/openvino_2023.0.1 /opt/intel/openvino_2023 + sudo ln -s /opt/intel/openvino_2023.1.0 /opt/intel/openvino_2023 .. note:: diff --git a/docs/install_guides/installing-openvino-from-archive-windows.md b/docs/install_guides/installing-openvino-from-archive-windows.md index 03ba2309807d5a..2193e78df60cb7 100644 --- a/docs/install_guides/installing-openvino-from-archive-windows.md +++ b/docs/install_guides/installing-openvino-from-archive-windows.md @@ -76,19 +76,19 @@ Step 1: Download and Install OpenVINO Core Components ``C:\Program Files (x86)\Intel`` is the recommended folder. You may also use a different path if desired or if you don't have administrator privileges on your computer. -2. Download the `OpenVINO Runtime archive file for Windows `__ to your local ``Downloads`` folder. +2. Download the `OpenVINO Runtime archive file for Windows `__ to your local ``Downloads`` folder. If you prefer using command-lines, run the following commands in the command prompt window you opened: .. code-block:: sh cd /Downloads - curl -L https://storage.openvinotoolkit.org/repositories/openvino/packages/2023.0.1/windows/w_openvino_toolkit_windows_2023.0.1.11005.fa1c41994f3_x86_64.zip --output openvino_2023.0.1.zip + curl -L https://storage.openvinotoolkit.org/repositories/openvino/packages/2023.1/windows/w_openvino_toolkit_windows_2023.1.0.12185.47b736f63ed_x86_64.zip --output openvino_2023.1.0.zip .. note:: - A ``.sha256`` file is provided together with the archive file to validate your download process. To do that, download the ``.sha256`` file from the same repository and run ``CertUtil -hashfile openvino_2023.0.1.zip SHA256``. Compare the returned value in the output with what's in the ``.sha256`` file: if the values are the same, you have downloaded the correct file successfully; if not, create a Support ticket `here `__. + A ``.sha256`` file is provided together with the archive file to validate your download process. To do that, download the ``.sha256`` file from the same repository and run ``CertUtil -hashfile openvino_2023.1.0.zip SHA256``. Compare the returned value in the output with what's in the ``.sha256`` file: if the values are the same, you have downloaded the correct file successfully; if not, create a Support ticket `here `__. 3. Use your favorite tool to extract the archive file, rename the extracted folder, and move it to the ``C:\Program Files (x86)\Intel`` directory. @@ -97,9 +97,9 @@ Step 1: Download and Install OpenVINO Core Components .. code-block:: sh - tar -xf openvino_2023.0.1.zip - ren w_openvino_toolkit_windows_2023.0.0.10926.b4452d56304_x86_64 openvino_2023.0.1 - move openvino_2023.0.1 "C:\Program Files (x86)\Intel" + tar -xf openvino_2023.1.0.zip + ren w_openvino_toolkit_windows_2023.1.0.10926.b4452d56304_x86_64 openvino_2023.1.0 + move openvino_2023.1.0 "C:\Program Files (x86)\Intel" 4. (Optional) Install *numpy* Python Library: @@ -108,11 +108,11 @@ Step 1: Download and Install OpenVINO Core Components This step is required only when you decide to use Python API. - You can use the ``requirements.txt`` file from the ``C:\Program Files (x86)\Intel\openvino_2023.0.1\python`` folder: + You can use the ``requirements.txt`` file from the ``C:\Program Files (x86)\Intel\openvino_2023.1.0\python`` folder: .. code-block:: sh - cd "C:\Program Files (x86)\Intel\openvino_2023.0.1" + cd "C:\Program Files (x86)\Intel\openvino_2023.1.0" python -m pip install -r .\python\requirements.txt @@ -121,7 +121,7 @@ Step 1: Download and Install OpenVINO Core Components .. code-block:: sh cd C:\Program Files (x86)\Intel - mklink /D openvino_2023 openvino_2023.0.1 + mklink /D openvino_2023 openvino_2023.1.0 .. note:: diff --git a/docs/install_guides/installing-openvino-pip.md b/docs/install_guides/installing-openvino-pip.md index 1cd4548cdf0347..01fe7e50d21498 100644 --- a/docs/install_guides/installing-openvino-pip.md +++ b/docs/install_guides/installing-openvino-pip.md @@ -13,7 +13,7 @@ * offers the Python API only * does not offer support for GNA and NPU inference - * is dedicated to users of all major OSs: Windows, Linux, macOS + * is dedicated to users of all major OSs: Windows, Linux, macOS and x86_64 / arm64 architectures .. tab-set:: diff --git a/docs/install_guides/installing-openvino-vcpkg.md b/docs/install_guides/installing-openvino-vcpkg.md index 39694079dfb2d3..c0eba8c88943d6 100644 --- a/docs/install_guides/installing-openvino-vcpkg.md +++ b/docs/install_guides/installing-openvino-vcpkg.md @@ -12,7 +12,7 @@ * offers C/C++ API only * does not offer support for GNA and NPU inference - * is dedicated to users of all major OSs: Windows, Linux, macOS. + * is dedicated to users of all major OSs: Windows, Linux, macOS and x86_64 / arm64 architectures. .. tab-set:: @@ -48,27 +48,35 @@ Installing OpenVINO Runtime vcpkg install openvino - vcpkg also enables you to install only selected components, by specifying them in the command. + vcpkg also enables you to install only selected components, by specifying them in the command. See the list of `available features `__, for example: .. code-block:: sh - vcpkg install openvino[cpu,ir] + vcpkg install 'openvino[core,cpu,ir]' + + vcpkg also provides a way to install OpenVINO for any specific configuration you want via `triplets `, for example to install OpenVINO statically on Windows, use: + + .. code-block:: sh + + vcpkg install openvino:x64-windows-static Note that the vcpkg installation means building all packages and dependencies from source, which means the compiler stage will require additional time to complete the process. -After installation, you can use OpenVINO in your product by running: +After installation, you can use OpenVINO in your product's cmake scripts: .. code-block:: sh - find_package(OpenVINO) + find_package(OpenVINO REQUIRED) + +And running from terminal: .. code-block:: sh - cmake -B [build directory] -S . -DCMAKE_TOOLCHAIN_FILE=[path to vcpkg]/scripts/buildsystems/vcpkg.cmake - -Congratulations! You've just Installed OpenVINO! For some use cases you may still + cmake -B -S -DCMAKE_TOOLCHAIN_FILE=/scripts/buildsystems/vcpkg.cmake + +Congratulations! You've just Installed and used OpenVINO in your project! For some use cases you may still need to install additional components. Check the :doc:`list of additional configurations ` to see if your case needs any of them. diff --git a/docs/install_guides/installing-openvino-yum.md b/docs/install_guides/installing-openvino-yum.md index 1d7f6228141133..0a71adce6b3f65 100644 --- a/docs/install_guides/installing-openvino-yum.md +++ b/docs/install_guides/installing-openvino-yum.md @@ -13,7 +13,6 @@ * offers C/C++ APIs only * does not offer support for GNA and NPU inference * additionally includes code samples - * is dedicated to Linux users. .. tab-set:: @@ -115,7 +114,7 @@ Install OpenVINO Runtime .. code-block:: sh - sudo yum install openvino-2023.0.0 + sudo yum install openvino-2023.1.0 @@ -186,7 +185,7 @@ To uninstall OpenVINO Runtime via YUM, run the following command based on your n .. code-block:: sh - sudo yum autoremove openvino-2023.0.0 + sudo yum autoremove openvino-2023.1.0 diff --git a/docs/snippets/export_compiled_model.cpp b/docs/snippets/export_compiled_model.cpp index 912e752478daa9..02b83d6b5ec5b8 100644 --- a/docs/snippets/export_compiled_model.cpp +++ b/docs/snippets/export_compiled_model.cpp @@ -1,17 +1,13 @@ - +#include #include int main() { //! [export_compiled_model] ov::Core core; - -std::stringstream stream; - ov::CompiledModel model = core.compile_model("modelPath", "deviceName"); - +std::fstream stream("compiled_model.blob"); model.export_model(stream); - //! [export_compiled_model] return 0; From a4cbac3deedf8cfb80d561a3a5cb0486c53dce36 Mon Sep 17 00:00:00 2001 From: Maxim Vafin Date: Mon, 18 Sep 2023 13:40:40 +0200 Subject: [PATCH 05/30] [PT FE] Add tests for detectron2 models (#19888) * [PT FE] Add tests for detectron2 models * Fix names of tests * Apply suggestions from code review Co-authored-by: Roman Kazantsev * Create secondary requirements file --------- Co-authored-by: Roman Kazantsev --- .github/workflows/linux.yml | 1 + .../models_hub_common/utils.py | 3 +- .../torch_tests/detectron2_models | 65 +++++++++++++ .../torch_tests/detectron2_precommit | 26 ++++++ .../torch_tests/requirements.txt | 2 +- .../torch_tests/requirements_secondary.txt | 3 + .../torch_tests/test_detectron2.py | 93 +++++++++++++++++++ 7 files changed, 191 insertions(+), 2 deletions(-) create mode 100644 tests/model_hub_tests/torch_tests/detectron2_models create mode 100644 tests/model_hub_tests/torch_tests/detectron2_precommit create mode 100644 tests/model_hub_tests/torch_tests/requirements_secondary.txt create mode 100644 tests/model_hub_tests/torch_tests/test_detectron2.py diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 55111be2453ee6..486cc879ec02d0 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -912,6 +912,7 @@ jobs: - name: PyTorch Models Tests 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 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 env: diff --git a/tests/model_hub_tests/models_hub_common/utils.py b/tests/model_hub_tests/models_hub_common/utils.py index efb4bd8a64c2e9..b5699a80e62b43 100644 --- a/tests/model_hub_tests/models_hub_common/utils.py +++ b/tests/model_hub_tests/models_hub_common/utils.py @@ -32,7 +32,8 @@ def compare_two_tensors(ov_res, fw_res, eps): is_ok = True if not np.allclose(ov_res, fw_res, atol=eps, rtol=eps, equal_nan=True): is_ok = False - print("Max diff is {}".format(np.array(abs(ov_res - fw_res)).max())) + max_diff = np.abs(ov_res.astype(np.float32) - fw_res.astype(np.float32)).max() + print("Max diff is {}".format(max_diff)) else: print("Accuracy validation successful!\n") print("absolute eps: {}, relative eps: {}".format(eps, eps)) diff --git a/tests/model_hub_tests/torch_tests/detectron2_models b/tests/model_hub_tests/torch_tests/detectron2_models new file mode 100644 index 00000000000000..091464ab8d3080 --- /dev/null +++ b/tests/model_hub_tests/torch_tests/detectron2_models @@ -0,0 +1,65 @@ +COCO-Detection/fast_rcnn_R_50_FPN_1x,none +COCO-Detection/faster_rcnn_R_101_C4_3x,none +COCO-Detection/faster_rcnn_R_101_DC5_3x,none +COCO-Detection/faster_rcnn_R_101_FPN_3x,none +COCO-Detection/faster_rcnn_R_50_C4_1x,none +COCO-Detection/faster_rcnn_R_50_C4_3x,none +COCO-Detection/faster_rcnn_R_50_DC5_1x,none +COCO-Detection/faster_rcnn_R_50_DC5_3x,none +COCO-Detection/faster_rcnn_R_50_FPN_1x,none +COCO-Detection/faster_rcnn_R_50_FPN_3x,none +COCO-Detection/faster_rcnn_X_101_32x8d_FPN_3x,none +COCO-Detection/retinanet_R_101_FPN_3x,none +COCO-Detection/retinanet_R_50_FPN_1x,none +COCO-Detection/retinanet_R_50_FPN_3x,none +COCO-Detection/rpn_R_50_C4_1x,none +COCO-Detection/rpn_R_50_FPN_1x,none +COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_1x,none +COCO-InstanceSegmentation/mask_rcnn_R_101_C4_3x,none +COCO-InstanceSegmentation/mask_rcnn_R_101_DC5_3x,none +COCO-InstanceSegmentation/mask_rcnn_R_101_FPN_3x,none +COCO-InstanceSegmentation/mask_rcnn_R_50_C4_1x,none +COCO-InstanceSegmentation/mask_rcnn_R_50_C4_3x,none +COCO-InstanceSegmentation/mask_rcnn_R_50_DC5_1x,none +COCO-InstanceSegmentation/mask_rcnn_R_50_DC5_3x,none +#COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_1x_giou,none - Pretrained model is not available! +COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x,none +COCO-InstanceSegmentation/mask_rcnn_X_101_32x8d_FPN_3x,none +#COCO-Keypoints/Base-Keypoint-RCNN-FPN,none - Pretrained model is not available! +COCO-Keypoints/keypoint_rcnn_R_101_FPN_3x,none +COCO-Keypoints/keypoint_rcnn_R_50_FPN_1x,none +COCO-Keypoints/keypoint_rcnn_R_50_FPN_3x,none +COCO-Keypoints/keypoint_rcnn_X_101_32x8d_FPN_3x,none +#COCO-PanopticSegmentation/Base-Panoptic-FPN,none - Pretrained model is not available! +COCO-PanopticSegmentation/panoptic_fpn_R_101_3x,none +COCO-PanopticSegmentation/panoptic_fpn_R_50_1x,none +COCO-PanopticSegmentation/panoptic_fpn_R_50_3x,none +Cityscapes/mask_rcnn_R_50_FPN,none +Detectron1-Comparisons/faster_rcnn_R_50_FPN_noaug_1x,none +Detectron1-Comparisons/keypoint_rcnn_R_50_FPN_1x,none +Detectron1-Comparisons/mask_rcnn_R_50_FPN_noaug_1x,none +LVISv0.5-InstanceSegmentation/mask_rcnn_R_101_FPN_1x,none +LVISv0.5-InstanceSegmentation/mask_rcnn_R_50_FPN_1x,none +LVISv0.5-InstanceSegmentation/mask_rcnn_X_101_32x8d_FPN_1x,none +#LVISv1-InstanceSegmentation/mask_rcnn_R_101_FPN_1x,none - Pretrained model is not available! +#LVISv1-InstanceSegmentation/mask_rcnn_R_50_FPN_1x,none - Pretrained model is not available! +#LVISv1-InstanceSegmentation/mask_rcnn_X_101_32x8d_FPN_1x,none - Pretrained model is not available! +#Misc/mask_rcnn_R_50_FPN_1x_cls_agnostic,none - Pretrained model is not available! +Misc/cascade_mask_rcnn_R_50_FPN_1x,none +Misc/cascade_mask_rcnn_R_50_FPN_3x,none +Misc/cascade_mask_rcnn_X_152_32x8d_FPN_IN5k_gn_dconv,none +Misc/mask_rcnn_R_50_FPN_1x_dconv_c3-c5,none +Misc/mask_rcnn_R_50_FPN_3x_dconv_c3-c5,none +Misc/mask_rcnn_R_50_FPN_3x_gn,none +Misc/mask_rcnn_R_50_FPN_3x_syncbn,none +Misc/panoptic_fpn_R_101_dconv_cascade_gn_3x,none +Misc/scratch_mask_rcnn_R_50_FPN_3x_gn,none +Misc/scratch_mask_rcnn_R_50_FPN_9x_gn,none +Misc/scratch_mask_rcnn_R_50_FPN_9x_syncbn,none +#Misc/semantic_R_50_FPN_1x,none - Pretrained model is not available! +PascalVOC-Detection/faster_rcnn_R_50_C4,none +#PascalVOC-Detection/faster_rcnn_R_50_FPN,none - Pretrained model is not available! +#Base-RCNN-C4,none - Pretrained model is not available! +#Base-RCNN-DilatedC5,none - Pretrained model is not available! +#Base-RCNN-FPN,none - Pretrained model is not available! +#Base-RetinaNet,none - Pretrained model is not available! diff --git a/tests/model_hub_tests/torch_tests/detectron2_precommit b/tests/model_hub_tests/torch_tests/detectron2_precommit new file mode 100644 index 00000000000000..155e4d2a359779 --- /dev/null +++ b/tests/model_hub_tests/torch_tests/detectron2_precommit @@ -0,0 +1,26 @@ +COCO-Detection/faster_rcnn_R_50_C4_1x,none +COCO-Detection/faster_rcnn_R_50_DC5_3x,none +COCO-Detection/faster_rcnn_R_50_FPN_1x,none +COCO-Detection/faster_rcnn_X_101_32x8d_FPN_3x,none +COCO-Detection/retinanet_R_50_FPN_1x,none +COCO-Detection/rpn_R_50_C4_1x,none +COCO-Detection/rpn_R_50_FPN_1x,none +COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_1x,none +COCO-InstanceSegmentation/mask_rcnn_R_50_C4_3x,none +COCO-InstanceSegmentation/mask_rcnn_R_50_DC5_3x,none +COCO-InstanceSegmentation/mask_rcnn_X_101_32x8d_FPN_3x,none +COCO-Keypoints/keypoint_rcnn_R_50_FPN_3x,none +COCO-Keypoints/keypoint_rcnn_X_101_32x8d_FPN_3x,none +Cityscapes/mask_rcnn_R_50_FPN,none +Detectron1-Comparisons/faster_rcnn_R_50_FPN_noaug_1x,none +Detectron1-Comparisons/keypoint_rcnn_R_50_FPN_1x,none +Detectron1-Comparisons/mask_rcnn_R_50_FPN_noaug_1x,none +LVISv0.5-InstanceSegmentation/mask_rcnn_R_50_FPN_1x,none +LVISv0.5-InstanceSegmentation/mask_rcnn_X_101_32x8d_FPN_1x,none +Misc/cascade_mask_rcnn_R_50_FPN_3x,none +Misc/cascade_mask_rcnn_X_152_32x8d_FPN_IN5k_gn_dconv,none +Misc/mask_rcnn_R_50_FPN_3x_dconv_c3-c5,none +Misc/mask_rcnn_R_50_FPN_3x_gn,none +Misc/mask_rcnn_R_50_FPN_3x_syncbn,none +Misc/scratch_mask_rcnn_R_50_FPN_9x_syncbn,none +PascalVOC-Detection/faster_rcnn_R_50_C4,none diff --git a/tests/model_hub_tests/torch_tests/requirements.txt b/tests/model_hub_tests/torch_tests/requirements.txt index de68479afe714e..9a859794b09d04 100644 --- a/tests/model_hub_tests/torch_tests/requirements.txt +++ b/tests/model_hub_tests/torch_tests/requirements.txt @@ -4,4 +4,4 @@ pytest pytest-html torch torchvision -av \ No newline at end of file +av diff --git a/tests/model_hub_tests/torch_tests/requirements_secondary.txt b/tests/model_hub_tests/torch_tests/requirements_secondary.txt new file mode 100644 index 00000000000000..f59753797b27a0 --- /dev/null +++ b/tests/model_hub_tests/torch_tests/requirements_secondary.txt @@ -0,0 +1,3 @@ +-c ../../constraints.txt +# This file contains requirements dependednt from modules in requirements.txt +git+https://github.com/facebookresearch/detectron2.git \ No newline at end of file diff --git a/tests/model_hub_tests/torch_tests/test_detectron2.py b/tests/model_hub_tests/torch_tests/test_detectron2.py new file mode 100644 index 00000000000000..e8859905622260 --- /dev/null +++ b/tests/model_hub_tests/torch_tests/test_detectron2.py @@ -0,0 +1,93 @@ +# Copyright (C) 2018-2023 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import os +import pytest +import torch +from models_hub_common.test_convert_model import TestConvertModel +from openvino import convert_model +from models_hub_common.utils import get_models_list, compare_two_tensors + + +class TestDetectron2ConvertModel(TestConvertModel): + def setup_class(self): + from PIL import Image + import requests + + url = "http://images.cocodataset.org/val2017/000000039769.jpg" + self.image = Image.open(requests.get(url, stream=True).raw) + self.image = self.image.resize([640, 480]) + + def load_model(self, model_name, model_link): + from detectron2 import model_zoo, export + from detectron2.modeling import build_model + from detectron2.checkpoint import DetectionCheckpointer + from detectron2.config import CfgNode + import torchvision.transforms as transforms + + transform = transforms.Compose([transforms.PILToTensor()]) + image = transform(self.image) + + cfg = model_zoo.get_config(model_name + ".yaml", trained=True) + assert isinstance(cfg, CfgNode), "Unexpected config" + cfg.MODEL.DEVICE = "cpu" + model = build_model(cfg) + DetectionCheckpointer(model, save_to_disk=False).load(cfg.MODEL.WEIGHTS) + + model.eval() + inputs = [{"image": image, + "height": torch.tensor(image.shape[1]), + "width": torch.tensor(image.shape[2])}] + adapter = export.TracingAdapter(model, inputs) + + self.example = adapter.flattened_inputs + return adapter + + def get_inputs_info(self, model_obj): + return None + + def prepare_inputs(self, inputs_info): + return [i.numpy() for i in self.example] + + def convert_model(self, model_obj): + ov_model = convert_model(model_obj, example_input=self.example) + return ov_model + + def infer_fw_model(self, model_obj, inputs): + fw_outputs = model_obj(*[torch.from_numpy(i) for i in inputs]) + if isinstance(fw_outputs, dict): + for k in fw_outputs.keys(): + fw_outputs[k] = fw_outputs[k].numpy(force=True) + elif isinstance(fw_outputs, (list, tuple)): + fw_outputs = [o.numpy(force=True) for o in fw_outputs] + else: + fw_outputs = [fw_outputs.numpy(force=True)] + return fw_outputs + + def compare_results(self, fw_outputs, ov_outputs): + assert len(fw_outputs) == len(ov_outputs), \ + "Different number of outputs between TensorFlow and OpenVINO:" \ + " {} vs. {}".format(len(fw_outputs), len(ov_outputs)) + + fw_eps = 5e-2 + is_ok = True + for i in range(len(ov_outputs)): + cur_fw_res = fw_outputs[i] + cur_ov_res = ov_outputs[i] + l = min(len(cur_fw_res), len(cur_ov_res)) + assert l > 0 or len(cur_fw_res) == len(cur_ov_res), "No boxes were selected." + print(f"fw_re: {cur_fw_res};\n ov_res: {cur_ov_res}") + is_ok = compare_two_tensors(cur_ov_res[:l], cur_fw_res[:l], fw_eps) + assert is_ok, "Accuracy validation failed" + + @pytest.mark.parametrize("name,type,mark,reason", + get_models_list(os.path.join(os.path.dirname(__file__), "detectron2_precommit"))) + @pytest.mark.precommit + def test_detectron2_precommit(self, name, type, mark, reason, ie_device): + self.run(name, None, ie_device) + + @pytest.mark.parametrize("name,type,mark,reason", + get_models_list(os.path.join(os.path.dirname(__file__), "detectron2_models"))) + @pytest.mark.nightly + def test_detectron2_all_models(self, name, type, mark, reason, ie_device): + self.run(name, None, ie_device) From df19699e3a6d3db2adcc88602bfd6922f42f6f68 Mon Sep 17 00:00:00 2001 From: Roman Kazantsev Date: Mon, 18 Sep 2023 16:18:05 +0400 Subject: [PATCH 06/30] [TF Hub API][TF FE] Support TF Keras Model OOB without example_input (#19892) * [TF Hub] Cover TF Hub use cases with adoption to OpenVINO This is necessarily to demonstrate support of models programmed with TF Hub API through OV notebooks. Signed-off-by: Kazantsev, Roman * Preserve original keras input and output tensor names * Add tests with TF Hub API models * No KerasLayer handling * Handle specific signature --------- Signed-off-by: Kazantsev, Roman --- .../src/openvino/frontend/tensorflow/utils.py | 105 +++++++++++++++++- .../models_hub_common/test_convert_model.py | 12 +- .../tf_hub_tests/test_tf_hub_api_notebooks.py | 63 +++++++++++ .../tf_hub_tests/test_tf_hub_convert_model.py | 14 +-- tests/model_hub_tests/tf_hub_tests/utils.py | 33 ++++++ 5 files changed, 206 insertions(+), 21 deletions(-) create mode 100644 tests/model_hub_tests/tf_hub_tests/test_tf_hub_api_notebooks.py create mode 100644 tests/model_hub_tests/tf_hub_tests/utils.py diff --git a/src/bindings/python/src/openvino/frontend/tensorflow/utils.py b/src/bindings/python/src/openvino/frontend/tensorflow/utils.py index d796f1cfb8fb73..056e0904b4c22f 100644 --- a/src/bindings/python/src/openvino/frontend/tensorflow/utils.py +++ b/src/bindings/python/src/openvino/frontend/tensorflow/utils.py @@ -63,7 +63,7 @@ def get_imported_module_version(imported_module): for attr in version_attrs: installed_version = getattr(imported_module, attr, None) if isinstance(installed_version, str): - return installed_version + return installed_version else: installed_version = None @@ -98,7 +98,8 @@ def get_environment_setup(framework): def trace_tf_model_if_needed(input_model, placeholder_shapes, placeholder_data_types, example_input): import tensorflow as tf - if not isinstance(input_model, (tf.keras.layers.Layer, tf.Module, tf.keras.Model, tf.types.experimental.GenericFunction)): + if not isinstance(input_model, + (tf.keras.layers.Layer, tf.Module, tf.keras.Model, tf.types.experimental.GenericFunction)): return input_model return trace_tf_model(input_model, placeholder_shapes, placeholder_data_types, example_input) @@ -175,6 +176,65 @@ def get_concrete_func(tf_function, example_input, input_needs_packing, error_mes return concrete_func +def create_generic_function_from_keras_model(keras_model): + import tensorflow as tf + assert isinstance(keras_model, tf.keras.Model), \ + "[TensorFlow Frontend] internal error: the input model must be of Keras model type" + if not hasattr(keras_model, 'input') or getattr(keras_model, 'input') is None: + return None + keras_input_signature = getattr(keras_model, 'input') + tf_input_signature = None + wrapper_function = None + if isinstance(keras_input_signature, dict): + tf_input_signature = [] + for tensor_name, tensor_spec in keras_input_signature.items(): + tf_input_signature.append(tf.TensorSpec(shape=tensor_spec.shape, + dtype=tensor_spec.dtype, + name=tensor_name)) + elif isinstance(keras_input_signature, list): + tf_input_signature = [] + for tensor_spec in keras_input_signature: + tf_input_signature.append(tf.TensorSpec(shape=tensor_spec.shape, + dtype=tensor_spec.dtype, + name=tensor_spec.name)) + else: + try: + # single KerasTensor case + tf_input_signature = [] + tf_input_signature.append(tf.TensorSpec(shape=keras_input_signature.shape, + dtype=keras_input_signature.dtype, + name=keras_input_signature.name)) + except: + tf_input_signature = None + if tf_input_signature is not None: + @tf.function(input_signature=tf_input_signature) + def wrapper_function_dict(*args): + input_dict = {} + for ind, tensor_spec in enumerate(tf_input_signature): + input_dict[tensor_spec.name] = args[ind] + outputs = keras_model(input_dict) + # need to wrap the output into dictionary + # it helps to preserve original keras tensor names + post_outputs = {} + if isinstance(outputs, dict): + for output_name, output_value in outputs.items(): + post_outputs[output_name] = output_value + else: + try: + if isinstance(outputs, list) and isinstance(keras_model.outputs, list) and \ + len(outputs) == len(keras_model.outputs): + for output_value, output_tensor in zip(outputs, keras_model.outputs): + post_outputs[output_tensor.name] = output_value + else: + post_outputs[keras_model.output.name] = outputs + except: + post_outputs = outputs + return post_outputs + + wrapper_function = wrapper_function_dict + return wrapper_function + + def trace_tf_model(model, input_shapes, input_types, example_input): import tensorflow as tf if isinstance(model.__call__, tf.types.experimental.GenericFunction): @@ -183,12 +243,25 @@ def trace_tf_model(model, input_shapes, input_types, example_input): elif isinstance(model, tf.types.experimental.GenericFunction): tf_function = model input_needs_packing = False + elif isinstance(model, tf.keras.Model): + tf_function = create_generic_function_from_keras_model(model) + if tf_function is not None: + input_needs_packing = False + else: + # Wrap model to tf.Function. + # In this case we loose input/output tensor names. + @tf.function + def tf_function(args): + return model(*args) + + input_needs_packing = True else: # Wrap model to tf.Function. # In this case we loose input/output tensor names. @tf.function def tf_function(args): return model(*args) + input_needs_packing = True if example_input is not None: @@ -216,7 +289,8 @@ def tf_function(args): def type_supported_by_tf_fe(input_model): import tensorflow as tf # Types that require tracing - if isinstance(input_model, (tf.keras.layers.Layer, tf.Module, tf.keras.Model, tf.types.experimental.GenericFunction)): + if isinstance(input_model, + (tf.keras.layers.Layer, tf.Module, tf.keras.Model, tf.types.experimental.GenericFunction)): return True # Types that do not require tracing if isinstance(input_model, (tf.Graph, tf.types.experimental.ConcreteFunction)): @@ -246,7 +320,15 @@ def create_tf_graph_iterator(input_model, placeholder_shapes, placeholder_data_t if func_input.dtype == tf.resource: continue internal_tensor_names.append(func_input.name) - if len(input_model.structured_input_signature) > 1 and \ + if len(input_model.structured_input_signature) > 0 and \ + len(internal_tensor_names) == len(input_model.structured_input_signature[0]): + for internal_name, tensor_spec in zip(internal_tensor_names, input_model.structured_input_signature[0]): + input_names_map = input_names_map or {} + if not isinstance(tensor_spec, tf.TensorSpec): + input_names_map = None + break + input_names_map[internal_name] = tensor_spec.name + elif len(input_model.structured_input_signature) > 1 and \ len(internal_tensor_names) == len(input_model.structured_input_signature[1]): external_tensor_names = sorted(input_model.structured_input_signature[1].keys()) for internal_name, external_name in zip(internal_tensor_names, external_tensor_names): @@ -262,6 +344,19 @@ def create_tf_graph_iterator(input_model, placeholder_shapes, placeholder_data_t for external_name, internal_name in zip(external_names, internal_names): output_names_map = output_names_map or {} output_names_map[internal_name] = external_name + else: + for external_name, internal_tensor in input_model.structured_outputs.items(): + internal_tf_tensor = None + if isinstance(internal_tensor, tf.Tensor): + internal_tf_tensor = internal_tensor + if isinstance(internal_tensor, list) and len(internal_tensor) > 0 and \ + isinstance(internal_tensor[0], tf.Tensor): + internal_tf_tensor = internal_tensor[0] + if internal_tf_tensor is None: + output_names_map = None + break + output_names_map = output_names_map or {} + output_names_map[internal_tf_tensor.name] = external_name return GraphIteratorTFGraph(input_model.graph, share_weights, False, input_names_map, output_names_map) raise Exception("Could not wrap model of type {} to GraphIteratorTFGraph.".format(type(input_model))) @@ -271,7 +366,7 @@ def extract_model_graph(argv): import tensorflow as tf trackable_is_imported = False try: - from tensorflow.python.training.tracking.base import Trackable # pylint: disable=no-name-in-module,import-error + from tensorflow.python.training.tracking.base import Trackable # pylint: disable=no-name-in-module,import-error trackable_is_imported = True except: log.warning("Could not import tensorflow.python.training.tracking.base.Trackable type.") diff --git a/tests/model_hub_tests/models_hub_common/test_convert_model.py b/tests/model_hub_tests/models_hub_common/test_convert_model.py index e64a8d17ea5076..145da6b61761f7 100644 --- a/tests/model_hub_tests/models_hub_common/test_convert_model.py +++ b/tests/model_hub_tests/models_hub_common/test_convert_model.py @@ -35,9 +35,15 @@ def prepare_input(self, input_shape, input_type): assert False, "Unsupported type {}".format(input_type) def prepare_inputs(self, inputs_info): - inputs = {} - for input_name, input_shape, input_type in inputs_info: - inputs[input_name] = self.prepare_input(input_shape, input_type) + if len(inputs_info) > 0 and inputs_info[0] == 'list': + inputs = [] + inputs_info = inputs_info[1:] + for input_name, input_shape, input_type in inputs_info: + inputs.append(self.prepare_input(input_shape, input_type)) + else: + inputs = {} + for input_name, input_shape, input_type in inputs_info: + inputs[input_name] = self.prepare_input(input_shape, input_type) return inputs def convert_model(self, model_obj): diff --git a/tests/model_hub_tests/tf_hub_tests/test_tf_hub_api_notebooks.py b/tests/model_hub_tests/tf_hub_tests/test_tf_hub_api_notebooks.py new file mode 100644 index 00000000000000..fe006d3860f56f --- /dev/null +++ b/tests/model_hub_tests/tf_hub_tests/test_tf_hub_api_notebooks.py @@ -0,0 +1,63 @@ +# Copyright (C) 2018-2023 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import pytest +import tensorflow as tf +import tensorflow_hub as hub +from models_hub_common.test_convert_model import TestConvertModel +from tf_hub_tests.utils import get_input_info + + +class TestTFHubApiNotebooks(TestConvertModel): + def load_model(self, model_name, model_link): + if model_name == 'mobilenet_v2_100_224_dict': + image = tf.keras.layers.Input(shape=(224, 224, 3), dtype=tf.float32, name="image") + feature_vector = hub.KerasLayer("https://tfhub.dev/google/imagenet/mobilenet_v2_100_224/feature_vector/5", + trainable=False)(image) + softmax = tf.keras.layers.Dense(20, activation='softmax')(feature_vector) + classification_model = tf.keras.Model(inputs={'image': image}, outputs={'softmax': softmax}) + return classification_model + elif model_name == 'mobilenet_v2_100_224_list': + image = tf.keras.layers.Input(shape=(224, 224, 3), dtype=tf.float32, name="image") + feature_vector = hub.KerasLayer("https://tfhub.dev/google/imagenet/mobilenet_v2_100_224/feature_vector/5", + trainable=False)(image) + softmax = tf.keras.layers.Dense(20, activation='softmax')(feature_vector) + classification_model = tf.keras.Model(inputs=[image], outputs=[softmax]) + return classification_model + else: + raise "Unknown input model: {}".format(model_name) + + def get_inputs_info(self, keras_model): + inputs_info = [] + if isinstance(keras_model.input, dict): + for input_name, input_tensor in keras_model.input.items(): + inputs_info.append(get_input_info(input_tensor, input_name)) + elif isinstance(keras_model.input, list): + inputs_info.append('list') + for input_tensor in keras_model.input: + inputs_info.append(get_input_info(input_tensor, input_tensor.name)) + else: + inputs_info.append('list') + input_tensor = keras_model.input + inputs_info.append(get_input_info(input_tensor, input_tensor.name)) + return inputs_info + + def infer_fw_model(self, model_obj, inputs): + outputs = model_obj(inputs) + if isinstance(outputs, dict): + post_outputs = {} + for out_name, out_value in outputs.items(): + post_outputs[out_name] = out_value.numpy() + elif isinstance(outputs, list): + post_outputs = [] + for out_value in outputs: + post_outputs.append(out_value.numpy()) + else: + post_outputs = [outputs.numpy()] + + return post_outputs + + @pytest.mark.precommit + @pytest.mark.parametrize("model_name", ['mobilenet_v2_100_224_dict', 'mobilenet_v2_100_224_list']) + def test_tf_hub_api_notebook1(self, model_name, ie_device): + self.run(model_name, '', ie_device) diff --git a/tests/model_hub_tests/tf_hub_tests/test_tf_hub_convert_model.py b/tests/model_hub_tests/tf_hub_tests/test_tf_hub_convert_model.py index 94fe5bba83e37c..c596273d92c8f1 100644 --- a/tests/model_hub_tests/tf_hub_tests/test_tf_hub_convert_model.py +++ b/tests/model_hub_tests/tf_hub_tests/test_tf_hub_convert_model.py @@ -5,7 +5,6 @@ import os import shutil -import numpy as np import pytest import tensorflow as tf import tensorflow_hub as hub @@ -14,6 +13,7 @@ from models_hub_common.constants import tf_hub_cache_dir from models_hub_common.test_convert_model import TestConvertModel from models_hub_common.utils import get_models_list +from tf_hub_tests.utils import type_map class TestTFHubConvertModel(TestConvertModel): @@ -49,18 +49,6 @@ def get_inputs_info(self, model_obj): except ValueError: # unknown rank case pass - type_map = { - tf.float64: np.float64, - tf.float32: np.float32, - tf.int8: np.int8, - tf.int16: np.int16, - tf.int32: np.int32, - tf.int64: np.int64, - tf.uint8: np.uint8, - tf.uint16: np.uint16, - tf.string: str, - tf.bool: bool, - } if input_info.dtype == tf.resource: # skip inputs corresponding to variables continue diff --git a/tests/model_hub_tests/tf_hub_tests/utils.py b/tests/model_hub_tests/tf_hub_tests/utils.py new file mode 100644 index 00000000000000..61f10d9d27af84 --- /dev/null +++ b/tests/model_hub_tests/tf_hub_tests/utils.py @@ -0,0 +1,33 @@ +# Copyright (C) 2018-2023 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import numpy as np +import tensorflow as tf + +type_map = { + tf.float64: np.float64, + tf.float32: np.float32, + tf.int8: np.int8, + tf.int16: np.int16, + tf.int32: np.int32, + tf.int64: np.int64, + tf.uint8: np.uint8, + tf.uint16: np.uint16, + tf.string: str, + tf.bool: bool, +} + + +def get_input_info(input_tensor, input_name): + input_shape = [] + try: + for dim in input_tensor.shape.as_list(): + if dim is None: + input_shape.append(1) + else: + input_shape.append(dim) + except ValueError: + # unknown rank case + pass + assert input_tensor.dtype in type_map, "Unsupported input type: {}".format(input_tensor.dtype) + return input_name, input_shape, type_map[input_tensor.dtype] From d90ceb93d167bc6713559f8ec00778230dea2b14 Mon Sep 17 00:00:00 2001 From: Roman Kazantsev Date: Mon, 18 Sep 2023 16:51:33 +0400 Subject: [PATCH 07/30] [TF Hub][TF FE] Fix 5D case for FusedBatchNorm (#19904) Signed-off-by: Kazantsev, Roman --- .../tensorflow_common/src/op/fused_batch_norm.cpp | 2 +- .../layer_tests/tensorflow_tests/test_tf_FusedBatchNorm.py | 7 ++++++- tests/model_hub_tests/tf_hub_tests/precommit_models | 1 + 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/frontends/tensorflow_common/src/op/fused_batch_norm.cpp b/src/frontends/tensorflow_common/src/op/fused_batch_norm.cpp index 656213e157394c..027b5fcdf0df9a 100644 --- a/src/frontends/tensorflow_common/src/op/fused_batch_norm.cpp +++ b/src/frontends/tensorflow_common/src/op/fused_batch_norm.cpp @@ -146,7 +146,7 @@ void compute_fused_batch_norm_inference(const NodeContext& node, // retrieve attributes auto epsilon = node.get_attribute("epsilon", 0.0001f); auto data_format = node.get_attribute("data_format", "NHWC"); - bool is_nhwc = (data_format == "NHWC"); + bool is_nhwc = (data_format == "NHWC" || data_format == "NDHWC"); // create auxiliary Constant nodes for some attributes: epsilon and exponential_avg_factor auto eps_const = create_same_type_const_scalar(x, epsilon); diff --git a/tests/layer_tests/tensorflow_tests/test_tf_FusedBatchNorm.py b/tests/layer_tests/tensorflow_tests/test_tf_FusedBatchNorm.py index 884a8a5bf4414f..94ae7dc628270d 100644 --- a/tests/layer_tests/tensorflow_tests/test_tf_FusedBatchNorm.py +++ b/tests/layer_tests/tensorflow_tests/test_tf_FusedBatchNorm.py @@ -35,7 +35,7 @@ def create_fused_batch_norm_net(self, x_shape, epsilon, exponential_avg_factor, # Create the graph and model with tf.compat.v1.Session() as sess: c_dim = x_shape[-1] - if data_format == "NCHW": + if data_format == "NCHW" or data_format == "NCDHW": c_dim = x_shape[1] x = tf.compat.v1.placeholder(tf.float32, x_shape, 'x') if empty_mean_variance: @@ -92,6 +92,11 @@ def create_fused_batch_norm_net(self, x_shape, epsilon, exponential_avg_factor, fbn_version="v3"), dict(x_shape=[5, 10, 8, 2], epsilon=0.0002, exponential_avg_factor=0.2, data_format="NHWC", is_training=True, fbn_version="v3", empty_mean_variance=False), + # 5D cases + dict(x_shape=[5, 4, 3, 2, 3], epsilon=0.0005, exponential_avg_factor=0.0, data_format="NCDHW", + is_training=False, fbn_version="v3"), + dict(x_shape=[3, 4, 3, 3, 2], epsilon=0.0003, exponential_avg_factor=0.0, data_format="NDHWC", + is_training=False, fbn_version="v3"), ] @pytest.mark.parametrize("params", test_data_basic) diff --git a/tests/model_hub_tests/tf_hub_tests/precommit_models b/tests/model_hub_tests/tf_hub_tests/precommit_models index 90dd3f4c5e1c17..f9be334761d23c 100644 --- a/tests/model_hub_tests/tf_hub_tests/precommit_models +++ b/tests/model_hub_tests/tf_hub_tests/precommit_models @@ -9,6 +9,7 @@ imagenet/efficientnet_v2_imagenet1k_b0/feature_vector,https://tfhub.dev/google/i imagenet/mobilenet_v1_100_224/classification,https://tfhub.dev/google/imagenet/mobilenet_v1_100_224/classification/5?tf-hub-format=compressed,skip,119718 - Accuracy issue magenta/arbitrary-image-stylization-v1-256,https://tfhub.dev/google/magenta/arbitrary-image-stylization-v1-256/2?tf-hub-format=compressed small_bert/bert_en_uncased_L-4_H-256_A-4,https://tfhub.dev/tensorflow/small_bert/bert_en_uncased_L-4_H-256_A-4/2?tf-hub-format=compressed,skip,119718 - Accuracy issue +movinet/a5/base/kinetics-600/classification,https://tfhub.dev/tensorflow/movinet/a5/base/kinetics-600/classification/3?tf-hub-format=compressed # secure notebook models unet/industrial/class_1,https://tfhub.dev/nvidia/unet/industrial/class_1/1?tf-hub-format=compressed movenet/singlepose/thunder,https://tfhub.dev/google/movenet/singlepose/thunder/4?tf-hub-format=compressed From 6df420ed67c6978e76bf54679caafb29a17609e1 Mon Sep 17 00:00:00 2001 From: Artyom Anokhov Date: Mon, 18 Sep 2023 15:36:55 +0200 Subject: [PATCH 08/30] [Azure] Fix linux_debian.yml (#19911) * Update linux_debian.yml Fixed apt-get update * More fixes --------- Co-authored-by: Ilya Lavrenov --- .ci/azure/linux_debian.yml | 2 +- .github/workflows/linux_debian.yml | 2 +- cmake/packaging/debian.cmake | 1 + cmake/packaging/rpm.cmake | 1 + 4 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.ci/azure/linux_debian.yml b/.ci/azure/linux_debian.yml index 96db6129c72ee1..e94a0819705bd7 100644 --- a/.ci/azure/linux_debian.yml +++ b/.ci/azure/linux_debian.yml @@ -228,7 +228,7 @@ jobs: wget https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB sudo apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB echo "deb https://apt.repos.intel.com/openvino/2023 ubuntu20 main" | sudo tee /etc/apt/sources.list.d/intel-openvino-2023.list - sudo apt-get update -o Dir::Etc::sourcelist=/etc/apt/sources.list.d/intel-openvino-2023.list + sudo apt-get update sudo apt-get install openvino -y # install our local one and make sure the conflicts are resolved sudo apt-get install --no-install-recommends dpkg-dev -y diff --git a/.github/workflows/linux_debian.yml b/.github/workflows/linux_debian.yml index b517a368c46ced..bff429be48c90a 100644 --- a/.github/workflows/linux_debian.yml +++ b/.github/workflows/linux_debian.yml @@ -219,7 +219,7 @@ jobs: wget https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB sudo apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB echo "deb https://apt.repos.intel.com/openvino/2023 ubuntu20 main" | sudo tee /etc/apt/sources.list.d/intel-openvino-2023.list - sudo apt-get update -o Dir::Etc::sourcelist=/etc/apt/sources.list.d/intel-openvino-2023.list + sudo apt-get update sudo apt-get install openvino -y # install our local one and make sure the conflicts are resolved sudo apt-get install --no-install-recommends dpkg-dev -y diff --git a/cmake/packaging/debian.cmake b/cmake/packaging/debian.cmake index 48adc7acf3980a..d359a40aa6df51 100644 --- a/cmake/packaging/debian.cmake +++ b/cmake/packaging/debian.cmake @@ -91,6 +91,7 @@ macro(ov_cpack_settings) # - 2022.3 is the first release where Debian updated packages are introduced, others 2022.3.X are LTS 2022.3.0 2022.3.1 2022.3.2 2022.3.3 2022.3.4 2022.3.5 2023.0.0 2023.0.1 2023.0.2 2023.0.3 + 2023.1.0 ) # diff --git a/cmake/packaging/rpm.cmake b/cmake/packaging/rpm.cmake index ad1172b6c833ae..077e970d138bc4 100644 --- a/cmake/packaging/rpm.cmake +++ b/cmake/packaging/rpm.cmake @@ -77,6 +77,7 @@ macro(ov_cpack_settings) # - 2022.3 is the first release where RPM updated packages are introduced, others 2022.3.X are LTS 2022.3.0 2022.3.1 2022.3.2 2022.3.3 2022.3.4 2022.3.5 2023.0.0 2023.0.1 2023.0.2 2023.0.3 + 2023.1.0 ) find_host_program(rpmlint_PROGRAM NAMES rpmlint DOC "Path to rpmlint") From dbab89f04706c597c6a08ab68e91ae1ec2eaaeb2 Mon Sep 17 00:00:00 2001 From: Karol Blaszczak Date: Mon, 18 Sep 2023 16:24:26 +0200 Subject: [PATCH 09/30] [DOCS] minor post release tweaks (#19914) --- docs/Documentation/model_introduction.md | 39 +++++++++++++------ .../Convert_Model_From_PyTorch.md | 2 +- docs/documentation.md | 4 +- docs/home.rst | 4 +- .../installing-openvino-linux-header.md | 13 ++++--- .../installing-openvino-macos-header.md | 20 +++++----- .../installing-openvino-windows-header.md | 7 ++-- 7 files changed, 54 insertions(+), 35 deletions(-) diff --git a/docs/Documentation/model_introduction.md b/docs/Documentation/model_introduction.md index ad38d118a01922..cd24fccbec8dfe 100644 --- a/docs/Documentation/model_introduction.md +++ b/docs/Documentation/model_introduction.md @@ -15,18 +15,37 @@ openvino_docs_OV_Converter_UG_prepare_model_convert_model_Converting_Model -Every deep learning workflow begins with obtaining a model. You can choose to prepare a custom one, use a ready-made solution and adjust it to your needs, or even download and run a pre-trained network from an online database, such as `TensorFlow Hub `__, `Hugging Face `__, or `Torchvision models `__. - -OpenVINO™ :doc:`supports several model formats ` and can convert them into its own representation, `openvino.Model `__ (`ov.Model `__), providing a conversion API. Converted models can be used for inference with one or multiple OpenVINO Hardware plugins. There are two ways to use the conversion API: using a Python script or calling the ``ovc`` command line tool. +Every deep learning workflow begins with obtaining a model. You can choose to prepare +a custom one, use a ready-made solution and adjust it to your needs, or even download +and run a pre-trained network from an online database, such as +`TensorFlow Hub `__, `Hugging Face `__, +or `Torchvision models `__. + +If your selected model is in one of the :doc:`OpenVINO™ supported model formats `, +you can use it directly, without the need to save as the OpenVINO IR. +(`openvino.Model `__ - +`ov.Model `__). +For this purpose, you can use ``openvino.Core.read_model`` and ``openvino.Core.compile_model`` +methods, so that conversion is performed automatically before inference, for +maximum convenience (note that working with PyTorch differs slightly, the Python API +being the only option, while TensorFlow may present additional considerations +:doc:`TensorFlow Frontend Capabilities and Limitations `). + + +For better performance and more optimization options, OpenVINO offers a conversion +API with two possible approaches: the Python API functions (``openvino.convert_model`` +and ``openvino.save_model``) and the ``ovc`` command line tool, which are described in detail in this article. .. note:: - Prior to OpenVINO 2023.1, model conversion API was exposed as the ``openvino.tools.mo.convert_model`` - function and the ``mo`` command line tool. Now, a new and simplified API is used: the - ``openvino.convert_model`` function and the ``ovc`` command line tool. + Model conversion API prior to OpenVINO 2023.1 is considered deprecated. + Both existing and new projects are recommended to transition to the new + solutions, keeping in mind that they are not fully backwards compatible + with ``openvino.tools.mo.convert_model`` or the ``mo`` CLI tool. + For more details, see the :doc:`Model Conversion API Transition Guide `. + + - All new projects are recommended to use the new tools, keeping in mind that they are not fully - backwards compatible. For more details, consult the :doc:`Model Conversion API Transition Guide `. Convert a Model in Python: ``convert_model`` ############################################## @@ -209,12 +228,8 @@ Another option for model conversion is to use ``ovc`` command-line tool, which s The results of both ``ovc`` and ``openvino.convert_model``/``openvino.save_model`` conversion methods are the same. You can choose either of them based on your convenience. Note that there should not be any differences in the results of model conversion if the same set of parameters is used and the model is saved into OpenVINO IR. -Cases when Model Preparation is not Required -############################################ -If a model is represented as a single file from ONNX, PaddlePaddle, TensorFlow and TensorFlow Lite (check :doc:`TensorFlow Frontend Capabilities and Limitations `), it does not require a separate conversion and IR-saving step, that is ``openvino.convert_model`` and ``openvino.save_model``, or ``ovc``. -OpenVINO provides C++ and Python APIs for reading such models by just calling the ``openvino.Core.read_model`` or ``openvino.Core.compile_model`` methods. These methods perform conversion of the model from the original representation. While this conversion may take extra time compared to using prepared OpenVINO IR, it is convenient when you need to read a model in the original format in C++, since ``openvino.convert_model`` is only available in Python. However, for efficient model deployment with the OpenVINO Runtime, it is still recommended to prepare OpenVINO IR and then use it in your inference application. Additional Resources #################### diff --git a/docs/MO_DG/prepare_model/convert_model/Convert_Model_From_PyTorch.md b/docs/MO_DG/prepare_model/convert_model/Convert_Model_From_PyTorch.md index 055e94049a78ed..0cafd3066535ab 100644 --- a/docs/MO_DG/prepare_model/convert_model/Convert_Model_From_PyTorch.md +++ b/docs/MO_DG/prepare_model/convert_model/Convert_Model_From_PyTorch.md @@ -58,7 +58,7 @@ parameter to be set, for example: Sometimes ``convert_model`` will produce inputs of the model with dynamic rank or dynamic type. Such model may not be supported by the hardware chosen for inference. To avoid this issue, -use the ``input`` argument of ``convert_model``. For more information, refer to `Convert Models Represented as Python Objects `. +use the ``input`` argument of ``convert_model``. For more information, refer to :doc:`Convert Models Represented as Python Objects `. .. important:: diff --git a/docs/documentation.md b/docs/documentation.md index a25e784165b78f..276e4e6e0930a6 100644 --- a/docs/documentation.md +++ b/docs/documentation.md @@ -12,9 +12,9 @@ :hidden: API Reference - OpenVINO IR format and Operation Sets + OpenVINO IR format and Operation Sets + Legacy Features Tool Ecosystem - Legacy Features OpenVINO Extensibility Media Processing and CV Libraries OpenVINO™ Security diff --git a/docs/home.rst b/docs/home.rst index d8f359e65aaa5a..4ed32d3aea261b 100644 --- a/docs/home.rst +++ b/docs/home.rst @@ -24,10 +24,10 @@ OpenVINO 2023.0
  • An open-source toolkit for optimizing and deploying deep learning models.
    Boost your AI deep-learning inference performance!
  • -
  • Use PyTorch models directly, without converting them first. +
  • Use PyTorch models directly, without converting them first.
    Learn more...
  • -
  • OpenVINO via PyTorch 2.0 torch.compile()
    Use OpenVINO directly in PyTorch-native applications! +
  • OpenVINO via PyTorch 2.0 torch.compile()
    Use OpenVINO directly in PyTorch-native applications!
    Learn more...
  • Do you like Generative AI? You will love how it performs with OpenVINO!
    diff --git a/docs/install_guides/installing-openvino-linux-header.md b/docs/install_guides/installing-openvino-linux-header.md index f0bb87d87f0ade..a45b11d20e2f5e 100644 --- a/docs/install_guides/installing-openvino-linux-header.md +++ b/docs/install_guides/installing-openvino-linux-header.md @@ -22,14 +22,15 @@ Use Docker -If you want to install OpenVINO™ Runtime on your Linux machine, these are your options: +If you want to install OpenVINO™ Runtime on Linux, you have the following options: -* :doc:`Install OpenVINO Runtime using an Archive File ` +* :doc:`Install OpenVINO using an Archive File ` * :doc:`Install OpenVINO using PyPI ` -* :doc:`Install OpenVINO Runtime using APT ` -* :doc:`Install OpenVINO Runtime using YUM ` -* :doc:`Install OpenVINO Runtime using Conda Forge ` -* :doc:`Install OpenVINO Runtime using Homebrew ` +* :doc:`Install OpenVINO using APT ` +* :doc:`Install OpenVINO using YUM ` +* :doc:`Install OpenVINO using Conda Forge ` +* :doc:`Install OpenVINO using vcpkg ` +* :doc:`Install OpenVINO using Homebrew ` * :doc:`Install OpenVINO using Docker ` diff --git a/docs/install_guides/installing-openvino-macos-header.md b/docs/install_guides/installing-openvino-macos-header.md index dff827ce9a89e8..2e0d70b61d04be 100644 --- a/docs/install_guides/installing-openvino-macos-header.md +++ b/docs/install_guides/installing-openvino-macos-header.md @@ -12,19 +12,21 @@ :maxdepth: 3 :hidden: - From Archive - Using Homebrew - From PyPI - Using Conda Forge + Use Archive + Use Homebrew + Use PyPI + Use Conda Forge Use vcpkg -If you want to install OpenVINO™ Runtime on macOS, there are a few ways to accomplish this. We prepared following options for you: +If you want to install OpenVINO™ Runtime on macOS, you have the following options: -* :doc:`Install OpenVINO Runtime from an Archive File ` -* :doc:`Install OpenVINO from PyPI ` -* :doc:`Install OpenVINO Runtime using Conda Forge ` -* :doc:`Install OpenVINO Runtime via Homebrew ` + +* :doc:`Install OpenVINO using an Archive File ` +* :doc:`Install OpenVINO using PyPI ` +* :doc:`Install OpenVINO using Conda Forge ` +* :doc:`Install OpenVINO using Homebrew ` +* :doc:`Install OpenVINO using vcpkg ` diff --git a/docs/install_guides/installing-openvino-windows-header.md b/docs/install_guides/installing-openvino-windows-header.md index 3044c2accef729..65b1803ec711ff 100644 --- a/docs/install_guides/installing-openvino-windows-header.md +++ b/docs/install_guides/installing-openvino-windows-header.md @@ -22,9 +22,10 @@ If you want to install OpenVINO™ Runtime on Windows, you have the following options: -* :doc:`Install OpenVINO Runtime from an Archive File ` -* :doc:`Install OpenVINO Runtime using PyPI ` -* :doc:`Install OpenVINO Runtime using Conda Forge ` +* :doc:`Install OpenVINO using an Archive File ` +* :doc:`Install OpenVINO using PyPI ` +* :doc:`Install OpenVINO using Conda Forge ` +* :doc:`Install OpenVINO using vcpkg ` * :doc:`Install OpenVINO using Docker ` From c10b45fe9e1b22a42436c73a7ed64929f0f504ac Mon Sep 17 00:00:00 2001 From: Maxim Vafin Date: Mon, 18 Sep 2023 17:04:39 +0200 Subject: [PATCH 10/30] [PT FE] Fix issue with http error when using torch.hub (#19901) * [PT FE] Fix issue with http error when using torch.hub * Mark failing models as xfail * Remove incorrect model names --- .../models_hub_common/test_convert_model.py | 2 +- .../models_hub_common/utils.py | 2 +- .../torch_tests/test_torchvision_models.py | 21 ++-- .../torch_tests/torchvision_models | 97 +++++++++++++++++++ 4 files changed, 112 insertions(+), 10 deletions(-) create mode 100644 tests/model_hub_tests/torch_tests/torchvision_models diff --git a/tests/model_hub_tests/models_hub_common/test_convert_model.py b/tests/model_hub_tests/models_hub_common/test_convert_model.py index 145da6b61761f7..d35061595fc0cb 100644 --- a/tests/model_hub_tests/models_hub_common/test_convert_model.py +++ b/tests/model_hub_tests/models_hub_common/test_convert_model.py @@ -99,7 +99,7 @@ def _run(self, model_name, model_link, ie_device): fw_outputs = self.infer_fw_model(fw_model, inputs) print("Infer ov::Model") ov_outputs = self.infer_ov_model(ov_model, inputs, ie_device) - print("Compare TensorFlow and OpenVINO results") + print("Compare framework and OpenVINO results") self.compare_results(fw_outputs, ov_outputs) def run(self, model_name, model_link, ie_device): diff --git a/tests/model_hub_tests/models_hub_common/utils.py b/tests/model_hub_tests/models_hub_common/utils.py index b5699a80e62b43..076cd8e2f1e4c0 100644 --- a/tests/model_hub_tests/models_hub_common/utils.py +++ b/tests/model_hub_tests/models_hub_common/utils.py @@ -22,7 +22,7 @@ def get_models_list(file_name: str): model_name, model_link = model_info.split(',') elif len(model_info.split(',')) == 4: model_name, model_link, mark, reason = model_info.split(',') - assert mark == "skip", "Incorrect failure mark for model info {}".format(model_info) + assert mark in ["skip", "xfail"], "Incorrect failure mark for model info {}".format(model_info) models.append((model_name, model_link, mark, reason)) return models diff --git a/tests/model_hub_tests/torch_tests/test_torchvision_models.py b/tests/model_hub_tests/torch_tests/test_torchvision_models.py index a77af0ec07549e..a7722389e4132d 100644 --- a/tests/model_hub_tests/torch_tests/test_torchvision_models.py +++ b/tests/model_hub_tests/torch_tests/test_torchvision_models.py @@ -1,16 +1,18 @@ # Copyright (C) 2018-2023 Intel Corporation # SPDX-License-Identifier: Apache-2.0 +import os import pytest import torch import tempfile import torchvision.transforms.functional as F -from models_hub_common.test_convert_model import TestConvertModel from openvino import convert_model +from models_hub_common.test_convert_model import TestConvertModel +from models_hub_common.utils import get_models_list def get_all_models() -> list: - m_list = torch.hub.list("pytorch/vision") + m_list = torch.hub.list("pytorch/vision", skip_validation=True) m_list.remove("get_model_weights") m_list.remove("get_weight") return m_list @@ -36,7 +38,8 @@ def get_video(): def prepare_frames_for_raft(name, frames1, frames2): - w = torch.hub.load("pytorch/vision", "get_model_weights", name=name).DEFAULT + w = torch.hub.load("pytorch/vision", "get_model_weights", + name=name, skip_validation=True).DEFAULT img1_batch = torch.stack(frames1) img2_batch = torch.stack(frames2) img1_batch = F.resize(img1_batch, size=[520, 960], antialias=False) @@ -50,13 +53,14 @@ def prepare_frames_for_raft(name, frames1, frames2): class TestTorchHubConvertModel(TestConvertModel): - def setup_method(self): + def setup_class(self): self.cache_dir = tempfile.TemporaryDirectory() # set temp dir for torch cache torch.hub.set_dir(str(self.cache_dir.name)) def load_model(self, model_name, model_link): - m = torch.hub.load("pytorch/vision", model_name, weights='DEFAULT') + m = torch.hub.load("pytorch/vision", model_name, + weights='DEFAULT', skip_validation=True) m.eval() if model_name == "s3d" or any([m in model_name for m in ["swin3d", "r3d_18", "mc3_18", "r2plus1d_18"]]): self.example = (torch.randn([1, 3, 224, 224, 224]),) @@ -109,7 +113,8 @@ def teardown_method(self): def test_convert_model_precommit(self, model_name, ie_device): self.run(model_name, None, ie_device) - @pytest.mark.parametrize("model_name", get_all_models()) + @pytest.mark.parametrize("name", + [pytest.param(n, marks=pytest.mark.xfail) if m == "xfail" else n for n, _, m, r in get_models_list(os.path.join(os.path.dirname(__file__), "torchvision_models"))]) @pytest.mark.nightly - def test_convert_model_all_models(self, model_name, ie_device): - self.run(model_name, None, ie_device) + def test_convert_model_all_models(self, name, ie_device): + self.run(name, None, ie_device) diff --git a/tests/model_hub_tests/torch_tests/torchvision_models b/tests/model_hub_tests/torch_tests/torchvision_models new file mode 100644 index 00000000000000..a13a0f606c6708 --- /dev/null +++ b/tests/model_hub_tests/torch_tests/torchvision_models @@ -0,0 +1,97 @@ +alexnet,none +convnext_base,none +convnext_large,none +convnext_small,none +convnext_tiny,none +deeplabv3_mobilenet_v3_large,none +deeplabv3_resnet101,none +deeplabv3_resnet50,none +densenet121,none +densenet161,none +densenet169,none +densenet201,none +efficientnet_b0,none +efficientnet_b1,none +efficientnet_b2,none +efficientnet_b3,none +efficientnet_b4,none +efficientnet_b5,none +efficientnet_b6,none +efficientnet_b7,none +efficientnet_v2_l,none +efficientnet_v2_m,none +efficientnet_v2_s,none +fcn_resnet101,none +fcn_resnet50,none +googlenet,none +inception_v3,none +lraspp_mobilenet_v3_large,none +maxvit_t,none +mc3_18,none +mnasnet0_5,none +mnasnet0_75,none +mnasnet1_0,none +mnasnet1_3,none +mobilenet_v2,none +mobilenet_v3_large,none +mobilenet_v3_small,none +mvit_v1_b,none +mvit_v2_s,none +r2plus1d_18,none +r3d_18,none +raft_large,none +raft_small,none +regnet_x_16gf,none +regnet_x_1_6gf,none +regnet_x_32gf,none +regnet_x_3_2gf,none +regnet_x_400mf,none +regnet_x_800mf,none +regnet_x_8gf,none +regnet_y_128gf,none +regnet_y_16gf,none +regnet_y_1_6gf,none +regnet_y_32gf,none +regnet_y_3_2gf,none +regnet_y_400mf,none +regnet_y_800mf,none +regnet_y_8gf,none +resnet101,none +resnet152,none +resnet18,none +resnet34,none +resnet50,none +resnext101_32x8d,none +resnext101_64x4d,none +resnext50_32x4d,none +s3d,none +shufflenet_v2_x0_5,none +shufflenet_v2_x1_0,none +shufflenet_v2_x1_5,none +shufflenet_v2_x2_0,none +squeezenet1_0,none +squeezenet1_1,none +swin3d_b,none +swin3d_s,none +swin3d_t,none +swin_b,none +swin_s,none +swin_t,none +swin_v2_b,none +swin_v2_s,none +swin_v2_t,none +vgg11,none +vgg11_bn,none +vgg13,none +vgg13_bn,none +vgg16,none +vgg16_bn,none +vgg19,none +vgg19_bn,none +vit_b_16,none,xfail,Tracing fails +vit_b_32,none,xfail,Tracing fails +vit_h_14,none,xfail,Tracing fails +vit_l_16,none,xfail,Tracing fails +vit_l_32,none,xfail,Tracing fails +wide_resnet101_2,none +wide_resnet50_2,none From 10dc2d8b9ba8e6a311532906161fd710f8fef991 Mon Sep 17 00:00:00 2001 From: Mikhail Ryzhov Date: Mon, 18 Sep 2023 17:29:01 +0200 Subject: [PATCH 11/30] [GHA] Improvement of test execution time cache (#19881) * renamed cache * disabled PR cache * corrected save condition * removed id * fixed path in save cache action * corrected if condition --- .github/workflows/linux.yml | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 486cc879ec02d0..d7cba0bc390e59 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -585,7 +585,7 @@ jobs: --ignore=${{ env.INSTALL_TEST_DIR }}/pyopenvino/tests/test_utils/test_utils.py \ --ignore=${{ env.INSTALL_TEST_DIR }}/pyopenvino/tests/test_onnx/test_zoo_models.py \ --ignore=${{ env.INSTALL_TEST_DIR }}/pyopenvino/tests/test_onnx/test_backend.py - + - name: Python API snippets run: | source ${{ env.INSTALL_DIR }}/setupvars.sh @@ -774,12 +774,13 @@ jobs: python3 -m pip install --upgrade pip python3 -m pip install -r ${{ env.INSTALL_TEST_DIR }}/functional_test_utils/requirements.txt - - name: Cache Tests Execution Time - id: tests-functional-cpu-cache - uses: actions/cache@v3 + - name: Restore tests execution time + uses: actions/cache/restore@v3 with: path: ${{ env.PARALLEL_TEST_CACHE }} - key: ${{ runner.os }}-tests-functional-cpu-cache + key: ${{ runner.os }}-tests-functional-cpu-stamp-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-tests-functional-cpu-stamp - name: Intel CPU plugin func tests (parallel) run: | @@ -787,6 +788,13 @@ jobs: python3 ${{ env.PARALLEL_TEST_SCRIPT }} -e ${{ env.INSTALL_TEST_DIR }}/ov_cpu_func_tests -c ${{ env.PARALLEL_TEST_CACHE }} -w ${{ env.INSTALL_TEST_DIR }} -s suite -rf 0 -- --gtest_print_time=1 --gtest_filter=*smoke* timeout-minutes: 25 + - name: Save tests execution time + uses: actions/cache/save@v3 + if: github.ref_name == 'master' + with: + path: ${{ env.PARALLEL_TEST_CACHE }} + key: ${{ runner.os }}-tests-functional-cpu-stamp-${{ github.sha }} + - name: Upload Test Results uses: actions/upload-artifact@v3 if: ${{ always() }} From 54609e7b72d9faa5a38fe7ac15c84aae77fbbc82 Mon Sep 17 00:00:00 2001 From: Ilya Lavrenov Date: Tue, 19 Sep 2023 00:07:59 +0400 Subject: [PATCH 12/30] Removed FixRtInfo pass (#16870) * Removed FixRtInfo pass * Removed FixRtInfo pass * Fixed macOS compilation --- CMakeLists.txt | 2 - .../docs/develop_cc_for_new_component.md | 1 - src/common/snippets/src/pass/hash.cpp | 2 +- .../include/transformations/fix_rt_info.hpp | 38 ----------------- .../src/transformations/fix_rt_info.cpp | 42 ------------------- .../src/transformations/init_node_info.cpp | 5 +-- src/core/CMakeLists.txt | 1 - src/core/src/pass/serialize.cpp | 2 +- src/core/tests/CMakeLists.txt | 2 - src/inference/src/cnn_network_ngraph_impl.cpp | 8 ---- src/inference/src/compilation_context.cpp | 2 - .../tests/unit/compilation_context_test.cpp | 3 +- .../functional/test_utils/cpu_test_utils.cpp | 7 ++-- .../functional/test_utils/cpu_test_utils.hpp | 3 +- .../template/tests/functional/CMakeLists.txt | 4 +- .../src/summary/op_summary.cpp | 2 +- 16 files changed, 13 insertions(+), 111 deletions(-) delete mode 100644 src/common/transformations/include/transformations/fix_rt_info.hpp delete mode 100644 src/common/transformations/src/transformations/fix_rt_info.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 0b552b3da3406c..e9d4760eb86916 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -106,8 +106,6 @@ function(openvino_developer_export_targets) if(TARGET "${target_name}") get_target_property(original_name ${target_name} ALIASED_TARGET) if(TARGET "${original_name}") - message(STATUS "The name ${target_name} is an ALIAS for ${original_name}. " - "It will be exported to the OpenVINODeveloperPackage with the original name.") list(REMOVE_ITEM ${EXPORT_COMPONENT} ${target_name}) list(APPEND ${EXPORT_COMPONENT} ${original_name}) endif() diff --git a/src/common/conditional_compilation/docs/develop_cc_for_new_component.md b/src/common/conditional_compilation/docs/develop_cc_for_new_component.md index 4166a907434b13..32c10478dc6310 100644 --- a/src/common/conditional_compilation/docs/develop_cc_for_new_component.md +++ b/src/common/conditional_compilation/docs/develop_cc_for_new_component.md @@ -69,7 +69,6 @@ It checks whether the code region in this module is active or inactive by the ma There is an example of `conditional_compilation_gen.h`: ``` -#define ov_pass_FixRtInfo_run_on_function 1 #define ov_pass_GraphRewrite_run_on_model 1 #define ov_pass_InitNodeInfo_run_on_function 1 #define ov_pass_ConstantFolding_run_on_model 1 diff --git a/src/common/snippets/src/pass/hash.cpp b/src/common/snippets/src/pass/hash.cpp index 8d509b568867fc..48dd9586ae4337 100644 --- a/src/common/snippets/src/pass/hash.cpp +++ b/src/common/snippets/src/pass/hash.cpp @@ -62,7 +62,7 @@ static uint64_t hash_combine(uint64_t seed, const T &v) { namespace rt_info { // some node attr is not type of ov::RuntimeAttribute, need dedicate visitor. -const std::vector list_of_names{ +static const std::vector list_of_names{ "PrimitivesPriority", "alt_width", }; diff --git a/src/common/transformations/include/transformations/fix_rt_info.hpp b/src/common/transformations/include/transformations/fix_rt_info.hpp deleted file mode 100644 index a9c33645633074..00000000000000 --- a/src/common/transformations/include/transformations/fix_rt_info.hpp +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -/** - * @brief Defines initialize node runtime information pass - * @file init_node_info.hpp - */ - -#include -#include - -#include "openvino/pass/graph_rewrite.hpp" -#include "transformations_visibility.hpp" - -namespace ov { -namespace pass { - -class TRANSFORMATIONS_API FixRtInfo; - -} // namespace pass -} // namespace ov - -/** - * @ingroup ie_transformation_common_api - * @brief FixRtInfo transformation helps to fix info attributes in a single place. - * User can pass runtime attribute using various types. - * This Pass should generalize them runtime info representation. - * - * Used to extract runtime attributes from shared pointer to `ov::RuntimeAttributeWrapper` to standard or trivial types - */ -class ov::pass::FixRtInfo : public ov::pass::ModelPass { -public: - OPENVINO_RTTI("FixRtInfo", "0"); - bool run_on_model(const std::shared_ptr& m) override; -}; diff --git a/src/common/transformations/src/transformations/fix_rt_info.cpp b/src/common/transformations/src/transformations/fix_rt_info.cpp deleted file mode 100644 index b70176ca7aecd1..00000000000000 --- a/src/common/transformations/src/transformations/fix_rt_info.cpp +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "transformations/fix_rt_info.hpp" - -#include -#include - -#include "itt.hpp" -#include "openvino/core/rt_info.hpp" -#include "openvino/opsets/opset1.hpp" -#include "transformations/rt_info/primitives_priority_attribute.hpp" - -bool ov::pass::FixRtInfo::run_on_model(const std::shared_ptr& f) { - RUN_ON_FUNCTION_SCOPE(FixRtInfo); - - for (auto& node : f->get_ops()) { - // Recursively apply transformation for sub-graph based operations - if (auto sub_graph_node = std::dynamic_pointer_cast(node)) { - if (auto sub_graph = sub_graph_node->get_function()) { - run_on_model(sub_graph); - } - } - auto& rt_info = node->get_rt_info(); - { - auto it_info = rt_info.find("PrimitivesPriority"); - if (it_info != rt_info.end()) { - if (it_info->second.is()) { - rt_info.emplace(ov::PrimitivesPriority::get_type_info_static(), - it_info->second.as()); - } - if (it_info->second.is()) { - rt_info.emplace(ov::PrimitivesPriority::get_type_info_static(), - ov::PrimitivesPriority{it_info->second.as()}); - } - rt_info.erase(it_info); - } - } - } - return false; -} diff --git a/src/common/transformations/src/transformations/init_node_info.cpp b/src/common/transformations/src/transformations/init_node_info.cpp index 93c958d14f661b..efc2627199c723 100644 --- a/src/common/transformations/src/transformations/init_node_info.cpp +++ b/src/common/transformations/src/transformations/init_node_info.cpp @@ -8,9 +8,7 @@ #include #include "itt.hpp" -#include "openvino/core/rt_info.hpp" -#include "openvino/opsets/opset1.hpp" -#include "transformations/fix_rt_info.hpp" +#include "openvino/op/util/sub_graph_base.hpp" #include "transformations/rt_info/fused_names_attribute.hpp" #include "transformations/rt_info/primitives_priority_attribute.hpp" @@ -27,6 +25,5 @@ bool ov::pass::InitNodeInfo::run_on_model(const std::shared_ptr& f) { auto& rtInfo = node->get_rt_info(); rtInfo.emplace(FusedNames::get_type_info_static(), FusedNames{node->get_friendly_name()}); } - FixRtInfo{}.run_on_model(f); return false; } diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 4d8545a5a21802..03580613532e7b 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -122,7 +122,6 @@ file(GLOB_RECURSE smart_reshape_srcs ${CMAKE_CURRENT_SOURCE_DIR}/src/pass/smart_ file(GLOB_RECURSE rt_info_srcs ${CMAKE_CURRENT_SOURCE_DIR}/src/pass/rt_info/*.cpp) set_source_files_properties("${CMAKE_CURRENT_SOURCE_DIR}/src/pass/convert_precision.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/src/pass/convert_fp32_to_fp16.cpp" - "${CMAKE_CURRENT_SOURCE_DIR}/src/pass/fix_rt_info.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/src/pass/init_node_info.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/src/pass/serialize.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/src/op/type_relaxed.cpp" diff --git a/src/core/src/pass/serialize.cpp b/src/core/src/pass/serialize.cpp index de2fcd8c46b8fe..70b91b7e97bf81 100644 --- a/src/core/src/pass/serialize.cpp +++ b/src/core/src/pass/serialize.cpp @@ -197,7 +197,7 @@ void ngfunction_2_ir(pugi::xml_node& node, bool deterministic); namespace rt_info { -const std::vector list_of_names{ +static const std::vector list_of_names{ "PrimitivesPriority", "alt_width", }; diff --git a/src/core/tests/CMakeLists.txt b/src/core/tests/CMakeLists.txt index e42513bd939ebb..b5298b9e5eea3c 100644 --- a/src/core/tests/CMakeLists.txt +++ b/src/core/tests/CMakeLists.txt @@ -11,8 +11,6 @@ ov_try_use_gold_linker() add_definitions(-DSERIALIZED_ZOO=\"${TEST_MODEL_ZOO}/core/models\") -message(STATUS "OpenVINO Core unit tests enabled") - # For type relaxed types set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/threading.cpp PROPERTIES INCLUDE_DIRECTORIES $) diff --git a/src/inference/src/cnn_network_ngraph_impl.cpp b/src/inference/src/cnn_network_ngraph_impl.cpp index cb26e63e7c2626..74f80f39e2f641 100644 --- a/src/inference/src/cnn_network_ngraph_impl.cpp +++ b/src/inference/src/cnn_network_ngraph_impl.cpp @@ -29,7 +29,6 @@ #include "transformations/common_optimizations/nop_elimination.hpp" #include "transformations/common_optimizations/remove_concat_zero_dim_input.hpp" #include "transformations/common_optimizations/remove_multi_subgraph_op_dangling_params.hpp" -#include "transformations/fix_rt_info.hpp" #include "transformations/smart_reshape/set_batch_size.hpp" #include "transformations/smart_reshape/smart_reshape.hpp" #include "transformations/utils/utils.hpp" @@ -136,7 +135,6 @@ CNNNetworkNGraphImpl::CNNNetworkNGraphImpl(const std::shared_ptr& nGra { ov::pass::Manager m; using namespace ov::pass; - REGISTER_PASS(m, FixRtInfo) REGISTER_PASS(m, EliminateScatterUpdate) REGISTER_PASS(m, RemoveConcatZeroDimInput) REGISTER_PASS(m, RemoveMultiSubGraphOpDanglingParamsResults) @@ -199,12 +197,6 @@ CNNNetworkNGraphImpl::CNNNetworkNGraphImpl(const CNNNetwork& network) { } _ngraph_function = ngraph::clone_function(*network.getFunction()); - { - ov::pass::Manager m; - using namespace ov::pass; - REGISTER_PASS(m, FixRtInfo) - m.run_passes(_ngraph_function); - } validateFunctionNames(); InputsDataMap inputs = network.getInputsInfo(); OutputsDataMap outputs = network.getOutputsInfo(); diff --git a/src/inference/src/compilation_context.cpp b/src/inference/src/compilation_context.cpp index e4a373f1c0223b..7c0b9cfba869c6 100644 --- a/src/inference/src/compilation_context.cpp +++ b/src/inference/src/compilation_context.cpp @@ -18,7 +18,6 @@ #include "itt.hpp" #include "ngraph/opsets/opset6.hpp" #include "openvino/pass/manager.hpp" -#include "transformations/fix_rt_info.hpp" #include "transformations/hash.hpp" #include "transformations/rt_info/fused_names_attribute.hpp" #include "transformations/rt_info/primitives_priority_attribute.hpp" @@ -86,7 +85,6 @@ std::string ModelCache::compute_hash(const std::shared_ptr& mod uint64_t seed = 0; // 1. Calculate hash on function ov::pass::Manager m; - m.register_pass(); m.register_pass(seed); m.run_passes(std::const_pointer_cast(model)); diff --git a/src/inference/tests/unit/compilation_context_test.cpp b/src/inference/tests/unit/compilation_context_test.cpp index 1f3d5266729c61..2070f2302e29ef 100644 --- a/src/inference/tests/unit/compilation_context_test.cpp +++ b/src/inference/tests/unit/compilation_context_test.cpp @@ -189,8 +189,7 @@ TEST(NetworkContext, HashWithPrimitivesPriority) { op3["PrimitivesPriority"] = "testPriority"; ASSERT_NE(ModelCache::compute_hash(net1, {}), ModelCache::compute_hash(net2, {})); - - ASSERT_EQ(ModelCache::compute_hash(net2, {}), ModelCache::compute_hash(net3, {})); + ASSERT_NE(ModelCache::compute_hash(net2, {}), ModelCache::compute_hash(net3, {})); } TEST(NetworkContext, HashWithFusedNames) { diff --git a/src/plugins/intel_cpu/tests/functional/test_utils/cpu_test_utils.cpp b/src/plugins/intel_cpu/tests/functional/test_utils/cpu_test_utils.cpp index e76d6caf9bdd33..e355ee79b75bcc 100644 --- a/src/plugins/intel_cpu/tests/functional/test_utils/cpu_test_utils.cpp +++ b/src/plugins/intel_cpu/tests/functional/test_utils/cpu_test_utils.cpp @@ -6,6 +6,7 @@ #include "ie_ngraph_utils.hpp" #include "openvino/core/type/element_type.hpp" #include "utils/rt_info/memory_formats_attribute.hpp" +#include "transformations/rt_info/primitives_priority_attribute.hpp" #include "utils/general_utils.h" #include @@ -101,7 +102,7 @@ std::string CPUTestsBase::fmts2str(const std::vector &fmts, return str; } -std::string CPUTestsBase::impls2str(const std::vector &priority) { +ov::PrimitivesPriority CPUTestsBase::impls2primProiority(const std::vector &priority) { std::string str; for (auto &impl : priority) { ((str += "cpu:") += impl) += ","; @@ -109,7 +110,7 @@ std::string CPUTestsBase::impls2str(const std::vector &priority) { if (!str.empty()) { str.pop_back(); } - return str; + return ov::PrimitivesPriority(str); } void CPUTestsBase::CheckPluginRelatedResults(InferenceEngine::ExecutableNetwork &execNet, const std::set& nodeType) const { @@ -321,7 +322,7 @@ CPUTestsBase::makeCPUInfo(const std::vector& inFmts, ov::intel_cpu::OutputMemoryFormats(fmts2str(outFmts, "cpu:"))}); } if (!priority.empty()) { - cpuInfo.insert({"PrimitivesPriority", impls2str(priority)}); + cpuInfo.emplace(ov::PrimitivesPriority::get_type_info_static(), impls2primProiority(priority)); } cpuInfo.insert({"enforceBF16evenForGraphTail", true}); diff --git a/src/plugins/intel_cpu/tests/functional/test_utils/cpu_test_utils.hpp b/src/plugins/intel_cpu/tests/functional/test_utils/cpu_test_utils.hpp index b1e77e48fe70d4..d8deddfebe5d69 100644 --- a/src/plugins/intel_cpu/tests/functional/test_utils/cpu_test_utils.hpp +++ b/src/plugins/intel_cpu/tests/functional/test_utils/cpu_test_utils.hpp @@ -7,6 +7,7 @@ #include #include "ie_system_conf.h" #include "shared_test_classes/base/layer_test_utils.hpp" +#include "transformations/rt_info/primitives_priority_attribute.hpp" #include #include #include "ie_system_conf.h" @@ -122,7 +123,7 @@ class CPUTestsBase { static const char *cpu_fmt2str(cpu_memory_format_t v); static cpu_memory_format_t cpu_str2fmt(const char *str); static std::string fmts2str(const std::vector &fmts, const std::string &prefix); - static std::string impls2str(const std::vector &priority); + static ov::PrimitivesPriority impls2primProiority(const std::vector &priority); static CPUInfo makeCPUInfo(const std::vector& inFmts, const std::vector& outFmts, const std::vector& priority); diff --git a/src/plugins/template/tests/functional/CMakeLists.txt b/src/plugins/template/tests/functional/CMakeLists.txt index a4ba476c4c2200..983ee2534a497c 100644 --- a/src/plugins/template/tests/functional/CMakeLists.txt +++ b/src/plugins/template/tests/functional/CMakeLists.txt @@ -28,11 +28,11 @@ ov_add_test_target( find_package(OpenCV QUIET COMPONENTS core imgproc) if(OpenCV_FOUND AND OpenCV_VERSION VERSION_GREATER_EQUAL 3.4) - message("-- Reference preprocessing: OpenCV tests are enabled") + message(STATUS "Reference preprocessing: OpenCV tests are enabled") target_compile_definitions(${TARGET_NAME} PRIVATE OPENCV_TEMPLATE_TESTS) target_link_libraries(${TARGET_NAME} PRIVATE opencv_imgproc opencv_core) else() - message("-- Reference preprocessing: OpenCV tests are disabled, because OpenCV ver. 3.4+ is not found") + message(WARNING "Reference preprocessing: OpenCV tests are disabled, because OpenCV ver. 3.4+ is not found") endif() if (ENABLE_INTEL_CPU) diff --git a/src/tests/test_utils/functional_test_utils/src/summary/op_summary.cpp b/src/tests/test_utils/functional_test_utils/src/summary/op_summary.cpp index 626cce43c2048d..08a0d9c0a2486e 100644 --- a/src/tests/test_utils/functional_test_utils/src/summary/op_summary.cpp +++ b/src/tests/test_utils/functional_test_utils/src/summary/op_summary.cpp @@ -140,7 +140,7 @@ void OpSummary::updateOPsStats(const std::shared_ptr& model, const Pa return; } bool isFunctionalGraph = false; - for (const auto &op : model->get_ordered_ops()) { + for (const auto& op : model->get_ordered_ops()) { if (!std::dynamic_pointer_cast(op) && !std::dynamic_pointer_cast(op) && !std::dynamic_pointer_cast(op)) { From c7850276ddc55784b5a785cef687289508c07d0c Mon Sep 17 00:00:00 2001 From: Ilya Lavrenov Date: Tue, 19 Sep 2023 00:11:05 +0400 Subject: [PATCH 13/30] Check only build requirements for Python API (#19919) --- src/bindings/python/CMakeLists.txt | 31 +++++++++++------------------- 1 file changed, 11 insertions(+), 20 deletions(-) diff --git a/src/bindings/python/CMakeLists.txt b/src/bindings/python/CMakeLists.txt index 4c4c9bce4d7804..24089b38531c27 100644 --- a/src/bindings/python/CMakeLists.txt +++ b/src/bindings/python/CMakeLists.txt @@ -20,8 +20,7 @@ endif() # Check python requirements # -set(ov_python_req "${OpenVINOPython_SOURCE_DIR}/requirements.txt") -set(ie_python_req "${OpenVINOPython_SOURCE_DIR}/src/compatibility/openvino/requirements-dev.txt") +set(ie_build_python_req "${OpenVINOPython_SOURCE_DIR}/src/compatibility/openvino/requirements-dev.txt") function(ov_check_python_build_conditions) # user explicitly specified ENABLE_PYTHON=ON @@ -81,31 +80,23 @@ function(ov_check_python_build_conditions) message(${message_mode} "Python 3.x interpreter is not found. OpenVINO Python API will be turned off (ENABLE_PYTHON is OFF)") endif() - # check pyopenvino requirements to OV 2.0 API - ov_check_pip_packages(REQUIREMENTS_FILE ${ov_python_req} - RESULT_VAR ov_python_req_FOUND - WARNING_MESSAGE "install python3 -m pip install -r ${ov_python_req} for OV API 2.0 requirements" - MESSAGE_MODE TRACE) - # ov_python_req are not mandatory for build - set(ov_python_req_FOUND ON) - # check for Cython requirement for build IE API 1.0 - ov_check_pip_packages(REQUIREMENTS_FILE ${ie_python_req} - RESULT_VAR ie_python_req_FOUND - WARNING_MESSAGE "install python3 -m pip install -r ${ie_python_req} for IE API 1.0 requirements" + ov_check_pip_packages(REQUIREMENTS_FILE ${ie_build_python_req} + RESULT_VAR ie_build_python_req_FOUND + WARNING_MESSAGE "install python3 -m pip install -r ${ie_build_python_req} for IE API 1.0 requirements" MESSAGE_MODE TRACE) # cython can be installed as a debian package, so pip requirements can be unsatisfied # so, let's check to find cython anyway - if(NOT ie_python_req_FOUND) + if(NOT ie_build_python_req_FOUND) find_package(Cython QUIET PATHS "${OpenVINOPython_SOURCE_DIR}/src/compatibility/openvino/cmake" NO_CMAKE_FIND_ROOT_PATH NO_DEFAULT_PATH) if(CYTHON_VERSION VERSION_GREATER_EQUAL 0.29) - set(ie_python_req_FOUND ON) + set(ie_build_python_req_FOUND ON) else() - message(${message_mode} "Python requirements '${ie_python_req}' are missed, IE Python API 1.0 will not be built (ENABLE_PYTHON is OFF)") + message(${message_mode} "Python requirements '${ie_build_python_req}' are missed, IE Python API 1.0 will not be built (ENABLE_PYTHON is OFF)") endif() endif() @@ -116,14 +107,14 @@ function(ov_check_python_build_conditions) set(python_debug OFF) endif() - if(PYTHONLIBS_FOUND AND ov_python_req_FOUND AND ie_python_req_FOUND AND NOT python_debug) + if(PYTHONLIBS_FOUND AND ie_build_python_req_FOUND AND NOT python_debug) set(ENABLE_PYTHON_DEFAULT ON PARENT_SCOPE) else() set(ENABLE_PYTHON_DEFAULT OFF PARENT_SCOPE) endif() # to disable API 1.0 - set(ie_python_req_FOUND ${ie_python_req_FOUND} PARENT_SCOPE) + set(ie_build_python_req_FOUND ${ie_build_python_req_FOUND} PARENT_SCOPE) # set pybind11 minimal version set(pybind11_min_version ${pybind11_min_version} PARENT_SCOPE) endfunction() @@ -178,7 +169,7 @@ ie_dependent_option(ENABLE_WHEEL "Build wheel packages for PyPI" ${ENABLE_WHEEL_ if(NOT ENABLE_PYTHON) if(CMAKE_SOURCE_DIR STREQUAL OpenVINOPython_SOURCE_DIR) - message(FATAL_ERROR "Python OpenVINO API requirements are not satisfied. Please, install ${ie_python_req} and ${ov_python_req}") + message(FATAL_ERROR "Python OpenVINO API requirements are not satisfied. Please, install ${ie_build_python_req}") else() return() endif() @@ -201,7 +192,7 @@ endif() add_subdirectory(src/compatibility/pyngraph) add_subdirectory(src/pyopenvino) -if(ie_python_req_FOUND) +if(ie_build_python_req_FOUND) add_subdirectory(src/compatibility/openvino) else() message(WARNING "NOTE: Python API for OpenVINO 1.0 is disabled") From 6556d07c321476618ea4e88a98588f7df349aaca Mon Sep 17 00:00:00 2001 From: Roman Kazantsev Date: Tue, 19 Sep 2023 00:25:44 +0400 Subject: [PATCH 14/30] [TF FE][Tests] Fix sporadic failure in CTCLoss test (#19920) --- tests/layer_tests/tensorflow_tests/test_tf_CTCLoss.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/layer_tests/tensorflow_tests/test_tf_CTCLoss.py b/tests/layer_tests/tensorflow_tests/test_tf_CTCLoss.py index 5a9b024f509ae6..78289a7144ba7a 100644 --- a/tests/layer_tests/tensorflow_tests/test_tf_CTCLoss.py +++ b/tests/layer_tests/tensorflow_tests/test_tf_CTCLoss.py @@ -58,4 +58,4 @@ def test_ctcloss_placeholder_const(self, params, ie_device, precision, ir_versio use_new_frontend, use_old_api): self._test(*self.create_ctcloss_placeholder_const_net(**params), ie_device, precision, ir_version, temp_dir=temp_dir, - use_new_frontend=use_new_frontend, use_old_api=use_old_api, custom_eps=1e-3) + use_new_frontend=use_new_frontend, use_old_api=use_old_api, custom_eps=1e-2) From e34c5a09c6ccd42dacc360dd780496107d537bf8 Mon Sep 17 00:00:00 2001 From: Przemyslaw Wysocki Date: Mon, 18 Sep 2023 22:36:13 +0200 Subject: [PATCH 15/30] [PyOV] Add an `__init__.py` alignment check in CMake (#19882) * Add init check * Apply CR --- src/bindings/python/CMakeLists.txt | 31 +++++++++++++++++ .../src/compatibility/openvino/__init__.py | 2 +- tools/openvino_dev/CMakeLists.txt | 33 +++++++++++++++++++ 3 files changed, 65 insertions(+), 1 deletion(-) diff --git a/src/bindings/python/CMakeLists.txt b/src/bindings/python/CMakeLists.txt index 24089b38531c27..a273184c4b8d1d 100644 --- a/src/bindings/python/CMakeLists.txt +++ b/src/bindings/python/CMakeLists.txt @@ -121,6 +121,37 @@ endfunction() ov_check_python_build_conditions() +# check __init__.py files alignment + +function(ov_check_init_files_alignment) + # check the files in pairs + list(APPEND init_files + "${OpenVINOPython_SOURCE_DIR}/src/openvino/__init__.py" + "${OpenVINOPython_SOURCE_DIR}/src/compatibility/openvino/__init__.py" + "${OpenVINO_SOURCE_DIR}/tools/mo/openvino/__init__.py" + "${OpenVINO_SOURCE_DIR}/tools/pot/openvino/__init__.py" + "${OpenVINO_SOURCE_DIR}/tools/ovc/openvino/__init__.py" + "${OpenVINO_SOURCE_DIR}/tools/benchmark_tool/openvino/__init__.py" + "${OpenVINO_SOURCE_DIR}/tools/openvino_dev/src/openvino/__init__.py") + + list(LENGTH init_files init_files_count) + math(EXPR file_loop_range "${init_files_count}-2") + foreach(init_file_idx RANGE 0 ${file_loop_range}) + math(EXPR init_file_idx_next "${init_file_idx}+1") + list(GET init_files ${init_file_idx} file1) + list(GET init_files ${init_file_idx_next} file2) + + execute_process(COMMAND ${CMAKE_COMMAND} -E compare_files ${file1} ${file2} + RESULT_VARIABLE compare_result + ) + if(compare_result EQUAL 1) + message(FATAL_ERROR "The __init__.py files are misaligned: ${file1} and ${file2}") + endif() + endforeach() +endfunction() + +ov_check_init_files_alignment() + ie_option(ENABLE_PYTHON "Enables OpenVINO Python API build" ${ENABLE_PYTHON_DEFAULT}) # diff --git a/src/bindings/python/src/compatibility/openvino/__init__.py b/src/bindings/python/src/compatibility/openvino/__init__.py index 8f0113d5bcaf6c..90552e0befed68 100644 --- a/src/bindings/python/src/compatibility/openvino/__init__.py +++ b/src/bindings/python/src/compatibility/openvino/__init__.py @@ -57,6 +57,6 @@ # Tools try: # Model Conversion API - ovc should reside in the main namespace - from openvino.tools.ovc import convert_model, InputCutInfo + from openvino.tools.ovc import convert_model except ImportError: pass diff --git a/tools/openvino_dev/CMakeLists.txt b/tools/openvino_dev/CMakeLists.txt index 2d2066d660dca3..42ad4031d69955 100644 --- a/tools/openvino_dev/CMakeLists.txt +++ b/tools/openvino_dev/CMakeLists.txt @@ -54,6 +54,39 @@ foreach(EXTRAS IN LISTS EXTRAS_LIST) ${OV_CPACK_COMP_OPENVINO_DEV_REQ_FILES_EXCLUDE_ALL}) endforeach() +# check __init__.py files alignment + +function(ov_check_init_files_alignment) + # check the files in pairs + list(APPEND init_files + "${OpenVINO_SOURCE_DIR}/src/bindings/python/src/openvino/__init__.py" + "${OpenVINO_SOURCE_DIR}/src/bindings/python/src/compatibility/openvino/__init__.py" + "${OpenVINO_SOURCE_DIR}/tools/mo/openvino/__init__.py" + "${OpenVINO_SOURCE_DIR}/tools/pot/openvino/__init__.py" + "${OpenVINO_SOURCE_DIR}/tools/ovc/openvino/__init__.py" + "${OpenVINO_SOURCE_DIR}/tools/benchmark_tool/openvino/__init__.py" + "${OpenVINO_SOURCE_DIR}/tools/openvino_dev/src/openvino/__init__.py") + + list(LENGTH init_files init_files_count) + math(EXPR file_loop_range "${init_files_count}-2") + foreach(init_file_idx RANGE 0 ${file_loop_range}) + math(EXPR init_file_idx_next "${init_file_idx}+1") + list(GET init_files ${init_file_idx} file1) + list(GET init_files ${init_file_idx_next} file2) + + execute_process(COMMAND ${CMAKE_COMMAND} -E compare_files ${file1} ${file2} + RESULT_VARIABLE compare_result + ) + if(compare_result EQUAL 1) + message(STATUS ${file1}) + message(STATUS ${file2}) + message(FATAL_ERROR "The __init__.py files are misaligned: ${file1} and ${file2}") + endif() + endforeach() +endfunction() + +ov_check_init_files_alignment() + # openvino_dev build if(NOT ENABLE_WHEEL) From 03918c2cac9ace8a78d963dd1191b1318a8b3f14 Mon Sep 17 00:00:00 2001 From: Paul Youngsoo Ahn Date: Tue, 19 Sep 2023 06:13:38 +0900 Subject: [PATCH 16/30] bug fix update (#19568) * [GPU] Fix gpu functional test failures * set m_max_batch to 1 * add debug log for condition operation * Add debug logs for condition and constant * To fix zero byte allocation issue, Convert zero dimension to 1 dimension in constant * Add the code to check if output shape is dynamic in split offset calculation and checking allow_new_shape_infer in program_builder * Add unit test for fix checking output shape * Add test case for zero dimennsion allocation and debug message * Fix build failure for condition unit test * Follow up code review --- .../intel_gpu/primitives/condition.hpp | 10 +-- .../src/graph/impls/common/condition.cpp | 3 + src/plugins/intel_gpu/src/graph/network.cpp | 15 +++- .../intel_gpu/src/plugin/ops/condition.cpp | 7 ++ .../intel_gpu/src/plugin/ops/constant.cpp | 8 +- .../intel_gpu/src/plugin/ops/split.cpp | 23 ++++- .../intel_gpu/src/plugin/program_builder.cpp | 8 ++ .../single_layer_tests/dynamic/shapeof.cpp | 85 +++++++++++++++++++ .../single_layer_tests/dynamic/split.cpp | 16 ++++ .../functional/subgraph_tests/condition.cpp | 82 ++++++++++++++++-- 10 files changed, 240 insertions(+), 17 deletions(-) diff --git a/src/plugins/intel_gpu/include/intel_gpu/primitives/condition.hpp b/src/plugins/intel_gpu/include/intel_gpu/primitives/condition.hpp index 664b240cba8a8a..5ad37c7dfa55bf 100644 --- a/src/plugins/intel_gpu/include/intel_gpu/primitives/condition.hpp +++ b/src/plugins/intel_gpu/include/intel_gpu/primitives/condition.hpp @@ -26,19 +26,17 @@ struct condition : public primitive_base { std::string str() { std::stringstream ss; - ss << "branch: { " << std::endl; - ss<< "* input_map : [(outer_id,inner_id),"; + ss << "branch: {input_map : [(outer_id,inner_id),"; for (auto& in_iter : input_map) { ss << "(" << in_iter.first << "," << in_iter.second << "),"; } - ss << "]," << std::endl; + ss << "],"; - ss << "* output_map : [(outer_idx,inner_id),"; + ss << " output_map : [(outer_idx,inner_id),"; for (auto& out_iter : output_map) { ss << "(" << out_iter.first << ","<< out_iter.second << "),"; } - ss << "]" << std::endl; - ss << "}" << std::endl; + ss << "]}"; return ss.str(); } }; diff --git a/src/plugins/intel_gpu/src/graph/impls/common/condition.cpp b/src/plugins/intel_gpu/src/graph/impls/common/condition.cpp index 4a1a8b414f0b0a..fbcdf6b277645b 100644 --- a/src/plugins/intel_gpu/src/graph/impls/common/condition.cpp +++ b/src/plugins/intel_gpu/src/graph/impls/common/condition.cpp @@ -39,6 +39,7 @@ struct condition_impl : typed_primitive_impl { auto pred = condition_inst::get_pred_from_memory(instance.pred_memory_ptr(), instance.get_network().get_stream()); network::ptr executed_net = pred? instance.get_net_true() : instance.get_net_false(); auto branch = pred? instance.get_branch_true() : instance.get_branch_false(); + GPU_DEBUG_LOG << "predicate: " << (pred ? "True" : "False") << std::endl; // Set input memory of inner network before its execution for (size_t mem_idx = 0; mem_idx < instance.inputs_memory_count(); mem_idx++) { @@ -48,6 +49,7 @@ struct condition_impl : typed_primitive_impl { const primitive_id& input_internal_id = iter->second; auto mem_ptr = instance.input_memory_ptr(mem_idx); executed_net->set_input_data(input_internal_id, mem_ptr); + GPU_DEBUG_LOG << "Inner net - Inputs[" << mem_idx << "]" << mem_ptr->get_layout().to_short_string() << std::endl; } } @@ -62,6 +64,7 @@ struct condition_impl : typed_primitive_impl { auto inner_out_id = out_mem_map.second; auto mem_ptr = executed_net->get_output(inner_out_id).get_memory(); instance.set_output_memory(mem_ptr, false, out_mem_idx); + GPU_DEBUG_LOG << "Inner net - Outputs[" << out_mem_idx << "]" << mem_ptr->get_layout().to_short_string() << std::endl; } ev->set(); diff --git a/src/plugins/intel_gpu/src/graph/network.cpp b/src/plugins/intel_gpu/src/graph/network.cpp index eb971ae9410e5f..ea2225b48844d1 100644 --- a/src/plugins/intel_gpu/src/graph/network.cpp +++ b/src/plugins/intel_gpu/src/graph/network.cpp @@ -1234,9 +1234,18 @@ void network::execute_impl(const std::vector& events) { GPU_DEBUG_COUT << inst->id() << std::endl; if (inst->get_node().is_type()) { auto& loop_node = inst->get_node().as(); - auto loop_body_primitives = loop_node.get_body_topology().get_primitives_ids(); - for (auto& primitive_id : loop_body_primitives) { - GPU_DEBUG_COUT << "\t" << primitive_id << std::endl; + for (auto& prim : loop_node.get_body_program()->get_processing_order()) { + GPU_DEBUG_COUT << "\t" << prim->id() << std::endl; + } + } else if (inst->get_node().is_type()) { + auto& cond_node = inst->get_node().as(); + GPU_DEBUG_COUT << "* Branch_True" << std::endl; + for (auto& prim : cond_node.get_branch_true().inner_program->get_processing_order()) { + GPU_DEBUG_COUT << "\t" << prim->id() << std::endl; + } + GPU_DEBUG_COUT << "* Branch_False" << std::endl; + for (auto& prim : cond_node.get_branch_false().inner_program->get_processing_order()) { + GPU_DEBUG_COUT << "\t" << prim->id() << std::endl; } } } diff --git a/src/plugins/intel_gpu/src/plugin/ops/condition.cpp b/src/plugins/intel_gpu/src/plugin/ops/condition.cpp index fde2e65d62c474..d9b4e77314e600 100644 --- a/src/plugins/intel_gpu/src/plugin/ops/condition.cpp +++ b/src/plugins/intel_gpu/src/plugin/ops/condition.cpp @@ -14,6 +14,12 @@ const size_t idx_false = 1; static cldnn::condition::branch gen_branch(ProgramBuilder& p, const std::shared_ptr& op, size_t idx) { cldnn::condition::branch branch; const auto& internal_body = (idx == idx_true)? op->get_then_body() : op->get_else_body(); + GPU_DEBUG_LOG << "Generate inner program for " << "op::v" + << op->get_type_info().version_id << "::" + << op->get_type_name() << " operation " + << "(friendly_name=" << op->get_friendly_name() << ") : " + << internal_body->get_friendly_name() + << ", num inputs: " << op->get_input_size() << std::endl; auto config = p.get_config(); config.set_property(ov::intel_gpu::max_dynamic_batch(1)); @@ -40,6 +46,7 @@ static cldnn::condition::branch gen_branch(ProgramBuilder& p, const std::shared_ output_map.insert({out_desc->m_output_index, internal_id}); } + GPU_DEBUG_LOG << op->get_friendly_name() << " branch_info[" << internal_body->get_friendly_name() << "] : " << branch << std::endl; return branch; } diff --git a/src/plugins/intel_gpu/src/plugin/ops/constant.cpp b/src/plugins/intel_gpu/src/plugin/ops/constant.cpp index 664098477e82aa..10eaa80327ff9c 100644 --- a/src/plugins/intel_gpu/src/plugin/ops/constant.cpp +++ b/src/plugins/intel_gpu/src/plugin/ops/constant.cpp @@ -97,8 +97,14 @@ static void create_data(ProgramBuilder& p, const ov::Shape& constDims, const std p.primitive_ids[initialconstPrimID] = constPrimID; p.profiling_ids.push_back(initialconstPrimID); } else { - GPU_DEBUG_LOG << "[" << initialconstPrimID << ": constant]" << std::endl; + if (constLayout.count() == 0) { + // Convert zero dimension constant layout to 1 dimension to fix the issue + // that memory allocation is failed on windows when constant layout is zero dimension. + constLayout = cldnn::layout(ov::PartialShape({1}), constLayout.data_type, constLayout.format); + } cldnn::memory::ptr mem = p.get_engine().allocate_memory(constLayout, false); + GPU_DEBUG_LOG << "[" << initialconstPrimID << ": constant] layout: " + << constLayout.to_short_string() << ", mem_ptr(" << mem << ", " << mem->size() << " bytes)"<< std::endl; auto& stream = p.get_engine().get_service_stream(); cldnn::mem_lock lock{mem, stream}; auto buf = lock.data(); diff --git a/src/plugins/intel_gpu/src/plugin/ops/split.cpp b/src/plugins/intel_gpu/src/plugin/ops/split.cpp index be35125f1b4689..be7d2dad4b0942 100644 --- a/src/plugins/intel_gpu/src/plugin/ops/split.cpp +++ b/src/plugins/intel_gpu/src/plugin/ops/split.cpp @@ -13,6 +13,21 @@ namespace ov { namespace intel_gpu { +static bool IsDynamic(const std::shared_ptr& op) { + if (op->is_dynamic()) { + return true; + } + + for (size_t i = 0; i < op->get_output_size(); i++) { + const auto outPartialShape = op->get_output_partial_shape(i); + if (outPartialShape.is_dynamic()) { + return true; + } + } + + return false; +} + static void CreateCommonSplitOp(ProgramBuilder& p, const std::shared_ptr& op) { auto get_layer_name = [&](size_t idx)->std::string { return layer_type_name_ID(op) + ((op->get_output_size() == 1)? "" : ".out" + std::to_string(idx)); @@ -22,11 +37,15 @@ static void CreateCommonSplitOp(ProgramBuilder& p, const std::shared_ptris_dynamic()) { std::vector offsets; - if (!op->is_dynamic()) { + // op->is_dynamic() does not check if output shape is dynamic. it only check dynamism for input shapes + // Even if op->is_dynamic() is false, output shape can be dynamic. + // Thus, it is necessary to check if output shape is dynamic. + if (!IsDynamic(op)) { auto input_pshape = op->get_input_partial_shape(0); ov::Shape start_offset(input_pshape.size()); for (size_t i = 0; i < op->get_output_size(); i++) { const auto outPartialShape = op->get_output_partial_shape(i); + auto offsetTensor = tensor_from_dims(start_offset, 0); offsets.push_back(offsetTensor); @@ -49,7 +68,7 @@ static void CreateCommonSplitOp(ProgramBuilder& p, const std::shared_ptris_dynamic() ? cldnn::tensor(0) : offsets[i]), + (offsets.empty() ? cldnn::tensor(0) : offsets[i]), op_mode, static_cast(i), num_splits); diff --git a/src/plugins/intel_gpu/src/plugin/program_builder.cpp b/src/plugins/intel_gpu/src/plugin/program_builder.cpp index 231ee37252a2a5..404818ce92ce8c 100644 --- a/src/plugins/intel_gpu/src/plugin/program_builder.cpp +++ b/src/plugins/intel_gpu/src/plugin/program_builder.cpp @@ -314,6 +314,14 @@ bool ProgramBuilder::requires_new_shape_infer(const ov::Node& op) const { return true; } + // When input node has dynamic shape with 4 dimension, this function return false + // because op.is_dynamic() which only checks input shapes return false. + // So, in the case of input data, we need to check output shape. + for (size_t i = 0; i < op.get_output_size(); i++) { + if (op.get_output_partial_shape(i).is_dynamic()) + return true; + } + if (ov::is_type(&op)) return true; diff --git a/src/plugins/intel_gpu/tests/functional/single_layer_tests/dynamic/shapeof.cpp b/src/plugins/intel_gpu/tests/functional/single_layer_tests/dynamic/shapeof.cpp index 7f4f6d6689e79f..f9244790e9fc7a 100644 --- a/src/plugins/intel_gpu/tests/functional/single_layer_tests/dynamic/shapeof.cpp +++ b/src/plugins/intel_gpu/tests/functional/single_layer_tests/dynamic/shapeof.cpp @@ -215,4 +215,89 @@ INSTANTIATE_TEST_SUITE_P(smoke_ShapeOf_5d_compareWithRefs_static, } // namespace +using ShapeOfParams = typename std::tuple< + InputShape, // Shape + InferenceEngine::Precision, // Precision + LayerTestsUtils::TargetDevice // Device name +>; + +class ShapeOfDynamicInputGPUTest : public testing::WithParamInterface, + virtual public SubgraphBaseTest { +public: + static std::string getTestCaseName(const testing::TestParamInfo& obj) { + InputShape inputShapes; + InferenceEngine::Precision dataPrc; + std::string targetDevice; + + std::tie(inputShapes, dataPrc, targetDevice) = obj.param; + std::ostringstream result; + result << "IS=("; + result << ov::test::utils::partialShape2str({inputShapes.first}) << "_"; + for (size_t i = 0lu; i < inputShapes.second.size(); i++) { + result << "{"; + result << ov::test::utils::vec2str(inputShapes.second[i]) << "_"; + result << "}_"; + } + result << ")_"; + result << "netPRC=" << dataPrc << "_"; + result << "targetDevice=" << targetDevice << "_"; + auto res_str = result.str(); + std::replace(res_str.begin(), res_str.end(), '-', '_'); + return res_str; + } + +protected: + void SetUp() override { + InputShape inputShapes; + InferenceEngine::Precision dataPrc; + targetDevice = ov::test::utils::DEVICE_GPU; + + std::tie(inputShapes, dataPrc, targetDevice) = GetParam(); + + init_input_shapes({inputShapes}); + + InferenceEngine::PreProcessInfo pre_process_info; + pre_process_info.setVariant(InferenceEngine::MeanVariant::MEAN_VALUE); + + const auto prc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(dataPrc); + + auto input = std::make_shared(prc, inputShapes.first); + input->get_output_tensor(0).get_rt_info()["ie_legacy_preproc"] = pre_process_info; + input->set_friendly_name("input_data"); + + auto shape_of_01 = std::make_shared(input); + shape_of_01->set_friendly_name("shape_of_01"); + + auto shape_of_02 = std::make_shared(shape_of_01); + shape_of_02->set_friendly_name("shape_of_02"); + + auto result = std::make_shared(shape_of_02); + result->set_friendly_name("outer_result"); + + function = std::make_shared(ngraph::OutputVector{result}, ngraph::ParameterVector{input}); + function->set_friendly_name("shape_of_test"); + } +}; + +TEST_P(ShapeOfDynamicInputGPUTest, CompareWithRefs) { + SKIP_IF_CURRENT_TEST_IS_DISABLED() + + run(); +} + +const std::vector dynamicInputShapes = { + ov::test::InputShape(ov::PartialShape({-1, -1, -1, -1, -1}), {{4, 1, 1, 64, 32}, {6, 1, 1, 8, 4}, {8, 1, 1, 24, 16}}), +}; + +const std::vector dynamicInputPrec = { + InferenceEngine::Precision::FP16, +}; + +INSTANTIATE_TEST_SUITE_P(smoke_Check, ShapeOfDynamicInputGPUTest, + testing::Combine( + testing::ValuesIn(dynamicInputShapes), // input shapes + testing::ValuesIn(dynamicInputPrec), // network precision + testing::Values(ov::test::utils::DEVICE_GPU)), // device type + ShapeOfDynamicInputGPUTest::getTestCaseName); + } // namespace GPULayerTestsDefinitions diff --git a/src/plugins/intel_gpu/tests/functional/single_layer_tests/dynamic/split.cpp b/src/plugins/intel_gpu/tests/functional/single_layer_tests/dynamic/split.cpp index c652a9770aa0c4..7a0b3fda62bcfe 100644 --- a/src/plugins/intel_gpu/tests/functional/single_layer_tests/dynamic/split.cpp +++ b/src/plugins/intel_gpu/tests/functional/single_layer_tests/dynamic/split.cpp @@ -264,4 +264,20 @@ INSTANTIATE_TEST_SUITE_P(smoke_VariadicSplitsCheck6D, VariadicSplitLayerGPUDynam ::testing::ValuesIn(restInputTypes)), // input type of splitLength VariadicSplitLayerGPUDynamicTest::getTestCaseName); + +const std::vector inputShapes4d_static = { + { + {5, 16, 10, 8}, {{5, 16, 10, 8}, } + } +}; + +INSTANTIATE_TEST_SUITE_P(smoke_VariadicSplitsCheck4D_static_input_dyn_output, VariadicSplitLayerGPUDynamicTest, + ::testing::Combine( + ::testing::Values(1), // axes + ::testing::Values(std::vector{2, 1, -1}), // splitLength + ::testing::Values(ElementType::f16), // netPrec + ::testing::ValuesIn(inputShapes4d_static), // inShapes + ::testing::ValuesIn(restInputTypes)), // input type of splitLength + VariadicSplitLayerGPUDynamicTest::getTestCaseName); + } // namespace GPULayerTestsDefinitions diff --git a/src/plugins/intel_gpu/tests/functional/subgraph_tests/condition.cpp b/src/plugins/intel_gpu/tests/functional/subgraph_tests/condition.cpp index 3f7e7f4bf4ff25..67cada5dbf661e 100644 --- a/src/plugins/intel_gpu/tests/functional/subgraph_tests/condition.cpp +++ b/src/plugins/intel_gpu/tests/functional/subgraph_tests/condition.cpp @@ -13,6 +13,8 @@ #include "common_test_utils/test_constants.hpp" #include "shared_test_classes/base/utils/ranges.hpp" #include +#include "shared_test_classes/base/utils/compare_results.hpp" +#include "openvino/pass/constant_folding.hpp" using namespace InferenceEngine; @@ -45,7 +47,11 @@ enum InnerBodyType { /** * Inner body with nested condition case */ - Type05 = 5 + Type05 = 5, + /** + * Inner body with single constant with zero dimensions + */ + Type06 = 6 }; public: @@ -251,6 +257,24 @@ class InnerBodyType05 : public InnerBodyGenerator { } }; +class InnerBodyType06 : public InnerBodyGenerator { +protected: + std::shared_ptr generate(ov::PartialShape& input_shape, ngraph::element::Type prc) override { + auto constant = ngraph::opset9::Constant::create(prc, ov::Shape(input_shape.rank().get_length(), 0), {2.0f}); + constant->set_friendly_name("body1_constant"); + // constant->get_rt_info().emplace(ov::pass::DisableConstantFolding::get_type_info_static(), ov::pass::DisableConstantFolding{}); + // constant->get_rt_info().emplace("can_be_folded", false); + auto result = std::make_shared(constant); + auto o_layout = result->get_layout(); + result->set_friendly_name("body1_result"); + auto body = std::make_shared( + ngraph::OutputVector {result}, + ngraph::ParameterVector{}, + "constant_only"); + return body; + } +}; + static std::shared_ptr get_inner_body_generator(InnerBodyGenerator::InnerBodyType type) { std::shared_ptr generator_ptr; switch (type) { @@ -274,6 +298,10 @@ static std::shared_ptr get_inner_body_generator(InnerBodyGen { return std::make_shared(); } + case InnerBodyGenerator::InnerBodyType::Type06: + { + return std::make_shared(); + } default: { OPENVINO_ASSERT(false, "Not supported type"); @@ -314,9 +342,22 @@ class TestModelGenerator { cond->set_then_body(body_then_generator->get_function()); cond->set_input(data, body_then_generator->get_input(), body_else_generator->get_input()); cond->set_output(body_then_generator->get_result(), body_else_generator->get_result()); - auto result = std::make_shared(cond); - result->set_friendly_name("outer_result"); - function = std::make_shared(ngraph::OutputVector {result}, params); + if (then_body_type == InnerBodyGenerator::InnerBodyType::Type06 || else_body_type == InnerBodyGenerator::InnerBodyType::Type06) { + auto constant = create_condition_input(params, prc, ngraph::Shape{1}, 0, true); + auto addition = std::make_shared(cond, constant); + auto shapeof1 = std::make_shared(addition); + auto convert = std::make_shared(shapeof1, prc); + auto mul = std::make_shared(convert, constant); + auto shapePatternsNode = create_condition_input(params, ov::element::Type_t::i64, ngraph::Shape{1}, 0, true); + auto reshapeOp = std::make_shared(mul, shapePatternsNode, true); + auto result = std::make_shared(reshapeOp); + result->set_friendly_name("outer_result"); + function = std::make_shared(ngraph::OutputVector {result}, params); + } else { + auto result = std::make_shared(cond); + result->set_friendly_name("outer_result"); + function = std::make_shared(ngraph::OutputVector {result}, params); + } } std::shared_ptr get_function() { return function; } @@ -394,6 +435,11 @@ static std::ostream& operator<<(std::ostream& os, const InnerBodyGenerator::Inne os << "Type05"; break; } + case InnerBodyGenerator::InnerBodyType::Type06: + { + os << "Type06"; + break; + } default: { os << "NONE"; @@ -596,7 +642,8 @@ class DynamicConditionLayerGPUTest : public testing::WithParamInterface& targetInputStaticShapes) override { ov::Shape input_shape; for (auto& shape : targetInputStaticShapes) { - if (shape.size() > 1) { + // Change condition to cover 1 dim input shape + if (shape.size() > 0) { input_shape = shape; break; } @@ -622,6 +669,7 @@ class DynamicConditionLayerGPUTest : public testing::WithParamInterface dynamicInputShapes_f16 = { ov::test::InputShape(ov::PartialShape({-1, -1, -1}), {{2, 24, 16}, {2, 64, 32}, {2, 8, 4}}) }; +const std::vector dynamicInputShapes_zero_dims = { + ov::test::InputShape(ov::PartialShape({-1}), {{24}, {64}, {8}}) +}; + const std::vector innerBodyTypes_f32 = { { InnerBodyGenerator::InnerBodyType::Type01, @@ -670,11 +722,22 @@ const std::vector innerBodyTypes_f16 = { } }; +const std::vector innerBodyTypes_zero_dims = { + { + InnerBodyGenerator::InnerBodyType::Type02, + InnerBodyGenerator::InnerBodyType::Type06 + }, +}; + const std::vector condTypes = { TestModelGenerator::PredicateTypes::PARAM, TestModelGenerator::PredicateTypes::NODE }; +const std::vector condTypes_zero_dims = { + TestModelGenerator::PredicateTypes::PARAM +}; + INSTANTIATE_TEST_SUITE_P(smoke_ConditionGPUTest_dynamic_f32, DynamicConditionLayerGPUTest, testing::Combine( testing::ValuesIn(dynamicInputShapes_f32), // input shapes @@ -693,4 +756,13 @@ INSTANTIATE_TEST_SUITE_P(smoke_ConditionGPUTest_dynamic_f16, DynamicConditionLay testing::ValuesIn(condTypes), // cond type testing::Values(ov::test::utils::DEVICE_GPU)), // device type DynamicConditionLayerGPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_ConditionGPUTest_zero_dims, DynamicConditionLayerGPUTest, + testing::Combine( + testing::ValuesIn(dynamicInputShapes_zero_dims), // input shapes + testing::ValuesIn(innerBodyTypes_zero_dims), // inner body type + testing::ValuesIn(netPrecisions_f32), // network precision + testing::ValuesIn(condTypes_zero_dims), // cond type + testing::Values(ov::test::utils::DEVICE_GPU)), // device type + DynamicConditionLayerGPUTest::getTestCaseName); } // namespace GPULayerTestsDefinitions From 691f5938d27820d409eb681e0d00c08a806e5222 Mon Sep 17 00:00:00 2001 From: Sofya Balandina Date: Tue, 19 Sep 2023 02:51:17 +0100 Subject: [PATCH 17/30] [template] Add faked hint property (#19887) * [template] Add faked hint property * fix comments --- src/plugins/template/src/config.cpp | 24 +++++++++++++++++++ src/plugins/template/src/config.hpp | 7 +++++- src/plugins/template/src/plugin.cpp | 4 ++++ .../ov_executable_network/properties.cpp | 2 +- .../behavior/ov_plugin/properties_tests.cpp | 2 +- .../ov_executable_network/properties.cpp | 11 +++++++++ .../behavior/ov_plugin/properties_tests.cpp | 7 ------ 7 files changed, 47 insertions(+), 10 deletions(-) diff --git a/src/plugins/template/src/config.cpp b/src/plugins/template/src/config.cpp index 155ed29ecd937a..683439d97018e5 100644 --- a/src/plugins/template/src/config.cpp +++ b/src/plugins/template/src/config.cpp @@ -36,6 +36,24 @@ Configuration::Configuration(const ov::AnyMap& config, const Configuration& defa } else if (ov::hint::performance_mode == key) { std::stringstream strm{value.as()}; strm >> performance_mode; + } else if (ov::hint::inference_precision == key) { + inference_precision = value.as(); + } else if (ov::hint::execution_mode == key) { + execution_mode = value.as(); + if ((execution_mode != ov::hint::ExecutionMode::ACCURACY) && + (execution_mode != ov::hint::ExecutionMode::PERFORMANCE)) { + OPENVINO_THROW("Unsupported execution mode, should be ACCURACY or PERFORMANCE, but was: ", + value.as()); + } + } else if (ov::num_streams == key) { + streams_executor_config.set_property(key, value); + } else if (ov::hint::num_requests == key) { + auto tmp_val = value.as(); + int tmp_i = std::stoi(tmp_val); + if (tmp_i >= 0) + num_requests = tmp_i; + else + OPENVINO_THROW("Incorrect value, it should be unsigned integer: ", key); } else if (throwOnUnsupported) { OPENVINO_THROW("Property was not found: ", key); } @@ -66,6 +84,12 @@ ov::Any Configuration::Get(const std::string& name) const { return {std::to_string(streams_executor_config._threadsPerStream)}; } else if (name == ov::hint::performance_mode) { return performance_mode; + } else if (name == ov::hint::inference_precision) { + return inference_precision; + } else if (name == ov::hint::execution_mode) { + return execution_mode; + } else if (name == ov::hint::num_requests) { + return num_requests; } else { OPENVINO_THROW("Property was not found: ", name); } diff --git a/src/plugins/template/src/config.hpp b/src/plugins/template/src/config.hpp index e2fb945e977895..d891fd472deddc 100644 --- a/src/plugins/template/src/config.hpp +++ b/src/plugins/template/src/config.hpp @@ -31,11 +31,16 @@ struct Configuration { // Plugin configuration parameters int device_id = 0; - bool perf_count = true; + bool perf_count = false; ov::threading::IStreamsExecutor::Config streams_executor_config; ov::hint::PerformanceMode performance_mode = ov::hint::PerformanceMode::LATENCY; + uint32_t num_requests = 1; bool disable_transformations = false; bool exclusive_async_requests = false; + + // unused + ov::element::Type inference_precision = ov::element::undefined; + ov::hint::ExecutionMode execution_mode = ov::hint::ExecutionMode::ACCURACY; }; // ! [configuration:header] diff --git a/src/plugins/template/src/plugin.cpp b/src/plugins/template/src/plugin.cpp index bcdd9b5ec3a0b4..2261204e5d7833 100644 --- a/src/plugins/template/src/plugin.cpp +++ b/src/plugins/template/src/plugin.cpp @@ -233,6 +233,10 @@ ov::Any ov::template_plugin::Plugin::get_property(const std::string& name, const std::vector rw_properties{ov::device::id, ov::enable_profiling, ov::hint::performance_mode, + ov::hint::num_requests, + ov::hint::inference_precision, + ov::hint::execution_mode, + ov::num_streams, ov::template_plugin::disable_transformations}; return rw_properties; }; diff --git a/src/plugins/template/tests/functional/shared_tests_instances/behavior/ov_executable_network/properties.cpp b/src/plugins/template/tests/functional/shared_tests_instances/behavior/ov_executable_network/properties.cpp index f180776721f23e..64b6fc0c1722b1 100644 --- a/src/plugins/template/tests/functional/shared_tests_instances/behavior/ov_executable_network/properties.cpp +++ b/src/plugins/template/tests/functional/shared_tests_instances/behavior/ov_executable_network/properties.cpp @@ -34,7 +34,7 @@ INSTANTIATE_TEST_SUITE_P(smoke_AutoBatch_BehaviorTests, OVClassCompiledModelPropertiesIncorrectTests::getTestCaseName); const std::vector default_properties = { - {ov::enable_profiling(true)}, + {ov::enable_profiling(false)}, {{ov::loaded_from_cache.name(), false}}, {ov::device::id("0")}, }; diff --git a/src/plugins/template/tests/functional/shared_tests_instances/behavior/ov_plugin/properties_tests.cpp b/src/plugins/template/tests/functional/shared_tests_instances/behavior/ov_plugin/properties_tests.cpp index 03d05b6ea9f9bf..0f05a09f4da99d 100644 --- a/src/plugins/template/tests/functional/shared_tests_instances/behavior/ov_plugin/properties_tests.cpp +++ b/src/plugins/template/tests/functional/shared_tests_instances/behavior/ov_plugin/properties_tests.cpp @@ -22,7 +22,7 @@ INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, OVPropertiesIncorrectTests::getTestCaseName); const std::vector default_properties = { - {ov::enable_profiling(true)}, + {ov::enable_profiling(false)}, {ov::device::id(0)}, }; diff --git a/src/tests/functional/plugin/conformance/test_runner/api_conformance_runner/src/behavior/ov_executable_network/properties.cpp b/src/tests/functional/plugin/conformance/test_runner/api_conformance_runner/src/behavior/ov_executable_network/properties.cpp index 5efdb3dba35e0d..bb361ab03088d8 100644 --- a/src/tests/functional/plugin/conformance/test_runner/api_conformance_runner/src/behavior/ov_executable_network/properties.cpp +++ b/src/tests/functional/plugin/conformance/test_runner/api_conformance_runner/src/behavior/ov_executable_network/properties.cpp @@ -70,4 +70,15 @@ INSTANTIATE_TEST_SUITE_P( INSTANTIATE_TEST_SUITE_P(ov_plugin_mandatory, OVCompiledModelIncorrectDevice, ::testing::Values(targetDevice)); +const std::vector multiModelPriorityConfigs = { + {ov::hint::model_priority(ov::hint::Priority::HIGH)}, + {ov::hint::model_priority(ov::hint::Priority::MEDIUM)}, + {ov::hint::model_priority(ov::hint::Priority::LOW)}, + {ov::hint::model_priority(ov::hint::Priority::DEFAULT)}}; + +INSTANTIATE_TEST_SUITE_P(ov_compiled_model_mandatory, + OVClassCompiledModelGetPropertyTest_MODEL_PRIORITY, + ::testing::Combine(::testing::ValuesIn(return_all_possible_device_combination()), + ::testing::ValuesIn(multiModelPriorityConfigs))); + } // namespace diff --git a/src/tests/functional/plugin/shared/src/behavior/ov_plugin/properties_tests.cpp b/src/tests/functional/plugin/shared/src/behavior/ov_plugin/properties_tests.cpp index 82affbe613bec0..b5cbff685b6340 100644 --- a/src/tests/functional/plugin/shared/src/behavior/ov_plugin/properties_tests.cpp +++ b/src/tests/functional/plugin/shared/src/behavior/ov_plugin/properties_tests.cpp @@ -254,13 +254,6 @@ std::vector OVPropertiesTestsWithCompileModelProps::getRWMandatoryPr } } - if (props.empty() || std::find(props.begin(), props.end(), ov::hint::model_priority.name()) != props.end()) { - ov::hint::Priority priorities[] = {ov::hint::Priority::LOW , ov::hint::Priority::MEDIUM, ov::hint::Priority::HIGH}; - for (auto &priority : priorities) { - res.push_back({{ov::hint::model_priority(priority)}}); - } - } - if (props.empty() || std::find(props.begin(), props.end(), ov::hint::performance_mode.name()) != props.end()) { ov::hint::PerformanceMode performance_modes[] = {ov::hint::PerformanceMode::LATENCY, ov::hint::PerformanceMode::THROUGHPUT, ov::hint::PerformanceMode::CUMULATIVE_THROUGHPUT}; From 9c4bc1cc2b955e76b350616fe12ce92de2b862a0 Mon Sep 17 00:00:00 2001 From: Zhang Yi Date: Tue, 19 Sep 2023 14:30:33 +0800 Subject: [PATCH 18/30] [CPU] Fix OMP thread count for MLAS ThreadPool initialization (#19731) --- src/plugins/intel_cpu/src/mlas/sgemm.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugins/intel_cpu/src/mlas/sgemm.cpp b/src/plugins/intel_cpu/src/mlas/sgemm.cpp index 2b3ebf9ecf9a9f..b2c868ddb1ba55 100644 --- a/src/plugins/intel_cpu/src/mlas/sgemm.cpp +++ b/src/plugins/intel_cpu/src/mlas/sgemm.cpp @@ -54,7 +54,7 @@ void mlas_sgemm(const char* transa, sgemmParam.beta = beta; auto _transa = *transa == 'N' ? CblasNoTrans : CblasTrans; auto _transb = *transb == 'N' ? CblasNoTrans : CblasTrans; - ov::cpu::OVMlasThreadPool threadPool(0 == thread_num ? parallel_get_num_threads() : thread_num); + ov::cpu::OVMlasThreadPool threadPool(0 == thread_num ? parallel_get_max_threads() : thread_num); MlasGemmBatch(_transa, _transb, M, N, K, &sgemmParam, 1, &threadPool); } @@ -74,7 +74,7 @@ void mlas_sgemm_compute(const char* transa, const float* bias, size_t thread_num) { // C = alpha*op( A )op( B ) + beta * C - ov::cpu::OVMlasThreadPool threadPool(0 == thread_num ? parallel_get_num_threads() : thread_num); + ov::cpu::OVMlasThreadPool threadPool(0 == thread_num ? parallel_get_max_threads() : thread_num); MLAS_SGEMM_DATA_PARAMS sgemmParam; sgemmParam.BIsPacked = true; sgemmParam.A = A; From e961ce307be7820f8cb333f0cda5a2e12a031a53 Mon Sep 17 00:00:00 2001 From: Chenhu Wang Date: Tue, 19 Sep 2023 14:41:38 +0800 Subject: [PATCH 19/30] [CPU] Eliminate dependency for emitters tails process (#19527) --- .../src/emitters/x64/jit_load_store_emitters.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/plugins/intel_cpu/src/emitters/x64/jit_load_store_emitters.cpp b/src/plugins/intel_cpu/src/emitters/x64/jit_load_store_emitters.cpp index ce09fb071ea4ce..67159c582b0d33 100644 --- a/src/plugins/intel_cpu/src/emitters/x64/jit_load_store_emitters.cpp +++ b/src/plugins/intel_cpu/src/emitters/x64/jit_load_store_emitters.cpp @@ -234,6 +234,18 @@ void jit_load_emitter::load_bytes(const Vmm &vmm, const Xbyak::Reg64 ®, int o has_xmm_block = true; } + // Cornerstone of partial load is combinaion of vpinsrb/w/d. + // As vpinsrb/w/d will not only write(insert) values into vmm, but also read values in vmm to copy from to positions that not in imm mask, + // this could introduce RAW false dependency(we actually do not care about values not in imm mask). + // To eliminate this false dependency, + // 1. For 1/2/3/4 bytes tails, replace vpinsrb/w/d with mov,shl etc instructions that don't read vmm. + // Besides eliminate RAW, these instructions have smaller latency, which also bring better perf, especially for small loop iteration case. + // 2. For 8/16 bytes, use vmovq/vmovdqu instructions to load, which also don't read src vmm. + // 3. For other size, insert vpxor before vpinsrb/w/d. vpxor and read vmm instructions in previous loop have WAR(write after read) relationship. + // CPU can identify this scenario and assign another physical vector register(register renameing) in next loop to eliminate RAW. + if (!one_of(bytes_to_load, 0, 1, 2, 3, 4, 8, 16)) { + h->uni_vpxor(vmm, vmm, vmm); + } if (bytes_to_load >= 8 && bytes_to_load < 16) h->uni_vmovq(xmm, addr(start_bytes)); else if (bytes_to_load == 16) From 933d9c1c0abe9c33f4ee330eec95e2035016459c Mon Sep 17 00:00:00 2001 From: Karol Blaszczak Date: Tue, 19 Sep 2023 08:56:45 +0200 Subject: [PATCH 20/30] [DOCS] OVC docs adjustments (#19918) (#19924) authored-by: Tatiana Savina --- docs/Documentation/model_introduction.md | 2 +- .../prepare_model/convert_model/Convert_Model_From_Paddle.md | 2 +- .../prepare_model/convert_model/Convert_Model_From_PyTorch.md | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/Documentation/model_introduction.md b/docs/Documentation/model_introduction.md index cd24fccbec8dfe..cadd407ba0b6a6 100644 --- a/docs/Documentation/model_introduction.md +++ b/docs/Documentation/model_introduction.md @@ -221,7 +221,7 @@ The figure below illustrates the typical workflow for deploying a trained deep-l Convert a Model in CLI: ``ovc`` ############################### -Another option for model conversion is to use ``ovc`` command-line tool, which stands for OpenVINO Model Converter. The tool combines both ``openvino.convert_model`` and ``openvino.save_model`` functionalities. It is convenient to use when the original model is ready for inference and is in one of the supported file formats: ONNX, TensorFlow, TensorFlow Lite, or PaddlePaddle. As a result, ``ovc`` produces an OpenVINO IR, consisting of ``.xml`` and ``.bin`` files, which needs to be read with the ``ov.read_model()`` method. You can compile and infer the ``ov.Model`` later with :doc:`OpenVINO™ Runtime ` +Another option for model conversion is to use ``ovc`` command-line tool, which stands for OpenVINO Model Converter. The tool combines both ``openvino.convert_model`` and ``openvino.save_model`` functionalities. It is convenient to use when the original model is ready for inference and is in one of the supported file formats: ONNX, TensorFlow, TensorFlow Lite, or PaddlePaddle. As a result, ``ovc`` produces an OpenVINO IR, consisting of ``.xml`` and ``.bin`` files, which needs to be read with the ``openvino.Core.read_model`` method. You can compile and infer the ``ov.Model`` later with :doc:`OpenVINO™ Runtime ` .. note:: PyTorch models cannot be converted with ``ovc``, use ``openvino.convert_model`` instead. diff --git a/docs/OV_Converter_UG/prepare_model/convert_model/Convert_Model_From_Paddle.md b/docs/OV_Converter_UG/prepare_model/convert_model/Convert_Model_From_Paddle.md index dd3f821229bf99..8b4c549547ebbd 100644 --- a/docs/OV_Converter_UG/prepare_model/convert_model/Convert_Model_From_Paddle.md +++ b/docs/OV_Converter_UG/prepare_model/convert_model/Convert_Model_From_Paddle.md @@ -89,7 +89,7 @@ Some PaddlePaddle models may require setting ``example_input`` or ``output`` for * Example of converting ``paddle.fluid.dygraph.layers.Layer`` format model: - ``example_input`` is required while ``output`` is optional, which accept the following formats: + ``example_input`` is required while ``output`` is optional. ``example_input`` accepts the following formats: ``list`` with tensor (``paddle.Tensor``) or InputSpec (``paddle.static.input.InputSpec``) diff --git a/docs/OV_Converter_UG/prepare_model/convert_model/Convert_Model_From_PyTorch.md b/docs/OV_Converter_UG/prepare_model/convert_model/Convert_Model_From_PyTorch.md index 83005b7e978e8c..6fcd6d7c03aaa8 100644 --- a/docs/OV_Converter_UG/prepare_model/convert_model/Convert_Model_From_PyTorch.md +++ b/docs/OV_Converter_UG/prepare_model/convert_model/Convert_Model_From_PyTorch.md @@ -40,8 +40,8 @@ The value for the ``example_input`` parameter can be easily derived from knowing import torch import openvino as ov - model = torchvision.models.resnet50(pretrained=True) - ov_model = ov.convert_model(model, example_input=example_input=torch.rand(1, 3, 224, 224)) + model = torchvision.models.resnet50(weights='DEFAULT') + ov_model = ov.convert_model(model, example_input=torch.rand(1, 3, 224, 224)) In practice, the code to evaluate or test the PyTorch model is usually provided with the model itself and can be used to generate a proper ``example_input`` value. A modified example of using ``resnet50`` model from ``torchvision`` is presented below. It demonstrates how to switch inference in the existing PyTorch application to OpenVINO and how to get value for ``example_input``: From e34f3a1feef0e71633f510d1bd1c98e52b8bc9bd Mon Sep 17 00:00:00 2001 From: River Li Date: Tue, 19 Sep 2023 15:13:57 +0800 Subject: [PATCH 21/30] Fix warning in template plugin (#19932) --- src/plugins/template/src/compiled_model.cpp | 10 ---------- src/plugins/template/src/plugin.cpp | 10 ---------- .../template/tests/functional/op_reference/loop.cpp | 4 ++-- .../tests/functional/op_reference/memory.cpp | 1 - .../subgraph_reference/preprocess_legacy.cpp | 12 ------------ 5 files changed, 2 insertions(+), 35 deletions(-) diff --git a/src/plugins/template/src/compiled_model.cpp b/src/plugins/template/src/compiled_model.cpp index e550bd1e6571bb..3227621305741f 100644 --- a/src/plugins/template/src/compiled_model.cpp +++ b/src/plugins/template/src/compiled_model.cpp @@ -126,9 +126,6 @@ std::shared_ptr ov::template_plugin::Compiled // ! [compiled_model:get_property] ov::Any ov::template_plugin::CompiledModel::get_property(const std::string& name) const { - const auto& add_ro_properties = [](const std::string& name, std::vector& properties) { - properties.emplace_back(ov::PropertyName{name, ov::PropertyMutability::RO}); - }; const auto& default_ro_properties = []() { std::vector ro_properties{ov::model_name, ov::supported_properties, @@ -141,13 +138,6 @@ ov::Any ov::template_plugin::CompiledModel::get_property(const std::string& name std::vector rw_properties{ov::device::id, ov::enable_profiling}; return rw_properties; }; - const auto& to_string_vector = [](const std::vector& properties) { - std::vector ret; - for (const auto& property : properties) { - ret.emplace_back(property); - } - return ret; - }; if (ov::model_name == name) { auto model_name = m_model->get_friendly_name(); return decltype(ov::model_name)::value_type(model_name); diff --git a/src/plugins/template/src/plugin.cpp b/src/plugins/template/src/plugin.cpp index 2261204e5d7833..e1f3f114715222 100644 --- a/src/plugins/template/src/plugin.cpp +++ b/src/plugins/template/src/plugin.cpp @@ -217,9 +217,6 @@ void ov::template_plugin::Plugin::set_property(const ov::AnyMap& properties) { // ! [plugin:get_property] ov::Any ov::template_plugin::Plugin::get_property(const std::string& name, const ov::AnyMap& arguments) const { - const auto& add_ro_properties = [](const std::string& name, std::vector& properties) { - properties.emplace_back(ov::PropertyName{name, ov::PropertyMutability::RO}); - }; const auto& default_ro_properties = []() { std::vector ro_properties{ov::available_devices, ov::supported_properties, @@ -240,13 +237,6 @@ ov::Any ov::template_plugin::Plugin::get_property(const std::string& name, const ov::template_plugin::disable_transformations}; return rw_properties; }; - const auto& to_string_vector = [](const std::vector& properties) { - std::vector ret; - for (const auto& property : properties) { - ret.emplace_back(property); - } - return ret; - }; if (ov::supported_properties == name) { auto ro_properties = default_ro_properties(); auto rw_properties = default_rw_properties(); diff --git a/src/plugins/template/tests/functional/op_reference/loop.cpp b/src/plugins/template/tests/functional/op_reference/loop.cpp index 3a760b0b8095b0..3e7f9ad63b51bf 100644 --- a/src/plugins/template/tests/functional/op_reference/loop.cpp +++ b/src/plugins/template/tests/functional/op_reference/loop.cpp @@ -153,7 +153,7 @@ struct LoopStaticInputs : public LoopFunctionalBase { // Body std::shared_ptr Zo = body_params[0]; - for (int i = 1; i < body_params.size(); ++i) { + for (size_t i = 1; i < body_params.size(); ++i) { Zo = std::make_shared(body_params[i], Zo); } @@ -164,7 +164,7 @@ struct LoopStaticInputs : public LoopFunctionalBase { loop->set_function(body); loop->set_special_body_ports(ov::opset8::Loop::SpecialBodyPorts{-1, 0}); - for (int i = 0; i < body_params.size(); ++i) { + for (size_t i = 0; i < body_params.size(); ++i) { if (loop_in_type[i] == LOOP_IN_TYPE::INVARIANT) { loop->set_invariant_input(body_params[i], loop_params[i]); } else if (loop_in_type[i] == LOOP_IN_TYPE::MERGED) { diff --git a/src/plugins/template/tests/functional/op_reference/memory.cpp b/src/plugins/template/tests/functional/op_reference/memory.cpp index f0492964cab1ce..01c7a321b53e5e 100644 --- a/src/plugins/template/tests/functional/op_reference/memory.cpp +++ b/src/plugins/template/tests/functional/op_reference/memory.cpp @@ -286,7 +286,6 @@ class ReferenceMemoryTest : public testing::TestWithParam { void CommonTestSteps(const std::function& custom_step = nullptr) { auto params = GetParam(); - const auto& functionParams = function->get_parameters(); inferRequest.set_tensor(executableNetwork.input(0), params.m_input_data); for (size_t i = 0; i < params.m_count_runs; ++i) { if (custom_step) { diff --git a/src/plugins/template/tests/functional/subgraph_reference/preprocess_legacy.cpp b/src/plugins/template/tests/functional/subgraph_reference/preprocess_legacy.cpp index f4f984726b81ba..574b8f618be473 100644 --- a/src/plugins/template/tests/functional/subgraph_reference/preprocess_legacy.cpp +++ b/src/plugins/template/tests/functional/subgraph_reference/preprocess_legacy.cpp @@ -41,18 +41,6 @@ static std::shared_ptr create_simple_function(element::Type type, const P return std::make_shared(ResultVector{res}, ParameterVector{data1}); } -static std::shared_ptr create_simple_function_yuv(const PartialShape& shape) { - auto data1 = std::make_shared(element::u8, shape); - data1->set_friendly_name("input1"); - data1->get_output_tensor(0).set_names({"tensor_input1", "input1"}); - auto op = std::make_shared(data1, element::f32); - op->set_friendly_name("Convert1"); - auto res = std::make_shared(op); - res->set_friendly_name("Result1"); - res->get_output_tensor(0).set_names({"tensor_output1", "Result1", "Convert1"}); - return std::make_shared(ResultVector{res}, ParameterVector{data1}); -} - TEST_F(ReferencePreprocessLegacyTest, mean) { function = create_simple_function(element::f32, Shape{1, 3, 2, 2}); auto p = PrePostProcessor(function); From 475ad32cc43a9689a6a40f578db59f560c1df526 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 19 Sep 2023 11:19:35 +0400 Subject: [PATCH 22/30] Update numpy requirement in /src/bindings/python (#19897) Updates the requirements on [numpy](https://github.com/numpy/numpy) to permit the latest version. - [Release notes](https://github.com/numpy/numpy/releases) - [Changelog](https://github.com/numpy/numpy/blob/main/doc/RELEASE_WALKTHROUGH.rst) - [Commits](https://github.com/numpy/numpy/compare/v1.16.6...v1.26.0) --- updated-dependencies: - dependency-name: numpy dependency-type: direct:production ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- src/bindings/python/constraints.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bindings/python/constraints.txt b/src/bindings/python/constraints.txt index 30be494ea327bc..1762fa681551d3 100644 --- a/src/bindings/python/constraints.txt +++ b/src/bindings/python/constraints.txt @@ -1,5 +1,5 @@ # used in multiple components -numpy>=1.16.6,<1.26 # Python bindings, frontends +numpy>=1.16.6,<1.27 # Python bindings, frontends # pytest pytest>=5.0,<7.5 From 6b5a22a656ba976ea2bcb5152845a7857e870822 Mon Sep 17 00:00:00 2001 From: Vitaliy Urusovskij Date: Tue, 19 Sep 2023 11:27:23 +0400 Subject: [PATCH 23/30] Add `bert-base-ner` in MemLeak tests (#19817) * Add `bert-base-ner` in MemLeak tests * Fix segfault caused by `fillTensorRandom()` --- tests/lib/src/common_utils.h | 88 ++++++++++--------- .../nightly_configs/desktop_test_config.xml | 8 ++ .../precommit_configs/desktop_test_config.xml | 8 ++ .../weekly_configs/desktop_test_config.xml | 10 ++- 4 files changed, 73 insertions(+), 41 deletions(-) diff --git a/tests/lib/src/common_utils.h b/tests/lib/src/common_utils.h index ac15570f38ce2e..a3bd72d844ff5d 100644 --- a/tests/lib/src/common_utils.h +++ b/tests/lib/src/common_utils.h @@ -10,6 +10,13 @@ #include +template +using uniformDistribution = typename std::conditional< + std::is_floating_point::value, + std::uniform_real_distribution, + typename std::conditional::value, std::uniform_int_distribution, void>::type>::type; + + /** * @brief Determine if InferenceEngine blob means image or not (OV API 1.0) */ @@ -84,27 +91,20 @@ void fillBlobRandom(InferenceEngine::Blob::Ptr &inputBlob) { /** * @brief Fill InferenceEngine tensor with random values (OV API 2.0) */ -template -ov::Tensor fillTensorRandom(T &input) { - ov::Tensor tensor{input.get_element_type(), input.get_shape()}; - std::vector values(ov::shape_size(input.get_shape())); - - std::random_device rd; - std::mt19937 gen(rd()); - - if (std::is_floating_point::value == true) { - std::uniform_real_distribution<> distrib_f = std::uniform_real_distribution<>(0, std::numeric_limits::max()); - for (size_t i = 0; i < values.size(); ++i) - values[i] = distrib_f(gen); - } else { - std::uniform_int_distribution<> distrib_i = std::uniform_int_distribution<>(0, std::numeric_limits::max()); - for (size_t i = 0; i < values.size(); ++i) - values[i] = distrib_i(gen); +template +void fillTensorRandom(ov::Tensor& tensor, + T rand_min = std::numeric_limits::min(), + T rand_max = std::numeric_limits::max()) { + std::mt19937 gen(0); + size_t tensor_size = tensor.get_size(); + if (0 == tensor_size) { + throw std::runtime_error( + "Models with dynamic shapes aren't supported. Input tensors must have specific shapes before inference"); } - - std::memcpy(tensor.data(), values.data(), sizeof(U) * values.size()); - - return tensor; + T* data = tensor.data(); + uniformDistribution distribution(rand_min, rand_max); + for (size_t i = 0; i < tensor_size; i++) + data[i] = static_cast(distribution(gen)); } @@ -141,26 +141,34 @@ void fillBlobImInfo(InferenceEngine::Blob::Ptr &inputBlob, template void fillTensors(ov::InferRequest &infer_request, std::vector &inputs) { for (size_t i = 0; i < inputs.size(); ++i) { - ov::Tensor input_tensor; - - if (inputs[i].get_element_type() == ov::element::f32) { - input_tensor = fillTensorRandom(inputs[i]); - } else if (inputs[i].get_element_type() == ov::element::f64) { - input_tensor = fillTensorRandom(inputs[i]); - } else if (inputs[i].get_element_type() == ov::element::f16) { - input_tensor = fillTensorRandom(inputs[i]); - } else if (inputs[i].get_element_type() == ov::element::i32) { - input_tensor = fillTensorRandom(inputs[i]); - } else if (inputs[i].get_element_type() == ov::element::i64) { - input_tensor = fillTensorRandom(inputs[i]); - } else if (inputs[i].get_element_type() == ov::element::u8) { - input_tensor = fillTensorRandom(inputs[i]); - } else if (inputs[i].get_element_type() == ov::element::i8) { - input_tensor = fillTensorRandom(inputs[i]); - } else if (inputs[i].get_element_type() == ov::element::u16) { - input_tensor = fillTensorRandom(inputs[i]); - } else if (inputs[i].get_element_type() == ov::element::i16) { - input_tensor = fillTensorRandom(inputs[i]); + auto input_tensor = infer_request.get_tensor(inputs[i]); + auto type = inputs[i].get_element_type(); + if (type == ov::element::f32) { + fillTensorRandom(input_tensor); + } else if (type == ov::element::f64) { + fillTensorRandom(input_tensor); + } else if (type == ov::element::f16) { + fillTensorRandom(input_tensor); + } else if (type == ov::element::i32) { + fillTensorRandom(input_tensor); + } else if (type == ov::element::i64) { + fillTensorRandom(input_tensor); + } else if ((type == ov::element::u8) || (type == ov::element::boolean)) { + // uniform_int_distribution is not allowed in the C++17 + // standard and vs2017/19 + fillTensorRandom(input_tensor); + } else if (type == ov::element::i8) { + // uniform_int_distribution is not allowed in the C++17 standard + // and vs2017/19 + fillTensorRandom(input_tensor, + std::numeric_limits::min(), + std::numeric_limits::max()); + } else if (type == ov::element::u16) { + fillTensorRandom(input_tensor); + } else if (type == ov::element::i16) { + fillTensorRandom(input_tensor); + } else if (type == ov::element::boolean) { + fillTensorRandom(input_tensor, 0, 1); } else { throw std::logic_error( "Input precision is not supported for " + inputs[i].get_element_type().get_type_name()); diff --git a/tests/stress_tests/.automation/memleaks_tests/nightly_configs/desktop_test_config.xml b/tests/stress_tests/.automation/memleaks_tests/nightly_configs/desktop_test_config.xml index 3058ceaa5f51a6..cca3ec23df13c8 100644 --- a/tests/stress_tests/.automation/memleaks_tests/nightly_configs/desktop_test_config.xml +++ b/tests/stress_tests/.automation/memleaks_tests/nightly_configs/desktop_test_config.xml @@ -24,6 +24,14 @@ + + + + + + + + diff --git a/tests/stress_tests/.automation/memleaks_tests/precommit_configs/desktop_test_config.xml b/tests/stress_tests/.automation/memleaks_tests/precommit_configs/desktop_test_config.xml index 4909b6411f1fa9..29d54db3f3c142 100644 --- a/tests/stress_tests/.automation/memleaks_tests/precommit_configs/desktop_test_config.xml +++ b/tests/stress_tests/.automation/memleaks_tests/precommit_configs/desktop_test_config.xml @@ -8,4 +8,12 @@ + + + + + + + + diff --git a/tests/stress_tests/.automation/memleaks_tests/weekly_configs/desktop_test_config.xml b/tests/stress_tests/.automation/memleaks_tests/weekly_configs/desktop_test_config.xml index d9240cc239aaec..57fd6c160caa60 100644 --- a/tests/stress_tests/.automation/memleaks_tests/weekly_configs/desktop_test_config.xml +++ b/tests/stress_tests/.automation/memleaks_tests/weekly_configs/desktop_test_config.xml @@ -23,7 +23,15 @@ - + + + + + + + + + From 068cd4473d076c8a985899a0c62fe1acbf251c3a Mon Sep 17 00:00:00 2001 From: Oleg Pipikin Date: Tue, 19 Sep 2023 09:40:29 +0200 Subject: [PATCH 24/30] Refactor AdaPool, BatchToSpace, and BatchNorm shared tests (#19597) * Refactor AdaPool, BatchToSpace, and BatchNorm shared tests --- .../single_layer_tests/adaptive_pooling.cpp | 65 +++++++++-------- .../single_layer_tests/batch_norm.cpp | 36 +++++----- .../single_layer_tests/batch_to_space.cpp | 71 +++++++------------ .../single_layer_tests/adaptive_pooling.hpp | 2 +- .../single_op_tests/adaptive_pooling.hpp | 15 ++++ .../include/single_op_tests/batch_norm.hpp | 15 ++++ .../single_op_tests/batch_to_space.hpp | 17 +++++ .../single_op/adaptive_pooling.hpp | 27 +++++++ .../single_op/batch_norm.hpp | 27 +++++++ .../single_op/batch_to_space.hpp | 32 +++++++++ .../single_op/comparison.hpp | 2 - .../single_op/gru_sequence.hpp | 3 - .../src/base/utils/generate_inputs.cpp | 45 ++++++++++++ .../src/single_op/adaptive_pooling.cpp | 60 ++++++++++++++++ .../src/single_op/batch_norm.cpp | 61 ++++++++++++++++ .../src/single_op/batch_to_space.cpp | 53 ++++++++++++++ .../src/single_op/comparison.cpp | 36 +--------- .../src/single_op/gru_sequence.cpp | 29 +++----- 18 files changed, 440 insertions(+), 156 deletions(-) create mode 100644 src/tests/functional/plugin/shared/include/single_op_tests/adaptive_pooling.hpp create mode 100644 src/tests/functional/plugin/shared/include/single_op_tests/batch_norm.hpp create mode 100644 src/tests/functional/plugin/shared/include/single_op_tests/batch_to_space.hpp create mode 100644 src/tests/functional/shared_test_classes/include/shared_test_classes/single_op/adaptive_pooling.hpp create mode 100644 src/tests/functional/shared_test_classes/include/shared_test_classes/single_op/batch_norm.hpp create mode 100644 src/tests/functional/shared_test_classes/include/shared_test_classes/single_op/batch_to_space.hpp create mode 100644 src/tests/functional/shared_test_classes/src/single_op/adaptive_pooling.cpp create mode 100644 src/tests/functional/shared_test_classes/src/single_op/batch_norm.cpp create mode 100644 src/tests/functional/shared_test_classes/src/single_op/batch_to_space.cpp diff --git a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/adaptive_pooling.cpp b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/adaptive_pooling.cpp index d4d87b825e7164..837844e4fcf625 100644 --- a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/adaptive_pooling.cpp +++ b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/adaptive_pooling.cpp @@ -4,55 +4,62 @@ #include -#include "single_layer_tests/adaptive_pooling.hpp" +#include "single_op_tests/adaptive_pooling.hpp" #include "common_test_utils/test_constants.hpp" -using namespace LayerTestsDefinitions; +namespace { +using ov::test::AdaPoolLayerTest; +const std::vector types = { + ov::element::f16, + ov::element::f32 +}; -const std::vector netPRCs = { - InferenceEngine::Precision::FP16, - InferenceEngine::Precision::FP32 +const std::vector> input_shapes_3d_static = { + {{ 1, 2, 1}}, + {{ 1, 1, 3 }}, + {{ 3, 17, 5 }} }; -const auto AdaPool3DCases = ::testing::Combine( - ::testing::ValuesIn( - std::vector> { - { 1, 2, 1}, - { 1, 1, 3 }, - { 3, 17, 5 }}), +const auto ada_pool_3d_cases = ::testing::Combine( + ::testing::ValuesIn(ov::test::static_shapes_to_test_representation(input_shapes_3d_static)), ::testing::ValuesIn(std::vector>{ {1}, {3}, {5} }), ::testing::ValuesIn(std::vector{"max", "avg"}), - ::testing::ValuesIn(netPRCs), + ::testing::ValuesIn(types), ::testing::Values(ov::test::utils::DEVICE_CPU) ); -INSTANTIATE_TEST_SUITE_P(smoke_TestsAdaPool3D, AdaPoolLayerTest, AdaPool3DCases, AdaPoolLayerTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_TestsAdaPool3D, AdaPoolLayerTest, ada_pool_3d_cases, AdaPoolLayerTest::getTestCaseName); + +const std::vector> input_shapes_4d_static = { + {{ 1, 2, 1, 2 }}, + {{ 1, 1, 3, 2 }}, + {{ 3, 17, 5, 1 }} +}; -const auto AdaPool4DCases = ::testing::Combine( - ::testing::ValuesIn( - std::vector> { - { 1, 2, 1, 2}, - { 1, 1, 3, 2}, - { 3, 17, 5, 1}}), +const auto ada_pool_4d_cases = ::testing::Combine( + ::testing::ValuesIn(ov::test::static_shapes_to_test_representation(input_shapes_4d_static)), ::testing::ValuesIn(std::vector>{ {1, 1}, {3, 5}, {5, 5} }), ::testing::ValuesIn(std::vector{"max", "avg"}), - ::testing::ValuesIn(netPRCs), + ::testing::ValuesIn(types), ::testing::Values(ov::test::utils::DEVICE_CPU) ); -INSTANTIATE_TEST_SUITE_P(smoke_TestsAdaPool4D, AdaPoolLayerTest, AdaPool4DCases, AdaPoolLayerTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_TestsAdaPool4D, AdaPoolLayerTest, ada_pool_4d_cases, AdaPoolLayerTest::getTestCaseName); + +const std::vector> input_shapes_5d_static = { + {{ 1, 2, 1, 2, 2 }}, + {{ 1, 1, 3, 2, 3 }}, + {{ 3, 17, 5, 1, 2 }} +}; -const auto AdaPool5DCases = ::testing::Combine( - ::testing::ValuesIn( - std::vector> { - { 1, 2, 1, 2, 2}, - { 1, 1, 3, 2, 3}, - { 3, 17, 5, 1, 2}}), +const auto ada_pool_5d_cases = ::testing::Combine( + ::testing::ValuesIn(ov::test::static_shapes_to_test_representation(input_shapes_5d_static)), ::testing::ValuesIn(std::vector>{ {1, 1, 1}, {3, 5, 3}, {5, 5, 5} }), ::testing::ValuesIn(std::vector{"max", "avg"}), - ::testing::ValuesIn(netPRCs), + ::testing::ValuesIn(types), ::testing::Values(ov::test::utils::DEVICE_CPU) ); -INSTANTIATE_TEST_SUITE_P(smoke_TestsAdaPool5D, AdaPoolLayerTest, AdaPool5DCases, AdaPoolLayerTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_TestsAdaPool5D, AdaPoolLayerTest, ada_pool_5d_cases, AdaPoolLayerTest::getTestCaseName); +} // namespace diff --git a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/batch_norm.cpp b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/batch_norm.cpp index 467e32c26689d2..a7850b4e94329c 100644 --- a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/batch_norm.cpp +++ b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/batch_norm.cpp @@ -4,14 +4,14 @@ #include -#include "single_layer_tests/batch_norm.hpp" - -using namespace LayerTestsDefinitions; +#include "single_op_tests/batch_norm.hpp" namespace { -const std::vector netPrecisions = { - InferenceEngine::Precision::FP32, - InferenceEngine::Precision::FP16 +using ov::test::BatchNormLayerTest; + +const std::vector model_type = { + ov::element::f32, + ov::element::f16 }; const std::vector epsilon = { @@ -20,30 +20,26 @@ const std::vector epsilon = { 1e-5, 1e-4 }; -const std::vector> inputShapes = { - {1, 3}, - {2, 5}, - {1, 3, 10}, - {1, 3, 1, 1}, - {2, 5, 4, 4}, +const std::vector> input_shapes_static = { + {{1, 3}}, + {{2, 5}}, + {{1, 3, 10}}, + {{1, 3, 1, 1}}, + {{2, 5, 4, 4}}, }; -const auto batchNormParams = testing::Combine( +const auto batch_norm_params = testing::Combine( testing::ValuesIn(epsilon), - testing::ValuesIn(netPrecisions), - testing::Values(InferenceEngine::Precision::UNSPECIFIED), - testing::Values(InferenceEngine::Precision::UNSPECIFIED), - testing::Values(InferenceEngine::Layout::ANY), - testing::Values(InferenceEngine::Layout::ANY), - testing::ValuesIn(inputShapes), + testing::ValuesIn(model_type), + testing::ValuesIn(ov::test::static_shapes_to_test_representation(input_shapes_static)), testing::Values(ov::test::utils::DEVICE_CPU) ); INSTANTIATE_TEST_SUITE_P( smoke_BatchNorm, BatchNormLayerTest, - batchNormParams, + batch_norm_params, BatchNormLayerTest::getTestCaseName ); diff --git a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/batch_to_space.cpp b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/batch_to_space.cpp index 2883915a91055f..dc7c4f41afb1c8 100644 --- a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/batch_to_space.cpp +++ b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/batch_to_space.cpp @@ -2,23 +2,20 @@ // SPDX-License-Identifier: Apache-2.0 // -#include - -#include "single_layer_tests/batch_to_space.hpp" +#include "single_op_tests/batch_to_space.hpp" #include "common_test_utils/test_constants.hpp" -using namespace LayerTestsDefinitions; - namespace { +using ov::test::BatchToSpaceLayerTest; -const std::vector net_precisions = { - InferenceEngine::Precision::FP32, - InferenceEngine::Precision::I32 +const std::vector net_types = { + ov::element::f32, + ov::element::i32 }; -const std::vector> data_shapes_2D = { - {12, 4}, - {48, 3} +const std::vector> data_shapes_2D_static = { + {{12, 4}}, + {{48, 3}} }; const std::vector> block_shapes_2D = { @@ -35,12 +32,8 @@ const auto batch_to_space_2d_tests = ::testing::Combine( ::testing::ValuesIn(block_shapes_2D), ::testing::ValuesIn(crops_2D), ::testing::ValuesIn(crops_2D), - ::testing::ValuesIn(data_shapes_2D), - ::testing::ValuesIn(net_precisions), - ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), - ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), - ::testing::Values(InferenceEngine::Layout::ANY), - ::testing::Values(InferenceEngine::Layout::ANY), + ::testing::ValuesIn(ov::test::static_shapes_to_test_representation(data_shapes_2D_static)), + ::testing::ValuesIn(net_types), ::testing::Values(ov::test::utils::DEVICE_CPU)); INSTANTIATE_TEST_SUITE_P( @@ -49,10 +42,10 @@ INSTANTIATE_TEST_SUITE_P( batch_to_space_2d_tests, BatchToSpaceLayerTest::getTestCaseName); -const std::vector> data_shapes_4D = { - {4, 1, 2, 2}, - {4, 3, 2, 2}, - {8, 1, 3, 2} +const std::vector> data_shapes_4D_static = { + {{4, 1, 2, 2}}, + {{4, 3, 2, 2}}, + {{8, 1, 3, 2}} }; const std::vector> block_shapes_4D = { @@ -76,24 +69,16 @@ const auto batch_to_space_4d_spatial_dims_tests = ::testing::Combine( ::testing::Values(block_shapes_4D[0]), ::testing::ValuesIn(crops_begin_4D), ::testing::ValuesIn(crops_end_4D), - ::testing::ValuesIn(data_shapes_4D), - ::testing::ValuesIn(net_precisions), - ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), - ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), - ::testing::Values(InferenceEngine::Layout::ANY), - ::testing::Values(InferenceEngine::Layout::ANY), + ::testing::ValuesIn(ov::test::static_shapes_to_test_representation(data_shapes_4D_static)), + ::testing::ValuesIn(net_types), ::testing::Values(ov::test::utils::DEVICE_CPU)); const auto batch_to_space_4d_channel_dim_tests = ::testing::Combine( ::testing::Values(block_shapes_4D[1]), ::testing::Values(crops_begin_4D[0]), ::testing::Values(crops_end_4D[0]), - ::testing::ValuesIn(data_shapes_4D), - ::testing::ValuesIn(net_precisions), - ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), - ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), - ::testing::Values(InferenceEngine::Layout::ANY), - ::testing::Values(InferenceEngine::Layout::ANY), + ::testing::ValuesIn(ov::test::static_shapes_to_test_representation(data_shapes_4D_static)), + ::testing::ValuesIn(net_types), ::testing::Values(ov::test::utils::DEVICE_CPU)); INSTANTIATE_TEST_SUITE_P( @@ -108,8 +93,8 @@ INSTANTIATE_TEST_SUITE_P( batch_to_space_4d_channel_dim_tests, BatchToSpaceLayerTest::getTestCaseName); -const std::vector> data_shapes_5D = { - {12, 1, 2, 1, 2} +const std::vector> data_shapes_5D_static = { + {{12, 1, 2, 1, 2}} }; const std::vector> block_shapes_5D = { @@ -133,24 +118,16 @@ const auto batch_to_space_5d_spatial_dims_tests = ::testing::Combine( ::testing::Values(block_shapes_5D[0]), ::testing::ValuesIn(crops_begin_5D), ::testing::ValuesIn(crops_end_5D), - ::testing::ValuesIn(data_shapes_5D), - ::testing::ValuesIn(net_precisions), - ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), - ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), - ::testing::Values(InferenceEngine::Layout::ANY), - ::testing::Values(InferenceEngine::Layout::ANY), + ::testing::ValuesIn(ov::test::static_shapes_to_test_representation(data_shapes_5D_static)), + ::testing::ValuesIn(net_types), ::testing::Values(ov::test::utils::DEVICE_CPU)); const auto batch_to_space_5d_channel_dim_tests = ::testing::Combine( ::testing::Values(block_shapes_5D[1]), ::testing::Values(crops_begin_5D[0]), ::testing::Values(crops_end_5D[0]), - ::testing::ValuesIn(data_shapes_5D), - ::testing::ValuesIn(net_precisions), - ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), - ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), - ::testing::Values(InferenceEngine::Layout::ANY), - ::testing::Values(InferenceEngine::Layout::ANY), + ::testing::ValuesIn(ov::test::static_shapes_to_test_representation(data_shapes_5D_static)), + ::testing::ValuesIn(net_types), ::testing::Values(ov::test::utils::DEVICE_CPU)); INSTANTIATE_TEST_SUITE_P( diff --git a/src/tests/functional/plugin/shared/include/single_layer_tests/adaptive_pooling.hpp b/src/tests/functional/plugin/shared/include/single_layer_tests/adaptive_pooling.hpp index f4d41b2b122294..3caf98b7566cfd 100644 --- a/src/tests/functional/plugin/shared/include/single_layer_tests/adaptive_pooling.hpp +++ b/src/tests/functional/plugin/shared/include/single_layer_tests/adaptive_pooling.hpp @@ -9,7 +9,7 @@ namespace LayerTestsDefinitions { TEST_P(AdaPoolLayerTest, CompareWithRefs) { -Run(); + Run(); } } // namespace LayerTestsDefinitions diff --git a/src/tests/functional/plugin/shared/include/single_op_tests/adaptive_pooling.hpp b/src/tests/functional/plugin/shared/include/single_op_tests/adaptive_pooling.hpp new file mode 100644 index 00000000000000..74b49d5f66387f --- /dev/null +++ b/src/tests/functional/plugin/shared/include/single_op_tests/adaptive_pooling.hpp @@ -0,0 +1,15 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include "shared_test_classes/single_op/adaptive_pooling.hpp" + +namespace ov { +namespace test { +TEST_P(AdaPoolLayerTest, Inference) { + run(); +} +} // namespace test +} // namespace ov diff --git a/src/tests/functional/plugin/shared/include/single_op_tests/batch_norm.hpp b/src/tests/functional/plugin/shared/include/single_op_tests/batch_norm.hpp new file mode 100644 index 00000000000000..d7cad68321cbe3 --- /dev/null +++ b/src/tests/functional/plugin/shared/include/single_op_tests/batch_norm.hpp @@ -0,0 +1,15 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include "shared_test_classes/single_op/batch_norm.hpp" + +namespace ov { +namespace test { +TEST_P(BatchNormLayerTest, Inference) { + run(); +} +} // namespace test +} // namespace ov diff --git a/src/tests/functional/plugin/shared/include/single_op_tests/batch_to_space.hpp b/src/tests/functional/plugin/shared/include/single_op_tests/batch_to_space.hpp new file mode 100644 index 00000000000000..d894fd039ab61c --- /dev/null +++ b/src/tests/functional/plugin/shared/include/single_op_tests/batch_to_space.hpp @@ -0,0 +1,17 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include "shared_test_classes/single_op/batch_to_space.hpp" + +namespace ov { +namespace test { + +TEST_P(BatchToSpaceLayerTest, Inference) { + run(); +}; + +} // namespace test +} // namespace ov diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_op/adaptive_pooling.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_op/adaptive_pooling.hpp new file mode 100644 index 00000000000000..5f3e5932a41a70 --- /dev/null +++ b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_op/adaptive_pooling.hpp @@ -0,0 +1,27 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include "shared_test_classes/base/ov_subgraph.hpp" + +namespace ov { +namespace test { +using adapoolParams = std::tuple< + std::vector, // feature map shape + std::vector, // pooled spatial shape + std::string, // pooling mode + ov::element::Type, // model type + std::string>; // device name + +class AdaPoolLayerTest : public testing::WithParamInterface, + virtual public ov::test::SubgraphBaseTest { +public: + static std::string getTestCaseName(const testing::TestParamInfo& obj); + +protected: + void SetUp() override; +}; +} // namespace test +} // namespace ov diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_op/batch_norm.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_op/batch_norm.hpp new file mode 100644 index 00000000000000..f28b24d088a900 --- /dev/null +++ b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_op/batch_norm.hpp @@ -0,0 +1,27 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include "shared_test_classes/base/ov_subgraph.hpp" + +namespace ov { +namespace test { +typedef std::tuple< + double, // epsilon + ov::element::Type, // Model type + std::vector, // Input shape + std::string // Target device name +> BatchNormLayerTestParams; + +class BatchNormLayerTest : public testing::WithParamInterface, + virtual public ov::test::SubgraphBaseTest { +public: + static std::string getTestCaseName(const testing::TestParamInfo& obj); +protected: + void SetUp() override; +}; + +} // namespace test +} // namespace ov diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_op/batch_to_space.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_op/batch_to_space.hpp new file mode 100644 index 00000000000000..07ac5c21542603 --- /dev/null +++ b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_op/batch_to_space.hpp @@ -0,0 +1,32 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include +#include +#include + +#include "shared_test_classes/base/ov_subgraph.hpp" + +namespace ov { +namespace test { +using batchToSpaceParamsTuple = typename std::tuple< + std::vector, // block shape + std::vector, // crops begin + std::vector, // crops end + std::vector, // Input shapes + ov::element::Type, // Model type + std::string>; // Device name>; + +class BatchToSpaceLayerTest : public testing::WithParamInterface, + virtual public ov::test::SubgraphBaseTest { +public: + static std::string getTestCaseName(const testing::TestParamInfo &obj); + +protected: + void SetUp() override; +}; +} // namespace test +} // namespace ov diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_op/comparison.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_op/comparison.hpp index 0e29e65f22c122..d3eb67f907dcb7 100644 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_op/comparison.hpp +++ b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_op/comparison.hpp @@ -26,10 +26,8 @@ typedef std::tuple< class ComparisonLayerTest : public testing::WithParamInterface, virtual public ov::test::SubgraphBaseTest { - ngraph::helpers::ComparisonTypes comparison_op_type; protected: void SetUp() override; - void generate_inputs(const std::vector& targetInputStaticShapes) override; public: static std::string getTestCaseName(const testing::TestParamInfo &obj); }; diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_op/gru_sequence.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_op/gru_sequence.hpp index 0b2b053cd4880f..507739669a22e5 100644 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_op/gru_sequence.hpp +++ b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_op/gru_sequence.hpp @@ -30,9 +30,6 @@ class GRUSequenceTest : public testing::WithParamInterface, protected: void SetUp() override; - void generate_inputs(const std::vector& targetInputStaticShapes) override; - ov::test::utils::SequenceTestsMode m_mode; - int64_t m_max_seq_len = 0; }; } // namespace test } // namespace ov diff --git a/src/tests/functional/shared_test_classes/src/base/utils/generate_inputs.cpp b/src/tests/functional/shared_test_classes/src/base/utils/generate_inputs.cpp index 369b6dedcd7a68..7a7e2bc4a89879 100644 --- a/src/tests/functional/shared_test_classes/src/base/utils/generate_inputs.cpp +++ b/src/tests/functional/shared_test_classes/src/base/utils/generate_inputs.cpp @@ -963,6 +963,51 @@ ov::runtime::Tensor generate(const return tensor; } +namespace comparison { +void fill_tensor(ov::Tensor& tensor) { + auto data_ptr = static_cast(tensor.data()); + auto data_ptr_int = static_cast(tensor.data()); + auto range = tensor.get_size(); + auto start = -static_cast(range) / 2.f; + testing::internal::Random random(1); + for (size_t i = 0; i < range; i++) { + if (i % 7 == 0) { + data_ptr[i] = std::numeric_limits::infinity(); + } else if (i % 7 == 1) { + data_ptr[i] = -std::numeric_limits::infinity(); + } else if (i % 7 == 2) { + data_ptr_int[i] = 0x7F800000 + random.Generate(range); + } else if (i % 7 == 3) { + data_ptr[i] = std::numeric_limits::quiet_NaN(); + } else if (i % 7 == 5) { + data_ptr[i] = -std::numeric_limits::quiet_NaN(); + } else { + data_ptr[i] = start + static_cast(random.Generate(range)); + } + } +} +} // namespace comparison + +ov::runtime::Tensor generate(const + std::shared_ptr& node, + size_t port, + const ov::element::Type& elemType, + const ov::Shape& targetShape) { + ov::Tensor tensor(elemType, targetShape); + comparison::fill_tensor(tensor); + return tensor; +} + +ov::runtime::Tensor generate(const + std::shared_ptr& node, + size_t port, + const ov::element::Type& elemType, + const ov::Shape& targetShape) { + ov::Tensor tensor{elemType, targetShape}; + comparison::fill_tensor(tensor); + return tensor; +} + template ov::runtime::Tensor generateInput(const std::shared_ptr& node, size_t port, diff --git a/src/tests/functional/shared_test_classes/src/single_op/adaptive_pooling.cpp b/src/tests/functional/shared_test_classes/src/single_op/adaptive_pooling.cpp new file mode 100644 index 00000000000000..17a848c8475ff1 --- /dev/null +++ b/src/tests/functional/shared_test_classes/src/single_op/adaptive_pooling.cpp @@ -0,0 +1,60 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "shared_test_classes/single_op/adaptive_pooling.hpp" + +namespace ov { +namespace test { + +std::string AdaPoolLayerTest::getTestCaseName(const testing::TestParamInfo& obj) { + std::vector shapes; + std::vector pooled_spatial_shape; + + std::string pooling_mode; + ov::element::Type model_type; + std::string target_device; + std::tie(shapes, pooled_spatial_shape, pooling_mode, model_type, target_device) = obj.param; + + std::ostringstream result; + + result << "IS=("; + for (const auto& shape : shapes) { + result << ov::test::utils::partialShape2str({shape.first}) << "_"; + } + result << ")_TS=("; + for (const auto& shape : shapes) { + for (const auto& item : shape.second) { + result << ov::test::utils::vec2str(item) << "_"; + } + } + result << "pooled_spatial_shape=" << ov::test::utils::vec2str(pooled_spatial_shape) << "_"; + result << "mode=" << pooling_mode << "_"; + result << "IT=" << model_type.get_type_name() << "_"; + result << "dev=" << target_device; + return result.str(); +} + +void AdaPoolLayerTest::SetUp() { + std::vector shapes; + std::vector pooled_spatial_shape; + std::string pooling_mode; + ov::element::Type model_type; + std::tie(shapes, pooled_spatial_shape, pooling_mode, model_type, targetDevice) = this->GetParam(); + init_input_shapes(shapes); + + ov::ParameterVector params{std::make_shared(model_type, inputDynamicShapes.front())}; + + ov::Shape pooled_shape = {pooled_spatial_shape.size()}; + auto pooled_param = std::make_shared(ov::element::i32, pooled_shape, pooled_spatial_shape); + + // we cannot create abstract Op to use polymorphism + auto adapoolMax = std::make_shared(params[0], pooled_param, ov::element::i32); + auto adapoolAvg = std::make_shared(params[0], pooled_param); + + function = (pooling_mode == "max" ? + std::make_shared(adapoolMax->outputs(), params, "AdaPoolMax") : + std::make_shared(adapoolAvg->outputs(), params, "AdaPoolAvg")); +} +} // namespace test +} // namespace ov diff --git a/src/tests/functional/shared_test_classes/src/single_op/batch_norm.cpp b/src/tests/functional/shared_test_classes/src/single_op/batch_norm.cpp new file mode 100644 index 00000000000000..f2df32ba5048f4 --- /dev/null +++ b/src/tests/functional/shared_test_classes/src/single_op/batch_norm.cpp @@ -0,0 +1,61 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "shared_test_classes/single_op/batch_norm.hpp" + +#include "common_test_utils/ov_tensor_utils.hpp" + +namespace ov { +namespace test { +std::string BatchNormLayerTest::getTestCaseName(const testing::TestParamInfo& obj) { + ov::element::Type model_type; + std::vector shapes; + double epsilon; + std::string target_device; + std::tie(epsilon, model_type, shapes, target_device) = obj.param; + + std::ostringstream result; + result << "IS=("; + for (const auto& shape : shapes) { + result << ov::test::utils::partialShape2str({shape.first}) << "_"; + } + result << ")_TS=("; + for (const auto& shape : shapes) { + for (const auto& item : shape.second) { + result << ov::test::utils::vec2str(item) << "_"; + } + } + result << "inT=" << model_type.get_type_name() << "_"; + result << "epsilon=" << epsilon << "_"; + result << "trgDev=" << target_device; + return result.str(); +} + +void BatchNormLayerTest::SetUp() { + ov::element::Type model_type; + std::vector shapes; + double epsilon; + std::tie(epsilon, model_type, shapes, targetDevice) = this->GetParam(); + init_input_shapes(shapes); + ov::ParameterVector params {std::make_shared(model_type, inputDynamicShapes.front())}; + + auto constant_shape = ov::Shape{params[0]->get_shape().at(1)}; + auto gamma_tensor = ov::test::utils::create_and_fill_tensor(model_type, constant_shape, 1, 0); + auto gamma = std::make_shared(gamma_tensor); + + auto beta_tensor = ov::test::utils::create_and_fill_tensor(model_type, constant_shape, 1, 0); + auto beta = std::make_shared(beta_tensor); + + auto mean_tensor = ov::test::utils::create_and_fill_tensor(model_type, constant_shape, 1, 0); + auto mean = std::make_shared(mean_tensor); + + // Fill the vector for variance with positive values + auto variance_tensor = ov::test::utils::create_and_fill_tensor(model_type, constant_shape, 10, 0); + auto variance = std::make_shared(variance_tensor); + auto batch_norm = std::make_shared(params[0], gamma, beta, mean, variance, epsilon); + + function = std::make_shared(ov::OutputVector{batch_norm}, params, "BatchNormInference"); +} +} // namespace test +} // namespace ov diff --git a/src/tests/functional/shared_test_classes/src/single_op/batch_to_space.cpp b/src/tests/functional/shared_test_classes/src/single_op/batch_to_space.cpp new file mode 100644 index 00000000000000..b814d07304d964 --- /dev/null +++ b/src/tests/functional/shared_test_classes/src/single_op/batch_to_space.cpp @@ -0,0 +1,53 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "shared_test_classes/single_op/batch_to_space.hpp" + +namespace ov { +namespace test { +std::string BatchToSpaceLayerTest::getTestCaseName(const testing::TestParamInfo &obj) { + std::vector shapes; + std::vector block_shape, crops_begin, crops_end; + ov::element::Type model_type; + std::string target_name; + std::tie(block_shape, crops_begin, crops_end, shapes, model_type, target_name) = obj.param; + std::ostringstream result; + result << "IS=("; + for (const auto& shape : shapes) { + result << ov::test::utils::partialShape2str({shape.first}) << "_"; + } + result << ")_TS=("; + for (const auto& shape : shapes) { + for (const auto& item : shape.second) { + result << ov::test::utils::vec2str(item) << "_"; + } + } + result << "inT=" << model_type.get_type_name() << "_"; + result << "BS=" << ov::test::utils::vec2str(block_shape) << "_"; + result << "CB=" << ov::test::utils::vec2str(crops_begin) << "_"; + result << "CE=" << ov::test::utils::vec2str(crops_end) << "_"; + result << "trgDev=" << target_name << "_"; + return result.str(); +} + +void BatchToSpaceLayerTest::SetUp() { + std::vector shapes; + std::vector block_shape, crops_begin, crops_end; + ov::element::Type model_type; + std::tie(block_shape, crops_begin, crops_end, shapes, model_type, targetDevice) = this->GetParam(); + init_input_shapes(shapes); + + ov::ParameterVector params{std::make_shared(model_type, inputDynamicShapes.front())}; + + auto const_shape = ov::Shape{inputDynamicShapes.front().size()}; + auto block_shape_node = std::make_shared(ov::element::i64, const_shape, block_shape.data()); + auto crops_begin_node = std::make_shared(ov::element::i64, const_shape, crops_begin.data()); + auto crops_end_node = std::make_shared(ov::element::i64, const_shape, crops_end.data()); + + auto b2s = std::make_shared(params[0], block_shape_node, crops_begin_node, crops_end_node); + ov::OutputVector results{std::make_shared(b2s)}; + function = std::make_shared(results, params, "BatchToSpace"); +} +} // namespace test +} // namespace ov diff --git a/src/tests/functional/shared_test_classes/src/single_op/comparison.cpp b/src/tests/functional/shared_test_classes/src/single_op/comparison.cpp index 7dacd12bc9d74c..f7ea71c95bb4b3 100644 --- a/src/tests/functional/shared_test_classes/src/single_op/comparison.cpp +++ b/src/tests/functional/shared_test_classes/src/single_op/comparison.cpp @@ -51,6 +51,7 @@ void ComparisonLayerTest::SetUp() { InputLayerType second_input_type; std::map additional_config; ov::element::Type model_type; + ngraph::helpers::ComparisonTypes comparison_op_type; std::tie(shapes, comparison_op_type, second_input_type, @@ -74,40 +75,5 @@ void ComparisonLayerTest::SetUp() { auto comparisonNode = ngraph::builder::makeComparison(inputs[0], second_input, comparison_op_type); function = std::make_shared(comparisonNode, inputs, "Comparison"); } - -void ComparisonLayerTest::generate_inputs(const std::vector& target_input_static_shapes) { - if (comparison_op_type == ComparisonTypes::IS_FINITE || comparison_op_type == ComparisonTypes::IS_NAN) { - inputs.clear(); - auto params = function->get_parameters(); - OPENVINO_ASSERT(target_input_static_shapes.size() >= params.size()); - for (int i = 0; i < params.size(); i++) { - ov::Tensor tensor(params[i]->get_element_type(), target_input_static_shapes[i]); - auto data_ptr = static_cast(tensor.data()); - auto data_ptr_int = static_cast(tensor.data()); - auto range = tensor.get_size(); - auto start = -static_cast(range) / 2.f; - testing::internal::Random random(1); - for (size_t i = 0; i < range; i++) { - if (i % 7 == 0) { - data_ptr[i] = std::numeric_limits::infinity(); - } else if (i % 7 == 1) { - data_ptr[i] = -std::numeric_limits::infinity(); - } else if (i % 7 == 2) { - data_ptr_int[i] = 0x7F800000 + random.Generate(range); - } else if (i % 7 == 3) { - data_ptr[i] = std::numeric_limits::quiet_NaN(); - } else if (i % 7 == 5) { - data_ptr[i] = -std::numeric_limits::quiet_NaN(); - } else { - data_ptr[i] = start + static_cast(random.Generate(range)); - } - } - inputs.insert({params[i], tensor}); - } - } else { - SubgraphBaseTest::generate_inputs(target_input_static_shapes); - } -} - } // namespace test } // namespace ov diff --git a/src/tests/functional/shared_test_classes/src/single_op/gru_sequence.cpp b/src/tests/functional/shared_test_classes/src/single_op/gru_sequence.cpp index 54e7140830d2ec..e98b04c5aa8ffc 100644 --- a/src/tests/functional/shared_test_classes/src/single_op/gru_sequence.cpp +++ b/src/tests/functional/shared_test_classes/src/single_op/gru_sequence.cpp @@ -61,7 +61,8 @@ void GRUSequenceTest::SetUp() { bool linear_before_reset; ov::op::RecurrentSequenceDirection direction; InputLayerType wbr_type; - std::tie(m_mode, shapes, activations, clip, linear_before_reset, direction, wbr_type, + ov::test::utils::SequenceTestsMode mode; + std::tie(mode, shapes, activations, clip, linear_before_reset, direction, wbr_type, inType, targetDevice) = this->GetParam(); outType = inType; init_input_shapes(shapes); @@ -87,15 +88,15 @@ void GRUSequenceTest::SetUp() { const auto& b_shape = ov::Shape{num_directions, (linear_before_reset ? 4 : 3) * hidden_size}; std::shared_ptr seq_lengths_node; - if (m_mode == SequenceTestsMode::CONVERT_TO_TI_MAX_SEQ_LEN_PARAM || - m_mode == SequenceTestsMode::CONVERT_TO_TI_RAND_SEQ_LEN_PARAM || - m_mode == SequenceTestsMode::PURE_SEQ_RAND_SEQ_LEN_PARAM) { + if (mode == SequenceTestsMode::CONVERT_TO_TI_MAX_SEQ_LEN_PARAM || + mode == SequenceTestsMode::CONVERT_TO_TI_RAND_SEQ_LEN_PARAM || + mode == SequenceTestsMode::PURE_SEQ_RAND_SEQ_LEN_PARAM) { auto param = std::make_shared(ov::element::i64, inputDynamicShapes[2]); param->set_friendly_name("seq_lengths"); params.push_back(param); seq_lengths_node = param; - } else if (m_mode == SequenceTestsMode::CONVERT_TO_TI_RAND_SEQ_LEN_CONST || - m_mode == SequenceTestsMode::PURE_SEQ_RAND_SEQ_LEN_CONST) { + } else if (mode == SequenceTestsMode::CONVERT_TO_TI_RAND_SEQ_LEN_CONST || + mode == SequenceTestsMode::PURE_SEQ_RAND_SEQ_LEN_CONST) { auto tensor = ov::test::utils::create_and_fill_tensor(ov::element::i64, targetStaticShapes[0][2], seq_lengths, 0); seq_lengths_node = std::make_shared(tensor); } else { @@ -131,9 +132,9 @@ void GRUSequenceTest::SetUp() { std::make_shared(gru_sequence->output(1))}; function = std::make_shared(results, params, "gru_sequence"); - bool is_pure_sequence = (m_mode == SequenceTestsMode::PURE_SEQ || - m_mode == SequenceTestsMode::PURE_SEQ_RAND_SEQ_LEN_PARAM || - m_mode == SequenceTestsMode::PURE_SEQ_RAND_SEQ_LEN_CONST); + bool is_pure_sequence = (mode == SequenceTestsMode::PURE_SEQ || + mode == SequenceTestsMode::PURE_SEQ_RAND_SEQ_LEN_PARAM || + mode == SequenceTestsMode::PURE_SEQ_RAND_SEQ_LEN_CONST); if (!is_pure_sequence) { ov::pass::Manager manager; if (direction == ov::op::RecurrentSequenceDirection::BIDIRECTIONAL) @@ -147,15 +148,5 @@ void GRUSequenceTest::SetUp() { EXPECT_EQ(ti_found, false); } } - -void GRUSequenceTest::generate_inputs(const std::vector& target_input_static_shapes) { - inputs.clear(); - auto params = function->get_parameters(); - OPENVINO_ASSERT(target_input_static_shapes.size() >= params.size()); - for (int i = 0; i < params.size(); i++) { - auto tensor = ov::test::utils::create_and_fill_tensor(params[i]->get_element_type(), target_input_static_shapes[i], m_max_seq_len, 0); - inputs.insert({params[i], tensor}); - } -} } // namespace test } // namespace ov From 9c908f5245588ee677bdeacec796d21059be7453 Mon Sep 17 00:00:00 2001 From: Ilya Churaev Date: Tue, 19 Sep 2023 11:46:11 +0400 Subject: [PATCH 25/30] Migrate template backend to new api (#19843) * Added set_element_type for tensor * Moved template backend to new API * Revert "Added set_element_type for tensor" This reverts commit 27608d2ea0acdf0f9fe3504b95e83f988f63c3a9. * Fixed build * Fixed more errors * Fixed loop implementation * Fixed ONNX tests * Small change * Fixed set_shape for host tensor * Fixed ReadValue Assign tests * Fixed template tests * Fixed build * Fix Windows build * Fixed more errors * Fixed CTCLoss * Fixed comments * Removed all comments * Fixed tensors update * Try to fix tests --- src/core/CMakeLists.txt | 1 + src/core/include/openvino/op/loop.hpp | 5 +- src/core/reference/CMakeLists.txt | 1 + .../include/openvino/reference/abs.hpp | 1 + .../openvino/reference/adaptive_max_pool.hpp | 1 + .../openvino/reference/convert_color_nv12.hpp | 60 +- .../include/openvino/reference/ctc_loss.hpp | 2 + .../include/openvino/reference/einsum.hpp | 2 +- .../include/openvino/reference/fft.hpp | 10 +- .../include/openvino/reference/function.hpp | 2 +- .../openvino/reference/hard_sigmoid.hpp | 1 + .../include/openvino/reference/if.hpp | 4 +- .../include/openvino/reference/is_finite.hpp | 1 + .../include/openvino/reference/is_inf.hpp | 3 + .../include/openvino/reference/is_nan.hpp | 1 + .../include/openvino/reference/loop.hpp | 4 +- .../include/openvino/reference/lstm_cell.hpp | 1 + .../reference/non_max_suppression.hpp | 4 +- .../openvino/reference/roi_pooling.hpp | 3 + .../openvino/reference/tensor_iterator.hpp | 11 +- src/core/reference/src/op/einsum.cpp | 377 ++++---- src/core/reference/src/op/fft.cpp | 13 +- src/core/reference/src/op/function.cpp | 11 +- src/core/reference/src/op/if.cpp | 15 +- src/core/reference/src/op/loop.cpp | 86 +- .../reference/src/op/non_max_suppression.cpp | 46 +- src/core/reference/src/op/tensor_iterator.cpp | 48 +- src/core/reference/src/op/tile.cpp | 2 - src/core/src/node.cpp | 9 +- src/core/src/op/loop.cpp | 5 +- src/core/src/runtime/host_tensor.cpp | 12 +- src/inference/src/dev/make_tensor.cpp | 2 + src/plugins/template/backend/backend.cpp | 2 - .../template/backend/evaluates_map.cpp | 64 +- .../template/backend/evaluates_map.hpp | 26 +- src/plugins/template/backend/executable.hpp | 4 +- .../template/backend/int_executable.cpp | 77 +- .../template/backend/int_executable.hpp | 5 +- src/plugins/template/backend/ops/abs.cpp | 92 +- .../backend/ops/adaptive_avg_pool.cpp | 123 +-- .../backend/ops/adaptive_max_pool.cpp | 143 ++- src/plugins/template/backend/ops/assign.cpp | 60 +- src/plugins/template/backend/ops/avg_pool.cpp | 93 +- .../template/backend/ops/batch_norm.cpp | 260 ++--- .../backend/ops/binary_convolution.cpp | 147 ++- .../template/backend/ops/bucketize.cpp | 271 +++--- src/plugins/template/backend/ops/ceiling.cpp | 91 +- src/plugins/template/backend/ops/convert.cpp | 208 ++-- .../backend/ops/convert_color_nv12.cpp | 403 +++----- .../template/backend/ops/convolution.cpp | 148 ++- .../backend/ops/convolution_backprop_data.cpp | 158 ++- .../backend/ops/ctc_greedy_decoder.cpp | 129 +-- .../ops/ctc_greedy_decoder_seq_len.cpp | 203 ++-- src/plugins/template/backend/ops/ctc_loss.cpp | 162 ++-- src/plugins/template/backend/ops/cum_sum.cpp | 113 ++- .../backend/ops/deformable_convolution.cpp | 367 +++---- .../backend/ops/deformable_psroi_pooling.cpp | 161 ++- .../template/backend/ops/detection_output.cpp | 274 ++---- src/plugins/template/backend/ops/einsum.cpp | 82 +- src/plugins/template/backend/ops/elu.cpp | 89 +- .../backend/ops/embedding_bag_offsets_sum.cpp | 155 ++- .../backend/ops/embedding_bag_packed_sum.cpp | 156 ++- .../backend/ops/embedding_segments_sum.cpp | 155 ++- src/plugins/template/backend/ops/equal.cpp | 105 +- .../template/backend/ops/evaluate_node.hpp | 82 +- src/plugins/template/backend/ops/exp.cpp | 87 +- ...xperimental_detectron_detection_output.cpp | 198 ++-- ...imental_detectron_prior_grid_generator.cpp | 207 ++-- ...mental_detectron_proposal_single_image.cpp | 142 ++- ...mental_detectron_roi_feature_extractor.cpp | 201 ++-- .../ops/experimental_detectron_topk_rois.cpp | 177 ++-- .../backend/ops/extract_image_patches.cpp | 153 ++- src/plugins/template/backend/ops/fft.cpp | 182 ++-- src/plugins/template/backend/ops/gather.cpp | 103 +- .../template/backend/ops/gather_elements.cpp | 151 ++- .../template/backend/ops/gather_nd.cpp | 234 +++-- .../template/backend/ops/gather_tree.cpp | 97 +- src/plugins/template/backend/ops/gelu.cpp | 180 ++-- .../backend/ops/generate_proposal.cpp | 144 ++- src/plugins/template/backend/ops/greater.cpp | 106 +- .../template/backend/ops/grid_sample.cpp | 130 +-- src/plugins/template/backend/ops/grn.cpp | 88 +- .../backend/ops/group_convolution.cpp | 148 ++- .../ops/group_convolution_backprop_data.cpp | 199 ++-- .../backend/ops/group_normalization.cpp | 41 +- src/plugins/template/backend/ops/gru_cell.cpp | 248 ++--- .../template/backend/ops/hard_sigmoid.cpp | 132 +-- src/plugins/template/backend/ops/if.cpp | 154 +-- .../template/backend/ops/interpolate.cpp | 340 +++---- src/plugins/template/backend/ops/irdft.cpp | 101 +- .../template/backend/ops/is_finite.cpp | 146 ++- src/plugins/template/backend/ops/is_inf.cpp | 125 ++- src/plugins/template/backend/ops/is_nan.cpp | 121 ++- src/plugins/template/backend/ops/log.cpp | 87 +- .../template/backend/ops/log_softmax.cpp | 125 +-- src/plugins/template/backend/ops/lrn.cpp | 89 +- .../template/backend/ops/lstm_cell.cpp | 237 +++-- .../template/backend/ops/matrix_nms.cpp | 189 ++-- src/plugins/template/backend/ops/mod.cpp | 93 +- .../template/backend/ops/multiclass_nms.cpp | 271 ++---- src/plugins/template/backend/ops/mvn.cpp | 194 ++-- .../backend/ops/non_max_suppression.cpp | 913 +++++++----------- .../template/backend/ops/normalize_l2.cpp | 121 +-- .../template/backend/ops/ops_evaluates.hpp | 792 ++++++++------- src/plugins/template/backend/ops/pad.cpp | 93 +- src/plugins/template/backend/ops/prelu.cpp | 95 +- src/plugins/template/backend/ops/proposal.cpp | 214 ++-- .../template/backend/ops/psroi_pooling.cpp | 101 +- src/plugins/template/backend/ops/rdft.cpp | 100 +- .../template/backend/ops/read_value.cpp | 80 +- .../template/backend/ops/region_yolo.cpp | 123 +-- src/plugins/template/backend/ops/relu.cpp | 87 +- .../template/backend/ops/reorg_yolo.cpp | 83 +- .../template/backend/ops/reverse_sequence.cpp | 185 ++-- src/plugins/template/backend/ops/rnn_cell.cpp | 109 +-- .../template/backend/ops/roi_align.cpp | 108 +-- .../template/backend/ops/roi_pooling.cpp | 128 +-- src/plugins/template/backend/ops/roll.cpp | 96 +- .../backend/ops/scatter_nd_update.cpp | 137 +-- src/plugins/template/backend/ops/selu.cpp | 97 +- .../template/backend/ops/sequences.cpp | 847 +++++++--------- src/plugins/template/backend/ops/sigmoid.cpp | 91 +- src/plugins/template/backend/ops/sign.cpp | 87 +- src/plugins/template/backend/ops/softsign.cpp | 121 ++- .../backend/ops/squared_difference.cpp | 127 +-- src/plugins/template/backend/ops/tanh.cpp | 92 +- .../template/backend/ops/tensor_iterator.cpp | 130 +-- src/plugins/template/backend/ops/unique.cpp | 137 ++- .../template/backend/opset_int_tbl.hpp | 54 +- 129 files changed, 7002 insertions(+), 9318 deletions(-) diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 03580613532e7b..c12a30d5a6f639 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -8,6 +8,7 @@ set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE ${ENABLE_LTO}) add_definitions(-DIN_OV_CORE_LIBRARY) set(OV_CORE_INCLUDE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/include) +set(OV_CORE_DEV_API_PATH ${CMAKE_CURRENT_SOURCE_DIR}/dev_api) file(GLOB_RECURSE LIBRARY_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/*.hpp) diff --git a/src/core/include/openvino/op/loop.hpp b/src/core/include/openvino/op/loop.hpp index cb174d588b7bc3..c1ad30e5308e4a 100644 --- a/src/core/include/openvino/op/loop.hpp +++ b/src/core/include/openvino/op/loop.hpp @@ -10,6 +10,7 @@ #include "openvino/op/constant.hpp" #include "openvino/op/parameter.hpp" #include "openvino/op/util/sub_graph_base.hpp" +#include "openvino/runtime/tensor.hpp" namespace ov { namespace op { @@ -61,9 +62,7 @@ class OPENVINO_API Loop : public op::util::SubGraphOp { bool visit_attributes(AttributeVisitor& visitor) override; std::shared_ptr clone_with_new_inputs(const OutputVector& new_args) const override; - OPENVINO_SUPPRESS_DEPRECATED_START - bool evaluate(const HostTensorVector& outputs, const HostTensorVector& inputs) const override; - OPENVINO_SUPPRESS_DEPRECATED_END + bool evaluate(ov::TensorVector& outputs, const ov::TensorVector& inputs) const override; bool has_evaluate() const override; protected: diff --git a/src/core/reference/CMakeLists.txt b/src/core/reference/CMakeLists.txt index dbd126d84a4bf0..0a6c16313d7ccb 100644 --- a/src/core/reference/CMakeLists.txt +++ b/src/core/reference/CMakeLists.txt @@ -35,6 +35,7 @@ endif() target_include_directories(${TARGET_NAME} PUBLIC $ + $ $) target_include_directories(${TARGET_NAME} SYSTEM PRIVATE diff --git a/src/core/reference/include/openvino/reference/abs.hpp b/src/core/reference/include/openvino/reference/abs.hpp index c58e70c5b4de02..426634a63a2d34 100644 --- a/src/core/reference/include/openvino/reference/abs.hpp +++ b/src/core/reference/include/openvino/reference/abs.hpp @@ -4,6 +4,7 @@ #pragma once +#include #include #include diff --git a/src/core/reference/include/openvino/reference/adaptive_max_pool.hpp b/src/core/reference/include/openvino/reference/adaptive_max_pool.hpp index 9aa0c3afa2af83..69c8ef2c940834 100644 --- a/src/core/reference/include/openvino/reference/adaptive_max_pool.hpp +++ b/src/core/reference/include/openvino/reference/adaptive_max_pool.hpp @@ -10,6 +10,7 @@ #include "ngraph/axis_vector.hpp" #include "ngraph/shape.hpp" +#include "openvino/reference/adaptive_avg_pool.hpp" namespace ov { namespace reference { diff --git a/src/core/reference/include/openvino/reference/convert_color_nv12.hpp b/src/core/reference/include/openvino/reference/convert_color_nv12.hpp index 4e8db24eb29668..a42aff6184c17f 100644 --- a/src/core/reference/include/openvino/reference/convert_color_nv12.hpp +++ b/src/core/reference/include/openvino/reference/convert_color_nv12.hpp @@ -107,12 +107,12 @@ void color_convert_i420(const T* arg_y, } } -OPENVINO_SUPPRESS_DEPRECATED_START -template +template inline bool color_convert_nv12(const std::shared_ptr& op, - const ov::HostTensorVector& outputs, - const ov::HostTensorVector& inputs, + ov::TensorVector& outputs, + const ov::TensorVector& inputs, ov::op::util::ConvertColorNV12Base::ColorConversion type) { + using ET = typename ov::element_type_traits::value_type; static const size_t N_DIM = 0; static const size_t H_DIM = 1; static const size_t W_DIM = 2; @@ -122,17 +122,17 @@ inline bool color_convert_nv12(const std::shared_ptr& op, auto single_plane = op->get_input_size() == 1; const auto& y_tensor = inputs[0]; - auto batch_size = y_tensor->get_shape()[N_DIM]; - auto image_w = y_tensor->get_shape()[W_DIM]; - auto image_h = y_tensor->get_shape()[H_DIM]; + auto batch_size = y_tensor.get_shape()[N_DIM]; + auto image_w = y_tensor.get_shape()[W_DIM]; + auto image_h = y_tensor.get_shape()[H_DIM]; if (single_plane) { image_h = image_h * 2 / 3; } - outputs[0]->set_shape({batch_size, image_h, image_w, 3}); // 3 is RGB + outputs[0].set_shape({batch_size, image_h, image_w, 3}); // 3 is RGB if (single_plane) { - color_convert_nv12(y_tensor->get_data_ptr(), - y_tensor->get_data_ptr() + image_w * image_h, - outputs[0]->get_data_ptr(), + color_convert_nv12(y_tensor.data(), + y_tensor.data() + image_w * image_h, + outputs[0].data(), batch_size, image_h, image_w, @@ -141,9 +141,9 @@ inline bool color_convert_nv12(const std::shared_ptr& op, type); } else { const auto& uv_tensor = inputs[1]; - color_convert_nv12(y_tensor->get_data_ptr(), - uv_tensor->get_data_ptr(), - outputs[0]->get_data_ptr(), + color_convert_nv12(y_tensor.data(), + uv_tensor.data(), + outputs[0].data(), batch_size, image_h, image_w, @@ -154,11 +154,12 @@ inline bool color_convert_nv12(const std::shared_ptr& op, return true; } -template +template inline bool color_convert_i420(const std::shared_ptr& op, - const ov::HostTensorVector& outputs, - const ov::HostTensorVector& inputs, + ov::TensorVector& outputs, + const ov::TensorVector& inputs, ov::op::util::ConvertColorI420Base::ColorConversion type) { + using ET = typename ov::element_type_traits::value_type; static const size_t N_DIM = 0; static const size_t H_DIM = 1; static const size_t W_DIM = 2; @@ -168,18 +169,18 @@ inline bool color_convert_i420(const std::shared_ptr& op, auto single_plane = op->get_input_size() == 1; const auto& y_tensor = inputs[0]; - auto batch_size = y_tensor->get_shape()[N_DIM]; - auto image_w = y_tensor->get_shape()[W_DIM]; - auto image_h = y_tensor->get_shape()[H_DIM]; + auto batch_size = y_tensor.get_shape()[N_DIM]; + auto image_w = y_tensor.get_shape()[W_DIM]; + auto image_h = y_tensor.get_shape()[H_DIM]; if (single_plane) { image_h = image_h * 2 / 3; } - outputs[0]->set_shape({batch_size, image_h, image_w, 3}); // 3 is RGB + outputs[0].set_shape({batch_size, image_h, image_w, 3}); // 3 is RGB if (single_plane) { - color_convert_i420(y_tensor->get_data_ptr(), - y_tensor->get_data_ptr() + image_w * image_h, - y_tensor->get_data_ptr() + 5 * image_w * image_h / 4, - outputs[0]->get_data_ptr(), + color_convert_i420(y_tensor.data(), + y_tensor.data() + image_w * image_h, + y_tensor.data() + 5 * image_w * image_h / 4, + outputs[0].data(), batch_size, image_h, image_w, @@ -189,10 +190,10 @@ inline bool color_convert_i420(const std::shared_ptr& op, } else { const auto& u_tensor = inputs[1]; const auto& v_tensor = inputs[2]; - color_convert_i420(y_tensor->get_data_ptr(), - u_tensor->get_data_ptr(), - v_tensor->get_data_ptr(), - outputs[0]->get_data_ptr(), + color_convert_i420(y_tensor.data(), + u_tensor.data(), + v_tensor.data(), + outputs[0].data(), batch_size, image_h, image_w, @@ -203,6 +204,5 @@ inline bool color_convert_i420(const std::shared_ptr& op, return true; } -OPENVINO_SUPPRESS_DEPRECATED_END } // namespace reference } // namespace ov diff --git a/src/core/reference/include/openvino/reference/ctc_loss.hpp b/src/core/reference/include/openvino/reference/ctc_loss.hpp index 03fae356ad69a7..1b16b352eb4870 100644 --- a/src/core/reference/include/openvino/reference/ctc_loss.hpp +++ b/src/core/reference/include/openvino/reference/ctc_loss.hpp @@ -6,6 +6,8 @@ #include +#include + #include "ngraph/shape_util.hpp" namespace ov { diff --git a/src/core/reference/include/openvino/reference/einsum.hpp b/src/core/reference/include/openvino/reference/einsum.hpp index 667a923739ce9c..8e477959bcba37 100644 --- a/src/core/reference/include/openvino/reference/einsum.hpp +++ b/src/core/reference/include/openvino/reference/einsum.hpp @@ -11,6 +11,6 @@ namespace ov { namespace reference { -void einsum(const HostTensorVector& outputs, const HostTensorVector& inputs, const std::string& equation); +void einsum(ov::TensorVector& outputs, const ov::TensorVector& inputs, const std::string& equation); } // namespace reference } // namespace ov diff --git a/src/core/reference/include/openvino/reference/fft.hpp b/src/core/reference/include/openvino/reference/fft.hpp index f35ef8ce79b981..474da3734157ed 100644 --- a/src/core/reference/include/openvino/reference/fft.hpp +++ b/src/core/reference/include/openvino/reference/fft.hpp @@ -23,13 +23,9 @@ #include #include #include -#include #include -#include "ngraph/node.hpp" -#include "ngraph/op/util/op_types.hpp" -#include "ngraph/ops.hpp" -#include "ngraph/shape_util.hpp" +#include "openvino/runtime/tensor.hpp" namespace ov { namespace reference { @@ -43,8 +39,8 @@ void fft(const float* input_data, const Shape& output_shape, FFTKind fft_kind); -void fft_postprocessing(const HostTensorVector& outputs, - const ngraph::element::Type output_type, +void fft_postprocessing(ov::TensorVector& outputs, + const ov::element::Type output_type, const std::vector& fft_result); std::vector canonicalize_axes(const int64_t* axes_data, diff --git a/src/core/reference/include/openvino/reference/function.hpp b/src/core/reference/include/openvino/reference/function.hpp index 575821e81b4a0f..24c10da48b40b8 100644 --- a/src/core/reference/include/openvino/reference/function.hpp +++ b/src/core/reference/include/openvino/reference/function.hpp @@ -12,6 +12,6 @@ namespace ov { namespace reference { -void function(const std::shared_ptr& function, const HostTensorVector& inputs, HostTensorVector& outputs); +void function(const std::shared_ptr& function, const ov::TensorVector& inputs, ov::TensorVector& outputs); } } // namespace ov diff --git a/src/core/reference/include/openvino/reference/hard_sigmoid.hpp b/src/core/reference/include/openvino/reference/hard_sigmoid.hpp index 4dd92870791bdb..dd2cb98df1da4c 100644 --- a/src/core/reference/include/openvino/reference/hard_sigmoid.hpp +++ b/src/core/reference/include/openvino/reference/hard_sigmoid.hpp @@ -4,6 +4,7 @@ #pragma once +#include #include #include diff --git a/src/core/reference/include/openvino/reference/if.hpp b/src/core/reference/include/openvino/reference/if.hpp index aaa47d0624ba29..27fc71ed393027 100644 --- a/src/core/reference/include/openvino/reference/if.hpp +++ b/src/core/reference/include/openvino/reference/if.hpp @@ -13,7 +13,7 @@ namespace reference { void if_reference(const std::vector>& body, const std::vector& out_descs, const std::vector& input_descs, - const HostTensorVector& out, - const HostTensorVector& args); + ov::TensorVector& out, + const ov::TensorVector& args); } } // namespace ov diff --git a/src/core/reference/include/openvino/reference/is_finite.hpp b/src/core/reference/include/openvino/reference/is_finite.hpp index 21677d0f9f9066..302da8485d3c83 100644 --- a/src/core/reference/include/openvino/reference/is_finite.hpp +++ b/src/core/reference/include/openvino/reference/is_finite.hpp @@ -4,6 +4,7 @@ #pragma once +#include #include #include diff --git a/src/core/reference/include/openvino/reference/is_inf.hpp b/src/core/reference/include/openvino/reference/is_inf.hpp index 156dafcfe6e9b0..210248ff2fcd2b 100644 --- a/src/core/reference/include/openvino/reference/is_inf.hpp +++ b/src/core/reference/include/openvino/reference/is_inf.hpp @@ -4,9 +4,12 @@ #pragma once +#include #include #include +#include "openvino/op/is_inf.hpp" + namespace ov { namespace reference { template diff --git a/src/core/reference/include/openvino/reference/is_nan.hpp b/src/core/reference/include/openvino/reference/is_nan.hpp index 47eed0e9944800..7b96e3abb08a79 100644 --- a/src/core/reference/include/openvino/reference/is_nan.hpp +++ b/src/core/reference/include/openvino/reference/is_nan.hpp @@ -4,6 +4,7 @@ #pragma once +#include #include #include diff --git a/src/core/reference/include/openvino/reference/loop.hpp b/src/core/reference/include/openvino/reference/loop.hpp index f233aaf0089576..19e16c2067d564 100644 --- a/src/core/reference/include/openvino/reference/loop.hpp +++ b/src/core/reference/include/openvino/reference/loop.hpp @@ -15,7 +15,7 @@ void loop(const std::shared_ptr& body, const op::util::OutputDescriptionVector& out_descs, const op::util::InputDescriptionVector& input_descs, const op::v5::Loop::SpecialBodyPorts& special_ports, - const HostTensorVector& out, - const HostTensorVector& args); + ov::TensorVector& out, + const ov::TensorVector& args); } } // namespace ov diff --git a/src/core/reference/include/openvino/reference/lstm_cell.hpp b/src/core/reference/include/openvino/reference/lstm_cell.hpp index b82eef98ba95d6..1a21f21cb3e497 100644 --- a/src/core/reference/include/openvino/reference/lstm_cell.hpp +++ b/src/core/reference/include/openvino/reference/lstm_cell.hpp @@ -6,6 +6,7 @@ #include +#include "openvino/op/lstm_cell.hpp" #include "openvino/reference/add.hpp" #include "openvino/reference/clamp.hpp" #include "openvino/reference/matmul.hpp" diff --git a/src/core/reference/include/openvino/reference/non_max_suppression.hpp b/src/core/reference/include/openvino/reference/non_max_suppression.hpp index ca4d9ef49c2955..b9e37e28c6a365 100644 --- a/src/core/reference/include/openvino/reference/non_max_suppression.hpp +++ b/src/core/reference/include/openvino/reference/non_max_suppression.hpp @@ -36,7 +36,7 @@ void non_max_suppression5(const float* boxes_data, int64_t* valid_outputs, const bool sort_result_descending); -void nms5_postprocessing(const HostTensorVector& outputs, +void nms5_postprocessing(ov::TensorVector& outputs, const ngraph::element::Type output_type, const std::vector& selected_indices, const std::vector& selected_scores, @@ -58,7 +58,7 @@ void non_max_suppression(const float* boxes_data, int64_t* valid_outputs, const bool sort_result_descending); -void nms_postprocessing(const HostTensorVector& outputs, +void nms_postprocessing(ov::TensorVector& outputs, const ngraph::element::Type output_type, const std::vector& selected_indices, const std::vector& selected_scores, diff --git a/src/core/reference/include/openvino/reference/roi_pooling.hpp b/src/core/reference/include/openvino/reference/roi_pooling.hpp index 7efa4daf38467d..5dbe13d1de51b6 100644 --- a/src/core/reference/include/openvino/reference/roi_pooling.hpp +++ b/src/core/reference/include/openvino/reference/roi_pooling.hpp @@ -4,6 +4,9 @@ #pragma once +#include +#include + #include "ngraph/shape.hpp" namespace ov { diff --git a/src/core/reference/include/openvino/reference/tensor_iterator.hpp b/src/core/reference/include/openvino/reference/tensor_iterator.hpp index f4ff4d8919ee76..05a66f2e640eb3 100644 --- a/src/core/reference/include/openvino/reference/tensor_iterator.hpp +++ b/src/core/reference/include/openvino/reference/tensor_iterator.hpp @@ -5,18 +5,21 @@ #pragma once #include -#include + +#include "openvino/core/model.hpp" +#include "openvino/op/util/sub_graph_base.hpp" +#include "openvino/runtime/tensor.hpp" namespace ov { namespace reference { using custom_evaluate_function = std::function< - void(const std::shared_ptr& function, const HostTensorVector& inputs, HostTensorVector& outputs)>; + void(const std::shared_ptr& function, const ov::TensorVector& inputs, ov::TensorVector& outputs)>; void tensor_iterator(uint64_t num_iterations, const std::shared_ptr& body, const op::util::OutputDescriptionVector& out_descs, const op::util::InputDescriptionVector& input_descs, - const HostTensorVector& out, - const HostTensorVector& args, + ov::TensorVector& out, + const ov::TensorVector& args, const custom_evaluate_function& evaluate = nullptr); } // namespace reference } // namespace ov diff --git a/src/core/reference/src/op/einsum.cpp b/src/core/reference/src/op/einsum.cpp index 1901073f184a8a..125e33e3aa6b49 100644 --- a/src/core/reference/src/op/einsum.cpp +++ b/src/core/reference/src/op/einsum.cpp @@ -5,9 +5,8 @@ #include "openvino/reference/einsum.hpp" #include -#include -#include "ngraph/shape.hpp" +#include "openvino/op/einsum.hpp" #include "openvino/reference/broadcast.hpp" #include "openvino/reference/matmul.hpp" #include "openvino/reference/multiply.hpp" @@ -16,7 +15,6 @@ #include "openvino/reference/transpose.hpp" #include "openvino/reference/utils/span.hpp" -NGRAPH_SUPPRESS_DEPRECATED_START namespace ov { namespace reference { namespace { @@ -27,7 +25,7 @@ namespace { std::vector> compute_einsum_path(size_t num_inputs) { // TODO: implement algorithm for finding (pseudo-)optimal einsum_path std::vector> einsum_path; - NGRAPH_CHECK(num_inputs > 0); + OPENVINO_ASSERT(num_inputs > 0); for (size_t input_ind = num_inputs - 1; input_ind > 0; --input_ind) { einsum_path.push_back(std::make_pair(0, input_ind)); } @@ -96,7 +94,7 @@ std::string generate_grouping_subscript(const std::string& input_subscript, return input_subscript; } - auto labels = ngraph::opset7::Einsum::extract_labels(input_subscript); + auto labels = ov::op::v7::Einsum::extract_labels(input_subscript); std::string required_subscript = ""; for (auto index : labels_inds) { required_subscript += labels[index]; @@ -108,15 +106,15 @@ std::string generate_grouping_subscript(const std::string& input_subscript, std::unordered_map compute_label_dim_map(const Rank& input_rank, const std::string& input_subscript) { constexpr char ellipsis[] = "..."; - auto labels = ngraph::opset7::Einsum::extract_labels(input_subscript); + auto labels = ov::op::v7::Einsum::extract_labels(input_subscript); size_t input_rank_length = labels.size(); - NGRAPH_CHECK(input_rank.is_static() || (std::find(labels.begin(), labels.end(), ellipsis) == labels.end()), - "Input rank cannot be dynamic in case of ellipsis in input subscript"); + OPENVINO_ASSERT(input_rank.is_static() || (std::find(labels.begin(), labels.end(), ellipsis) == labels.end()), + "Input rank cannot be dynamic in case of ellipsis in input subscript"); if (input_rank.is_static()) { input_rank_length = input_rank.get_length(); } std::unordered_map resulted_map; - NGRAPH_CHECK(input_rank_length >= labels.size()); + OPENVINO_ASSERT(input_rank_length >= labels.size()); size_t num_broadcasted_dims = input_rank_length - labels.size() + 1; size_t current_dim = 0; @@ -146,7 +144,7 @@ std::unordered_map compute_label_dim_map(const Ran /// range [s_begin;s_end) /// Shape compute_sub_shape(const Shape& input_shape, size_t begin, size_t end, bool is_product = false) { - NGRAPH_CHECK(end <= input_shape.size()); + OPENVINO_ASSERT(end <= input_shape.size()); if (end <= begin) { // return empty shape return Shape(); @@ -179,17 +177,17 @@ void compute_ranges(const Rank& input_rank, constexpr char ellipsis[] = "..."; size_t common_rank = common_labels.size(); if (std::find(common_labels.begin(), common_labels.end(), ellipsis) != common_labels.end()) { - NGRAPH_CHECK(label_to_dim_map.find(ellipsis) != label_to_dim_map.end()); + OPENVINO_ASSERT(label_to_dim_map.find(ellipsis) != label_to_dim_map.end()); common_rank += label_to_dim_map[ellipsis].size() - 1; } size_t sep_rank = sep_labels.size(); if (std::find(sep_labels.begin(), sep_labels.end(), ellipsis) != sep_labels.end()) { - NGRAPH_CHECK(label_to_dim_map.find(ellipsis) != label_to_dim_map.end()); + OPENVINO_ASSERT(label_to_dim_map.find(ellipsis) != label_to_dim_map.end()); sep_rank += label_to_dim_map[ellipsis].size() - 1; } size_t reduced_rank = reduced_labels.size(); if (std::find(reduced_labels.begin(), reduced_labels.end(), ellipsis) != reduced_labels.end()) { - NGRAPH_CHECK(label_to_dim_map.find(ellipsis) != label_to_dim_map.end()); + OPENVINO_ASSERT(label_to_dim_map.find(ellipsis) != label_to_dim_map.end()); reduced_rank += label_to_dim_map[ellipsis].size() - 1; } @@ -255,15 +253,15 @@ Shape compute_matmul_output_shape(const Shape& common_sub_shape, /// inputs with indices input_ind1 and input_ind2 and inserted new input and /// the corresponsing subscript in the tail /// -void update_operands(HostTensorVector& inputs, +void update_operands(ov::TensorVector& inputs, std::vector& input_subscripts, size_t input_ind1, size_t input_ind2, - const HostTensorPtr& new_input, + const ov::Tensor& new_input, const std::string& new_subscript) { - NGRAPH_CHECK(input_ind1 < input_ind2); - NGRAPH_CHECK(input_ind2 < inputs.size()); - NGRAPH_CHECK(input_ind2 < input_subscripts.size()); + OPENVINO_ASSERT(input_ind1 < input_ind2); + OPENVINO_ASSERT(input_ind2 < inputs.size()); + OPENVINO_ASSERT(input_ind2 < input_subscripts.size()); inputs.erase(inputs.begin() + input_ind2); inputs.erase(inputs.begin() + input_ind1); inputs.push_back(new_input); @@ -275,26 +273,28 @@ void update_operands(HostTensorVector& inputs, /// \brief Unsqueeze input by given dimensions if a vector of unsqueezing /// dimensions is not empty template -HostTensorPtr unsqueeze_input(const HostTensorPtr& input, std::vector& unsqueeze_axes) { +ov::Tensor unsqueeze_input(const ov::Tensor& input, std::vector& unsqueeze_axes) { if (unsqueeze_axes.empty()) { return input; } - Shape input_shape = input->get_shape(); + Shape input_shape = input.get_shape(); Shape output_shape = input_shape; std::sort(unsqueeze_axes.begin(), unsqueeze_axes.end()); for (auto unsqueeze_axis : unsqueeze_axes) { - NGRAPH_CHECK(unsqueeze_axis >= 0); - NGRAPH_CHECK(static_cast(unsqueeze_axis) <= output_shape.size()); + OPENVINO_ASSERT(unsqueeze_axis >= 0); + OPENVINO_ASSERT(static_cast(unsqueeze_axis) <= output_shape.size()); output_shape.insert(output_shape.begin() + unsqueeze_axis, 1); } - HostTensorPtr output = std::shared_ptr(new HostTensor(input->get_element_type(), output_shape)); - const AxisVector order = ngraph::get_default_order(input->get_shape()); - const auto element_type = input->get_element_type(); + auto output = ov::Tensor(input.get_element_type(), output_shape); + OPENVINO_SUPPRESS_DEPRECATED_START + const AxisVector order = ngraph::get_default_order(input.get_shape()); + OPENVINO_SUPPRESS_DEPRECATED_END + const auto element_type = input.get_element_type(); - reference::reshape(reinterpret_cast(input->get_data_ptr()), - reinterpret_cast(output->get_data_ptr()), + reference::reshape(reinterpret_cast(input.data()), + reinterpret_cast(output.data()), input_shape, order, output_shape, @@ -307,31 +307,31 @@ HostTensorPtr unsqueeze_input(const HostTensorPtr& input, std::vector& /// equation and reduce dimensions corresponding to such labels /// template -void reduce_input(HostTensorVector& inputs, +void reduce_input(ov::TensorVector& inputs, std::vector& input_subscripts, const std::string& output_subscript, size_t input_ind) { // perform sanity check for arguments auto num_inputs = inputs.size(); - NGRAPH_CHECK(num_inputs == input_subscripts.size(), "Each input must have own subscript."); - NGRAPH_CHECK(input_ind < num_inputs, "Input index is out of range."); + OPENVINO_ASSERT(num_inputs == input_subscripts.size(), "Each input must have own subscript."); + OPENVINO_ASSERT(input_ind < num_inputs, "Input index is out of range."); const auto& input_ptr = inputs[input_ind]; const auto& input_subscript = input_subscripts[input_ind]; - const auto input_shape = input_ptr->get_shape(); + const auto input_shape = input_ptr.get_shape(); // compute output shape and axes to reduce - ngraph::Shape output_shape; - ngraph::AxisSet reduced_axes; - auto labels = ngraph::opset7::Einsum::extract_labels(input_subscripts[input_ind]); - auto label_dim_map = compute_label_dim_map(input_ptr->get_partial_shape().rank(), input_subscript); + ov::Shape output_shape; + ov::AxisSet reduced_axes; + auto labels = ov::op::v7::Einsum::extract_labels(input_subscripts[input_ind]); + auto label_dim_map = compute_label_dim_map(input_ptr.get_shape().size(), input_subscript); std::string new_input_subscript = ""; for (const auto& label : labels) { // check if the current label is met in the other input subscripts // or the output subscript bool is_dim_reduced = is_dimension_reduced(input_subscripts, output_subscript, label, {input_ind}); - NGRAPH_CHECK(label_dim_map.find(label) != label_dim_map.end()); + OPENVINO_ASSERT(label_dim_map.find(label) != label_dim_map.end()); auto label_dims = label_dim_map[label]; // if label is not met, dimension corresponding to the label is to reduce @@ -350,9 +350,9 @@ void reduce_input(HostTensorVector& inputs, return; } - HostTensorPtr output_ptr = std::shared_ptr(new HostTensor(input_ptr->get_element_type(), output_shape)); + auto output_ptr = ov::Tensor(input_ptr.get_element_type(), output_shape); - reference::sum(input_ptr->get_data_ptr(), output_ptr->get_data_ptr(), input_shape, reduced_axes); + reference::sum(input_ptr.data(), output_ptr.data(), input_shape, reduced_axes); // update a vector of inputs and input subscripts inputs[input_ind] = output_ptr; @@ -362,14 +362,14 @@ void reduce_input(HostTensorVector& inputs, /// \brief Transpose input to layout specified through the required subscript /// template -void transpose_input(HostTensorVector& inputs, +void transpose_input(ov::TensorVector& inputs, std::vector& input_subscripts, const std::string& required_subscript, size_t input_ind) { // perform sanity check for arguments auto num_inputs = inputs.size(); - NGRAPH_CHECK(num_inputs == input_subscripts.size(), "Each input must have own subscript."); - NGRAPH_CHECK(input_ind < num_inputs, "Input index is out of range."); + OPENVINO_ASSERT(num_inputs == input_subscripts.size(), "Each input must have own subscript."); + OPENVINO_ASSERT(input_ind < num_inputs, "Input index is out of range."); // generate permutation vector by searching for bijection between // input_subscripts and required_subscript @@ -384,29 +384,29 @@ void transpose_input(HostTensorVector& inputs, // find permutation that establishes bijection between the input subscript // and the required one - auto label_dim_map = compute_label_dim_map(input_ptr->get_partial_shape().rank(), input_subscript); - auto labels = ngraph::opset7::Einsum::extract_labels(input_subscript); - auto required_labels = ngraph::opset7::Einsum::extract_labels(required_subscript); - NGRAPH_CHECK(labels.size() == required_labels.size()); + auto label_dim_map = compute_label_dim_map(input_ptr.get_shape().size(), input_subscript); + auto labels = ov::op::v7::Einsum::extract_labels(input_subscript); + auto required_labels = ov::op::v7::Einsum::extract_labels(required_subscript); + OPENVINO_ASSERT(labels.size() == required_labels.size()); for (const auto& required_label : required_labels) { - NGRAPH_CHECK(label_dim_map.find(required_label) != label_dim_map.end()); + OPENVINO_ASSERT(label_dim_map.find(required_label) != label_dim_map.end()); auto label_dims = label_dim_map[required_label]; permutation.insert(permutation.end(), label_dims.begin(), label_dims.end()); } - const auto input_shape = input_ptr->get_shape(); - const auto element_type = input_ptr->get_element_type(); + const auto input_shape = input_ptr.get_shape(); + const auto element_type = input_ptr.get_element_type(); Shape output_shape(input_shape.size()); std::transform(permutation.begin(), permutation.end(), output_shape.begin(), [&](const int64_t& v) { - NGRAPH_CHECK(v >= 0, "Negative values for transpose axes order are not supported."); - NGRAPH_CHECK(v < int64_t(input_shape.size()), "Transpose axis ", v, " is out of shape range."); + OPENVINO_ASSERT(v >= 0, "Negative values for transpose axes order are not supported."); + OPENVINO_ASSERT(v < int64_t(input_shape.size()), "Transpose axis ", v, " is out of shape range."); return input_shape[v]; }); - HostTensorPtr output_ptr = std::shared_ptr(new HostTensor(element_type, output_shape)); + auto output_ptr = ov::Tensor(element_type, output_shape); - reference::transpose(reinterpret_cast(input_ptr->get_data_ptr()), - reinterpret_cast(output_ptr->get_data_ptr()), + reference::transpose(reinterpret_cast(input_ptr.data()), + reinterpret_cast(output_ptr.data()), input_shape, element_type.size(), permutation.data(), @@ -421,15 +421,15 @@ void transpose_input(HostTensorVector& inputs, /// same shape of both operands in the common (or batch) dimensionsy. /// template -void broadcast_input(HostTensorVector& inputs, +void broadcast_input(ov::TensorVector& inputs, size_t input_ind, const Shape& new_common_shape, const Shape& separate_shape, const Shape& reduced_shape, bool is_separate_first) { - NGRAPH_CHECK(input_ind < inputs.size()); - HostTensorPtr& input = inputs[input_ind]; - const Shape old_shape = input->get_shape(); + OPENVINO_ASSERT(input_ind < inputs.size()); + ov::Tensor& input = inputs[input_ind]; + const Shape old_shape = input.get_shape(); Shape new_shape; new_shape.insert(new_shape.end(), new_common_shape.begin(), new_common_shape.end()); if (is_separate_first) { @@ -440,22 +440,22 @@ void broadcast_input(HostTensorVector& inputs, new_shape.insert(new_shape.end(), separate_shape.begin(), separate_shape.end()); } - if (input->get_shape() == new_shape) { + if (input.get_shape() == new_shape) { return; } - NGRAPH_CHECK(old_shape.size() <= new_shape.size()); + OPENVINO_ASSERT(old_shape.size() <= new_shape.size()); - HostTensorPtr output = std::shared_ptr(new HostTensor(input->get_element_type(), new_shape)); + auto output = ov::Tensor(input.get_element_type(), new_shape); std::vector broadcast_axes(old_shape.size()); std::iota(broadcast_axes.begin(), broadcast_axes.end(), new_shape.size() - old_shape.size()); - reference::broadcast(reinterpret_cast(input->get_data_ptr()), - reinterpret_cast(output->get_data_ptr()), - input->get_shape(), - output->get_shape(), + reference::broadcast(reinterpret_cast(input.data()), + reinterpret_cast(output.data()), + input.get_shape(), + output.get_shape(), broadcast_axes, - input->get_element_type().size()); + input.get_element_type().size()); input = output; } @@ -465,21 +465,21 @@ void broadcast_input(HostTensorVector& inputs, /// identity /// template -HostTensorPtr build_identity(const HostTensorPtr& input_ptr, const ov::TensorLabel& repeated_label_dims) { +ov::Tensor build_identity(const ov::Tensor& input, const ov::TensorLabel& repeated_label_dims) { // allocate HostTensor for building identity tensor - NGRAPH_CHECK(repeated_label_dims.size() > 1); - Shape input_shape = input_ptr->get_shape(); + OPENVINO_ASSERT(repeated_label_dims.size() > 1); + Shape input_shape = input.get_shape(); Shape identity_shape(input_shape.size(), 1); size_t repeated_label_dim_size = input_shape[repeated_label_dims[0]]; for (auto dim : repeated_label_dims) { - NGRAPH_CHECK(dim < input_shape.size()); - NGRAPH_CHECK(repeated_label_dim_size == input_shape[dim]); + OPENVINO_ASSERT(dim < input_shape.size()); + OPENVINO_ASSERT(repeated_label_dim_size == input_shape[dim]); identity_shape[dim] = repeated_label_dim_size; } - HostTensorPtr identity = std::shared_ptr(new HostTensor(input_ptr->get_element_type(), identity_shape)); + auto identity = ov::Tensor(input.get_element_type(), identity_shape); - T* identity_data_ptr = identity->get_data_ptr(); - size_t data_size = shape_size(identity_shape) * identity->get_element_type().size(); + T* identity_data_ptr = identity.data(); + size_t data_size = shape_size(identity_shape) * identity.get_element_type().size(); std::memset(identity_data_ptr, 0, data_size); // Identity[k,k,...,k] element is placed in k*p^(n-1) + ... + k*p + k position, @@ -507,35 +507,32 @@ HostTensorPtr build_identity(const HostTensorPtr& input_ptr, const ov::TensorLab /// repeated label /// template -HostTensorPtr build_multi_identity(const HostTensorPtr& input_ptr, - const std::vector& repeated_labels, - std::unordered_map& label_dim_map) { - Shape input_shape = input_ptr->get_shape(); +ov::Tensor build_multi_identity(const ov::Tensor& input, + const std::vector& repeated_labels, + std::unordered_map& label_dim_map) { + Shape input_shape = input.get_shape(); // initially set multi-identity with identity for the first repeated label - NGRAPH_CHECK(repeated_labels.size() > 0); + OPENVINO_ASSERT(repeated_labels.size() > 0); auto first_repeated_label = repeated_labels[0]; - NGRAPH_CHECK(label_dim_map.find(first_repeated_label) != label_dim_map.end()); + OPENVINO_ASSERT(label_dim_map.find(first_repeated_label) != label_dim_map.end()); auto repeated_label_dims = label_dim_map[first_repeated_label]; - HostTensorPtr multi_identity = build_identity(input_ptr, repeated_label_dims); + ov::Tensor multi_identity = build_identity(input, repeated_label_dims); for (size_t label_ind = 1; label_ind < repeated_labels.size(); ++label_ind) { - NGRAPH_CHECK(label_dim_map.find(repeated_labels[label_ind]) != label_dim_map.end()); + OPENVINO_ASSERT(label_dim_map.find(repeated_labels[label_ind]) != label_dim_map.end()); repeated_label_dims = label_dim_map[repeated_labels[label_ind]]; - HostTensorPtr identity = build_identity(input_ptr, repeated_label_dims); - - PartialShape output_shape = multi_identity->get_partial_shape(); - PartialShape::broadcast_merge_into(output_shape, - identity->get_partial_shape(), - ngraph::op::AutoBroadcastType::NUMPY); - HostTensorPtr mul_output = - std::shared_ptr(new HostTensor(identity->get_element_type(), output_shape.get_shape())); - reference::multiply(multi_identity->get_data_ptr(), - identity->get_data_ptr(), - mul_output->get_data_ptr(), - multi_identity->get_shape(), - identity->get_shape(), - ngraph::op::AutoBroadcastType::NUMPY); + ov::Tensor identity = build_identity(input, repeated_label_dims); + + PartialShape output_shape = multi_identity.get_shape(); + PartialShape::broadcast_merge_into(output_shape, identity.get_shape(), ov::op::AutoBroadcastType::NUMPY); + auto mul_output = ov::Tensor(identity.get_element_type(), output_shape.get_shape()); + reference::multiply(multi_identity.data(), + identity.data(), + mul_output.data(), + multi_identity.get_shape(), + identity.get_shape(), + ov::op::AutoBroadcastType::NUMPY); multi_identity = mul_output; } return multi_identity; @@ -545,28 +542,28 @@ HostTensorPtr build_multi_identity(const HostTensorPtr& input_ptr, /// labels) is diagonal /// template -void extract_diagonal(HostTensorVector& inputs, std::vector& input_subscripts, size_t input_ind) { +void extract_diagonal(ov::TensorVector& inputs, std::vector& input_subscripts, size_t input_ind) { // perform sanity check for arguments auto num_inputs = inputs.size(); - NGRAPH_CHECK(num_inputs == input_subscripts.size(), "Each input must have own subscript."); - NGRAPH_CHECK(input_ind < num_inputs, "Input index is out of range."); + OPENVINO_ASSERT(num_inputs == input_subscripts.size(), "Each input must have own subscript."); + OPENVINO_ASSERT(input_ind < num_inputs, "Input index is out of range."); const auto& input_ptr = inputs[input_ind]; const auto& input_subscript = input_subscripts[input_ind]; - const auto input_shape = input_ptr->get_shape(); + const auto input_shape = input_ptr.get_shape(); std::string resultant_subscript = ""; constexpr char ellipsis[] = "..."; - auto labels = ngraph::opset7::Einsum::extract_labels(input_subscript); - auto label_dim_map = compute_label_dim_map(input_ptr->get_partial_shape().rank(), input_subscript); + auto labels = ov::op::v7::Einsum::extract_labels(input_subscript); + auto label_dim_map = compute_label_dim_map(input_ptr.get_shape().size(), input_subscript); std::vector repeated_labels; Shape result_shape; AxisSet reduced_axes; for (const auto& label : labels) { if (resultant_subscript.find(label) == std::string::npos) { - NGRAPH_CHECK(label_dim_map.find(label) != label_dim_map.end()); + OPENVINO_ASSERT(label_dim_map.find(label) != label_dim_map.end()); auto dims = label_dim_map[label]; - NGRAPH_CHECK(dims.size() > 0); + OPENVINO_ASSERT(dims.size() > 0); if (label != ellipsis && dims.size() > 1) { // repeated label is found for (size_t dim_ind = 1; dim_ind < dims.size(); ++dim_ind) { @@ -578,7 +575,7 @@ void extract_diagonal(HostTensorVector& inputs, std::vector& input_ } resultant_subscript += label; for (auto dim : dims) { - NGRAPH_CHECK(dim < input_shape.size()); + OPENVINO_ASSERT(dim < input_shape.size()); result_shape.push_back(input_shape[dim]); } } @@ -587,18 +584,18 @@ void extract_diagonal(HostTensorVector& inputs, std::vector& input_ return; } - HostTensorPtr multi_identity = build_multi_identity(input_ptr, repeated_labels, label_dim_map); + ov::Tensor multi_identity = build_multi_identity(input_ptr, repeated_labels, label_dim_map); - HostTensorPtr mul_output = input_ptr; - reference::multiply(input_ptr->get_data_ptr(), - multi_identity->get_data_ptr(), - mul_output->get_data_ptr(), - input_ptr->get_shape(), - multi_identity->get_shape(), - ngraph::op::AutoBroadcastType::NUMPY); + ov::Tensor mul_output = input_ptr; + reference::multiply(input_ptr.data(), + multi_identity.data(), + mul_output.data(), + input_ptr.get_shape(), + multi_identity.get_shape(), + ov::op::AutoBroadcastType::NUMPY); - HostTensorPtr result = std::shared_ptr(new HostTensor(input_ptr->get_element_type(), result_shape)); - reference::sum(mul_output->get_data_ptr(), result->get_data_ptr(), mul_output->get_shape(), reduced_axes); + auto result = ov::Tensor(input_ptr.get_element_type(), result_shape); + reference::sum(mul_output.data(), result.data(), mul_output.get_shape(), reduced_axes); inputs[input_ind] = result; input_subscripts[input_ind] = resultant_subscript; } @@ -608,11 +605,11 @@ void extract_diagonal(HostTensorVector& inputs, std::vector& input_ /// acceptable by MatMul /// template -HostTensorPtr reshape_input_for_matmul(const HostTensorPtr& input, - const Shape& common_sub_shape, - const Shape& separate_sub_shape, - const Shape& reduced_sub_shape_prod, - bool is_separate_first) { +ov::Tensor reshape_input_for_matmul(const ov::Tensor& input, + const Shape& common_sub_shape, + const Shape& separate_sub_shape, + const Shape& reduced_sub_shape_prod, + bool is_separate_first) { Shape new_shape; new_shape.insert(new_shape.end(), common_sub_shape.begin(), common_sub_shape.end()); @@ -643,17 +640,19 @@ HostTensorPtr reshape_input_for_matmul(const HostTensorPtr& input, // when new shape is equal to the current one, // there is no need in reshape - if (new_shape == input->get_shape()) { + if (new_shape == input.get_shape()) { return input; } - const auto element_type = input->get_element_type(); - const auto input_shape = input->get_shape(); - HostTensorPtr output = std::shared_ptr(new HostTensor(element_type, new_shape)); + const auto element_type = input.get_element_type(); + const auto input_shape = input.get_shape(); + auto output = ov::Tensor(element_type, new_shape); + OPENVINO_SUPPRESS_DEPRECATED_START const AxisVector order = ngraph::get_default_order(input_shape); + OPENVINO_SUPPRESS_DEPRECATED_END - reference::reshape(reinterpret_cast(input->get_data_ptr()), - reinterpret_cast(output->get_data_ptr()), + reference::reshape(reinterpret_cast(input.data()), + reinterpret_cast(output.data()), input_shape, order, new_shape, @@ -667,7 +666,7 @@ HostTensorPtr reshape_input_for_matmul(const HostTensorPtr& input, /// inputs along with their input subscripts /// template -void contract_two_inputs(HostTensorVector& inputs, +void contract_two_inputs(ov::TensorVector& inputs, std::vector& input_subscripts, const std::string& output_subscript, size_t input_ind1, @@ -680,8 +679,8 @@ void contract_two_inputs(HostTensorVector& inputs, // perform sanity check for arguments auto num_inputs = inputs.size(); - NGRAPH_CHECK(num_inputs == input_subscripts.size(), "Each input must have own subscript."); - NGRAPH_CHECK(input_ind2 < num_inputs && input_ind1 != input_ind2, "Incorrect input index is specified."); + OPENVINO_ASSERT(num_inputs == input_subscripts.size(), "Each input must have own subscript."); + OPENVINO_ASSERT(input_ind2 < num_inputs && input_ind1 != input_ind2, "Incorrect input index is specified."); const auto& input1 = inputs[input_ind1]; const auto& input2 = inputs[input_ind2]; @@ -705,9 +704,9 @@ void contract_two_inputs(HostTensorVector& inputs, // corresponding label are met in neither the output subscript nor the input // subscripts for other Einsum inputs excluding two given inputs auto& input_subscript1 = input_subscripts[input_ind1]; - auto labels1 = ngraph::opset7::Einsum::extract_labels(input_subscript1); + auto labels1 = ov::op::v7::Einsum::extract_labels(input_subscript1); auto& input_subscript2 = input_subscripts[input_ind2]; - auto labels2 = ngraph::opset7::Einsum::extract_labels(input_subscript2); + auto labels2 = ov::op::v7::Einsum::extract_labels(input_subscript2); std::string common_part = ""; std::string separate_part1 = ""; std::string separate_part2 = ""; @@ -756,27 +755,27 @@ void contract_two_inputs(HostTensorVector& inputs, // for further unsqueezing transpose_input(inputs, input_subscripts, convenient_subscript, input_ind2); - auto separate_labels1 = ngraph::opset7::Einsum::extract_labels(separate_part1); - auto separate_labels2 = ngraph::opset7::Einsum::extract_labels(separate_part2); - auto label_to_dim_map1 = compute_label_dim_map(input1->get_partial_shape().rank(), input_subscript1); - auto label_to_dim_map2 = compute_label_dim_map(input2->get_partial_shape().rank(), input_subscript2); + auto separate_labels1 = ov::op::v7::Einsum::extract_labels(separate_part1); + auto separate_labels2 = ov::op::v7::Einsum::extract_labels(separate_part2); + auto label_to_dim_map1 = compute_label_dim_map(input1.get_shape().size(), input_subscript1); + auto label_to_dim_map2 = compute_label_dim_map(input2.get_shape().size(), input_subscript2); // unsqueeze the first operand with new dimensions in the tail // and the number of them is equal to the number of separate labels in the // second subscript - int64_t input_rank1 = input1->get_shape().size(); + int64_t input_rank1 = input1.get_shape().size(); int64_t unsqueeze_dim = input_rank1; std::vector unsqueeze_axis1; std::vector unsqueeze_axis2; for (const auto& sep_label2 : separate_labels2) { - NGRAPH_CHECK(label_to_dim_map2.find(sep_label2) != label_to_dim_map2.end()); + OPENVINO_ASSERT(label_to_dim_map2.find(sep_label2) != label_to_dim_map2.end()); auto label_dims = label_to_dim_map2[sep_label2]; for (size_t dim_ind = 0; dim_ind < label_dims.size(); ++dim_ind) { unsqueeze_axis1.push_back(unsqueeze_dim + static_cast(dim_ind)); } } for (const auto& sep_label1 : separate_labels1) { - NGRAPH_CHECK(label_to_dim_map1.find(sep_label1) != label_to_dim_map1.end()); + OPENVINO_ASSERT(label_to_dim_map1.find(sep_label1) != label_to_dim_map1.end()); auto label_dims = label_to_dim_map1[sep_label1]; for (auto label_dim : label_dims) { unsqueeze_axis2.push_back(label_dim); @@ -784,22 +783,21 @@ void contract_two_inputs(HostTensorVector& inputs, } // unsqueeze input operands for elementwise-multiplication with broadcasting - HostTensorPtr unsqueeze_output1 = unsqueeze_input(input1, unsqueeze_axis1); - HostTensorPtr unsqueeze_output2 = unsqueeze_input(input2, unsqueeze_axis2); + ov::Tensor unsqueeze_output1 = unsqueeze_input(input1, unsqueeze_axis1); + ov::Tensor unsqueeze_output2 = unsqueeze_input(input2, unsqueeze_axis2); // multiply both operands with broadcasting - PartialShape output_shape = unsqueeze_output1->get_partial_shape(); + PartialShape output_shape = unsqueeze_output1.get_shape(); PartialShape::broadcast_merge_into(output_shape, - unsqueeze_output2->get_partial_shape(), - ngraph::op::AutoBroadcastType::NUMPY); - HostTensorPtr mul_output = std::shared_ptr( - new HostTensor(unsqueeze_output1->get_element_type(), output_shape.get_shape())); - reference::multiply(unsqueeze_output1->get_data_ptr(), - unsqueeze_output2->get_data_ptr(), - mul_output->get_data_ptr(), - unsqueeze_output1->get_shape(), - unsqueeze_output2->get_shape(), - ngraph::op::AutoBroadcastType::NUMPY); + unsqueeze_output2.get_shape(), + ov::op::AutoBroadcastType::NUMPY); + auto mul_output = ov::Tensor(unsqueeze_output1.get_element_type(), output_shape.get_shape()); + reference::multiply(unsqueeze_output1.data(), + unsqueeze_output2.data(), + mul_output.data(), + unsqueeze_output1.get_shape(), + unsqueeze_output2.get_shape(), + ov::op::AutoBroadcastType::NUMPY); // update input operand and input subscript for Einsum operation update_operands(inputs, input_subscripts, input_ind1, input_ind2, mul_output, resultant_subscript); @@ -830,11 +828,11 @@ void contract_two_inputs(HostTensorVector& inputs, // [B1, ..., Bm, X1, Y] or [B1, ..., Bm, Y, X2], where B1, ..., Bm are common // dimensions, X1 and X2 are collapsed dimensions for separate labels and Y is // collapsed dimension for reduced labels - Shape input_shape1 = input1->get_shape(); - Shape input_shape2 = input2->get_shape(); + Shape input_shape1 = input1.get_shape(); + Shape input_shape2 = input2.get_shape(); size_t common_dims_begin, common_dims_end, reduced_dims_begin, reduced_dims_end, separate1_dims_begin, separate1_dims_end; - compute_ranges(input1->get_partial_shape().rank(), + compute_ranges(input1.get_shape().size(), input_subscript1, common_labels, sep_labels1, @@ -849,7 +847,7 @@ void contract_two_inputs(HostTensorVector& inputs, size_t common_dims_begin2, common_dims_end2, reduced_dims_begin2, reduced_dims_end2, separate2_dims_begin, separate2_dims_end; - compute_ranges(input2->get_partial_shape().rank(), + compute_ranges(input2.get_shape().size(), input_subscript2, common_labels, sep_labels2, @@ -888,29 +886,28 @@ void contract_two_inputs(HostTensorVector& inputs, reduced_sub_shape, is_separate_first2); - HostTensorPtr matmul_operand1 = reshape_input_for_matmul(input1, - common_sub_shape, - separate1_sub_shape, - reduced_sub_shape_prod, - is_separate_first1); - HostTensorPtr matmul_operand2 = reshape_input_for_matmul(input2, - common_sub_shape, - separate2_sub_shape, - reduced_sub_shape_prod, - is_separate_first2); + ov::Tensor matmul_operand1 = reshape_input_for_matmul(input1, + common_sub_shape, + separate1_sub_shape, + reduced_sub_shape_prod, + is_separate_first1); + ov::Tensor matmul_operand2 = reshape_input_for_matmul(input2, + common_sub_shape, + separate2_sub_shape, + reduced_sub_shape_prod, + is_separate_first2); // step 3. apply MatMul operation for formatted inputs Shape matmul_output_shape = compute_matmul_output_shape(common_sub_shape, separate1_sub_shape, separate2_sub_shape); - HostTensorPtr matmul_output = - std::shared_ptr(new HostTensor(matmul_operand1->get_element_type(), matmul_output_shape)); + auto matmul_output = ov::Tensor(matmul_operand1.get_element_type(), matmul_output_shape); bool transpose_a = (is_separate_first1 ? false : true); bool transpose_b = (is_separate_first2 ? true : false); - reference::matmul(matmul_operand1->get_data_ptr(), - matmul_operand2->get_data_ptr(), - matmul_output->get_data_ptr(), - matmul_operand1->get_shape(), - matmul_operand2->get_shape(), + reference::matmul(matmul_operand1.data(), + matmul_operand2.data(), + matmul_output.data(), + matmul_operand1.get_shape(), + matmul_operand2.get_shape(), matmul_output_shape, transpose_a, transpose_b); @@ -928,38 +925,39 @@ void contract_two_inputs(HostTensorVector& inputs, back_shape.insert(back_shape.end(), separate1_sub_shape.begin(), separate1_sub_shape.end()); back_shape.insert(back_shape.end(), separate2_sub_shape.begin(), separate2_sub_shape.end()); - HostTensorPtr contract_output = - std::shared_ptr(new HostTensor(matmul_output->get_element_type(), back_shape)); - const AxisVector order = ngraph::get_default_order(matmul_output->get_shape()); - reference::reshape(reinterpret_cast(matmul_output->get_data_ptr()), - reinterpret_cast(contract_output->get_data_ptr()), - matmul_output->get_shape(), + auto contract_output = ov::Tensor(matmul_output.get_element_type(), back_shape); + OPENVINO_SUPPRESS_DEPRECATED_START + const AxisVector order = ngraph::get_default_order(matmul_output.get_shape()); + OPENVINO_SUPPRESS_DEPRECATED_END + reference::reshape(reinterpret_cast(matmul_output.data()), + reinterpret_cast(contract_output.data()), + matmul_output.get_shape(), order, back_shape, - matmul_output->get_element_type().size()); + matmul_output.get_element_type().size()); update_operands(inputs, input_subscripts, input_ind1, input_ind2, contract_output, resultant_subscript); } template -void einsum_impl(const HostTensorVector& inputs, const HostTensorVector& outputs, const std::string& equation) { +void einsum_impl(const ov::TensorVector& inputs, ov::TensorVector& outputs, const std::string& equation) { std::vector input_subscripts; std::string output_subscript; - ngraph::opset7::Einsum::parse_equation(equation, input_subscripts, output_subscript); + ov::op::v7::Einsum::parse_equation(equation, input_subscripts, output_subscript); // compute einsum path that is used to contract a pair of operands // in more optimal order size_t num_inputs = inputs.size(); auto einsum_path = compute_einsum_path(num_inputs); - HostTensorVector int_inputs = inputs; + ov::TensorVector int_inputs = inputs; // contract inputs by Einsum until just one is remained for (auto const& inds_pair : einsum_path) { contract_two_inputs(int_inputs, input_subscripts, output_subscript, inds_pair.first, inds_pair.second); } - NGRAPH_CHECK(int_inputs.size() == 1); + OPENVINO_ASSERT(int_inputs.size() == 1); // extract diagonal for the single operand extract_diagonal(int_inputs, input_subscripts, 0); @@ -970,26 +968,23 @@ void einsum_impl(const HostTensorVector& inputs, const HostTensorVector& outputs // transpose dimensions to layout required by the output subscript transpose_input(int_inputs, input_subscripts, output_subscript, 0); - auto output_shape = int_inputs[0]->get_shape(); - const auto& element_type = int_inputs[0]->get_element_type(); - const auto& buf_size = shape_size(output_shape) * element_type.size(); - outputs[0]->write(int_inputs[0]->get_data_ptr(), buf_size); + int_inputs[0].copy_to(outputs[0]); } } // namespace -void einsum(const HostTensorVector& outputs, const HostTensorVector& inputs, const std::string& equation) { - NGRAPH_CHECK(inputs.size() > 0, "Einsum must accept at least one input."); - auto input_type = inputs[0]->get_element_type(); +void einsum(ov::TensorVector& outputs, const ov::TensorVector& inputs, const std::string& equation) { + OPENVINO_ASSERT(inputs.size() > 0, "Einsum must accept at least one input."); + auto input_type = inputs[0].get_element_type(); for (size_t input_ind = 1; input_ind < inputs.size(); ++input_ind) { - NGRAPH_CHECK(inputs[input_ind]->get_element_type() == input_type, "Input types must be the same."); + OPENVINO_ASSERT(inputs[input_ind].get_element_type() == input_type, "Input types must be the same."); } if (input_type == element::Type_t::f32) { einsum_impl(inputs, outputs, equation); } else if (input_type == element::Type_t::i32) { einsum_impl(inputs, outputs, equation); } else { - NGRAPH_CHECK(false, "Unsupported input type for Einsum operation."); + OPENVINO_ASSERT(false, "Unsupported input type for Einsum operation."); } } diff --git a/src/core/reference/src/op/fft.cpp b/src/core/reference/src/op/fft.cpp index 012969f278f8f5..9c88b21fd8d1b8 100644 --- a/src/core/reference/src/op/fft.cpp +++ b/src/core/reference/src/op/fft.cpp @@ -25,7 +25,6 @@ #include #include -#include "ngraph/shape.hpp" #include "openvino/reference/utils/fft_common.hpp" namespace ov { @@ -446,32 +445,30 @@ void fft(const float* input_data, } } -OPENVINO_SUPPRESS_DEPRECATED_START -void fft_postprocessing(const HostTensorVector& outputs, - const ngraph::element::Type output_type, +void fft_postprocessing(ov::TensorVector& outputs, + const ov::element::Type output_type, const std::vector& fft_result) { size_t fft_result_size = fft_result.size(); switch (output_type) { case element::Type_t::bf16: { - bfloat16* result_ptr = outputs[0]->get_data_ptr(); + bfloat16* result_ptr = outputs[0].data(); for (size_t i = 0; i < fft_result_size; ++i) { result_ptr[i] = bfloat16(fft_result[i]); } } break; case element::Type_t::f16: { - float16* result_ptr = outputs[0]->get_data_ptr(); + float16* result_ptr = outputs[0].data(); for (size_t i = 0; i < fft_result_size; ++i) { result_ptr[i] = float16(fft_result[i]); } } break; case element::Type_t::f32: { - float* result_ptr = outputs[0]->get_data_ptr(); + float* result_ptr = outputs[0].data(); memcpy(result_ptr, fft_result.data(), fft_result_size * sizeof(float)); } break; default:; } } -OPENVINO_SUPPRESS_DEPRECATED_END } // namespace reference } // namespace ov diff --git a/src/core/reference/src/op/function.cpp b/src/core/reference/src/op/function.cpp index cfd370e38a5c80..a0bedfa1241728 100644 --- a/src/core/reference/src/op/function.cpp +++ b/src/core/reference/src/op/function.cpp @@ -11,18 +11,21 @@ #include "ngraph/runtime/tensor.hpp" #include "openvino/core/deprecated.hpp" #include "openvino/reference/concat.hpp" +#include "shape_util.hpp" namespace ov { namespace reference { -OPENVINO_SUPPRESS_DEPRECATED_START -void function(const std::shared_ptr& function, const HostTensorVector& inputs, HostTensorVector& outputs) { +void function(const std::shared_ptr& function, const ov::TensorVector& inputs, ov::TensorVector& outputs) { const auto& results = function->get_results(); outputs.reserve(results.size()); for (size_t i = 0; i < results.size(); ++i) { - outputs.push_back(std::make_shared()); + OPENVINO_SUPPRESS_DEPRECATED_START + auto shape = results[i]->get_output_partial_shape(0).is_static() ? results[i]->get_output_shape(0) + : ov::util::make_dynamic_shape(); + OPENVINO_SUPPRESS_DEPRECATED_END + outputs.push_back(ov::Tensor(results[i]->get_element_type(), shape)); } function->evaluate(outputs, inputs); } -OPENVINO_SUPPRESS_DEPRECATED_END } // namespace reference } // namespace ov diff --git a/src/core/reference/src/op/if.cpp b/src/core/reference/src/op/if.cpp index 3fe42b61719809..25a04a7057f106 100644 --- a/src/core/reference/src/op/if.cpp +++ b/src/core/reference/src/op/if.cpp @@ -7,20 +7,19 @@ #include "ngraph/op/if.hpp" #include "openvino/reference/function.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START namespace ov { namespace reference { void if_reference(const std::vector>& bodies, const std::vector& out_descs, const std::vector& input_descs, - const HostTensorVector& out, - const HostTensorVector& args) { + ov::TensorVector& out, + const ov::TensorVector& args) { NGRAPH_CHECK(args.size() > 0, "If operation must have input condition value"); - auto condition_value = args[0]->get_data_ptr()[0]; + auto condition_value = args[0].data()[0]; auto branch_index = (condition_value) ? op::v8::If::THEN_BODY_INDEX : op::v8::If::ELSE_BODY_INDEX; - HostTensorVector inputs_to_body; - HostTensorVector outs_from_body; + ov::TensorVector inputs_to_body; + ov::TensorVector outs_from_body; inputs_to_body.resize(input_descs[branch_index].size()); auto inputs_size = args.size(); auto output_size = out.size(); @@ -36,8 +35,8 @@ void if_reference(const std::vector>& bodies, "Incorrect associating! If has not output with id ", out_descr->m_output_index); auto res = outs_from_body[out_descr->m_body_value_index]; - out[out_descr->m_output_index]->set_shape(res->get_shape()); - out[out_descr->m_output_index]->write(res->get_data_ptr(), res->get_size_in_bytes()); + out[out_descr->m_output_index].set_shape(res.get_shape()); + res.copy_to(out[out_descr->m_output_index]); } } } // namespace reference diff --git a/src/core/reference/src/op/loop.cpp b/src/core/reference/src/op/loop.cpp index 0a1ee146664a74..0582f18f438e59 100644 --- a/src/core/reference/src/op/loop.cpp +++ b/src/core/reference/src/op/loop.cpp @@ -4,12 +4,13 @@ #include "openvino/reference/loop.hpp" +#include + #include "openvino/op/tensor_iterator.hpp" #include "openvino/reference/concat.hpp" #include "openvino/reference/function.hpp" #include "openvino/reference/split.hpp" - -OPENVINO_SUPPRESS_DEPRECATED_START +#include "openvino/runtime/tensor.hpp" namespace ov { namespace reference { @@ -17,8 +18,8 @@ void loop(const std::shared_ptr& func, const op::util::OutputDescriptionVector& out_descs, const op::util::InputDescriptionVector& input_descs, const op::v5::Loop::SpecialBodyPorts& special_ports, - const HostTensorVector& out, - const HostTensorVector& args) { + ov::TensorVector& out, + const ov::TensorVector& args) { const auto& cur_iter_idx = special_ports.current_iteration_input_idx; auto val = std::find_if(input_descs.begin(), input_descs.end(), @@ -32,9 +33,9 @@ void loop(const std::shared_ptr& func, // should allocate input_descs.size() + 1 inputs and set default value (0) for // current_iteration input. int64_t inputs_count = input_descs.size() + (cur_iter_idx >= 0 ? !cur_iter_initial_value_exist : 0); - HostTensorVector inputs_to_body; + ov::TensorVector inputs_to_body; for (int64_t i = 0; i < inputs_count; ++i) - inputs_to_body.push_back(std::make_shared(element::dynamic, PartialShape::dynamic())); + inputs_to_body.push_back(ov::Tensor()); if (cur_iter_idx >= 0 && !cur_iter_initial_value_exist) { const auto& cur_iter = func->get_parameters().at(cur_iter_idx); if (cur_iter->get_partial_shape().is_dynamic()) { @@ -45,8 +46,10 @@ void loop(const std::shared_ptr& func, auto init = std::make_shared(func->get_parameters().at(cur_iter_idx)->get_element_type(), func->get_parameters().at(cur_iter_idx)->get_shape(), 0); - inputs_to_body.at(cur_iter_idx)->initialize(init); - // reinterpret_cast(inputs_to_body.at(cur_iter_idx).data())[0] = 0; + ov::Tensor in_tensor(func->get_parameters().at(cur_iter_idx)->get_element_type(), + func->get_parameters().at(cur_iter_idx)->get_shape()); + std::memset(in_tensor.data(), 0, in_tensor.get_byte_size()); + inputs_to_body.at(cur_iter_idx) = in_tensor; } // Port map processing: inputs and back edges @@ -65,19 +68,19 @@ void loop(const std::shared_ptr& func, // Get TripCount int64_t trip_count = 0; - if (args[0]->get_element_type() == ngraph::element::i32) { - auto* trip_count_p = args[0]->get_data_ptr(); + if (args[0].get_element_type() == ov::element::i32) { + auto* trip_count_p = args[0].data(); trip_count = trip_count_p[0]; - } else if (args[0]->get_element_type() == ngraph::element::i64) { - auto* trip_count_p = args[0]->get_data_ptr(); + } else if (args[0].get_element_type() == ov::element::i64) { + auto* trip_count_p = args[0].data(); trip_count = trip_count_p[0]; } else { - NGRAPH_CHECK(false, "Unsupported element type for trip_count input. Expected int32 or int64."); + OPENVINO_THROW("Unsupported element type for trip_count input. Expected int32 or int64."); } - NGRAPH_CHECK(trip_count != 0, "Zero count of iteration not supported"); + OPENVINO_ASSERT(trip_count != 0, "Zero count of iteration not supported"); // Loop iterations - auto exec_condition = args[1]->get_data_ptr(); + auto exec_condition = args[1].data(); if (exec_condition[0]) { // Find all ConcatOutputDescription std::vector> concat_outputs; @@ -89,28 +92,28 @@ void loop(const std::shared_ptr& func, // Slicing std::vector> slice_inputs; - std::vector sliced_values; + std::vector sliced_values; int slice_in_idx = 0; for (const auto& desc : input_descs) { if (const auto& slice_desc = std::dynamic_pointer_cast(desc)) { - const auto el_size = args[slice_desc->m_input_index]->get_element_type().size(); + const auto el_size = args[slice_desc->m_input_index].get_element_type().size(); slice_inputs.push_back(slice_desc); - auto shape = args[slice_desc->m_input_index]->get_shape(); + auto shape = args[slice_desc->m_input_index].get_shape(); uint64_t num_iterations = shape.at(slice_desc->m_axis); shape.at(slice_desc->m_axis) = 1; - sliced_values.emplace_back(HostTensorVector()); + sliced_values.emplace_back(ov::TensorVector()); for (uint64_t i = 0; i < num_iterations; ++i) { sliced_values.back().emplace_back( - std::make_shared(args[slice_desc->m_input_index]->get_element_type(), shape)); + ov::Tensor(args[slice_desc->m_input_index].get_element_type(), shape)); } std::vector pointers_to_data(num_iterations); for (size_t j = 0; j < pointers_to_data.size(); ++j) { pointers_to_data[slice_desc->m_stride > 0 ? j : (pointers_to_data.size() - j - 1)] = - sliced_values[slice_in_idx][j]->get_data_ptr(); + static_cast(sliced_values[slice_in_idx][j].data()); } - reference::split(args[slice_desc->m_input_index]->get_data_ptr(), - args[slice_desc->m_input_index]->get_shape(), + reference::split(static_cast(args[slice_desc->m_input_index].data()), + args[slice_desc->m_input_index].get_shape(), el_size, slice_desc->m_axis, num_iterations, @@ -120,8 +123,8 @@ void loop(const std::shared_ptr& func, } // Allocate vectors for store output values - std::vector values_to_concat(concat_outputs.size()); - HostTensorVector body_outputs; + std::vector values_to_concat(concat_outputs.size()); + ov::TensorVector body_outputs; // Negative value means infinity count of iterations trip_count = trip_count >= 0 ? trip_count : std::numeric_limits::max(); @@ -145,7 +148,7 @@ void loop(const std::shared_ptr& func, bool body_exec_condition(false); if (static_cast(body_outputs.size()) > special_ports.body_condition_output_idx && body_outputs[special_ports.body_condition_output_idx]) - body_outputs[special_ports.body_condition_output_idx]->read(&body_exec_condition, sizeof(bool)); + body_exec_condition = body_outputs[special_ports.body_condition_output_idx].data()[0]; if (!body_exec_condition) break; @@ -155,21 +158,24 @@ void loop(const std::shared_ptr& func, const auto& cur_iter_param = func->get_parameters().at(cur_iter_idx); int64_t iter_num = cur_iter + 1; if (cur_iter_param->get_element_type() == element::i64) - inputs_to_body.at(cur_iter_idx)->write(&iter_num, cur_iter_param->get_element_type().size()); + std::memcpy(inputs_to_body.at(cur_iter_idx).data(), + &iter_num, + cur_iter_param->get_element_type().size()); else if (cur_iter_param->get_element_type() == element::i32) { int32_t iter_num_i32 = static_cast(iter_num); - inputs_to_body.at(cur_iter_idx)->write(&iter_num_i32, cur_iter_param->get_element_type().size()); + std::memcpy(inputs_to_body.at(cur_iter_idx).data(), + &iter_num_i32, + cur_iter_param->get_element_type().size()); } else - NGRAPH_CHECK(false, - "Unsupported element type for current iteration " - "input. Expected int32 or int64."); + OPENVINO_THROW("Unsupported element type for current iteration " + "input. Expected int32 or int64."); } // Back-edge processing bool need_validate = false; for (auto& back_edge : back_edges) { - const auto& input_shape = inputs_to_body[back_edge.param_idx]->get_shape(); - const auto& result_shape = body_outputs[back_edge.result_idx]->get_shape(); + const auto& input_shape = inputs_to_body[back_edge.param_idx].get_shape(); + const auto& result_shape = body_outputs[back_edge.result_idx].get_shape(); // when output shape does not equal to input shape in a back-edge, such as // Parameter(out:1)->| // |->Concat(out:2)->Result(out:2) @@ -190,8 +196,8 @@ void loop(const std::shared_ptr& func, for (const auto& desc : out_descs) { if (const auto& body_desc = std::dynamic_pointer_cast(desc)) { const auto& res = body_outputs[body_desc->m_body_value_index]; - out[body_desc->m_output_index]->set_shape(res->get_shape()); - out[body_desc->m_output_index]->write(res->get_data_ptr(), res->get_size_in_bytes()); + out[body_desc->m_output_index].set_shape(res.get_shape()); + res.copy_to(out[body_desc->m_output_index]); } } @@ -201,21 +207,21 @@ void loop(const std::shared_ptr& func, auto shape = func->get_results().at(concat_desc->m_body_value_index)->get_shape(); std::vector shapes_to_concat(values_to_concat[i].size(), shape); shape.at(concat_desc->m_axis) = values_to_concat[i].size(); - out[concat_desc->m_output_index]->set_shape(shape); + out[concat_desc->m_output_index].set_shape(shape); std::vector pointers_on_values; pointers_on_values.reserve(values_to_concat[i].size()); for (const auto& vec : values_to_concat[i]) { - pointers_on_values.push_back(vec->get_data_ptr()); + pointers_on_values.push_back(static_cast(vec.data())); } reference::concat(pointers_on_values, - out[concat_desc->m_output_index]->get_data_ptr(), + static_cast(out[concat_desc->m_output_index].data()), shapes_to_concat, shape, concat_desc->m_axis, - out[concat_desc->m_output_index]->get_element_type().size()); + out[concat_desc->m_output_index].get_element_type().size()); } } else { - NGRAPH_CHECK(false, "ExecutionCondition is false. Zero count of iteration not supported."); + OPENVINO_THROW("ExecutionCondition is false. Zero count of iteration not supported."); } } } // namespace reference diff --git a/src/core/reference/src/op/non_max_suppression.cpp b/src/core/reference/src/op/non_max_suppression.cpp index e0032c3f5b4ecb..1dc7373bc17654 100644 --- a/src/core/reference/src/op/non_max_suppression.cpp +++ b/src/core/reference/src/op/non_max_suppression.cpp @@ -2,15 +2,15 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "ngraph/op/non_max_suppression.hpp" +#include "openvino/op/non_max_suppression.hpp" #include #include #include #include -#include "ngraph/shape.hpp" #include "openvino/reference/non_max_suppression.hpp" +#include "openvino/runtime/tensor.hpp" namespace ov { namespace reference { @@ -366,35 +366,33 @@ void non_max_suppression(const float* boxes_data, } } -OPENVINO_SUPPRESS_DEPRECATED_START -void nms_postprocessing(const HostTensorVector& outputs, - const ngraph::element::Type output_type, +void nms_postprocessing(ov::TensorVector& outputs, + const ov::element::Type output_type, const std::vector& selected_indices, const std::vector& selected_scores, int64_t valid_outputs, - const ngraph::element::Type selected_scores_type) { - outputs[0]->set_element_type(output_type); - outputs[0]->set_shape(Shape{static_cast(valid_outputs), 3}); + const ov::element::Type selected_scores_type) { + // outputs[0].set_element_type(output_type); + outputs[0].set_shape(Shape{static_cast(valid_outputs), 3}); size_t num_of_outputs = outputs.size(); if (num_of_outputs >= 2) { - outputs[1]->set_element_type(selected_scores_type); - outputs[1]->set_shape(Shape{static_cast(valid_outputs), 3}); + // outputs[1].set_element_type(selected_scores_type); + outputs[1].set_shape(Shape{static_cast(valid_outputs), 3}); } if (num_of_outputs >= 3) { - outputs[2]->set_element_type(output_type); - outputs[2]->set_shape(Shape{1}); + outputs[2].set_shape(Shape{1}); } size_t selected_size = valid_outputs * 3; - if (output_type == ngraph::element::i64) { - int64_t* indices_ptr = outputs[0]->get_data_ptr(); + if (output_type == ov::element::i64) { + int64_t* indices_ptr = outputs[0].data(); memcpy(indices_ptr, selected_indices.data(), selected_size * sizeof(int64_t)); } else { - int32_t* indices_ptr = outputs[0]->get_data_ptr(); + int32_t* indices_ptr = outputs[0].data(); for (size_t i = 0; i < selected_size; ++i) { indices_ptr[i] = static_cast(selected_indices[i]); } @@ -408,19 +406,19 @@ void nms_postprocessing(const HostTensorVector& outputs, switch (selected_scores_type) { case element::Type_t::bf16: { - bfloat16* scores_ptr = outputs[1]->get_data_ptr(); + bfloat16* scores_ptr = outputs[1].data(); for (size_t i = 0; i < selected_scores_size; ++i) { scores_ptr[i] = bfloat16(selected_scores[i]); } } break; case element::Type_t::f16: { - float16* scores_ptr = outputs[1]->get_data_ptr(); + float16* scores_ptr = outputs[1].data(); for (size_t i = 0; i < selected_scores_size; ++i) { scores_ptr[i] = float16(selected_scores[i]); } } break; case element::Type_t::f32: { - float* scores_ptr = outputs[1]->get_data_ptr(); + float* scores_ptr = outputs[1].data(); memcpy(scores_ptr, selected_scores.data(), selected_size * sizeof(float)); } break; default:; @@ -430,21 +428,21 @@ void nms_postprocessing(const HostTensorVector& outputs, return; } - if (output_type == ngraph::element::i64) { - int64_t* valid_outputs_ptr = outputs[2]->get_data_ptr(); + if (output_type == ov::element::i64) { + int64_t* valid_outputs_ptr = outputs[2].data(); *valid_outputs_ptr = valid_outputs; } else { - int32_t* valid_outputs_ptr = outputs[2]->get_data_ptr(); + int32_t* valid_outputs_ptr = outputs[2].data(); *valid_outputs_ptr = static_cast(valid_outputs); } } -void nms5_postprocessing(const HostTensorVector& outputs, - const ngraph::element::Type output_type, +void nms5_postprocessing(ov::TensorVector& outputs, + const ov::element::Type output_type, const std::vector& selected_indices, const std::vector& selected_scores, int64_t valid_outputs, - const ngraph::element::Type selected_scores_type) { + const ov::element::Type selected_scores_type) { nms_postprocessing(outputs, output_type, selected_indices, selected_scores, valid_outputs, selected_scores_type); } } // namespace reference diff --git a/src/core/reference/src/op/tensor_iterator.cpp b/src/core/reference/src/op/tensor_iterator.cpp index 26646536372c98..6ac83923f5b9a8 100644 --- a/src/core/reference/src/op/tensor_iterator.cpp +++ b/src/core/reference/src/op/tensor_iterator.cpp @@ -4,23 +4,25 @@ #include "openvino/reference/tensor_iterator.hpp" +#include "openvino/op/loop.hpp" +#include "openvino/op/tensor_iterator.hpp" #include "openvino/reference/concat.hpp" #include "openvino/reference/function.hpp" #include "openvino/reference/split.hpp" +#include "openvino/runtime/tensor.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START namespace ov { namespace reference { void tensor_iterator(uint64_t num_iterations, const std::shared_ptr& func, const op::util::OutputDescriptionVector& out_descs, const op::util::InputDescriptionVector& input_descs, - const HostTensorVector& out, - const HostTensorVector& args, + ov::TensorVector& out, + const ov::TensorVector& args, const custom_evaluate_function& evaluate) { - HostTensorVector inputs_to_body; + ov::TensorVector inputs_to_body; for (size_t i = 0; i < input_descs.size(); ++i) - inputs_to_body.push_back(std::make_shared(element::dynamic, PartialShape::dynamic())); + inputs_to_body.push_back(ov::Tensor()); // Port map processing: inputs and back edges struct BackEdge { @@ -30,12 +32,12 @@ void tensor_iterator(uint64_t num_iterations, std::vector back_edges; for (const auto& desc : input_descs) { inputs_to_body[desc->m_body_parameter_index] = args[desc->m_input_index]; - if (const auto& merged_desc = std::dynamic_pointer_cast(desc)) { + if (const auto& merged_desc = std::dynamic_pointer_cast(desc)) { back_edges.push_back({merged_desc->m_body_parameter_index, merged_desc->m_body_value_index}); } } // Find all ConcatOutputDescription - std::vector> concat_outputs; + std::vector> concat_outputs; for (const auto& desc : out_descs) { if (const auto& concat_desc = std::dynamic_pointer_cast(desc)) { @@ -45,26 +47,26 @@ void tensor_iterator(uint64_t num_iterations, // Slicing std::vector> slice_inputs; - std::vector sliced_values; + std::vector sliced_values; int slice_in_idx = 0; for (const auto& desc : input_descs) { if (const auto& slice_desc = std::dynamic_pointer_cast(desc)) { - const auto el_size = args[slice_desc->m_input_index]->get_element_type().size(); + const auto el_size = args[slice_desc->m_input_index].get_element_type().size(); slice_inputs.push_back(slice_desc); - auto shape = args[slice_desc->m_input_index]->get_shape(); + auto shape = args[slice_desc->m_input_index].get_shape(); shape.at(slice_desc->m_axis) = 1; - sliced_values.emplace_back(HostTensorVector()); + sliced_values.emplace_back(ov::TensorVector()); for (uint64_t i = 0; i < num_iterations; ++i) { sliced_values.back().emplace_back( - std::make_shared(args[slice_desc->m_input_index]->get_element_type(), shape)); + ov::Tensor(args[slice_desc->m_input_index].get_element_type(), shape)); } std::vector pointers_to_data(num_iterations); for (size_t j = 0; j < pointers_to_data.size(); ++j) { pointers_to_data[slice_desc->m_stride > 0 ? j : (pointers_to_data.size() - j - 1)] = - sliced_values[slice_in_idx][j]->get_data_ptr(); + static_cast(sliced_values[slice_in_idx][j].data()); } - reference::split(args[slice_desc->m_input_index]->get_data_ptr(), - args[slice_desc->m_input_index]->get_shape(), + reference::split(static_cast(args[slice_desc->m_input_index].data()), + args[slice_desc->m_input_index].get_shape(), el_size, slice_desc->m_axis, num_iterations, @@ -74,8 +76,8 @@ void tensor_iterator(uint64_t num_iterations, } // Allocate vectors for store output values - std::vector values_to_concat(concat_outputs.size()); - HostTensorVector body_outputs; + std::vector values_to_concat(concat_outputs.size()); + ov::TensorVector body_outputs; for (uint64_t cur_iter = 0; cur_iter < num_iterations; ++cur_iter) { // Copy new values for sliced inputs @@ -107,8 +109,8 @@ void tensor_iterator(uint64_t num_iterations, if (const auto& body_desc = std::dynamic_pointer_cast(desc)) { // Copy output values from the last iteration const auto& res = body_outputs[body_desc->m_body_value_index]; - out[body_desc->m_output_index]->set_shape(res->get_shape()); - out[body_desc->m_output_index]->write(res->get_data_ptr(), res->get_size_in_bytes()); + out[body_desc->m_output_index].set_shape(res.get_shape()); + res.copy_to(out[body_desc->m_output_index]); } } @@ -120,20 +122,20 @@ void tensor_iterator(uint64_t num_iterations, auto shape = func->get_results().at(concat_desc->m_body_value_index)->get_shape(); std::vector shapes_to_concat(values_to_concat[i].size(), shape); shape.at(concat_desc->m_axis) = values_to_concat[i].size(); - out[concat_desc->m_output_index]->set_shape(shape); + out[concat_desc->m_output_index].set_shape(shape); std::vector pointers_on_values; pointers_on_values.reserve(values_to_concat[i].size()); for (size_t j = 0; j < values_to_concat[i].size(); ++j) { size_t idx = concat_desc->m_stride > 0 ? j : (values_to_concat[i].size() - j - 1); if (values_to_concat[i].size() > idx && values_to_concat[i][idx]) - pointers_on_values.push_back(values_to_concat[i][idx]->get_data_ptr()); + pointers_on_values.push_back(static_cast(values_to_concat[i][idx].data())); } reference::concat(pointers_on_values, - out[concat_desc->m_output_index]->get_data_ptr(), + static_cast(out[concat_desc->m_output_index].data()), shapes_to_concat, shape, concat_desc->m_axis, - out[concat_desc->m_output_index]->get_element_type().size()); + out[concat_desc->m_output_index].get_element_type().size()); } } } // namespace reference diff --git a/src/core/reference/src/op/tile.cpp b/src/core/reference/src/op/tile.cpp index b027613d980623..f88e56392a26a8 100644 --- a/src/core/reference/src/op/tile.cpp +++ b/src/core/reference/src/op/tile.cpp @@ -9,8 +9,6 @@ #include #include -#include "ngraph/check.hpp" - using namespace ov; namespace { diff --git a/src/core/src/node.cpp b/src/core/src/node.cpp index 10ebc91b976d92..1cce81d2f9fb7d 100644 --- a/src/core/src/node.cpp +++ b/src/core/src/node.cpp @@ -740,7 +740,14 @@ inline void update_output_tensors(ov::TensorVector& output_values, const ngraph: if (!tensor && outputs[i]->get_partial_shape().is_static()) { tensor = ov::Tensor(outputs[i]->get_element_type(), outputs[i]->get_shape()); } - output_values[i] = tensor; + if (output_values[i]) { + // Copy value to the original tensor + output_values[i].set_shape(tensor.get_shape()); + tensor.copy_to(output_values[i]); + } else { + // Tensor is not initialized, so create the new tensor + output_values[i] = tensor; + } } } } diff --git a/src/core/src/op/loop.cpp b/src/core/src/op/loop.cpp index 419e564b19f35e..ef623af65814b6 100644 --- a/src/core/src/op/loop.cpp +++ b/src/core/src/op/loop.cpp @@ -12,6 +12,7 @@ #include "ngraph/graph_util.hpp" #include "ngraph/opsets/opset5.hpp" #include "openvino/reference/loop.hpp" +#include "openvino/runtime/tensor.hpp" using namespace std; using namespace ngraph; @@ -347,8 +348,7 @@ Output op::v5::Loop::get_concatenated_slices(const Output& value, return SubGraphOp::get_concatenated_slices(value, start, stride, part_size, end, axis); } -OPENVINO_SUPPRESS_DEPRECATED_START -bool op::v5::Loop::evaluate(const HostTensorVector& outputs, const HostTensorVector& inputs) const { +bool op::v5::Loop::evaluate(ov::TensorVector& outputs, const ov::TensorVector& inputs) const { OV_OP_SCOPE(v5_Loop_evaluate); ov::reference::loop(m_bodies[0], m_output_descriptions[0], @@ -358,7 +358,6 @@ bool op::v5::Loop::evaluate(const HostTensorVector& outputs, const HostTensorVec inputs); return true; } -OPENVINO_SUPPRESS_DEPRECATED_END bool op::v5::Loop::has_evaluate() const { OV_OP_SCOPE(v5_Loop_has_evaluate); diff --git a/src/core/src/runtime/host_tensor.cpp b/src/core/src/runtime/host_tensor.cpp index 712b6df02203c0..28ad2526b82529 100644 --- a/src/core/src/runtime/host_tensor.cpp +++ b/src/core/src/runtime/host_tensor.cpp @@ -139,11 +139,13 @@ void runtime::HostTensor::set_element_type(const element::Type& element_type) { } void runtime::HostTensor::set_shape(const Shape& shape) { - NGRAPH_CHECK(PartialShape(shape).refines(get_partial_shape()), - "Allocation shape ", - shape, - " must be compatible with the partial shape: ", - get_partial_shape()); + NGRAPH_CHECK( + PartialShape(shape).refines(get_partial_shape()) || + (m_descriptor->m_partial_shape.is_static() && m_descriptor->m_partial_shape.to_shape() == ov::Shape{0}), + "Allocation shape ", + shape, + " must be compatible with the partial shape: ", + get_partial_shape()); m_descriptor->m_partial_shape = shape; m_descriptor->m_shape_changed = true; } diff --git a/src/inference/src/dev/make_tensor.cpp b/src/inference/src/dev/make_tensor.cpp index ddd0ea293966c0..94ddf723eabc4c 100644 --- a/src/inference/src/dev/make_tensor.cpp +++ b/src/inference/src/dev/make_tensor.cpp @@ -188,6 +188,8 @@ class AllocatedTensor : public ViewTensor { } void set_shape(ov::Shape new_shape) override { + if (m_shape == new_shape) + return; auto old_byte_size = get_byte_size(); m_shape = std::move(new_shape); if (get_byte_size() > old_byte_size) { diff --git a/src/plugins/template/backend/backend.cpp b/src/plugins/template/backend/backend.cpp index 7605b8b5fb110a..a8153bfca2ee7f 100644 --- a/src/plugins/template/backend/backend.cpp +++ b/src/plugins/template/backend/backend.cpp @@ -7,8 +7,6 @@ #include #include "int_backend.hpp" -#include "ngraph/file_util.hpp" -#include "ngraph/util.hpp" #include "openvino/core/except.hpp" #include "openvino/util/file_util.hpp" diff --git a/src/plugins/template/backend/evaluates_map.cpp b/src/plugins/template/backend/evaluates_map.cpp index 2bb18904e6a45b..f88efae92d0f35 100644 --- a/src/plugins/template/backend/evaluates_map.cpp +++ b/src/plugins/template/backend/evaluates_map.cpp @@ -6,26 +6,25 @@ #include "ops/ops_evaluates.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START -std::vector get_floats(const std::shared_ptr& input, const ngraph::Shape& shape) { - size_t input_size = ngraph::shape_size(shape); +std::vector get_floats(const ov::Tensor& input, const ov::Shape& shape) { + size_t input_size = ov::shape_size(shape); std::vector result(input_size); - switch (input->get_element_type()) { - case ngraph::element::Type_t::bf16: { - ngraph::bfloat16* p = input->get_data_ptr(); + switch (input.get_element_type()) { + case ov::element::bf16: { + ov::bfloat16* p = input.data(); for (size_t i = 0; i < input_size; ++i) { result[i] = float(p[i]); } } break; - case ngraph::element::Type_t::f16: { - ngraph::float16* p = input->get_data_ptr(); + case ov::element::f16: { + ov::float16* p = input.data(); for (size_t i = 0; i < input_size; ++i) { result[i] = float(p[i]); } } break; - case ngraph::element::Type_t::f32: { - float* p = input->get_data_ptr(); + case ov::element::f32: { + float* p = input.data(); memcpy(result.data(), p, input_size * sizeof(float)); } break; default: @@ -36,55 +35,55 @@ std::vector get_floats(const std::shared_ptr& input, return result; } -std::vector get_integers(const std::shared_ptr& input, const ngraph::Shape& shape) { - size_t input_size = ngraph::shape_size(shape); +std::vector get_integers(const ov::Tensor& input, const ov::Shape& shape) { + size_t input_size = ov::shape_size(shape); std::vector result(input_size); - switch (input->get_element_type()) { - case ngraph::element::Type_t::i8: { - auto p = input->get_data_ptr(); + switch (input.get_element_type()) { + case ov::element::Type_t::i8: { + auto p = input.data(); for (size_t i = 0; i < input_size; ++i) { result[i] = int64_t(p[i]); } } break; - case ngraph::element::Type_t::i16: { - auto p = input->get_data_ptr(); + case ov::element::Type_t::i16: { + auto p = input.data(); for (size_t i = 0; i < input_size; ++i) { result[i] = int64_t(p[i]); } } break; - case ngraph::element::Type_t::i32: { - auto p = input->get_data_ptr(); + case ov::element::Type_t::i32: { + auto p = input.data(); for (size_t i = 0; i < input_size; ++i) { result[i] = int64_t(p[i]); } } break; - case ngraph::element::Type_t::i64: { - auto p = input->get_data_ptr(); + case ov::element::Type_t::i64: { + auto p = input.data(); for (size_t i = 0; i < input_size; ++i) { result[i] = int64_t(p[i]); } } break; - case ngraph::element::Type_t::u8: { - auto p = input->get_data_ptr(); + case ov::element::Type_t::u8: { + auto p = input.data(); for (size_t i = 0; i < input_size; ++i) { result[i] = int64_t(p[i]); } } break; - case ngraph::element::Type_t::u16: { - auto p = input->get_data_ptr(); + case ov::element::Type_t::u16: { + auto p = input.data(); for (size_t i = 0; i < input_size; ++i) { result[i] = int64_t(p[i]); } } break; - case ngraph::element::Type_t::u32: { - auto p = input->get_data_ptr(); + case ov::element::Type_t::u32: { + auto p = input.data(); for (size_t i = 0; i < input_size; ++i) { result[i] = int64_t(p[i]); } } break; - case ngraph::element::Type_t::u64: { - auto p = input->get_data_ptr(); + case ov::element::Type_t::u64: { + auto p = input.data(); for (size_t i = 0; i < input_size; ++i) { result[i] = int64_t(p[i]); } @@ -97,16 +96,15 @@ std::vector get_integers(const std::shared_ptr& inp return result; } -std::vector get_signal_size(const std::vector>& inputs, - size_t num_of_axes) { +std::vector get_signal_size(const ov::TensorVector& inputs, size_t num_of_axes) { if (inputs.size() == 3) { - return get_integers(inputs[2], inputs[2]->get_shape()); + return get_integers(inputs[2], inputs[2].get_shape()); } return std::vector(num_of_axes, static_cast(-1)); } -ngraph::runtime::interpreter::EvaluatorsMap& ngraph::runtime::interpreter::get_evaluators_map() { +ov::runtime::interpreter::EvaluatorsMap& ov::runtime::interpreter::get_evaluators_map() { static runtime::interpreter::EvaluatorsMap evaluatorsMap{ #define _OPENVINO_OP_REG(NAME, NAMESPACE) {NAMESPACE::NAME::get_type_info_static(), evaluate_node}, diff --git a/src/plugins/template/backend/evaluates_map.hpp b/src/plugins/template/backend/evaluates_map.hpp index d141a3896202ea..7fb249229e3365 100644 --- a/src/plugins/template/backend/evaluates_map.hpp +++ b/src/plugins/template/backend/evaluates_map.hpp @@ -3,23 +3,27 @@ // #pragma once -#include "ngraph/node.hpp" -std::vector get_floats(const std::shared_ptr& input, const ngraph::Shape& shape); +#include -std::vector get_integers(const std::shared_ptr& input, const ngraph::Shape& shape); +#include "openvino/core/node.hpp" +#include "openvino/core/shape.hpp" +#include "openvino/runtime/tensor.hpp" -std::vector get_signal_size(const std::vector>& inputs, - size_t num_of_axes); +std::vector get_floats(const ov::Tensor& input, const ov::Shape& shape); -namespace ngraph { +std::vector get_integers(const ov::Tensor& input, const ov::Shape& shape); + +std::vector get_signal_size(const ov::TensorVector& inputs, size_t num_of_axes); + +namespace ov { namespace runtime { namespace interpreter { -using EvaluatorsMap = std::map& node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs)>>; +using EvaluatorsMap = std::map< + ov::NodeTypeInfo, + std::function< + bool(const std::shared_ptr& node, ov::TensorVector& outputs, const ov::TensorVector& inputs)>>; EvaluatorsMap& get_evaluators_map(); } // namespace interpreter } // namespace runtime -} // namespace ngraph +} // namespace ov diff --git a/src/plugins/template/backend/executable.hpp b/src/plugins/template/backend/executable.hpp index 4e9e00cab52642..2259cc5192a4c0 100644 --- a/src/plugins/template/backend/executable.hpp +++ b/src/plugins/template/backend/executable.hpp @@ -52,11 +52,11 @@ class Executable { void validate(const std::vector& outputs, const std::vector& inputs); /// \brief Query the input Parameters - /// \returns an ngraph::op::ParameterVector of all input parameters + /// \returns an ov::op::ParameterVector of all input parameters const ov::ParameterVector& get_parameters() const; /// \brief Query the output Results - /// \returns an ngraph::ResultVector of all input parameters + /// \returns an ov::ResultVector of all input parameters const ov::ResultVector& get_results() const; /// \brief Query the internal model diff --git a/src/plugins/template/backend/int_executable.cpp b/src/plugins/template/backend/int_executable.cpp index f7a06f407cb42c..f866d77b6528b6 100644 --- a/src/plugins/template/backend/int_executable.cpp +++ b/src/plugins/template/backend/int_executable.cpp @@ -6,72 +6,15 @@ #include #include -#include #include "evaluates_map.hpp" #include "openvino/core/except.hpp" #include "openvino/op/parameter.hpp" #include "openvino/op/result.hpp" #include "openvino/op/util/op_types.hpp" +#include "openvino/op/util/variable_context.hpp" #include "perf_counter.hpp" -#include "tensor_conversion_util.hpp" - -OPENVINO_SUPPRESS_DEPRECATED_START -namespace { - -class DynamicTensor : public ngraph::runtime::HostTensor { -private: - ov::Tensor tensor; - -public: - DynamicTensor(const ov::element::Type& type) : ngraph::runtime::HostTensor(type, ov::PartialShape::dynamic()) {} - - ov::Tensor get_tensor() { - return tensor; - } - -protected: - void allocate_buffer() override { - OPENVINO_ASSERT(get_partial_shape().is_static(), - "Attempt to allocate buffer for tensor with partial shape: ", - get_partial_shape()); - OPENVINO_ASSERT(get_element_type().is_static(), - "Attempt to allocate buffer for tensor with dynamic type: ", - get_element_type()); - m_buffer_size = m_descriptor->size(); - tensor = ov::Tensor(get_element_type(), get_partial_shape().get_shape()); - m_memory_pointer = tensor.data(); - m_aligned_buffer_pool = m_memory_pointer; - } -}; - -inline ngraph::HostTensorPtr make_tmp_host_tensor(const ov::Tensor& t) { - if (!t) { - return std::make_shared(ov::element::dynamic); - } else if (t.get_shape() == ov::Shape{0, std::numeric_limits::max()}) { - return std::make_shared(t.get_element_type()); - } else { - return std::make_shared(t.get_element_type(), t.get_shape(), t.data()); - } -} -inline ngraph::HostTensorVector create_tmp_tensors(const ov::TensorVector& tensors) { - ngraph::HostTensorVector result; - result.reserve(tensors.size()); - for (const auto& tensor : tensors) { - result.push_back(make_tmp_host_tensor(tensor)); - } - return result; -} - -inline void update_output_tensors(ov::TensorVector& output_values, const ngraph::HostTensorVector& outputs) { - OPENVINO_ASSERT(output_values.size() == outputs.size()); - for (size_t i = 0; i < outputs.size(); i++) { - if (auto dyn_output = std::dynamic_pointer_cast(outputs[i])) { - output_values[i] = dyn_output->get_tensor(); - } - } -} -} // namespace +#include "shape_util.hpp" class TemporaryOverrideOutputs { std::shared_ptr model; @@ -184,10 +127,11 @@ bool ov::runtime::interpreter::INTExecutable::call(std::vector& outp auto it = tensor_map.find(tensor); auto output = op->output(i); if (op::util::is_output(op) || it == tensor_map.end() || !it->second) { - host_tensor = ov::Tensor(output.get_element_type(), - output.get_partial_shape().is_dynamic() - ? ov::Shape{0, std::numeric_limits::max()} - : output.get_shape()); + OPENVINO_SUPPRESS_DEPRECATED_START + host_tensor = ov::Tensor( + output.get_element_type(), + output.get_partial_shape().is_dynamic() ? ov::util::make_dynamic_shape() : output.get_shape()); + OPENVINO_SUPPRESS_DEPRECATED_END } else { host_tensor = it->second; } @@ -268,17 +212,14 @@ std::vector ov::runtime::interpreter::INTExecutable::create_output_t bool ov::runtime::interpreter::INTExecutable::evaluate_node(const std::shared_ptr& node, ov::TensorVector& outputs, const ov::TensorVector& inputs) const { - auto& map = ngraph::runtime::interpreter::get_evaluators_map(); + auto& map = ov::runtime::interpreter::get_evaluators_map(); auto it = map.find(node->get_type_info()); bool res = false; - const auto tensor_inputs = create_tmp_tensors(inputs); - auto tensor_outputs = create_tmp_tensors(outputs); OPENVINO_ASSERT(it != map.end(), "Interpreter backend doesn't implement evaluate method for OP ", node->get_type_info().name); - res = it->second(node, tensor_outputs, tensor_inputs); + res = it->second(node, outputs, inputs); OPENVINO_ASSERT(res, "Running evaluate method for OP ", node->get_type_info().name, " failed!"); - update_output_tensors(outputs, tensor_outputs); return res; } diff --git a/src/plugins/template/backend/int_executable.hpp b/src/plugins/template/backend/int_executable.hpp index 1be052349f3e9e..6a98dac4d992c6 100644 --- a/src/plugins/template/backend/int_executable.hpp +++ b/src/plugins/template/backend/int_executable.hpp @@ -72,11 +72,8 @@ class INTExecutable : public Executable { std::vector scores_data; size_t out_shape_size; bool sort_result_descending; - ngraph::element::Type output_type; + ov::element::Type output_type; }; - - InfoForNMS5 get_info_for_nms5_eval(const ov::op::v5::NonMaxSuppression* nms5, - const std::vector>& inputs); }; } // namespace interpreter diff --git a/src/plugins/template/backend/ops/abs.cpp b/src/plugins/template/backend/ops/abs.cpp index b72163d1bb8f57..a23c6d91387e10 100644 --- a/src/plugins/template/backend/ops/abs.cpp +++ b/src/plugins/template/backend/ops/abs.cpp @@ -2,65 +2,59 @@ // SPDX-License-Identifier: Apache-2.0 // -// clang-format off -#include "evaluate_node.hpp" #include "openvino/reference/abs.hpp" -// clang-format on -template -bool evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { - using T = typename ngraph::element_type_traits::value_type; - ov::reference::abs(inputs[0]->get_data_ptr(), - outputs[0]->get_data_ptr(), - ngraph::shape_size(inputs[0]->get_shape())); +#include "evaluate_node.hpp" + +template +bool evaluate(const std::shared_ptr& op, ov::TensorVector& outputs, const ov::TensorVector& inputs) { + using T = typename ov::element_type_traits::value_type; + ov::reference::abs(inputs[0].data(), outputs[0].data(), ov::shape_size(inputs[0].get_shape())); return true; } template <> -bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { auto element_type = node->get_output_element_type(0); - if (ov::is_type(node) || ov::is_type(node)) + if (ov::is_type(node) || ov::is_type(node)) element_type = node->get_input_element_type(1); switch (element_type) { - case ngraph::element::Type_t::boolean: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::bf16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i4: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i8: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u1: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u4: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u8: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::boolean: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::bf16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u1: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); default: - OPENVINO_THROW(std::string("Unhandled data type ") + node->get_element_type().get_type_name() + - std::string("in evaluate_node()")); + OPENVINO_THROW("Unhandled data type ", node->get_element_type().get_type_name(), " in evaluate_node()"); } } diff --git a/src/plugins/template/backend/ops/adaptive_avg_pool.cpp b/src/plugins/template/backend/ops/adaptive_avg_pool.cpp index 789460103b92b6..0bd4d1a6fddf8d 100644 --- a/src/plugins/template/backend/ops/adaptive_avg_pool.cpp +++ b/src/plugins/template/backend/ops/adaptive_avg_pool.cpp @@ -6,93 +6,60 @@ #include "evaluate_node.hpp" -template -bool evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { - using T = typename ngraph::element_type_traits::value_type; - ov::reference::adaptive_avg_pool(inputs[0]->get_data_ptr(), - outputs[0]->get_data_ptr(), - inputs[0]->get_shape(), +template +bool evaluate(const std::shared_ptr& op, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { + using T = typename ov::element_type_traits::value_type; + ov::reference::adaptive_avg_pool(inputs[0].data(), + outputs[0].data(), + inputs[0].get_shape(), op->get_output_shape(0)); return true; } template <> -bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { auto element_type = node->get_output_element_type(0); - if (ov::is_type(node) || ov::is_type(node)) + if (ov::is_type(node) || ov::is_type(node)) element_type = node->get_input_element_type(1); switch (element_type) { - case ngraph::element::Type_t::boolean: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::bf16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i4: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i8: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u1: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u4: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u8: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); + case ov::element::boolean: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::bf16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u1: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); default: - OPENVINO_THROW(std::string("Unhandled data type ") + node->get_element_type().get_type_name() + - std::string("in evaluate_node()")); + OPENVINO_THROW("Unhandled data type ", node->get_element_type().get_type_name(), " in evaluate_node()"); } } diff --git a/src/plugins/template/backend/ops/adaptive_max_pool.cpp b/src/plugins/template/backend/ops/adaptive_max_pool.cpp index e70fc9195a2d65..52aec1ea410556 100644 --- a/src/plugins/template/backend/ops/adaptive_max_pool.cpp +++ b/src/plugins/template/backend/ops/adaptive_max_pool.cpp @@ -2,108 +2,73 @@ // SPDX-License-Identifier: Apache-2.0 // -// clang-format off -#include "evaluate_node.hpp" -#include "openvino/reference/adaptive_avg_pool.hpp" #include "openvino/reference/adaptive_max_pool.hpp" -// clang-format on -template -bool evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { - using T = typename ngraph::element_type_traits::value_type; - if (op->get_index_element_type() == ngraph::element::i32) { - ov::reference::adaptive_max_pool(inputs[0]->get_data_ptr(), - outputs[0]->get_data_ptr(), - outputs[1]->get_data_ptr(), - inputs[0]->get_shape(), +#include "evaluate_node.hpp" + +template +bool evaluate(const std::shared_ptr& op, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { + using T = typename ov::element_type_traits::value_type; + if (op->get_index_element_type() == ov::element::i32) { + ov::reference::adaptive_max_pool(inputs[0].data(), + outputs[0].data(), + outputs[1].data(), + inputs[0].get_shape(), op->get_output_shape(0)); - } else if (op->get_index_element_type() == ngraph::element::i64) { - ov::reference::adaptive_max_pool(inputs[0]->get_data_ptr(), - outputs[0]->get_data_ptr(), - outputs[1]->get_data_ptr(), - inputs[0]->get_shape(), + } else if (op->get_index_element_type() == ov::element::i64) { + ov::reference::adaptive_max_pool(inputs[0].data(), + outputs[0].data(), + outputs[1].data(), + inputs[0].get_shape(), op->get_output_shape(0)); } return true; } template <> -bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { auto element_type = node->get_output_element_type(0); - if (ov::is_type(node) || ov::is_type(node)) + if (ov::is_type(node) || ov::is_type(node)) element_type = node->get_input_element_type(1); switch (element_type) { - case ngraph::element::Type_t::boolean: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::bf16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i4: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i8: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u1: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u4: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u8: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); + case ov::element::boolean: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::bf16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u1: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); default: - OPENVINO_THROW(std::string("Unhandled data type ") + node->get_element_type().get_type_name() + - std::string("in evaluate_node()")); + OPENVINO_THROW("Unhandled data type ", node->get_element_type().get_type_name(), " in evaluate_node()"); } } diff --git a/src/plugins/template/backend/ops/assign.cpp b/src/plugins/template/backend/ops/assign.cpp index 8cdef6c7677e9c..3f4b5f108d5662 100644 --- a/src/plugins/template/backend/ops/assign.cpp +++ b/src/plugins/template/backend/ops/assign.cpp @@ -4,61 +4,21 @@ #include "evaluate_node.hpp" -template -bool evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { - outputs[0]->set_unary(inputs[0]); - void* input = inputs[0]->get_data_ptr(); - outputs[0]->write(input, outputs[0]->get_size_in_bytes()); +bool evaluate(const std::shared_ptr& op, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { + outputs[0].set_shape(inputs[0].get_shape()); + inputs[0].copy_to(outputs[0]); return true; } template <> -bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { auto element_type = node->get_output_element_type(0); - if (ov::is_type(node) || ov::is_type(node)) + if (ov::is_type(node) || ov::is_type(node)) element_type = node->get_input_element_type(1); - switch (element_type) { - case ngraph::element::Type_t::boolean: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::bf16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i4: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i8: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u1: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u4: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u8: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - default: - OPENVINO_THROW(std::string("Unhandled data type ") + node->get_element_type().get_type_name() + - std::string("in evaluate_node()")); - } + return evaluate(ov::as_type_ptr(node), outputs, inputs); } diff --git a/src/plugins/template/backend/ops/avg_pool.cpp b/src/plugins/template/backend/ops/avg_pool.cpp index b6f3a6a9803eca..03d610fcd1ae70 100644 --- a/src/plugins/template/backend/ops/avg_pool.cpp +++ b/src/plugins/template/backend/ops/avg_pool.cpp @@ -6,14 +6,14 @@ #include "evaluate_node.hpp" -template -bool evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { - using T = typename ngraph::element_type_traits::value_type; - ov::reference::avg_pool(inputs[0]->get_data_ptr(), - outputs[0]->get_data_ptr(), - inputs[0]->get_shape(), +template +bool evaluate(const std::shared_ptr& op, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { + using T = typename ov::element_type_traits::value_type; + ov::reference::avg_pool(inputs[0].data(), + outputs[0].data(), + inputs[0].get_shape(), op->get_output_shape(0), op->get_kernel(), op->get_strides(), @@ -24,50 +24,47 @@ bool evaluate(const std::shared_ptr& op, } template <> -bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { auto element_type = node->get_output_element_type(0); - if (ov::is_type(node) || ov::is_type(node)) + if (ov::is_type(node) || ov::is_type(node)) element_type = node->get_input_element_type(1); switch (element_type) { - case ngraph::element::Type_t::boolean: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::bf16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i4: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i8: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u1: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u4: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u8: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::boolean: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::bf16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u1: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); default: - OPENVINO_THROW(std::string("Unhandled data type ") + node->get_element_type().get_type_name() + - std::string("in evaluate_node()")); + OPENVINO_THROW("Unhandled data type ", node->get_element_type().get_type_name(), " in evaluate_node()"); } } diff --git a/src/plugins/template/backend/ops/batch_norm.cpp b/src/plugins/template/backend/ops/batch_norm.cpp index 012fc449186bf9..7a7821070818f6 100644 --- a/src/plugins/template/backend/ops/batch_norm.cpp +++ b/src/plugins/template/backend/ops/batch_norm.cpp @@ -6,192 +6,126 @@ #include "evaluate_node.hpp" -template -bool evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { - using T = typename ngraph::element_type_traits::value_type; +template +bool evaluate(const std::shared_ptr& op, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { + using T = typename ov::element_type_traits::value_type; ov::reference::batch_norm_inference(static_cast(op->get_eps_value()), - inputs[2]->get_data_ptr(), - inputs[0]->get_data_ptr(), - inputs[1]->get_data_ptr(), - inputs[3]->get_data_ptr(), - inputs[4]->get_data_ptr(), - outputs[0]->get_data_ptr(), - inputs[2]->get_shape()); + inputs[2].data(), + inputs[0].data(), + inputs[1].data(), + inputs[3].data(), + inputs[4].data(), + outputs[0].data(), + inputs[2].get_shape()); return true; } -template -bool evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { - using T = typename ngraph::element_type_traits::value_type; +template +bool evaluate(const std::shared_ptr& op, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { + using T = typename ov::element_type_traits::value_type; ov::reference::batch_norm_inference(static_cast(static_cast(op->get_eps_value())), - inputs[0]->get_data_ptr(), - inputs[1]->get_data_ptr(), - inputs[2]->get_data_ptr(), - inputs[3]->get_data_ptr(), - inputs[4]->get_data_ptr(), - outputs[0]->get_data_ptr(), + inputs[0].data(), + inputs[1].data(), + inputs[2].data(), + inputs[3].data(), + inputs[4].data(), + outputs[0].data(), op->get_input_shape(0)); return true; } template <> -bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { auto element_type = node->get_output_element_type(0); - if (ov::is_type(node) || ov::is_type(node)) + if (ov::is_type(node) || ov::is_type(node)) element_type = node->get_input_element_type(1); switch (element_type) { - case ngraph::element::Type_t::boolean: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::bf16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i4: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i8: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u1: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u4: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u8: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); + case ov::element::boolean: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::bf16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u1: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); default: - OPENVINO_THROW(std::string("Unhandled data type ") + node->get_element_type().get_type_name() + - std::string("in evaluate_node()")); + OPENVINO_THROW("Unhandled data type ", node->get_element_type().get_type_name(), " in evaluate_node()"); } } template <> -bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { auto element_type = node->get_output_element_type(0); - if (ov::is_type(node) || ov::is_type(node)) + if (ov::is_type(node) || ov::is_type(node)) element_type = node->get_input_element_type(1); switch (element_type) { - case ngraph::element::Type_t::boolean: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::bf16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i4: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i8: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u1: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u4: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u8: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); + case ov::element::boolean: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::bf16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u1: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); default: - OPENVINO_THROW(std::string("Unhandled data type ") + node->get_element_type().get_type_name() + - std::string("in evaluate_node()")); + OPENVINO_THROW("Unhandled data type ", node->get_element_type().get_type_name(), " in evaluate_node()"); } } diff --git a/src/plugins/template/backend/ops/binary_convolution.cpp b/src/plugins/template/backend/ops/binary_convolution.cpp index 4b09df85a80bdd..1974c749d19826 100644 --- a/src/plugins/template/backend/ops/binary_convolution.cpp +++ b/src/plugins/template/backend/ops/binary_convolution.cpp @@ -7,19 +7,19 @@ #include "evaluate_node.hpp" namespace bin_conv_v1 { -template -inline void evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { - using T_IN = typename ngraph::element_type_traits::value_type; - using T_F = typename ngraph::element_type_traits::value_type; +template +inline void evaluate(const std::shared_ptr& op, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { + using T_IN = typename ov::element_type_traits::value_type; + using T_F = typename ov::element_type_traits::value_type; - const auto in_data_ptr = inputs[0]->get_data_ptr(); - const auto filter_data_ptr = inputs[1]->get_data_ptr(); - auto out_data_ptr = outputs[0]->get_data_ptr(); - const auto in_shape = inputs[0]->get_shape(); - const auto filter_shape = inputs[1]->get_shape(); - const auto out_shape = outputs[0]->get_shape(); + const auto in_data_ptr = static_cast(inputs[0].data()); + const auto filter_data_ptr = static_cast(inputs[1].data()); + auto out_data_ptr = static_cast(outputs[0].data()); + const auto in_shape = inputs[0].get_shape(); + const auto filter_shape = inputs[1].get_shape(); + const auto out_shape = outputs[0].get_shape(); ov::reference::binary_convolution(in_data_ptr, filter_data_ptr, @@ -35,96 +35,63 @@ inline void evaluate(const std::shared_ptr& o } } // namespace bin_conv_v1 -template -bool evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { - switch (inputs[1]->get_element_type()) { - case ngraph::element::Type_t::u1: - bin_conv_v1::evaluate(op, outputs, inputs); +template +bool evaluate(const std::shared_ptr& op, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { + switch (inputs[1].get_element_type()) { + case ov::element::u1: + bin_conv_v1::evaluate(op, outputs, inputs); break; default: - throw std::runtime_error("BinaryConvolution supports only u1 element type for filters input"); + OPENVINO_THROW("BinaryConvolution supports only u1 element type for filters input"); break; } return true; } template <> -bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { auto element_type = node->get_output_element_type(0); - if (ov::is_type(node) || ov::is_type(node)) + if (ov::is_type(node) || ov::is_type(node)) element_type = node->get_input_element_type(1); switch (element_type) { - case ngraph::element::Type_t::boolean: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::bf16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i4: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i8: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u1: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u4: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u8: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); + case ov::element::boolean: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::bf16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u1: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); default: - OPENVINO_THROW(std::string("Unhandled data type ") + node->get_element_type().get_type_name() + - std::string("in evaluate_node()")); + OPENVINO_THROW("Unhandled data type ", node->get_element_type().get_type_name(), " in evaluate_node()"); } } diff --git a/src/plugins/template/backend/ops/bucketize.cpp b/src/plugins/template/backend/ops/bucketize.cpp index b55f7cda250a8f..ca9119fe19255a 100644 --- a/src/plugins/template/backend/ops/bucketize.cpp +++ b/src/plugins/template/backend/ops/bucketize.cpp @@ -7,139 +7,139 @@ #include "evaluate_node.hpp" namespace bucketize_v3 { -template -inline void evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { - using T1 = typename ngraph::element_type_traits::value_type; - using T2 = typename ngraph::element_type_traits::value_type; - using T3 = typename ngraph::element_type_traits::value_type; +template +inline void evaluate(const std::shared_ptr& op, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { + using T1 = typename ov::element_type_traits::value_type; + using T2 = typename ov::element_type_traits::value_type; + using T3 = typename ov::element_type_traits::value_type; - ov::reference::bucketize(inputs[0]->get_data_ptr(), - inputs[1]->get_data_ptr(), - outputs[0]->get_data_ptr(), + ov::reference::bucketize(inputs[0].data(), + inputs[1].data(), + outputs[0].data(), op->get_input_shape(0), op->get_input_shape(1), op->get_with_right_bound()); } -static inline constexpr uint16_t getElementMask(ngraph::element::Type_t type1, ngraph::element::Type_t type2) { +static inline constexpr uint16_t getElementMask(ov::element::Type_t type1, ov::element::Type_t type2) { return (static_cast(type1)) | (static_cast(type2) << 8); } } // namespace bucketize_v3 -template -bool evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +template +bool evaluate(const std::shared_ptr& op, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { switch (bucketize_v3::getElementMask(op->get_input_element_type(0), op->get_input_element_type(1))) { - case bucketize_v3::getElementMask(ngraph::element::Type_t::f32, ngraph::element::Type_t::f32): - bucketize_v3::evaluate(op, outputs, inputs); + case bucketize_v3::getElementMask(ov::element::f32, ov::element::f32): + bucketize_v3::evaluate(op, outputs, inputs); break; - case bucketize_v3::getElementMask(ngraph::element::Type_t::f32, ngraph::element::Type_t::f16): - bucketize_v3::evaluate(op, outputs, inputs); + case bucketize_v3::getElementMask(ov::element::f32, ov::element::f16): + bucketize_v3::evaluate(op, outputs, inputs); break; - case bucketize_v3::getElementMask(ngraph::element::Type_t::f32, ngraph::element::Type_t::i32): - bucketize_v3::evaluate(op, outputs, inputs); + case bucketize_v3::getElementMask(ov::element::f32, ov::element::i32): + bucketize_v3::evaluate(op, outputs, inputs); break; - case bucketize_v3::getElementMask(ngraph::element::Type_t::f32, ngraph::element::Type_t::i64): - bucketize_v3::evaluate(op, outputs, inputs); + case bucketize_v3::getElementMask(ov::element::f32, ov::element::i64): + bucketize_v3::evaluate(op, outputs, inputs); break; - case bucketize_v3::getElementMask(ngraph::element::Type_t::f32, ngraph::element::Type_t::i8): - bucketize_v3::evaluate(op, outputs, inputs); + case bucketize_v3::getElementMask(ov::element::f32, ov::element::i8): + bucketize_v3::evaluate(op, outputs, inputs); break; - case bucketize_v3::getElementMask(ngraph::element::Type_t::f32, ngraph::element::Type_t::u8): - bucketize_v3::evaluate(op, outputs, inputs); + case bucketize_v3::getElementMask(ov::element::f32, ov::element::u8): + bucketize_v3::evaluate(op, outputs, inputs); break; - case bucketize_v3::getElementMask(ngraph::element::Type_t::f16, ngraph::element::Type_t::f32): - bucketize_v3::evaluate(op, outputs, inputs); + case bucketize_v3::getElementMask(ov::element::f16, ov::element::f32): + bucketize_v3::evaluate(op, outputs, inputs); break; - case bucketize_v3::getElementMask(ngraph::element::Type_t::f16, ngraph::element::Type_t::f16): - bucketize_v3::evaluate(op, outputs, inputs); + case bucketize_v3::getElementMask(ov::element::f16, ov::element::f16): + bucketize_v3::evaluate(op, outputs, inputs); break; - case bucketize_v3::getElementMask(ngraph::element::Type_t::f16, ngraph::element::Type_t::i32): - bucketize_v3::evaluate(op, outputs, inputs); + case bucketize_v3::getElementMask(ov::element::f16, ov::element::i32): + bucketize_v3::evaluate(op, outputs, inputs); break; - case bucketize_v3::getElementMask(ngraph::element::Type_t::f16, ngraph::element::Type_t::i64): - bucketize_v3::evaluate(op, outputs, inputs); + case bucketize_v3::getElementMask(ov::element::f16, ov::element::i64): + bucketize_v3::evaluate(op, outputs, inputs); break; - case bucketize_v3::getElementMask(ngraph::element::Type_t::f16, ngraph::element::Type_t::i8): - bucketize_v3::evaluate(op, outputs, inputs); + case bucketize_v3::getElementMask(ov::element::f16, ov::element::i8): + bucketize_v3::evaluate(op, outputs, inputs); break; - case bucketize_v3::getElementMask(ngraph::element::Type_t::f16, ngraph::element::Type_t::u8): - bucketize_v3::evaluate(op, outputs, inputs); + case bucketize_v3::getElementMask(ov::element::f16, ov::element::u8): + bucketize_v3::evaluate(op, outputs, inputs); break; - case bucketize_v3::getElementMask(ngraph::element::Type_t::i32, ngraph::element::Type_t::f32): - bucketize_v3::evaluate(op, outputs, inputs); + case bucketize_v3::getElementMask(ov::element::i32, ov::element::f32): + bucketize_v3::evaluate(op, outputs, inputs); break; - case bucketize_v3::getElementMask(ngraph::element::Type_t::i32, ngraph::element::Type_t::f16): - bucketize_v3::evaluate(op, outputs, inputs); + case bucketize_v3::getElementMask(ov::element::i32, ov::element::f16): + bucketize_v3::evaluate(op, outputs, inputs); break; - case bucketize_v3::getElementMask(ngraph::element::Type_t::i32, ngraph::element::Type_t::i32): - bucketize_v3::evaluate(op, outputs, inputs); + case bucketize_v3::getElementMask(ov::element::i32, ov::element::i32): + bucketize_v3::evaluate(op, outputs, inputs); break; - case bucketize_v3::getElementMask(ngraph::element::Type_t::i32, ngraph::element::Type_t::i64): - bucketize_v3::evaluate(op, outputs, inputs); + case bucketize_v3::getElementMask(ov::element::i32, ov::element::i64): + bucketize_v3::evaluate(op, outputs, inputs); break; - case bucketize_v3::getElementMask(ngraph::element::Type_t::i32, ngraph::element::Type_t::i8): - bucketize_v3::evaluate(op, outputs, inputs); + case bucketize_v3::getElementMask(ov::element::i32, ov::element::i8): + bucketize_v3::evaluate(op, outputs, inputs); break; - case bucketize_v3::getElementMask(ngraph::element::Type_t::i32, ngraph::element::Type_t::u8): - bucketize_v3::evaluate(op, outputs, inputs); + case bucketize_v3::getElementMask(ov::element::i32, ov::element::u8): + bucketize_v3::evaluate(op, outputs, inputs); break; - case bucketize_v3::getElementMask(ngraph::element::Type_t::i64, ngraph::element::Type_t::f32): - bucketize_v3::evaluate(op, outputs, inputs); + case bucketize_v3::getElementMask(ov::element::i64, ov::element::f32): + bucketize_v3::evaluate(op, outputs, inputs); break; - case bucketize_v3::getElementMask(ngraph::element::Type_t::i64, ngraph::element::Type_t::f16): - bucketize_v3::evaluate(op, outputs, inputs); + case bucketize_v3::getElementMask(ov::element::i64, ov::element::f16): + bucketize_v3::evaluate(op, outputs, inputs); break; - case bucketize_v3::getElementMask(ngraph::element::Type_t::i64, ngraph::element::Type_t::i32): - bucketize_v3::evaluate(op, outputs, inputs); + case bucketize_v3::getElementMask(ov::element::i64, ov::element::i32): + bucketize_v3::evaluate(op, outputs, inputs); break; - case bucketize_v3::getElementMask(ngraph::element::Type_t::i64, ngraph::element::Type_t::i64): - bucketize_v3::evaluate(op, outputs, inputs); + case bucketize_v3::getElementMask(ov::element::i64, ov::element::i64): + bucketize_v3::evaluate(op, outputs, inputs); break; - case bucketize_v3::getElementMask(ngraph::element::Type_t::i64, ngraph::element::Type_t::i8): - bucketize_v3::evaluate(op, outputs, inputs); + case bucketize_v3::getElementMask(ov::element::i64, ov::element::i8): + bucketize_v3::evaluate(op, outputs, inputs); break; - case bucketize_v3::getElementMask(ngraph::element::Type_t::i64, ngraph::element::Type_t::u8): - bucketize_v3::evaluate(op, outputs, inputs); + case bucketize_v3::getElementMask(ov::element::i64, ov::element::u8): + bucketize_v3::evaluate(op, outputs, inputs); break; - case bucketize_v3::getElementMask(ngraph::element::Type_t::i8, ngraph::element::Type_t::f32): - bucketize_v3::evaluate(op, outputs, inputs); + case bucketize_v3::getElementMask(ov::element::i8, ov::element::f32): + bucketize_v3::evaluate(op, outputs, inputs); break; - case bucketize_v3::getElementMask(ngraph::element::Type_t::i8, ngraph::element::Type_t::f16): - bucketize_v3::evaluate(op, outputs, inputs); + case bucketize_v3::getElementMask(ov::element::i8, ov::element::f16): + bucketize_v3::evaluate(op, outputs, inputs); break; - case bucketize_v3::getElementMask(ngraph::element::Type_t::i8, ngraph::element::Type_t::i32): - bucketize_v3::evaluate(op, outputs, inputs); + case bucketize_v3::getElementMask(ov::element::i8, ov::element::i32): + bucketize_v3::evaluate(op, outputs, inputs); break; - case bucketize_v3::getElementMask(ngraph::element::Type_t::i8, ngraph::element::Type_t::i64): - bucketize_v3::evaluate(op, outputs, inputs); + case bucketize_v3::getElementMask(ov::element::i8, ov::element::i64): + bucketize_v3::evaluate(op, outputs, inputs); break; - case bucketize_v3::getElementMask(ngraph::element::Type_t::i8, ngraph::element::Type_t::i8): - bucketize_v3::evaluate(op, outputs, inputs); + case bucketize_v3::getElementMask(ov::element::i8, ov::element::i8): + bucketize_v3::evaluate(op, outputs, inputs); break; - case bucketize_v3::getElementMask(ngraph::element::Type_t::i8, ngraph::element::Type_t::u8): - bucketize_v3::evaluate(op, outputs, inputs); + case bucketize_v3::getElementMask(ov::element::i8, ov::element::u8): + bucketize_v3::evaluate(op, outputs, inputs); break; - case bucketize_v3::getElementMask(ngraph::element::Type_t::u8, ngraph::element::Type_t::f32): - bucketize_v3::evaluate(op, outputs, inputs); + case bucketize_v3::getElementMask(ov::element::u8, ov::element::f32): + bucketize_v3::evaluate(op, outputs, inputs); break; - case bucketize_v3::getElementMask(ngraph::element::Type_t::u8, ngraph::element::Type_t::f16): - bucketize_v3::evaluate(op, outputs, inputs); + case bucketize_v3::getElementMask(ov::element::u8, ov::element::f16): + bucketize_v3::evaluate(op, outputs, inputs); break; - case bucketize_v3::getElementMask(ngraph::element::Type_t::u8, ngraph::element::Type_t::i32): - bucketize_v3::evaluate(op, outputs, inputs); + case bucketize_v3::getElementMask(ov::element::u8, ov::element::i32): + bucketize_v3::evaluate(op, outputs, inputs); break; - case bucketize_v3::getElementMask(ngraph::element::Type_t::u8, ngraph::element::Type_t::i64): - bucketize_v3::evaluate(op, outputs, inputs); + case bucketize_v3::getElementMask(ov::element::u8, ov::element::i64): + bucketize_v3::evaluate(op, outputs, inputs); break; - case bucketize_v3::getElementMask(ngraph::element::Type_t::u8, ngraph::element::Type_t::i8): - bucketize_v3::evaluate(op, outputs, inputs); + case bucketize_v3::getElementMask(ov::element::u8, ov::element::i8): + bucketize_v3::evaluate(op, outputs, inputs); break; - case bucketize_v3::getElementMask(ngraph::element::Type_t::u8, ngraph::element::Type_t::u8): - bucketize_v3::evaluate(op, outputs, inputs); + case bucketize_v3::getElementMask(ov::element::u8, ov::element::u8): + bucketize_v3::evaluate(op, outputs, inputs); break; default: return false; @@ -148,70 +148,47 @@ bool evaluate(const std::shared_ptr& op, } template <> -bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { auto element_type = node->get_output_element_type(0); - if (ov::is_type(node) || ov::is_type(node)) + if (ov::is_type(node) || ov::is_type(node)) element_type = node->get_input_element_type(1); switch (element_type) { - case ngraph::element::Type_t::boolean: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::bf16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i4: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i8: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u1: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u4: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u8: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); + case ov::element::boolean: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::bf16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u1: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); default: - OPENVINO_THROW(std::string("Unhandled data type ") + node->get_element_type().get_type_name() + - std::string("in evaluate_node()")); + OPENVINO_THROW("Unhandled data type ", node->get_element_type().get_type_name(), " in evaluate_node()"); } } diff --git a/src/plugins/template/backend/ops/ceiling.cpp b/src/plugins/template/backend/ops/ceiling.cpp index 19c3127a43c523..3278219a3e6b6b 100644 --- a/src/plugins/template/backend/ops/ceiling.cpp +++ b/src/plugins/template/backend/ops/ceiling.cpp @@ -6,62 +6,57 @@ #include "evaluate_node.hpp" -template -bool evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { - using T = typename ngraph::element_type_traits::value_type; - ov::reference::ceiling(inputs[0]->get_data_ptr(), - outputs[0]->get_data_ptr(), - ngraph::shape_size(inputs[0]->get_shape())); +template +bool evaluate(const std::shared_ptr& op, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { + using T = typename ov::element_type_traits::value_type; + ov::reference::ceiling(inputs[0].data(), outputs[0].data(), ov::shape_size(inputs[0].get_shape())); return true; } template <> -bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { auto element_type = node->get_output_element_type(0); - if (ov::is_type(node) || ov::is_type(node)) + if (ov::is_type(node) || ov::is_type(node)) element_type = node->get_input_element_type(1); switch (element_type) { - case ngraph::element::Type_t::boolean: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::bf16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i4: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i8: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u1: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u4: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u8: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::boolean: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::bf16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u1: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); default: - OPENVINO_THROW(std::string("Unhandled data type ") + node->get_element_type().get_type_name() + - std::string("in evaluate_node()")); + OPENVINO_THROW("Unhandled data type ", node->get_element_type().get_type_name(), " in evaluate_node()"); } } diff --git a/src/plugins/template/backend/ops/convert.cpp b/src/plugins/template/backend/ops/convert.cpp index 319818a5727854..71f6f3cc87a152 100644 --- a/src/plugins/template/backend/ops/convert.cpp +++ b/src/plugins/template/backend/ops/convert.cpp @@ -7,79 +7,76 @@ #include "evaluate_node.hpp" namespace convert_like_v1 { -template -inline void evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { - outputs[0]->set_shape(inputs[0]->get_shape()); - size_t element_count = ngraph::shape_size(outputs[0]->get_shape()); +template +inline void evaluate(const std::shared_ptr& op, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { + using T_I = typename ov::element_type_traits::value_type; + using T_O = typename ov::element_type_traits::value_type; + outputs[0].set_shape(inputs[0].get_shape()); + size_t element_count = ov::shape_size(outputs[0].get_shape()); - if (((ti == ngraph::element::u1) || (to == ngraph::element::u1)) || - ((ti == ngraph::element::u4) || (to == ngraph::element::u4)) || - ((ti == ngraph::element::i4) || (to == ngraph::element::i4))) { - ov::reference::detail::lp_convert(inputs[0]->get_data_ptr(), - outputs[0]->get_data_ptr(), - element_count, - ti, - to); + if (((ti == ov::element::u1) || (to == ov::element::u1)) || ((ti == ov::element::u4) || (to == ov::element::u4)) || + ((ti == ov::element::i4) || (to == ov::element::i4))) { + ov::reference::detail::lp_convert(inputs[0].data(), outputs[0].data(), element_count, ti, to); } else { - ov::reference::convert(inputs[0]->get_data_ptr(), outputs[0]->get_data_ptr(), element_count); + ov::reference::convert(inputs[0].data(), outputs[0].data(), element_count); } } } // namespace convert_like_v1 -template -bool evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { - switch (inputs[0]->get_element_type()) { - case ngraph::element::Type_t::boolean: - convert_like_v1::evaluate(op, outputs, inputs); +template +bool evaluate(const std::shared_ptr& op, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { + switch (inputs[0].get_element_type()) { + case ov::element::boolean: + convert_like_v1::evaluate(op, outputs, inputs); break; - case ngraph::element::Type_t::u1: - convert_like_v1::evaluate(op, outputs, inputs); + case ov::element::u1: + convert_like_v1::evaluate(op, outputs, inputs); break; - case ngraph::element::Type_t::u4: - convert_like_v1::evaluate(op, outputs, inputs); + case ov::element::u4: + convert_like_v1::evaluate(op, outputs, inputs); break; - case ngraph::element::Type_t::u8: - convert_like_v1::evaluate(op, outputs, inputs); + case ov::element::u8: + convert_like_v1::evaluate(op, outputs, inputs); break; - case ngraph::element::Type_t::u16: - convert_like_v1::evaluate(op, outputs, inputs); + case ov::element::u16: + convert_like_v1::evaluate(op, outputs, inputs); break; - case ngraph::element::Type_t::u32: - convert_like_v1::evaluate(op, outputs, inputs); + case ov::element::u32: + convert_like_v1::evaluate(op, outputs, inputs); break; - case ngraph::element::Type_t::u64: - convert_like_v1::evaluate(op, outputs, inputs); + case ov::element::u64: + convert_like_v1::evaluate(op, outputs, inputs); break; - case ngraph::element::Type_t::i4: - convert_like_v1::evaluate(op, outputs, inputs); + case ov::element::i4: + convert_like_v1::evaluate(op, outputs, inputs); break; - case ngraph::element::Type_t::i8: - convert_like_v1::evaluate(op, outputs, inputs); + case ov::element::i8: + convert_like_v1::evaluate(op, outputs, inputs); break; - case ngraph::element::Type_t::i16: - convert_like_v1::evaluate(op, outputs, inputs); + case ov::element::i16: + convert_like_v1::evaluate(op, outputs, inputs); break; - case ngraph::element::Type_t::i32: - convert_like_v1::evaluate(op, outputs, inputs); + case ov::element::i32: + convert_like_v1::evaluate(op, outputs, inputs); break; - case ngraph::element::Type_t::i64: - convert_like_v1::evaluate(op, outputs, inputs); + case ov::element::i64: + convert_like_v1::evaluate(op, outputs, inputs); break; - case ngraph::element::Type_t::bf16: - convert_like_v1::evaluate(op, outputs, inputs); + case ov::element::bf16: + convert_like_v1::evaluate(op, outputs, inputs); break; - case ngraph::element::Type_t::f16: - convert_like_v1::evaluate(op, outputs, inputs); + case ov::element::f16: + convert_like_v1::evaluate(op, outputs, inputs); break; - case ngraph::element::Type_t::f32: - convert_like_v1::evaluate(op, outputs, inputs); + case ov::element::f32: + convert_like_v1::evaluate(op, outputs, inputs); break; - case ngraph::element::Type_t::f64: - convert_like_v1::evaluate(op, outputs, inputs); + case ov::element::f64: + convert_like_v1::evaluate(op, outputs, inputs); break; default: return false; @@ -88,80 +85,47 @@ bool evaluate(const std::shared_ptr& op, } template <> -bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { auto element_type = node->get_output_element_type(0); - if (ov::is_type(node) || ov::is_type(node)) + if (ov::is_type(node) || ov::is_type(node)) element_type = node->get_input_element_type(1); switch (element_type) { - case ngraph::element::Type_t::boolean: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::bf16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i4: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i8: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u1: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u4: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u8: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); + case ov::element::boolean: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::bf16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u1: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); default: - OPENVINO_THROW(std::string("Unhandled data type ") + node->get_element_type().get_type_name() + - std::string("in evaluate_node()")); + OPENVINO_THROW("Unhandled data type ", node->get_element_type().get_type_name(), " in evaluate_node()"); } } diff --git a/src/plugins/template/backend/ops/convert_color_nv12.cpp b/src/plugins/template/backend/ops/convert_color_nv12.cpp index 3b9996da285192..f2b571f73cacfb 100644 --- a/src/plugins/template/backend/ops/convert_color_nv12.cpp +++ b/src/plugins/template/backend/ops/convert_color_nv12.cpp @@ -7,9 +7,9 @@ #include "evaluate_node.hpp" template -inline bool evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +inline bool evaluate(const std::shared_ptr& op, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { return ov::reference::color_convert_nv12(op, outputs, inputs, @@ -17,9 +17,9 @@ inline bool evaluate(const std::shared_ptr& op, } template -inline bool evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +inline bool evaluate(const std::shared_ptr& op, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { return ov::reference::color_convert_nv12(op, outputs, inputs, @@ -27,9 +27,9 @@ inline bool evaluate(const std::shared_ptr& op, } template -inline bool evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +inline bool evaluate(const std::shared_ptr& op, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { return ov::reference::color_convert_i420(op, outputs, inputs, @@ -37,9 +37,9 @@ inline bool evaluate(const std::shared_ptr& op, } template -inline bool evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +inline bool evaluate(const std::shared_ptr& op, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { return ov::reference::color_convert_i420(op, outputs, inputs, @@ -47,68 +47,46 @@ inline bool evaluate(const std::shared_ptr& op, } template <> -bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { auto element_type = node->get_output_element_type(0); - if (ov::is_type(node) || ov::is_type(node)) + if (ov::is_type(node) || ov::is_type(node)) element_type = node->get_input_element_type(1); switch (element_type) { - case ngraph::element::Type_t::boolean: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::bf16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i4: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i8: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u1: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u4: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u8: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); + case ov::element::boolean: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::bf16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u1: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); default: OPENVINO_THROW(std::string("Unhandled data type ") + node->get_element_type().get_type_name() + std::string("in evaluate_node()")); @@ -116,68 +94,46 @@ bool evaluate_node(std::shared_ptr node } template <> -bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { auto element_type = node->get_output_element_type(0); - if (ov::is_type(node) || ov::is_type(node)) + if (ov::is_type(node) || ov::is_type(node)) element_type = node->get_input_element_type(1); switch (element_type) { - case ngraph::element::Type_t::boolean: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::bf16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i4: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i8: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u1: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u4: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u8: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); + case ov::element::boolean: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::bf16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u1: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); default: OPENVINO_THROW(std::string("Unhandled data type ") + node->get_element_type().get_type_name() + std::string("in evaluate_node()")); @@ -185,68 +141,46 @@ bool evaluate_node(std::shared_ptr node } template <> -bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { auto element_type = node->get_output_element_type(0); - if (ov::is_type(node) || ov::is_type(node)) + if (ov::is_type(node) || ov::is_type(node)) element_type = node->get_input_element_type(1); switch (element_type) { - case ngraph::element::Type_t::boolean: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::bf16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i4: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i8: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u1: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u4: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u8: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); + case ov::element::boolean: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::bf16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u1: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); default: OPENVINO_THROW(std::string("Unhandled data type ") + node->get_element_type().get_type_name() + std::string("in evaluate_node()")); @@ -254,70 +188,47 @@ bool evaluate_node(std::shared_ptr node } template <> -bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { auto element_type = node->get_output_element_type(0); - if (ov::is_type(node) || ov::is_type(node)) + if (ov::is_type(node) || ov::is_type(node)) element_type = node->get_input_element_type(1); switch (element_type) { - case ngraph::element::Type_t::boolean: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::bf16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i4: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i8: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u1: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u4: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u8: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); + case ov::element::boolean: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::bf16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u1: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); default: - OPENVINO_THROW(std::string("Unhandled data type ") + node->get_element_type().get_type_name() + - std::string("in evaluate_node()")); + OPENVINO_THROW("Unhandled data type ", node->get_element_type().get_type_name(), " in evaluate_node()"); } } diff --git a/src/plugins/template/backend/ops/convolution.cpp b/src/plugins/template/backend/ops/convolution.cpp index 1af7805495022f..ea7e7ba20c1675 100644 --- a/src/plugins/template/backend/ops/convolution.cpp +++ b/src/plugins/template/backend/ops/convolution.cpp @@ -6,104 +6,72 @@ #include "evaluate_node.hpp" -template -bool evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { - const auto filter_data = inputs[1]->get_data_ptr(); - auto out_data_ptr = outputs[0]->get_data_ptr(); - const auto in_data_ptr = inputs[0]->get_data_ptr(); - const auto& out_shape = outputs[0]->get_shape(); - const auto& in_shape = inputs[0]->get_shape(); - const auto& filter_shape = inputs[1]->get_shape(); - ov::reference::convolution::value_type>(in_data_ptr, - filter_data, - out_data_ptr, - in_shape, - filter_shape, - out_shape, - op->get_strides(), - op->get_dilations(), - op->get_pads_begin(), - op->get_pads_end()); +template +bool evaluate(const std::shared_ptr& op, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { + using ET = typename ov::element_type_traits::value_type; + const auto filter_data = inputs[1].data(); + auto out_data_ptr = outputs[0].data(); + const auto in_data_ptr = inputs[0].data(); + const auto& out_shape = outputs[0].get_shape(); + const auto& in_shape = inputs[0].get_shape(); + const auto& filter_shape = inputs[1].get_shape(); + ov::reference::convolution(in_data_ptr, + filter_data, + out_data_ptr, + in_shape, + filter_shape, + out_shape, + op->get_strides(), + op->get_dilations(), + op->get_pads_begin(), + op->get_pads_end()); return true; } template <> -bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { auto element_type = node->get_output_element_type(0); - if (ov::is_type(node) || ov::is_type(node)) + if (ov::is_type(node) || ov::is_type(node)) element_type = node->get_input_element_type(1); switch (element_type) { - case ngraph::element::Type_t::boolean: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::bf16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i4: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i8: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u1: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u4: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u8: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); + case ov::element::boolean: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::bf16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u1: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); default: - OPENVINO_THROW(std::string("Unhandled data type ") + node->get_element_type().get_type_name() + - std::string("in evaluate_node()")); + OPENVINO_THROW("Unhandled data type ", node->get_element_type().get_type_name(), " in evaluate_node()"); } } diff --git a/src/plugins/template/backend/ops/convolution_backprop_data.cpp b/src/plugins/template/backend/ops/convolution_backprop_data.cpp index e0d7d7aafcb650..a9d8ebb6ef30e9 100644 --- a/src/plugins/template/backend/ops/convolution_backprop_data.cpp +++ b/src/plugins/template/backend/ops/convolution_backprop_data.cpp @@ -6,110 +6,78 @@ #include "evaluate_node.hpp" -template -bool evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { - const auto filter_data = inputs[1]->get_data_ptr(); - auto out_data_ptr = outputs[0]->get_data_ptr(); - const auto in_data_ptr = inputs[0]->get_data_ptr(); - const auto& out_shape = outputs[0]->get_shape(); - const auto& in_shape = inputs[0]->get_shape(); - const auto& filter_shape = inputs[1]->get_shape(); - ngraph::Strides in_dilation(std::vector(in_shape.size() - 2)); +template +bool evaluate(const std::shared_ptr& op, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { + using ET = typename ov::element_type_traits::value_type; + const auto filter_data = inputs[1].data(); + auto out_data_ptr = outputs[0].data(); + const auto in_data_ptr = inputs[0].data(); + const auto& out_shape = outputs[0].get_shape(); + const auto& in_shape = inputs[0].get_shape(); + const auto& filter_shape = inputs[1].get_shape(); + ov::Strides in_dilation(std::vector(in_shape.size() - 2)); std::fill(in_dilation.begin(), in_dilation.end(), 1); - ov::reference::convolution_backprop_in::value_type>( - in_data_ptr, - filter_data, - out_data_ptr, - in_shape, - filter_shape, - out_shape, - in_dilation, - op->get_dilations(), - op->get_pads_begin(), - op->get_pads_end(), - op->get_strides(), - op->get_output_padding()); + ov::reference::convolution_backprop_in(in_data_ptr, + filter_data, + out_data_ptr, + in_shape, + filter_shape, + out_shape, + in_dilation, + op->get_dilations(), + op->get_pads_begin(), + op->get_pads_end(), + op->get_strides(), + op->get_output_padding()); return true; } template <> -bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { auto element_type = node->get_output_element_type(0); - if (ov::is_type(node) || ov::is_type(node)) + if (ov::is_type(node) || ov::is_type(node)) element_type = node->get_input_element_type(1); switch (element_type) { - case ngraph::element::Type_t::boolean: - return evaluate( - ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::bf16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i4: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i8: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u1: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u4: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u8: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); + case ov::element::boolean: + return evaluate(ov::as_type_ptr(node), + outputs, + inputs); + case ov::element::bf16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u1: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); default: - OPENVINO_THROW(std::string("Unhandled data type ") + node->get_element_type().get_type_name() + - std::string("in evaluate_node()")); + OPENVINO_THROW("Unhandled data type ", node->get_element_type().get_type_name(), " in evaluate_node()"); } } diff --git a/src/plugins/template/backend/ops/ctc_greedy_decoder.cpp b/src/plugins/template/backend/ops/ctc_greedy_decoder.cpp index b0bbeffd5a0e18..de6f162ab44b3b 100644 --- a/src/plugins/template/backend/ops/ctc_greedy_decoder.cpp +++ b/src/plugins/template/backend/ops/ctc_greedy_decoder.cpp @@ -6,96 +6,63 @@ #include "evaluate_node.hpp" -template -bool evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { - using T = typename ngraph::element_type_traits::value_type; - ov::reference::ctc_greedy_decoder(inputs[0]->get_data_ptr(), - inputs[1]->get_data_ptr(), - outputs[0]->get_data_ptr(), - inputs[0]->get_shape(), - inputs[1]->get_shape(), - outputs[0]->get_shape(), +template +bool evaluate(const std::shared_ptr& op, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { + using T = typename ov::element_type_traits::value_type; + ov::reference::ctc_greedy_decoder(inputs[0].data(), + inputs[1].data(), + outputs[0].data(), + inputs[0].get_shape(), + inputs[1].get_shape(), + outputs[0].get_shape(), op->get_ctc_merge_repeated()); return true; } template <> -bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { auto element_type = node->get_output_element_type(0); - if (ov::is_type(node) || ov::is_type(node)) + if (ov::is_type(node) || ov::is_type(node)) element_type = node->get_input_element_type(1); switch (element_type) { - case ngraph::element::Type_t::boolean: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::bf16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i4: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i8: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u1: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u4: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u8: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); + case ov::element::boolean: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::bf16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u1: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); default: - OPENVINO_THROW(std::string("Unhandled data type ") + node->get_element_type().get_type_name() + - std::string("in evaluate_node()")); + OPENVINO_THROW("Unhandled data type ", node->get_element_type().get_type_name(), " in evaluate_node()"); } } diff --git a/src/plugins/template/backend/ops/ctc_greedy_decoder_seq_len.cpp b/src/plugins/template/backend/ops/ctc_greedy_decoder_seq_len.cpp index 7cff484d99ef6c..b76c5459cdfc7c 100644 --- a/src/plugins/template/backend/ops/ctc_greedy_decoder_seq_len.cpp +++ b/src/plugins/template/backend/ops/ctc_greedy_decoder_seq_len.cpp @@ -7,69 +7,57 @@ #include "evaluate_node.hpp" namespace ctc_greedy_decoder_v6 { -template -inline void evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { - using TF = typename ngraph::element_type_traits::value_type; - using TI = typename ngraph::element_type_traits::value_type; - using TIND1 = typename ngraph::element_type_traits::value_type; - TI blank_index_val = static_cast(inputs[0]->get_shape().back() - 1); +template +inline void evaluate(const std::shared_ptr& op, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { + using TF = typename ov::element_type_traits::value_type; + using TI = typename ov::element_type_traits::value_type; + using TIND1 = typename ov::element_type_traits::value_type; + TI blank_index_val = static_cast(inputs[0].get_shape().back() - 1); const TI* blank_index = &blank_index_val; if (inputs.size() == 3) { - blank_index = inputs[2]->get_data_ptr(); + blank_index = inputs[2].data(); } - if (op->get_sequence_length_type() == ngraph::element::i32) { - ov::reference::ctc_greedy_decoder_seq_len(inputs[0]->get_data_ptr(), - inputs[1]->get_data_ptr(), + if (op->get_sequence_length_type() == ov::element::i32) { + ov::reference::ctc_greedy_decoder_seq_len(inputs[0].data(), + inputs[1].data(), blank_index, - outputs[0]->get_data_ptr(), - outputs[1]->get_data_ptr(), - inputs[0]->get_shape(), - outputs[0]->get_shape(), + outputs[0].data(), + outputs[1].data(), + inputs[0].get_shape(), + outputs[0].get_shape(), op->get_merge_repeated()); - } else if (op->get_sequence_length_type() == ngraph::element::i64) { - ov::reference::ctc_greedy_decoder_seq_len(inputs[0]->get_data_ptr(), - inputs[1]->get_data_ptr(), + } else if (op->get_sequence_length_type() == ov::element::i64) { + ov::reference::ctc_greedy_decoder_seq_len(inputs[0].data(), + inputs[1].data(), blank_index, - outputs[0]->get_data_ptr(), - outputs[1]->get_data_ptr(), - inputs[0]->get_shape(), - outputs[0]->get_shape(), + outputs[0].data(), + outputs[1].data(), + inputs[0].get_shape(), + outputs[0].get_shape(), op->get_merge_repeated()); } } } // namespace ctc_greedy_decoder_v6 -template -bool evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { - const auto& dataType = inputs[0]->get_element_type(); - const auto& seqLenType = inputs[1]->get_element_type(); - if (dataType == ngraph::element::Type_t::f16 && seqLenType == ngraph::element::Type_t::i32) { - ctc_greedy_decoder_v6::evaluate(op, - outputs, - inputs); - } else if (dataType == ngraph::element::Type_t::f32 && seqLenType == ngraph::element::Type_t::i32) { - ctc_greedy_decoder_v6::evaluate(op, - outputs, - inputs); - } else if (dataType == ngraph::element::Type_t::f64 && seqLenType == ngraph::element::Type_t::i32) { - ctc_greedy_decoder_v6::evaluate(op, - outputs, - inputs); - } else if (dataType == ngraph::element::Type_t::f16 && seqLenType == ngraph::element::Type_t::i64) { - ctc_greedy_decoder_v6::evaluate(op, - outputs, - inputs); - } else if (dataType == ngraph::element::Type_t::f32 && seqLenType == ngraph::element::Type_t::i64) { - ctc_greedy_decoder_v6::evaluate(op, - outputs, - inputs); - } else if (dataType == ngraph::element::Type_t::f64 && seqLenType == ngraph::element::Type_t::i64) { - ctc_greedy_decoder_v6::evaluate(op, - outputs, - inputs); +template +bool evaluate(const std::shared_ptr& op, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { + const auto& dataType = inputs[0].get_element_type(); + const auto& seqLenType = inputs[1].get_element_type(); + if (dataType == ov::element::f16 && seqLenType == ov::element::i32) { + ctc_greedy_decoder_v6::evaluate(op, outputs, inputs); + } else if (dataType == ov::element::f32 && seqLenType == ov::element::i32) { + ctc_greedy_decoder_v6::evaluate(op, outputs, inputs); + } else if (dataType == ov::element::f64 && seqLenType == ov::element::i32) { + ctc_greedy_decoder_v6::evaluate(op, outputs, inputs); + } else if (dataType == ov::element::f16 && seqLenType == ov::element::i64) { + ctc_greedy_decoder_v6::evaluate(op, outputs, inputs); + } else if (dataType == ov::element::f32 && seqLenType == ov::element::i64) { + ctc_greedy_decoder_v6::evaluate(op, outputs, inputs); + } else if (dataType == ov::element::f64 && seqLenType == ov::element::i64) { + ctc_greedy_decoder_v6::evaluate(op, outputs, inputs); } else { return false; } @@ -77,80 +65,49 @@ bool evaluate(const std::shared_ptr& op, } template <> -bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { auto element_type = node->get_output_element_type(0); - if (ov::is_type(node) || ov::is_type(node)) + if (ov::is_type(node) || ov::is_type(node)) element_type = node->get_input_element_type(1); switch (element_type) { - case ngraph::element::Type_t::boolean: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::bf16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i4: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i8: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u1: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u4: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u8: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); + case ov::element::boolean: + return evaluate(ov::as_type_ptr(node), + outputs, + inputs); + case ov::element::bf16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u1: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); default: - OPENVINO_THROW(std::string("Unhandled data type ") + node->get_element_type().get_type_name() + - std::string("in evaluate_node()")); + OPENVINO_THROW("Unhandled data type ", node->get_element_type().get_type_name(), " in evaluate_node()"); } } diff --git a/src/plugins/template/backend/ops/ctc_loss.cpp b/src/plugins/template/backend/ops/ctc_loss.cpp index 41b009be635185..215f4e661a08e6 100644 --- a/src/plugins/template/backend/ops/ctc_loss.cpp +++ b/src/plugins/template/backend/ops/ctc_loss.cpp @@ -2,62 +2,59 @@ // SPDX-License-Identifier: Apache-2.0 // -// clang-format off -#include "evaluate_node.hpp" #include "openvino/reference/ctc_loss.hpp" -// clang-format on + +#include "evaluate_node.hpp" namespace ctc_loss_v4 { -template ::value_type>::value && - !std::is_same::value_type, ngraph::bfloat16>::value && - !std::is_same::value_type, ngraph::float16>::value, - bool>::type = true> -inline void evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { - OPENVINO_ASSERT(false, - "The data type for logits is expected to be a floating point type. Got:", - ngraph::element::Type(t1)); +template < + ov::element::Type_t ET1, + ov::element::Type_t ET2, + typename std::enable_if::value_type>::value && + !std::is_same::value_type, ov::bfloat16>::value && + !std::is_same::value_type, ov::float16>::value, + bool>::type = true> +inline void evaluate(const std::shared_ptr& op, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { + OPENVINO_THROW("The data type for logits is expected to be a floating point type. Got:", ov::element::Type(ET1)); } -template ::value_type>::value || - std::is_same::value_type, ngraph::bfloat16>::value || - std::is_same::value_type, ngraph::float16>::value, - bool>::type = true> -inline void evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { - using T1 = typename ngraph::element_type_traits::value_type; - using T2 = typename ngraph::element_type_traits::value_type; - ov::reference::CTCLoss(inputs[0]->get_data_ptr(), - inputs[0]->get_shape(), - inputs[1]->get_data_ptr(), - inputs[2]->get_data_ptr(), - inputs[3]->get_data_ptr(), - inputs[4]->get_data_ptr(), +template < + ov::element::Type_t ET1, + ov::element::Type_t ET2, + typename std::enable_if::value_type>::value || + std::is_same::value_type, ov::bfloat16>::value || + std::is_same::value_type, ov::float16>::value, + bool>::type = true> +inline void evaluate(const std::shared_ptr& op, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { + using T1 = typename ov::element_type_traits::value_type; + using T2 = typename ov::element_type_traits::value_type; + ov::reference::CTCLoss(static_cast(inputs[0].data()), + inputs[0].get_shape(), + static_cast(inputs[1].data()), + static_cast(inputs[2].data()), + static_cast(inputs[3].data()), + static_cast(inputs[4].data()), op->get_preprocess_collapse_repeated(), op->get_ctc_merge_repeated(), op->get_unique(), - outputs[0]->get_data_ptr()); + static_cast(outputs[0].data())); } } // namespace ctc_loss_v4 -template -bool evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { - switch (inputs[1]->get_element_type()) { - case ngraph::element::Type_t::i32: - ctc_loss_v4::evaluate(op, outputs, inputs); +template +bool evaluate(const std::shared_ptr& op, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { + switch (inputs[1].get_element_type()) { + case ov::element::i32: + ctc_loss_v4::evaluate(op, outputs, inputs); break; - case ngraph::element::Type_t::i64: - ctc_loss_v4::evaluate(op, outputs, inputs); + case ov::element::i64: + ctc_loss_v4::evaluate(op, outputs, inputs); break; default: return false; @@ -66,50 +63,47 @@ bool evaluate(const std::shared_ptr& op, } template <> -bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { auto element_type = node->get_output_element_type(0); - if (ov::is_type(node) || ov::is_type(node)) + if (ov::is_type(node) || ov::is_type(node)) element_type = node->get_input_element_type(1); switch (element_type) { - case ngraph::element::Type_t::boolean: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::bf16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i4: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i8: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u1: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u4: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u8: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::boolean: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::bf16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u1: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); default: - OPENVINO_THROW(std::string("Unhandled data type ") + node->get_element_type().get_type_name() + - std::string("in evaluate_node()")); + OPENVINO_THROW("Unhandled data type ", node->get_element_type().get_type_name(), " in evaluate_node()"); } } diff --git a/src/plugins/template/backend/ops/cum_sum.cpp b/src/plugins/template/backend/ops/cum_sum.cpp index a0d23e50563996..06dc952b233fe7 100644 --- a/src/plugins/template/backend/ops/cum_sum.cpp +++ b/src/plugins/template/backend/ops/cum_sum.cpp @@ -8,81 +8,78 @@ // clang-format on namespace cum_sum_v0 { -template -inline void evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { - using T1 = typename ngraph::element_type_traits::value_type; - using T2 = typename ngraph::element_type_traits::value_type; - ov::reference::cumsum(inputs[0]->get_data_ptr(), - inputs[1]->get_data_ptr(), - outputs[0]->get_data_ptr(), - inputs[0]->get_shape(), +template +inline void evaluate(const std::shared_ptr& op, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { + using T1 = typename ov::element_type_traits::value_type; + using T2 = typename ov::element_type_traits::value_type; + ov::reference::cumsum(inputs[0].data(), + inputs[1].data(), + outputs[0].data(), + inputs[0].get_shape(), op->is_exclusive(), op->is_reverse()); } } // namespace cum_sum_v0 -template -bool evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { - switch (inputs[1]->get_element_type()) { - case ngraph::element::Type_t::i64: - cum_sum_v0::evaluate(op, outputs, inputs); +template +bool evaluate(const std::shared_ptr& op, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { + switch (inputs[1].get_element_type()) { + case ov::element::i64: + cum_sum_v0::evaluate(op, outputs, inputs); break; default: - cum_sum_v0::evaluate(op, outputs, inputs); + cum_sum_v0::evaluate(op, outputs, inputs); break; } return true; } template <> -bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { auto element_type = node->get_output_element_type(0); - if (ov::is_type(node) || ov::is_type(node)) + if (ov::is_type(node) || ov::is_type(node)) element_type = node->get_input_element_type(1); switch (element_type) { - case ngraph::element::Type_t::boolean: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::bf16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i4: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i8: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u1: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u4: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u8: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::boolean: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::bf16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u1: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); default: - OPENVINO_THROW(std::string("Unhandled data type ") + node->get_element_type().get_type_name() + - std::string("in evaluate_node()")); + OPENVINO_THROW("Unhandled data type ", node->get_element_type().get_type_name(), " in evaluate_node()"); } } diff --git a/src/plugins/template/backend/ops/deformable_convolution.cpp b/src/plugins/template/backend/ops/deformable_convolution.cpp index d4b96062b842f8..ea9eeb2ac13aed 100644 --- a/src/plugins/template/backend/ops/deformable_convolution.cpp +++ b/src/plugins/template/backend/ops/deformable_convolution.cpp @@ -6,244 +6,181 @@ #include "evaluate_node.hpp" -template -bool evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { - const auto in_data_ptr = inputs[0]->get_data_ptr(); - const auto offset_data_ptr = inputs[1]->get_data_ptr(); - const auto filter_data_ptr = inputs[2]->get_data_ptr(); - auto out_data_ptr = outputs[0]->get_data_ptr(); - const auto& out_shape = outputs[0]->get_shape(); - const auto& in_shape = inputs[0]->get_shape(); - const auto& offset_shape = inputs[1]->get_shape(); - const auto& filter_shape = inputs[2]->get_shape(); +template +bool evaluate(const std::shared_ptr& op, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { + using ET = typename ov::element_type_traits::value_type; + const auto in_data_ptr = inputs[0].data(); + const auto offset_data_ptr = inputs[1].data(); + const auto filter_data_ptr = inputs[2].data(); + auto out_data_ptr = outputs[0].data(); + const auto& out_shape = outputs[0].get_shape(); + const auto& in_shape = inputs[0].get_shape(); + const auto& offset_shape = inputs[1].get_shape(); + const auto& filter_shape = inputs[2].get_shape(); if (inputs.size() == 3) { - ov::reference::deformable_convolution::value_type>( - in_data_ptr, - offset_data_ptr, - filter_data_ptr, - out_data_ptr, - in_shape, - offset_shape, - filter_shape, - out_shape, - op->get_strides(), - op->get_dilations(), - op->get_pads_begin(), - op->get_pads_end(), - op->get_group(), - op->get_deformable_group(), - op->get_bilinear_interpolation_pad()); + ov::reference::deformable_convolution(in_data_ptr, + offset_data_ptr, + filter_data_ptr, + out_data_ptr, + in_shape, + offset_shape, + filter_shape, + out_shape, + op->get_strides(), + op->get_dilations(), + op->get_pads_begin(), + op->get_pads_end(), + op->get_group(), + op->get_deformable_group(), + op->get_bilinear_interpolation_pad()); } else { - const auto mask_data_ptr = inputs[3]->get_data_ptr(); - const auto& mask_shape = inputs[3]->get_shape(); - ov::reference::deformable_convolution::value_type>( - in_data_ptr, - offset_data_ptr, - filter_data_ptr, - mask_data_ptr, - out_data_ptr, - in_shape, - offset_shape, - filter_shape, - mask_shape, - out_shape, - op->get_strides(), - op->get_dilations(), - op->get_pads_begin(), - op->get_pads_end(), - op->get_group(), - op->get_deformable_group(), - op->get_bilinear_interpolation_pad()); + const auto mask_data_ptr = inputs[3].data(); + const auto& mask_shape = inputs[3].get_shape(); + ov::reference::deformable_convolution(in_data_ptr, + offset_data_ptr, + filter_data_ptr, + mask_data_ptr, + out_data_ptr, + in_shape, + offset_shape, + filter_shape, + mask_shape, + out_shape, + op->get_strides(), + op->get_dilations(), + op->get_pads_begin(), + op->get_pads_end(), + op->get_group(), + op->get_deformable_group(), + op->get_bilinear_interpolation_pad()); } return true; } -template -bool evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { - const auto in_data_ptr = inputs[0]->get_data_ptr(); - const auto offset_data_ptr = inputs[1]->get_data_ptr(); - const auto filter_data_ptr = inputs[2]->get_data_ptr(); - auto out_data_ptr = outputs[0]->get_data_ptr(); - const auto& out_shape = outputs[0]->get_shape(); - const auto& in_shape = inputs[0]->get_shape(); - const auto& offset_shape = inputs[1]->get_shape(); - const auto& filter_shape = inputs[2]->get_shape(); - ov::reference::deformable_convolution::value_type>( - in_data_ptr, - offset_data_ptr, - filter_data_ptr, - out_data_ptr, - in_shape, - offset_shape, - filter_shape, - out_shape, - op->get_strides(), - op->get_dilations(), - op->get_pads_begin(), - op->get_pads_end(), - op->get_group(), - op->get_deformable_group()); +template +bool evaluate(const std::shared_ptr& op, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { + using ET = typename ov::element_type_traits::value_type; + const auto in_data_ptr = inputs[0].data(); + const auto offset_data_ptr = inputs[1].data(); + const auto filter_data_ptr = inputs[2].data(); + auto out_data_ptr = outputs[0].data(); + const auto& out_shape = outputs[0].get_shape(); + const auto& in_shape = inputs[0].get_shape(); + const auto& offset_shape = inputs[1].get_shape(); + const auto& filter_shape = inputs[2].get_shape(); + ov::reference::deformable_convolution(in_data_ptr, + offset_data_ptr, + filter_data_ptr, + out_data_ptr, + in_shape, + offset_shape, + filter_shape, + out_shape, + op->get_strides(), + op->get_dilations(), + op->get_pads_begin(), + op->get_pads_end(), + op->get_group(), + op->get_deformable_group()); return true; } template <> -bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { auto element_type = node->get_output_element_type(0); - if (ov::is_type(node) || ov::is_type(node)) + if (ov::is_type(node) || ov::is_type(node)) element_type = node->get_input_element_type(1); switch (element_type) { - case ngraph::element::Type_t::boolean: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::bf16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i4: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i8: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u1: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u4: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u8: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); + case ov::element::boolean: + return evaluate(ov::as_type_ptr(node), + outputs, + inputs); + case ov::element::bf16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u1: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); default: - OPENVINO_THROW(std::string("Unhandled data type ") + node->get_element_type().get_type_name() + - std::string("in evaluate_node()")); + OPENVINO_THROW("Unhandled data type ", node->get_element_type().get_type_name(), " in evaluate_node()"); } } template <> -bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { auto element_type = node->get_output_element_type(0); - if (ov::is_type(node) || ov::is_type(node)) + if (ov::is_type(node) || ov::is_type(node)) element_type = node->get_input_element_type(1); switch (element_type) { - case ngraph::element::Type_t::boolean: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::bf16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i4: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i8: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u1: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u4: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u8: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); + case ov::element::boolean: + return evaluate(ov::as_type_ptr(node), + outputs, + inputs); + case ov::element::bf16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u1: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); default: - OPENVINO_THROW(std::string("Unhandled data type ") + node->get_element_type().get_type_name() + - std::string("in evaluate_node()")); + OPENVINO_THROW("Unhandled data type ", node->get_element_type().get_type_name(), " in evaluate_node()"); } } diff --git a/src/plugins/template/backend/ops/deformable_psroi_pooling.cpp b/src/plugins/template/backend/ops/deformable_psroi_pooling.cpp index 78a0ed95612b9e..70c24918edd975 100644 --- a/src/plugins/template/backend/ops/deformable_psroi_pooling.cpp +++ b/src/plugins/template/backend/ops/deformable_psroi_pooling.cpp @@ -6,28 +6,28 @@ #include "evaluate_node.hpp" -template -bool evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { - using T = typename ngraph::element_type_traits::value_type; - NGRAPH_CHECK(inputs.size() > 1 && inputs[1]->get_shape().size() == 2, - "2D tensor must be provided as second input. "); - outputs[0]->set_shape({inputs[1]->get_shape()[0], - static_cast(op->get_output_dim()), - static_cast(op->get_group_size()), - static_cast(op->get_group_size())}); +template +bool evaluate(const std::shared_ptr& op, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { + using T = typename ov::element_type_traits::value_type; + OPENVINO_ASSERT(inputs.size() > 1 && inputs[1].get_shape().size() == 2, + "2D tensor must be provided as second input. "); + outputs[0].set_shape({inputs[1].get_shape()[0], + static_cast(op->get_output_dim()), + static_cast(op->get_group_size()), + static_cast(op->get_group_size())}); const bool has_offset_intput = inputs.size() == 3; if (has_offset_intput) { - ov::reference::deformable_psroi_pooling(inputs[0]->get_data_ptr(), - inputs[0]->get_shape(), - inputs[1]->get_data_ptr(), - inputs[1]->get_shape(), - inputs[2]->get_data_ptr(), - inputs[2]->get_shape(), - outputs[0]->get_data_ptr(), - outputs[0]->get_shape(), + ov::reference::deformable_psroi_pooling(inputs[0].data(), + inputs[0].get_shape(), + inputs[1].data(), + inputs[1].get_shape(), + inputs[2].data(), + inputs[2].get_shape(), + outputs[0].data(), + outputs[0].get_shape(), op->get_mode(), op->get_spatial_scale(), op->get_spatial_bins_x(), @@ -35,14 +35,14 @@ bool evaluate(const std::shared_ptr& op, op->get_trans_std(), op->get_part_size()); } else { - ov::reference::deformable_psroi_pooling(inputs[0]->get_data_ptr(), - inputs[0]->get_shape(), - inputs[1]->get_data_ptr(), - inputs[1]->get_shape(), + ov::reference::deformable_psroi_pooling(inputs[0].data(), + inputs[0].get_shape(), + inputs[1].data(), + inputs[1].get_shape(), nullptr, - ngraph::Shape(), - outputs[0]->get_data_ptr(), - outputs[0]->get_shape(), + ov::Shape(), + outputs[0].data(), + outputs[0].get_shape(), op->get_mode(), op->get_spatial_scale(), op->get_spatial_bins_x(), @@ -54,80 +54,49 @@ bool evaluate(const std::shared_ptr& op, } template <> -bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { auto element_type = node->get_output_element_type(0); - if (ov::is_type(node) || ov::is_type(node)) + if (ov::is_type(node) || ov::is_type(node)) element_type = node->get_input_element_type(1); switch (element_type) { - case ngraph::element::Type_t::boolean: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::bf16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i4: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i8: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u1: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u4: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u8: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); + case ov::element::boolean: + return evaluate(ov::as_type_ptr(node), + outputs, + inputs); + case ov::element::bf16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u1: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); default: - OPENVINO_THROW(std::string("Unhandled data type ") + node->get_element_type().get_type_name() + - std::string("in evaluate_node()")); + OPENVINO_THROW("Unhandled data type ", node->get_element_type().get_type_name(), " in evaluate_node()"); } } diff --git a/src/plugins/template/backend/ops/detection_output.cpp b/src/plugins/template/backend/ops/detection_output.cpp index 42ea79e14ab392..bc750cdffa339d 100644 --- a/src/plugins/template/backend/ops/detection_output.cpp +++ b/src/plugins/template/backend/ops/detection_output.cpp @@ -6,60 +6,60 @@ #include "evaluate_node.hpp" -template -bool evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { - using T = typename ngraph::element_type_traits::value_type; +template +bool evaluate(const std::shared_ptr& op, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { + using T = typename ov::element_type_traits::value_type; ov::reference::referenceDetectionOutput refDetOut(op->get_attrs(), op->get_input_shape(0), op->get_input_shape(1), op->get_input_shape(2), op->get_output_shape(0)); if (op->get_input_size() == 3) { - refDetOut.run(inputs[0]->get_data_ptr(), - inputs[1]->get_data_ptr(), - inputs[2]->get_data_ptr(), + refDetOut.run(inputs[0].data(), + inputs[1].data(), + inputs[2].data(), nullptr, nullptr, - outputs[0]->get_data_ptr()); + outputs[0].data()); } else if (op->get_input_size() == 5) { - refDetOut.run(inputs[0]->get_data_ptr(), - inputs[1]->get_data_ptr(), - inputs[2]->get_data_ptr(), - inputs[3]->get_data_ptr(), - inputs[4]->get_data_ptr(), - outputs[0]->get_data_ptr()); + refDetOut.run(inputs[0].data(), + inputs[1].data(), + inputs[2].data(), + inputs[3].data(), + inputs[4].data(), + outputs[0].data()); } else { OPENVINO_THROW("DetectionOutput layer supports only 3 or 5 inputs"); } return true; } -template -bool evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { - using T = typename ngraph::element_type_traits::value_type; +template +bool evaluate(const std::shared_ptr& op, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { + using T = typename ov::element_type_traits::value_type; ov::reference::referenceDetectionOutput refDetOut(op->get_attrs(), op->get_input_shape(0), op->get_input_shape(1), op->get_input_shape(2), op->get_output_shape(0)); if (op->get_input_size() == 3) { - refDetOut.run(inputs[0]->get_data_ptr(), - inputs[1]->get_data_ptr(), - inputs[2]->get_data_ptr(), + refDetOut.run(inputs[0].data(), + inputs[1].data(), + inputs[2].data(), nullptr, nullptr, - outputs[0]->get_data_ptr()); + outputs[0].data()); } else if (op->get_input_size() == 5) { - refDetOut.run(inputs[0]->get_data_ptr(), - inputs[1]->get_data_ptr(), - inputs[2]->get_data_ptr(), - inputs[3]->get_data_ptr(), - inputs[4]->get_data_ptr(), - outputs[0]->get_data_ptr()); + refDetOut.run(inputs[0].data(), + inputs[1].data(), + inputs[2].data(), + inputs[3].data(), + inputs[4].data(), + outputs[0].data()); } else { OPENVINO_THROW("DetectionOutput layer supports only 3 or 5 inputs"); } @@ -67,159 +67,93 @@ bool evaluate(const std::shared_ptr& op, } template <> -bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { auto element_type = node->get_output_element_type(0); - if (ov::is_type(node) || ov::is_type(node)) + if (ov::is_type(node) || ov::is_type(node)) element_type = node->get_input_element_type(1); switch (element_type) { - case ngraph::element::Type_t::boolean: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::bf16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i4: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i8: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u1: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u4: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u8: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); + case ov::element::boolean: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::bf16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u1: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); default: - OPENVINO_THROW(std::string("Unhandled data type ") + node->get_element_type().get_type_name() + - std::string("in evaluate_node()")); + OPENVINO_THROW("Unhandled data type ", node->get_element_type().get_type_name(), " in evaluate_node()"); } } template <> -bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { auto element_type = node->get_output_element_type(0); - if (ov::is_type(node) || ov::is_type(node)) + if (ov::is_type(node) || ov::is_type(node)) element_type = node->get_input_element_type(1); switch (element_type) { - case ngraph::element::Type_t::boolean: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::bf16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i4: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i8: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u1: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u4: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u8: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); + case ov::element::boolean: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::bf16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u1: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); default: - OPENVINO_THROW(std::string("Unhandled data type ") + node->get_element_type().get_type_name() + - std::string("in evaluate_node()")); + OPENVINO_THROW("Unhandled data type ", node->get_element_type().get_type_name(), " in evaluate_node()"); } } diff --git a/src/plugins/template/backend/ops/einsum.cpp b/src/plugins/template/backend/ops/einsum.cpp index 70ac9c66be98a3..c744275de2778e 100644 --- a/src/plugins/template/backend/ops/einsum.cpp +++ b/src/plugins/template/backend/ops/einsum.cpp @@ -6,58 +6,56 @@ #include "evaluate_node.hpp" -template -bool evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +template +bool evaluate(const std::shared_ptr& op, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { const auto equation = op->get_equation(); ov::reference::einsum(outputs, inputs, equation); return true; } template <> -bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { auto element_type = node->get_output_element_type(0); - if (ov::is_type(node) || ov::is_type(node)) + if (ov::is_type(node) || ov::is_type(node)) element_type = node->get_input_element_type(1); switch (element_type) { - case ngraph::element::Type_t::boolean: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::bf16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i4: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i8: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u1: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u4: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u8: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::boolean: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::bf16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u1: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); default: OPENVINO_THROW(std::string("Unhandled data type ") + node->get_element_type().get_type_name() + std::string("in evaluate_node()")); diff --git a/src/plugins/template/backend/ops/elu.cpp b/src/plugins/template/backend/ops/elu.cpp index 3da9d8f83621fe..45b23f6ff579c5 100644 --- a/src/plugins/template/backend/ops/elu.cpp +++ b/src/plugins/template/backend/ops/elu.cpp @@ -6,61 +6,58 @@ #include "evaluate_node.hpp" -template -bool evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { - using T = typename ngraph::element_type_traits::value_type; - ov::reference::elu(inputs[0]->get_data_ptr(), - outputs[0]->get_data_ptr(), - ngraph::shape_size(inputs[0]->get_shape()), +template +bool evaluate(const std::shared_ptr& op, ov::TensorVector& outputs, const ov::TensorVector& inputs) { + using T = typename ov::element_type_traits::value_type; + ov::reference::elu(inputs[0].data(), + outputs[0].data(), + ov::shape_size(inputs[0].get_shape()), op->get_alpha()); return true; } template <> -bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { auto element_type = node->get_output_element_type(0); - if (ov::is_type(node) || ov::is_type(node)) + if (ov::is_type(node) || ov::is_type(node)) element_type = node->get_input_element_type(1); switch (element_type) { - case ngraph::element::Type_t::boolean: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::bf16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i4: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i8: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u1: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u4: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u8: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::boolean: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::bf16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u1: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); default: - OPENVINO_THROW(std::string("Unhandled data type ") + node->get_element_type().get_type_name() + - std::string("in evaluate_node()")); + OPENVINO_THROW("Unhandled data type ", node->get_element_type().get_type_name(), " in evaluate_node()"); } } diff --git a/src/plugins/template/backend/ops/embedding_bag_offsets_sum.cpp b/src/plugins/template/backend/ops/embedding_bag_offsets_sum.cpp index a58340a56b112f..a391a502b8b885 100644 --- a/src/plugins/template/backend/ops/embedding_bag_offsets_sum.cpp +++ b/src/plugins/template/backend/ops/embedding_bag_offsets_sum.cpp @@ -7,33 +7,33 @@ #include "evaluate_node.hpp" namespace embedding_bag_offsets_sum_v3 { -template -inline void evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { - using T1 = typename ngraph::element_type_traits::value_type; - using T2 = typename ngraph::element_type_traits::value_type; - ov::reference::embeddingBagOffsetsSum(inputs[0]->get_data_ptr(), - inputs[1]->get_data_ptr(), - inputs[2]->get_data_ptr(), - inputs.size() > 3 ? inputs[3]->get_data_ptr() : nullptr, - inputs.size() > 4 ? inputs[4]->get_data_ptr() : nullptr, - outputs[0]->get_data_ptr(), - ngraph::shape_size(inputs[1]->get_shape()), - outputs[0]->get_shape()); +template +inline void evaluate(const std::shared_ptr& op, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { + using T1 = typename ov::element_type_traits::value_type; + using T2 = typename ov::element_type_traits::value_type; + ov::reference::embeddingBagOffsetsSum(inputs[0].data(), + inputs[1].data(), + inputs[2].data(), + inputs.size() > 3 ? inputs[3].data() : nullptr, + inputs.size() > 4 ? inputs[4].data() : nullptr, + outputs[0].data(), + ov::shape_size(inputs[1].get_shape()), + outputs[0].get_shape()); } } // namespace embedding_bag_offsets_sum_v3 -template -bool evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { - switch (inputs[1]->get_element_type()) { - case ngraph::element::Type_t::i32: - embedding_bag_offsets_sum_v3::evaluate(op, outputs, inputs); +template +bool evaluate(const std::shared_ptr& op, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { + switch (inputs[1].get_element_type()) { + case ov::element::i32: + embedding_bag_offsets_sum_v3::evaluate(op, outputs, inputs); break; - case ngraph::element::Type_t::i64: - embedding_bag_offsets_sum_v3::evaluate(op, outputs, inputs); + case ov::element::i64: + embedding_bag_offsets_sum_v3::evaluate(op, outputs, inputs); break; default: return false; @@ -42,80 +42,49 @@ bool evaluate(const std::shared_ptr& op, } template <> -bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { auto element_type = node->get_output_element_type(0); - if (ov::is_type(node) || ov::is_type(node)) + if (ov::is_type(node) || ov::is_type(node)) element_type = node->get_input_element_type(1); switch (element_type) { - case ngraph::element::Type_t::boolean: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::bf16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i4: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i8: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u1: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u4: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u8: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); + case ov::element::boolean: + return evaluate(ov::as_type_ptr(node), + outputs, + inputs); + case ov::element::bf16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u1: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); default: - OPENVINO_THROW(std::string("Unhandled data type ") + node->get_element_type().get_type_name() + - std::string("in evaluate_node()")); + OPENVINO_THROW("Unhandled data type ", node->get_element_type().get_type_name(), " in evaluate_node()"); } } diff --git a/src/plugins/template/backend/ops/embedding_bag_packed_sum.cpp b/src/plugins/template/backend/ops/embedding_bag_packed_sum.cpp index 4a9e764bc8d86d..8ff618230b8b54 100644 --- a/src/plugins/template/backend/ops/embedding_bag_packed_sum.cpp +++ b/src/plugins/template/backend/ops/embedding_bag_packed_sum.cpp @@ -2,37 +2,36 @@ // SPDX-License-Identifier: Apache-2.0 // -// clang-format off -#include "evaluate_node.hpp" #include "openvino/reference/embedding_bag_packed_sum.hpp" -// clang-format on + +#include "evaluate_node.hpp" namespace embedding_bag_packed_sum_v3 { -template -inline void evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { - using T1 = typename ngraph::element_type_traits::value_type; - using T2 = typename ngraph::element_type_traits::value_type; - ov::reference::embeddingBagPackedSum(inputs[0]->get_data_ptr(), - inputs[1]->get_data_ptr(), - inputs.size() > 2 ? inputs[2]->get_data_ptr() : nullptr, - outputs[0]->get_data_ptr(), - inputs[1]->get_shape(), - outputs[0]->get_shape()); +template +inline void evaluate(const std::shared_ptr& op, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { + using T1 = typename ov::element_type_traits::value_type; + using T2 = typename ov::element_type_traits::value_type; + ov::reference::embeddingBagPackedSum(inputs[0].data(), + inputs[1].data(), + inputs.size() > 2 ? inputs[2].data() : nullptr, + outputs[0].data(), + inputs[1].get_shape(), + outputs[0].get_shape()); } } // namespace embedding_bag_packed_sum_v3 -template -bool evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { - switch (inputs[1]->get_element_type()) { - case ngraph::element::Type_t::i32: - embedding_bag_packed_sum_v3::evaluate(op, outputs, inputs); +template +bool evaluate(const std::shared_ptr& op, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { + switch (inputs[1].get_element_type()) { + case ov::element::i32: + embedding_bag_packed_sum_v3::evaluate(op, outputs, inputs); break; - case ngraph::element::Type_t::i64: - embedding_bag_packed_sum_v3::evaluate(op, outputs, inputs); + case ov::element::i64: + embedding_bag_packed_sum_v3::evaluate(op, outputs, inputs); break; default: return false; @@ -42,80 +41,49 @@ bool evaluate(const std::shared_ptr& op, } template <> -bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { auto element_type = node->get_output_element_type(0); - if (ov::is_type(node) || ov::is_type(node)) + if (ov::is_type(node) || ov::is_type(node)) element_type = node->get_input_element_type(1); switch (element_type) { - case ngraph::element::Type_t::boolean: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::bf16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i4: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i8: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u1: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u4: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u8: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); + case ov::element::boolean: + return evaluate(ov::as_type_ptr(node), + outputs, + inputs); + case ov::element::bf16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u1: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); default: - OPENVINO_THROW(std::string("Unhandled data type ") + node->get_element_type().get_type_name() + - std::string("in evaluate_node()")); + OPENVINO_THROW("Unhandled data type ", node->get_element_type().get_type_name(), " in evaluate_node()"); } } diff --git a/src/plugins/template/backend/ops/embedding_segments_sum.cpp b/src/plugins/template/backend/ops/embedding_segments_sum.cpp index 1d67090fd9c8f5..8307406e7b5373 100644 --- a/src/plugins/template/backend/ops/embedding_segments_sum.cpp +++ b/src/plugins/template/backend/ops/embedding_segments_sum.cpp @@ -7,34 +7,34 @@ #include "evaluate_node.hpp" namespace embedding_offsets_sum_v3 { -template -inline void evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { - using T1 = typename ngraph::element_type_traits::value_type; - using T2 = typename ngraph::element_type_traits::value_type; - ov::reference::embeddingSegmentsSum(inputs[0]->get_data_ptr(), - inputs[1]->get_data_ptr(), - inputs[2]->get_data_ptr(), - inputs.size() > 4 ? inputs[4]->get_data_ptr() : nullptr, - inputs.size() > 5 ? inputs[5]->get_data_ptr() : nullptr, - outputs[0]->get_data_ptr(), - inputs[0]->get_shape(), - inputs[1]->get_shape(), - outputs[0]->get_shape()); +template +inline void evaluate(const std::shared_ptr& op, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { + using T1 = typename ov::element_type_traits::value_type; + using T2 = typename ov::element_type_traits::value_type; + ov::reference::embeddingSegmentsSum(inputs[0].data(), + inputs[1].data(), + inputs[2].data(), + inputs.size() > 4 ? inputs[4].data() : nullptr, + inputs.size() > 5 ? inputs[5].data() : nullptr, + outputs[0].data(), + inputs[0].get_shape(), + inputs[1].get_shape(), + outputs[0].get_shape()); } } // namespace embedding_offsets_sum_v3 -template -bool evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { - switch (inputs[1]->get_element_type()) { - case ngraph::element::Type_t::i32: - embedding_offsets_sum_v3::evaluate(op, outputs, inputs); +template +bool evaluate(const std::shared_ptr& op, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { + switch (inputs[1].get_element_type()) { + case ov::element::i32: + embedding_offsets_sum_v3::evaluate(op, outputs, inputs); break; - case ngraph::element::Type_t::i64: - embedding_offsets_sum_v3::evaluate(op, outputs, inputs); + case ov::element::i64: + embedding_offsets_sum_v3::evaluate(op, outputs, inputs); break; default: return false; @@ -43,80 +43,47 @@ bool evaluate(const std::shared_ptr& op, } template <> -bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { auto element_type = node->get_output_element_type(0); - if (ov::is_type(node) || ov::is_type(node)) + if (ov::is_type(node) || ov::is_type(node)) element_type = node->get_input_element_type(1); switch (element_type) { - case ngraph::element::Type_t::boolean: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::bf16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i4: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i8: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u1: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u4: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u8: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); + case ov::element::boolean: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::bf16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u1: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); default: - OPENVINO_THROW(std::string("Unhandled data type ") + node->get_element_type().get_type_name() + - std::string("in evaluate_node()")); + OPENVINO_THROW("Unhandled data type ", node->get_element_type().get_type_name(), " in evaluate_node()"); } } diff --git a/src/plugins/template/backend/ops/equal.cpp b/src/plugins/template/backend/ops/equal.cpp index a6773c15c8a072..70402f9feb8c7a 100644 --- a/src/plugins/template/backend/ops/equal.cpp +++ b/src/plugins/template/backend/ops/equal.cpp @@ -5,73 +5,64 @@ #include "openvino/reference/equal.hpp" #include "evaluate_node.hpp" +#include "openvino/core/type/element_type.hpp" -template -bool evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { - const auto in0_data_ptr = inputs[0]->get_data_ptr(); - const auto in1_data_ptr = inputs[1]->get_data_ptr(); - const auto out_data_ptr = outputs[0]->get_data_ptr(); - const auto in0_shape = inputs[0]->get_shape(); - const auto in1_shape = inputs[1]->get_shape(); +template +bool evaluate(const std::shared_ptr& op, ov::TensorVector& outputs, const ov::TensorVector& inputs) { + using ET = typename ov::element_type_traits::value_type; + using BT = typename ov::element_type_traits::value_type; + const auto in0_data_ptr = inputs[0].data(); + const auto in1_data_ptr = inputs[1].data(); + const auto out_data_ptr = outputs[0].data(); + const auto in0_shape = inputs[0].get_shape(); + const auto in1_shape = inputs[1].get_shape(); const auto broadcast_spec = op->get_autob(); - ov::reference::equal::value_type, - typename ngraph::element_type_traits::value_type>( - in0_data_ptr, - in1_data_ptr, - out_data_ptr, - in0_shape, - in1_shape, - broadcast_spec); + ov::reference::equal(in0_data_ptr, in1_data_ptr, out_data_ptr, in0_shape, in1_shape, broadcast_spec); return true; } template <> -bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { auto element_type = node->get_output_element_type(0); - if (ov::is_type(node) || ov::is_type(node)) + if (ov::is_type(node) || ov::is_type(node)) element_type = node->get_input_element_type(1); switch (element_type) { - case ngraph::element::Type_t::boolean: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::bf16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i4: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i8: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u1: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u4: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u8: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::boolean: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::bf16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u1: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); default: - OPENVINO_THROW(std::string("Unhandled data type ") + node->get_element_type().get_type_name() + - std::string("in evaluate_node()")); + OPENVINO_THROW("Unhandled data type ", node->get_element_type().get_type_name(), " in evaluate_node()"); } } diff --git a/src/plugins/template/backend/ops/evaluate_node.hpp b/src/plugins/template/backend/ops/evaluate_node.hpp index 8f5ac4892be458..58484f0a389de0 100644 --- a/src/plugins/template/backend/ops/evaluate_node.hpp +++ b/src/plugins/template/backend/ops/evaluate_node.hpp @@ -3,60 +3,56 @@ // #pragma once -#include "ngraph/ops.hpp" + #include "openvino/core/except.hpp" #include "openvino/op/ops.hpp" +#include "openvino/runtime/tensor.hpp" -template -bool evaluate(std::shared_ptr op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +template +bool evaluate(std::shared_ptr op, ov::TensorVector& outputs, const ov::TensorVector& inputs) { return false; } template -bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +bool evaluate_node(std::shared_ptr node, ov::TensorVector& outputs, const ov::TensorVector& inputs) { auto element_type = node->get_output_element_type(0); - if (ov::is_type(node) || ov::is_type(node)) + if (ov::is_type(node) || ov::is_type(node)) element_type = node->get_input_element_type(1); switch (element_type) { - case ngraph::element::Type_t::boolean: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::bf16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i4: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i8: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u1: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u4: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u8: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::Type_t::boolean: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::Type_t::bf16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::Type_t::f16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::Type_t::f64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::Type_t::f32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::Type_t::i4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::Type_t::i8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::Type_t::i16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::Type_t::i32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::Type_t::i64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::Type_t::u1: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::Type_t::u4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::Type_t::u8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::Type_t::u16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::Type_t::u32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::Type_t::u64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); default: - OPENVINO_THROW(std::string("Unhandled data type ") + node->get_element_type().get_type_name() + - std::string("in evaluate_node()")); + OPENVINO_THROW("Unhandled data type ", node->get_element_type().get_type_name(), " in evaluate_node()"); } } diff --git a/src/plugins/template/backend/ops/exp.cpp b/src/plugins/template/backend/ops/exp.cpp index 4d3fd3402b5d18..1f78c498ee1b84 100644 --- a/src/plugins/template/backend/ops/exp.cpp +++ b/src/plugins/template/backend/ops/exp.cpp @@ -6,60 +6,55 @@ #include "evaluate_node.hpp" -template -bool evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { - using T = typename ngraph::element_type_traits::value_type; - ov::reference::exp(inputs[0]->get_data_ptr(), - outputs[0]->get_data_ptr(), - ngraph::shape_size(inputs[0]->get_shape())); +template +bool evaluate(const std::shared_ptr& op, ov::TensorVector& outputs, const ov::TensorVector& inputs) { + using T = typename ov::element_type_traits::value_type; + ov::reference::exp(inputs[0].data(), outputs[0].data(), ov::shape_size(inputs[0].get_shape())); return true; } template <> -bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { auto element_type = node->get_output_element_type(0); - if (ov::is_type(node) || ov::is_type(node)) + if (ov::is_type(node) || ov::is_type(node)) element_type = node->get_input_element_type(1); switch (element_type) { - case ngraph::element::Type_t::boolean: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::bf16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i4: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i8: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u1: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u4: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u8: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::boolean: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::bf16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u1: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); default: - OPENVINO_THROW(std::string("Unhandled data type ") + node->get_element_type().get_type_name() + - std::string("in evaluate_node()")); + OPENVINO_THROW("Unhandled data type ", node->get_element_type().get_type_name(), " in evaluate_node()"); } } diff --git a/src/plugins/template/backend/ops/experimental_detectron_detection_output.cpp b/src/plugins/template/backend/ops/experimental_detectron_detection_output.cpp index 9c6199637c8208..4eafe3f5cdd4b4 100644 --- a/src/plugins/template/backend/ops/experimental_detectron_detection_output.cpp +++ b/src/plugins/template/backend/ops/experimental_detectron_detection_output.cpp @@ -7,34 +7,31 @@ #include "evaluate_node.hpp" #include "evaluates_map.hpp" -template -bool evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +template +bool evaluate(const std::shared_ptr& op, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { const auto attrs = op->get_attrs(); size_t rois_num = attrs.max_detections_per_image; - const ngraph::Shape output_boxes_shape = ngraph::Shape{rois_num, 4}; - const ngraph::Shape output_classes_shape = ngraph::Shape{rois_num}; - const ngraph::Shape output_scores_shape = ngraph::Shape{rois_num}; + const ov::Shape output_boxes_shape = ov::Shape{rois_num, 4}; + const ov::Shape output_classes_shape = ov::Shape{rois_num}; + const ov::Shape output_scores_shape = ov::Shape{rois_num}; const auto output_type = op->get_input_element_type(0); - const auto boxes_data = get_floats(inputs[0], inputs[0]->get_shape()); - const auto input_deltas_data = get_floats(inputs[1], inputs[1]->get_shape()); - const auto input_scores_data = get_floats(inputs[2], inputs[2]->get_shape()); - const auto input_im_info_data = get_floats(inputs[3], inputs[3]->get_shape()); + const auto boxes_data = get_floats(inputs[0], inputs[0].get_shape()); + const auto input_deltas_data = get_floats(inputs[1], inputs[1].get_shape()); + const auto input_scores_data = get_floats(inputs[2], inputs[2].get_shape()); + const auto input_im_info_data = get_floats(inputs[3], inputs[3].get_shape()); - std::vector output_boxes(ngraph::shape_size(output_boxes_shape)); - std::vector output_classes(ngraph::shape_size(output_classes_shape)); - std::vector output_scores(ngraph::shape_size(output_scores_shape)); + std::vector output_boxes(ov::shape_size(output_boxes_shape)); + std::vector output_classes(ov::shape_size(output_classes_shape)); + std::vector output_scores(ov::shape_size(output_scores_shape)); - outputs[0]->set_element_type(output_type); - outputs[0]->set_shape(output_boxes_shape); - outputs[1]->set_element_type(ngraph::element::Type_t::i32); - outputs[1]->set_shape(output_classes_shape); - outputs[2]->set_element_type(output_type); - outputs[2]->set_shape(output_scores_shape); + outputs[0].set_shape(output_boxes_shape); + outputs[1].set_shape(output_classes_shape); + outputs[2].set_shape(output_scores_shape); ov::reference::experimental_detectron_detection_output(boxes_data.data(), input_deltas_data.data(), @@ -45,9 +42,9 @@ bool evaluate(const std::shared_ptrget_data_ptr(), - outputs[1]->get_data_ptr(), - outputs[2]->get_data_ptr(), + ov::reference::experimental_detectron_detection_output_postprocessing(outputs[0].data(), + outputs[1].data(), + outputs[2].data(), output_type, output_boxes, output_classes, @@ -60,96 +57,79 @@ bool evaluate(const std::shared_ptr -bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { auto element_type = node->get_output_element_type(0); - if (ov::is_type(node) || ov::is_type(node)) + if (ov::is_type(node) || ov::is_type(node)) element_type = node->get_input_element_type(1); switch (element_type) { - case ngraph::element::Type_t::boolean: - return evaluate( - ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::bf16: - return evaluate( - ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f16: - return evaluate( - ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f64: - return evaluate( - ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f32: - return evaluate( - ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i4: - return evaluate( - ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i8: - return evaluate( - ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i16: - return evaluate( - ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i32: - return evaluate( - ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i64: - return evaluate( - ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u1: - return evaluate( - ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u4: - return evaluate( - ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u8: - return evaluate( - ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u16: - return evaluate( - ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u32: - return evaluate( - ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u64: - return evaluate( - ov::as_type_ptr(node), - outputs, - inputs); + case ov::element::boolean: + return evaluate(ov::as_type_ptr(node), + outputs, + inputs); + case ov::element::bf16: + return evaluate(ov::as_type_ptr(node), + outputs, + inputs); + case ov::element::f16: + return evaluate(ov::as_type_ptr(node), + outputs, + inputs); + case ov::element::f64: + return evaluate(ov::as_type_ptr(node), + outputs, + inputs); + case ov::element::f32: + return evaluate(ov::as_type_ptr(node), + outputs, + inputs); + case ov::element::i4: + return evaluate(ov::as_type_ptr(node), + outputs, + inputs); + case ov::element::i8: + return evaluate(ov::as_type_ptr(node), + outputs, + inputs); + case ov::element::i16: + return evaluate(ov::as_type_ptr(node), + outputs, + inputs); + case ov::element::i32: + return evaluate(ov::as_type_ptr(node), + outputs, + inputs); + case ov::element::i64: + return evaluate(ov::as_type_ptr(node), + outputs, + inputs); + case ov::element::u1: + return evaluate(ov::as_type_ptr(node), + outputs, + inputs); + case ov::element::u4: + return evaluate(ov::as_type_ptr(node), + outputs, + inputs); + case ov::element::u8: + return evaluate(ov::as_type_ptr(node), + outputs, + inputs); + case ov::element::u16: + return evaluate(ov::as_type_ptr(node), + outputs, + inputs); + case ov::element::u32: + return evaluate(ov::as_type_ptr(node), + outputs, + inputs); + case ov::element::u64: + return evaluate(ov::as_type_ptr(node), + outputs, + inputs); default: - OPENVINO_THROW(std::string("Unhandled data type ") + node->get_element_type().get_type_name() + - std::string("in evaluate_node()")); + OPENVINO_THROW("Unhandled data type ", node->get_element_type().get_type_name(), " in evaluate_node()"); } } diff --git a/src/plugins/template/backend/ops/experimental_detectron_prior_grid_generator.cpp b/src/plugins/template/backend/ops/experimental_detectron_prior_grid_generator.cpp index cff1eb493222bc..6fa9c91c5ae106 100644 --- a/src/plugins/template/backend/ops/experimental_detectron_prior_grid_generator.cpp +++ b/src/plugins/template/backend/ops/experimental_detectron_prior_grid_generator.cpp @@ -8,7 +8,7 @@ namespace experimental_prior_grid { struct InfoForEDPriorGrid { - ngraph::Shape output_shape; + ov::Shape output_shape; int64_t grid_h; int64_t grid_w; float stride_h; @@ -18,20 +18,17 @@ struct InfoForEDPriorGrid { constexpr size_t priors_port = 0; constexpr size_t feature_map_port = 1; -ngraph::PartialShape infer_output_shape(const std::vector>& inputs, bool flatten) { - ngraph::PartialShape out_shape = {ngraph::Dimension::dynamic(), - ngraph::Dimension::dynamic(), - ngraph::Dimension::dynamic(), - 4}; +ov::PartialShape infer_output_shape(const ov::TensorVector& inputs, bool flatten) { + ov::PartialShape out_shape = {ov::Dimension::dynamic(), ov::Dimension::dynamic(), ov::Dimension::dynamic(), 4}; if (flatten) { - out_shape = ngraph::PartialShape{ngraph::Dimension::dynamic(), 4}; + out_shape = ov::PartialShape{ov::Dimension::dynamic(), 4}; } - const auto priors_shape = inputs[priors_port]->get_partial_shape(); - const auto feature_map_shape = inputs[feature_map_port]->get_partial_shape(); + const auto priors_shape = inputs[priors_port].get_shape(); + const auto feature_map_shape = inputs[feature_map_port].get_shape(); - if (priors_shape.rank().is_dynamic() || feature_map_shape.rank().is_dynamic()) { + if (!ov::shape_size(priors_shape) || !ov::shape_size(feature_map_shape)) { return out_shape; } @@ -40,17 +37,21 @@ ngraph::PartialShape infer_output_shape(const std::vector(featmap_height * featmap_width * num_priors)), 4}; } else { - out_shape = ngraph::PartialShape{featmap_height, featmap_width, num_priors, 4}; + out_shape = ov::PartialShape{ov::Dimension(static_cast(featmap_height)), + ov::Dimension(static_cast(featmap_width)), + ov::Dimension(static_cast(num_priors)), + 4}; } return out_shape; } InfoForEDPriorGrid get_info_for_ed_prior_grid_eval( - const std::shared_ptr& prior_grid, - const std::vector>& inputs) { + const std::shared_ptr& prior_grid, + const ov::TensorVector& inputs) { InfoForEDPriorGrid result; auto attrs = prior_grid->get_attrs(); @@ -67,19 +68,19 @@ InfoForEDPriorGrid get_info_for_ed_prior_grid_eval( } } // namespace experimental_prior_grid -template -bool evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +template +bool evaluate(const std::shared_ptr& op, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { auto info = experimental_prior_grid::get_info_for_ed_prior_grid_eval(op, inputs); - using T = typename ngraph::element_type_traits::value_type; - outputs[0]->set_shape(info.output_shape); - ov::reference::experimental_detectron_prior_grid_generator(inputs[0]->get_data_ptr(), - inputs[0]->get_shape(), - inputs[1]->get_shape(), - inputs[2]->get_shape(), - outputs[0]->get_data_ptr(), + using T = typename ov::element_type_traits::value_type; + outputs[0].set_shape(info.output_shape); + ov::reference::experimental_detectron_prior_grid_generator(inputs[0].data(), + inputs[0].get_shape(), + inputs[1].get_shape(), + inputs[2].get_shape(), + outputs[0].data(), info.grid_h, info.grid_w, info.stride_h, @@ -89,96 +90,80 @@ bool evaluate(const std::shared_ptr -bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { auto element_type = node->get_output_element_type(0); - if (ov::is_type(node) || ov::is_type(node)) + if (ov::is_type(node) || ov::is_type(node)) element_type = node->get_input_element_type(1); switch (element_type) { - case ngraph::element::Type_t::boolean: - return evaluate( - ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::bf16: - return evaluate( - ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f16: - return evaluate( - ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f64: - return evaluate( - ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f32: - return evaluate( - ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i4: - return evaluate( - ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i8: - return evaluate( - ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i16: - return evaluate( - ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i32: - return evaluate( - ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i64: - return evaluate( - ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u1: - return evaluate( - ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u4: - return evaluate( - ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u8: - return evaluate( - ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u16: - return evaluate( - ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u32: - return evaluate( - ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u64: - return evaluate( - ov::as_type_ptr(node), - outputs, - inputs); + case ov::element::boolean: + return evaluate( + ov::as_type_ptr(node), + outputs, + inputs); + case ov::element::bf16: + return evaluate(ov::as_type_ptr(node), + outputs, + inputs); + case ov::element::f16: + return evaluate(ov::as_type_ptr(node), + outputs, + inputs); + case ov::element::f64: + return evaluate(ov::as_type_ptr(node), + outputs, + inputs); + case ov::element::f32: + return evaluate(ov::as_type_ptr(node), + outputs, + inputs); + case ov::element::i4: + return evaluate(ov::as_type_ptr(node), + outputs, + inputs); + case ov::element::i8: + return evaluate(ov::as_type_ptr(node), + outputs, + inputs); + case ov::element::i16: + return evaluate(ov::as_type_ptr(node), + outputs, + inputs); + case ov::element::i32: + return evaluate(ov::as_type_ptr(node), + outputs, + inputs); + case ov::element::i64: + return evaluate(ov::as_type_ptr(node), + outputs, + inputs); + case ov::element::u1: + return evaluate(ov::as_type_ptr(node), + outputs, + inputs); + case ov::element::u4: + return evaluate(ov::as_type_ptr(node), + outputs, + inputs); + case ov::element::u8: + return evaluate(ov::as_type_ptr(node), + outputs, + inputs); + case ov::element::u16: + return evaluate(ov::as_type_ptr(node), + outputs, + inputs); + case ov::element::u32: + return evaluate(ov::as_type_ptr(node), + outputs, + inputs); + case ov::element::u64: + return evaluate(ov::as_type_ptr(node), + outputs, + inputs); default: - OPENVINO_THROW(std::string("Unhandled data type ") + node->get_element_type().get_type_name() + - std::string("in evaluate_node()")); + OPENVINO_THROW("Unhandled data type ", node->get_element_type().get_type_name(), " in evaluate_node()"); } } diff --git a/src/plugins/template/backend/ops/experimental_detectron_proposal_single_image.cpp b/src/plugins/template/backend/ops/experimental_detectron_proposal_single_image.cpp index df064504a28126..9a933181ec7a90 100644 --- a/src/plugins/template/backend/ops/experimental_detectron_proposal_single_image.cpp +++ b/src/plugins/template/backend/ops/experimental_detectron_proposal_single_image.cpp @@ -7,10 +7,10 @@ #include "evaluate_node.hpp" #include "evaluates_map.hpp" -template -bool evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +template +bool evaluate(const std::shared_ptr& op, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { const auto attrs = op->get_attrs(); size_t post_nms_count = 0; @@ -22,28 +22,26 @@ bool evaluate(const std::shared_ptr(attrs.post_nms_count); } - const ngraph::Shape output_rois_shape = ngraph::Shape{post_nms_count, 4}; - const ngraph::Shape output_scores_shape = ngraph::Shape{post_nms_count}; + const ov::Shape output_rois_shape = ov::Shape{post_nms_count, 4}; + const ov::Shape output_scores_shape = ov::Shape{post_nms_count}; const auto output_type = op->get_input_element_type(0); - const auto im_info_shape = inputs[0]->get_shape(); - const auto anchors_shape = inputs[1]->get_shape(); - const auto deltas_shape = inputs[2]->get_shape(); - const auto scores_shape = inputs[3]->get_shape(); + const auto im_info_shape = inputs[0].get_shape(); + const auto anchors_shape = inputs[1].get_shape(); + const auto deltas_shape = inputs[2].get_shape(); + const auto scores_shape = inputs[3].get_shape(); const auto im_info_data = get_floats(inputs[0], im_info_shape); const auto anchors_data = get_floats(inputs[1], anchors_shape); const auto deltas_data = get_floats(inputs[2], deltas_shape); const auto scores_data = get_floats(inputs[3], scores_shape); - std::vector output_rois(ngraph::shape_size(output_rois_shape)); - std::vector output_scores(ngraph::shape_size(output_scores_shape)); + std::vector output_rois(ov::shape_size(output_rois_shape)); + std::vector output_scores(ov::shape_size(output_scores_shape)); - outputs[0]->set_element_type(output_type); - outputs[0]->set_shape(output_rois_shape); - outputs[1]->set_element_type(output_type); - outputs[1]->set_shape(output_scores_shape); + outputs[0].set_shape(output_rois_shape); + outputs[1].set_shape(output_scores_shape); ov::reference::experimental_detectron_proposals_single_image(im_info_data.data(), anchors_data.data(), @@ -56,8 +54,8 @@ bool evaluate(const std::shared_ptrget_data_ptr(), - outputs[1]->get_data_ptr(), + ov::reference::experimental_detectron_proposals_single_image_postprocessing(outputs[0].data(), + outputs[1].data(), output_type, output_rois, output_scores, @@ -68,97 +66,95 @@ bool evaluate(const std::shared_ptr -bool evaluate_node( - std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { auto element_type = node->get_output_element_type(0); - if (ov::is_type(node) || ov::is_type(node)) + if (ov::is_type(node) || ov::is_type(node)) element_type = node->get_input_element_type(1); switch (element_type) { - case ngraph::element::Type_t::boolean: - return evaluate( - ov::as_type_ptr(node), + case ov::element::boolean: + return evaluate( + ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::bf16: - return evaluate( - ov::as_type_ptr(node), + case ov::element::bf16: + return evaluate( + ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f16: - return evaluate( - ov::as_type_ptr(node), + case ov::element::f16: + return evaluate( + ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f64: - return evaluate( - ov::as_type_ptr(node), + case ov::element::f64: + return evaluate( + ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f32: - return evaluate( - ov::as_type_ptr(node), + case ov::element::f32: + return evaluate( + ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i4: - return evaluate( - ov::as_type_ptr(node), + case ov::element::i4: + return evaluate( + ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i8: - return evaluate( - ov::as_type_ptr(node), + case ov::element::i8: + return evaluate( + ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i16: - return evaluate( - ov::as_type_ptr(node), + case ov::element::i16: + return evaluate( + ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i32: - return evaluate( - ov::as_type_ptr(node), + case ov::element::i32: + return evaluate( + ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i64: - return evaluate( - ov::as_type_ptr(node), + case ov::element::i64: + return evaluate( + ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u1: - return evaluate( - ov::as_type_ptr(node), + case ov::element::u1: + return evaluate( + ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u4: - return evaluate( - ov::as_type_ptr(node), + case ov::element::u4: + return evaluate( + ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u8: - return evaluate( - ov::as_type_ptr(node), + case ov::element::u8: + return evaluate( + ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u16: - return evaluate( - ov::as_type_ptr(node), + case ov::element::u16: + return evaluate( + ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u32: - return evaluate( - ov::as_type_ptr(node), + case ov::element::u32: + return evaluate( + ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u64: - return evaluate( - ov::as_type_ptr(node), + case ov::element::u64: + return evaluate( + ov::as_type_ptr(node), outputs, inputs); default: - OPENVINO_THROW(std::string("Unhandled data type ") + node->get_element_type().get_type_name() + - std::string("in evaluate_node()")); + OPENVINO_THROW("Unhandled data type ", node->get_element_type().get_type_name(), " in evaluate_node()"); } } diff --git a/src/plugins/template/backend/ops/experimental_detectron_roi_feature_extractor.cpp b/src/plugins/template/backend/ops/experimental_detectron_roi_feature_extractor.cpp index 4aaac9f381522e..847eb7f62e8b89 100644 --- a/src/plugins/template/backend/ops/experimental_detectron_roi_feature_extractor.cpp +++ b/src/plugins/template/backend/ops/experimental_detectron_roi_feature_extractor.cpp @@ -2,26 +2,25 @@ // SPDX-License-Identifier: Apache-2.0 // -// clang-format off -#include "evaluates_map.hpp" -#include "evaluate_node.hpp" #include "openvino/reference/experimental_detectron_roi_feature_extractor.hpp" -// clang-format on + +#include "evaluate_node.hpp" +#include "evaluates_map.hpp" namespace experimental_roi_feature { struct InfoForEDROIFeature { - ngraph::Shape output_rois_features_shape; - ngraph::Shape output_rois_shape; + ov::Shape output_rois_features_shape; + ov::Shape output_rois_shape; }; InfoForEDROIFeature get_info_for_ed_roi_feature( - const std::vector input_shapes, - const ngraph::op::v6::ExperimentalDetectronROIFeatureExtractor::Attributes& attrs) { + const std::vector input_shapes, + const ov::op::v6::ExperimentalDetectronROIFeatureExtractor::Attributes& attrs) { InfoForEDROIFeature result; size_t output_size = static_cast(attrs.output_size); - auto out_shape = ngraph::Shape{0, 0, output_size, output_size}; - auto out_rois_shape = ngraph::Shape{0, 4}; + auto out_shape = ov::Shape{0, 0, output_size, output_size}; + auto out_rois_shape = ov::Shape{0, 4}; auto rois_shape = input_shapes[0]; @@ -37,16 +36,16 @@ InfoForEDROIFeature get_info_for_ed_roi_feature( } } // namespace experimental_roi_feature -template -bool evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +template +bool evaluate(const std::shared_ptr& op, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { const auto attrs = op->get_attrs(); std::vector> input_data; - std::vector input_shapes; + std::vector input_shapes; for (const auto& input : inputs) { - const auto current_shape = input->get_shape(); + const auto current_shape = input.get_shape(); input_data.push_back(get_floats(input, current_shape)); input_shapes.push_back(current_shape); } @@ -57,13 +56,11 @@ bool evaluate(const std::shared_ptrget_input_element_type(0); - outputs[0]->set_element_type(output_type); - outputs[0]->set_shape(output_rois_features_shape); - outputs[1]->set_element_type(output_type); - outputs[1]->set_shape(output_rois_shape); + outputs[0].set_shape(output_rois_features_shape); + outputs[1].set_shape(output_rois_shape); - std::vector output_rois_features(ngraph::shape_size(output_rois_features_shape)); - std::vector output_rois(ngraph::shape_size(output_rois_shape)); + std::vector output_rois_features(ov::shape_size(output_rois_features_shape)); + std::vector output_rois(ov::shape_size(output_rois_shape)); ov::reference::experimental_detectron_roi_feature_extractor(input_data, input_shapes, @@ -71,8 +68,8 @@ bool evaluate(const std::shared_ptrget_data_ptr(), - outputs[1]->get_data_ptr(), + ov::reference::experimental_detectron_roi_feature_extractor_postprocessing(outputs[0].data(), + outputs[1].data(), output_type, output_rois_features, output_rois, @@ -83,96 +80,80 @@ bool evaluate(const std::shared_ptr -bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { auto element_type = node->get_output_element_type(0); - if (ov::is_type(node) || ov::is_type(node)) + if (ov::is_type(node) || ov::is_type(node)) element_type = node->get_input_element_type(1); switch (element_type) { - case ngraph::element::Type_t::boolean: - return evaluate( - ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::bf16: - return evaluate( - ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f16: - return evaluate( - ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f64: - return evaluate( - ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f32: - return evaluate( - ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i4: - return evaluate( - ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i8: - return evaluate( - ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i16: - return evaluate( - ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i32: - return evaluate( - ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i64: - return evaluate( - ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u1: - return evaluate( - ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u4: - return evaluate( - ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u8: - return evaluate( - ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u16: - return evaluate( - ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u32: - return evaluate( - ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u64: - return evaluate( - ov::as_type_ptr(node), - outputs, - inputs); + case ov::element::boolean: + return evaluate( + ov::as_type_ptr(node), + outputs, + inputs); + case ov::element::bf16: + return evaluate(ov::as_type_ptr(node), + outputs, + inputs); + case ov::element::f16: + return evaluate(ov::as_type_ptr(node), + outputs, + inputs); + case ov::element::f64: + return evaluate(ov::as_type_ptr(node), + outputs, + inputs); + case ov::element::f32: + return evaluate(ov::as_type_ptr(node), + outputs, + inputs); + case ov::element::i4: + return evaluate(ov::as_type_ptr(node), + outputs, + inputs); + case ov::element::i8: + return evaluate(ov::as_type_ptr(node), + outputs, + inputs); + case ov::element::i16: + return evaluate(ov::as_type_ptr(node), + outputs, + inputs); + case ov::element::i32: + return evaluate(ov::as_type_ptr(node), + outputs, + inputs); + case ov::element::i64: + return evaluate(ov::as_type_ptr(node), + outputs, + inputs); + case ov::element::u1: + return evaluate(ov::as_type_ptr(node), + outputs, + inputs); + case ov::element::u4: + return evaluate(ov::as_type_ptr(node), + outputs, + inputs); + case ov::element::u8: + return evaluate(ov::as_type_ptr(node), + outputs, + inputs); + case ov::element::u16: + return evaluate(ov::as_type_ptr(node), + outputs, + inputs); + case ov::element::u32: + return evaluate(ov::as_type_ptr(node), + outputs, + inputs); + case ov::element::u64: + return evaluate(ov::as_type_ptr(node), + outputs, + inputs); default: - OPENVINO_THROW(std::string("Unhandled data type ") + node->get_element_type().get_type_name() + - std::string("in evaluate_node()")); + OPENVINO_THROW("Unhandled data type ", node->get_element_type().get_type_name(), " in evaluate_node()"); } } diff --git a/src/plugins/template/backend/ops/experimental_detectron_topk_rois.cpp b/src/plugins/template/backend/ops/experimental_detectron_topk_rois.cpp index cd03df2f38ccb4..ea05aea182f117 100644 --- a/src/plugins/template/backend/ops/experimental_detectron_topk_rois.cpp +++ b/src/plugins/template/backend/ops/experimental_detectron_topk_rois.cpp @@ -6,113 +6,96 @@ #include "evaluate_node.hpp" -template -bool evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { - using T = typename ngraph::element_type_traits::value_type; +template +bool evaluate(const std::shared_ptr& op, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { + using T = typename ov::element_type_traits::value_type; size_t max_rois = op->get_max_rois(); - outputs[0]->set_shape(ngraph::Shape{max_rois, 4}); - ov::reference::experimental_detectron_topk_rois(inputs[0]->get_data_ptr(), - inputs[1]->get_data_ptr(), - inputs[0]->get_shape(), - inputs[1]->get_shape(), + outputs[0].set_shape(ov::Shape{max_rois, 4}); + ov::reference::experimental_detectron_topk_rois(inputs[0].data(), + inputs[1].data(), + inputs[0].get_shape(), + inputs[1].get_shape(), max_rois, - outputs[0]->get_data_ptr()); + outputs[0].data()); return true; } template <> -bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { auto element_type = node->get_output_element_type(0); - if (ov::is_type(node) || ov::is_type(node)) + if (ov::is_type(node) || ov::is_type(node)) element_type = node->get_input_element_type(1); switch (element_type) { - case ngraph::element::Type_t::boolean: - return evaluate( - ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::bf16: - return evaluate( - ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f16: - return evaluate( - ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f64: - return evaluate( - ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f32: - return evaluate( - ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i4: - return evaluate( - ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i8: - return evaluate( - ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i16: - return evaluate( - ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i32: - return evaluate( - ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i64: - return evaluate( - ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u1: - return evaluate( - ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u4: - return evaluate( - ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u8: - return evaluate( - ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u16: - return evaluate( - ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u32: - return evaluate( - ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u64: - return evaluate( - ov::as_type_ptr(node), - outputs, - inputs); + case ov::element::boolean: + return evaluate(ov::as_type_ptr(node), + outputs, + inputs); + case ov::element::bf16: + return evaluate(ov::as_type_ptr(node), + outputs, + inputs); + case ov::element::f16: + return evaluate(ov::as_type_ptr(node), + outputs, + inputs); + case ov::element::f64: + return evaluate(ov::as_type_ptr(node), + outputs, + inputs); + case ov::element::f32: + return evaluate(ov::as_type_ptr(node), + outputs, + inputs); + case ov::element::i4: + return evaluate(ov::as_type_ptr(node), + outputs, + inputs); + case ov::element::i8: + return evaluate(ov::as_type_ptr(node), + outputs, + inputs); + case ov::element::i16: + return evaluate(ov::as_type_ptr(node), + outputs, + inputs); + case ov::element::i32: + return evaluate(ov::as_type_ptr(node), + outputs, + inputs); + case ov::element::i64: + return evaluate(ov::as_type_ptr(node), + outputs, + inputs); + case ov::element::u1: + return evaluate(ov::as_type_ptr(node), + outputs, + inputs); + case ov::element::u4: + return evaluate(ov::as_type_ptr(node), + outputs, + inputs); + case ov::element::u8: + return evaluate(ov::as_type_ptr(node), + outputs, + inputs); + case ov::element::u16: + return evaluate(ov::as_type_ptr(node), + outputs, + inputs); + case ov::element::u32: + return evaluate(ov::as_type_ptr(node), + outputs, + inputs); + case ov::element::u64: + return evaluate(ov::as_type_ptr(node), + outputs, + inputs); default: - OPENVINO_THROW(std::string("Unhandled data type ") + node->get_element_type().get_type_name() + - std::string("in evaluate_node()")); + OPENVINO_THROW("Unhandled data type ", node->get_element_type().get_type_name(), " in evaluate_node()"); } } diff --git a/src/plugins/template/backend/ops/extract_image_patches.cpp b/src/plugins/template/backend/ops/extract_image_patches.cpp index d78a21e984b3fb..f1b087e3c44147 100644 --- a/src/plugins/template/backend/ops/extract_image_patches.cpp +++ b/src/plugins/template/backend/ops/extract_image_patches.cpp @@ -6,94 +6,93 @@ #include "evaluate_node.hpp" -template -bool evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { - using T = typename ngraph::element_type_traits::value_type; +template +bool evaluate(const std::shared_ptr& op, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { + using T = typename ov::element_type_traits::value_type; ov::reference::extract_image_patches(op, - inputs[0]->get_data_ptr(), - outputs[0]->get_data_ptr(), - inputs[0]->get_shape(), - outputs[0]->get_shape()); + inputs[0].data(), + outputs[0].data(), + inputs[0].get_shape(), + outputs[0].get_shape()); return true; } template <> -bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { auto element_type = node->get_output_element_type(0); - if (ov::is_type(node) || ov::is_type(node)) + if (ov::is_type(node) || ov::is_type(node)) element_type = node->get_input_element_type(1); switch (element_type) { - case ngraph::element::Type_t::boolean: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::bf16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i4: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i8: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u1: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u4: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u8: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u64: - return evaluate(ov::as_type_ptr(node), + case ov::element::Type_t::boolean: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::Type_t::bf16: + return evaluate(ov::as_type_ptr(node), + outputs, + inputs); + case ov::element::Type_t::f16: + return evaluate(ov::as_type_ptr(node), + outputs, + inputs); + case ov::element::Type_t::f64: + return evaluate(ov::as_type_ptr(node), + outputs, + inputs); + case ov::element::Type_t::f32: + return evaluate(ov::as_type_ptr(node), + outputs, + inputs); + case ov::element::Type_t::i4: + return evaluate(ov::as_type_ptr(node), + outputs, + inputs); + case ov::element::Type_t::i8: + return evaluate(ov::as_type_ptr(node), + outputs, + inputs); + case ov::element::Type_t::i16: + return evaluate(ov::as_type_ptr(node), + outputs, + inputs); + case ov::element::Type_t::i32: + return evaluate(ov::as_type_ptr(node), + outputs, + inputs); + case ov::element::Type_t::i64: + return evaluate(ov::as_type_ptr(node), + outputs, + inputs); + case ov::element::Type_t::u1: + return evaluate(ov::as_type_ptr(node), + outputs, + inputs); + case ov::element::Type_t::u4: + return evaluate(ov::as_type_ptr(node), + outputs, + inputs); + case ov::element::Type_t::u8: + return evaluate(ov::as_type_ptr(node), + outputs, + inputs); + case ov::element::Type_t::u16: + return evaluate(ov::as_type_ptr(node), + outputs, + inputs); + case ov::element::Type_t::u32: + return evaluate(ov::as_type_ptr(node), + outputs, + inputs); + case ov::element::Type_t::u64: + return evaluate(ov::as_type_ptr(node), + outputs, + inputs); default: - OPENVINO_THROW(std::string("Unhandled data type ") + node->get_element_type().get_type_name() + - std::string("in evaluate_node()")); + OPENVINO_THROW("Unhandled data type ", node->get_element_type().get_type_name(), " in evaluate_node()"); } } diff --git a/src/plugins/template/backend/ops/fft.cpp b/src/plugins/template/backend/ops/fft.cpp index db4620270faaf9..6ee238c0b4cf14 100644 --- a/src/plugins/template/backend/ops/fft.cpp +++ b/src/plugins/template/backend/ops/fft.cpp @@ -11,16 +11,16 @@ namespace fft_v7 { struct InfoForFFT7 { std::vector input_data; std::vector axes_data; - ngraph::Shape input_data_shape; - ngraph::Shape axes_data_shape; - ngraph::Shape output_shape; + ov::Shape input_data_shape; + ov::Shape axes_data_shape; + ov::Shape output_shape; }; -InfoForFFT7 get_info_for_fft7_eval(const std::vector>& inputs) { +InfoForFFT7 get_info_for_fft7_eval(const ov::TensorVector& inputs) { InfoForFFT7 result; - result.input_data_shape = inputs[0]->get_shape(); - result.axes_data_shape = inputs[1]->get_shape(); + result.input_data_shape = inputs[0].get_shape(); + result.axes_data_shape = inputs[1].get_shape(); result.input_data = get_floats(inputs[0], result.input_data_shape); result.axes_data = get_integers(inputs[1], result.axes_data_shape); @@ -48,14 +48,12 @@ InfoForFFT7 get_info_for_fft7_eval(const std::vector -bool evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +template +bool evaluate(const std::shared_ptr& op, ov::TensorVector& outputs, const ov::TensorVector& inputs) { auto info = fft_v7::get_info_for_fft7_eval(inputs); - outputs[0]->set_shape(info.output_shape); + outputs[0].set_shape(info.output_shape); - std::vector fft_result(ngraph::shape_size(info.output_shape), 0.0f); + std::vector fft_result(ov::shape_size(info.output_shape), 0.0f); ov::reference::fft(info.input_data.data(), info.input_data_shape, info.axes_data.data(), @@ -69,14 +67,12 @@ bool evaluate(const std::shared_ptr& op, return true; } -template -bool evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +template +bool evaluate(const std::shared_ptr& op, ov::TensorVector& outputs, const ov::TensorVector& inputs) { auto info = fft_v7::get_info_for_fft7_eval(inputs); - outputs[0]->set_shape(info.output_shape); + outputs[0].set_shape(info.output_shape); - std::vector fft_result(ngraph::shape_size(info.output_shape), 0.0f); + std::vector fft_result(ov::shape_size(info.output_shape), 0.0f); ov::reference::fft(info.input_data.data(), info.input_data_shape, info.axes_data.data(), @@ -91,95 +87,93 @@ bool evaluate(const std::shared_ptr& op, } template <> -bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { auto element_type = node->get_output_element_type(0); - if (ov::is_type(node) || ov::is_type(node)) + if (ov::is_type(node) || ov::is_type(node)) element_type = node->get_input_element_type(1); switch (element_type) { - case ngraph::element::Type_t::boolean: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::bf16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i4: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i8: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u1: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u4: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u8: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::boolean: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::bf16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u1: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); default: - OPENVINO_THROW(std::string("Unhandled data type ") + node->get_element_type().get_type_name() + - std::string("in evaluate_node()")); + OPENVINO_THROW("Unhandled data type ", node->get_element_type().get_type_name(), " in evaluate_node()"); } } template <> -bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { auto element_type = node->get_output_element_type(0); - if (ov::is_type(node) || ov::is_type(node)) + if (ov::is_type(node) || ov::is_type(node)) element_type = node->get_input_element_type(1); switch (element_type) { - case ngraph::element::Type_t::boolean: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::bf16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i4: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i8: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u1: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u4: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u8: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::boolean: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::bf16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u1: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); default: - OPENVINO_THROW(std::string("Unhandled data type ") + node->get_element_type().get_type_name() + - std::string("in evaluate_node()")); + OPENVINO_THROW("Unhandled data type ", node->get_element_type().get_type_name(), " in evaluate_node()"); } } diff --git a/src/plugins/template/backend/ops/gather.cpp b/src/plugins/template/backend/ops/gather.cpp index 9bb9799dc0d664..027a6c8cca1df7 100644 --- a/src/plugins/template/backend/ops/gather.cpp +++ b/src/plugins/template/backend/ops/gather.cpp @@ -6,24 +6,24 @@ #include "evaluate_node.hpp" -template -bool evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { - using T = typename ngraph::element_type_traits::value_type; - if (op->get_input_element_type(1) == ngraph::element::i64) { - ov::reference::gather(inputs[0]->get_data_ptr(), - inputs[1]->get_data_ptr(), - outputs[0]->get_data_ptr(), +template +bool evaluate(const std::shared_ptr& op, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { + using T = typename ov::element_type_traits::value_type; + if (op->get_input_element_type(1) == ov::element::i64) { + ov::reference::gather(inputs[0].data(), + inputs[1].data(), + outputs[0].data(), op->get_input_shape(0), op->get_input_shape(1), op->get_output_shape(0), op->get_axis(), op->get_batch_dims()); - } else if (op->get_input_element_type(1) == ngraph::element::i32) { - ov::reference::gather(inputs[0]->get_data_ptr(), - inputs[1]->get_data_ptr(), - outputs[0]->get_data_ptr(), + } else if (op->get_input_element_type(1) == ov::element::i32) { + ov::reference::gather(inputs[0].data(), + inputs[1].data(), + outputs[0].data(), op->get_input_shape(0), op->get_input_shape(1), op->get_output_shape(0), @@ -36,50 +36,47 @@ bool evaluate(const std::shared_ptr& op, } template <> -bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { auto element_type = node->get_output_element_type(0); - if (ov::is_type(node) || ov::is_type(node)) + if (ov::is_type(node) || ov::is_type(node)) element_type = node->get_input_element_type(1); switch (element_type) { - case ngraph::element::Type_t::boolean: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::bf16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i4: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i8: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u1: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u4: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u8: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::boolean: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::bf16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u1: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); default: - OPENVINO_THROW(std::string("Unhandled data type ") + node->get_element_type().get_type_name() + - std::string("in evaluate_node()")); + OPENVINO_THROW("Unhandled data type ", node->get_element_type().get_type_name(), " in evaluate_node()"); } } diff --git a/src/plugins/template/backend/ops/gather_elements.cpp b/src/plugins/template/backend/ops/gather_elements.cpp index 9c7ac6e892cfa4..e919dc14e166a0 100644 --- a/src/plugins/template/backend/ops/gather_elements.cpp +++ b/src/plugins/template/backend/ops/gather_elements.cpp @@ -6,31 +6,31 @@ #include "evaluate_node.hpp" -template -bool evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { - using T = typename ngraph::element_type_traits::value_type; - ngraph::Shape params_shape = inputs[0]->get_shape(); - ngraph::Shape indices_shape = inputs[1]->get_shape(); +template +bool evaluate(const std::shared_ptr& op, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { + using T = typename ov::element_type_traits::value_type; + ov::Shape params_shape = inputs[0].get_shape(); + ov::Shape indices_shape = inputs[1].get_shape(); - outputs[0]->set_shape(indices_shape); + outputs[0].set_shape(indices_shape); - if (inputs[1]->get_element_type() == ngraph::element::i64) { - ov::reference::gather_elements(inputs[0]->get_data_ptr(), - inputs[1]->get_data_ptr(), - outputs[0]->get_data_ptr(), - inputs[0]->get_shape(), - inputs[1]->get_shape(), - outputs[0]->get_shape(), + if (inputs[1].get_element_type() == ov::element::i64) { + ov::reference::gather_elements(inputs[0].data(), + inputs[1].data(), + outputs[0].data(), + inputs[0].get_shape(), + inputs[1].get_shape(), + outputs[0].get_shape(), op->get_axis()); - } else if (inputs[1]->get_element_type() == ngraph::element::i32) { - ov::reference::gather_elements(inputs[0]->get_data_ptr(), - inputs[1]->get_data_ptr(), - outputs[0]->get_data_ptr(), - inputs[0]->get_shape(), - inputs[1]->get_shape(), - outputs[0]->get_shape(), + } else if (inputs[1].get_element_type() == ov::element::i32) { + ov::reference::gather_elements(inputs[0].data(), + inputs[1].data(), + outputs[0].data(), + inputs[0].get_shape(), + inputs[1].get_shape(), + outputs[0].get_shape(), op->get_axis()); } else { OPENVINO_THROW("Unexpected indices type"); @@ -40,80 +40,47 @@ bool evaluate(const std::shared_ptr& op, } template <> -bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { auto element_type = node->get_output_element_type(0); - if (ov::is_type(node) || ov::is_type(node)) + if (ov::is_type(node) || ov::is_type(node)) element_type = node->get_input_element_type(1); switch (element_type) { - case ngraph::element::Type_t::boolean: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::bf16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i4: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i8: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u1: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u4: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u8: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); + case ov::element::boolean: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::bf16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u1: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); default: - OPENVINO_THROW(std::string("Unhandled data type ") + node->get_element_type().get_type_name() + - std::string("in evaluate_node()")); + OPENVINO_THROW("Unhandled data type ", node->get_element_type().get_type_name(), " in evaluate_node()"); } } diff --git a/src/plugins/template/backend/ops/gather_nd.cpp b/src/plugins/template/backend/ops/gather_nd.cpp index 97127a297d287d..373fb57eeb6074 100644 --- a/src/plugins/template/backend/ops/gather_nd.cpp +++ b/src/plugins/template/backend/ops/gather_nd.cpp @@ -6,26 +6,26 @@ #include "evaluate_node.hpp" -template -bool evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { - using T = typename ngraph::element_type_traits::value_type; - if (op->get_input_element_type(1) == ngraph::element::i64) { - ov::reference::gather_nd(inputs[0]->get_data_ptr(), - inputs[1]->get_data_ptr(), - outputs[0]->get_data_ptr(), - inputs[0]->get_shape(), - inputs[1]->get_shape(), - outputs[0]->get_shape(), +template +bool evaluate(const std::shared_ptr& op, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { + using T = typename ov::element_type_traits::value_type; + if (op->get_input_element_type(1) == ov::element::i64) { + ov::reference::gather_nd(inputs[0].data(), + inputs[1].data(), + outputs[0].data(), + inputs[0].get_shape(), + inputs[1].get_shape(), + outputs[0].get_shape(), static_cast(op->get_batch_dims())); - } else if (op->get_input_element_type(1) == ngraph::element::i32) { - ov::reference::gather_nd(inputs[0]->get_data_ptr(), - inputs[1]->get_data_ptr(), - outputs[0]->get_data_ptr(), - inputs[0]->get_shape(), - inputs[1]->get_shape(), - outputs[0]->get_shape(), + } else if (op->get_input_element_type(1) == ov::element::i32) { + ov::reference::gather_nd(inputs[0].data(), + inputs[1].data(), + outputs[0].data(), + inputs[0].get_shape(), + inputs[1].get_shape(), + outputs[0].get_shape(), static_cast(op->get_batch_dims())); } else { OPENVINO_THROW("Unexpected indices type for GatherND operation"); @@ -33,26 +33,26 @@ bool evaluate(const std::shared_ptr& op, return true; } -template -bool evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { - using T = typename ngraph::element_type_traits::value_type; - if (op->get_input_element_type(1) == ngraph::element::i64) { - ov::reference::gather_nd(inputs[0]->get_data_ptr(), - inputs[1]->get_data_ptr(), - outputs[0]->get_data_ptr(), - inputs[0]->get_shape(), - inputs[1]->get_shape(), - outputs[0]->get_shape(), +template +bool evaluate(const std::shared_ptr& op, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { + using T = typename ov::element_type_traits::value_type; + if (op->get_input_element_type(1) == ov::element::i64) { + ov::reference::gather_nd(inputs[0].data(), + inputs[1].data(), + outputs[0].data(), + inputs[0].get_shape(), + inputs[1].get_shape(), + outputs[0].get_shape(), static_cast(op->get_batch_dims())); - } else if (op->get_input_element_type(1) == ngraph::element::i32) { - ov::reference::gather_nd(inputs[0]->get_data_ptr(), - inputs[1]->get_data_ptr(), - outputs[0]->get_data_ptr(), - inputs[0]->get_shape(), - inputs[1]->get_shape(), - outputs[0]->get_shape(), + } else if (op->get_input_element_type(1) == ov::element::i32) { + ov::reference::gather_nd(inputs[0].data(), + inputs[1].data(), + outputs[0].data(), + inputs[0].get_shape(), + inputs[1].get_shape(), + outputs[0].get_shape(), static_cast(op->get_batch_dims())); } else { OPENVINO_THROW("Unexpected indices type for GatherND operation"); @@ -61,103 +61,93 @@ bool evaluate(const std::shared_ptr& op, } template <> -bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { auto element_type = node->get_output_element_type(0); - if (ov::is_type(node) || ov::is_type(node)) + if (ov::is_type(node) || ov::is_type(node)) element_type = node->get_input_element_type(1); switch (element_type) { - case ngraph::element::Type_t::boolean: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::bf16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i4: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i8: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u1: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u4: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u8: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::boolean: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::bf16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u1: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); default: - OPENVINO_THROW(std::string("Unhandled data type ") + node->get_element_type().get_type_name() + - std::string("in evaluate_node()")); + OPENVINO_THROW("Unhandled data type ", node->get_element_type().get_type_name(), " in evaluate_node()"); } } template <> -bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { auto element_type = node->get_output_element_type(0); - if (ov::is_type(node) || ov::is_type(node)) + if (ov::is_type(node) || ov::is_type(node)) element_type = node->get_input_element_type(1); switch (element_type) { - case ngraph::element::Type_t::boolean: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::bf16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i4: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i8: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u1: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u4: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u8: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::boolean: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::bf16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u1: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); default: - OPENVINO_THROW(std::string("Unhandled data type ") + node->get_element_type().get_type_name() + - std::string("in evaluate_node()")); + OPENVINO_THROW("Unhandled data type ", node->get_element_type().get_type_name(), " in evaluate_node()"); } } diff --git a/src/plugins/template/backend/ops/gather_tree.cpp b/src/plugins/template/backend/ops/gather_tree.cpp index 1aec9368d7cd4f..1c06cec35d34f4 100644 --- a/src/plugins/template/backend/ops/gather_tree.cpp +++ b/src/plugins/template/backend/ops/gather_tree.cpp @@ -6,98 +6,29 @@ #include "evaluate_node.hpp" -template -bool evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { - ov::reference::gather_tree(inputs[0]->get_data_ptr(), - inputs[1]->get_data_ptr(), - inputs[2]->get_data_ptr(), - inputs[3]->get_data_ptr(), - outputs[0]->get_data_ptr(), +bool evaluate(const std::shared_ptr& op, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { + ov::reference::gather_tree(static_cast(inputs[0].data()), + static_cast(inputs[1].data()), + static_cast(inputs[2].data()), + static_cast(inputs[3].data()), + static_cast(outputs[0].data()), op->get_input_shape(0), op->get_input_shape(1), op->get_input_shape(2), op->get_input_shape(3), - inputs[1]->get_element_type()); + inputs[1].get_element_type()); return true; } template <> -bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { auto element_type = node->get_output_element_type(0); - if (ov::is_type(node) || ov::is_type(node)) + if (ov::is_type(node) || ov::is_type(node)) element_type = node->get_input_element_type(1); - switch (element_type) { - case ngraph::element::Type_t::boolean: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::bf16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i4: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i8: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u1: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u4: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u8: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - default: - OPENVINO_THROW(std::string("Unhandled data type ") + node->get_element_type().get_type_name() + - std::string("in evaluate_node()")); - } + return evaluate(ov::as_type_ptr(node), outputs, inputs); } diff --git a/src/plugins/template/backend/ops/gelu.cpp b/src/plugins/template/backend/ops/gelu.cpp index 0b994fedca4536..dae4e32e967dae 100644 --- a/src/plugins/template/backend/ops/gelu.cpp +++ b/src/plugins/template/backend/ops/gelu.cpp @@ -6,120 +6,114 @@ #include "evaluate_node.hpp" -template -bool evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { - using T = typename ngraph::element_type_traits::value_type; - ov::reference::gelu(inputs[0]->get_data_ptr(), - outputs[0]->get_data_ptr(), - ngraph::op::GeluApproximationMode::ERF, - ngraph::shape_size(inputs[0]->get_shape())); +template +bool evaluate(const std::shared_ptr& op, ov::TensorVector& outputs, const ov::TensorVector& inputs) { + using T = typename ov::element_type_traits::value_type; + ov::reference::gelu(inputs[0].data(), + outputs[0].data(), + ov::op::GeluApproximationMode::ERF, + ov::shape_size(inputs[0].get_shape())); return true; } -template -bool evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { - using T = typename ngraph::element_type_traits::value_type; - ov::reference::gelu(inputs[0]->get_data_ptr(), - outputs[0]->get_data_ptr(), +template +bool evaluate(const std::shared_ptr& op, ov::TensorVector& outputs, const ov::TensorVector& inputs) { + using T = typename ov::element_type_traits::value_type; + ov::reference::gelu(inputs[0].data(), + outputs[0].data(), op->get_approximation_mode(), - ngraph::shape_size(inputs[0]->get_shape())); + ov::shape_size(inputs[0].get_shape())); return true; } template <> -bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { auto element_type = node->get_output_element_type(0); - if (ov::is_type(node) || ov::is_type(node)) + if (ov::is_type(node) || ov::is_type(node)) element_type = node->get_input_element_type(1); switch (element_type) { - case ngraph::element::Type_t::boolean: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::bf16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i4: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i8: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u1: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u4: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u8: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::boolean: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::bf16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u1: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); default: - OPENVINO_THROW(std::string("Unhandled data type ") + node->get_element_type().get_type_name() + - std::string("in evaluate_node()")); + OPENVINO_THROW("Unhandled data type ", node->get_element_type().get_type_name(), " in evaluate_node()"); } } template <> -bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { auto element_type = node->get_output_element_type(0); - if (ov::is_type(node) || ov::is_type(node)) + if (ov::is_type(node) || ov::is_type(node)) element_type = node->get_input_element_type(1); switch (element_type) { - case ngraph::element::Type_t::boolean: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::bf16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i4: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i8: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u1: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u4: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u8: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::boolean: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::bf16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u1: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); default: - OPENVINO_THROW(std::string("Unhandled data type ") + node->get_element_type().get_type_name() + - std::string("in evaluate_node()")); + OPENVINO_THROW("Unhandled data type ", node->get_element_type().get_type_name(), " in evaluate_node()"); } } diff --git a/src/plugins/template/backend/ops/generate_proposal.cpp b/src/plugins/template/backend/ops/generate_proposal.cpp index 53571e113e9b67..bbdb0a140c191d 100644 --- a/src/plugins/template/backend/ops/generate_proposal.cpp +++ b/src/plugins/template/backend/ops/generate_proposal.cpp @@ -7,10 +7,10 @@ #include "evaluate_node.hpp" #include "evaluates_map.hpp" -template -bool evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +template +bool evaluate(const std::shared_ptr& op, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { const auto& attrs = op->get_attrs(); if (attrs.post_nms_count < 0) { @@ -21,10 +21,10 @@ bool evaluate(const std::shared_ptr& op, const auto& output_type = op->get_input_element_type(0); - const auto& im_info_shape = inputs[0]->get_shape(); - const auto& anchors_shape = inputs[1]->get_shape(); - const auto& deltas_shape = inputs[2]->get_shape(); - const auto& scores_shape = inputs[3]->get_shape(); + const auto& im_info_shape = inputs[0].get_shape(); + const auto& anchors_shape = inputs[1].get_shape(); + const auto& deltas_shape = inputs[2].get_shape(); + const auto& scores_shape = inputs[3].get_shape(); const auto im_info_data = get_floats(inputs[0], im_info_shape); const auto anchors_data = get_floats(inputs[1], anchors_shape); @@ -50,22 +50,19 @@ bool evaluate(const std::shared_ptr& op, size_t num_selected = static_cast(std::accumulate(output_num.begin(), output_num.end(), 0)); - ngraph::Shape output_rois_shape = ngraph::Shape{num_selected, 4}; - ngraph::Shape output_scores_shape = ngraph::Shape{num_selected}; + ov::Shape output_rois_shape = ov::Shape{num_selected, 4}; + ov::Shape output_scores_shape = ov::Shape{num_selected}; - outputs[0]->set_element_type(output_type); - outputs[0]->set_shape(output_rois_shape); - outputs[1]->set_element_type(output_type); - outputs[1]->set_shape(output_scores_shape); + outputs[0].set_shape(output_rois_shape); + outputs[1].set_shape(output_scores_shape); const auto& roi_num_type = op->get_output_element_type(2); - ngraph::Shape output_roi_num_shape = ngraph::Shape{im_info_shape[0]}; - outputs[2]->set_element_type(roi_num_type); - outputs[2]->set_shape(output_roi_num_shape); + ov::Shape output_roi_num_shape = ov::Shape{im_info_shape[0]}; + outputs[2].set_shape(output_roi_num_shape); - ov::reference::generate_proposals_postprocessing(outputs[0]->get_data_ptr(), - outputs[1]->get_data_ptr(), - outputs[2]->get_data_ptr(), + ov::reference::generate_proposals_postprocessing(outputs[0].data(), + outputs[1].data(), + outputs[2].data(), output_type, roi_num_type, output_rois, @@ -78,80 +75,47 @@ bool evaluate(const std::shared_ptr& op, } template <> -bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { auto element_type = node->get_output_element_type(0); - if (ov::is_type(node) || ov::is_type(node)) + if (ov::is_type(node) || ov::is_type(node)) element_type = node->get_input_element_type(1); switch (element_type) { - case ngraph::element::Type_t::boolean: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::bf16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i4: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i8: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u1: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u4: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u8: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); + case ov::element::boolean: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::bf16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u1: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); default: - OPENVINO_THROW(std::string("Unhandled data type ") + node->get_element_type().get_type_name() + - std::string("in evaluate_node()")); + OPENVINO_THROW("Unhandled data type ", node->get_element_type().get_type_name(), " in evaluate_node()"); } } diff --git a/src/plugins/template/backend/ops/greater.cpp b/src/plugins/template/backend/ops/greater.cpp index 6df8f4c73e372d..7f8d28389933f0 100644 --- a/src/plugins/template/backend/ops/greater.cpp +++ b/src/plugins/template/backend/ops/greater.cpp @@ -6,72 +6,64 @@ #include "evaluate_node.hpp" -template -bool evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { - const auto in0_data_ptr = inputs[0]->get_data_ptr(); - const auto in1_data_ptr = inputs[1]->get_data_ptr(); - const auto out_data_ptr = outputs[0]->get_data_ptr(); - const auto in0_shape = inputs[0]->get_shape(); - const auto in1_shape = inputs[1]->get_shape(); +template +bool evaluate(const std::shared_ptr& op, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { + using ET = typename ov::element_type_traits::value_type; + using BT = typename ov::element_type_traits::value_type; + const auto in0_data_ptr = inputs[0].data(); + const auto in1_data_ptr = inputs[1].data(); + const auto out_data_ptr = outputs[0].data(); + const auto in0_shape = inputs[0].get_shape(); + const auto in1_shape = inputs[1].get_shape(); const auto broadcast_spec = op->get_autob(); - ov::reference::greater::value_type, - typename ngraph::element_type_traits::value_type>( - in0_data_ptr, - in1_data_ptr, - out_data_ptr, - in0_shape, - in1_shape, - broadcast_spec); + ov::reference::greater(in0_data_ptr, in1_data_ptr, out_data_ptr, in0_shape, in1_shape, broadcast_spec); return true; } template <> -bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { auto element_type = node->get_output_element_type(0); - if (ov::is_type(node) || ov::is_type(node)) + if (ov::is_type(node) || ov::is_type(node)) element_type = node->get_input_element_type(1); switch (element_type) { - case ngraph::element::Type_t::boolean: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::bf16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i4: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i8: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u1: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u4: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u8: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::boolean: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::bf16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u1: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); default: - OPENVINO_THROW(std::string("Unhandled data type ") + node->get_element_type().get_type_name() + - std::string("in evaluate_node()")); + OPENVINO_THROW("Unhandled data type ", node->get_element_type().get_type_name(), " in evaluate_node()"); } } diff --git a/src/plugins/template/backend/ops/grid_sample.cpp b/src/plugins/template/backend/ops/grid_sample.cpp index 20e74f5699a642..f47dba333f3c4e 100644 --- a/src/plugins/template/backend/ops/grid_sample.cpp +++ b/src/plugins/template/backend/ops/grid_sample.cpp @@ -6,19 +6,20 @@ #include "evaluate_node.hpp" -template -bool evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +template +bool evaluate(const std::shared_ptr& op, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { + using ET = typename ov::element_type_traits::value_type; const auto& attributes = op->get_attributes(); - ngraph::element::Type grid_et = op->get_input_element_type(1); + ov::element::Type grid_et = op->get_input_element_type(1); switch (grid_et) { - case ngraph::element::Type_t::f32: - ov::reference::grid_sample(outputs[0]->get_data_ptr(), - inputs[0]->get_data_ptr(), - inputs[1]->get_data_ptr(), - inputs[0]->get_shape(), - inputs[1]->get_shape(), + case ov::element::f32: + ov::reference::grid_sample(outputs[0].data(), + inputs[0].data(), + inputs[1].data(), + inputs[0].get_shape(), + inputs[1].get_shape(), attributes.align_corners, attributes.mode, attributes.padding_mode); @@ -30,80 +31,47 @@ bool evaluate(const std::shared_ptr& op, } template <> -bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { auto element_type = node->get_output_element_type(0); - if (ov::is_type(node) || ov::is_type(node)) + if (ov::is_type(node) || ov::is_type(node)) element_type = node->get_input_element_type(1); switch (element_type) { - case ngraph::element::Type_t::boolean: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::bf16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i4: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i8: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u1: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u4: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u8: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); + case ov::element::boolean: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::bf16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u1: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); default: - OPENVINO_THROW(std::string("Unhandled data type ") + node->get_element_type().get_type_name() + - std::string("in evaluate_node()")); + OPENVINO_THROW("Unhandled data type ", node->get_element_type().get_type_name(), " in evaluate_node()"); } } diff --git a/src/plugins/template/backend/ops/grn.cpp b/src/plugins/template/backend/ops/grn.cpp index 74a5fceaa23f09..4eb748373f5005 100644 --- a/src/plugins/template/backend/ops/grn.cpp +++ b/src/plugins/template/backend/ops/grn.cpp @@ -6,61 +6,55 @@ #include "evaluate_node.hpp" -template -bool evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { - using T = typename ngraph::element_type_traits::value_type; - ov::reference::grn(inputs[0]->get_data_ptr(), - outputs[0]->get_data_ptr(), - op->get_bias(), - inputs[0]->get_shape()); +template +bool evaluate(const std::shared_ptr& op, ov::TensorVector& outputs, const ov::TensorVector& inputs) { + using ET = typename ov::element_type_traits::value_type; + ov::reference::grn(inputs[0].data(), outputs[0].data(), op->get_bias(), inputs[0].get_shape()); return true; } template <> -bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { auto element_type = node->get_output_element_type(0); - if (ov::is_type(node) || ov::is_type(node)) + if (ov::is_type(node) || ov::is_type(node)) element_type = node->get_input_element_type(1); switch (element_type) { - case ngraph::element::Type_t::boolean: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::bf16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i4: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i8: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u1: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u4: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u8: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::boolean: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::bf16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u1: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); default: - OPENVINO_THROW(std::string("Unhandled data type ") + node->get_element_type().get_type_name() + - std::string("in evaluate_node()")); + OPENVINO_THROW("Unhandled data type ", node->get_element_type().get_type_name(), " in evaluate_node()"); } } diff --git a/src/plugins/template/backend/ops/group_convolution.cpp b/src/plugins/template/backend/ops/group_convolution.cpp index 6dc851171d2d5b..be1a6601dd2d3f 100644 --- a/src/plugins/template/backend/ops/group_convolution.cpp +++ b/src/plugins/template/backend/ops/group_convolution.cpp @@ -6,104 +6,72 @@ #include "evaluate_node.hpp" -template -bool evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { - const auto filter_data = inputs[1]->get_data_ptr(); - auto out_data_ptr = outputs[0]->get_data_ptr(); - const auto in_data_ptr = inputs[0]->get_data_ptr(); - const auto& out_shape = outputs[0]->get_shape(); - const auto& in_shape = inputs[0]->get_shape(); - const auto& filter_shape = inputs[1]->get_shape(); - ov::reference::group_convolution::value_type>(in_data_ptr, - filter_data, - out_data_ptr, - in_shape, - filter_shape, - out_shape, - op->get_strides(), - op->get_dilations(), - op->get_pads_begin(), - op->get_pads_end()); +template +bool evaluate(const std::shared_ptr& op, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { + using ET = typename ov::element_type_traits::value_type; + const auto filter_data = inputs[1].data(); + auto out_data_ptr = outputs[0].data(); + const auto in_data_ptr = inputs[0].data(); + const auto& out_shape = outputs[0].get_shape(); + const auto& in_shape = inputs[0].get_shape(); + const auto& filter_shape = inputs[1].get_shape(); + ov::reference::group_convolution(in_data_ptr, + filter_data, + out_data_ptr, + in_shape, + filter_shape, + out_shape, + op->get_strides(), + op->get_dilations(), + op->get_pads_begin(), + op->get_pads_end()); return true; } template <> -bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { auto element_type = node->get_output_element_type(0); - if (ov::is_type(node) || ov::is_type(node)) + if (ov::is_type(node) || ov::is_type(node)) element_type = node->get_input_element_type(1); switch (element_type) { - case ngraph::element::Type_t::boolean: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::bf16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i4: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i8: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u1: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u4: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u8: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); + case ov::element::boolean: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::bf16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u1: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); default: - OPENVINO_THROW(std::string("Unhandled data type ") + node->get_element_type().get_type_name() + - std::string("in evaluate_node()")); + OPENVINO_THROW("Unhandled data type ", node->get_element_type().get_type_name(), " in evaluate_node()"); } } diff --git a/src/plugins/template/backend/ops/group_convolution_backprop_data.cpp b/src/plugins/template/backend/ops/group_convolution_backprop_data.cpp index ec58d1efdb83e7..26f1c44e57f9c6 100644 --- a/src/plugins/template/backend/ops/group_convolution_backprop_data.cpp +++ b/src/plugins/template/backend/ops/group_convolution_backprop_data.cpp @@ -6,122 +6,105 @@ #include "evaluate_node.hpp" -template -bool evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { - const auto in_data_ptr = inputs[0]->get_data_ptr(); - const auto filter_data_ptr = inputs[1]->get_data_ptr(); - const auto out_data_ptr = outputs[0]->get_data_ptr(); - const auto in_shape = inputs[0]->get_shape(); - const auto filter_shape = inputs[1]->get_shape(); - const auto out_shape = outputs[0]->get_shape(); - ov::reference::group_convolution_backprop_data::value_type>( - in_data_ptr, - filter_data_ptr, - out_data_ptr, - in_shape, - filter_shape, - out_shape, - op->get_strides(), - op->get_dilations(), - op->get_pads_begin(), - op->get_pads_end(), - op->get_output_padding()); +template +bool evaluate(const std::shared_ptr& op, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { + using ET = typename ov::element_type_traits::value_type; + const auto in_data_ptr = inputs[0].data(); + const auto filter_data_ptr = inputs[1].data(); + const auto out_data_ptr = outputs[0].data(); + const auto in_shape = inputs[0].get_shape(); + const auto filter_shape = inputs[1].get_shape(); + const auto out_shape = outputs[0].get_shape(); + ov::reference::group_convolution_backprop_data(in_data_ptr, + filter_data_ptr, + out_data_ptr, + in_shape, + filter_shape, + out_shape, + op->get_strides(), + op->get_dilations(), + op->get_pads_begin(), + op->get_pads_end(), + op->get_output_padding()); return true; } template <> -bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { auto element_type = node->get_output_element_type(0); - if (ov::is_type(node) || ov::is_type(node)) + if (ov::is_type(node) || ov::is_type(node)) element_type = node->get_input_element_type(1); switch (element_type) { - case ngraph::element::Type_t::boolean: - return evaluate( - ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::bf16: - return evaluate( - ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f16: - return evaluate( - ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f64: - return evaluate( - ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f32: - return evaluate( - ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i4: - return evaluate( - ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i8: - return evaluate( - ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i16: - return evaluate( - ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i32: - return evaluate( - ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i64: - return evaluate( - ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u1: - return evaluate( - ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u4: - return evaluate( - ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u8: - return evaluate( - ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u16: - return evaluate( - ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u32: - return evaluate( - ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u64: - return evaluate( - ov::as_type_ptr(node), - outputs, - inputs); + case ov::element::boolean: + return evaluate(ov::as_type_ptr(node), + outputs, + inputs); + case ov::element::bf16: + return evaluate(ov::as_type_ptr(node), + outputs, + inputs); + case ov::element::f16: + return evaluate(ov::as_type_ptr(node), + outputs, + inputs); + case ov::element::f64: + return evaluate(ov::as_type_ptr(node), + outputs, + inputs); + case ov::element::f32: + return evaluate(ov::as_type_ptr(node), + outputs, + inputs); + case ov::element::i4: + return evaluate(ov::as_type_ptr(node), + outputs, + inputs); + case ov::element::i8: + return evaluate(ov::as_type_ptr(node), + outputs, + inputs); + case ov::element::i16: + return evaluate(ov::as_type_ptr(node), + outputs, + inputs); + case ov::element::i32: + return evaluate(ov::as_type_ptr(node), + outputs, + inputs); + case ov::element::i64: + return evaluate(ov::as_type_ptr(node), + outputs, + inputs); + case ov::element::u1: + return evaluate(ov::as_type_ptr(node), + outputs, + inputs); + case ov::element::u4: + return evaluate(ov::as_type_ptr(node), + outputs, + inputs); + case ov::element::u8: + return evaluate(ov::as_type_ptr(node), + outputs, + inputs); + case ov::element::u16: + return evaluate(ov::as_type_ptr(node), + outputs, + inputs); + case ov::element::u32: + return evaluate(ov::as_type_ptr(node), + outputs, + inputs); + case ov::element::u64: + return evaluate(ov::as_type_ptr(node), + outputs, + inputs); default: - OPENVINO_THROW(std::string("Unhandled data type ") + node->get_element_type().get_type_name() + - std::string("in evaluate_node()")); + OPENVINO_THROW("Unhandled data type ", node->get_element_type().get_type_name(), " in evaluate_node()"); } } diff --git a/src/plugins/template/backend/ops/group_normalization.cpp b/src/plugins/template/backend/ops/group_normalization.cpp index 71481b560ac2c2..eb339388822f40 100644 --- a/src/plugins/template/backend/ops/group_normalization.cpp +++ b/src/plugins/template/backend/ops/group_normalization.cpp @@ -9,16 +9,17 @@ using namespace ov; -template +template bool evaluate(const std::shared_ptr& node, - const ov::HostTensorVector& outputs, - const ov::HostTensorVector& inputs) { - outputs[0]->set_shape(inputs[0]->get_shape()); - ov::reference::group_normalization(inputs[0]->get_data_ptr(), - inputs[1]->get_data_ptr(), - inputs[2]->get_data_ptr(), - outputs[0]->get_data_ptr(), - inputs[0]->get_shape(), + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { + using ET = typename ov::element_type_traits::value_type; + outputs[0].set_shape(inputs[0].get_shape()); + ov::reference::group_normalization(inputs[0].data(), + inputs[1].data(), + inputs[2].data(), + outputs[0].data(), + inputs[0].get_shape(), static_cast(node->get_num_groups()), node->get_epsilon()); return true; @@ -26,18 +27,18 @@ bool evaluate(const std::shared_ptr& node, template <> bool evaluate_node(std::shared_ptr node, - const ov::HostTensorVector& outputs, - const ov::HostTensorVector& inputs) { + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { switch (node->get_input_element_type(0)) { - case element::Type_t::bf16: - return evaluate(as_type_ptr(node), outputs, inputs); - case element::Type_t::f16: - return evaluate(as_type_ptr(node), outputs, inputs); - case element::Type_t::f64: - return evaluate(as_type_ptr(node), outputs, inputs); - case element::Type_t::f32: - return evaluate(as_type_ptr(node), outputs, inputs); + case element::bf16: + return evaluate(as_type_ptr(node), outputs, inputs); + case element::f16: + return evaluate(as_type_ptr(node), outputs, inputs); + case element::f64: + return evaluate(as_type_ptr(node), outputs, inputs); + case element::f32: + return evaluate(as_type_ptr(node), outputs, inputs); default: - OPENVINO_THROW("Unhandled data type ", node->get_element_type().get_type_name(), "in evaluate_node()"); + OPENVINO_THROW("Unhandled data type ", node->get_element_type().get_type_name(), " in evaluate_node()"); } } diff --git a/src/plugins/template/backend/ops/gru_cell.cpp b/src/plugins/template/backend/ops/gru_cell.cpp index b34b5ea945965c..cbd431121fb058 100644 --- a/src/plugins/template/backend/ops/gru_cell.cpp +++ b/src/plugins/template/backend/ops/gru_cell.cpp @@ -7,22 +7,22 @@ #include "evaluate_node.hpp" #include "ov_ops/augru_cell.hpp" -template -bool evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { - using T = typename ngraph::element_type_traits::value_type; - ov::reference::gru_cell(inputs[0]->get_data_ptr(), - inputs[0]->get_shape(), - inputs[1]->get_data_ptr(), - inputs[1]->get_shape(), - inputs[2]->get_data_ptr(), - inputs[2]->get_shape(), - inputs[3]->get_data_ptr(), - inputs[3]->get_shape(), - inputs[4]->get_data_ptr(), - inputs[4]->get_shape(), - outputs[0]->get_data_ptr(), +template +bool evaluate(const std::shared_ptr& op, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { + using T = typename ov::element_type_traits::value_type; + ov::reference::gru_cell(inputs[0].data(), + inputs[0].get_shape(), + inputs[1].data(), + inputs[1].get_shape(), + inputs[2].data(), + inputs[2].get_shape(), + inputs[3].data(), + inputs[3].get_shape(), + inputs[4].data(), + inputs[4].get_shape(), + outputs[0].data(), op->get_activations()[0], op->get_activations()[1], op->get_clip(), @@ -30,154 +30,118 @@ bool evaluate(const std::shared_ptr& op, return true; } -template +template bool evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { - using T = typename ngraph::element_type_traits::value_type; - ov::reference::gru_cell(inputs[0]->get_data_ptr(), - inputs[0]->get_shape(), - inputs[1]->get_data_ptr(), - inputs[1]->get_shape(), - inputs[2]->get_data_ptr(), - inputs[2]->get_shape(), - inputs[3]->get_data_ptr(), - inputs[3]->get_shape(), - inputs[4]->get_data_ptr(), - inputs[4]->get_shape(), - outputs[0]->get_data_ptr(), + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { + using T = typename ov::element_type_traits::value_type; + ov::reference::gru_cell(inputs[0].data(), + inputs[0].get_shape(), + inputs[1].data(), + inputs[1].get_shape(), + inputs[2].data(), + inputs[2].get_shape(), + inputs[3].data(), + inputs[3].get_shape(), + inputs[4].data(), + inputs[4].get_shape(), + outputs[0].data(), op->get_activations()[0], op->get_activations()[1], op->get_clip(), op->get_linear_before_reset(), - inputs[5]->get_data_ptr()); + inputs[5].data()); return true; } template <> -bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { auto element_type = node->get_output_element_type(0); - if (ov::is_type(node) || ov::is_type(node)) + if (ov::is_type(node) || ov::is_type(node)) element_type = node->get_input_element_type(1); switch (element_type) { - case ngraph::element::Type_t::boolean: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::bf16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i4: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i8: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u1: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u4: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u8: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::boolean: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::bf16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u1: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); default: - OPENVINO_THROW(std::string("Unhandled data type ") + node->get_element_type().get_type_name() + - std::string("in evaluate_node()")); + OPENVINO_THROW("Unhandled data type ", node->get_element_type().get_type_name(), " in evaluate_node()"); } } template <> -bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { auto element_type = node->get_output_element_type(0); - if (ov::is_type(node) || ov::is_type(node)) + if (ov::is_type(node) || ov::is_type(node)) element_type = node->get_input_element_type(1); switch (element_type) { - case ngraph::element::Type_t::boolean: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::bf16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i4: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i8: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u1: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u4: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u8: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); + case ov::element::boolean: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::bf16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u1: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); default: - OPENVINO_THROW(std::string("Unhandled data type ") + node->get_element_type().get_type_name() + - std::string("in evaluate_node()")); + OPENVINO_THROW("Unhandled data type ", node->get_element_type().get_type_name(), " in evaluate_node()"); } } diff --git a/src/plugins/template/backend/ops/hard_sigmoid.cpp b/src/plugins/template/backend/ops/hard_sigmoid.cpp index 9cf2a16f5dace1..9d3b9f56b53115 100644 --- a/src/plugins/template/backend/ops/hard_sigmoid.cpp +++ b/src/plugins/template/backend/ops/hard_sigmoid.cpp @@ -2,99 +2,65 @@ // SPDX-License-Identifier: Apache-2.0 // -// clang-format off -#include "evaluate_node.hpp" #include "openvino/reference/hard_sigmoid.hpp" -// clang-format on -template -bool evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { - using T = typename ngraph::element_type_traits::value_type; - ov::reference::hard_sigmoid(inputs[0]->get_data_ptr(), - inputs[1]->get_data_ptr()[0], - inputs[2]->get_data_ptr()[0], - outputs[0]->get_data_ptr(), - ngraph::shape_size(outputs[0]->get_shape())); +#include "evaluate_node.hpp" + +template +bool evaluate(const std::shared_ptr& op, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { + using T = typename ov::element_type_traits::value_type; + ov::reference::hard_sigmoid(inputs[0].data(), + inputs[1].data()[0], + inputs[2].data()[0], + outputs[0].data(), + ov::shape_size(outputs[0].get_shape())); return true; } template <> -bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { auto element_type = node->get_output_element_type(0); - if (ov::is_type(node) || ov::is_type(node)) + if (ov::is_type(node) || ov::is_type(node)) element_type = node->get_input_element_type(1); switch (element_type) { - case ngraph::element::Type_t::boolean: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::bf16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i4: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i8: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u1: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u4: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u8: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); + case ov::element::boolean: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::bf16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u1: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); default: - OPENVINO_THROW(std::string("Unhandled data type ") + node->get_element_type().get_type_name() + - std::string("in evaluate_node()")); + OPENVINO_THROW("Unhandled data type ", node->get_element_type().get_type_name(), " in evaluate_node()"); } } diff --git a/src/plugins/template/backend/ops/if.cpp b/src/plugins/template/backend/ops/if.cpp index df93652d103bdb..8795d0bfa789b6 100644 --- a/src/plugins/template/backend/ops/if.cpp +++ b/src/plugins/template/backend/ops/if.cpp @@ -6,23 +6,24 @@ #include "evaluate_node.hpp" #include "evaluates_map.hpp" +#include "shape_util.hpp" namespace if_op { -bool call(const ngraph::HostTensorVector& func_outputs, - const ngraph::HostTensorVector& func_inputs, - const std::shared_ptr& function) { - // map function params -> ngraph::HostTensor - std::unordered_map> tensor_map; +bool call(ov::TensorVector& func_outputs, + const ov::TensorVector& func_inputs, + const std::shared_ptr& function) { + // map function params -> ov::Tensor + std::unordered_map tensor_map; size_t input_count = 0; for (const auto& param : function->get_parameters()) { for (size_t i = 0; i < param->get_output_size(); ++i) { - ngraph::descriptor::Tensor* tensor = ¶m->output(i).get_tensor(); + ov::descriptor::Tensor* tensor = ¶m->output(i).get_tensor(); tensor_map.insert({tensor, func_inputs[input_count++]}); } } - std::unordered_map, size_t> results_map; - // map function outputs -> ngraph::HostTensor + std::unordered_map, size_t> results_map; + // map function outputs -> ov::HostTensor for (size_t output_count = 0; output_count < function->get_results().size(); ++output_count) { auto output = function->get_results()[output_count]; results_map[output] = output_count; @@ -30,27 +31,27 @@ bool call(const ngraph::HostTensorVector& func_outputs, // for each ordered op in the graph for (const auto& op : function->get_ordered_ops()) { - if (ngraph::op::is_parameter(op)) { + if (ov::op::util::is_parameter(op)) { continue; } // get op inputs from map - std::vector> op_inputs; + std::vector op_inputs; for (auto input : op->inputs()) { - ngraph::descriptor::Tensor* tensor = &input.get_tensor(); + ov::descriptor::Tensor* tensor = &input.get_tensor(); op_inputs.push_back(tensor_map.at(tensor)); } // get op outputs from map or create - std::vector> op_outputs; + std::vector op_outputs; for (size_t i = 0; i < op->get_output_size(); ++i) { - ngraph::descriptor::Tensor* tensor = &op->output(i).get_tensor(); - std::shared_ptr host_tensor; + ov::descriptor::Tensor* tensor = &op->output(i).get_tensor(); + ov::Tensor host_tensor; auto it = tensor_map.find(tensor); - if (ngraph::op::is_output(op)) { + if (ov::op::util::is_output(op)) { host_tensor = func_outputs[results_map[op]]; } else if (it == tensor_map.end()) { - host_tensor = std::make_shared(op->output(i)); + host_tensor = ov::Tensor(op->output(i)); tensor_map.insert({tensor, host_tensor}); } else { host_tensor = it->second; @@ -58,22 +59,18 @@ bool call(const ngraph::HostTensorVector& func_outputs, op_outputs.push_back(host_tensor); } op->validate_and_infer_types(); - OPENVINO_SUPPRESS_DEPRECATED_START if (!op->evaluate(op_outputs, op_inputs)) { - const auto& evaluates_map = ngraph::runtime::interpreter::get_evaluators_map(); + const auto& evaluates_map = ov::runtime::interpreter::get_evaluators_map(); auto it = evaluates_map.find(op->get_type_info()); if (!it->second(op, op_outputs, op_inputs)) { return false; } } - OPENVINO_SUPPRESS_DEPRECATED_END } return true; } -void function(const std::shared_ptr& function, - const ngraph::HostTensorVector& inputs, - ngraph::HostTensorVector& outputs) { +void function(const std::shared_ptr& function, const ov::TensorVector& inputs, ov::TensorVector& outputs) { const auto& parameters = function->get_parameters(); const auto& parametersNumber = parameters.size(); const auto& inputsNumber = inputs.size(); @@ -90,10 +87,10 @@ void function(const std::shared_ptr& function, const auto& parameterIndex = function->get_parameter_index(parameter); const auto& parameterShape = parameter->get_shape(); const auto& parameterType = parameter->get_element_type(); - const auto& parameterSize = ngraph::shape_size(parameterShape) * parameterType.size(); + const auto& parameterSize = ov::shape_size(parameterShape) * parameterType.size(); const auto& input = inputs[parameterIndex]; - const auto& inputSize = input->get_size_in_bytes(); + const auto& inputSize = input.get_byte_size(); NGRAPH_CHECK(parameterSize == inputSize, "Got parameter (", parameter->get_friendly_name(), @@ -109,22 +106,26 @@ void function(const std::shared_ptr& function, const auto& results = function->get_results(); outputs.reserve(results.size()); for (size_t i = 0; i < results.size(); ++i) { - outputs.push_back(std::make_shared()); + OPENVINO_SUPPRESS_DEPRECATED_START + ov::Shape res_shape = results[i]->get_output_partial_shape(0).is_static() ? results[i]->get_output_shape(0) + : ov::util::make_dynamic_shape(); + OPENVINO_SUPPRESS_DEPRECATED_END + outputs.push_back(ov::Tensor(results[i]->get_element_type(), res_shape)); } call(outputs, inputs, function); } -void if_reference(const std::vector>& bodies, - const std::vector& out_descs, - const std::vector& input_descs, - const ngraph::HostTensorVector& out, - const ngraph::HostTensorVector& args) { +void if_reference(const std::vector>& bodies, + const std::vector& out_descs, + const std::vector& input_descs, + ov::TensorVector& out, + const ov::TensorVector& args) { NGRAPH_CHECK(args.size() > 0, "If operation must have input condition value"); - auto condition_value = args[0]->get_data_ptr()[0]; - auto branch_index = (condition_value) ? ngraph::op::v8::If::THEN_BODY_INDEX : ngraph::op::v8::If::ELSE_BODY_INDEX; - ngraph::HostTensorVector inputs_to_body; - ngraph::HostTensorVector outs_from_body; + auto condition_value = args[0].data()[0]; + auto branch_index = (condition_value) ? ov::op::v8::If::THEN_BODY_INDEX : ov::op::v8::If::ELSE_BODY_INDEX; + ov::TensorVector inputs_to_body; + ov::TensorVector outs_from_body; inputs_to_body.resize(input_descs[branch_index].size()); auto inputs_size = args.size(); auto output_size = out.size(); @@ -140,17 +141,16 @@ void if_reference(const std::vector>& bodies, "Incorrect associating! If has not output with id ", out_descr->m_output_index); auto res = outs_from_body[out_descr->m_body_value_index]; - out[out_descr->m_output_index]->set_shape(res->get_shape()); - out[out_descr->m_output_index]->write(res->get_data_ptr(), res->get_size_in_bytes()); + out[out_descr->m_output_index].set_shape(res.get_shape()); + + res.copy_to(out[out_descr->m_output_index]); } } } // namespace if_op -template -bool evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { - std::vector> bodies; +template +bool evaluate(const std::shared_ptr& op, ov::TensorVector& outputs, const ov::TensorVector& inputs) { + std::vector> bodies; for (size_t i = 0; i < op->get_internal_subgraphs_size(); i++) { bodies.emplace_back(op->get_function(static_cast(i))); } @@ -171,46 +171,46 @@ bool evaluate(const std::shared_ptr& op, } template <> -bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { auto element_type = node->get_output_element_type(0); - if (ov::is_type(node) || ov::is_type(node)) + if (ov::is_type(node) || ov::is_type(node)) element_type = node->get_input_element_type(1); switch (element_type) { - case ngraph::element::Type_t::boolean: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::bf16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i4: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i8: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u1: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u4: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u8: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::boolean: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::bf16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u1: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); default: OPENVINO_THROW(std::string("Unhandled data type ") + node->get_element_type().get_type_name() + std::string("in evaluate_node()")); diff --git a/src/plugins/template/backend/ops/interpolate.cpp b/src/plugins/template/backend/ops/interpolate.cpp index c2f760c00524ba..16d3a425f5b486 100644 --- a/src/plugins/template/backend/ops/interpolate.cpp +++ b/src/plugins/template/backend/ops/interpolate.cpp @@ -7,39 +7,39 @@ #include "evaluate_node.hpp" #include "interpolate_shape_inference.hpp" -template -bool evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { - ngraph::element::Type input_et = op->get_input_element_type(0); +template +bool evaluate(const std::shared_ptr& op, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { + ov::element::Type input_et = op->get_input_element_type(0); switch (input_et) { - case ngraph::element::Type_t::f64: - ov::reference::interpolate(inputs[0]->get_data_ptr(), + case ov::element::f64: + ov::reference::interpolate(inputs[0].data(), op->get_input_partial_shape(0), - outputs[0]->get_data_ptr(), + outputs[0].data(), op->get_output_shape(0), op->get_attrs()); break; - case ngraph::element::Type_t::f32: - ov::reference::interpolate(inputs[0]->get_data_ptr(), + case ov::element::f32: + ov::reference::interpolate(inputs[0].data(), op->get_input_partial_shape(0), - outputs[0]->get_data_ptr(), + outputs[0].data(), op->get_output_shape(0), op->get_attrs()); break; - case ngraph::element::Type_t::f16: - ov::reference::interpolate(inputs[0]->get_data_ptr(), - op->get_input_partial_shape(0), - outputs[0]->get_data_ptr(), - op->get_output_shape(0), - op->get_attrs()); + case ov::element::f16: + ov::reference::interpolate(inputs[0].data(), + op->get_input_partial_shape(0), + outputs[0].data(), + op->get_output_shape(0), + op->get_attrs()); break; - case ngraph::element::Type_t::bf16: - ov::reference::interpolate(inputs[0]->get_data_ptr(), - op->get_input_partial_shape(0), - outputs[0]->get_data_ptr(), - op->get_output_shape(0), - op->get_attrs()); + case ov::element::bf16: + ov::reference::interpolate(inputs[0].data(), + op->get_input_partial_shape(0), + outputs[0].data(), + op->get_output_shape(0), + op->get_attrs()); break; default:; } @@ -47,78 +47,46 @@ bool evaluate(const std::shared_ptr& op, } template <> -bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { auto element_type = node->get_output_element_type(0); - if (ov::is_type(node) || ov::is_type(node)) + if (ov::is_type(node) || ov::is_type(node)) element_type = node->get_input_element_type(1); switch (element_type) { - case ngraph::element::Type_t::boolean: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::bf16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i4: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i8: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u1: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u4: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u8: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); + case ov::element::boolean: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::bf16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u1: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); default: OPENVINO_THROW(std::string("Unhandled data type ") + node->get_element_type().get_type_name() + std::string("in evaluate_node()")); @@ -129,7 +97,7 @@ namespace eval { namespace interpolate { // The helpers below are similar to the internal utils used in evaluate method of v4::Intepolate core op // Those functions can be unified and moved to a common place -std::vector get_axes_vector(const ngraph::HostTensorVector& args, +std::vector get_axes_vector(const ov::TensorVector& args, size_t default_size, size_t axes_port, size_t max_num_of_ports) { @@ -138,18 +106,18 @@ std::vector get_axes_vector(const ngraph::HostTensorVector& args, if (num_of_inputs == max_num_of_ports) { auto axes_arg = args[axes_port]; - size_t num_of_axes = args[axes_port]->get_shape()[0]; + size_t num_of_axes = args[axes_port].get_shape()[0]; axes.reserve(num_of_axes); - if (axes_arg->get_element_type() == ov::element::i64) { - int64_t* axes_ptr = axes_arg->get_data_ptr(); + if (axes_arg.get_element_type() == ov::element::i64) { + int64_t* axes_ptr = axes_arg.data(); axes.insert(axes.end(), axes_ptr, axes_ptr + num_of_axes); - } else if (axes_arg->get_element_type() == ov::element::i32) { - int32_t* axes_ptr = axes_arg->get_data_ptr(); + } else if (axes_arg.get_element_type() == ov::element::i32) { + int32_t* axes_ptr = axes_arg.data(); for (size_t i = 0; i < num_of_axes; ++i) axes.push_back(axes_ptr[i]); } else { - OPENVINO_ASSERT(false, "Failed to process ", axes_arg->get_element_type()); + OPENVINO_THROW("Failed to process ", axes_arg.get_element_type()); } } else { for (size_t i = 0; i < default_size; ++i) { @@ -160,28 +128,28 @@ std::vector get_axes_vector(const ngraph::HostTensorVector& args, return axes; } -std::vector get_target_shape_vector(const ngraph::HostTensorVector& args, +std::vector get_target_shape_vector(const ov::TensorVector& args, size_t num_of_axes, size_t target_shape_port = 1) { std::vector target_shape; target_shape.reserve(num_of_axes); auto target_shape_arg = args[target_shape_port]; - if (target_shape_arg->get_element_type() == ov::element::i64) { - int64_t* target_shape_ptr = target_shape_arg->get_data_ptr(); + if (target_shape_arg.get_element_type() == ov::element::i64) { + int64_t* target_shape_ptr = target_shape_arg.data(); target_shape.insert(target_shape.end(), target_shape_ptr, target_shape_ptr + num_of_axes); - } else if (target_shape_arg->get_element_type() == ov::element::i32) { - int32_t* target_shape_ptr = target_shape_arg->get_data_ptr(); + } else if (target_shape_arg.get_element_type() == ov::element::i32) { + int32_t* target_shape_ptr = target_shape_arg.data(); for (size_t i = 0; i < num_of_axes; ++i) target_shape.push_back(target_shape_ptr[i]); } else { - OPENVINO_ASSERT(false, "Failed to process ", target_shape_arg->get_element_type()); + OPENVINO_THROW("Failed to process ", target_shape_arg.get_element_type()); } return target_shape; } -std::vector get_scales_vector(const ngraph::HostTensorVector& args, +std::vector get_scales_vector(const ov::TensorVector& args, const ov::Shape& input_shape, const ov::op::util::InterpolateBase::InterpolateAttrs& attrs, std::vector axes, @@ -189,7 +157,7 @@ std::vector get_scales_vector(const ngraph::HostTensorVector& args, std::vector scales; size_t num_of_axes = axes.size(); if (attrs.shape_calculation_mode == ov::op::util::InterpolateBase::ShapeCalcMode::SCALES) { - float* scales_ptr = args[scales_port]->get_data_ptr(); + float* scales_ptr = args[scales_port].data(); scales.insert(scales.end(), scales_ptr, scales_ptr + num_of_axes); } else { auto target_shape = get_target_shape_vector(args, num_of_axes); @@ -212,7 +180,7 @@ static void pad_input_data(const uint8_t* data_ptr, ov::CoordinateTransform input_transform(input_shape); ov::CoordinateTransform padded_transform(padded_input_shape); - for (const ngraph::Coordinate& input_coord : input_transform) { + for (const ov::Coordinate& input_coord : input_transform) { auto padded_coord = input_coord; size_t i = 0; for (size_t pad : pads_begin) { @@ -228,8 +196,8 @@ static void pad_input_data(const uint8_t* data_ptr, namespace v11 { bool evaluate_interpolate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { using namespace ov; constexpr size_t data_port = 0; @@ -237,16 +205,16 @@ bool evaluate_interpolate(const std::shared_ptr& op, constexpr size_t axes_port = 2; constexpr size_t max_num_of_ports = 3; - element::Type input_et = inputs[0]->get_element_type(); + element::Type input_et = inputs[0].get_element_type(); size_t type_size = input_et.size(); - PartialShape input_shape{inputs[data_port]->get_shape()}; + PartialShape input_shape{inputs[data_port].get_shape()}; auto m_attrs = op->get_attrs(); const auto ta = make_tensor_accessor(inputs); auto input_shapes = std::vector(); - std::transform(inputs.cbegin(), inputs.cend(), std::back_inserter(input_shapes), [](const HostTensorPtr& ht) { - return ht->get_shape(); + std::transform(inputs.cbegin(), inputs.cend(), std::back_inserter(input_shapes), [](const ov::Tensor& ht) { + return ht.get_shape(); }); const auto output_shape = ov::op::v11::shape_infer(op.get(), input_shapes, m_attrs.pads_begin, m_attrs.pads_end, ta).front(); @@ -256,17 +224,16 @@ bool evaluate_interpolate(const std::shared_ptr& op, padded_input_shape.emplace_back(m_attrs.pads_begin[i] + m_attrs.pads_end[i] + input_shape[i].get_length()); } - auto axes = get_axes_vector(inputs, inputs[1]->get_shape()[0], axes_port, max_num_of_ports); + auto axes = get_axes_vector(inputs, inputs[1].get_shape()[0], axes_port, max_num_of_ports); auto scales = get_scales_vector(inputs, padded_input_shape, m_attrs, axes, scales_sizes_port); Shape out_shape = output_shape.to_shape(); - outputs[0]->set_shape(out_shape); - outputs[0]->set_element_type(input_et); + outputs[0].set_shape(out_shape); size_t bytes_in_padded_input = shape_size(padded_input_shape) * type_size; std::vector padded_input_data(bytes_in_padded_input, 0); - const uint8_t* data_ptr = inputs[0]->get_data_ptr(); + const uint8_t* data_ptr = static_cast(inputs[0].data()); uint8_t* padded_data_ptr = padded_input_data.data(); pad_input_data(data_ptr, @@ -277,57 +244,57 @@ bool evaluate_interpolate(const std::shared_ptr& op, m_attrs.pads_begin); switch (input_et) { - case element::Type_t::f32: + case element::f32: ov::reference::interpolate(reinterpret_cast(padded_data_ptr), padded_input_shape, scales, axes, - outputs[0]->get_data_ptr(), + outputs[0].data(), out_shape, m_attrs); break; - case element::Type_t::bf16: + case element::bf16: ov::reference::interpolate(reinterpret_cast(padded_data_ptr), padded_input_shape, scales, axes, - outputs[0]->get_data_ptr(), + outputs[0].data(), out_shape, m_attrs); break; - case element::Type_t::f16: + case element::f16: ov::reference::interpolate(reinterpret_cast(padded_data_ptr), padded_input_shape, scales, axes, - outputs[0]->get_data_ptr(), + outputs[0].data(), out_shape, m_attrs); break; - case element::Type_t::u8: + case element::u8: ov::reference::interpolate(reinterpret_cast(padded_data_ptr), padded_input_shape, scales, axes, - outputs[0]->get_data_ptr(), + outputs[0].data(), out_shape, m_attrs); break; - case element::Type_t::i8: + case element::i8: ov::reference::interpolate(reinterpret_cast(padded_data_ptr), padded_input_shape, scales, axes, - outputs[0]->get_data_ptr(), + outputs[0].data(), out_shape, m_attrs); break; - case element::Type_t::i32: + case element::i32: ov::reference::interpolate(reinterpret_cast(padded_data_ptr), padded_input_shape, scales, axes, - outputs[0]->get_data_ptr(), + outputs[0].data(), out_shape, m_attrs); break; @@ -340,88 +307,55 @@ bool evaluate_interpolate(const std::shared_ptr& op, } // namespace interpolate } // namespace eval -template -bool evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +template +bool evaluate(const std::shared_ptr& op, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { return eval::interpolate::v11::evaluate_interpolate(op, outputs, inputs); } template <> -bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { auto element_type = node->get_output_element_type(0); - if (ov::is_type(node) || ov::is_type(node)) + if (ov::is_type(node) || ov::is_type(node)) element_type = node->get_input_element_type(1); switch (element_type) { - case ngraph::element::Type_t::boolean: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::bf16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i4: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i8: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u1: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u4: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u8: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); + case ov::element::boolean: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::bf16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u1: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); default: - OPENVINO_THROW(std::string("Unhandled data type ") + node->get_element_type().get_type_name() + - std::string("in evaluate_node()")); + OPENVINO_THROW("Unhandled data type ", node->get_element_type().get_type_name(), " in evaluate_node()"); } } diff --git a/src/plugins/template/backend/ops/irdft.cpp b/src/plugins/template/backend/ops/irdft.cpp index 65a6093a2fda4e..4bf662d4e7b80c 100644 --- a/src/plugins/template/backend/ops/irdft.cpp +++ b/src/plugins/template/backend/ops/irdft.cpp @@ -12,18 +12,18 @@ namespace irfft_v9 { struct InfoForIRFFT9 { std::vector input_data; std::vector axes_data; - ngraph::Shape input_data_shape; - ngraph::Shape axes_data_shape; - ngraph::Shape fft_output_shape; - ngraph::Shape output_shape; + ov::Shape input_data_shape; + ov::Shape axes_data_shape; + ov::Shape fft_output_shape; + ov::Shape output_shape; int64_t last_signal_size; }; -InfoForIRFFT9 get_info_for_irfft9_eval(const std::vector>& inputs) { +InfoForIRFFT9 get_info_for_irfft9_eval(const ov::TensorVector& inputs) { InfoForIRFFT9 result; - result.input_data_shape = inputs[0]->get_shape(); - result.axes_data_shape = inputs[1]->get_shape(); + result.input_data_shape = inputs[0].get_shape(); + result.axes_data_shape = inputs[1].get_shape(); result.input_data = get_floats(inputs[0], result.input_data_shape); result.axes_data = get_integers(inputs[1], result.axes_data_shape); @@ -64,14 +64,12 @@ InfoForIRFFT9 get_info_for_irfft9_eval(const std::vector -bool evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +template +bool evaluate(const std::shared_ptr& op, ov::TensorVector& outputs, const ov::TensorVector& inputs) { auto info = irfft_v9::get_info_for_irfft9_eval(inputs); - outputs[0]->set_shape(info.output_shape); + outputs[0].set_shape(info.output_shape); - std::vector irfft_result(ngraph::shape_size(info.output_shape), 0.0f); + std::vector irfft_result(ov::shape_size(info.output_shape), 0.0f); ov::reference::irdft(info.input_data, info.input_data_shape, info.axes_data, @@ -86,50 +84,47 @@ bool evaluate(const std::shared_ptr& op, } template <> -bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { auto element_type = node->get_output_element_type(0); - if (ov::is_type(node) || ov::is_type(node)) + if (ov::is_type(node) || ov::is_type(node)) element_type = node->get_input_element_type(1); switch (element_type) { - case ngraph::element::Type_t::boolean: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::bf16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i4: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i8: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u1: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u4: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u8: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::boolean: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::bf16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u1: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); default: - OPENVINO_THROW(std::string("Unhandled data type ") + node->get_element_type().get_type_name() + - std::string("in evaluate_node()")); + OPENVINO_THROW("Unhandled data type ", node->get_element_type().get_type_name(), " in evaluate_node()"); } } diff --git a/src/plugins/template/backend/ops/is_finite.cpp b/src/plugins/template/backend/ops/is_finite.cpp index 2ec4826a50b7ac..3f081149cf0ea7 100644 --- a/src/plugins/template/backend/ops/is_finite.cpp +++ b/src/plugins/template/backend/ops/is_finite.cpp @@ -2,36 +2,37 @@ // SPDX-License-Identifier: Apache-2.0 // -// clang-format off -#include "evaluate_node.hpp" #include "openvino/reference/is_finite.hpp" -// clang-format on -template -bool evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { - ngraph::element::Type input_et = op->get_input_element_type(0); +#include "evaluate_node.hpp" +#include "openvino/core/type/element_type.hpp" + +template +bool evaluate(const std::shared_ptr& op, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { + using BT = typename ov::element_type_traits::value_type; + ov::element::Type input_et = op->get_input_element_type(0); switch (input_et) { - case ngraph::element::Type_t::f64: - ov::reference::is_finite(inputs[0]->get_data_ptr(), - outputs[0]->get_data_ptr(), - ngraph::shape_size(inputs[0]->get_shape())); + case ov::element::f64: + ov::reference::is_finite(inputs[0].data(), + outputs[0].data(), + ov::shape_size(inputs[0].get_shape())); break; - case ngraph::element::Type_t::f32: - ov::reference::is_finite(inputs[0]->get_data_ptr(), - outputs[0]->get_data_ptr(), - ngraph::shape_size(inputs[0]->get_shape())); + case ov::element::f32: + ov::reference::is_finite(inputs[0].data(), + outputs[0].data(), + ov::shape_size(inputs[0].get_shape())); break; - case ngraph::element::Type_t::f16: - ov::reference::is_finite(inputs[0]->get_data_ptr(), - outputs[0]->get_data_ptr(), - ngraph::shape_size(inputs[0]->get_shape())); + case ov::element::f16: + ov::reference::is_finite(inputs[0].data(), + outputs[0].data(), + ov::shape_size(inputs[0].get_shape())); break; - case ngraph::element::Type_t::bf16: - ov::reference::is_finite(inputs[0]->get_data_ptr(), - outputs[0]->get_data_ptr(), - ngraph::shape_size(inputs[0]->get_shape())); + case ov::element::bf16: + ov::reference::is_finite(inputs[0].data(), + outputs[0].data(), + ov::shape_size(inputs[0].get_shape())); break; default: return false; @@ -40,70 +41,47 @@ bool evaluate(const std::shared_ptr& op, } template <> -bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { auto element_type = node->get_output_element_type(0); - if (ov::is_type(node) || ov::is_type(node)) + if (ov::is_type(node) || ov::is_type(node)) element_type = node->get_input_element_type(1); switch (element_type) { - case ngraph::element::Type_t::boolean: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::bf16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i4: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i8: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u1: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u4: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u8: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); + case ov::element::boolean: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::bf16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u1: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); default: - OPENVINO_THROW(std::string("Unhandled data type ") + node->get_element_type().get_type_name() + - std::string("in evaluate_node()")); + OPENVINO_THROW("Unhandled data type ", node->get_element_type().get_type_name(), " in evaluate_node()"); } } diff --git a/src/plugins/template/backend/ops/is_inf.cpp b/src/plugins/template/backend/ops/is_inf.cpp index 4509ced254446d..40255efce351b8 100644 --- a/src/plugins/template/backend/ops/is_inf.cpp +++ b/src/plugins/template/backend/ops/is_inf.cpp @@ -2,39 +2,39 @@ // SPDX-License-Identifier: Apache-2.0 // -// clang-format off -#include "evaluate_node.hpp" #include "openvino/reference/is_inf.hpp" -// clang-format on -template -bool evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { - ngraph::element::Type input_et = op->get_input_element_type(0); +#include "evaluate_node.hpp" + +template +bool evaluate(const std::shared_ptr& op, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { + using BT = typename ov::element_type_traits::value_type; + ov::element::Type input_et = op->get_input_element_type(0); switch (input_et) { - case ngraph::element::Type_t::f64: - ov::reference::is_inf(inputs[0]->get_data_ptr(), - outputs[0]->get_data_ptr(), - ngraph::shape_size(inputs[0]->get_shape()), + case ov::element::f64: + ov::reference::is_inf(inputs[0].data(), + outputs[0].data(), + ov::shape_size(inputs[0].get_shape()), op->get_attributes()); break; - case ngraph::element::Type_t::f32: - ov::reference::is_inf(inputs[0]->get_data_ptr(), - outputs[0]->get_data_ptr(), - ngraph::shape_size(inputs[0]->get_shape()), + case ov::element::f32: + ov::reference::is_inf(inputs[0].data(), + outputs[0].data(), + ov::shape_size(inputs[0].get_shape()), op->get_attributes()); break; - case ngraph::element::Type_t::f16: - ov::reference::is_inf(inputs[0]->get_data_ptr(), - outputs[0]->get_data_ptr(), - ngraph::shape_size(inputs[0]->get_shape()), + case ov::element::f16: + ov::reference::is_inf(inputs[0].data(), + outputs[0].data(), + ov::shape_size(inputs[0].get_shape()), op->get_attributes()); break; - case ngraph::element::Type_t::bf16: - ov::reference::is_inf(inputs[0]->get_data_ptr(), - outputs[0]->get_data_ptr(), - ngraph::shape_size(inputs[0]->get_shape()), + case ov::element::bf16: + ov::reference::is_inf(inputs[0].data(), + outputs[0].data(), + ov::shape_size(inputs[0].get_shape()), op->get_attributes()); break; default: @@ -44,50 +44,47 @@ bool evaluate(const std::shared_ptr& op, } template <> -bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { auto element_type = node->get_output_element_type(0); - if (ov::is_type(node) || ov::is_type(node)) + if (ov::is_type(node) || ov::is_type(node)) element_type = node->get_input_element_type(1); switch (element_type) { - case ngraph::element::Type_t::boolean: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::bf16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i4: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i8: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u1: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u4: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u8: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::boolean: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::bf16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u1: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); default: - OPENVINO_THROW(std::string("Unhandled data type ") + node->get_element_type().get_type_name() + - std::string("in evaluate_node()")); + OPENVINO_THROW("Unhandled data type ", node->get_element_type().get_type_name(), " in evaluate_node()"); } } diff --git a/src/plugins/template/backend/ops/is_nan.cpp b/src/plugins/template/backend/ops/is_nan.cpp index 87ba4c34328be4..c188256538e550 100644 --- a/src/plugins/template/backend/ops/is_nan.cpp +++ b/src/plugins/template/backend/ops/is_nan.cpp @@ -2,36 +2,32 @@ // SPDX-License-Identifier: Apache-2.0 // -// clang-format off -#include "evaluate_node.hpp" #include "openvino/reference/is_nan.hpp" -// clang-format on -template -bool evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { - ngraph::element::Type input_et = op->get_input_element_type(0); +#include "evaluate_node.hpp" + +template +bool evaluate(const std::shared_ptr& op, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { + using BT = typename ov::element_type_traits::value_type; + ov::element::Type input_et = op->get_input_element_type(0); switch (input_et) { - case ngraph::element::Type_t::f64: - ov::reference::is_nan(inputs[0]->get_data_ptr(), - outputs[0]->get_data_ptr(), - ngraph::shape_size(inputs[0]->get_shape())); + case ov::element::f64: + ov::reference::is_nan(inputs[0].data(), outputs[0].data(), ov::shape_size(inputs[0].get_shape())); break; - case ngraph::element::Type_t::f32: - ov::reference::is_nan(inputs[0]->get_data_ptr(), - outputs[0]->get_data_ptr(), - ngraph::shape_size(inputs[0]->get_shape())); + case ov::element::f32: + ov::reference::is_nan(inputs[0].data(), outputs[0].data(), ov::shape_size(inputs[0].get_shape())); break; - case ngraph::element::Type_t::f16: - ov::reference::is_nan(inputs[0]->get_data_ptr(), - outputs[0]->get_data_ptr(), - ngraph::shape_size(inputs[0]->get_shape())); + case ov::element::f16: + ov::reference::is_nan(inputs[0].data(), + outputs[0].data(), + ov::shape_size(inputs[0].get_shape())); break; - case ngraph::element::Type_t::bf16: - ov::reference::is_nan(inputs[0]->get_data_ptr(), - outputs[0]->get_data_ptr(), - ngraph::shape_size(inputs[0]->get_shape())); + case ov::element::bf16: + ov::reference::is_nan(inputs[0].data(), + outputs[0].data(), + ov::shape_size(inputs[0].get_shape())); break; default: return false; @@ -40,50 +36,47 @@ bool evaluate(const std::shared_ptr& op, } template <> -bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { auto element_type = node->get_output_element_type(0); - if (ov::is_type(node) || ov::is_type(node)) + if (ov::is_type(node) || ov::is_type(node)) element_type = node->get_input_element_type(1); switch (element_type) { - case ngraph::element::Type_t::boolean: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::bf16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i4: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i8: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u1: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u4: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u8: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::boolean: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::bf16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u1: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); default: - OPENVINO_THROW(std::string("Unhandled data type ") + node->get_element_type().get_type_name() + - std::string("in evaluate_node()")); + OPENVINO_THROW("Unhandled data type ", node->get_element_type().get_type_name(), " in evaluate_node()"); } } diff --git a/src/plugins/template/backend/ops/log.cpp b/src/plugins/template/backend/ops/log.cpp index c6b988dc66a16f..dea640a558443c 100644 --- a/src/plugins/template/backend/ops/log.cpp +++ b/src/plugins/template/backend/ops/log.cpp @@ -6,60 +6,55 @@ #include "evaluate_node.hpp" -template -bool evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { - using T = typename ngraph::element_type_traits::value_type; - ov::reference::log(inputs[0]->get_data_ptr(), - outputs[0]->get_data_ptr(), - ngraph::shape_size(inputs[0]->get_shape())); +template +bool evaluate(const std::shared_ptr& op, ov::TensorVector& outputs, const ov::TensorVector& inputs) { + using T = typename ov::element_type_traits::value_type; + ov::reference::log(inputs[0].data(), outputs[0].data(), ov::shape_size(inputs[0].get_shape())); return true; } template <> -bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { auto element_type = node->get_output_element_type(0); - if (ov::is_type(node) || ov::is_type(node)) + if (ov::is_type(node) || ov::is_type(node)) element_type = node->get_input_element_type(1); switch (element_type) { - case ngraph::element::Type_t::boolean: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::bf16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i4: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i8: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u1: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u4: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u8: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::boolean: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::bf16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u1: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); default: - OPENVINO_THROW(std::string("Unhandled data type ") + node->get_element_type().get_type_name() + - std::string("in evaluate_node()")); + OPENVINO_THROW("Unhandled data type ", node->get_element_type().get_type_name(), " in evaluate_node()"); } } diff --git a/src/plugins/template/backend/ops/log_softmax.cpp b/src/plugins/template/backend/ops/log_softmax.cpp index 415171d1db6caa..aa34a3905cb64c 100644 --- a/src/plugins/template/backend/ops/log_softmax.cpp +++ b/src/plugins/template/backend/ops/log_softmax.cpp @@ -6,97 +6,64 @@ #include "evaluate_node.hpp" -template -bool evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { - using T = typename ngraph::element_type_traits::value_type; +template +bool evaluate(const std::shared_ptr& op, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { + using T = typename ov::element_type_traits::value_type; int64_t i_axis = op->get_axis(); if (i_axis < 0) { - i_axis += inputs[0]->get_partial_shape().rank().get_length(); + i_axis += inputs[0].get_shape().size(); } - ov::reference::log_softmax(inputs[0]->get_data_ptr(), - outputs[0]->get_data_ptr(), + ov::reference::log_softmax(inputs[0].data(), + outputs[0].data(), op->get_output_shape(0), - ngraph::AxisSet{(size_t)i_axis}); + ov::AxisSet{(size_t)i_axis}); return true; } template <> -bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { auto element_type = node->get_output_element_type(0); - if (ov::is_type(node) || ov::is_type(node)) + if (ov::is_type(node) || ov::is_type(node)) element_type = node->get_input_element_type(1); switch (element_type) { - case ngraph::element::Type_t::boolean: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::bf16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i4: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i8: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u1: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u4: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u8: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); + case ov::element::boolean: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::bf16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u1: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); default: - OPENVINO_THROW(std::string("Unhandled data type ") + node->get_element_type().get_type_name() + - std::string("in evaluate_node()")); + OPENVINO_THROW("Unhandled data type ", node->get_element_type().get_type_name(), " in evaluate_node()"); } } diff --git a/src/plugins/template/backend/ops/lrn.cpp b/src/plugins/template/backend/ops/lrn.cpp index 5522a695bea922..4c5aca69a5f0af 100644 --- a/src/plugins/template/backend/ops/lrn.cpp +++ b/src/plugins/template/backend/ops/lrn.cpp @@ -6,15 +6,13 @@ #include "evaluate_node.hpp" -template -bool evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { - using T = typename ngraph::element_type_traits::value_type; - ov::reference::lrn(inputs[0]->get_data_ptr(), +template +bool evaluate(const std::shared_ptr& op, ov::TensorVector& outputs, const ov::TensorVector& inputs) { + using T = typename ov::element_type_traits::value_type; + ov::reference::lrn(inputs[0].data(), op->get_reduction_axes(), - outputs[0]->get_data_ptr(), - inputs[0]->get_shape(), + outputs[0].data(), + inputs[0].get_shape(), op->get_alpha(), op->get_beta(), op->get_bias(), @@ -23,48 +21,47 @@ bool evaluate(const std::shared_ptr& op, } template <> -bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { auto element_type = node->get_output_element_type(0); - if (ov::is_type(node) || ov::is_type(node)) + if (ov::is_type(node) || ov::is_type(node)) element_type = node->get_input_element_type(1); switch (element_type) { - case ngraph::element::Type_t::boolean: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::bf16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i4: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i8: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u1: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u4: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u8: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::boolean: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::bf16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u1: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); default: - OPENVINO_THROW(std::string("Unhandled data type ") + node->get_element_type().get_type_name() + - std::string("in evaluate_node()")); + OPENVINO_THROW("Unhandled data type ", node->get_element_type().get_type_name(), " in evaluate_node()"); } } diff --git a/src/plugins/template/backend/ops/lstm_cell.cpp b/src/plugins/template/backend/ops/lstm_cell.cpp index 12f81d29a26b13..1615c136cb3606 100644 --- a/src/plugins/template/backend/ops/lstm_cell.cpp +++ b/src/plugins/template/backend/ops/lstm_cell.cpp @@ -2,30 +2,29 @@ // SPDX-License-Identifier: Apache-2.0 // -// clang-format off -#include "evaluate_node.hpp" #include "openvino/reference/lstm_cell.hpp" -// clang-format on -template -bool evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { - using T = typename ngraph::element_type_traits::value_type; - ov::reference::lstm_cell(inputs[0]->get_data_ptr(), - inputs[0]->get_shape(), - inputs[1]->get_data_ptr(), - inputs[1]->get_shape(), - inputs[2]->get_data_ptr(), - inputs[2]->get_shape(), - inputs[3]->get_data_ptr(), - inputs[3]->get_shape(), - inputs[4]->get_data_ptr(), - inputs[4]->get_shape(), - inputs[5]->get_data_ptr(), - inputs[5]->get_shape(), - outputs[0]->get_data_ptr(), - outputs[1]->get_data_ptr(), +#include "evaluate_node.hpp" + +template +bool evaluate(const std::shared_ptr& op, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { + using T = typename ov::element_type_traits::value_type; + ov::reference::lstm_cell(inputs[0].data(), + inputs[0].get_shape(), + inputs[1].data(), + inputs[1].get_shape(), + inputs[2].data(), + inputs[2].get_shape(), + inputs[3].data(), + inputs[3].get_shape(), + inputs[4].data(), + inputs[4].get_shape(), + inputs[5].data(), + inputs[5].get_shape(), + outputs[0].data(), + outputs[1].data(), op->get_activations()[0], op->get_activations()[1], op->get_activations()[2], @@ -33,27 +32,27 @@ bool evaluate(const std::shared_ptr& op, return true; } -template -bool evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { - using T = typename ngraph::element_type_traits::value_type; - ov::reference::lstm_cell_v1(inputs[0]->get_data_ptr(), - inputs[0]->get_shape(), - inputs[1]->get_data_ptr(), - inputs[1]->get_shape(), - inputs[2]->get_data_ptr(), - inputs[2]->get_shape(), - inputs[3]->get_data_ptr(), - inputs[3]->get_shape(), - inputs[4]->get_data_ptr(), - inputs[4]->get_shape(), - inputs[5]->get_data_ptr(), - inputs[5]->get_shape(), - inputs[6]->get_data_ptr(), - inputs[6]->get_shape(), - outputs[0]->get_data_ptr(), - outputs[1]->get_data_ptr(), +template +bool evaluate(const std::shared_ptr& op, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { + using T = typename ov::element_type_traits::value_type; + ov::reference::lstm_cell_v1(inputs[0].data(), + inputs[0].get_shape(), + inputs[1].data(), + inputs[1].get_shape(), + inputs[2].data(), + inputs[2].get_shape(), + inputs[3].data(), + inputs[3].get_shape(), + inputs[4].data(), + inputs[4].get_shape(), + inputs[5].data(), + inputs[5].get_shape(), + inputs[6].data(), + inputs[6].get_shape(), + outputs[0].data(), + outputs[1].data(), op->get_activations()[0], op->get_activations()[1], op->get_activations()[2], @@ -64,50 +63,46 @@ bool evaluate(const std::shared_ptr& op, } template <> -bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { auto element_type = node->get_output_element_type(0); - if (ov::is_type(node) || ov::is_type(node)) + if (ov::is_type(node) || ov::is_type(node)) element_type = node->get_input_element_type(1); switch (element_type) { - case ngraph::element::Type_t::boolean: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::bf16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i4: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i8: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u1: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u4: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u8: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::boolean: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::bf16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u1: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); default: OPENVINO_THROW(std::string("Unhandled data type ") + node->get_element_type().get_type_name() + std::string("in evaluate_node()")); @@ -115,50 +110,46 @@ bool evaluate_node(std::shared_ptr node, } template <> -bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { auto element_type = node->get_output_element_type(0); - if (ov::is_type(node) || ov::is_type(node)) + if (ov::is_type(node) || ov::is_type(node)) element_type = node->get_input_element_type(1); switch (element_type) { - case ngraph::element::Type_t::boolean: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::bf16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i4: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i8: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u1: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u4: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u8: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::boolean: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::bf16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u1: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); default: OPENVINO_THROW(std::string("Unhandled data type ") + node->get_element_type().get_type_name() + std::string("in evaluate_node()")); diff --git a/src/plugins/template/backend/ops/matrix_nms.cpp b/src/plugins/template/backend/ops/matrix_nms.cpp index 3e13c542ec43b0..abf78dac65aa81 100644 --- a/src/plugins/template/backend/ops/matrix_nms.cpp +++ b/src/plugins/template/backend/ops/matrix_nms.cpp @@ -6,15 +6,17 @@ #include "evaluate_node.hpp" #include "evaluates_map.hpp" +#include "openvino/core/type/element_type.hpp" #include "openvino/reference/utils/nms_common.hpp" +#include "openvino/runtime/tensor.hpp" namespace matrix_nms_v8 { -using SortResultType = ngraph::op::v8::MatrixNms::SortResultType; +using SortResultType = ov::op::v8::MatrixNms::SortResultType; struct InfoForNMS { - ngraph::Shape selected_outputs_shape; - ngraph::Shape selected_indices_shape; - ngraph::Shape boxes_shape; - ngraph::Shape scores_shape; + ov::Shape selected_outputs_shape; + ov::Shape selected_indices_shape; + ov::Shape boxes_shape; + ov::Shape scores_shape; std::vector boxes_data; std::vector scores_data; size_t selected_outputs_shape_size; @@ -24,50 +26,42 @@ struct InfoForNMS { constexpr size_t boxes_port = 0; constexpr size_t scores_port = 1; -ngraph::PartialShape infer_selected_outputs_shape(const std::vector>& inputs, - int nms_top_k, - int keep_top_k) { - const auto boxes_ps = inputs[boxes_port]->get_partial_shape(); - const auto scores_ps = inputs[scores_port]->get_partial_shape(); - - ngraph::PartialShape result = {ngraph::Dimension::dynamic(), 6}; - - if (boxes_ps.rank().is_static() && scores_ps.rank().is_static()) { - const auto num_boxes_boxes = boxes_ps[1]; - if (num_boxes_boxes.is_static() && scores_ps[0].is_static() && scores_ps[1].is_static()) { - const auto num_boxes = num_boxes_boxes.get_length(); - const auto num_classes = scores_ps[1].get_length(); - int64_t max_output_boxes_per_class = 0; - if (nms_top_k >= 0) - max_output_boxes_per_class = std::min(num_boxes, (int64_t)nms_top_k); - else - max_output_boxes_per_class = num_boxes; - - auto max_output_boxes_per_batch = max_output_boxes_per_class * num_classes; - if (keep_top_k >= 0) - max_output_boxes_per_batch = std::min(max_output_boxes_per_batch, (int64_t)keep_top_k); - - result[0] = max_output_boxes_per_batch * scores_ps[0].get_length(); - } +ov::PartialShape infer_selected_outputs_shape(const ov::TensorVector& inputs, int nms_top_k, int keep_top_k) { + const auto boxes_ps = inputs[boxes_port].get_shape(); + const auto scores_ps = inputs[scores_port].get_shape(); + + ov::PartialShape result = {ov::Dimension::dynamic(), 6}; + + if (ov::shape_size(boxes_ps) && ov::shape_size(scores_ps)) { + const auto num_boxes = boxes_ps[1]; + const auto num_classes = scores_ps[1]; + size_t max_output_boxes_per_class = 0; + if (nms_top_k >= 0) + max_output_boxes_per_class = std::min(num_boxes, (size_t)nms_top_k); + else + max_output_boxes_per_class = num_boxes; + + auto max_output_boxes_per_batch = max_output_boxes_per_class * num_classes; + if (keep_top_k >= 0) + max_output_boxes_per_batch = std::min(max_output_boxes_per_batch, (size_t)keep_top_k); + + result[0] = max_output_boxes_per_batch * scores_ps[0]; } return result; } -std::vector prepare_boxes_data(const std::shared_ptr& boxes, - const ngraph::Shape& boxes_shape) { +std::vector prepare_boxes_data(const ov::Tensor& boxes, const ov::Shape& boxes_shape) { auto result = get_floats(boxes, boxes_shape); return result; } -std::vector prepare_scores_data(const std::shared_ptr& scores, - const ngraph::Shape& scores_shape) { +std::vector prepare_scores_data(const ov::Tensor& scores, const ov::Shape& scores_shape) { auto result = get_floats(scores, scores_shape); return result; } -InfoForNMS get_info_for_nms_eval(const std::shared_ptr& nms, - const std::vector>& inputs) { +InfoForNMS get_info_for_nms_eval(const std::shared_ptr& nms, const ov::TensorVector& inputs) { InfoForNMS result; const auto& nms_attrs = nms->get_attrs(); const auto nms_top_k = nms_attrs.nms_top_k; @@ -77,23 +71,23 @@ InfoForNMS get_info_for_nms_eval(const std::shared_ptrget_shape(); - result.scores_shape = inputs[scores_port]->get_shape(); + result.boxes_shape = inputs[boxes_port].get_shape(); + result.scores_shape = inputs[scores_port].get_shape(); result.boxes_data = prepare_boxes_data(inputs[boxes_port], result.boxes_shape); result.scores_data = prepare_scores_data(inputs[scores_port], result.scores_shape); - result.selected_outputs_shape_size = ngraph::shape_size(result.selected_outputs_shape); - result.selected_indices_shape_size = ngraph::shape_size(result.selected_indices_shape); + result.selected_outputs_shape_size = ov::shape_size(result.selected_outputs_shape); + result.selected_indices_shape_size = ov::shape_size(result.selected_indices_shape); return result; } } // namespace matrix_nms_v8 -template -bool evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +template +bool evaluate(const std::shared_ptr& op, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { auto info = matrix_nms_v8::get_info_for_nms_eval(op, inputs); std::vector selected_outputs(info.selected_outputs_shape_size); @@ -116,15 +110,15 @@ bool evaluate(const std::shared_ptr& op, void* prois; size_t num_selected = static_cast(std::accumulate(valid_outputs.begin(), valid_outputs.end(), size_t(0))); - outputs[0]->set_shape({num_selected, 6}); - prois = outputs[0]->get_data_ptr(); + outputs[0].set_shape({num_selected, 6}); + prois = outputs[0].data(); if (outputs.size() >= 2) { - outputs[1]->set_shape({num_selected, 1}); - pscores = outputs[1]->get_data_ptr(); + outputs[1].set_shape({num_selected, 1}); + pscores = outputs[1].data(); } if (outputs.size() >= 3) { - pselected_num = outputs[2]->get_data_ptr(); + pselected_num = outputs[2].data(); } ov::reference::nms_common::nms_common_postprocessing(prois, @@ -139,70 +133,47 @@ bool evaluate(const std::shared_ptr& op, } template <> -bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { auto element_type = node->get_output_element_type(0); - if (ov::is_type(node) || ov::is_type(node)) + if (ov::is_type(node) || ov::is_type(node)) element_type = node->get_input_element_type(1); switch (element_type) { - case ngraph::element::Type_t::boolean: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::bf16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i4: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i8: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u1: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u4: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u8: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); + case ov::element::boolean: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::bf16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u1: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); default: - OPENVINO_THROW(std::string("Unhandled data type ") + node->get_element_type().get_type_name() + - std::string("in evaluate_node()")); + OPENVINO_THROW("Unhandled data type ", node->get_element_type().get_type_name(), " in evaluate_node()"); } } diff --git a/src/plugins/template/backend/ops/mod.cpp b/src/plugins/template/backend/ops/mod.cpp index a8e4ac1cbc44f7..b1668981a5b46b 100644 --- a/src/plugins/template/backend/ops/mod.cpp +++ b/src/plugins/template/backend/ops/mod.cpp @@ -6,63 +6,60 @@ #include "evaluate_node.hpp" -template -bool evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { - using T = typename ngraph::element_type_traits::value_type; - ov::reference::mod(inputs[0]->get_data_ptr(), - inputs[1]->get_data_ptr(), - outputs[0]->get_data_ptr(), - inputs[0]->get_shape(), - inputs[1]->get_shape(), +template +bool evaluate(const std::shared_ptr& op, ov::TensorVector& outputs, const ov::TensorVector& inputs) { + using T = typename ov::element_type_traits::value_type; + ov::reference::mod(inputs[0].data(), + inputs[1].data(), + outputs[0].data(), + inputs[0].get_shape(), + inputs[1].get_shape(), op->get_autob()); return true; } template <> -bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { auto element_type = node->get_output_element_type(0); - if (ov::is_type(node) || ov::is_type(node)) + if (ov::is_type(node) || ov::is_type(node)) element_type = node->get_input_element_type(1); switch (element_type) { - case ngraph::element::Type_t::boolean: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::bf16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i4: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i8: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u1: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u4: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u8: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::boolean: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::bf16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u1: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); default: - OPENVINO_THROW(std::string("Unhandled data type ") + node->get_element_type().get_type_name() + - std::string("in evaluate_node()")); + OPENVINO_THROW("Unhandled data type ", node->get_element_type().get_type_name(), " in evaluate_node()"); } } diff --git a/src/plugins/template/backend/ops/multiclass_nms.cpp b/src/plugins/template/backend/ops/multiclass_nms.cpp index e4a3e7f1d5a71c..51d1d6e4cab2ff 100644 --- a/src/plugins/template/backend/ops/multiclass_nms.cpp +++ b/src/plugins/template/backend/ops/multiclass_nms.cpp @@ -8,6 +8,7 @@ #include "evaluates_map.hpp" #include "multiclass_nms_shape_inference.hpp" #include "openvino/reference/utils/nms_common.hpp" +#include "openvino/runtime/tensor.hpp" namespace multiclass_nms { using namespace ov; @@ -27,18 +28,17 @@ struct InfoForNMS { size_t selected_numrois_shape_size; }; -static std::vector prepare_boxes_data(const std::shared_ptr& boxes, const Shape& boxes_shape) { +static std::vector prepare_boxes_data(const ov::Tensor& boxes, const Shape& boxes_shape) { auto result = get_floats(boxes, boxes_shape); return result; } -static std::vector prepare_scores_data(const std::shared_ptr& scores, const Shape& scores_shape) { +static std::vector prepare_scores_data(const ov::Tensor& scores, const Shape& scores_shape) { auto result = get_floats(scores, scores_shape); return result; } -static std::vector prepare_roisnum_data(const std::shared_ptr& roisnum, - const Shape& roisnum_shape) { +static std::vector prepare_roisnum_data(const ov::Tensor& roisnum, const Shape& roisnum_shape) { auto result = get_integers(roisnum, roisnum_shape); return result; } @@ -48,14 +48,14 @@ constexpr size_t scores_port = 1; constexpr size_t roisnum_port = 2; InfoForNMS get_info_for_nms_eval(const std::shared_ptr& nms, - const std::vector>& inputs) { + const ov::TensorVector& inputs) { InfoForNMS result; - const auto boxes_ps = inputs[boxes_port]->get_partial_shape(); - const auto scores_ps = inputs[scores_port]->get_partial_shape(); + const auto boxes_ps = inputs[boxes_port].get_shape(); + const auto scores_ps = inputs[scores_port].get_shape(); std::vector input_shapes = {boxes_ps, scores_ps}; if (nms->get_input_size() == 3) { - const auto roisnum_ps = inputs[roisnum_port]->get_partial_shape(); + const auto roisnum_ps = inputs[roisnum_port].get_shape(); input_shapes.push_back(roisnum_ps); } @@ -65,14 +65,14 @@ InfoForNMS get_info_for_nms_eval(const std::shared_ptrget_shape(); - result.scores_shape = inputs[scores_port]->get_shape(); + result.boxes_shape = inputs[boxes_port].get_shape(); + result.scores_shape = inputs[scores_port].get_shape(); result.boxes_data = prepare_boxes_data(inputs[boxes_port], result.boxes_shape); result.scores_data = prepare_scores_data(inputs[scores_port], result.scores_shape); if (inputs.size() == 3) { - result.roisnum_shape = inputs[roisnum_port]->get_shape(); + result.roisnum_shape = inputs[roisnum_port].get_shape(); result.roisnum_data = prepare_roisnum_data(inputs[roisnum_port], result.roisnum_shape); } @@ -84,10 +84,10 @@ InfoForNMS get_info_for_nms_eval(const std::shared_ptr -bool evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +template +bool evaluate(const std::shared_ptr& op, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { auto info = multiclass_nms::get_info_for_nms_eval(op, inputs); std::vector selected_outputs(info.selected_outputs_shape_size); @@ -99,7 +99,7 @@ bool evaluate(const std::shared_ptr& op, info.scores_data.data(), info.scores_shape, nullptr, - ngraph::Shape(), // won't be used + ov::Shape(), // won't be used op->get_attrs(), selected_outputs.data(), info.selected_outputs_shape, @@ -112,15 +112,15 @@ bool evaluate(const std::shared_ptr& op, void* prois; size_t num_selected = static_cast(std::accumulate(valid_outputs.begin(), valid_outputs.end(), int64_t(0))); - outputs[0]->set_shape({num_selected, 6}); - prois = outputs[0]->get_data_ptr(); + outputs[0].set_shape({num_selected, 6}); + prois = outputs[0].data(); if (outputs.size() >= 2) { - outputs[1]->set_shape({num_selected, 1}); - pscores = outputs[1]->get_data_ptr(); + outputs[1].set_shape({num_selected, 1}); + pscores = outputs[1].data(); } if (outputs.size() >= 3) { - pselected_num = outputs[2]->get_data_ptr(); + pselected_num = outputs[2].data(); } ov::reference::nms_common::nms_common_postprocessing(prois, @@ -135,10 +135,10 @@ bool evaluate(const std::shared_ptr& op, return true; } -template -bool evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +template +bool evaluate(const std::shared_ptr& op, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { auto info = multiclass_nms::get_info_for_nms_eval(op, inputs); std::vector selected_outputs(info.selected_outputs_shape_size); @@ -163,15 +163,15 @@ bool evaluate(const std::shared_ptr& op, void* prois; size_t num_selected = static_cast(std::accumulate(valid_outputs.begin(), valid_outputs.end(), 0)); - outputs[0]->set_shape({num_selected, 6}); - prois = outputs[0]->get_data_ptr(); + outputs[0].set_shape({num_selected, 6}); + prois = outputs[0].data(); if (outputs.size() >= 2) { - outputs[1]->set_shape({num_selected, 1}); - pscores = outputs[1]->get_data_ptr(); + outputs[1].set_shape({num_selected, 1}); + pscores = outputs[1].data(); } if (outputs.size() >= 3) { - pselected_num = outputs[2]->get_data_ptr(); + pselected_num = outputs[2].data(); } ov::reference::nms_common::nms_common_postprocessing(prois, @@ -187,78 +187,46 @@ bool evaluate(const std::shared_ptr& op, } template <> -bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { auto element_type = node->get_output_element_type(0); - if (ov::is_type(node) || ov::is_type(node)) + if (ov::is_type(node) || ov::is_type(node)) element_type = node->get_input_element_type(1); switch (element_type) { - case ngraph::element::Type_t::boolean: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::bf16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i4: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i8: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u1: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u4: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u8: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); + case ov::element::boolean: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::bf16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u1: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); default: OPENVINO_THROW(std::string("Unhandled data type ") + node->get_element_type().get_type_name() + std::string("in evaluate_node()")); @@ -266,80 +234,47 @@ bool evaluate_node(std::shared_ptr } template <> -bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { auto element_type = node->get_output_element_type(0); - if (ov::is_type(node) || ov::is_type(node)) + if (ov::is_type(node) || ov::is_type(node)) element_type = node->get_input_element_type(1); switch (element_type) { - case ngraph::element::Type_t::boolean: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::bf16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i4: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i8: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u1: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u4: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u8: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); + case ov::element::boolean: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::bf16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u1: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); default: - OPENVINO_THROW(std::string("Unhandled data type ") + node->get_element_type().get_type_name() + - std::string("in evaluate_node()")); + OPENVINO_THROW("Unhandled data type ", node->get_element_type().get_type_name(), " in evaluate_node()"); } } diff --git a/src/plugins/template/backend/ops/mvn.cpp b/src/plugins/template/backend/ops/mvn.cpp index 325016eef883ff..efd745ca25ee35 100644 --- a/src/plugins/template/backend/ops/mvn.cpp +++ b/src/plugins/template/backend/ops/mvn.cpp @@ -6,14 +6,12 @@ #include "evaluate_node.hpp" -template -bool evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { - using T = typename ngraph::element_type_traits::value_type; - ov::reference::mvn(inputs[0]->get_data_ptr(), - outputs[0]->get_data_ptr(), - inputs[0]->get_shape(), +template +bool evaluate(const std::shared_ptr& op, ov::TensorVector& outputs, const ov::TensorVector& inputs) { + using T = typename ov::element_type_traits::value_type; + ov::reference::mvn(inputs[0].data(), + outputs[0].data(), + inputs[0].get_shape(), op->get_normalize_variance(), op->get_reduction_axes(), op->get_eps()); @@ -22,9 +20,9 @@ bool evaluate(const std::shared_ptr& op, namespace mvn_6_axes { template -ngraph::AxisSet mvn_6_reduction_axes(const ngraph::HostTensorPtr& axes_input, size_t rank) { - T* a = axes_input->get_data_ptr(); - auto v = std::vector(a, a + axes_input->get_shape()[0]); +ov::AxisSet mvn_6_reduction_axes(const ov::Tensor& axes_input, size_t rank) { + T* a = axes_input.data(); + auto v = std::vector(a, a + axes_input.get_shape()[0]); std::vector axes(v.size(), 0); for (size_t i = 0; i < v.size(); i++) { if (v[i] < 0) { @@ -36,27 +34,25 @@ ngraph::AxisSet mvn_6_reduction_axes(const ngraph::HostTensorPtr& axes_input, si axes[i] = (size_t)(v[i]); } } - return ngraph::AxisSet(axes); + return ov::AxisSet(axes); } } // namespace mvn_6_axes -template -bool evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { - using T = typename ngraph::element_type_traits::value_type; - ngraph::AxisSet reduction_axes; - auto rank = inputs[0]->get_shape().size(); - if (inputs[1]->get_element_type() == ngraph::element::i64) { +template +bool evaluate(const std::shared_ptr& op, ov::TensorVector& outputs, const ov::TensorVector& inputs) { + using T = typename ov::element_type_traits::value_type; + ov::AxisSet reduction_axes; + auto rank = inputs[0].get_shape().size(); + if (inputs[1].get_element_type() == ov::element::i64) { reduction_axes = mvn_6_axes::mvn_6_reduction_axes(inputs[1], rank); - } else if (inputs[1]->get_element_type() == ngraph::element::i32) { + } else if (inputs[1].get_element_type() == ov::element::i32) { reduction_axes = mvn_6_axes::mvn_6_reduction_axes(inputs[1], rank); } else { OPENVINO_THROW("Unexpected indices type"); } - ov::reference::mvn_6(inputs[0]->get_data_ptr(), - outputs[0]->get_data_ptr(), - inputs[0]->get_shape(), + ov::reference::mvn_6(inputs[0].data(), + outputs[0].data(), + inputs[0].get_shape(), reduction_axes, op->get_normalize_variance(), op->get_eps(), @@ -65,95 +61,93 @@ bool evaluate(const std::shared_ptr& op, } template <> -bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { auto element_type = node->get_output_element_type(0); - if (ov::is_type(node) || ov::is_type(node)) + if (ov::is_type(node) || ov::is_type(node)) element_type = node->get_input_element_type(1); switch (element_type) { - case ngraph::element::Type_t::boolean: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::bf16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i4: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i8: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u1: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u4: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u8: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::boolean: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::bf16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u1: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); default: - OPENVINO_THROW(std::string("Unhandled data type ") + node->get_element_type().get_type_name() + - std::string("in evaluate_node()")); + OPENVINO_THROW("Unhandled data type ", node->get_element_type().get_type_name(), " in evaluate_node()"); } } template <> -bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { auto element_type = node->get_output_element_type(0); - if (ov::is_type(node) || ov::is_type(node)) + if (ov::is_type(node) || ov::is_type(node)) element_type = node->get_input_element_type(1); switch (element_type) { - case ngraph::element::Type_t::boolean: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::bf16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i4: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i8: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u1: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u4: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u8: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::boolean: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::bf16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u1: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); default: - OPENVINO_THROW(std::string("Unhandled data type ") + node->get_element_type().get_type_name() + - std::string("in evaluate_node()")); + OPENVINO_THROW("Unhandled data type ", node->get_element_type().get_type_name(), " in evaluate_node()"); } } diff --git a/src/plugins/template/backend/ops/non_max_suppression.cpp b/src/plugins/template/backend/ops/non_max_suppression.cpp index e99f6d6c85ad88..c62b7a8187c148 100644 --- a/src/plugins/template/backend/ops/non_max_suppression.cpp +++ b/src/plugins/template/backend/ops/non_max_suppression.cpp @@ -2,56 +2,53 @@ // SPDX-License-Identifier: Apache-2.0 // -// clang-format off -#include "evaluates_map.hpp" -#include "evaluate_node.hpp" #include "openvino/reference/non_max_suppression.hpp" -// clang-format on + +#include "evaluate_node.hpp" +#include "evaluates_map.hpp" +#include "openvino/runtime/tensor.hpp" namespace nms_v9 { -using V9BoxEncoding = ngraph::op::v9::NonMaxSuppression::BoxEncodingType; +using V9BoxEncoding = ov::op::v9::NonMaxSuppression::BoxEncodingType; struct InfoForNMS9 { int64_t max_output_boxes_per_class; float iou_threshold; float score_threshold; float soft_nms_sigma; - ngraph::Shape out_shape; - ngraph::Shape boxes_shape; - ngraph::Shape scores_shape; + ov::Shape out_shape; + ov::Shape boxes_shape; + ov::Shape scores_shape; std::vector boxes_data; std::vector scores_data; size_t out_shape_size; bool sort_result_descending; - ngraph::element::Type output_type; + ov::element::Type output_type; }; constexpr size_t boxes_port = 0; constexpr size_t scores_port = 1; -ngraph::PartialShape infer_selected_indices_shape(const std::vector>& inputs, - int64_t max_output_boxes_per_class) { - const auto boxes_ps = inputs[boxes_port]->get_partial_shape(); - const auto scores_ps = inputs[scores_port]->get_partial_shape(); +ov::PartialShape infer_selected_indices_shape(const ov::TensorVector& inputs, size_t max_output_boxes_per_class) { + const auto boxes_ps = inputs[boxes_port].get_shape(); + const auto scores_ps = inputs[scores_port].get_shape(); // NonMaxSuppression produces triplets // that have the following format: [batch_index, class_index, box_index] - ngraph::PartialShape result = {ngraph::Dimension::dynamic(), 3}; + ov::PartialShape result = {ov::Dimension::dynamic(), 3}; - if (boxes_ps.rank().is_static() && scores_ps.rank().is_static()) { + if (ov::shape_size(boxes_ps) && ov::shape_size(scores_ps)) { const auto num_boxes_boxes = boxes_ps[1]; - if (num_boxes_boxes.is_static() && scores_ps[0].is_static() && scores_ps[1].is_static()) { - const auto num_boxes = num_boxes_boxes.get_length(); - const auto num_classes = scores_ps[1].get_length(); + const auto num_boxes = num_boxes_boxes; + const auto num_classes = scores_ps[1]; - result[0] = std::min(num_boxes, max_output_boxes_per_class) * num_classes * scores_ps[0].get_length(); - } + result[0] = std::min(num_boxes, max_output_boxes_per_class) * num_classes * scores_ps[0]; } return result; } -void normalize_corner(float* boxes, const ngraph::Shape& boxes_shape) { - size_t total_num_of_boxes = ngraph::shape_size(boxes_shape) / 4; +void normalize_corner(float* boxes, const ov::Shape& boxes_shape) { + size_t total_num_of_boxes = ov::shape_size(boxes_shape) / 4; for (size_t i = 0; i < total_num_of_boxes; ++i) { float* current_box = boxes + 4 * i; @@ -72,8 +69,8 @@ void normalize_corner(float* boxes, const ngraph::Shape& boxes_shape) { } } -void normalize_center(float* boxes, const ngraph::Shape& boxes_shape) { - size_t total_num_of_boxes = ngraph::shape_size(boxes_shape) / 4; +void normalize_center(float* boxes, const ov::Shape& boxes_shape) { + size_t total_num_of_boxes = ov::shape_size(boxes_shape) / 4; for (size_t i = 0; i < total_num_of_boxes; ++i) { float* current_box = boxes + 4 * i; @@ -94,7 +91,7 @@ void normalize_center(float* boxes, const ngraph::Shape& boxes_shape) { } } -void normalize_box_encoding(float* boxes, const ngraph::Shape& boxes_shape, const V9BoxEncoding box_encoding) { +void normalize_box_encoding(float* boxes, const ov::Shape& boxes_shape, const V9BoxEncoding box_encoding) { if (box_encoding == V9BoxEncoding::CORNER) { normalize_corner(boxes, boxes_shape); } else { @@ -102,39 +99,38 @@ void normalize_box_encoding(float* boxes, const ngraph::Shape& boxes_shape, cons } } -std::vector prepare_boxes_data(const std::shared_ptr& boxes, - const ngraph::Shape& boxes_shape, +std::vector prepare_boxes_data(const ov::Tensor& boxes, + const ov::Shape& boxes_shape, const V9BoxEncoding box_encoding) { auto result = get_floats(boxes, boxes_shape); normalize_box_encoding(result.data(), boxes_shape, box_encoding); return result; } -std::vector prepare_scores_data(const std::shared_ptr& scores, - const ngraph::Shape& scores_shape) { +std::vector prepare_scores_data(const ov::Tensor& scores, const ov::Shape& scores_shape) { auto result = get_floats(scores, scores_shape); return result; } -InfoForNMS9 get_info_for_nms9_eval(const std::shared_ptr& nms9, - const std::vector>& inputs) { +InfoForNMS9 get_info_for_nms9_eval(const std::shared_ptr& nms9, + const ov::TensorVector& inputs) { InfoForNMS9 result; - result.max_output_boxes_per_class = inputs.size() > 2 ? get_integers(inputs[2], ngraph::Shape({}))[0] : 0; - result.iou_threshold = inputs.size() > 3 ? get_floats(inputs[3], ngraph::Shape({}))[0] : 0.0f; - result.score_threshold = inputs.size() > 4 ? get_floats(inputs[4], ngraph::Shape({}))[0] : 0.0f; - result.soft_nms_sigma = inputs.size() > 5 ? get_floats(inputs[5], ngraph::Shape({}))[0] : 0.0f; + result.max_output_boxes_per_class = inputs.size() > 2 ? get_integers(inputs[2], ov::Shape({}))[0] : 0; + result.iou_threshold = inputs.size() > 3 ? get_floats(inputs[3], ov::Shape({}))[0] : 0.0f; + result.score_threshold = inputs.size() > 4 ? get_floats(inputs[4], ov::Shape({}))[0] : 0.0f; + result.soft_nms_sigma = inputs.size() > 5 ? get_floats(inputs[5], ov::Shape({}))[0] : 0.0f; auto selected_indices_shape = infer_selected_indices_shape(inputs, result.max_output_boxes_per_class); result.out_shape = selected_indices_shape.to_shape(); - result.boxes_shape = inputs[boxes_port]->get_shape(); - result.scores_shape = inputs[scores_port]->get_shape(); + result.boxes_shape = inputs[boxes_port].get_shape(); + result.scores_shape = inputs[scores_port].get_shape(); result.boxes_data = prepare_boxes_data(inputs[boxes_port], result.boxes_shape, nms9->get_box_encoding()); result.scores_data = prepare_scores_data(inputs[scores_port], result.scores_shape); - result.out_shape_size = ngraph::shape_size(result.out_shape); + result.out_shape_size = ov::shape_size(result.out_shape); result.sort_result_descending = nms9->get_sort_result_descending(); @@ -144,10 +140,10 @@ InfoForNMS9 get_info_for_nms9_eval(const std::shared_ptr -bool evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +template +bool evaluate(const std::shared_ptr& op, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { auto info = nms_v9::get_info_for_nms9_eval(op, inputs); std::vector selected_indices(info.out_shape_size); @@ -169,7 +165,7 @@ bool evaluate(const std::shared_ptr& op, &valid_outputs, info.sort_result_descending); - auto selected_scores_type = (outputs.size() < 3) ? ngraph::element::f32 : outputs[1]->get_element_type(); + auto selected_scores_type = (outputs.size() < 3) ? ov::element::f32 : outputs[1].get_element_type(); ov::reference::nms_postprocessing(outputs, info.output_type, @@ -181,49 +177,46 @@ bool evaluate(const std::shared_ptr& op, } namespace nms_v4 { -using V4BoxEncoding = ngraph::op::v4::NonMaxSuppression::BoxEncodingType; +using V4BoxEncoding = ov::op::v4::NonMaxSuppression::BoxEncodingType; struct InfoForNMS4 { int64_t max_output_boxes_per_class; float iou_threshold; float score_threshold; float soft_nms_sigma; - ngraph::Shape out_shape; - ngraph::Shape boxes_shape; - ngraph::Shape scores_shape; + ov::Shape out_shape; + ov::Shape boxes_shape; + ov::Shape scores_shape; std::vector boxes_data; std::vector scores_data; size_t out_shape_size; bool sort_result_descending; - ngraph::element::Type output_type; + ov::element::Type output_type; }; constexpr size_t boxes_port = 0; constexpr size_t scores_port = 1; -ngraph::PartialShape infer_selected_indices_shape(const std::vector>& inputs, - int64_t max_output_boxes_per_class) { - const auto boxes_ps = inputs[boxes_port]->get_partial_shape(); - const auto scores_ps = inputs[scores_port]->get_partial_shape(); +ov::PartialShape infer_selected_indices_shape(const ov::TensorVector& inputs, size_t max_output_boxes_per_class) { + const auto boxes_ps = inputs[boxes_port].get_shape(); + const auto scores_ps = inputs[scores_port].get_shape(); // NonMaxSuppression produces triplets // that have the following format: [batch_index, class_index, box_index] - ngraph::PartialShape result = {ngraph::Dimension::dynamic(), 3}; + ov::PartialShape result = {ov::Dimension::dynamic(), 3}; - if (boxes_ps.rank().is_static() && scores_ps.rank().is_static()) { + if (ov::shape_size(boxes_ps) && ov::shape_size(scores_ps)) { const auto num_boxes_boxes = boxes_ps[1]; - if (num_boxes_boxes.is_static() && scores_ps[0].is_static() && scores_ps[1].is_static()) { - const auto num_boxes = num_boxes_boxes.get_length(); - const auto num_classes = scores_ps[1].get_length(); + const auto num_boxes = num_boxes_boxes; + const auto num_classes = scores_ps[1]; - result[0] = std::min(num_boxes, max_output_boxes_per_class) * num_classes * scores_ps[0].get_length(); - } + result[0] = std::min(num_boxes, max_output_boxes_per_class) * num_classes * scores_ps[0]; } return result; } -void normalize_corner(float* boxes, const ngraph::Shape& boxes_shape) { - size_t total_num_of_boxes = ngraph::shape_size(boxes_shape) / 4; +void normalize_corner(float* boxes, const ov::Shape& boxes_shape) { + size_t total_num_of_boxes = ov::shape_size(boxes_shape) / 4; for (size_t i = 0; i < total_num_of_boxes; ++i) { float* current_box = boxes + 4 * i; @@ -244,8 +237,8 @@ void normalize_corner(float* boxes, const ngraph::Shape& boxes_shape) { } } -void normalize_center(float* boxes, const ngraph::Shape& boxes_shape) { - size_t total_num_of_boxes = ngraph::shape_size(boxes_shape) / 4; +void normalize_center(float* boxes, const ov::Shape& boxes_shape) { + size_t total_num_of_boxes = ov::shape_size(boxes_shape) / 4; for (size_t i = 0; i < total_num_of_boxes; ++i) { float* current_box = boxes + 4 * i; @@ -266,7 +259,7 @@ void normalize_center(float* boxes, const ngraph::Shape& boxes_shape) { } } -void normalize_box_encoding(float* boxes, const ngraph::Shape& boxes_shape, const V4BoxEncoding box_encoding) { +void normalize_box_encoding(float* boxes, const ov::Shape& boxes_shape, const V4BoxEncoding box_encoding) { if (box_encoding == V4BoxEncoding::CORNER) { normalize_corner(boxes, boxes_shape); } else { @@ -274,39 +267,38 @@ void normalize_box_encoding(float* boxes, const ngraph::Shape& boxes_shape, cons } } -std::vector prepare_boxes_data(const std::shared_ptr& boxes, - const ngraph::Shape& boxes_shape, +std::vector prepare_boxes_data(const ov::Tensor& boxes, + const ov::Shape& boxes_shape, const V4BoxEncoding box_encoding) { auto result = get_floats(boxes, boxes_shape); normalize_box_encoding(result.data(), boxes_shape, box_encoding); return result; } -std::vector prepare_scores_data(const std::shared_ptr& scores, - const ngraph::Shape& scores_shape) { +std::vector prepare_scores_data(const ov::Tensor& scores, const ov::Shape& scores_shape) { auto result = get_floats(scores, scores_shape); return result; } -InfoForNMS4 get_info_for_nms4_eval(const std::shared_ptr& nms4, - const std::vector>& inputs) { +InfoForNMS4 get_info_for_nms4_eval(const std::shared_ptr& nms4, + const ov::TensorVector& inputs) { InfoForNMS4 result; - result.max_output_boxes_per_class = inputs.size() > 2 ? get_integers(inputs[2], ngraph::Shape({}))[0] : 0; - result.iou_threshold = inputs.size() > 3 ? get_floats(inputs[3], ngraph::Shape({}))[0] : 0.0f; - result.score_threshold = inputs.size() > 4 ? get_floats(inputs[4], ngraph::Shape({}))[0] : 0.0f; - result.soft_nms_sigma = inputs.size() > 5 ? get_floats(inputs[5], ngraph::Shape({}))[0] : 0.0f; + result.max_output_boxes_per_class = inputs.size() > 2 ? get_integers(inputs[2], ov::Shape({}))[0] : 0; + result.iou_threshold = inputs.size() > 3 ? get_floats(inputs[3], ov::Shape({}))[0] : 0.0f; + result.score_threshold = inputs.size() > 4 ? get_floats(inputs[4], ov::Shape({}))[0] : 0.0f; + result.soft_nms_sigma = inputs.size() > 5 ? get_floats(inputs[5], ov::Shape({}))[0] : 0.0f; auto selected_indices_shape = infer_selected_indices_shape(inputs, result.max_output_boxes_per_class); result.out_shape = selected_indices_shape.to_shape(); - result.boxes_shape = inputs[boxes_port]->get_shape(); - result.scores_shape = inputs[scores_port]->get_shape(); + result.boxes_shape = inputs[boxes_port].get_shape(); + result.scores_shape = inputs[scores_port].get_shape(); result.boxes_data = prepare_boxes_data(inputs[boxes_port], result.boxes_shape, nms4->get_box_encoding()); result.scores_data = prepare_scores_data(inputs[scores_port], result.scores_shape); - result.out_shape_size = ngraph::shape_size(result.out_shape); + result.out_shape_size = ov::shape_size(result.out_shape); result.sort_result_descending = nms4->get_sort_result_descending(); @@ -316,10 +308,10 @@ InfoForNMS4 get_info_for_nms4_eval(const std::shared_ptr -bool evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +template +bool evaluate(const std::shared_ptr& op, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { auto info = nms_v4::get_info_for_nms4_eval(op, inputs); std::vector selected_indices(info.out_shape_size); @@ -341,7 +333,7 @@ bool evaluate(const std::shared_ptr& op, &valid_outputs, info.sort_result_descending); - auto selected_scores_type = (inputs.size() < 4) ? ngraph::element::f32 : inputs[3]->get_element_type(); + auto selected_scores_type = (inputs.size() < 4) ? ov::element::f32 : inputs[3].get_element_type(); ov::reference::nms_postprocessing(outputs, info.output_type, @@ -353,49 +345,46 @@ bool evaluate(const std::shared_ptr& op, } namespace nms_v3 { -using V3BoxEncoding = ngraph::op::v3::NonMaxSuppression::BoxEncodingType; +using V3BoxEncoding = ov::op::v3::NonMaxSuppression::BoxEncodingType; struct InfoForNMS3 { int64_t max_output_boxes_per_class; float iou_threshold; float score_threshold; float soft_nms_sigma; - ngraph::Shape out_shape; - ngraph::Shape boxes_shape; - ngraph::Shape scores_shape; + ov::Shape out_shape; + ov::Shape boxes_shape; + ov::Shape scores_shape; std::vector boxes_data; std::vector scores_data; size_t out_shape_size; bool sort_result_descending; - ngraph::element::Type output_type; + ov::element::Type output_type; }; constexpr size_t boxes_port = 0; constexpr size_t scores_port = 1; -ngraph::PartialShape infer_selected_indices_shape(const std::vector>& inputs, - int64_t max_output_boxes_per_class) { - const auto boxes_ps = inputs[boxes_port]->get_partial_shape(); - const auto scores_ps = inputs[scores_port]->get_partial_shape(); +ov::PartialShape infer_selected_indices_shape(const ov::TensorVector& inputs, size_t max_output_boxes_per_class) { + const auto boxes_ps = inputs[boxes_port].get_shape(); + const auto scores_ps = inputs[scores_port].get_shape(); // NonMaxSuppression produces triplets // that have the following format: [batch_index, class_index, box_index] - ngraph::PartialShape result = {ngraph::Dimension::dynamic(), 3}; + ov::PartialShape result = {ov::Dimension::dynamic(), 3}; - if (boxes_ps.rank().is_static() && scores_ps.rank().is_static()) { + if (ov::shape_size(boxes_ps) && ov::shape_size(scores_ps)) { const auto num_boxes_boxes = boxes_ps[1]; - if (num_boxes_boxes.is_static() && scores_ps[0].is_static() && scores_ps[1].is_static()) { - const auto num_boxes = num_boxes_boxes.get_length(); - const auto num_classes = scores_ps[1].get_length(); + const auto num_boxes = num_boxes_boxes; + const auto num_classes = scores_ps[1]; - result[0] = std::min(num_boxes, max_output_boxes_per_class * num_classes); - } + result[0] = std::min(num_boxes, max_output_boxes_per_class * num_classes); } return result; } -void normalize_corner(float* boxes, const ngraph::Shape& boxes_shape) { - size_t total_num_of_boxes = ngraph::shape_size(boxes_shape) / 4; +void normalize_corner(float* boxes, const ov::Shape& boxes_shape) { + size_t total_num_of_boxes = ov::shape_size(boxes_shape) / 4; for (size_t i = 0; i < total_num_of_boxes; ++i) { float* current_box = boxes + 4 * i; @@ -416,8 +405,8 @@ void normalize_corner(float* boxes, const ngraph::Shape& boxes_shape) { } } -void normalize_center(float* boxes, const ngraph::Shape& boxes_shape) { - size_t total_num_of_boxes = ngraph::shape_size(boxes_shape) / 4; +void normalize_center(float* boxes, const ov::Shape& boxes_shape) { + size_t total_num_of_boxes = ov::shape_size(boxes_shape) / 4; for (size_t i = 0; i < total_num_of_boxes; ++i) { float* current_box = boxes + 4 * i; @@ -438,7 +427,7 @@ void normalize_center(float* boxes, const ngraph::Shape& boxes_shape) { } } -void normalize_box_encoding(float* boxes, const ngraph::Shape& boxes_shape, const V3BoxEncoding box_encoding) { +void normalize_box_encoding(float* boxes, const ov::Shape& boxes_shape, const V3BoxEncoding box_encoding) { if (box_encoding == V3BoxEncoding::CORNER) { normalize_corner(boxes, boxes_shape); } else { @@ -446,39 +435,38 @@ void normalize_box_encoding(float* boxes, const ngraph::Shape& boxes_shape, cons } } -std::vector prepare_boxes_data(const std::shared_ptr& boxes, - const ngraph::Shape& boxes_shape, +std::vector prepare_boxes_data(const ov::Tensor& boxes, + const ov::Shape& boxes_shape, const V3BoxEncoding box_encoding) { auto result = get_floats(boxes, boxes_shape); normalize_box_encoding(result.data(), boxes_shape, box_encoding); return result; } -std::vector prepare_scores_data(const std::shared_ptr& scores, - const ngraph::Shape& scores_shape) { +std::vector prepare_scores_data(const ov::Tensor& scores, const ov::Shape& scores_shape) { auto result = get_floats(scores, scores_shape); return result; } -InfoForNMS3 get_info_for_nms3_eval(const std::shared_ptr& nms3, - const std::vector>& inputs) { +InfoForNMS3 get_info_for_nms3_eval(const std::shared_ptr& nms3, + const ov::TensorVector& inputs) { InfoForNMS3 result; - result.max_output_boxes_per_class = inputs.size() > 2 ? get_integers(inputs[2], ngraph::Shape({}))[0] : 0; - result.iou_threshold = inputs.size() > 3 ? get_floats(inputs[3], ngraph::Shape({}))[0] : 0.0f; - result.score_threshold = inputs.size() > 4 ? get_floats(inputs[4], ngraph::Shape({}))[0] : 0.0f; - result.soft_nms_sigma = inputs.size() > 5 ? get_floats(inputs[5], ngraph::Shape({}))[0] : 0.0f; + result.max_output_boxes_per_class = inputs.size() > 2 ? get_integers(inputs[2], ov::Shape({}))[0] : 0; + result.iou_threshold = inputs.size() > 3 ? get_floats(inputs[3], ov::Shape({}))[0] : 0.0f; + result.score_threshold = inputs.size() > 4 ? get_floats(inputs[4], ov::Shape({}))[0] : 0.0f; + result.soft_nms_sigma = inputs.size() > 5 ? get_floats(inputs[5], ov::Shape({}))[0] : 0.0f; auto selected_indices_shape = infer_selected_indices_shape(inputs, result.max_output_boxes_per_class); result.out_shape = selected_indices_shape.to_shape(); - result.boxes_shape = inputs[boxes_port]->get_shape(); - result.scores_shape = inputs[scores_port]->get_shape(); + result.boxes_shape = inputs[boxes_port].get_shape(); + result.scores_shape = inputs[scores_port].get_shape(); result.boxes_data = prepare_boxes_data(inputs[boxes_port], result.boxes_shape, nms3->get_box_encoding()); result.scores_data = prepare_scores_data(inputs[scores_port], result.scores_shape); - result.out_shape_size = ngraph::shape_size(result.out_shape); + result.out_shape_size = ov::shape_size(result.out_shape); result.sort_result_descending = nms3->get_sort_result_descending(); @@ -488,10 +476,10 @@ InfoForNMS3 get_info_for_nms3_eval(const std::shared_ptr -bool evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +template +bool evaluate(const std::shared_ptr& op, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { auto info = nms_v3::get_info_for_nms3_eval(op, inputs); std::vector selected_indices(info.out_shape_size); @@ -513,7 +501,7 @@ bool evaluate(const std::shared_ptr& op, &valid_outputs, info.sort_result_descending); - auto selected_scores_type = (inputs.size() < 4) ? ngraph::element::f32 : inputs[3]->get_element_type(); + auto selected_scores_type = (inputs.size() < 4) ? ov::element::f32 : inputs[3].get_element_type(); ov::reference::nms_postprocessing(outputs, info.output_type, @@ -525,49 +513,46 @@ bool evaluate(const std::shared_ptr& op, } namespace nms_v1 { -using V1BoxEncoding = ngraph::op::v1::NonMaxSuppression::BoxEncodingType; +using V1BoxEncoding = ov::op::v1::NonMaxSuppression::BoxEncodingType; struct InfoForNMS1 { int64_t max_output_boxes_per_class; float iou_threshold; float score_threshold; float soft_nms_sigma; - ngraph::Shape out_shape; - ngraph::Shape boxes_shape; - ngraph::Shape scores_shape; + ov::Shape out_shape; + ov::Shape boxes_shape; + ov::Shape scores_shape; std::vector boxes_data; std::vector scores_data; size_t out_shape_size; bool sort_result_descending; - ngraph::element::Type output_type; + ov::element::Type output_type; }; constexpr size_t boxes_port = 0; constexpr size_t scores_port = 1; -ngraph::PartialShape infer_selected_indices_shape(const std::vector>& inputs, - int64_t max_output_boxes_per_class) { - const auto boxes_ps = inputs[boxes_port]->get_partial_shape(); - const auto scores_ps = inputs[scores_port]->get_partial_shape(); +ov::PartialShape infer_selected_indices_shape(const ov::TensorVector& inputs, size_t max_output_boxes_per_class) { + const auto boxes_ps = inputs[boxes_port].get_shape(); + const auto scores_ps = inputs[scores_port].get_shape(); // NonMaxSuppression produces triplets // that have the following format: [batch_index, class_index, box_index] - ngraph::PartialShape result = {ngraph::Dimension::dynamic(), 3}; + ov::PartialShape result = {ov::Dimension::dynamic(), 3}; - if (boxes_ps.rank().is_static() && scores_ps.rank().is_static()) { + if (ov::shape_size(boxes_ps) && ov::shape_size(scores_ps)) { const auto num_boxes_boxes = boxes_ps[1]; - if (num_boxes_boxes.is_static() && scores_ps[0].is_static() && scores_ps[1].is_static()) { - const auto num_boxes = num_boxes_boxes.get_length(); - const auto num_classes = scores_ps[1].get_length(); + const auto num_boxes = num_boxes_boxes; + const auto num_classes = scores_ps[1]; - result[0] = std::min(num_boxes, max_output_boxes_per_class * num_classes); - } + result[0] = std::min(num_boxes, max_output_boxes_per_class * num_classes); } return result; } -void normalize_corner(float* boxes, const ngraph::Shape& boxes_shape) { - size_t total_num_of_boxes = ngraph::shape_size(boxes_shape) / 4; +void normalize_corner(float* boxes, const ov::Shape& boxes_shape) { + size_t total_num_of_boxes = ov::shape_size(boxes_shape) / 4; for (size_t i = 0; i < total_num_of_boxes; ++i) { float* current_box = boxes + 4 * i; @@ -588,8 +573,8 @@ void normalize_corner(float* boxes, const ngraph::Shape& boxes_shape) { } } -void normalize_center(float* boxes, const ngraph::Shape& boxes_shape) { - size_t total_num_of_boxes = ngraph::shape_size(boxes_shape) / 4; +void normalize_center(float* boxes, const ov::Shape& boxes_shape) { + size_t total_num_of_boxes = ov::shape_size(boxes_shape) / 4; for (size_t i = 0; i < total_num_of_boxes; ++i) { float* current_box = boxes + 4 * i; @@ -610,7 +595,7 @@ void normalize_center(float* boxes, const ngraph::Shape& boxes_shape) { } } -void normalize_box_encoding(float* boxes, const ngraph::Shape& boxes_shape, const V1BoxEncoding box_encoding) { +void normalize_box_encoding(float* boxes, const ov::Shape& boxes_shape, const V1BoxEncoding box_encoding) { if (box_encoding == V1BoxEncoding::CORNER) { normalize_corner(boxes, boxes_shape); } else { @@ -618,39 +603,38 @@ void normalize_box_encoding(float* boxes, const ngraph::Shape& boxes_shape, cons } } -std::vector prepare_boxes_data(const std::shared_ptr& boxes, - const ngraph::Shape& boxes_shape, +std::vector prepare_boxes_data(const ov::Tensor& boxes, + const ov::Shape& boxes_shape, const V1BoxEncoding box_encoding) { auto result = get_floats(boxes, boxes_shape); normalize_box_encoding(result.data(), boxes_shape, box_encoding); return result; } -std::vector prepare_scores_data(const std::shared_ptr& scores, - const ngraph::Shape& scores_shape) { +std::vector prepare_scores_data(const ov::Tensor& scores, const ov::Shape& scores_shape) { auto result = get_floats(scores, scores_shape); return result; } -InfoForNMS1 get_info_for_nms1_eval(const std::shared_ptr& nms1, - const std::vector>& inputs) { +InfoForNMS1 get_info_for_nms1_eval(const std::shared_ptr& nms1, + const ov::TensorVector& inputs) { InfoForNMS1 result; - result.max_output_boxes_per_class = inputs.size() > 2 ? get_integers(inputs[2], ngraph::Shape({}))[0] : 0; - result.iou_threshold = inputs.size() > 3 ? get_floats(inputs[3], ngraph::Shape({}))[0] : 0.0f; - result.score_threshold = inputs.size() > 4 ? get_floats(inputs[4], ngraph::Shape({}))[0] : 0.0f; - result.soft_nms_sigma = inputs.size() > 5 ? get_floats(inputs[5], ngraph::Shape({}))[0] : 0.0f; + result.max_output_boxes_per_class = inputs.size() > 2 ? get_integers(inputs[2], ov::Shape({}))[0] : 0; + result.iou_threshold = inputs.size() > 3 ? get_floats(inputs[3], ov::Shape({}))[0] : 0.0f; + result.score_threshold = inputs.size() > 4 ? get_floats(inputs[4], ov::Shape({}))[0] : 0.0f; + result.soft_nms_sigma = inputs.size() > 5 ? get_floats(inputs[5], ov::Shape({}))[0] : 0.0f; auto selected_indices_shape = infer_selected_indices_shape(inputs, result.max_output_boxes_per_class); result.out_shape = selected_indices_shape.to_shape(); - result.boxes_shape = inputs[boxes_port]->get_shape(); - result.scores_shape = inputs[scores_port]->get_shape(); + result.boxes_shape = inputs[boxes_port].get_shape(); + result.scores_shape = inputs[scores_port].get_shape(); result.boxes_data = prepare_boxes_data(inputs[boxes_port], result.boxes_shape, nms1->get_box_encoding()); result.scores_data = prepare_scores_data(inputs[scores_port], result.scores_shape); - result.out_shape_size = ngraph::shape_size(result.out_shape); + result.out_shape_size = ov::shape_size(result.out_shape); result.sort_result_descending = nms1->get_sort_result_descending(); @@ -660,10 +644,10 @@ InfoForNMS1 get_info_for_nms1_eval(const std::shared_ptr -bool evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +template +bool evaluate(const std::shared_ptr& op, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { auto info = nms_v1::get_info_for_nms1_eval(op, inputs); std::vector selected_indices(info.out_shape_size); @@ -685,7 +669,7 @@ bool evaluate(const std::shared_ptr& op, &valid_outputs, info.sort_result_descending); - auto selected_scores_type = (inputs.size() < 4) ? ngraph::element::f32 : inputs[3]->get_element_type(); + auto selected_scores_type = (inputs.size() < 4) ? ov::element::f32 : inputs[3].get_element_type(); ov::reference::nms_postprocessing(outputs, info.output_type, @@ -697,49 +681,46 @@ bool evaluate(const std::shared_ptr& op, } namespace nms_v5 { -using V5BoxEncoding = ngraph::op::v5::NonMaxSuppression::BoxEncodingType; +using V5BoxEncoding = ov::op::v5::NonMaxSuppression::BoxEncodingType; struct InfoForNMS5 { int64_t max_output_boxes_per_class; float iou_threshold; float score_threshold; float soft_nms_sigma; - ngraph::Shape out_shape; - ngraph::Shape boxes_shape; - ngraph::Shape scores_shape; + ov::Shape out_shape; + ov::Shape boxes_shape; + ov::Shape scores_shape; std::vector boxes_data; std::vector scores_data; size_t out_shape_size; bool sort_result_descending; - ngraph::element::Type output_type; + ov::element::Type output_type; }; constexpr size_t boxes_port = 0; constexpr size_t scores_port = 1; -ngraph::PartialShape infer_selected_indices_shape(const std::vector>& inputs, - int64_t max_output_boxes_per_class) { - const auto boxes_ps = inputs[boxes_port]->get_partial_shape(); - const auto scores_ps = inputs[scores_port]->get_partial_shape(); +ov::PartialShape infer_selected_indices_shape(const ov::TensorVector& inputs, size_t max_output_boxes_per_class) { + const auto boxes_ps = inputs[boxes_port].get_shape(); + const auto scores_ps = inputs[scores_port].get_shape(); // NonMaxSuppression produces triplets // that have the following format: [batch_index, class_index, box_index] - ngraph::PartialShape result = {ngraph::Dimension::dynamic(), 3}; + ov::PartialShape result = {ov::Dimension::dynamic(), 3}; - if (boxes_ps.rank().is_static() && scores_ps.rank().is_static()) { + if (ov::shape_size(boxes_ps) && ov::shape_size(scores_ps)) { const auto num_boxes_boxes = boxes_ps[1]; - if (num_boxes_boxes.is_static() && scores_ps[0].is_static() && scores_ps[1].is_static()) { - const auto num_boxes = num_boxes_boxes.get_length(); - const auto num_classes = scores_ps[1].get_length(); + const auto num_boxes = num_boxes_boxes; + const auto num_classes = scores_ps[1]; - result[0] = std::min(num_boxes, max_output_boxes_per_class) * num_classes * scores_ps[0].get_length(); - } + result[0] = std::min(num_boxes, max_output_boxes_per_class) * num_classes * scores_ps[0]; } return result; } -void normalize_corner(float* boxes, const ngraph::Shape& boxes_shape) { - size_t total_num_of_boxes = ngraph::shape_size(boxes_shape) / 4; +void normalize_corner(float* boxes, const ov::Shape& boxes_shape) { + size_t total_num_of_boxes = ov::shape_size(boxes_shape) / 4; for (size_t i = 0; i < total_num_of_boxes; ++i) { float* current_box = boxes + 4 * i; @@ -760,8 +741,8 @@ void normalize_corner(float* boxes, const ngraph::Shape& boxes_shape) { } } -void normalize_center(float* boxes, const ngraph::Shape& boxes_shape) { - size_t total_num_of_boxes = ngraph::shape_size(boxes_shape) / 4; +void normalize_center(float* boxes, const ov::Shape& boxes_shape) { + size_t total_num_of_boxes = ov::shape_size(boxes_shape) / 4; for (size_t i = 0; i < total_num_of_boxes; ++i) { float* current_box = boxes + 4 * i; @@ -782,7 +763,7 @@ void normalize_center(float* boxes, const ngraph::Shape& boxes_shape) { } } -void normalize_box_encoding(float* boxes, const ngraph::Shape& boxes_shape, const V5BoxEncoding box_encoding) { +void normalize_box_encoding(float* boxes, const ov::Shape& boxes_shape, const V5BoxEncoding box_encoding) { if (box_encoding == V5BoxEncoding::CORNER) { normalize_corner(boxes, boxes_shape); } else { @@ -790,39 +771,38 @@ void normalize_box_encoding(float* boxes, const ngraph::Shape& boxes_shape, cons } } -std::vector prepare_boxes_data(const std::shared_ptr& boxes, - const ngraph::Shape& boxes_shape, +std::vector prepare_boxes_data(const ov::Tensor& boxes, + const ov::Shape& boxes_shape, const V5BoxEncoding box_encoding) { auto result = get_floats(boxes, boxes_shape); normalize_box_encoding(result.data(), boxes_shape, box_encoding); return result; } -std::vector prepare_scores_data(const std::shared_ptr& scores, - const ngraph::Shape& scores_shape) { +std::vector prepare_scores_data(const ov::Tensor& scores, const ov::Shape& scores_shape) { auto result = get_floats(scores, scores_shape); return result; } -InfoForNMS5 get_info_for_nms5_eval(const std::shared_ptr& nms5, - const std::vector>& inputs) { +InfoForNMS5 get_info_for_nms5_eval(const std::shared_ptr& nms5, + const ov::TensorVector& inputs) { InfoForNMS5 result; - result.max_output_boxes_per_class = inputs.size() > 2 ? get_integers(inputs[2], ngraph::Shape({}))[0] : 0; - result.iou_threshold = inputs.size() > 3 ? get_floats(inputs[3], ngraph::Shape({}))[0] : 0.0f; - result.score_threshold = inputs.size() > 4 ? get_floats(inputs[4], ngraph::Shape({}))[0] : 0.0f; - result.soft_nms_sigma = inputs.size() > 5 ? get_floats(inputs[5], ngraph::Shape({}))[0] : 0.0f; + result.max_output_boxes_per_class = inputs.size() > 2 ? get_integers(inputs[2], ov::Shape({}))[0] : 0; + result.iou_threshold = inputs.size() > 3 ? get_floats(inputs[3], ov::Shape({}))[0] : 0.0f; + result.score_threshold = inputs.size() > 4 ? get_floats(inputs[4], ov::Shape({}))[0] : 0.0f; + result.soft_nms_sigma = inputs.size() > 5 ? get_floats(inputs[5], ov::Shape({}))[0] : 0.0f; auto selected_indices_shape = infer_selected_indices_shape(inputs, result.max_output_boxes_per_class); result.out_shape = selected_indices_shape.to_shape(); - result.boxes_shape = inputs[boxes_port]->get_shape(); - result.scores_shape = inputs[scores_port]->get_shape(); + result.boxes_shape = inputs[boxes_port].get_shape(); + result.scores_shape = inputs[scores_port].get_shape(); result.boxes_data = prepare_boxes_data(inputs[boxes_port], result.boxes_shape, nms5->get_box_encoding()); result.scores_data = prepare_scores_data(inputs[scores_port], result.scores_shape); - result.out_shape_size = ngraph::shape_size(result.out_shape); + result.out_shape_size = ov::shape_size(result.out_shape); result.sort_result_descending = nms5->get_sort_result_descending(); @@ -832,10 +812,10 @@ InfoForNMS5 get_info_for_nms5_eval(const std::shared_ptr -bool evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +template +bool evaluate(const std::shared_ptr& op, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { auto info = nms_v5::get_info_for_nms5_eval(op, inputs); std::vector selected_indices(info.out_shape_size); @@ -857,7 +837,7 @@ bool evaluate(const std::shared_ptr& op, &valid_outputs, info.sort_result_descending); - auto selected_scores_type = (outputs.size() < 3) ? ngraph::element::f32 : outputs[1]->get_element_type(); + auto selected_scores_type = (outputs.size() < 3) ? ov::element::f32 : outputs[1].get_element_type(); ov::reference::nms_postprocessing(outputs, info.output_type, @@ -869,396 +849,231 @@ bool evaluate(const std::shared_ptr& op, } template <> -bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { auto element_type = node->get_output_element_type(0); - if (ov::is_type(node) || ov::is_type(node)) + if (ov::is_type(node) || ov::is_type(node)) element_type = node->get_input_element_type(1); switch (element_type) { - case ngraph::element::Type_t::boolean: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::bf16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i4: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i8: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u1: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u4: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u8: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); + case ov::element::boolean: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::bf16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u1: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); default: - OPENVINO_THROW(std::string("Unhandled data type ") + node->get_element_type().get_type_name() + - std::string("in evaluate_node()")); + OPENVINO_THROW("Unhandled data type ", node->get_element_type().get_type_name(), " in evaluate_node()"); } } template <> -bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { auto element_type = node->get_output_element_type(0); - if (ov::is_type(node) || ov::is_type(node)) + if (ov::is_type(node) || ov::is_type(node)) element_type = node->get_input_element_type(1); switch (element_type) { - case ngraph::element::Type_t::boolean: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::bf16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i4: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i8: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u1: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u4: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u8: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); + case ov::element::boolean: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::bf16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u1: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); default: - OPENVINO_THROW(std::string("Unhandled data type ") + node->get_element_type().get_type_name() + - std::string("in evaluate_node()")); + OPENVINO_THROW("Unhandled data type ", node->get_element_type().get_type_name(), " in evaluate_node()"); } } template <> -bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { auto element_type = node->get_output_element_type(0); - if (ov::is_type(node) || ov::is_type(node)) + if (ov::is_type(node) || ov::is_type(node)) element_type = node->get_input_element_type(1); switch (element_type) { - case ngraph::element::Type_t::boolean: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::bf16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i4: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i8: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u1: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u4: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u8: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); + case ov::element::boolean: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::bf16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u1: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); default: - OPENVINO_THROW(std::string("Unhandled data type ") + node->get_element_type().get_type_name() + - std::string("in evaluate_node()")); + OPENVINO_THROW("Unhandled data type ", node->get_element_type().get_type_name(), " in evaluate_node()"); } } template <> -bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { auto element_type = node->get_output_element_type(0); - if (ov::is_type(node) || ov::is_type(node)) + if (ov::is_type(node) || ov::is_type(node)) element_type = node->get_input_element_type(1); switch (element_type) { - case ngraph::element::Type_t::boolean: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::bf16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i4: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i8: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u1: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u4: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u8: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); + case ov::element::boolean: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::bf16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u1: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); default: - OPENVINO_THROW(std::string("Unhandled data type ") + node->get_element_type().get_type_name() + - std::string("in evaluate_node()")); + OPENVINO_THROW("Unhandled data type ", node->get_element_type().get_type_name(), " in evaluate_node()"); } } template <> -bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { auto element_type = node->get_output_element_type(0); - if (ov::is_type(node) || ov::is_type(node)) + if (ov::is_type(node) || ov::is_type(node)) element_type = node->get_input_element_type(1); switch (element_type) { - case ngraph::element::Type_t::boolean: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::bf16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i4: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i8: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u1: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u4: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u8: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); + case ov::element::boolean: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::bf16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u1: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); default: - OPENVINO_THROW(std::string("Unhandled data type ") + node->get_element_type().get_type_name() + - std::string("in evaluate_node()")); + OPENVINO_THROW("Unhandled data type ", node->get_element_type().get_type_name(), " in evaluate_node()"); } } diff --git a/src/plugins/template/backend/ops/normalize_l2.cpp b/src/plugins/template/backend/ops/normalize_l2.cpp index c2eb3691755ad9..2d2035640ba2da 100644 --- a/src/plugins/template/backend/ops/normalize_l2.cpp +++ b/src/plugins/template/backend/ops/normalize_l2.cpp @@ -6,13 +6,13 @@ #include "evaluate_node.hpp" -template -bool evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { - using T = typename ngraph::element_type_traits::value_type; - ov::reference::normalize_l2(inputs[0]->get_data_ptr(), - outputs[0]->get_data_ptr(), +template +bool evaluate(const std::shared_ptr& op, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { + using T = typename ov::element_type_traits::value_type; + ov::reference::normalize_l2(inputs[0].data(), + outputs[0].data(), op->get_input_shape(0), op->get_reduction_axes(), op->get_eps(), @@ -21,80 +21,47 @@ bool evaluate(const std::shared_ptr& op, } template <> -bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { auto element_type = node->get_output_element_type(0); - if (ov::is_type(node) || ov::is_type(node)) + if (ov::is_type(node) || ov::is_type(node)) element_type = node->get_input_element_type(1); switch (element_type) { - case ngraph::element::Type_t::boolean: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::bf16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i4: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i8: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u1: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u4: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u8: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); + case ov::element::boolean: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::bf16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u1: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); default: - OPENVINO_THROW(std::string("Unhandled data type ") + node->get_element_type().get_type_name() + - std::string("in evaluate_node()")); + OPENVINO_THROW("Unhandled data type ", node->get_element_type().get_type_name(), " in evaluate_node()"); } } diff --git a/src/plugins/template/backend/ops/ops_evaluates.hpp b/src/plugins/template/backend/ops/ops_evaluates.hpp index 7b71cbaf844dbf..c3a316bea50aa5 100644 --- a/src/plugins/template/backend/ops/ops_evaluates.hpp +++ b/src/plugins/template/backend/ops/ops_evaluates.hpp @@ -7,452 +7,448 @@ #include "ov_ops/augru_cell.hpp" #include "ov_ops/augru_sequence.hpp" -extern template bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs); +extern template bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs); -extern template bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs); +extern template bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs); -extern template bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs); +extern template bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs); -extern template bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs); +extern template bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs); -extern template bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs); +extern template bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs); -extern template bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs); +extern template bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs); -extern template bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs); +extern template bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs); -extern template bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs); +extern template bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs); -extern template bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs); +extern template bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs); -extern template bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs); +extern template bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs); -extern template bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs); +extern template bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs); -extern template bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs); +extern template bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs); -extern template bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs); +extern template bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs); -extern template bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs); +extern template bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs); -extern template bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs); - -extern template bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs); - -extern template bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs); - -extern template bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs); - -extern template bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs); - -extern template bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs); - -extern template bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs); - -extern template bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs); - -extern template bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs); - -extern template bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs); - -extern template bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs); - -extern template bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs); +extern template bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs); -extern template bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs); +extern template bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs); -extern template bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs); +extern template bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs); -extern template bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs); +extern template bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs); -extern template bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs); +extern template bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs); -extern template bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs); +extern template bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs); -extern template bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs); +extern template bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs); -extern template bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs); +extern template bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs); -extern template bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs); +extern template bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs); -extern template bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs); +extern template bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs); -extern template bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs); +extern template bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs); -extern template bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs); +extern template bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs); -extern template bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs); +extern template bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs); -extern template bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs); +extern template bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs); -extern template bool evaluate_node( - std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs); +extern template bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs); -extern template bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs); +extern template bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs); -extern template bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs); +extern template bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs); -extern template bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs); - -extern template bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs); - -extern template bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs); - -extern template bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs); - -extern template bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs); - -extern template bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs); - -extern template bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs); - -extern template bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs); - -extern template bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs); - -extern template bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs); - -extern template bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs); - -extern template bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs); - -extern template bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs); - -extern template bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs); - -extern template bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs); - -extern template bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs); - -extern template bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs); - -extern template bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs); - -extern template bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs); - -extern template bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs); - -extern template bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs); - -extern template bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs); - -extern template bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs); - -extern template bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs); - -extern template bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs); - -extern template bool evaluate_node( - std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs); - -extern template bool evaluate_node( - std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs); - -extern template bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs); - -extern template bool evaluate_node( - std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs); - -extern template bool evaluate_node( - std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs); - -extern template bool evaluate_node( - std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs); - -extern template bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs); - -extern template bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs); - -extern template bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs); - -extern template bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs); - -extern template bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs); - -extern template bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs); - -extern template bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs); - -extern template bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs); - -extern template bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs); - -extern template bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs); - -extern template bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs); - -extern template bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs); - -extern template bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs); - -extern template bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs); - -extern template bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs); - -extern template bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs); - -extern template bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs); - -extern template bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs); - -extern template bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs); +extern template bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs); -extern template bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs); +extern template bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs); -extern template bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs); +extern template bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs); -extern template bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs); +extern template bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs); -extern template bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs); +extern template bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs); -extern template bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs); +extern template bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs); -extern template bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs); +extern template bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs); -extern template bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs); +extern template bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs); -extern template bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs); +extern template bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs); -extern template bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs); +extern template bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs); -extern template bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs); +extern template bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs); -extern template bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs); +extern template bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs); -extern template bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs); +extern template bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs); -extern template bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs); +extern template bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs); -extern template bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs); +extern template bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs); -extern template bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs); +extern template bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs); -extern template bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs); +extern template bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs); + +extern template bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs); + +extern template bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs); + +extern template bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs); + +extern template bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs); + +extern template bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs); + +extern template bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs); + +extern template bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs); + +extern template bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs); + +extern template bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs); + +extern template bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs); + +extern template bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs); + +extern template bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs); + +extern template bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs); + +extern template bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs); + +extern template bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs); + +extern template bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs); + +extern template bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs); + +extern template bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs); + +extern template bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs); + +extern template bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs); + +extern template bool evaluate_node( + std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs); + +extern template bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs); + +extern template bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs); + +extern template bool evaluate_node( + std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs); + +extern template bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs); + +extern template bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs); + +extern template bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs); + +extern template bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs); + +extern template bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs); + +extern template bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs); + +extern template bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs); + +extern template bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs); + +extern template bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs); + +extern template bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs); + +extern template bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs); + +extern template bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs); + +extern template bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs); + +extern template bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs); + +extern template bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs); + +extern template bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs); + +extern template bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs); + +extern template bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs); + +extern template bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs); + +extern template bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs); + +extern template bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs); + +extern template bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs); + +extern template bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs); + +extern template bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs); + +extern template bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs); + +extern template bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs); + +extern template bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs); + +extern template bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs); + +extern template bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs); + +extern template bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs); + +extern template bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs); + +extern template bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs); + +extern template bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs); + +extern template bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs); + +extern template bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs); + +extern template bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs); extern template bool evaluate_node(std::shared_ptr node, - const ov::HostTensorVector& outputs, - const ov::HostTensorVector& inputs); + ov::TensorVector& outputs, + const ov::TensorVector& inputs); -extern template bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs); +extern template bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs); -extern template bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs); +extern template bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs); diff --git a/src/plugins/template/backend/ops/pad.cpp b/src/plugins/template/backend/ops/pad.cpp index e5fdee71c10cf3..9bc0f5935484c5 100644 --- a/src/plugins/template/backend/ops/pad.cpp +++ b/src/plugins/template/backend/ops/pad.cpp @@ -6,16 +6,14 @@ #include "evaluate_node.hpp" -template -bool evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { - ov::reference::pad(inputs[0]->get_data_ptr(), - inputs[1]->get_data_ptr(), - outputs[0]->get_data_ptr(), - ngraph::shape_size(inputs[0]->get_shape()), - inputs[1]->get_shape(), - outputs[0]->get_shape(), +template +bool evaluate(const std::shared_ptr& op, ov::TensorVector& outputs, const ov::TensorVector& inputs) { + ov::reference::pad(inputs[0].data(), + inputs[1].data(), + outputs[0].data(), + ov::shape_size(inputs[0].get_shape()), + inputs[1].get_shape(), + outputs[0].get_shape(), op->get_pads_end(), op->get_pads_begin(), op->get_pad_mode()); @@ -23,48 +21,47 @@ bool evaluate(const std::shared_ptr& op, } template <> -bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { auto element_type = node->get_output_element_type(0); - if (ov::is_type(node) || ov::is_type(node)) + if (ov::is_type(node) || ov::is_type(node)) element_type = node->get_input_element_type(1); switch (element_type) { - case ngraph::element::Type_t::boolean: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::bf16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i4: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i8: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u1: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u4: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u8: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::boolean: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::bf16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u1: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); default: - OPENVINO_THROW(std::string("Unhandled data type ") + node->get_element_type().get_type_name() + - std::string("in evaluate_node()")); + OPENVINO_THROW("Unhandled data type ", node->get_element_type().get_type_name(), " in evaluate_node()"); } } diff --git a/src/plugins/template/backend/ops/prelu.cpp b/src/plugins/template/backend/ops/prelu.cpp index 914feb94f6ab8d..d60f90f9fd3f7c 100644 --- a/src/plugins/template/backend/ops/prelu.cpp +++ b/src/plugins/template/backend/ops/prelu.cpp @@ -6,64 +6,59 @@ #include "evaluate_node.hpp" -template -bool evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { - using T = typename ngraph::element_type_traits::value_type; - ov::reference::prelu(inputs[0]->get_data_ptr(), - inputs[1]->get_data_ptr(), - outputs[0]->get_data_ptr(), - inputs[0]->get_shape(), - inputs[1]->get_shape()); +template +bool evaluate(const std::shared_ptr& op, ov::TensorVector& outputs, const ov::TensorVector& inputs) { + using T = typename ov::element_type_traits::value_type; + ov::reference::prelu(inputs[0].data(), + inputs[1].data(), + outputs[0].data(), + inputs[0].get_shape(), + inputs[1].get_shape()); return true; } template <> -bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { auto element_type = node->get_output_element_type(0); - if (ov::is_type(node) || ov::is_type(node)) + if (ov::is_type(node) || ov::is_type(node)) element_type = node->get_input_element_type(1); switch (element_type) { - case ngraph::element::Type_t::boolean: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::bf16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i4: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i8: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u1: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u4: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u8: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::boolean: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::bf16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u1: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); default: - OPENVINO_THROW(std::string("Unhandled data type ") + node->get_element_type().get_type_name() + - std::string("in evaluate_node()")); + OPENVINO_THROW("Unhandled data type ", node->get_element_type().get_type_name(), " in evaluate_node()"); } } diff --git a/src/plugins/template/backend/ops/proposal.cpp b/src/plugins/template/backend/ops/proposal.cpp index b94c06379a1c2c..4cc40aae3b872f 100644 --- a/src/plugins/template/backend/ops/proposal.cpp +++ b/src/plugins/template/backend/ops/proposal.cpp @@ -6,140 +6,130 @@ #include "evaluate_node.hpp" -template -bool evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { - using T = typename ngraph::element_type_traits::value_type; - ov::reference::proposal_v0(inputs[0]->get_data_ptr(), - inputs[1]->get_data_ptr(), - inputs[2]->get_data_ptr(), - outputs[0]->get_data_ptr(), - inputs[0]->get_shape(), - inputs[1]->get_shape(), - inputs[2]->get_shape(), - outputs[0]->get_shape(), +template +bool evaluate(const std::shared_ptr& op, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { + using T = typename ov::element_type_traits::value_type; + ov::reference::proposal_v0(inputs[0].data(), + inputs[1].data(), + inputs[2].data(), + outputs[0].data(), + inputs[0].get_shape(), + inputs[1].get_shape(), + inputs[2].get_shape(), + outputs[0].get_shape(), op.get()->get_attrs()); return true; } -template -bool evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { - using T = typename ngraph::element_type_traits::value_type; - ov::reference::proposal_v4(inputs[0]->get_data_ptr(), - inputs[1]->get_data_ptr(), - inputs[2]->get_data_ptr(), - outputs[0]->get_data_ptr(), - outputs[1]->get_data_ptr(), - inputs[0]->get_shape(), - inputs[1]->get_shape(), - inputs[2]->get_shape(), - outputs[0]->get_shape(), - outputs[1]->get_shape(), +template +bool evaluate(const std::shared_ptr& op, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { + using T = typename ov::element_type_traits::value_type; + ov::reference::proposal_v4(inputs[0].data(), + inputs[1].data(), + inputs[2].data(), + outputs[0].data(), + outputs[1].data(), + inputs[0].get_shape(), + inputs[1].get_shape(), + inputs[2].get_shape(), + outputs[0].get_shape(), + outputs[1].get_shape(), op.get()->get_attrs()); return true; } template <> -bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { auto element_type = node->get_output_element_type(0); - if (ov::is_type(node) || ov::is_type(node)) + if (ov::is_type(node) || ov::is_type(node)) element_type = node->get_input_element_type(1); switch (element_type) { - case ngraph::element::Type_t::boolean: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::bf16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i4: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i8: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u1: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u4: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u8: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::boolean: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::bf16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u1: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); default: - OPENVINO_THROW(std::string("Unhandled data type ") + node->get_element_type().get_type_name() + - std::string("in evaluate_node()")); + OPENVINO_THROW("Unhandled data type ", node->get_element_type().get_type_name(), " in evaluate_node()"); } } template <> -bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { auto element_type = node->get_output_element_type(0); - if (ov::is_type(node) || ov::is_type(node)) + if (ov::is_type(node) || ov::is_type(node)) element_type = node->get_input_element_type(1); switch (element_type) { - case ngraph::element::Type_t::boolean: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::bf16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i4: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i8: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u1: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u4: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u8: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::boolean: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::bf16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u1: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); default: - OPENVINO_THROW(std::string("Unhandled data type ") + node->get_element_type().get_type_name() + - std::string("in evaluate_node()")); + OPENVINO_THROW("Unhandled data type ", node->get_element_type().get_type_name(), " in evaluate_node()"); } } diff --git a/src/plugins/template/backend/ops/psroi_pooling.cpp b/src/plugins/template/backend/ops/psroi_pooling.cpp index c2bf72bcb624fe..beabc3d01a98b4 100644 --- a/src/plugins/template/backend/ops/psroi_pooling.cpp +++ b/src/plugins/template/backend/ops/psroi_pooling.cpp @@ -6,17 +6,17 @@ #include "evaluate_node.hpp" -template -bool evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { - using T = typename ngraph::element_type_traits::value_type; - ov::reference::psroi_pooling(inputs[0]->get_data_ptr(), - inputs[0]->get_shape(), - inputs[1]->get_data_ptr(), - inputs[1]->get_shape(), - outputs[0]->get_data_ptr(), - outputs[0]->get_shape(), +template +bool evaluate(const std::shared_ptr& op, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { + using T = typename ov::element_type_traits::value_type; + ov::reference::psroi_pooling(inputs[0].data(), + inputs[0].get_shape(), + inputs[1].data(), + inputs[1].get_shape(), + outputs[0].data(), + outputs[0].get_shape(), op->get_mode(), op->get_spatial_scale(), op->get_spatial_bins_x(), @@ -26,52 +26,47 @@ bool evaluate(const std::shared_ptr& op, } template <> -bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { auto element_type = node->get_output_element_type(0); - if (ov::is_type(node) || ov::is_type(node)) + if (ov::is_type(node) || ov::is_type(node)) element_type = node->get_input_element_type(1); switch (element_type) { - case ngraph::element::Type_t::boolean: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::bf16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i4: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i8: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u1: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u4: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u8: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::boolean: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::bf16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u1: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); default: - OPENVINO_THROW(std::string("Unhandled data type ") + node->get_element_type().get_type_name() + - std::string("in evaluate_node()")); + OPENVINO_THROW("Unhandled data type ", node->get_element_type().get_type_name(), " in evaluate_node()"); } } diff --git a/src/plugins/template/backend/ops/rdft.cpp b/src/plugins/template/backend/ops/rdft.cpp index 0f3623876e9387..f2f53a5cfdeca2 100644 --- a/src/plugins/template/backend/ops/rdft.cpp +++ b/src/plugins/template/backend/ops/rdft.cpp @@ -7,22 +7,23 @@ #include "evaluate_node.hpp" #include "evaluates_map.hpp" #include "openvino/reference/fft.hpp" +#include "openvino/runtime/tensor.hpp" namespace rfft_v9 { struct InfoForRFFT9 { std::vector input_data; std::vector axes_data; - ngraph::Shape input_data_shape; - ngraph::Shape axes_data_shape; - ngraph::Shape fft_output_shape; - ngraph::Shape output_shape; + ov::Shape input_data_shape; + ov::Shape axes_data_shape; + ov::Shape fft_output_shape; + ov::Shape output_shape; }; -InfoForRFFT9 get_info_for_rfft9_eval(const std::vector>& inputs) { +InfoForRFFT9 get_info_for_rfft9_eval(const ov::TensorVector& inputs) { InfoForRFFT9 result; - result.input_data_shape = inputs[0]->get_shape(); - result.axes_data_shape = inputs[1]->get_shape(); + result.input_data_shape = inputs[0].get_shape(); + result.axes_data_shape = inputs[1].get_shape(); result.input_data = get_floats(inputs[0], result.input_data_shape); result.axes_data = get_integers(inputs[1], result.axes_data_shape); @@ -58,14 +59,12 @@ InfoForRFFT9 get_info_for_rfft9_eval(const std::vector -bool evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +template +bool evaluate(const std::shared_ptr& op, ov::TensorVector& outputs, const ov::TensorVector& inputs) { auto info = rfft_v9::get_info_for_rfft9_eval(inputs); - outputs[0]->set_shape(info.output_shape); + outputs[0].set_shape(info.output_shape); - std::vector rfft_result(ngraph::shape_size(info.output_shape), 0.0f); + std::vector rfft_result(ov::shape_size(info.output_shape), 0.0f); ov::reference::rdft(info.input_data, info.input_data_shape, info.axes_data, @@ -78,48 +77,47 @@ bool evaluate(const std::shared_ptr& op, } template <> -bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { auto element_type = node->get_output_element_type(0); - if (ov::is_type(node) || ov::is_type(node)) + if (ov::is_type(node) || ov::is_type(node)) element_type = node->get_input_element_type(1); switch (element_type) { - case ngraph::element::Type_t::boolean: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::bf16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i4: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i8: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u1: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u4: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u8: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::boolean: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::bf16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u1: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); default: - OPENVINO_THROW(std::string("Unhandled data type ") + node->get_element_type().get_type_name() + - std::string("in evaluate_node()")); + OPENVINO_THROW("Unhandled data type ", node->get_element_type().get_type_name(), " in evaluate_node()"); } } diff --git a/src/plugins/template/backend/ops/read_value.cpp b/src/plugins/template/backend/ops/read_value.cpp index 4a1926568d4f32..39d06f29c9ba80 100644 --- a/src/plugins/template/backend/ops/read_value.cpp +++ b/src/plugins/template/backend/ops/read_value.cpp @@ -4,81 +4,21 @@ #include "evaluate_node.hpp" -template -bool evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { - outputs[0]->set_unary(inputs[0]); - void* input = inputs[0]->get_data_ptr(); - outputs[0]->write(input, outputs[0]->get_size_in_bytes()); +bool evaluate(const std::shared_ptr& op, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { + outputs[0].set_shape(inputs[0].get_shape()); + inputs[0].copy_to(outputs[0]); return true; } template <> -bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { auto element_type = node->get_output_element_type(0); - if (ov::is_type(node) || ov::is_type(node)) + if (ov::is_type(node) || ov::is_type(node)) element_type = node->get_input_element_type(1); - switch (element_type) { - case ngraph::element::Type_t::boolean: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::bf16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i4: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i8: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u1: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u4: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u8: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - default: - OPENVINO_THROW(std::string("Unhandled data type ") + node->get_element_type().get_type_name() + - std::string("in evaluate_node()")); - } + return evaluate(ov::as_type_ptr(node), outputs, inputs); } diff --git a/src/plugins/template/backend/ops/region_yolo.cpp b/src/plugins/template/backend/ops/region_yolo.cpp index 7d3ae5971945ff..51038d036dabb1 100644 --- a/src/plugins/template/backend/ops/region_yolo.cpp +++ b/src/plugins/template/backend/ops/region_yolo.cpp @@ -6,14 +6,14 @@ #include "evaluate_node.hpp" -template -bool evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { - using T = typename ngraph::element_type_traits::value_type; - ov::reference::region_yolo(inputs[0]->get_data_ptr(), - outputs[0]->get_data_ptr(), - inputs[0]->get_shape(), +template +bool evaluate(const std::shared_ptr& op, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { + using T = typename ov::element_type_traits::value_type; + ov::reference::region_yolo(inputs[0].data(), + outputs[0].data(), + inputs[0].get_shape(), static_cast(op->get_num_coords()), static_cast(op->get_num_classes()), static_cast(op->get_num_regions()), @@ -23,80 +23,47 @@ bool evaluate(const std::shared_ptr& op, } template <> -bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { auto element_type = node->get_output_element_type(0); - if (ov::is_type(node) || ov::is_type(node)) + if (ov::is_type(node) || ov::is_type(node)) element_type = node->get_input_element_type(1); switch (element_type) { - case ngraph::element::Type_t::boolean: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::bf16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i4: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i8: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u1: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u4: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u8: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); + case ov::element::boolean: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::bf16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u1: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); default: - OPENVINO_THROW(std::string("Unhandled data type ") + node->get_element_type().get_type_name() + - std::string("in evaluate_node()")); + OPENVINO_THROW("Unhandled data type ", node->get_element_type().get_type_name(), " in evaluate_node()"); } } diff --git a/src/plugins/template/backend/ops/relu.cpp b/src/plugins/template/backend/ops/relu.cpp index ce570e1a65c63e..dd2b4131d7847a 100644 --- a/src/plugins/template/backend/ops/relu.cpp +++ b/src/plugins/template/backend/ops/relu.cpp @@ -6,60 +6,55 @@ #include "evaluate_node.hpp" -template -bool evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { - using T = typename ngraph::element_type_traits::value_type; - ov::reference::relu(inputs[0]->get_data_ptr(), - outputs[0]->get_data_ptr(), - ngraph::shape_size(inputs[0]->get_shape())); +template +bool evaluate(const std::shared_ptr& op, ov::TensorVector& outputs, const ov::TensorVector& inputs) { + using T = typename ov::element_type_traits::value_type; + ov::reference::relu(inputs[0].data(), outputs[0].data(), ov::shape_size(inputs[0].get_shape())); return true; } template <> -bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { auto element_type = node->get_output_element_type(0); - if (ov::is_type(node) || ov::is_type(node)) + if (ov::is_type(node) || ov::is_type(node)) element_type = node->get_input_element_type(1); switch (element_type) { - case ngraph::element::Type_t::boolean: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::bf16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i4: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i8: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u1: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u4: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u8: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::boolean: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::bf16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u1: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); default: - OPENVINO_THROW(std::string("Unhandled data type ") + node->get_element_type().get_type_name() + - std::string("in evaluate_node()")); + OPENVINO_THROW("Unhandled data type ", node->get_element_type().get_type_name(), " in evaluate_node()"); } } diff --git a/src/plugins/template/backend/ops/reorg_yolo.cpp b/src/plugins/template/backend/ops/reorg_yolo.cpp index 05730f4279d64f..d54e661958582b 100644 --- a/src/plugins/template/backend/ops/reorg_yolo.cpp +++ b/src/plugins/template/backend/ops/reorg_yolo.cpp @@ -6,83 +6,24 @@ #include "evaluate_node.hpp" -template -bool evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { - ov::reference::reorg_yolo(inputs[0]->get_data_ptr(), - outputs[0]->get_data_ptr(), - inputs[0]->get_shape(), +bool evaluate(const std::shared_ptr& op, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { + ov::reference::reorg_yolo(static_cast(inputs[0].data()), + static_cast(outputs[0].data()), + inputs[0].get_shape(), op->get_strides().at(0), - inputs[0]->get_element_type().size()); + inputs[0].get_element_type().size()); return true; } template <> -bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { auto element_type = node->get_output_element_type(0); - if (ov::is_type(node) || ov::is_type(node)) + if (ov::is_type(node) || ov::is_type(node)) element_type = node->get_input_element_type(1); - switch (element_type) { - case ngraph::element::Type_t::boolean: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::bf16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i4: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i8: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u1: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u4: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u8: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - default: - OPENVINO_THROW(std::string("Unhandled data type ") + node->get_element_type().get_type_name() + - std::string("in evaluate_node()")); - } + return evaluate(ov::as_type_ptr(node), outputs, inputs); } diff --git a/src/plugins/template/backend/ops/reverse_sequence.cpp b/src/plugins/template/backend/ops/reverse_sequence.cpp index d00ba0b0fc2669..fa896ac13902b6 100644 --- a/src/plugins/template/backend/ops/reverse_sequence.cpp +++ b/src/plugins/template/backend/ops/reverse_sequence.cpp @@ -7,61 +7,61 @@ #include "evaluate_node.hpp" namespace reverse_sequence_v0 { -template -inline void evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { - using T1 = typename ngraph::element_type_traits::value_type; - using T2 = typename ngraph::element_type_traits::value_type; - ov::reference::reverse_sequence(inputs[0]->get_data_ptr(), - outputs[0]->get_data_ptr(), - inputs[0]->get_shape(), +template +inline void evaluate(const std::shared_ptr& op, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { + using T1 = typename ov::element_type_traits::value_type; + using T2 = typename ov::element_type_traits::value_type; + ov::reference::reverse_sequence(inputs[0].data(), + outputs[0].data(), + inputs[0].get_shape(), op->get_batch_axis(), op->get_sequence_axis(), - inputs[1]->get_data_ptr()); + inputs[1].data()); } } // namespace reverse_sequence_v0 -template -bool evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { - switch (inputs[1]->get_element_type()) { - case ngraph::element::Type_t::boolean: - reverse_sequence_v0::evaluate(op, outputs, inputs); +template +bool evaluate(const std::shared_ptr& op, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { + switch (inputs[1].get_element_type()) { + case ov::element::boolean: + reverse_sequence_v0::evaluate(op, outputs, inputs); break; - case ngraph::element::Type_t::i8: - reverse_sequence_v0::evaluate(op, outputs, inputs); + case ov::element::i8: + reverse_sequence_v0::evaluate(op, outputs, inputs); break; - case ngraph::element::Type_t::i16: - reverse_sequence_v0::evaluate(op, outputs, inputs); + case ov::element::i16: + reverse_sequence_v0::evaluate(op, outputs, inputs); break; - case ngraph::element::Type_t::i32: - reverse_sequence_v0::evaluate(op, outputs, inputs); + case ov::element::i32: + reverse_sequence_v0::evaluate(op, outputs, inputs); break; - case ngraph::element::Type_t::i64: - reverse_sequence_v0::evaluate(op, outputs, inputs); + case ov::element::i64: + reverse_sequence_v0::evaluate(op, outputs, inputs); break; - case ngraph::element::Type_t::u8: - reverse_sequence_v0::evaluate(op, outputs, inputs); + case ov::element::u8: + reverse_sequence_v0::evaluate(op, outputs, inputs); break; - case ngraph::element::Type_t::u16: - reverse_sequence_v0::evaluate(op, outputs, inputs); + case ov::element::u16: + reverse_sequence_v0::evaluate(op, outputs, inputs); break; - case ngraph::element::Type_t::u32: - reverse_sequence_v0::evaluate(op, outputs, inputs); + case ov::element::u32: + reverse_sequence_v0::evaluate(op, outputs, inputs); break; - case ngraph::element::Type_t::u64: - reverse_sequence_v0::evaluate(op, outputs, inputs); + case ov::element::u64: + reverse_sequence_v0::evaluate(op, outputs, inputs); break; - case ngraph::element::Type_t::f16: - reverse_sequence_v0::evaluate(op, outputs, inputs); + case ov::element::f16: + reverse_sequence_v0::evaluate(op, outputs, inputs); break; - case ngraph::element::Type_t::f32: - reverse_sequence_v0::evaluate(op, outputs, inputs); + case ov::element::f32: + reverse_sequence_v0::evaluate(op, outputs, inputs); break; - case ngraph::element::Type_t::f64: - reverse_sequence_v0::evaluate(op, outputs, inputs); + case ov::element::f64: + reverse_sequence_v0::evaluate(op, outputs, inputs); break; default: return false; @@ -70,80 +70,47 @@ bool evaluate(const std::shared_ptr& op, } template <> -bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { auto element_type = node->get_output_element_type(0); - if (ov::is_type(node) || ov::is_type(node)) + if (ov::is_type(node) || ov::is_type(node)) element_type = node->get_input_element_type(1); switch (element_type) { - case ngraph::element::Type_t::boolean: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::bf16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i4: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i8: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u1: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u4: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u8: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); + case ov::element::boolean: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::bf16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u1: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); default: - OPENVINO_THROW(std::string("Unhandled data type ") + node->get_element_type().get_type_name() + - std::string("in evaluate_node()")); + OPENVINO_THROW("Unhandled data type ", node->get_element_type().get_type_name(), " in evaluate_node()"); } } diff --git a/src/plugins/template/backend/ops/rnn_cell.cpp b/src/plugins/template/backend/ops/rnn_cell.cpp index 8b52ff0275e2e5..6813b6eddde29a 100644 --- a/src/plugins/template/backend/ops/rnn_cell.cpp +++ b/src/plugins/template/backend/ops/rnn_cell.cpp @@ -6,72 +6,69 @@ #include "evaluate_node.hpp" -template -bool evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { - using T = typename ngraph::element_type_traits::value_type; - ov::reference::rnn_cell(inputs[0]->get_data_ptr(), - inputs[0]->get_shape(), - inputs[1]->get_data_ptr(), - inputs[1]->get_shape(), - inputs[2]->get_data_ptr(), - inputs[2]->get_shape(), - inputs[3]->get_data_ptr(), - inputs[3]->get_shape(), - inputs[4]->get_data_ptr(), - inputs[4]->get_shape(), - outputs[0]->get_data_ptr(), +template +bool evaluate(const std::shared_ptr& op, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { + using T = typename ov::element_type_traits::value_type; + ov::reference::rnn_cell(inputs[0].data(), + inputs[0].get_shape(), + inputs[1].data(), + inputs[1].get_shape(), + inputs[2].data(), + inputs[2].get_shape(), + inputs[3].data(), + inputs[3].get_shape(), + inputs[4].data(), + inputs[4].get_shape(), + outputs[0].data(), op->get_activations().front(), op->get_clip()); return true; } template <> -bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { auto element_type = node->get_output_element_type(0); - if (ov::is_type(node) || ov::is_type(node)) + if (ov::is_type(node) || ov::is_type(node)) element_type = node->get_input_element_type(1); switch (element_type) { - case ngraph::element::Type_t::boolean: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::bf16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i4: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i8: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u1: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u4: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u8: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::boolean: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::bf16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u1: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); default: - OPENVINO_THROW(std::string("Unhandled data type ") + node->get_element_type().get_type_name() + - std::string("in evaluate_node()")); + OPENVINO_THROW("Unhandled data type ", node->get_element_type().get_type_name(), " in evaluate_node()"); } } diff --git a/src/plugins/template/backend/ops/roi_align.cpp b/src/plugins/template/backend/ops/roi_align.cpp index ae1fc3d9b83837..119c801cfe9fb8 100644 --- a/src/plugins/template/backend/ops/roi_align.cpp +++ b/src/plugins/template/backend/ops/roi_align.cpp @@ -5,31 +5,32 @@ #include "openvino/reference/roi_align.hpp" #include "evaluate_node.hpp" +#include "evaluates_map.hpp" -template -bool evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { - using T = typename ngraph::element_type_traits::value_type; - std::vector batch_indices_vec_scaled_up = host_tensor_2_vector(inputs[2]); - ngraph::op::v3::ROIAlign::PoolingMode m_mode_v3; +template +bool evaluate(const std::shared_ptr& op, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { + using T = typename ov::element_type_traits::value_type; + std::vector batch_indices_vec_scaled_up = get_integers(inputs[2], inputs[2].get_shape()); + ov::op::v3::ROIAlign::PoolingMode m_mode_v3; switch (op->get_mode()) { - case ngraph::op::v9::ROIAlign::PoolingMode::AVG: { - m_mode_v3 = ngraph::op::v3::ROIAlign::PoolingMode::AVG; + case ov::op::v9::ROIAlign::PoolingMode::AVG: { + m_mode_v3 = ov::op::v3::ROIAlign::PoolingMode::AVG; break; } - case ngraph::op::v9::ROIAlign::PoolingMode::MAX: { - m_mode_v3 = ngraph::op::v3::ROIAlign::PoolingMode::MAX; + case ov::op::v9::ROIAlign::PoolingMode::MAX: { + m_mode_v3 = ov::op::v3::ROIAlign::PoolingMode::MAX; break; } default: { NGRAPH_CHECK(false, "unsupported PoolingMode "); } } - ov::reference::roi_align(inputs[0]->get_data_ptr(), - inputs[1]->get_data_ptr(), + ov::reference::roi_align(inputs[0].data(), + inputs[1].data(), batch_indices_vec_scaled_up.data(), - outputs[0]->get_data_ptr(), + outputs[0].data(), op->get_input_shape(0), op->get_input_shape(1), op->get_input_shape(2), @@ -44,52 +45,47 @@ bool evaluate(const std::shared_ptr& op, } template <> -bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { auto element_type = node->get_output_element_type(0); - if (ov::is_type(node) || ov::is_type(node)) + if (ov::is_type(node) || ov::is_type(node)) element_type = node->get_input_element_type(1); switch (element_type) { - case ngraph::element::Type_t::boolean: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::bf16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i4: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i8: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u1: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u4: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u8: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::boolean: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::bf16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u1: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); default: - OPENVINO_THROW(std::string("Unhandled data type ") + node->get_element_type().get_type_name() + - std::string("in evaluate_node()")); + OPENVINO_THROW("Unhandled data type ", node->get_element_type().get_type_name(), " in evaluate_node()"); } } diff --git a/src/plugins/template/backend/ops/roi_pooling.cpp b/src/plugins/template/backend/ops/roi_pooling.cpp index a10fe0b06ba8f0..bc115b114a2051 100644 --- a/src/plugins/template/backend/ops/roi_pooling.cpp +++ b/src/plugins/template/backend/ops/roi_pooling.cpp @@ -2,19 +2,18 @@ // SPDX-License-Identifier: Apache-2.0 // -// clang-format off -#include "evaluate_node.hpp" #include "openvino/reference/roi_pooling.hpp" -// clang-format on -template -bool evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { - using T = typename ngraph::element_type_traits::value_type; - ov::reference::roi_pooling(inputs[0]->get_data_ptr(), - inputs[1]->get_data_ptr(), - outputs[0]->get_data_ptr(), +#include "evaluate_node.hpp" + +template +bool evaluate(const std::shared_ptr& op, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { + using T = typename ov::element_type_traits::value_type; + ov::reference::roi_pooling(inputs[0].data(), + inputs[1].data(), + outputs[0].data(), op->get_input_shape(0), op->get_input_shape(1), op->get_output_shape(0), @@ -24,80 +23,47 @@ bool evaluate(const std::shared_ptr& op, } template <> -bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { auto element_type = node->get_output_element_type(0); - if (ov::is_type(node) || ov::is_type(node)) + if (ov::is_type(node) || ov::is_type(node)) element_type = node->get_input_element_type(1); switch (element_type) { - case ngraph::element::Type_t::boolean: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::bf16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i4: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i8: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u1: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u4: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u8: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); + case ov::element::boolean: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::bf16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u1: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); default: - OPENVINO_THROW(std::string("Unhandled data type ") + node->get_element_type().get_type_name() + - std::string("in evaluate_node()")); + OPENVINO_THROW("Unhandled data type ", node->get_element_type().get_type_name(), " in evaluate_node()"); } } diff --git a/src/plugins/template/backend/ops/roll.cpp b/src/plugins/template/backend/ops/roll.cpp index 69caac63c73769..57a4f666ad3b8c 100644 --- a/src/plugins/template/backend/ops/roll.cpp +++ b/src/plugins/template/backend/ops/roll.cpp @@ -6,91 +6,47 @@ #include "evaluate_node.hpp" -template -bool evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { - const auto& shiftType = inputs[1]->get_element_type(); +bool evaluate(const std::shared_ptr& op, ov::TensorVector& outputs, const ov::TensorVector& inputs) { + const auto& shiftType = inputs[1].get_element_type(); std::vector shift_int64; - if (shiftType == ngraph::element::Type_t::i32) { - auto shift = inputs[1]->get_data_ptr(); - shift_int64.resize(ngraph::shape_size(inputs[1]->get_shape())); + if (shiftType == ov::element::i32) { + auto shift = inputs[1].data(); + shift_int64.resize(ov::shape_size(inputs[1].get_shape())); std::transform(shift, - shift + ngraph::shape_size(inputs[1]->get_shape()), + shift + ov::shape_size(inputs[1].get_shape()), shift_int64.begin(), [](const int32_t& elem) { return static_cast(elem); }); } - const auto& axesType = inputs[2]->get_element_type(); + const auto& axesType = inputs[2].get_element_type(); std::vector axes_int64; - if (axesType == ngraph::element::Type_t::i32) { - auto axes = inputs[2]->get_data_ptr(); - axes_int64.resize(ngraph::shape_size(inputs[2]->get_shape())); - std::transform(axes, - axes + ngraph::shape_size(inputs[2]->get_shape()), - axes_int64.begin(), - [](const int32_t& elem) { - return static_cast(elem); - }); + if (axesType == ov::element::i32) { + auto axes = inputs[2].data(); + axes_int64.resize(ov::shape_size(inputs[2].get_shape())); + std::transform(axes, axes + ov::shape_size(inputs[2].get_shape()), axes_int64.begin(), [](const int32_t& elem) { + return static_cast(elem); + }); } ov::reference::roll( - inputs[0]->get_data_ptr(), - inputs[1]->get_element_type() != ngraph::element::Type_t::i64 ? shift_int64.data() - : inputs[1]->get_data_ptr(), - inputs[2]->get_element_type() != ngraph::element::Type_t::i64 ? axes_int64.data() - : inputs[2]->get_data_ptr(), - outputs[0]->get_data_ptr(), - inputs[0]->get_shape(), - inputs[1]->get_shape(), - inputs[2]->get_shape(), - inputs[0]->get_element_type().size()); + static_cast(inputs[0].data()), + inputs[1].get_element_type() != ov::element::i64 ? shift_int64.data() : inputs[1].data(), + inputs[2].get_element_type() != ov::element::i64 ? axes_int64.data() : inputs[2].data(), + static_cast(outputs[0].data()), + inputs[0].get_shape(), + inputs[1].get_shape(), + inputs[2].get_shape(), + inputs[0].get_element_type().size()); return true; } template <> -bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { auto element_type = node->get_output_element_type(0); - if (ov::is_type(node) || ov::is_type(node)) + if (ov::is_type(node) || ov::is_type(node)) element_type = node->get_input_element_type(1); - switch (element_type) { - case ngraph::element::Type_t::boolean: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::bf16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i4: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i8: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u1: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u4: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u8: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - default: - OPENVINO_THROW(std::string("Unhandled data type ") + node->get_element_type().get_type_name() + - std::string("in evaluate_node()")); - } + return evaluate(ov::as_type_ptr(node), outputs, inputs); } diff --git a/src/plugins/template/backend/ops/scatter_nd_update.cpp b/src/plugins/template/backend/ops/scatter_nd_update.cpp index d55cac83087035..8064535a1b62db 100644 --- a/src/plugins/template/backend/ops/scatter_nd_update.cpp +++ b/src/plugins/template/backend/ops/scatter_nd_update.cpp @@ -6,25 +6,25 @@ #include "evaluate_node.hpp" -template -bool evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { - using T = typename ngraph::element_type_traits::value_type; +template +bool evaluate(const std::shared_ptr& op, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { + using T = typename ov::element_type_traits::value_type; auto idxType = op->get_input_element_type(1); - if (idxType == ngraph::element::i32) { - ov::reference::scatterNdUpdate(inputs[0]->get_data_ptr(), - inputs[1]->get_data_ptr(), - inputs[2]->get_data_ptr(), - outputs[0]->get_data_ptr(), + if (idxType == ov::element::i32) { + ov::reference::scatterNdUpdate(inputs[0].data(), + inputs[1].data(), + inputs[2].data(), + outputs[0].data(), op->get_input_shape(0), op->get_input_shape(1), op->get_input_shape(2)); - } else if (idxType == ngraph::element::i64) { - ov::reference::scatterNdUpdate(inputs[0]->get_data_ptr(), - inputs[1]->get_data_ptr(), - inputs[2]->get_data_ptr(), - outputs[0]->get_data_ptr(), + } else if (idxType == ov::element::i64) { + ov::reference::scatterNdUpdate(inputs[0].data(), + inputs[1].data(), + inputs[2].data(), + outputs[0].data(), op->get_input_shape(0), op->get_input_shape(1), op->get_input_shape(2)); @@ -35,80 +35,47 @@ bool evaluate(const std::shared_ptr& op, } template <> -bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { auto element_type = node->get_output_element_type(0); - if (ov::is_type(node) || ov::is_type(node)) + if (ov::is_type(node) || ov::is_type(node)) element_type = node->get_input_element_type(1); switch (element_type) { - case ngraph::element::Type_t::boolean: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::bf16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i4: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i8: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u1: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u4: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u8: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); + case ov::element::boolean: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::bf16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u1: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); default: - OPENVINO_THROW(std::string("Unhandled data type ") + node->get_element_type().get_type_name() + - std::string("in evaluate_node()")); + OPENVINO_THROW("Unhandled data type ", node->get_element_type().get_type_name(), " in evaluate_node()"); } } diff --git a/src/plugins/template/backend/ops/selu.cpp b/src/plugins/template/backend/ops/selu.cpp index 0580bd7220020d..11e3659b790963 100644 --- a/src/plugins/template/backend/ops/selu.cpp +++ b/src/plugins/template/backend/ops/selu.cpp @@ -6,64 +6,61 @@ #include "evaluate_node.hpp" -template -bool evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { - using T = typename ngraph::element_type_traits::value_type; - ov::reference::selu(inputs[0]->get_data_ptr(), - inputs[1]->get_data_ptr(), - inputs[2]->get_data_ptr(), - outputs[0]->get_data_ptr(), - ngraph::shape_size(inputs[0]->get_shape()), - ngraph::shape_size(inputs[1]->get_shape()), - ngraph::shape_size(inputs[2]->get_shape())); +template +bool evaluate(const std::shared_ptr& op, ov::TensorVector& outputs, const ov::TensorVector& inputs) { + using T = typename ov::element_type_traits::value_type; + ov::reference::selu(inputs[0].data(), + inputs[1].data(), + inputs[2].data(), + outputs[0].data(), + ov::shape_size(inputs[0].get_shape()), + ov::shape_size(inputs[1].get_shape()), + ov::shape_size(inputs[2].get_shape())); return true; } template <> -bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { auto element_type = node->get_output_element_type(0); - if (ov::is_type(node) || ov::is_type(node)) + if (ov::is_type(node) || ov::is_type(node)) element_type = node->get_input_element_type(1); switch (element_type) { - case ngraph::element::Type_t::boolean: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::bf16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i4: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i8: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u1: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u4: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u8: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::boolean: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::bf16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u1: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); default: - OPENVINO_THROW(std::string("Unhandled data type ") + node->get_element_type().get_type_name() + - std::string("in evaluate_node()")); + OPENVINO_THROW("Unhandled data type ", node->get_element_type().get_type_name(), " in evaluate_node()"); } } diff --git a/src/plugins/template/backend/ops/sequences.cpp b/src/plugins/template/backend/ops/sequences.cpp index a8d0ddf49b1cb0..dd182836e7485b 100644 --- a/src/plugins/template/backend/ops/sequences.cpp +++ b/src/plugins/template/backend/ops/sequences.cpp @@ -9,44 +9,44 @@ // clang-format on namespace rnn_seq_v5 { -template -inline void evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { - using T1 = typename ngraph::element_type_traits::value_type; - using T2 = typename ngraph::element_type_traits::value_type; - ov::reference::rnn_sequence(inputs[0]->get_data_ptr(), - inputs[0]->get_shape(), - inputs[1]->get_data_ptr(), - inputs[1]->get_shape(), - inputs[2]->get_data_ptr(), - inputs[2]->get_shape(), - inputs[3]->get_data_ptr(), - inputs[3]->get_shape(), - inputs[4]->get_data_ptr(), - inputs[4]->get_shape(), - inputs[5]->get_data_ptr(), - inputs[5]->get_shape(), - outputs[0]->get_data_ptr(), - outputs[1]->get_data_ptr(), +template +inline void evaluate(const std::shared_ptr& op, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { + using T1 = typename ov::element_type_traits::value_type; + using T2 = typename ov::element_type_traits::value_type; + ov::reference::rnn_sequence(static_cast(inputs[0].data()), + inputs[0].get_shape(), + static_cast(inputs[1].data()), + inputs[1].get_shape(), + static_cast(inputs[2].data()), + inputs[2].get_shape(), + static_cast(inputs[3].data()), + inputs[3].get_shape(), + static_cast(inputs[4].data()), + inputs[4].get_shape(), + static_cast(inputs[5].data()), + inputs[5].get_shape(), + static_cast(outputs[0].data()), + static_cast(outputs[1].data()), op->get_activations()[0], op->get_clip(), op->get_direction()); } } // namespace rnn_seq_v5 -template -bool evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { - switch (inputs[2]->get_element_type()) { - case ngraph::element::Type_t::i64: - case ngraph::element::Type_t::u64: - rnn_seq_v5::evaluate(op, outputs, inputs); +template +bool evaluate(const std::shared_ptr& op, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { + switch (inputs[2].get_element_type()) { + case ov::element::i64: + case ov::element::u64: + rnn_seq_v5::evaluate(op, outputs, inputs); break; - case ngraph::element::Type_t::i32: - case ngraph::element::Type_t::u32: - rnn_seq_v5::evaluate(op, outputs, inputs); + case ov::element::i32: + case ov::element::u32: + rnn_seq_v5::evaluate(op, outputs, inputs); break; default: return false; @@ -55,31 +55,31 @@ bool evaluate(const std::shared_ptr& op, } namespace lstm_seq_v1 { -template -inline void evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { - using T1 = typename ngraph::element_type_traits::value_type; - using T2 = typename ngraph::element_type_traits::value_type; - ov::reference::lstm_sequence_v1(inputs[0]->get_data_ptr(), - inputs[0]->get_shape(), - inputs[1]->get_data_ptr(), - inputs[1]->get_shape(), - inputs[2]->get_data_ptr(), - inputs[2]->get_shape(), - inputs[3]->get_data_ptr(), - inputs[3]->get_shape(), - inputs[4]->get_data_ptr(), - inputs[4]->get_shape(), - inputs[5]->get_data_ptr(), - inputs[5]->get_shape(), - inputs[6]->get_data_ptr(), - inputs[6]->get_shape(), - inputs[7]->get_data_ptr(), - inputs[7]->get_shape(), - outputs[0]->get_data_ptr(), - outputs[1]->get_data_ptr(), - outputs[2]->get_data_ptr(), +template +inline void evaluate(const std::shared_ptr& op, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { + using T1 = typename ov::element_type_traits::value_type; + using T2 = typename ov::element_type_traits::value_type; + ov::reference::lstm_sequence_v1(static_cast(inputs[0].data()), + inputs[0].get_shape(), + static_cast(inputs[1].data()), + inputs[1].get_shape(), + static_cast(inputs[2].data()), + inputs[2].get_shape(), + static_cast(inputs[3].data()), + inputs[3].get_shape(), + static_cast(inputs[4].data()), + inputs[4].get_shape(), + static_cast(inputs[5].data()), + inputs[5].get_shape(), + static_cast(inputs[6].data()), + inputs[6].get_shape(), + static_cast(inputs[7].data()), + inputs[7].get_shape(), + static_cast(outputs[0].data()), + static_cast(outputs[1].data()), + static_cast(outputs[2].data()), op->get_activations()[0], op->get_activations()[1], op->get_activations()[2], @@ -91,29 +91,29 @@ inline void evaluate(const std::shared_ptr& op, } // namespace lstm_seq_v1 namespace lstm_seq_v5 { -template -inline void evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { - using T1 = typename ngraph::element_type_traits::value_type; - using T2 = typename ngraph::element_type_traits::value_type; - ov::reference::lstm_sequence(inputs[0]->get_data_ptr(), - inputs[0]->get_shape(), - inputs[1]->get_data_ptr(), - inputs[1]->get_shape(), - inputs[2]->get_data_ptr(), - inputs[2]->get_shape(), - inputs[3]->get_data_ptr(), - inputs[3]->get_shape(), - inputs[4]->get_data_ptr(), - inputs[4]->get_shape(), - inputs[5]->get_data_ptr(), - inputs[5]->get_shape(), - inputs[6]->get_data_ptr(), - inputs[6]->get_shape(), - outputs[0]->get_data_ptr(), - outputs[1]->get_data_ptr(), - outputs[2]->get_data_ptr(), +template +inline void evaluate(const std::shared_ptr& op, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { + using T1 = typename ov::element_type_traits::value_type; + using T2 = typename ov::element_type_traits::value_type; + ov::reference::lstm_sequence(static_cast(inputs[0].data()), + inputs[0].get_shape(), + static_cast(inputs[1].data()), + inputs[1].get_shape(), + static_cast(inputs[2].data()), + inputs[2].get_shape(), + static_cast(inputs[3].data()), + inputs[3].get_shape(), + static_cast(inputs[4].data()), + inputs[4].get_shape(), + static_cast(inputs[5].data()), + inputs[5].get_shape(), + static_cast(inputs[6].data()), + inputs[6].get_shape(), + static_cast(outputs[0].data()), + static_cast(outputs[1].data()), + static_cast(outputs[2].data()), op->get_activations()[0], op->get_activations()[1], op->get_activations()[2], @@ -122,18 +122,18 @@ inline void evaluate(const std::shared_ptr& op, } } // namespace lstm_seq_v5 -template -bool evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { - switch (inputs[3]->get_element_type()) { - case ngraph::element::Type_t::i64: - case ngraph::element::Type_t::u64: - lstm_seq_v1::evaluate(op, outputs, inputs); +template +bool evaluate(const std::shared_ptr& op, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { + switch (inputs[3].get_element_type()) { + case ov::element::i64: + case ov::element::u64: + lstm_seq_v1::evaluate(op, outputs, inputs); break; - case ngraph::element::Type_t::i32: - case ngraph::element::Type_t::u32: - lstm_seq_v1::evaluate(op, outputs, inputs); + case ov::element::i32: + case ov::element::u32: + lstm_seq_v1::evaluate(op, outputs, inputs); break; default: return false; @@ -141,18 +141,18 @@ bool evaluate(const std::shared_ptr& op, return true; } -template -bool evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { - switch (inputs[3]->get_element_type()) { - case ngraph::element::Type_t::i64: - case ngraph::element::Type_t::u64: - lstm_seq_v5::evaluate(op, outputs, inputs); +template +bool evaluate(const std::shared_ptr& op, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { + switch (inputs[3].get_element_type()) { + case ov::element::i64: + case ov::element::u64: + lstm_seq_v5::evaluate(op, outputs, inputs); break; - case ngraph::element::Type_t::i32: - case ngraph::element::Type_t::u32: - lstm_seq_v5::evaluate(op, outputs, inputs); + case ov::element::i32: + case ov::element::u32: + lstm_seq_v5::evaluate(op, outputs, inputs); break; default: return false; @@ -161,26 +161,26 @@ bool evaluate(const std::shared_ptr& op, } namespace gru_seq_v5 { -template -inline void evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { - using T1 = typename ngraph::element_type_traits::value_type; - using T2 = typename ngraph::element_type_traits::value_type; - ov::reference::gru_sequence(inputs[0]->get_data_ptr(), - inputs[0]->get_shape(), - inputs[1]->get_data_ptr(), - inputs[1]->get_shape(), - inputs[2]->get_data_ptr(), - inputs[2]->get_shape(), - inputs[3]->get_data_ptr(), - inputs[3]->get_shape(), - inputs[4]->get_data_ptr(), - inputs[4]->get_shape(), - inputs[5]->get_data_ptr(), - inputs[5]->get_shape(), - outputs[0]->get_data_ptr(), - outputs[1]->get_data_ptr(), +template +inline void evaluate(const std::shared_ptr& op, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { + using T1 = typename ov::element_type_traits::value_type; + using T2 = typename ov::element_type_traits::value_type; + ov::reference::gru_sequence(static_cast(inputs[0].data()), + inputs[0].get_shape(), + static_cast(inputs[1].data()), + inputs[1].get_shape(), + static_cast(inputs[2].data()), + inputs[2].get_shape(), + static_cast(inputs[3].data()), + inputs[3].get_shape(), + static_cast(inputs[4].data()), + inputs[4].get_shape(), + static_cast(inputs[5].data()), + inputs[5].get_shape(), + static_cast(outputs[0].data()), + static_cast(outputs[1].data()), op->get_activations()[0], op->get_activations()[1], op->get_clip(), @@ -189,18 +189,18 @@ inline void evaluate(const std::shared_ptr& op, } } // namespace gru_seq_v5 -template -bool evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { - switch (inputs[2]->get_element_type()) { - case ngraph::element::Type_t::i64: - case ngraph::element::Type_t::u64: - gru_seq_v5::evaluate(op, outputs, inputs); +template +bool evaluate(const std::shared_ptr& op, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { + switch (inputs[2].get_element_type()) { + case ov::element::i64: + case ov::element::u64: + gru_seq_v5::evaluate(op, outputs, inputs); break; - case ngraph::element::Type_t::i32: - case ngraph::element::Type_t::u32: - gru_seq_v5::evaluate(op, outputs, inputs); + case ov::element::i32: + case ov::element::u32: + gru_seq_v5::evaluate(op, outputs, inputs); break; default: return false; @@ -209,47 +209,47 @@ bool evaluate(const std::shared_ptr& op, } namespace augru_seq { -template +template inline void evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { - using T1 = typename ngraph::element_type_traits::value_type; - using T2 = typename ngraph::element_type_traits::value_type; - ov::reference::gru_sequence(inputs[0]->get_data_ptr(), - inputs[0]->get_shape(), - inputs[1]->get_data_ptr(), - inputs[1]->get_shape(), - inputs[2]->get_data_ptr(), - inputs[2]->get_shape(), - inputs[3]->get_data_ptr(), - inputs[3]->get_shape(), - inputs[4]->get_data_ptr(), - inputs[4]->get_shape(), - inputs[5]->get_data_ptr(), - inputs[5]->get_shape(), - outputs[0]->get_data_ptr(), - outputs[1]->get_data_ptr(), + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { + using T1 = typename ov::element_type_traits::value_type; + using T2 = typename ov::element_type_traits::value_type; + ov::reference::gru_sequence(static_cast(inputs[0].data()), + inputs[0].get_shape(), + static_cast(inputs[1].data()), + inputs[1].get_shape(), + static_cast(inputs[2].data()), + inputs[2].get_shape(), + static_cast(inputs[3].data()), + inputs[3].get_shape(), + static_cast(inputs[4].data()), + inputs[4].get_shape(), + static_cast(inputs[5].data()), + inputs[5].get_shape(), + static_cast(outputs[0].data()), + static_cast(outputs[1].data()), op->get_activations()[0], op->get_activations()[1], op->get_clip(), op->get_direction(), op->get_linear_before_reset(), - inputs[6]->get_data_ptr()); + static_cast(inputs[6].data())); } } // namespace augru_seq -template +template bool evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { - switch (inputs[2]->get_element_type()) { - case ngraph::element::Type_t::i64: - case ngraph::element::Type_t::u64: - augru_seq::evaluate(op, outputs, inputs); + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { + switch (inputs[2].get_element_type()) { + case ov::element::i64: + case ov::element::u64: + augru_seq::evaluate(op, outputs, inputs); break; - case ngraph::element::Type_t::i32: - case ngraph::element::Type_t::u32: - augru_seq::evaluate(op, outputs, inputs); + case ov::element::i32: + case ov::element::u32: + augru_seq::evaluate(op, outputs, inputs); break; default: return false; @@ -258,78 +258,46 @@ bool evaluate(const std::shared_ptr& op, } template <> -bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { auto element_type = node->get_output_element_type(0); - if (ov::is_type(node) || ov::is_type(node)) + if (ov::is_type(node) || ov::is_type(node)) element_type = node->get_input_element_type(1); switch (element_type) { - case ngraph::element::Type_t::boolean: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::bf16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i4: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i8: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u1: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u4: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u8: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); + case ov::element::boolean: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::bf16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u1: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); default: OPENVINO_THROW(std::string("Unhandled data type ") + node->get_element_type().get_type_name() + std::string("in evaluate_node()")); @@ -337,78 +305,46 @@ bool evaluate_node(std::shared_ptr -bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { auto element_type = node->get_output_element_type(0); - if (ov::is_type(node) || ov::is_type(node)) + if (ov::is_type(node) || ov::is_type(node)) element_type = node->get_input_element_type(1); switch (element_type) { - case ngraph::element::Type_t::boolean: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::bf16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i4: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i8: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u1: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u4: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u8: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); + case ov::element::boolean: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::bf16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u1: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); default: OPENVINO_THROW(std::string("Unhandled data type ") + node->get_element_type().get_type_name() + std::string("in evaluate_node()")); @@ -416,78 +352,46 @@ bool evaluate_node(std::shared_ptr no } template <> -bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { auto element_type = node->get_output_element_type(0); - if (ov::is_type(node) || ov::is_type(node)) + if (ov::is_type(node) || ov::is_type(node)) element_type = node->get_input_element_type(1); switch (element_type) { - case ngraph::element::Type_t::boolean: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::bf16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i4: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i8: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u1: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u4: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u8: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); + case ov::element::boolean: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::bf16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u1: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); default: OPENVINO_THROW(std::string("Unhandled data type ") + node->get_element_type().get_type_name() + std::string("in evaluate_node()")); @@ -495,78 +399,46 @@ bool evaluate_node(std::shared_ptr n } template <> -bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { auto element_type = node->get_output_element_type(0); - if (ov::is_type(node) || ov::is_type(node)) + if (ov::is_type(node) || ov::is_type(node)) element_type = node->get_input_element_type(1); switch (element_type) { - case ngraph::element::Type_t::boolean: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::bf16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i4: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i8: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u1: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u4: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u8: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); + case ov::element::boolean: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::bf16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u1: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); default: OPENVINO_THROW(std::string("Unhandled data type ") + node->get_element_type().get_type_name() + std::string("in evaluate_node()")); @@ -574,80 +446,47 @@ bool evaluate_node(std::shared_ptr n } template <> -bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { auto element_type = node->get_output_element_type(0); - if (ov::is_type(node) || ov::is_type(node)) + if (ov::is_type(node) || ov::is_type(node)) element_type = node->get_input_element_type(1); switch (element_type) { - case ngraph::element::Type_t::boolean: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::bf16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i4: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i8: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u1: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u4: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u8: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); + case ov::element::boolean: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::bf16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u1: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); default: - OPENVINO_THROW(std::string("Unhandled data type ") + node->get_element_type().get_type_name() + - std::string("in evaluate_node()")); + OPENVINO_THROW("Unhandled data type ", node->get_element_type().get_type_name(), " in evaluate_node()"); } } diff --git a/src/plugins/template/backend/ops/sigmoid.cpp b/src/plugins/template/backend/ops/sigmoid.cpp index 7123ac4cb72249..9b2307ad884528 100644 --- a/src/plugins/template/backend/ops/sigmoid.cpp +++ b/src/plugins/template/backend/ops/sigmoid.cpp @@ -6,62 +6,57 @@ #include "evaluate_node.hpp" -template -bool evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { - using T = typename ngraph::element_type_traits::value_type; - ov::reference::sigmoid(inputs[0]->get_data_ptr(), - outputs[0]->get_data_ptr(), - ngraph::shape_size(inputs[0]->get_shape())); +template +bool evaluate(const std::shared_ptr& op, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { + using T = typename ov::element_type_traits::value_type; + ov::reference::sigmoid(inputs[0].data(), outputs[0].data(), ov::shape_size(inputs[0].get_shape())); return true; } template <> -bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { auto element_type = node->get_output_element_type(0); - if (ov::is_type(node) || ov::is_type(node)) + if (ov::is_type(node) || ov::is_type(node)) element_type = node->get_input_element_type(1); switch (element_type) { - case ngraph::element::Type_t::boolean: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::bf16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i4: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i8: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u1: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u4: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u8: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::boolean: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::bf16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u1: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); default: - OPENVINO_THROW(std::string("Unhandled data type ") + node->get_element_type().get_type_name() + - std::string("in evaluate_node()")); + OPENVINO_THROW("Unhandled data type ", node->get_element_type().get_type_name(), " in evaluate_node()"); } } diff --git a/src/plugins/template/backend/ops/sign.cpp b/src/plugins/template/backend/ops/sign.cpp index 663a7a702be43b..c273c59afb5cc3 100644 --- a/src/plugins/template/backend/ops/sign.cpp +++ b/src/plugins/template/backend/ops/sign.cpp @@ -6,60 +6,55 @@ #include "evaluate_node.hpp" -template -bool evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { - using T = typename ngraph::element_type_traits::value_type; - ov::reference::sign(inputs[0]->get_data_ptr(), - outputs[0]->get_data_ptr(), - ngraph::shape_size(inputs[0]->get_shape())); +template +bool evaluate(const std::shared_ptr& op, ov::TensorVector& outputs, const ov::TensorVector& inputs) { + using T = typename ov::element_type_traits::value_type; + ov::reference::sign(inputs[0].data(), outputs[0].data(), ov::shape_size(inputs[0].get_shape())); return true; } template <> -bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { auto element_type = node->get_output_element_type(0); - if (ov::is_type(node) || ov::is_type(node)) + if (ov::is_type(node) || ov::is_type(node)) element_type = node->get_input_element_type(1); switch (element_type) { - case ngraph::element::Type_t::boolean: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::bf16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i4: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i8: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u1: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u4: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u8: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::boolean: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::bf16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u1: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); default: - OPENVINO_THROW(std::string("Unhandled data type ") + node->get_element_type().get_type_name() + - std::string("in evaluate_node()")); + OPENVINO_THROW("Unhandled data type ", node->get_element_type().get_type_name(), " in evaluate_node()"); } } diff --git a/src/plugins/template/backend/ops/softsign.cpp b/src/plugins/template/backend/ops/softsign.cpp index 97885e733ee056..cd4c639bff8b6b 100644 --- a/src/plugins/template/backend/ops/softsign.cpp +++ b/src/plugins/template/backend/ops/softsign.cpp @@ -6,31 +6,31 @@ #include "evaluate_node.hpp" -template -bool evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { - ngraph::element::Type input_et = op->get_input_element_type(0); +template +bool evaluate(const std::shared_ptr& op, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { + ov::element::Type input_et = op->get_input_element_type(0); switch (input_et) { - case ngraph::element::Type_t::f64: - ov::reference::softsign(inputs[0]->get_data_ptr(), - outputs[0]->get_data_ptr(), - ngraph::shape_size(inputs[0]->get_shape())); + case ov::element::f64: + ov::reference::softsign(inputs[0].data(), + outputs[0].data(), + ov::shape_size(inputs[0].get_shape())); break; - case ngraph::element::Type_t::f32: - ov::reference::softsign(inputs[0]->get_data_ptr(), - outputs[0]->get_data_ptr(), - ngraph::shape_size(inputs[0]->get_shape())); + case ov::element::f32: + ov::reference::softsign(inputs[0].data(), + outputs[0].data(), + ov::shape_size(inputs[0].get_shape())); break; - case ngraph::element::Type_t::f16: - ov::reference::softsign(inputs[0]->get_data_ptr(), - outputs[0]->get_data_ptr(), - ngraph::shape_size(inputs[0]->get_shape())); + case ov::element::f16: + ov::reference::softsign(inputs[0].data(), + outputs[0].data(), + ov::shape_size(inputs[0].get_shape())); break; - case ngraph::element::Type_t::bf16: - ov::reference::softsign(inputs[0]->get_data_ptr(), - outputs[0]->get_data_ptr(), - ngraph::shape_size(inputs[0]->get_shape())); + case ov::element::bf16: + ov::reference::softsign(inputs[0].data(), + outputs[0].data(), + ov::shape_size(inputs[0].get_shape())); break; default: return false; @@ -39,52 +39,47 @@ bool evaluate(const std::shared_ptr& op, } template <> -bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { auto element_type = node->get_output_element_type(0); - if (ov::is_type(node) || ov::is_type(node)) + if (ov::is_type(node) || ov::is_type(node)) element_type = node->get_input_element_type(1); switch (element_type) { - case ngraph::element::Type_t::boolean: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::bf16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i4: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i8: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u1: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u4: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u8: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::boolean: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::bf16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u1: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); default: - OPENVINO_THROW(std::string("Unhandled data type ") + node->get_element_type().get_type_name() + - std::string("in evaluate_node()")); + OPENVINO_THROW("Unhandled data type ", node->get_element_type().get_type_name(), " in evaluate_node()"); } } diff --git a/src/plugins/template/backend/ops/squared_difference.cpp b/src/plugins/template/backend/ops/squared_difference.cpp index 9f8c385e6b6bd0..f861cd2fe62cbe 100644 --- a/src/plugins/template/backend/ops/squared_difference.cpp +++ b/src/plugins/template/backend/ops/squared_difference.cpp @@ -6,95 +6,62 @@ #include "evaluate_node.hpp" -template -bool evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { - using T = typename ngraph::element_type_traits::value_type; - ov::reference::squared_difference(inputs[0]->get_data_ptr(), - inputs[1]->get_data_ptr(), - outputs[0]->get_data_ptr(), - inputs[0]->get_shape(), - inputs[1]->get_shape(), +template +bool evaluate(const std::shared_ptr& op, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { + using T = typename ov::element_type_traits::value_type; + ov::reference::squared_difference(inputs[0].data(), + inputs[1].data(), + outputs[0].data(), + inputs[0].get_shape(), + inputs[1].get_shape(), op->get_autob()); return true; } template <> -bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { auto element_type = node->get_output_element_type(0); - if (ov::is_type(node) || ov::is_type(node)) + if (ov::is_type(node) || ov::is_type(node)) element_type = node->get_input_element_type(1); switch (element_type) { - case ngraph::element::Type_t::boolean: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::bf16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i4: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i8: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u1: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u4: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u8: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); + case ov::element::boolean: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::bf16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u1: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); default: - OPENVINO_THROW(std::string("Unhandled data type ") + node->get_element_type().get_type_name() + - std::string("in evaluate_node()")); + OPENVINO_THROW("Unhandled data type ", node->get_element_type().get_type_name(), " in evaluate_node()"); } } diff --git a/src/plugins/template/backend/ops/tanh.cpp b/src/plugins/template/backend/ops/tanh.cpp index c85c5827a95fab..cb0c35246f09a9 100644 --- a/src/plugins/template/backend/ops/tanh.cpp +++ b/src/plugins/template/backend/ops/tanh.cpp @@ -2,65 +2,59 @@ // SPDX-License-Identifier: Apache-2.0 // -// clang-format off -#include "evaluate_node.hpp" #include "openvino/reference/tanh.hpp" -// clang-format on -template -bool evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { - using T = typename ngraph::element_type_traits::value_type; - ov::reference::tanh(inputs[0]->get_data_ptr(), - outputs[0]->get_data_ptr(), - ngraph::shape_size(inputs[0]->get_shape())); +#include "evaluate_node.hpp" + +template +bool evaluate(const std::shared_ptr& op, ov::TensorVector& outputs, const ov::TensorVector& inputs) { + using T = typename ov::element_type_traits::value_type; + ov::reference::tanh(inputs[0].data(), outputs[0].data(), ov::shape_size(inputs[0].get_shape())); return true; } template <> -bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { auto element_type = node->get_output_element_type(0); - if (ov::is_type(node) || ov::is_type(node)) + if (ov::is_type(node) || ov::is_type(node)) element_type = node->get_input_element_type(1); switch (element_type) { - case ngraph::element::Type_t::boolean: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::bf16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i4: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i8: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u1: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u4: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u8: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::boolean: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::bf16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u1: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); default: - OPENVINO_THROW(std::string("Unhandled data type ") + node->get_element_type().get_type_name() + - std::string("in evaluate_node()")); + OPENVINO_THROW("Unhandled data type ", node->get_element_type().get_type_name(), " in evaluate_node()"); } } diff --git a/src/plugins/template/backend/ops/tensor_iterator.cpp b/src/plugins/template/backend/ops/tensor_iterator.cpp index 4266186b592315..8b3fbd62874b27 100644 --- a/src/plugins/template/backend/ops/tensor_iterator.cpp +++ b/src/plugins/template/backend/ops/tensor_iterator.cpp @@ -9,9 +9,8 @@ #include "tensor_conversion_util.hpp" namespace ti_v0 { -ov::reference::custom_evaluate_function evaluate = [](const std::shared_ptr& function, - const ngraph::HostTensorVector& inputs, - ngraph::HostTensorVector& outputs) -> void { +ov::reference::custom_evaluate_function evaluate = + [](const std::shared_ptr& function, const ov::TensorVector& inputs, ov::TensorVector& outputs) -> void { const auto& parameters = function->get_parameters(); const auto& parametersNumber = parameters.size(); const auto& inputsNumber = inputs.size(); @@ -27,25 +26,19 @@ ov::reference::custom_evaluate_function evaluate = [](const std::shared_ptrget_results(); outputs.reserve(results.size()); for (size_t i = 0; i < results.size(); ++i) { - outputs.push_back(std::make_shared(results[i]->output(0))); + outputs.push_back(ov::Tensor(results[i]->output(0))); } auto backend = ov::runtime::Backend::create(); auto handle = backend->compile(function); - OPENVINO_SUPPRESS_DEPRECATED_START - auto outputTensors = ov::util::wrap_tensors(outputs); - auto inputTensors = ov::util::wrap_tensors(inputs); - handle->call_with_validate(outputTensors, inputTensors); - - ov::util::update_output_host_tensors(outputs, outputTensors); - OPENVINO_SUPPRESS_DEPRECATED_END + handle->call_with_validate(outputs, inputs); }; } // namespace ti_v0 -template -bool evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +template +bool evaluate(const std::shared_ptr& op, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { ov::reference::tensor_iterator(op->get_num_iterations(), op->get_function(), op->get_output_descriptions(), @@ -57,80 +50,47 @@ bool evaluate(const std::shared_ptr& op, } template <> -bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { auto element_type = node->get_output_element_type(0); - if (ov::is_type(node) || ov::is_type(node)) + if (ov::is_type(node) || ov::is_type(node)) element_type = node->get_input_element_type(1); switch (element_type) { - case ngraph::element::Type_t::boolean: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::bf16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::f32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i4: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i8: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::i64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u1: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u4: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u8: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u16: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u32: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::u64: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); + case ov::element::boolean: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::bf16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u1: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); default: - OPENVINO_THROW(std::string("Unhandled data type ") + node->get_element_type().get_type_name() + - std::string("in evaluate_node()")); + OPENVINO_THROW("Unhandled data type ", node->get_element_type().get_type_name(), " in evaluate_node()"); } } diff --git a/src/plugins/template/backend/ops/unique.cpp b/src/plugins/template/backend/ops/unique.cpp index da1c0d09e54030..172d2299fa9034 100644 --- a/src/plugins/template/backend/ops/unique.cpp +++ b/src/plugins/template/backend/ops/unique.cpp @@ -7,63 +7,59 @@ #include "evaluate_node.hpp" template -void execute_unique(const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs, - const std::shared_ptr& op) { +void execute_unique(ov::TensorVector& outputs, + const ov::TensorVector& inputs, + const std::shared_ptr& op) { const auto maybe_extract_axis = [&op]() { std::unique_ptr axis; if (op->get_input_size() == 2 && ov::op::util::is_constant(op->input_value(1).get_node())) { const auto axis_constant = - std::dynamic_pointer_cast(op->input_value(1).get_node_shared_ptr()); + std::dynamic_pointer_cast(op->input_value(1).get_node_shared_ptr()); const auto axis_vec = axis_constant->cast_vector(); axis = std::unique_ptr(new int64_t{axis_vec.at(0)}); } return axis; }; - const auto unique_elements = - ov::reference::find_unique_elements(inputs[0]->get_data_ptr(), - inputs[0]->get_shape(), - maybe_extract_axis(), - op->get_sorted()); + const auto unique_elements = ov::reference::find_unique_elements(inputs[0].data(), + inputs[0].get_shape(), + maybe_extract_axis(), + op->get_sorted()); const auto tensor_shapes = - ov::reference::make_tensor_shapes(unique_elements, inputs[0]->get_shape(), maybe_extract_axis()); + ov::reference::make_tensor_shapes(unique_elements, inputs[0].get_shape(), maybe_extract_axis()); auto& out_unique_elements = outputs[0]; auto& out_indices = outputs[1]; auto& out_rev_indices = outputs[2]; auto& out_counts = outputs[3]; - out_unique_elements->set_shape(std::get<0>(tensor_shapes)); - out_indices->set_shape(std::get<1>(tensor_shapes)); - out_rev_indices->set_shape(std::get<2>(tensor_shapes)); - out_counts->set_shape(std::get<1>(tensor_shapes)); + out_unique_elements.set_shape(std::get<0>(tensor_shapes)); + out_indices.set_shape(std::get<1>(tensor_shapes)); + out_rev_indices.set_shape(std::get<2>(tensor_shapes)); + out_counts.set_shape(std::get<1>(tensor_shapes)); - ov::reference::unique(out_unique_elements->get_data_ptr(), - out_indices->get_data_ptr(), - out_rev_indices->get_data_ptr(), - out_counts->get_data_ptr(), - inputs[0]->get_data_ptr(), - inputs[0]->get_shape(), + ov::reference::unique(out_unique_elements.data(), + out_indices.data(), + out_rev_indices.data(), + out_counts.data(), + inputs[0].data(), + inputs[0].get_shape(), std::get<0>(tensor_shapes), unique_elements); } -template -bool evaluate(const std::shared_ptr& op, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { - using Data_t = typename ngraph::element_type_traits::value_type; - if (op->get_index_element_type() == ngraph::element::i32 && op->get_count_element_type() == ngraph::element::i32) { +template +bool evaluate(const std::shared_ptr& op, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { + using Data_t = typename ov::element_type_traits::value_type; + if (op->get_index_element_type() == ov::element::i32 && op->get_count_element_type() == ov::element::i32) { execute_unique(outputs, inputs, op); - } else if (op->get_index_element_type() == ngraph::element::i64 && - op->get_count_element_type() == ngraph::element::i64) { + } else if (op->get_index_element_type() == ov::element::i64 && op->get_count_element_type() == ov::element::i64) { execute_unique(outputs, inputs, op); - } else if (op->get_index_element_type() == ngraph::element::i32 && - op->get_count_element_type() == ngraph::element::i64) { + } else if (op->get_index_element_type() == ov::element::i32 && op->get_count_element_type() == ov::element::i64) { execute_unique(outputs, inputs, op); - } else if (op->get_index_element_type() == ngraph::element::i64 && - op->get_count_element_type() == ngraph::element::i32) { + } else if (op->get_index_element_type() == ov::element::i64 && op->get_count_element_type() == ov::element::i32) { execute_unique(outputs, inputs, op); } else { return false; @@ -73,50 +69,47 @@ bool evaluate(const std::shared_ptr& op, } template <> -bool evaluate_node(std::shared_ptr node, - const ngraph::HostTensorVector& outputs, - const ngraph::HostTensorVector& inputs) { +bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { auto element_type = node->get_output_element_type(0); - if (ov::is_type(node) || ov::is_type(node)) + if (ov::is_type(node) || ov::is_type(node)) element_type = node->get_input_element_type(1); switch (element_type) { - case ngraph::element::Type_t::boolean: - return evaluate(ov::as_type_ptr(node), - outputs, - inputs); - case ngraph::element::Type_t::bf16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::f32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i4: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i8: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::i64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u1: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u4: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u8: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u16: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u32: - return evaluate(ov::as_type_ptr(node), outputs, inputs); - case ngraph::element::Type_t::u64: - return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::boolean: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::bf16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::f32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::i64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u1: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u4: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u8: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u16: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u32: + return evaluate(ov::as_type_ptr(node), outputs, inputs); + case ov::element::u64: + return evaluate(ov::as_type_ptr(node), outputs, inputs); default: - OPENVINO_THROW(std::string("Unhandled data type ") + node->get_element_type().get_type_name() + - std::string("in evaluate_node()")); + OPENVINO_THROW("Unhandled data type ", node->get_element_type().get_type_name(), " in evaluate_node()"); } } diff --git a/src/plugins/template/backend/opset_int_tbl.hpp b/src/plugins/template/backend/opset_int_tbl.hpp index f65bf093a800cb..c94db72de7728f 100644 --- a/src/plugins/template/backend/opset_int_tbl.hpp +++ b/src/plugins/template/backend/opset_int_tbl.hpp @@ -12,7 +12,7 @@ _OPENVINO_OP_REG(BatchNormInference, op::v0) _OPENVINO_OP_REG(Ceiling, op::v0) _OPENVINO_OP_REG(Convert, op::v0) _OPENVINO_OP_REG(CTCGreedyDecoder, op::v0) -_OPENVINO_OP_REG(CumSum, ngraph::op::v0) +_OPENVINO_OP_REG(CumSum, op::v0) _OPENVINO_OP_REG(DetectionOutput, op::v0) _OPENVINO_OP_REG(Elu, op::v0) _OPENVINO_OP_REG(FakeQuantize, op::v0) @@ -20,13 +20,13 @@ _OPENVINO_OP_REG(Gelu, op::v0) _OPENVINO_OP_REG(GRN, op::v0) _OPENVINO_OP_REG(HardSigmoid, op::v0) _OPENVINO_OP_REG(Interpolate, op::v0) -_OPENVINO_OP_REG(LRN, ngraph::op::v0) +_OPENVINO_OP_REG(LRN, op::v0) _OPENVINO_OP_REG(LSTMCell, op::v0) _OPENVINO_OP_REG(LSTMSequence, op::v0) -_OPENVINO_OP_REG(MVN, ngraph::op::v0) +_OPENVINO_OP_REG(MVN, op::v0) _OPENVINO_OP_REG(NormalizeL2, op::v0) -_OPENVINO_OP_REG(PriorBox, ngraph::op::v0) -_OPENVINO_OP_REG(Proposal, ngraph::op::v0) +_OPENVINO_OP_REG(PriorBox, op::v0) +_OPENVINO_OP_REG(Proposal, op::v0) _OPENVINO_OP_REG(PSROIPooling, op::v0) _OPENVINO_OP_REG(RegionYolo, op::v0) _OPENVINO_OP_REG(Relu, op::v0) @@ -40,16 +40,16 @@ _OPENVINO_OP_REG(TensorIterator, op::v0) _OPENVINO_OP_REG(ROIPooling, op::v0) _OPENVINO_OP_REG(AvgPool, op::v1) -_OPENVINO_OP_REG(BinaryConvolution, ngraph::op::v1) +_OPENVINO_OP_REG(BinaryConvolution, op::v1) _OPENVINO_OP_REG(ConvertLike, op::v1) -_OPENVINO_OP_REG(Convolution, ngraph::op::v1) -_OPENVINO_OP_REG(ConvolutionBackpropData, ngraph::op::v1) -_OPENVINO_OP_REG(DeformablePSROIPooling, ngraph::op::v1) -_OPENVINO_OP_REG(Equal, ngraph::op::v1) -_OPENVINO_OP_REG(Greater, ngraph::op::v1) -_OPENVINO_OP_REG(GroupConvolution, ngraph::op::v1) -_OPENVINO_OP_REG(GroupConvolutionBackpropData, ngraph::op::v1) -_OPENVINO_OP_REG(DeformableConvolution, ngraph::op::v1) +_OPENVINO_OP_REG(Convolution, op::v1) +_OPENVINO_OP_REG(ConvolutionBackpropData, op::v1) +_OPENVINO_OP_REG(DeformablePSROIPooling, op::v1) +_OPENVINO_OP_REG(Equal, op::v1) +_OPENVINO_OP_REG(Greater, op::v1) +_OPENVINO_OP_REG(GroupConvolution, op::v1) +_OPENVINO_OP_REG(GroupConvolutionBackpropData, op::v1) +_OPENVINO_OP_REG(DeformableConvolution, op::v1) _OPENVINO_OP_REG(LessEqual, op::v1) _OPENVINO_OP_REG(LogicalAnd, op::v1) _OPENVINO_OP_REG(LogicalOr, op::v1) @@ -67,11 +67,11 @@ _OPENVINO_OP_REG(GatherTree, op::v1) _OPENVINO_OP_REG(Assign, op::v3) _OPENVINO_OP_REG(Bucketize, op::v3) -_OPENVINO_OP_REG(EmbeddingBagOffsetsSum, ngraph::op::v3) -_OPENVINO_OP_REG(EmbeddingBagPackedSum, ngraph::op::v3) +_OPENVINO_OP_REG(EmbeddingBagOffsetsSum, op::v3) +_OPENVINO_OP_REG(EmbeddingBagPackedSum, op::v3) _OPENVINO_OP_REG(ExtractImagePatches, op::v3) -_OPENVINO_OP_REG(EmbeddingSegmentsSum, ngraph::op::v3) -_OPENVINO_OP_REG(GRUCell, ngraph::op::v3) +_OPENVINO_OP_REG(EmbeddingSegmentsSum, op::v3) +_OPENVINO_OP_REG(GRUCell, op::v3) _OPENVINO_OP_REG(NonMaxSuppression, op::v3) _OPENVINO_OP_REG(NonZero, op::v3) _OPENVINO_OP_REG(ReadValue, op::v3) @@ -94,7 +94,7 @@ _OPENVINO_OP_REG(NonMaxSuppression, op::v5) _OPENVINO_OP_REG(RNNSequence, op::v5) _OPENVINO_OP_REG(Round, op::v5) -_OPENVINO_OP_REG(Assign, ngraph::op::v6) +_OPENVINO_OP_REG(Assign, op::v6) _OPENVINO_OP_REG(CTCGreedyDecoderSeqLen, op::v6) _OPENVINO_OP_REG(ExperimentalDetectronDetectionOutput, op::v6) _OPENVINO_OP_REG(ExperimentalDetectronGenerateProposalsSingleImage, op::v6) @@ -103,21 +103,21 @@ _OPENVINO_OP_REG(ExperimentalDetectronPriorGridGenerator, op::v6) _OPENVINO_OP_REG(ExperimentalDetectronROIFeatureExtractor, op::v6) _OPENVINO_OP_REG(ExperimentalDetectronTopKROIs, op::v6) _OPENVINO_OP_REG(GatherElements, op::v6) -_OPENVINO_OP_REG(MVN, ngraph::op::v6) -_OPENVINO_OP_REG(ReadValue, ngraph::op::v6) +_OPENVINO_OP_REG(MVN, op::v6) +_OPENVINO_OP_REG(ReadValue, op::v6) _OPENVINO_OP_REG(DFT, op::v7) _OPENVINO_OP_REG(Einsum, op::v7) _OPENVINO_OP_REG(IDFT, op::v7) -_OPENVINO_OP_REG(Roll, ngraph::op::v7) +_OPENVINO_OP_REG(Roll, op::v7) -_OPENVINO_OP_REG(AdaptiveAvgPool, ngraph::op::v8) -_OPENVINO_OP_REG(AdaptiveMaxPool, ngraph::op::v8) +_OPENVINO_OP_REG(AdaptiveAvgPool, op::v8) +_OPENVINO_OP_REG(AdaptiveMaxPool, op::v8) _OPENVINO_OP_REG(Gather, op::v8) _OPENVINO_OP_REG(MatrixNms, op::v8) _OPENVINO_OP_REG(MulticlassNms, op::v8) -_OPENVINO_OP_REG(DeformableConvolution, ngraph::op::v8) -_OPENVINO_OP_REG(If, ngraph::op::v8) +_OPENVINO_OP_REG(DeformableConvolution, op::v8) +_OPENVINO_OP_REG(If, op::v8) _OPENVINO_OP_REG(GatherND, op::v8) _OPENVINO_OP_REG(DetectionOutput, op::v8) _OPENVINO_OP_REG(NV12toRGB, op::v8) @@ -129,7 +129,7 @@ _OPENVINO_OP_REG(Sigmoid, op::v0) _OPENVINO_OP_REG(Tanh, op::v0) _OPENVINO_OP_REG(Exp, op::v0) _OPENVINO_OP_REG(Log, op::v0) -_OPENVINO_OP_REG(PriorBox, ngraph::op::v8) +_OPENVINO_OP_REG(PriorBox, op::v8) _OPENVINO_OP_REG(PRelu, op::v0) _OPENVINO_OP_REG(GridSample, op::v9) From 35d0d92ef7d665f238e835ed3ea3d760476dde76 Mon Sep 17 00:00:00 2001 From: Evgeny Kotov Date: Tue, 19 Sep 2023 11:55:43 +0200 Subject: [PATCH 26/30] fix TSGatherForward transformation (#19821) * fix ts_gather_forward * remove unneeded header --- .../transpose_sinking/ts_gather.cpp | 10 ++++---- .../transpose_sinking/ts_gather_test.cpp | 25 +++++++++++++++++-- .../tests/transpose_sinking/ts_test_utils.cpp | 13 ++++++++++ .../tests/transpose_sinking/ts_test_utils.hpp | 3 +++ 4 files changed, 44 insertions(+), 7 deletions(-) diff --git a/src/common/transformations/src/transformations/transpose_sinking/ts_gather.cpp b/src/common/transformations/src/transformations/transpose_sinking/ts_gather.cpp index d7609c935f1d61..42fa6f85cc61cf 100644 --- a/src/common/transformations/src/transformations/transpose_sinking/ts_gather.cpp +++ b/src/common/transformations/src/transformations/transpose_sinking/ts_gather.cpp @@ -57,16 +57,17 @@ TSGatherForward::TSGatherForward() { } } - size_t axis; + size_t order_axis; if (axes[0] < 0) { auto data_rank = main_node->get_input_partial_shape(0).rank(); if (data_rank.is_dynamic()) { return false; } - axis = static_cast(axes[0] + data_rank.get_length()); + order_axis = static_cast(axes[0] + data_rank.get_length()); } else { - axis = static_cast(axes[0]); + order_axis = static_cast(axes[0]); } + const size_t axis = order_val[order_axis]; /* https://docs.openvino.ai/2023.0/openvino_docs_ops_movement_Gather_8.html The Gather output shape has the same shape as the input, @@ -136,8 +137,7 @@ TSGatherForward::TSGatherForward() { if (!success) { return false; } - auto new_axis = - ov::op::v0::Constant::create(gather_axis->get_element_type(), gather_axis->get_shape(), {order_val[axis]}); + auto new_axis = ov::op::v0::Constant::create(gather_axis->get_element_type(), gather_axis->get_shape(), {axis}); main_node->input(2).replace_source_output(new_axis); copy_runtime_info(gather_axis, new_axis); diff --git a/src/common/transformations/tests/transpose_sinking/ts_gather_test.cpp b/src/common/transformations/tests/transpose_sinking/ts_gather_test.cpp index 34586bcdd81178..2a410fb0181333 100644 --- a/src/common/transformations/tests/transpose_sinking/ts_gather_test.cpp +++ b/src/common/transformations/tests/transpose_sinking/ts_gather_test.cpp @@ -63,6 +63,7 @@ auto wrapper = [](const TestCase& test_case) { struct GatherForwardArguments { OutputVector inputs_to_main; + std::function&, const OutputVector&)> create_input_transpose_to_main; Output new_Gather_first_input; AxisVector new_transpose_order; }; @@ -76,7 +77,7 @@ auto test_forward_gather = [](const GatherForwardArguments& test_arguments) { test_case.inputs_to_main = test_arguments.inputs_to_main; // Test model description: - test_case.model.preprocess_inputs_to_main = {{set_transpose_for}, {{0}}}; + test_case.model.preprocess_inputs_to_main = {{test_arguments.create_input_transpose_to_main}, {{0}}}; test_case.model.main_op = {CREATE_GATHER_FACTORY(Gather)}; test_case.model.model_template = create_model; @@ -104,24 +105,44 @@ auto test_forward_gather = [](const GatherForwardArguments& test_arguments) { return wrapper(test_case); }; +class SetTransposeWithOrder { +public: + SetTransposeWithOrder(const AxisVector& order) : _order(order) {} + OutputVector operator()(const vector& idxs, const OutputVector& out_vec) const { + return set_transpose_with_order(idxs, out_vec, _order); + } + +private: + const AxisVector _order; +}; + vector tests_arguments_fw{ {{{parameter(f32, {3, 4, 5, 6}), constant(i32, {2}, {0, 2}), constant(i32, {1}, {2})}}, + set_transpose_for, constant(i32, {1}, {1}), AxisVector{3, 2, 1, 0}}, {{parameter(f32, {2, 4}), constant(i32, {}, {0}), constant(i32, {1}, {1})}, + set_transpose_for, constant(i32, {1}, {0}), AxisVector{0}}, {{parameter(f32, {2, 4}), constant(i32, {1}, {0}), constant(i32, {1}, {1})}, + set_transpose_for, constant(i32, {1}, {0}), AxisVector{1, 0}}, {{parameter(f32, {2, 3, 4}), constant(i32, {2, 3}, {0, 1, 0, 1, 0, 1}), constant(i32, {1}, {1})}, + set_transpose_for, constant(i32, {1}, {1}), - AxisVector{3, 1, 2, 0}}}; + AxisVector{3, 1, 2, 0}}, + {{parameter(f32, {64, 49, 3, 3, 32}), constant(i32, {}, {1}), constant(i32, {}, {0})}, + SetTransposeWithOrder(AxisVector{2, 0, 3, 1, 4}), + constant(i32, {}, {2}), + AxisVector{0, 2, 1, 3}}}; INSTANTIATE_TEST_SUITE_P(TSCommonGatherForward_0, TSTestFixture, test_forward_gather(tests_arguments_fw[0])); INSTANTIATE_TEST_SUITE_P(TSCommonGatherForward_1, TSTestFixture, test_forward_gather(tests_arguments_fw[1])); INSTANTIATE_TEST_SUITE_P(TSCommonGatherForward_2, TSTestFixture, test_forward_gather(tests_arguments_fw[2])); INSTANTIATE_TEST_SUITE_P(TSCommonGatherForward_3, TSTestFixture, test_forward_gather(tests_arguments_fw[3])); +INSTANTIATE_TEST_SUITE_P(TSCommonGatherForward_4, TSTestFixture, test_forward_gather(tests_arguments_fw[4])); struct GatherBackwardArguments { OutputVector inputs_to_main; diff --git a/src/common/transformations/tests/transpose_sinking/ts_test_utils.cpp b/src/common/transformations/tests/transpose_sinking/ts_test_utils.cpp index d0a81c5dd404bf..31be099f03a868 100644 --- a/src/common/transformations/tests/transpose_sinking/ts_test_utils.cpp +++ b/src/common/transformations/tests/transpose_sinking/ts_test_utils.cpp @@ -52,6 +52,19 @@ OutputVector set_transpose_for(const vector& idxs, const OutputVector& o return result; } +OutputVector set_transpose_with_order(const vector& idxs, + const OutputVector& out_vec, + const vector& transpose_order_axes) { + OutputVector result = out_vec; + for (const auto& idx : idxs) { + const auto& out = out_vec[idx]; + auto order = make_shared(element::i32, Shape{transpose_order_axes.size()}, transpose_order_axes); + auto transpose = make_shared(out, order); + result[idx] = transpose; + } + return result; +} + OutputVector set_gather_for(const vector& idxs, const OutputVector& out_vec) { OutputVector result = out_vec; for (const auto& idx : idxs) { diff --git a/src/common/transformations/tests/transpose_sinking/ts_test_utils.hpp b/src/common/transformations/tests/transpose_sinking/ts_test_utils.hpp index 826d75e0b1bcdb..cc8685c1d7e911 100644 --- a/src/common/transformations/tests/transpose_sinking/ts_test_utils.hpp +++ b/src/common/transformations/tests/transpose_sinking/ts_test_utils.hpp @@ -21,6 +21,9 @@ std::string to_string(const ov::Shape& shape); ov::ParameterVector filter_parameters(const ov::OutputVector& out_vec); ov::OutputVector set_transpose_for(const std::vector& idxs, const ov::OutputVector& out_vec); +ov::OutputVector set_transpose_with_order(const std::vector& idxs, + const ov::OutputVector& out_vec, + const std::vector& transpose_order_axes); ov::OutputVector set_gather_for(const std::vector& idxs, const ov::OutputVector& out_vec); std::shared_ptr create_main_node(const ov::OutputVector& inputs, size_t num_ops, const FactoryPtr& creator); From 2de9df8832991874edf8191478bc39374df621ea Mon Sep 17 00:00:00 2001 From: Sofya Balandina Date: Tue, 19 Sep 2023 11:00:14 +0100 Subject: [PATCH 27/30] [apiConformance] Remove bf16 precision as unsupported (#19761) --- .../behavior/ov_infer_request/io_tensor.cpp | 19 ++++++++++++++++++- .../behavior/ov_infer_request/io_tensor.cpp | 5 ----- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/tests/functional/plugin/conformance/test_runner/api_conformance_runner/src/behavior/ov_infer_request/io_tensor.cpp b/src/tests/functional/plugin/conformance/test_runner/api_conformance_runner/src/behavior/ov_infer_request/io_tensor.cpp index e1858a17781514..5d741f5f8148e7 100644 --- a/src/tests/functional/plugin/conformance/test_runner/api_conformance_runner/src/behavior/ov_infer_request/io_tensor.cpp +++ b/src/tests/functional/plugin/conformance/test_runner/api_conformance_runner/src/behavior/ov_infer_request/io_tensor.cpp @@ -20,7 +20,6 @@ INSTANTIATE_TEST_SUITE_P(ov_infer_request_mandatory, OVInferRequestIOTensorTest, std::vector ovIOTensorElemTypes = { ov::element::boolean, - ov::element::bf16, ov::element::f16, ov::element::f32, ov::element::f64, @@ -47,4 +46,22 @@ INSTANTIATE_TEST_SUITE_P(ov_infer_request_mandatory, OVInferRequestCheckTensorPr ::testing::ValuesIn(return_all_possible_device_combination()), ::testing::Values(pluginConfig)), OVInferRequestCheckTensorPrecision::getTestCaseName); + +std::vector ovIOTensorElemTypesOptional = { + ov::element::bf16 +}; + +INSTANTIATE_TEST_SUITE_P(ov_infer_request, OVInferRequestIOTensorSetPrecisionTest, + ::testing::Combine( + ::testing::ValuesIn(ovIOTensorElemTypesOptional), + ::testing::ValuesIn(return_all_possible_device_combination()), + ::testing::Values(pluginConfig)), + OVInferRequestIOTensorSetPrecisionTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(ov_infer_request, OVInferRequestCheckTensorPrecision, + ::testing::Combine( + ::testing::ValuesIn(ovIOTensorElemTypesOptional), + ::testing::ValuesIn(return_all_possible_device_combination()), + ::testing::Values(pluginConfig)), + OVInferRequestCheckTensorPrecision::getTestCaseName); } // namespace diff --git a/src/tests/functional/plugin/shared/src/behavior/ov_infer_request/io_tensor.cpp b/src/tests/functional/plugin/shared/src/behavior/ov_infer_request/io_tensor.cpp index 59fbc9b10852d2..344f0e57daf5d0 100644 --- a/src/tests/functional/plugin/shared/src/behavior/ov_infer_request/io_tensor.cpp +++ b/src/tests/functional/plugin/shared/src/behavior/ov_infer_request/io_tensor.cpp @@ -325,11 +325,6 @@ void OVInferRequestCheckTensorPrecision::createInferRequest() { try { compModel = core->compile_model(model, target_device, config); request = compModel.create_infer_request(); - - if (std::count(precisions.begin(), precisions.end(), element_type) == 0) { - FAIL() << "Precision " << element_type.c_type_string() - << " is marked as unsupported but the network was loaded successfully"; - } } catch (std::runtime_error& e) { const std::string errorMsg = e.what(); const auto expectedMsg = exp_error_str_; From a139fb48b796bcefa4ff263cbee1d8293090a6eb Mon Sep 17 00:00:00 2001 From: Roman Kazantsev Date: Tue, 19 Sep 2023 14:00:54 +0400 Subject: [PATCH 28/30] [TF FE][JAX] Add upper bound for jax dependencies (#19943) Signed-off-by: Kazantsev, Roman --- tests/constraints.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/constraints.txt b/tests/constraints.txt index aae862f09a37c7..3f5a718dff257a 100644 --- a/tests/constraints.txt +++ b/tests/constraints.txt @@ -20,3 +20,5 @@ pytest>=5.0,<7.5 pytest-dependency==0.5.1 pytest-html==3.2.0 pytest-timeout==2.1.0 +jax<=0.4.14 +jaxlib<=0.4.14 From ca344aea541da2df0d3358a52a6a1b35e667a7cb Mon Sep 17 00:00:00 2001 From: Vitaliy Urusovskij Date: Tue, 19 Sep 2023 15:46:13 +0400 Subject: [PATCH 29/30] `TensorIteratorTest` to API2.0 (#19869) * `TensorIteratorTest` to API2.0 * Port `TensorIteratorBody` to ov::test::utils --- .../single_layer_tests/tensor_iterator.cpp | 94 ++++--- .../single_op_tests/tensor_iterator.hpp | 15 ++ .../single_op/tensor_iterator.hpp | 39 +++ .../src/single_op/tensor_iterator.cpp | 238 ++++++++++++++++++ .../ngraph_functions/utils/ngraph_helpers.hpp | 12 +- .../src/utils/ngraph_helpers.cpp | 17 -- .../include/common_test_utils/test_enums.hpp | 9 + .../common_test_utils/src/test_enums.cpp | 17 ++ 8 files changed, 365 insertions(+), 76 deletions(-) create mode 100644 src/tests/functional/plugin/shared/include/single_op_tests/tensor_iterator.hpp create mode 100644 src/tests/functional/shared_test_classes/include/shared_test_classes/single_op/tensor_iterator.hpp create mode 100644 src/tests/functional/shared_test_classes/src/single_op/tensor_iterator.cpp diff --git a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/tensor_iterator.cpp b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/tensor_iterator.cpp index 75e8cfe94225dc..d0c0f7594c72bc 100644 --- a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/tensor_iterator.cpp +++ b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/tensor_iterator.cpp @@ -3,59 +3,57 @@ // #include -#include -#include "single_layer_tests/tensor_iterator.hpp" +#include "single_op_tests/tensor_iterator.hpp" #include "common_test_utils/test_constants.hpp" -using namespace LayerTestsDefinitions; +using ov::test::TensorIteratorTest; namespace { - std::vector should_decompose = {true, false}; - // output values increase rapidly without clip, so use only seq_lengths = 2 - std::vector seq_lengths_zero_clip{2}; - std::vector seq_lengths_clip_non_zero{20}; - std::vector batch{1, 10}; - std::vector hidden_size{1, 10}; - // std::vector input_size{10}; - std::vector sequence_axis{0, 1}; - std::vector body_type - = {ngraph::helpers::TensorIteratorBody::LSTM, ngraph::helpers::TensorIteratorBody::RNN, - ngraph::helpers::TensorIteratorBody::GRU}; - std::vector clip{0.f}; - std::vector clip_non_zeros{0.7f}; - std::vector direction = {ngraph::op::RecurrentSequenceDirection::FORWARD, - ngraph::op::RecurrentSequenceDirection::REVERSE}; - std::vector netPrecisions = {InferenceEngine::Precision::FP32, - InferenceEngine::Precision::FP16}; +std::vector should_decompose = {true, false}; +// output values increase rapidly without clip, so use only seq_lengths = 2 +std::vector seq_lengths_zero_clip{2}; +std::vector seq_lengths_clip_non_zero{20}; +std::vector batch{1, 10}; +std::vector hidden_size{1, 10}; +// std::vector input_size{10}; +std::vector sequence_axis{0, 1}; +std::vector body_type += {ov::test::utils::TensorIteratorBody::LSTM, ov::test::utils::TensorIteratorBody::RNN, + ov::test::utils::TensorIteratorBody::GRU}; +std::vector clip{0.f}; +std::vector clip_non_zeros{0.7f}; +std::vector direction = {ov::op::RecurrentSequenceDirection::FORWARD, + ov::op::RecurrentSequenceDirection::REVERSE}; +std::vector model_types = {ov::element::f32, ov::element::f16}; - INSTANTIATE_TEST_SUITE_P(smoke_TensorIteratorCommon, TensorIteratorTest, - ::testing::Combine( - ::testing::ValuesIn(should_decompose), - ::testing::ValuesIn(seq_lengths_zero_clip), - ::testing::ValuesIn(batch), - ::testing::ValuesIn(hidden_size), - //::testing::ValuesIn(input_size), // hardcoded to 10 due to Combine supports up to 10 args - ::testing::ValuesIn(sequence_axis), - ::testing::ValuesIn(clip), - ::testing::ValuesIn(body_type), - ::testing::ValuesIn(direction), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - TensorIteratorTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_TensorIteratorCommon, TensorIteratorTest, + ::testing::Combine( + ::testing::ValuesIn(should_decompose), + ::testing::ValuesIn(seq_lengths_zero_clip), + ::testing::ValuesIn(batch), + ::testing::ValuesIn(hidden_size), + //::testing::ValuesIn(input_size), // hardcoded to 10 due to Combine supports up to 10 args + ::testing::ValuesIn(sequence_axis), + ::testing::ValuesIn(clip), + ::testing::ValuesIn(body_type), + ::testing::ValuesIn(direction), + ::testing::ValuesIn(model_types), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + TensorIteratorTest::getTestCaseName); - INSTANTIATE_TEST_SUITE_P(smoke_TensorIteratorCommonClip, TensorIteratorTest, - ::testing::Combine( - ::testing::ValuesIn(should_decompose), - ::testing::ValuesIn(seq_lengths_clip_non_zero), - ::testing::ValuesIn(batch), - ::testing::ValuesIn(hidden_size), - //::testing::ValuesIn(input_size), // hardcoded to 10 due to Combine supports up to 10 args - ::testing::ValuesIn(sequence_axis), - ::testing::ValuesIn(clip_non_zeros), - ::testing::ValuesIn(body_type), - ::testing::ValuesIn(direction), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - TensorIteratorTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_TensorIteratorCommonClip, TensorIteratorTest, + ::testing::Combine( + ::testing::ValuesIn(should_decompose), + ::testing::ValuesIn(seq_lengths_clip_non_zero), + ::testing::ValuesIn(batch), + ::testing::ValuesIn(hidden_size), + //::testing::ValuesIn(input_size), // hardcoded to 10 due to Combine supports up to 10 args + ::testing::ValuesIn(sequence_axis), + ::testing::ValuesIn(clip_non_zeros), + ::testing::ValuesIn(body_type), + ::testing::ValuesIn(direction), + ::testing::ValuesIn(model_types), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + TensorIteratorTest::getTestCaseName); } // namespace diff --git a/src/tests/functional/plugin/shared/include/single_op_tests/tensor_iterator.hpp b/src/tests/functional/plugin/shared/include/single_op_tests/tensor_iterator.hpp new file mode 100644 index 00000000000000..f2409efa0cdeb3 --- /dev/null +++ b/src/tests/functional/plugin/shared/include/single_op_tests/tensor_iterator.hpp @@ -0,0 +1,15 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include "shared_test_classes/single_op/tensor_iterator.hpp" + +namespace ov { +namespace test { +TEST_P(TensorIteratorTest, Inference) { + run(); +}; +} // namespace test +} // namespace ov diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_op/tensor_iterator.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_op/tensor_iterator.hpp new file mode 100644 index 00000000000000..27e8a4e420d5ec --- /dev/null +++ b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_op/tensor_iterator.hpp @@ -0,0 +1,39 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include +#include +#include +#include +#include "shared_test_classes/base/ov_subgraph.hpp" +#include "common_test_utils/test_enums.hpp" + +namespace ov { +namespace test { +using TensorIteratorParams = typename std::tuple< + bool, // using unroll tensor iterator transformation + size_t, // seq_lengths + size_t, // batch + size_t, // hidden size + // todo: fix. input size hardcoded to 10 due to limitation (10 args) of gtests Combine() func. + //size_t, // input size + size_t, // sequence axis + float, // clip + ov::test::utils::TensorIteratorBody, // body type + ov::op::RecurrentSequenceDirection, // direction + ov::element::Type, // Model type + ov::test::TargetDevice>; // Device name + +class TensorIteratorTest : public testing::WithParamInterface, + virtual public ov::test::SubgraphBaseTest { +public: + static std::string getTestCaseName(const testing::TestParamInfo &obj); + +protected: + void SetUp() override; +}; +} // namespace test +} // namespace ov diff --git a/src/tests/functional/shared_test_classes/src/single_op/tensor_iterator.cpp b/src/tests/functional/shared_test_classes/src/single_op/tensor_iterator.cpp new file mode 100644 index 00000000000000..7cf3bd44972846 --- /dev/null +++ b/src/tests/functional/shared_test_classes/src/single_op/tensor_iterator.cpp @@ -0,0 +1,238 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "transformations/control_flow/unroll_tensor_iterator.hpp" +#include "shared_test_classes/single_op/tensor_iterator.hpp" +#include "openvino/pass/manager.hpp" +#include "ngraph_functions/builders.hpp" + +namespace ov { +namespace test { +std::string TensorIteratorTest::getTestCaseName(const testing::TestParamInfo &obj) { + bool should_decompose; + size_t seq_lengths; + size_t batch; + size_t hidden_size; + size_t input_size = 10; + size_t sequence_axis; + ov::test::utils::TensorIteratorBody ti_body; + float clip; + ov::op::RecurrentSequenceDirection direction; + ov::element::Type model_type; + std::string target_device; + std::tie(should_decompose, seq_lengths, batch, hidden_size, sequence_axis, clip, ti_body, direction, model_type, + target_device) = obj.param; + std::vector input_shapes = {}; + + switch (ti_body) { + case ov::test::utils::TensorIteratorBody::LSTM: + input_shapes = { + {{batch, input_size}, {batch, hidden_size}, {batch, hidden_size}, {4 * hidden_size, input_size}, + {4 * hidden_size, hidden_size}, {4 * hidden_size}}, + }; + break; + case ov::test::utils::TensorIteratorBody::GRU: + input_shapes = { + {{batch, input_size}, {batch, hidden_size}, {3 * hidden_size, input_size}, + {3 * hidden_size, hidden_size}, {3 * hidden_size}}, + }; + break; + case ov::test::utils::TensorIteratorBody::RNN: + input_shapes = {{batch, input_size}, {batch, hidden_size}, + {hidden_size, input_size}, {hidden_size, hidden_size}, {hidden_size}}; + break; + } + + std::ostringstream result; + result << "unrolling=" << should_decompose << "_"; + result << "seq_len=" << seq_lengths << "_"; + result << "seq_len_axis=" << sequence_axis << "_"; + result << "batch=" << batch << "_"; + result << "hidden_size=" << hidden_size << "_"; + result << "input_size=" << input_size << "_"; + result << "IS=" << ov::test::utils::vec2str(input_shapes) << "_"; + result << "TensorIteratorBody=" << ti_body << "_"; + result << "direction=" << direction << "_"; + result << "clip=" << clip << "_"; + result << "modelType=" << model_type.to_string() << "_"; + result << "targetDevice=" << target_device << "_"; + return result.str(); +} + +void TensorIteratorTest::SetUp() { + size_t seq_lengths; + bool should_decompose; + size_t batch; + size_t hidden_size; + size_t input_size = 10; + size_t sequence_axis; + ov::test::utils::TensorIteratorBody ti_body; + float clip; + ov::op::RecurrentSequenceDirection direction; + ov::element::Type model_type; + std::tie(should_decompose, seq_lengths, batch, hidden_size, sequence_axis, clip, ti_body, direction, model_type, + targetDevice) = this->GetParam(); + std::vector input_shapes; + auto tensor_iterator = std::make_shared(); + + // Each case consist of 3 steps: + // 1. Create TensorIterator body. + // 2. Set PortMap + // 3. Create outer function + auto axis = std::make_shared(ov::element::i64, ov::Shape{1}, + std::vector{static_cast(sequence_axis)}); + switch (ti_body) { + case ov::test::utils::TensorIteratorBody::LSTM: { + input_shapes = { + {{batch, seq_lengths, input_size}, {batch, hidden_size}, {batch, hidden_size}, {4 * hidden_size, input_size}, + {4 * hidden_size, hidden_size}, {4 * hidden_size}}, + }; + if (sequence_axis == 0) { + // swap batch and seq_lengths + std::swap(input_shapes[0][0], input_shapes[0][1]); + } + init_input_shapes(static_shapes_to_test_representation(input_shapes)); + ov::ParameterVector outer_params{std::make_shared(model_type, inputDynamicShapes[0]), + std::make_shared(model_type, inputDynamicShapes[1]), + std::make_shared(model_type, inputDynamicShapes[2])}; + + // 1. Create TensorIterator body. + inputDynamicShapes[0][sequence_axis] = 1; // sliced dimension + ov::ParameterVector body_params{std::make_shared(model_type, inputDynamicShapes[0]), + std::make_shared(model_type, inputDynamicShapes[1]), + std::make_shared(model_type, inputDynamicShapes[2])}; + + auto squeeze = std::make_shared(body_params[0], axis); + std::vector WRB = {input_shapes[3], input_shapes[4], input_shapes[5]}; + ov::OutputVector out_vector = {squeeze, body_params[1], body_params[2]}; + auto lstm_cell = ngraph::builder::makeLSTM(out_vector, WRB, hidden_size, {"sigmoid", "tanh", "tanh"}, {}, {}, clip); + auto unsqueeze = std::make_shared(lstm_cell->output(0), axis); + ov::ResultVector results{std::make_shared(unsqueeze), + std::make_shared(lstm_cell->output(0)), + std::make_shared(lstm_cell->output(1))}; + auto body = std::make_shared(results, body_params, "lstm_cell"); + tensor_iterator->set_function(body); + + // 2. Set PortMap + if (direction == ov::op::RecurrentSequenceDirection::FORWARD) { + tensor_iterator->set_sliced_input(body_params[0], outer_params[0], 0, 1, 1, -1, sequence_axis); + tensor_iterator->get_concatenated_slices(results[0], 0, 1, 1, -1, sequence_axis); + } else if (direction == ov::op::RecurrentSequenceDirection::REVERSE) { + tensor_iterator->set_sliced_input(body_params[0], outer_params[0], -1, -1, 1, 0, sequence_axis); + tensor_iterator->get_concatenated_slices(results[0], -1, -1, 1, 0, sequence_axis); + } else { + OPENVINO_THROW("Bidirectional case is not supported."); + } + + tensor_iterator->set_merged_input(body_params[1], outer_params[1], results[1]); + tensor_iterator->set_merged_input(body_params[2], outer_params[2], results[2]); + tensor_iterator->get_iter_value(results[1]); + tensor_iterator->get_iter_value(results[2]); + + // 3. Outer model + function = std::make_shared(tensor_iterator->outputs(), outer_params); + break; + } + case ov::test::utils::TensorIteratorBody::GRU: { + input_shapes = { + {{batch, seq_lengths, input_size}, {batch, hidden_size}, {3 * hidden_size, input_size}, + {3 * hidden_size, hidden_size}, {3 * hidden_size}}, + }; + if (sequence_axis == 0) { + // swap batch and seq_lengths + std::swap(input_shapes[0][0], input_shapes[0][1]); + } + init_input_shapes(static_shapes_to_test_representation(input_shapes)); + ov::ParameterVector outer_params{std::make_shared(model_type, inputDynamicShapes[0]), + std::make_shared(model_type, inputDynamicShapes[1])}; + + // 1. Create TensorIterator body. + inputDynamicShapes[0][sequence_axis] = 1; // sliced dimension + ov::ParameterVector body_params{std::make_shared(model_type, inputDynamicShapes[0]), + std::make_shared(model_type, inputDynamicShapes[1])}; + + std::vector WRB = {input_shapes[2], input_shapes[3], input_shapes[4]}; + auto squeeze = std::make_shared(body_params[0], axis); + ov::OutputVector out_vector = {squeeze, body_params[1]}; + auto gru_cell = ngraph::builder::makeGRU(out_vector, WRB, hidden_size, {"sigmoid", "tanh"}, + {}, {}, clip, false); + auto unsqueeze = std::make_shared(gru_cell->output(0), axis); + ov::ResultVector results{std::make_shared(gru_cell->output(0)), + std::make_shared(unsqueeze)}; + auto body = std::make_shared(results, body_params, "gru_cell"); + tensor_iterator->set_function(body); + + // 2. Set PortMap + if (direction == ov::op::RecurrentSequenceDirection::FORWARD) { + tensor_iterator->set_sliced_input(body_params[0], outer_params[0], 0, 1, 1, -1, sequence_axis); + tensor_iterator->get_concatenated_slices(results[1], 0, 1, 1, -1, sequence_axis); + } else if (direction == ov::op::RecurrentSequenceDirection::REVERSE) { + tensor_iterator->set_sliced_input(body_params[0], outer_params[0], -1, -1, 1, 0, sequence_axis); + tensor_iterator->get_concatenated_slices(results[1], -1, -1, 1, 0, sequence_axis); + } else { + OPENVINO_THROW("Bidirectional case is not supported."); + } + + tensor_iterator->set_merged_input(body_params[1], outer_params[1], results[0]); + tensor_iterator->get_iter_value(results[0]); + + // 3. Outer function + function = std::make_shared(ov::OutputVector{tensor_iterator->output(0), tensor_iterator->output(1)}, outer_params); + break; + } + case ov::test::utils::TensorIteratorBody::RNN: { + input_shapes = {{batch, seq_lengths, input_size}, + {batch, hidden_size}, + {hidden_size, input_size}, + {hidden_size, hidden_size}, + {hidden_size}}; + if (sequence_axis == 0) { + // swap batch and seq_lengths + std::swap(input_shapes[0][0], input_shapes[0][1]); + } + init_input_shapes(static_shapes_to_test_representation(input_shapes)); + ov::ParameterVector outer_params{std::make_shared(model_type, inputDynamicShapes[0]), + std::make_shared(model_type, inputDynamicShapes[1])}; + + // 1. Create TensorIterator body. + inputDynamicShapes[0][sequence_axis] = 1; // sliced dimension + ov::ParameterVector body_params{std::make_shared(model_type, inputDynamicShapes[0]), + std::make_shared(model_type, inputDynamicShapes[1])}; + std::vector WRB = {input_shapes[2], input_shapes[3], input_shapes[4]}; + auto squeeze = std::make_shared(body_params[0], axis); + ov::OutputVector out_vector = {squeeze, body_params[1]}; + auto rnn_cell = ngraph::builder::makeRNN(out_vector, WRB, hidden_size, {"tanh"}, {}, {}, clip); + auto unsqueeze = std::make_shared(rnn_cell->output(0), axis); + ov::ResultVector results{std::make_shared(rnn_cell), + std::make_shared(unsqueeze)}; + auto body = std::make_shared(results, body_params, "rnn_cell"); + tensor_iterator->set_function(body); + + // 2. Set PortMap + if (direction == ov::op::RecurrentSequenceDirection::FORWARD) { + tensor_iterator->set_sliced_input(body_params[0], outer_params[0], 0, 1, 1, -1, sequence_axis); + tensor_iterator->get_concatenated_slices(results[1], 0, 1, 1, -1, sequence_axis); + } else if (direction == ov::op::RecurrentSequenceDirection::REVERSE) { + tensor_iterator->set_sliced_input(body_params[0], outer_params[0], -1, -1, 1, 0, sequence_axis); + tensor_iterator->get_concatenated_slices(results[1], -1, -1, 1, 0, sequence_axis); + } else { + OPENVINO_THROW("Bidirectional case is not supported."); + } + + tensor_iterator->set_merged_input(body_params[1], outer_params[1], results[0]); + tensor_iterator->get_iter_value(results[0]); + + // 3. Outer function + function = std::make_shared(ov::OutputVector{tensor_iterator->output(0), tensor_iterator->output(1)}, outer_params); + break; + } + } + if (should_decompose) { + ov::pass::Manager m; + m.register_pass(); + m.run_passes(function); + } +} +} // namespace test +} // namespace ov diff --git a/src/tests/ngraph_helpers/ngraph_functions/include/ngraph_functions/utils/ngraph_helpers.hpp b/src/tests/ngraph_helpers/ngraph_functions/include/ngraph_functions/utils/ngraph_helpers.hpp index e8d16e0cfb783b..5d0f3cd4ac7d0b 100644 --- a/src/tests/ngraph_helpers/ngraph_functions/include/ngraph_functions/utils/ngraph_helpers.hpp +++ b/src/tests/ngraph_helpers/ngraph_functions/include/ngraph_functions/utils/ngraph_helpers.hpp @@ -85,19 +85,11 @@ enum QuantizationGranularity { Perchannel }; +using ov::test::utils::TensorIteratorBody; using ov::test::utils::ReductionType; using ov::test::utils::DFTOpType; using ov::test::utils::InputLayerType; using ov::test::utils::PadMode; - - -enum class TensorIteratorBody { - RNN, - GRU, - LSTM, - // CNN todo: implement -}; - using ov::test::utils::SequenceTestsMode; enum class MemoryTransformation { @@ -169,8 +161,6 @@ std::vector convertOutputPrecision(const std::vector const element::Type_t& toPrecision, const size_t elementsCount); -std::ostream& operator<<(std::ostream& os, TensorIteratorBody type); - std::ostream& operator<<(std::ostream& os, MemoryTransformation type); void resize_function(std::shared_ptr function, const std::vector& targetInputStaticShapes); diff --git a/src/tests/ngraph_helpers/ngraph_functions/src/utils/ngraph_helpers.cpp b/src/tests/ngraph_helpers/ngraph_functions/src/utils/ngraph_helpers.cpp index ff28247546f311..6237536c9436e8 100644 --- a/src/tests/ngraph_helpers/ngraph_functions/src/utils/ngraph_helpers.cpp +++ b/src/tests/ngraph_helpers/ngraph_functions/src/utils/ngraph_helpers.cpp @@ -650,23 +650,6 @@ std::vector convertOutputPrecision(const std::vector } } -std::ostream& operator<<(std::ostream& os, TensorIteratorBody type) { - switch (type) { - case TensorIteratorBody::LSTM: - os << "LSTM"; - break; - case TensorIteratorBody::RNN: - os << "RNN"; - break; - case TensorIteratorBody::GRU: - os << "GRU"; - break; - default: - throw std::runtime_error("NOT_SUPPORTED_OP_TYPE"); - } - return os; -} - std::ostream& operator<<(std::ostream& os, MemoryTransformation type) { switch (type) { case MemoryTransformation::NONE: diff --git a/src/tests/test_utils/common_test_utils/include/common_test_utils/test_enums.hpp b/src/tests/test_utils/common_test_utils/include/common_test_utils/test_enums.hpp index 4311535df95697..6e73dd07a5adac 100644 --- a/src/tests/test_utils/common_test_utils/include/common_test_utils/test_enums.hpp +++ b/src/tests/test_utils/common_test_utils/include/common_test_utils/test_enums.hpp @@ -152,6 +152,13 @@ enum class DFTOpType { INVERSE }; +enum class TensorIteratorBody { + RNN, + GRU, + LSTM, + // CNN todo: implement +}; + // clang-format on std::ostream& operator<<(std::ostream& os, const ReductionType& m); @@ -182,6 +189,8 @@ std::ostream& operator<<(std::ostream& os, ov::op::v8::MatrixNms::SortResultType std::ostream& operator<<(std::ostream& os, ov::op::v8::MatrixNms::DecayFunction type); +std::ostream& operator<<(std::ostream& os, TensorIteratorBody type); + } // namespace utils } // namespace test } // namespace ov diff --git a/src/tests/test_utils/common_test_utils/src/test_enums.cpp b/src/tests/test_utils/common_test_utils/src/test_enums.cpp index 446aae2cda769a..8bb1cff3ce77dc 100644 --- a/src/tests/test_utils/common_test_utils/src/test_enums.cpp +++ b/src/tests/test_utils/common_test_utils/src/test_enums.cpp @@ -322,6 +322,23 @@ std::ostream& operator<<(std::ostream& os, op::v8::MatrixNms::DecayFunction type return os; } +std::ostream& operator<<(std::ostream& os, TensorIteratorBody type) { + switch (type) { + case TensorIteratorBody::LSTM: + os << "LSTM"; + break; + case TensorIteratorBody::RNN: + os << "RNN"; + break; + case TensorIteratorBody::GRU: + os << "GRU"; + break; + default: + throw std::runtime_error("NOT_SUPPORTED_OP_TYPE"); + } + return os; +} + } // namespace utils } // namespace test } // namespace ov From f926e0e3920e27d81355f007f3b5dcfb51342ad1 Mon Sep 17 00:00:00 2001 From: Maxim Vafin Date: Tue, 19 Sep 2023 14:02:46 +0200 Subject: [PATCH 30/30] [PT FE] Simplify repeat operation (#19926) --- src/frontends/pytorch/src/op/repeat.cpp | 34 ------------------------- src/frontends/pytorch/src/op_table.cpp | 3 +-- 2 files changed, 1 insertion(+), 36 deletions(-) delete mode 100644 src/frontends/pytorch/src/op/repeat.cpp diff --git a/src/frontends/pytorch/src/op/repeat.cpp b/src/frontends/pytorch/src/op/repeat.cpp deleted file mode 100644 index 15dc03a466ec92..00000000000000 --- a/src/frontends/pytorch/src/op/repeat.cpp +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "openvino/frontend/pytorch/node_context.hpp" -#include "openvino/op/broadcast.hpp" -#include "openvino/op/constant.hpp" -#include "openvino/op/shape_of.hpp" -#include "openvino/op/tile.hpp" -#include "utils.hpp" - -namespace ov { -namespace frontend { -namespace pytorch { -namespace op { - -using namespace ov::op; - -OutputVector translate_repeat(const NodeContext& context) { - num_inputs_check(context, 2, 2); - auto x = context.get_input(0); - auto repeats = context.get_input(1); - auto one = context.mark_node(v0::Constant::create(element::i32, Shape{}, {1})); - auto sizes_shape = context.mark_node(std::make_shared(repeats, element::i32)); - auto expand_shape = context.mark_node(std::make_shared(one, sizes_shape)); - auto expanded_input = - context.mark_node(std::make_shared(x, expand_shape, BroadcastType::BIDIRECTIONAL)); - return {context.mark_node(std::make_shared(expanded_input, repeats))}; -}; - -} // namespace op -} // namespace pytorch -} // namespace frontend -} // namespace ov \ No newline at end of file diff --git a/src/frontends/pytorch/src/op_table.cpp b/src/frontends/pytorch/src/op_table.cpp index 87358dd4d42ee3..4dd60e01b71d7f 100644 --- a/src/frontends/pytorch/src/op_table.cpp +++ b/src/frontends/pytorch/src/op_table.cpp @@ -134,7 +134,6 @@ OP_CONVERTER(translate_randn_like); OP_CONVERTER(translate_reciprocal); OP_CONVERTER(translate_relu6); OP_CONVERTER(translate_remainder); -OP_CONVERTER(translate_repeat); OP_CONVERTER(translate_repeat_interleave); OP_CONVERTER(translate_reshape); OP_CONVERTER(translate_reshape_as); @@ -393,7 +392,7 @@ const std::map get_supported_ops_ts() { {"aten::relu_", op::inplace_op>}, {"aten::relu6", op::translate_relu6}, {"aten::remainder", op::translate_remainder}, - {"aten::repeat", op::translate_repeat}, + {"aten::repeat", op::inplace_op>}, {"aten::repeat_interleave", op::translate_repeat_interleave}, {"aten::reshape", op::translate_reshape}, {"aten::reshape_as", op::translate_reshape_as},