Merge remote-tracking branch 'upstream/master' into ngraph_api_deprecate

This commit is contained in:
Ilya Churaev 2023-05-29 08:14:49 +04:00
commit 5ebb6f79bf
81 changed files with 1216 additions and 1238 deletions

View File

@ -167,14 +167,14 @@ jobs:
echo "CC=aarch64-linux-gnu-gcc-10" >> $(BUILD_OPENVINO)/linux_arm64
echo "CXX=aarch64-linux-gnu-g++-10" >> $(BUILD_OPENVINO)/linux_arm64
# install OpenVINO dependencies
export CMAKE_CXX_COMPILER_LAUNCHER=ccache
export CMAKE_C_COMPILER_LAUNCHER=ccache
conan install $(OPENVINO_REPO_DIR)/conanfile.txt \
-pr:h $(BUILD_OPENVINO)/linux_arm64 \
-s:h arch=armv8 \
-of $(BUILD_OPENVINO) \
-b missing
env:
CMAKE_CXX_COMPILER_LAUNCHER: ccache
CMAKE_C_COMPILER_LAUNCHER: ccache
CCACHE_DIR: $(OPENVINO_CCACHE_DIR)
CCACHE_TEMPDIR: $(TMP_DIR)/ccache
CCACHE_BASEDIR: $(Pipeline.Workspace)
@ -224,8 +224,16 @@ jobs:
- script: cmake --build $(BUILD_OPENVINO) --parallel --config $(BUILD_TYPE) --target install
displayName: 'Install OpenVINO Runtime'
- script: |
source $(BUILD_OPENVINO)/conanbuild.sh
$(INSTALL_OPENVINO)/samples/cpp/build_samples.sh
source $(BUILD_OPENVINO)/deactivate_conanbuild.sh
env:
CMAKE_TOOLCHAIN_FILE: $(BUILD_OPENVINO)/conan_toolchain.cmake
displayName: 'Build OpenVINO C++ samples'
- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: $(Build.ArtifactStagingDirectory)
PathtoPublish: $(INSTALL_OPENVINO)
ArtifactName: 'openvino_aarch64_linux'
displayName: 'Publish OpenVINO Runtime for ARM'

View File

@ -3,10 +3,11 @@
#
if(DEFINED BUILD_SHARED_LIBS AND NOT BUILD_SHARED_LIBS)
# 'target_link_libraries' does not work correctly when called from
# 3.17: 'target_link_libraries' does not work correctly when called from
# different directory where 'add_library' is called: CMake generates
# incorrect OpenVINOConfig.cmake in this case
cmake_minimum_required(VERSION 3.17)
# 3.18: add_library cannot create ALIAS for non-GLOBAL targets
cmake_minimum_required(VERSION 3.18)
else()
if(CPACK_GENERATOR STREQUAL "DEB")
# we have to use CPACK_DEBIAN_PACKAGE_SHLIBDEPS_PRIVATE_DIRS variable
@ -120,7 +121,7 @@ if (ENABLE_TESTS)
include(cmake/test_model_zoo.cmake)
endif()
add_subdirectory(thirdparty)
include(thirdparty/dependencies.cmake)
add_subdirectory(src)
if(ENABLE_SAMPLES OR ENABLE_TESTS OR ENABLE_COMPILE_TOOL)

View File

@ -6,10 +6,11 @@
[![Apache License Version 2.0](https://img.shields.io/badge/license-Apache_2.0-green.svg)](LICENSE)
![GitHub branch checks state](https://img.shields.io/github/checks-status/openvinotoolkit/openvino/master?label=GitHub%20checks)
![Azure DevOps builds (branch)](https://img.shields.io/azure-devops/build/openvinoci/b2bab62f-ab2f-4871-a538-86ea1be7d20f/13?label=Public%20CI)
[![PyPI Status](https://badge.fury.io/py/openvino.svg)](https://badge.fury.io/py/openvino)
[![Anaconda Status](https://anaconda.org/conda-forge/openvino/badges/version.svg)](https://anaconda.org/conda-forge/openvino/badges/version.svg)
[![PyPI Downloads](https://pepy.tech/badge/openvino)](https://pepy.tech/project/openvino)
[![PyPI Status](https://badge.fury.io/py/openvino.svg)](https://badge.fury.io/py/openvino)
[![PyPI Downloads](https://pepy.tech/badge/openvino)](https://pepy.tech/project/openvino)
[![Anaconda Status](https://anaconda.org/conda-forge/openvino/badges/version.svg)](https://anaconda.org/conda-forge/openvino)
[![Anaconda Downloads](https://anaconda.org/conda-forge/openvino/badges/downloads.svg)](https://anaconda.org/conda-forge/openvino/files)
</div>
## Contents:

View File

@ -160,7 +160,7 @@ ie_dependent_option (ENABLE_SYSTEM_TBB "Enables use of system TBB" ${ENABLE_SYS
ie_option (ENABLE_SYSTEM_PUGIXML "Enables use of system PugiXML" ${ENABLE_SYSTEM_PUGIXML_DEFAULT})
# the option is on by default, because we use only flatc compiler and don't use any libraries
ie_dependent_option(ENABLE_SYSTEM_FLATBUFFERS "Enables use of system flatbuffers" ON
"ENABLE_OV_TF_LITE_FRONTEND" OFF)
"ENABLE_OV_TF_LITE_FRONTEND;NOT ANDROID" OFF)
ie_dependent_option (ENABLE_SYSTEM_OPENCL "Enables use of system OpenCL" ${ENABLE_SYSTEM_LIBS_DEFAULT}
"ENABLE_INTEL_GPU" OFF)
# the option is turned off by default, because we compile our own static version of protobuf

View File

@ -238,7 +238,15 @@ macro(_ov_find_pugixml)
if(_ov_pugixml_pkgconfig_interface AND NOT ANDROID)
_ov_find_dependency(PkgConfig)
elseif(_ov_pugixml_cmake_interface)
_ov_find_dependency(PugiXML REQUIRED)
_ov_find_dependency(PugiXML NAMES PugiXML pugixml)
endif()
# see https://cmake.org/cmake/help/latest/command/add_library.html#alias-libraries
# cmake older than 3.18 cannot create an alias for imported non-GLOBAL targets
# so, we have to use 'GLOBAL' property for cases when we call from OpenVINODeveloperPackage
# because the alias openvino::pugixml is created later
if(CMAKE_VERSION VERSION_LESS 3.18 AND OpenVINODeveloperPackage_DIR)
set(_ov_pugixml_visibility GLOBAL)
endif()
if(PugiXML_FOUND)
@ -248,8 +256,10 @@ macro(_ov_find_pugixml)
set(_ov_pugixml_target pugixml::pugixml)
endif()
if(OpenVINODeveloperPackage_DIR)
set_property(TARGET ${_ov_pugixml_target} PROPERTY IMPORTED_GLOBAL ON)
# align with build tree
# align with build tree and create alias
if(_ov_pugixml_visibility STREQUAL "GLOBAL")
set_target_properties(${_ov_pugixml_target} PROPERTIES IMPORTED_GLOBAL TRUE)
endif()
add_library(openvino::pugixml ALIAS ${_ov_pugixml_target})
endif()
unset(_ov_pugixml_target)
@ -265,7 +275,7 @@ macro(_ov_find_pugixml)
${pkg_config_quiet_arg}
${pkg_config_required_arg}
IMPORTED_TARGET
GLOBAL
${_ov_pugixml_visibility}
pugixml)
unset(pkg_config_quiet_arg)
@ -295,6 +305,8 @@ macro(_ov_find_pugixml)
message(FATAL_ERROR "Failed to find system pugixml in OpenVINO Developer Package")
endif()
endif()
unset(_ov_pugixml_visibility)
endif()
endmacro()
@ -314,7 +326,7 @@ macro(_ov_find_ade)
# whether 'ade' is found via find_package
set(_ENABLE_SYSTEM_ADE "@ade_FOUND@")
if(_OV_ENABLE_GAPI_PREPROCESSING AND _ENABLE_SYSTEM_ADE)
_ov_find_dependency(ade 0.1.2)
_ov_find_dependency(ade @ade_VERSION@)
endif()
unset(_OV_ENABLE_GAPI_PREPROCESSING)
unset(_ENABLE_SYSTEM_ADE)
@ -375,9 +387,8 @@ endmacro()
macro(_ov_find_protobuf_frontend_dependency)
set(_OV_ENABLE_SYSTEM_PROTOBUF "@ENABLE_SYSTEM_PROTOBUF@")
# TODO: remove check for target existence
if(_OV_ENABLE_SYSTEM_PROTOBUF AND NOT TARGET protobuf::libprotobuf)
_ov_find_dependency(Protobuf @Protobuf_VERSION@ EXACT)
if(_OV_ENABLE_SYSTEM_PROTOBUF)
_ov_find_dependency(Protobuf @Protobuf_VERSION@ EXACT NAMES Protobuf protobuf)
endif()
unset(_OV_ENABLE_SYSTEM_PROTOBUF)
endmacro()
@ -385,8 +396,7 @@ endmacro()
macro(_ov_find_tensorflow_frontend_dependencies)
set(_OV_ENABLE_SYSTEM_SNAPPY "@ENABLE_SYSTEM_SNAPPY@")
set(_ov_snappy_lib "@ov_snappy_lib@")
# TODO: remove check for target existence
if(_OV_ENABLE_SYSTEM_SNAPPY AND NOT TARGET ${_ov_snappy_lib})
if(_OV_ENABLE_SYSTEM_SNAPPY)
_ov_find_dependency(Snappy @Snappy_VERSION@ EXACT)
endif()
unset(_OV_ENABLE_SYSTEM_SNAPPY)

View File

@ -33,7 +33,11 @@ set(ENABLE_PLUGINS_XML ON)
# for samples in 3rd party projects
if(ENABLE_SAMPLES)
set_and_check(gflags_DIR "@gflags_BINARY_DIR@")
if("@gflags_FOUND@")
set_and_check(gflags_DIR "@gflags_DIR@")
else()
set_and_check(gflags_DIR "@gflags_BINARY_DIR@")
endif()
endif()
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")

View File

@ -1,33 +0,0 @@
# Running and Deploying Inference {#openvino_docs_deployment_guide_introduction}
@sphinxdirective
.. toctree::
:maxdepth: 1
:hidden:
Run and Deploy Locally <openvino_deployment_guide>
Deploy via Model Serving <ovms_what_is_openvino_model_server>
Once you have a model that meets both OpenVINO™ and your requirements, you can choose how to deploy it with your application.
.. panels::
:doc:`Deploy via OpenVINO Runtime <openvino_deployment_guide>`
^^^^^^^^^^^^^^
Local deployment uses OpenVINO Runtime that is called from, and linked to, the application directly.
It utilizes resources available to the system and provides the quickest way of launching inference.
---
:doc:`Deploy via Model Server <ovms_what_is_openvino_model_server>`
^^^^^^^^^^^^^^
Deployment via OpenVINO Model Server allows the application to connect to the inference server set up remotely.
This way inference can use external resources instead of those available to the application itself.
Apart from the default deployment options, you may also :doc:`deploy your application for the TensorFlow framework with OpenVINO Integration <ovtf_integration>`
@endsphinxdirective

View File

@ -7,7 +7,6 @@
:hidden:
ote_documentation
ovtf_integration
ovsa_get_started
openvino_docs_tuning_utilities
@ -15,8 +14,7 @@
OpenVINO™ is not just one tool. It is an expansive ecosystem of utilities, providing a comprehensive workflow for deep learning solution development. Learn more about each of them to reach the full potential of OpenVINO™ Toolkit.
Neural Network Compression Framework (NNCF)
###########################################
**Neural Network Compression Framework (NNCF)**
A suite of advanced algorithms for Neural Network inference optimization with minimal accuracy drop. NNCF applies quantization, filter pruning, binarization and sparsity algorithms to PyTorch and TensorFlow models during training.
@ -27,8 +25,7 @@ More resources:
* `PyPI <https://pypi.org/project/nncf/>`__
OpenVINO™ Training Extensions
#############################
**OpenVINO™ Training Extensions**
A convenient environment to train Deep Learning models and convert them using the OpenVINO™ toolkit for optimized inference.
@ -38,9 +35,7 @@ More resources:
* `GitHub <https://github.com/openvinotoolkit/training_extensions>`__
* `Documentation <https://openvinotoolkit.github.io/training_extensions/stable/guide/get_started/introduction.html>`__
OpenVINO™ Security Add-on
#########################
**OpenVINO™ Security Add-on**
A solution for Model Developers and Independent Software Vendors to use secure packaging and secure model execution.
@ -49,53 +44,7 @@ More resources:
* :doc:`Documentation <ovsa_get_started>`
* `GitHub <https://github.com/openvinotoolkit/security_addon>`__
OpenVINO™ integration with TensorFlow (OVTF)
############################################
A solution empowering TensorFlow developers with OpenVINO's optimization capabilities. With just two lines of code in your application, you can offload inference to OpenVINO, while keeping the TensorFlow API.
More resources:
* `Documentation <https://github.com/openvinotoolkit/openvino_tensorflow>`__
* `PyPI <https://pypi.org/project/openvino-tensorflow/>`__
* `GitHub <https://github.com/openvinotoolkit/openvino_tensorflow>`__
DL Streamer
###########
A streaming media analytics framework, based on the GStreamer multimedia framework, for creating complex media analytics pipelines.
More resources:
* `Documentation on GitHub <https://dlstreamer.github.io/index.html>`__
* `Installation Guide on GitHub <https://github.com/openvinotoolkit/dlstreamer_gst/wiki/Install-Guide>`__
DL Workbench
############
A web-based tool for deploying deep learning models. Built on the core of OpenVINO and equipped with a graphics user interface, DL Workbench is a great way to explore the possibilities of the OpenVINO workflow, import, analyze, optimize, and build your pre-trained models. You can do all that by visiting `Intel® Developer Cloud <https://software.intel.com/content/www/us/en/develop/tools/devcloud.html>`__ and launching DL Workbench online.
More resources:
* `Documentation <https://docs.openvino.ai/2023.0/workbench_docs_Workbench_DG_Introduction.html>`__
* `Docker Hub <https://hub.docker.com/r/openvino/workbench>`__
* `PyPI <https://pypi.org/project/openvino-workbench/>`__
Computer Vision Annotation Tool (CVAT)
######################################
An online, interactive video and image annotation tool for computer vision purposes.
More resources:
* `Documentation on GitHub <https://opencv.github.io/cvat/docs/>`__
* `Web application <https://www.cvat.ai/>`__
* `Docker Hub <https://hub.docker.com/r/openvino/cvat_server>`__
* `GitHub <https://github.com/openvinotoolkit/cvat>`__
Dataset Management Framework (Datumaro)
#######################################
**Dataset Management Framework (Datumaro)**
A framework and CLI tool to build, transform, and analyze datasets.
@ -105,10 +54,10 @@ More resources:
* `PyPI <https://pypi.org/project/datumaro/>`__
* `GitHub <https://github.com/openvinotoolkit/datumaro>`__
Compile Tool
#############
**Compile Tool**
Compile tool is deprecated since the 2023.0 OpenVINO release. If you need to compile a model for inference on a specific device, use the following script:
Compile tool is now deprecated. If you need to compile a model for inference on a specific device, use the following script:
.. tab:: python
@ -127,5 +76,14 @@ To learn which device supports the import / export functionality, see the :doc:`
For more details on preprocessing steps, refer to the :doc:`Optimize Preprocessing <openvino_docs_OV_UG_Preprocessing_Overview>`. To compile the model with advanced preprocessing capabilities, refer to the :doc:`Use Case - Integrate and Save Preprocessing Steps Into OpenVINO IR <openvino_docs_OV_UG_Preprocess_Usecase_save>`, which shows how to have all the preprocessing in the compiled blob.
**DL Workbench**
A web-based tool for deploying deep learning models. Built on the core of OpenVINO and equipped with a graphics user interface, DL Workbench is a great way to explore the possibilities of the OpenVINO workflow, import, analyze, optimize, and build your pre-trained models. You can do all that by visiting `Intel® Developer Cloud <https://software.intel.com/content/www/us/en/develop/tools/devcloud.html>`__ and launching DL Workbench online.
**OpenVINO™ integration with TensorFlow (OVTF)**
OpenVINO™ Integration with TensorFlow will no longer be supported as of OpenVINO release 2023.0. As part of the 2023.0 release, OpenVINO will feature a significantly enhanced TensorFlow user experience within native OpenVINO without needing offline model conversions. :doc:`Learn more <openvino_docs_MO_DG_TensorFlow_Frontend>`.
@endsphinxdirective

View File

@ -1,55 +0,0 @@
# OpenVINO™ integration with TensorFlow {#ovtf_integration}
@sphinxdirective
**OpenVINO™ integration with TensorFlow** is a solution for TensorFlow developers who want to get started with OpenVINO™ in their inferencing applications. By adding just two lines of code you can now take advantage of OpenVINO™ toolkit optimizations with TensorFlow inference applications across a range of Intel® computation devices.
This is all you need:
.. code-block:: bash
import openvino_tensorflow
openvino_tensorflow.set_backend('<backend_name>')
**OpenVINO™ integration with TensorFlow** accelerates inference across many AI models on a variety of Intel® technologies, such as:
* Intel® CPUs
* Intel® integrated GPUs
.. note::
For maximum performance, efficiency, tooling customization, and hardware control, we recommend developers to adopt native OpenVINO™ solutions.
To find out more about the product itself, as well as learn how to use it in your project, check its dedicated `GitHub repository <https://github.com/openvinotoolkit/openvino_tensorflow/tree/master/docs>`__.
To see what you can do with **OpenVINO™ integration with TensorFlow**, explore the demos located in the `examples folder <https://github.com/openvinotoolkit/openvino_tensorflow/tree/master/examples>`__ in our GitHub repository.
Sample tutorials are also hosted on `Intel® DevCloud <https://www.intel.com/content/www/us/en/developer/tools/devcloud/edge/build/ovtfoverview.html>`__. The demo applications are implemented using Jupyter Notebooks. You can interactively execute them on Intel® DevCloud nodes, compare the results of **OpenVINO™ integration with TensorFlow**, native TensorFlow, and OpenVINO™.
License
#######
**OpenVINO™ integration with TensorFlow** is licensed under `Apache License Version 2.0 <https://github.com/openvinotoolkit/openvino_tensorflow/blob/master/LICENSE>`__.
By contributing to the project, you agree to the license and copyright terms therein
and release your contribution under these terms.
Support
#######
Submit your questions, feature requests and bug reports via `GitHub issues <https://github.com/openvinotoolkit/openvino_tensorflow/issues>`__.
How to Contribute
#################
We welcome community contributions to **OpenVINO™ integration with TensorFlow**. If you have an idea for improvement:
* Share your proposal via `GitHub issues <https://github.com/openvinotoolkit/openvino_tensorflow/issues>`__.
* Submit a `pull request <https://github.com/openvinotoolkit/openvino_tensorflow/pulls>`__.
We will review your contribution as soon as possible. If any additional fixes or modifications are necessary, we will guide you and provide feedback. Before you make your contribution, make sure you can build **OpenVINO™ integration with TensorFlow** and run all the examples with your fix/patch. If you want to introduce a large feature, create test cases for your feature. Upon our verification of your pull request, we will merge it to the repository provided that the pull request has met the above mentioned requirements and proved acceptable.
\* Other names and brands may be claimed as the property of others.
@endsphinxdirective

View File

@ -9,7 +9,9 @@
Model Preparation <openvino_docs_model_processing_introduction>
Model Optimization and Compression <openvino_docs_model_optimization_guide>
Running and Deploying Inference <openvino_docs_deployment_guide_introduction>
Running Inference <openvino_docs_OV_UG_OV_Runtime_User_Guide>
Deployment on a Local System <openvino_deployment_guide>
Deployment on a Model Server <ovms_what_is_openvino_model_server>
| :doc:`Model Preparation <openvino_docs_model_processing_introduction>`
@ -18,7 +20,23 @@
| :doc:`Model Optimization and Compression <openvino_docs_model_optimization_guide>`
| In this section you will find out how to optimize a model to achieve better inference performance. It describes multiple optimization methods for both the training and post-training stages.
| :doc:`Deployment <openvino_docs_deployment_guide_introduction>`
| This section explains the process of deploying your own inference application using either OpenVINO Runtime or OpenVINO Model Server. It describes how to run inference which is the most basic form of deployment and the quickest way of launching inference.
| :doc:`Running Inference <openvino_docs_OV_UG_OV_Runtime_User_Guide>`
| This section explains describes how to run inference which is the most basic form of deployment and the quickest way of launching inference.
Once you have a model that meets both OpenVINO™ and your requirements, you can choose how to deploy it with your application.
| :doc:`Option 1. Deployment via OpenVINO Runtime <openvino_deployment_guide>`
| Local deployment uses OpenVINO Runtime that is called from, and linked to, the application directly.
| It utilizes resources available to the system and provides the quickest way of launching inference.
| Deployment on a local system requires performing the steps from the running inference section.
| :doc:`Option 2. Deployment via Model Server <ovms_what_is_openvino_model_server>`
| Deployment via OpenVINO Model Server allows the application to connect to the inference server set up remotely.
| This way inference can use external resources instead of those available to the application itself.
| Deployment on a model server can be done quickly and without performing any additional steps described in the running inference section.
@endsphinxdirective

View File

@ -1,4 +1,4 @@
# Run and Deploy Locally {#openvino_deployment_guide}
# Deploy Locally {#openvino_deployment_guide}
@sphinxdirective
@ -6,8 +6,6 @@
:maxdepth: 1
:hidden:
Run Inference <openvino_docs_OV_UG_OV_Runtime_User_Guide>
Optimize Inference <openvino_docs_deployment_optimization_guide_dldt_optimization_guide>
Deploy Application with Deployment Manager <openvino_docs_install_guides_deployment_manager_tool>
Local Distribution Libraries <openvino_docs_deploy_local_distribution>

View File

@ -14,6 +14,7 @@
openvino_docs_OV_UG_ShapeInference
openvino_docs_OV_UG_DynamicShapes
openvino_docs_OV_UG_model_state_intro
Optimize Inference <openvino_docs_deployment_optimization_guide_dldt_optimization_guide>
OpenVINO Runtime is a set of C++ libraries with C and Python bindings providing a common API to deliver inference solutions on the platform of your choice. Use the OpenVINO Runtime API to read an Intermediate Representation (IR), TensorFlow, TensorFlow Lite, ONNX, or PaddlePaddle model and execute it on preferred devices.

View File

@ -19,7 +19,7 @@ It is possible because not all interface symbols of OpenVINO Runtime libraries a
## System requirements
* CMake version 3.17 or higher must be used to build static OpenVINO libraries.
* CMake version 3.18 or higher must be used to build static OpenVINO libraries.
* Supported OSes:
* Windows x64
* Linux x64

View File

@ -17,7 +17,7 @@ before every release. These models are considered officially supported.
| If your model is not included but is similar to those that are, it is still very likely to work.
If your model fails to execute properly there are a few options available:
* If the model originates from a framework like TensorFlow or PyTorch, OpenVINO™ offers a hybrid solution. The original model can be run without explicit conversion into the OpenVINO format. For more information, see :doc:`OpenVINO TensorFlow Integration <ovtf_integration>`.
* You can create a GitHub request for the operation(s) that are missing. These requests are reviewed regularly. You will be informed if and how the request will be accommodated. Additionally, your request may trigger a reply from someone in the community who can help.
* As OpenVINO™ is open source you can enhance it with your own contribution to the GitHub repository. To learn more, see the articles on :doc:`OpenVINO Extensibility <openvino_docs_Extensibility_UG_Intro>`.

View File

@ -64,8 +64,7 @@ function(ov_check_python_build_conditions)
endif()
# use libraries with the same version as python itself
set(PYBIND11_PYTHON_VERSION ${PYTHON_VERSION_STRING})
find_host_package(PythonLibsNew ${PYBIND11_PYTHON_VERSION} EXACT
${find_package_mode})
find_host_package(PythonLibsNew ${PYBIND11_PYTHON_VERSION} EXACT ${find_package_mode})
set(PYTHONLIBSNEW_FOUND ${PYTHONLIBS_FOUND} PARENT_SCOPE)
endfunction()
# try to find python libraries

View File

@ -115,7 +115,7 @@ macro(ov_find_package_tbb)
IMPORTED_TARGET
# we need to set GLOBAL in order to create ALIAS later
# ALIAS creation for non-GLOBAL targets is available since cmake 3.18
GLOBAL
${OV_PkgConfig_VISILITY}
tbb)
if(tbb_FOUND)
# parse version
@ -190,7 +190,6 @@ macro(ov_find_package_tbb)
if(PkgConfig_FOUND)
pkg_search_module(HWLOC QUIET
IMPORTED_TARGET
GLOBAL
hwloc)
endif()

View File

@ -12,7 +12,7 @@ add_library(openvino::itt ALIAS ${TARGET_NAME})
target_link_libraries(${TARGET_NAME} PUBLIC openvino::util)
if(ENABLE_PROFILING_ITT)
target_link_libraries(${TARGET_NAME} PUBLIC ittapi::ittnotify)
target_link_libraries(${TARGET_NAME} PUBLIC ittapi::ittapi)
if(ENABLE_PROFILING_FILTER STREQUAL "ALL")
target_compile_definitions(${TARGET_NAME} PUBLIC
ENABLE_PROFILING_ALL

View File

@ -47,12 +47,12 @@ find_package_handle_standard_args(ITT
if(ITT_FOUND)
set(INTEL_ITT_FOUND ${ITT_FOUND})
add_library(ittapi::ittnotify STATIC IMPORTED GLOBAL)
set_target_properties(ittapi::ittnotify PROPERTIES IMPORTED_LOCATION "${Located_ITT_LIBS}"
INTERFACE_INCLUDE_DIRECTORIES ${Located_ITT_INCLUDE_DIRS}
INTERFACE_COMPILE_DEFINITIONS ENABLE_PROFILING_ITT)
add_library(ittapi::ittapi STATIC IMPORTED GLOBAL)
set_target_properties(ittapi::ittapi PROPERTIES IMPORTED_LOCATION "${Located_ITT_LIBS}"
INTERFACE_INCLUDE_DIRECTORIES ${Located_ITT_INCLUDE_DIRS}
INTERFACE_COMPILE_DEFINITIONS ENABLE_PROFILING_ITT)
if(UNIX)
set_target_properties(ittapi::ittnotify PROPERTIES INTERFACE_LINK_LIBRARIES "${CMAKE_DL_LIBS};Threads::Threads")
set_target_properties(ittapi::ittapi PROPERTIES INTERFACE_LINK_LIBRARIES "${CMAKE_DL_LIBS};Threads::Threads")
endif()
endif()

View File

@ -64,6 +64,13 @@ public:
const Attributes& get_attrs() const {
return m_attrs;
}
/**
* @brief Set the Proposal operator attributes.
* @param attrs Attributes to be set.
*/
void set_attrs(Attributes attrs);
bool visit_attributes(AttributeVisitor& visitor) override;
protected:
@ -93,9 +100,6 @@ public:
void validate_and_infer_types() override;
std::shared_ptr<Node> clone_with_new_inputs(const OutputVector& new_args) const override;
const Attributes& get_attrs() const {
return m_attrs;
}
};
} // namespace v4
} // namespace op

View File

@ -18,8 +18,7 @@ namespace v6 {
// 2. out_rois_shape = [number_of_ROIs, 4]
template <class TShape>
std::vector<TShape> shape_infer(const ExperimentalDetectronROIFeatureExtractor* op,
const std::vector<TShape>& input_shapes,
const ITensorAccessor& tensor_accessor = make_tensor_accessor()) {
const std::vector<TShape>& input_shapes) {
using TDim = typename TShape::value_type;
using namespace ov::util;
NODE_VALIDATION_CHECK(op, input_shapes.size() >= 2);

View File

@ -4,16 +4,18 @@
#pragma once
#include <openvino/op/proposal.hpp>
#include "dimension_util.hpp"
#include "openvino/op/proposal.hpp"
#include "utils.hpp"
namespace ov {
namespace op {
namespace v0 {
template <class OpType, class ShapeType>
void infer_prop_shape(const OpType* op,
const std::vector<ShapeType>& input_shapes,
std::vector<ShapeType>& output_shapes) {
using DimType = typename std::iterator_traits<typename ShapeType::iterator>::value_type;
namespace proposal {
template <class TOp, class TShape>
TShape shape_infer_boxes(const TOp* op, const std::vector<TShape>& input_shapes) {
using TDim = typename TShape::value_type;
NODE_VALIDATION_CHECK(op, input_shapes.size() == 3);
const auto& class_probs_ps = input_shapes[0];
const auto& bbox_deltas_ps = input_shapes[1];
const auto& image_shape_ps = input_shapes[2];
@ -30,62 +32,56 @@ void infer_prop_shape(const OpType* op,
bbox_deltas_ps,
").");
NODE_VALIDATION_CHECK(op,
image_shape_ps.rank().compatible(1),
"Proposal layer shape image_shape should be rank 1 compatible (",
image_shape_ps,
").");
if (bbox_deltas_ps.rank().is_static() && class_probs_ps.rank().is_static()) {
if (image_shape_ps.rank().is_static()) {
NODE_VALIDATION_CHECK(
op,
image_shape_ps.size() == 1 && (image_shape_ps[0].compatible(3) || image_shape_ps[0].compatible(4)),
"Image_shape must be 1-D tensor and has got 3 or 4 elements (image_shape_shape[0]",
image_shape_ps,
").");
}
const auto is_bbox_rank_dynamic = bbox_deltas_ps.rank().is_dynamic();
TShape proposed_boxes_shape;
proposed_boxes_shape.reserve(2);
if (class_probs_ps.rank().is_static()) {
proposed_boxes_shape.push_back(class_probs_ps[0]);
// check anchor count and batch number consistency
NODE_VALIDATION_CHECK(op,
bbox_deltas_ps[1].compatible(class_probs_ps[1] * 2),
is_bbox_rank_dynamic || bbox_deltas_ps[1].compatible(class_probs_ps[1] * 2),
"Anchor number inconsistent between class_probs (",
class_probs_ps[1] * 2,
"), and bbox_deltas (",
bbox_deltas_ps[1],
").");
NODE_VALIDATION_CHECK(op,
class_probs_ps[0].compatible(bbox_deltas_ps[0]),
"Batch size inconsistent between class_probs (",
class_probs_ps[0],
") and bbox deltas (",
bbox_deltas_ps[0],
").");
}
if (image_shape_ps.is_static()) {
const auto image_shape_elem = image_shape_ps[0].get_length();
NODE_VALIDATION_CHECK(op,
image_shape_elem >= 3 && image_shape_elem <= 4,
"Image_shape 1D tensor must have => 3 and <= 4 elements (image_shape_shape[0]",
image_shape_ps[0],
").");
}
auto out_dim = DimType{};
if (class_probs_ps.rank().is_static() && bbox_deltas_ps.rank().is_static()) {
OPENVINO_ASSERT(DimType::merge(out_dim, class_probs_ps[0], bbox_deltas_ps[0]));
} else if (class_probs_ps.rank().is_static()) {
out_dim = class_probs_ps[0];
} else if (bbox_deltas_ps.rank().is_static()) {
out_dim = bbox_deltas_ps[0];
} else {
out_dim = Dimension::dynamic();
proposed_boxes_shape.emplace_back(ov::util::dim::inf_bound);
}
auto& proposed_boxes_shape = output_shapes[0];
proposed_boxes_shape.resize(2);
proposed_boxes_shape[0] = out_dim * op->get_attrs().post_nms_topn;
proposed_boxes_shape[1] = 5;
}
template <class T>
void shape_infer(const ov::op::v0::Proposal* op, const std::vector<T>& input_shapes, std::vector<T>& output_shapes) {
NODE_VALIDATION_CHECK(op, input_shapes.size() == 3 && output_shapes.size() == 1);
ov::op::v0::infer_prop_shape(op, input_shapes, output_shapes);
}
NODE_VALIDATION_CHECK(
op,
is_bbox_rank_dynamic || TDim::merge(proposed_boxes_shape[0], proposed_boxes_shape[0], bbox_deltas_ps[0]),
"Batch size inconsistent between class_probs (",
class_probs_ps[0],
") and bbox deltas (",
bbox_deltas_ps[0],
").");
proposed_boxes_shape[0] *= op->get_attrs().post_nms_topn;
proposed_boxes_shape.emplace_back(5);
return proposed_boxes_shape;
}
} // namespace proposal
namespace v0 {
template <class TShape>
std::vector<TShape> shape_infer(const Proposal* op, const std::vector<TShape>& input_shapes) {
return {ov::op::proposal::shape_infer_boxes(op, input_shapes)};
}
} // namespace v0
} // namespace op
} // namespace ov
@ -93,15 +89,11 @@ void shape_infer(const ov::op::v0::Proposal* op, const std::vector<T>& input_sha
namespace ov {
namespace op {
namespace v4 {
template <class T>
void shape_infer(const ov::op::v4::Proposal* op, const std::vector<T>& input_shapes, std::vector<T>& output_shapes) {
NODE_VALIDATION_CHECK(op, input_shapes.size() == 3 && output_shapes.size() == 2);
ov::op::v0::infer_prop_shape(op, input_shapes, output_shapes);
const auto& proposals_ps = output_shapes[0];
auto& out_ps = output_shapes[1];
out_ps = T{proposals_ps[0]};
template <class TShape>
std::vector<TShape> shape_infer(const Proposal* op, const std::vector<TShape>& input_shapes) {
auto output_shapes = std::vector<TShape>(2, ov::op::proposal::shape_infer_boxes(op, input_shapes));
output_shapes[1].resize(1);
return output_shapes;
}
} // namespace v4

View File

@ -43,7 +43,7 @@ void shape_infer(const ReorgYolo* op, const std::vector<T>& input_shapes, std::v
const auto& interval = input_shape[i].get_interval();
if (interval.has_upper_bound()) {
output_shape.push_back(
ov::Dimension(interval.get_max_val() / strides[0], interval.get_min_val() / strides[0]));
ov::Dimension(interval.get_min_val() / strides[0], interval.get_max_val() / strides[0]));
} else {
output_shape.push_back(ov::Dimension::dynamic());
}

View File

@ -18,8 +18,6 @@ public:
* @return Tensor to data at port.
*/
virtual Tensor operator()(size_t port) const = 0;
virtual ~ITensorAccessor() = default;
};
/**
@ -35,14 +33,14 @@ public:
* @tparam TContainer Type of tensor container.
*/
template <class TContainer>
class TensorAccessor : public ITensorAccessor {
class TensorAccessor final : public ITensorAccessor {
public:
/**
* @brief Construct a new Tensor Accessor object for tensors container.
*
* @param tensors Pointer to container with tensors.
*/
TensorAccessor(const TContainer* tensors) : m_tensors{tensors} {}
constexpr TensorAccessor(const TContainer* tensors) : m_tensors{tensors} {}
/**
* @brief Get tensor for given port number.
@ -79,7 +77,7 @@ Tensor TensorAccessor<void>::operator()(size_t port) const;
* @return TensorContainer for specific type.
*/
template <class TContainer>
auto make_tensor_accessor(const TContainer& c) -> TensorAccessor<TContainer> {
constexpr auto make_tensor_accessor(const TContainer& c) -> TensorAccessor<TContainer> {
return TensorAccessor<TContainer>(&c);
}
@ -88,5 +86,5 @@ auto make_tensor_accessor(const TContainer& c) -> TensorAccessor<TContainer> {
*
* @return TensorAccessor to return empty tensor.
*/
auto make_tensor_accessor() -> TensorAccessor<void>;
auto make_tensor_accessor() -> const TensorAccessor<void>&;
} // namespace ov

View File

@ -43,8 +43,8 @@ Tensor TensorAccessor<void>::operator()(size_t) const {
return empty;
}
auto make_tensor_accessor() -> TensorAccessor<void> {
static const auto empty_tensor_accessor = TensorAccessor<void>(nullptr);
auto make_tensor_accessor() -> const TensorAccessor<void>& {
static constexpr auto empty_tensor_accessor = TensorAccessor<void>(nullptr);
return empty_tensor_accessor;
}
} // namespace ov

View File

@ -2,16 +2,13 @@
// SPDX-License-Identifier: Apache-2.0
//
#include "ngraph/op/proposal.hpp"
#include <proposal_shape_inference.hpp>
#include "openvino/op/proposal.hpp"
#include "itt.hpp"
#include "ngraph/op/constant.hpp"
using namespace std;
using namespace ngraph;
#include "openvino/core/validation_util.hpp"
#include "proposal_shape_inference.hpp"
namespace ov {
op::v0::Proposal::Proposal(const Output<Node>& class_probs,
const Output<Node>& bbox_deltas,
const Output<Node>& image_shape,
@ -43,19 +40,20 @@ void op::v0::Proposal::validate_element_types() {
void op::v0::Proposal::validate_and_infer_types() {
OV_OP_SCOPE(v0_Proposal_validate_and_infer_types);
validate_element_types();
std::vector<ov::PartialShape> output_shapes = {ov::PartialShape{}};
std::vector<ov::PartialShape> input_shapes = {get_input_partial_shape(0),
get_input_partial_shape(1),
get_input_partial_shape(2)};
shape_infer(this, input_shapes, output_shapes);
OPENVINO_SUPPRESS_DEPRECATED_START
const auto intput_shapes = get_node_input_partial_shapes(*this);
OPENVINO_SUPPRESS_DEPRECATED_END
const auto output_shapes = shape_infer(this, intput_shapes);
set_output_type(0, get_input_element_type(0), output_shapes[0]);
}
shared_ptr<Node> op::v0::Proposal::clone_with_new_inputs(const OutputVector& new_args) const {
std::shared_ptr<Node> op::v0::Proposal::clone_with_new_inputs(const OutputVector& new_args) const {
OV_OP_SCOPE(v0_Proposal_clone_with_new_inputs);
check_new_args_count(this, new_args);
return make_shared<op::v0::Proposal>(new_args.at(0), new_args.at(1), new_args.at(2), m_attrs);
return std::make_shared<Proposal>(new_args.at(0), new_args.at(1), new_args.at(2), m_attrs);
}
bool op::v0::Proposal::visit_attributes(AttributeVisitor& visitor) {
@ -77,32 +75,40 @@ bool op::v0::Proposal::visit_attributes(AttributeVisitor& visitor) {
return true;
}
void op::v0::Proposal::set_attrs(Attributes attrs) {
m_attrs = std::move(attrs);
}
// --- v4 ---
op::v4::Proposal::Proposal(const Output<Node>& class_probs,
const Output<Node>& class_bbox_deltas,
const Output<Node>& image_shape,
const op::v0::Proposal::Attributes& attrs)
: v0::Proposal(class_probs, class_bbox_deltas, image_shape, attrs) {
: v0::Proposal() {
set_arguments({class_probs, class_bbox_deltas, image_shape});
set_attrs(attrs);
constructor_validate_and_infer_types();
}
void op::v4::Proposal::validate_and_infer_types() {
OV_OP_SCOPE(v4_Proposal_validate_and_infer_types);
v0::Proposal::validate_element_types();
std::vector<ov::PartialShape> output_shapes = {ov::PartialShape{}, ov::PartialShape{}};
std::vector<ov::PartialShape> input_shapes = {get_input_partial_shape(0),
get_input_partial_shape(1),
get_input_partial_shape(2)};
shape_infer(this, input_shapes, output_shapes);
validate_element_types();
OPENVINO_SUPPRESS_DEPRECATED_START
const auto intput_shapes = get_node_input_partial_shapes(*this);
OPENVINO_SUPPRESS_DEPRECATED_END
const auto output_shapes = shape_infer(this, intput_shapes);
const auto& out_et = get_input_element_type(0);
const auto& input0_type = get_input_element_type(0);
set_output_type(0, input0_type, output_shapes[0]);
set_output_type(1, input0_type, output_shapes[1]);
for (size_t i = 0; i < output_shapes.size(); ++i) {
set_output_type(i, out_et, output_shapes[i]);
}
m_attrs.infer_probs = true; // Proposal v4 requires default true of infer_probs so output_1 has valid data.
}
std::shared_ptr<Node> op::v4::Proposal::clone_with_new_inputs(const OutputVector& new_args) const {
OV_OP_SCOPE(v4_Proposal_clone_with_new_inputs);
check_new_args_count(this, new_args);
return make_shared<op::v4::Proposal>(new_args.at(0), new_args.at(1), new_args.at(2), m_attrs);
return std::make_shared<Proposal>(new_args.at(0), new_args.at(1), new_args.at(2), m_attrs);
}
} // namespace ov

View File

@ -41,10 +41,8 @@ void op::v8::RandomUniform::validate_and_infer_types() {
"The rank of the tensor defining output shape must be equal to 1.");
OPENVINO_SUPPRESS_DEPRECATED_START
if (const auto& const_shape = get_constant_from_source(input_value(0))) {
if (!evaluate_as_partial_shape(input_value(0), output_shape)) {
OPENVINO_SUPPRESS_DEPRECATED_END
output_shape = ov::PartialShape(const_shape->cast_vector<int64_t>());
} else {
output_shape = ov::PartialShape::dynamic(input_shape[0]);
}
}

View File

@ -4,12 +4,14 @@
#include "ngraph/op/proposal.hpp"
#include "gtest/gtest.h"
#include "common_test_utils/test_assertions.hpp"
#include "gmock/gmock.h"
#include "ngraph/ngraph.hpp"
#include "util/type_prop.hpp"
using namespace std;
using namespace ngraph;
using namespace testing;
// ------------------------------ V0 ------------------------------
@ -19,15 +21,9 @@ TEST(type_prop, proposal_v0_invalid_class_probs_rank) {
auto class_bbox_deltas = make_shared<op::Parameter>(element::f32, Shape{1, 2, 3, 4});
auto image_shape = make_shared<op::Parameter>(element::f32, Shape{3});
try {
auto proposal = make_shared<op::v0::Proposal>(class_probs, class_bbox_deltas, image_shape, attrs);
// Should have thrown, so fail if it didn't
FAIL() << "Invalid input tensor rank.";
} catch (const NodeValidationFailure& error) {
EXPECT_HAS_SUBSTRING(error.what(), std::string("Proposal layer shape class_probs should be rank 4 compatible"));
} catch (...) {
FAIL() << "Deduced type check failed for unexpected reason";
}
OV_EXPECT_THROW(std::ignore = make_shared<op::v0::Proposal>(class_probs, class_bbox_deltas, image_shape, attrs),
NodeValidationFailure,
HasSubstr("Proposal layer shape class_probs should be rank 4 compatible"));
}
TEST(type_prop, proposal_v0_invalid_anchor_count) {
@ -36,15 +32,9 @@ TEST(type_prop, proposal_v0_invalid_anchor_count) {
auto class_bbox_deltas = make_shared<op::Parameter>(element::f32, Shape{1, 2, 3, 4});
auto image_shape = make_shared<op::Parameter>(element::f32, Shape{3});
try {
auto proposal = make_shared<op::v0::Proposal>(class_probs, class_bbox_deltas, image_shape, attrs);
// Should have thrown, so fail if it didn't
FAIL() << "Invalid input tensor rank.";
} catch (const NodeValidationFailure& error) {
EXPECT_HAS_SUBSTRING(error.what(), std::string("Anchor number inconsistent between"));
} catch (...) {
FAIL() << "Deduced type check failed for unexpected reason";
}
OV_EXPECT_THROW(std::ignore = make_shared<op::v0::Proposal>(class_probs, class_bbox_deltas, image_shape, attrs),
NodeValidationFailure,
HasSubstr("Anchor number inconsistent between"));
}
TEST(type_prop, proposal_v0_invalid_class_bbox_deltas_rank) {
@ -53,15 +43,9 @@ TEST(type_prop, proposal_v0_invalid_class_bbox_deltas_rank) {
auto class_bbox_deltas = make_shared<op::Parameter>(element::f32, Shape{1, 2, 3});
auto image_shape = make_shared<op::Parameter>(element::f32, Shape{3});
try {
auto proposal = make_shared<op::v0::Proposal>(class_probs, class_bbox_deltas, image_shape, attrs);
// Should have thrown, so fail if it didn't
FAIL() << "Invalid input tensor rank.";
} catch (const NodeValidationFailure& error) {
EXPECT_HAS_SUBSTRING(error.what(), std::string("Proposal layer shape bbox_deltas should be rank 4 compatible"));
} catch (...) {
FAIL() << "Deduced type check failed for unexpected reason";
}
OV_EXPECT_THROW(std::ignore = make_shared<op::v0::Proposal>(class_probs, class_bbox_deltas, image_shape, attrs),
NodeValidationFailure,
HasSubstr("Proposal layer shape bbox_deltas should be rank 4 compatible"));
}
TEST(type_prop, proposal_v0_invalid_image_shape_rank) {
@ -70,15 +54,9 @@ TEST(type_prop, proposal_v0_invalid_image_shape_rank) {
auto class_bbox_deltas = make_shared<op::Parameter>(element::f32, Shape{1, 4, 3, 4});
auto image_shape = make_shared<op::Parameter>(element::f32, Shape{2, 1});
try {
auto proposal = make_shared<op::v0::Proposal>(class_probs, class_bbox_deltas, image_shape, attrs);
// Should have thrown, so fail if it didn't
FAIL() << "Invalid input tensor rank.";
} catch (const NodeValidationFailure& error) {
EXPECT_HAS_SUBSTRING(error.what(), std::string("Proposal layer shape image_shape should be rank 1 compatible"));
} catch (...) {
FAIL() << "Deduced type check failed for unexpected reason";
}
OV_EXPECT_THROW(std::ignore = make_shared<op::v0::Proposal>(class_probs, class_bbox_deltas, image_shape, attrs),
NodeValidationFailure,
HasSubstr("Image_shape must be 1-D tensor"));
}
TEST(type_prop, proposal_v0_invalid_image_shape_size) {
@ -87,17 +65,31 @@ TEST(type_prop, proposal_v0_invalid_image_shape_size) {
auto class_bbox_deltas = make_shared<op::Parameter>(element::f32, Shape{1, 4, 3, 4});
auto image_shape = make_shared<op::Parameter>(element::f32, Shape{5});
try {
auto proposal = make_shared<op::v0::Proposal>(class_probs, class_bbox_deltas, image_shape, attrs);
// Should have thrown, so fail if it didn't
FAIL() << "Invalid input tensor rank.";
} catch (const NodeValidationFailure& error) {
EXPECT_HAS_SUBSTRING(
error.what(),
std::string("Image_shape 1D tensor must have => 3 and <= 4 elements (image_shape_shape[0]"));
} catch (...) {
FAIL() << "Deduced type check failed for unexpected reason";
}
OV_EXPECT_THROW(std::ignore = make_shared<op::v0::Proposal>(class_probs, class_bbox_deltas, image_shape, attrs),
NodeValidationFailure,
HasSubstr("Image_shape must be 1-D tensor and has got 3 or 4 elements (image_shape_shape[0]"));
}
TEST(type_prop, proposal_v0_default_ctor) {
op::ProposalAttrs attrs;
attrs.base_size = 1;
attrs.pre_nms_topn = 20;
attrs.post_nms_topn = 200;
const size_t batch_size = 7;
auto class_probs = make_shared<op::Parameter>(element::f16, Shape{batch_size, 12, 34, 62});
auto class_bbox_deltas = make_shared<op::Parameter>(element::f16, Shape{batch_size, 24, 34, 62});
auto image_shape = make_shared<op::Parameter>(element::f16, Shape{3});
auto op = make_shared<op::v0::Proposal>();
op->set_arguments(OutputVector{class_probs, class_bbox_deltas, image_shape});
op->set_attrs(attrs);
op->validate_and_infer_types();
EXPECT_EQ(op->get_input_size(), 3);
EXPECT_EQ(op->get_output_size(), 1);
EXPECT_EQ(op->get_output_element_type(0), element::f16);
EXPECT_EQ(op->get_output_shape(0), (Shape{batch_size * attrs.post_nms_topn, 5}));
}
TEST(type_prop, proposal_v0_shape_infer) {
@ -107,72 +99,134 @@ TEST(type_prop, proposal_v0_shape_infer) {
attrs.post_nms_topn = 200;
const size_t batch_size = 7;
auto class_probs = make_shared<op::Parameter>(element::f32, Shape{batch_size, 12, 34, 62});
auto class_bbox_deltas = make_shared<op::Parameter>(element::f32, Shape{batch_size, 24, 34, 62});
auto image_shape = make_shared<op::Parameter>(element::f32, Shape{3});
auto class_probs = make_shared<op::Parameter>(element::bf16, Shape{batch_size, 12, 34, 62});
auto class_bbox_deltas = make_shared<op::Parameter>(element::bf16, Shape{batch_size, 24, 34, 62});
auto image_shape = make_shared<op::Parameter>(element::bf16, Shape{3});
auto op = make_shared<op::v0::Proposal>(class_probs, class_bbox_deltas, image_shape, attrs);
ASSERT_EQ(op->get_output_shape(0), (Shape{batch_size * attrs.post_nms_topn, 5}));
EXPECT_EQ(op->get_output_element_type(0), element::bf16);
EXPECT_EQ(op->get_output_shape(0), (Shape{batch_size * attrs.post_nms_topn, 5}));
}
TEST(type_prop, proposal_v0_dynamic_class_probs_dim1_batch_size_infer) {
op::ProposalAttrs attrs;
attrs.post_nms_topn = 1;
const size_t batch_size = 2;
auto class_probs = make_shared<op::Parameter>(element::f32, PartialShape{Dimension::dynamic(), 2, 3, 4});
auto class_bbox_deltas = make_shared<op::Parameter>(element::f32, Shape{batch_size, 4, 3, 4});
const auto batch_size = Dimension(2);
auto class_props_shape = PartialShape{-1, 2, 3, 4};
auto class_bbox_shape = PartialShape{batch_size, 4, {0, 3}, {1, 4}};
set_shape_labels(class_props_shape, 10);
set_shape_labels(class_bbox_shape, 20);
auto class_probs = make_shared<op::Parameter>(element::f32, class_props_shape);
auto class_bbox_deltas = make_shared<op::Parameter>(element::f32, class_bbox_shape);
auto image_shape = make_shared<op::Parameter>(element::f32, Shape{3});
auto op = make_shared<op::v0::Proposal>(class_probs, class_bbox_deltas, image_shape, attrs);
ASSERT_EQ(op->get_output_shape(0), (Shape{batch_size * attrs.post_nms_topn, 5}));
EXPECT_EQ(op->get_output_element_type(0), element::f32);
EXPECT_EQ(op->get_output_partial_shape(0), (PartialShape{batch_size * attrs.post_nms_topn, 5}));
EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), ElementsAre(20, ov::no_label));
}
TEST(type_prop, proposal_v0_dynamic_bbox_deltas_dim1_batch_size_infer) {
op::ProposalAttrs attrs;
attrs.post_nms_topn = 1;
const size_t batch_size = 2;
auto class_probs = make_shared<op::Parameter>(element::f32, PartialShape{Dimension::dynamic(), 2, 3, 4});
auto class_bbox_deltas = make_shared<op::Parameter>(element::f32, Shape{batch_size, 4, 3, 4});
auto image_shape = make_shared<op::Parameter>(element::f32, Shape{3});
const auto batch_size = Dimension(2);
auto class_props_shape = PartialShape{batch_size, 2, {1, 3}, {1, 4}};
auto class_bbox_shape = PartialShape{-1, 4, 3, 4};
set_shape_labels(class_props_shape, 10);
auto class_probs = make_shared<op::Parameter>(element::f64, class_props_shape);
auto class_bbox_deltas = make_shared<op::Parameter>(element::f64, class_bbox_shape);
auto image_shape = make_shared<op::Parameter>(element::f64, Shape{3});
auto op = make_shared<op::v0::Proposal>(class_probs, class_bbox_deltas, image_shape, attrs);
ASSERT_EQ(op->get_output_shape(0), (Shape{batch_size * attrs.post_nms_topn, 5}));
EXPECT_EQ(op->get_output_element_type(0), element::f64);
EXPECT_EQ(op->get_output_partial_shape(0), (PartialShape{batch_size * attrs.post_nms_topn, 5}));
EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), ElementsAre(10, ov::no_label));
}
TEST(type_prop, proposal_v0_dynamic_class_probs_bbox_deltas_dim1_batch_size_infer) {
op::ProposalAttrs attrs;
attrs.post_nms_topn = 1;
auto class_probs = make_shared<op::Parameter>(element::f32, PartialShape{Dimension::dynamic(), 2, 3, 4});
auto class_bbox_deltas = make_shared<op::Parameter>(element::f32, PartialShape{Dimension::dynamic(), 4, 3, 4});
auto class_probs = make_shared<op::Parameter>(element::f32, PartialShape{-1, 2, 3, 4});
auto class_bbox_deltas = make_shared<op::Parameter>(element::f32, PartialShape{-1, 4, 3, 4});
auto image_shape = make_shared<op::Parameter>(element::f32, Shape{3});
auto op = make_shared<op::v0::Proposal>(class_probs, class_bbox_deltas, image_shape, attrs);
ASSERT_EQ(op->get_output_partial_shape(0), (PartialShape{Dimension::dynamic() * attrs.post_nms_topn, 5}));
EXPECT_EQ(op->get_output_partial_shape(0), (PartialShape{-1, 5}));
EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), Each(ov::no_label));
}
TEST(type_prop, proposal_v0_dynamic_range_class_probs_bbox_deltas_dim1_batch_size_infer) {
op::ProposalAttrs attrs;
attrs.post_nms_topn = 2;
auto class_probs = make_shared<op::Parameter>(element::f32, PartialShape{Dimension(8, 14), 2, 3, 4});
auto class_bbox_deltas = make_shared<op::Parameter>(element::f32, PartialShape{Dimension(10, 15), 4, 3, 4});
auto class_props_shape = PartialShape{{8, 14}, 2, 3, 4};
auto class_bbox_shape = PartialShape{{10, 15}, 4, {0, 3}, {1, 4}};
set_shape_labels(class_props_shape, 10);
set_shape_labels(class_bbox_shape, 20);
auto class_probs = make_shared<op::Parameter>(element::f32, class_props_shape);
auto class_bbox_deltas = make_shared<op::Parameter>(element::f32, class_bbox_shape);
auto image_shape = make_shared<op::Parameter>(element::f32, Shape{3});
auto op = make_shared<op::v0::Proposal>(class_probs, class_bbox_deltas, image_shape, attrs);
ASSERT_EQ(op->get_output_partial_shape(0),
EXPECT_EQ(op->get_output_partial_shape(0),
(PartialShape{Dimension(10 * attrs.post_nms_topn, 14 * attrs.post_nms_topn), 5}));
EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), Each(ov::no_label));
}
TEST(type_prop, proposal_v0_dynamic_image_shape_shape_infer) {
op::ProposalAttrs attrs;
attrs.base_size = 1;
attrs.base_size = 2;
attrs.pre_nms_topn = 20;
attrs.post_nms_topn = 200;
const size_t batch_size = 7;
const auto batch_size = Dimension(7);
auto class_probs = make_shared<op::Parameter>(element::f32, Shape{batch_size, 12, 34, 62});
auto class_bbox_deltas = make_shared<op::Parameter>(element::f32, Shape{batch_size, 24, 34, 62});
auto class_props_shape = PartialShape{batch_size, 12, 34, 62};
auto class_bbox_shape = PartialShape{batch_size, 24, 34, 62};
set_shape_labels(class_props_shape, 10);
set_shape_labels(class_bbox_shape, 20);
auto class_probs = make_shared<op::Parameter>(element::f32, class_props_shape);
auto class_bbox_deltas = make_shared<op::Parameter>(element::f32, class_bbox_shape);
auto image_shape = make_shared<op::Parameter>(element::f32, PartialShape::dynamic());
auto op = make_shared<op::v0::Proposal>(class_probs, class_bbox_deltas, image_shape, attrs);
ASSERT_EQ(op->get_output_shape(0), (Shape{batch_size * attrs.post_nms_topn, 5}));
EXPECT_EQ(op->get_output_partial_shape(0), (PartialShape{batch_size * attrs.post_nms_topn, 5}));
EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), Each(ov::no_label));
}
TEST(type_prop, proposal_v0_class_probs_dynamic_rank_but_batch_shape_defined_in_bbox) {
op::ProposalAttrs attrs;
attrs.post_nms_topn = 2;
const auto batch_size = Dimension(7);
auto class_probs = make_shared<op::Parameter>(element::f32, PartialShape::dynamic());
auto class_bbox_deltas = make_shared<op::Parameter>(element::f32, PartialShape{batch_size, 24, 32, 32});
auto image_shape = make_shared<op::Parameter>(element::f32, PartialShape::dynamic(1));
auto op = make_shared<op::v0::Proposal>(class_probs, class_bbox_deltas, image_shape, attrs);
EXPECT_EQ(op->get_output_partial_shape(0), (PartialShape{batch_size * attrs.post_nms_topn, 5}));
}
TEST(type_prop, proposal_v0_bbox_dynamic_rank_but_batch_defined_in_class_probs) {
op::ProposalAttrs attrs;
attrs.post_nms_topn = 2;
const auto batch_size = Dimension(7);
auto class_probs = make_shared<op::Parameter>(element::f32, PartialShape{batch_size, 24, 32, 32});
auto class_bbox_deltas = make_shared<op::Parameter>(element::f32, PartialShape::dynamic());
auto image_shape = make_shared<op::Parameter>(element::f32, PartialShape::dynamic(1));
auto op = make_shared<op::v0::Proposal>(class_probs, class_bbox_deltas, image_shape, attrs);
EXPECT_EQ(op->get_output_partial_shape(0), (PartialShape{batch_size * attrs.post_nms_topn, 5}));
}
TEST(type_prop, proposal_v0_everything_dynamic_shape_infer) {
@ -183,18 +237,18 @@ TEST(type_prop, proposal_v0_everything_dynamic_shape_infer) {
auto image_shape = make_shared<op::Parameter>(element::f32, PartialShape::dynamic(1));
auto op = make_shared<op::v0::Proposal>(class_probs, class_bbox_deltas, image_shape, attrs);
ASSERT_EQ(op->get_output_partial_shape(0), (PartialShape{Dimension::dynamic() * attrs.post_nms_topn, 5}));
EXPECT_EQ(op->get_output_partial_shape(0), (PartialShape{-1, 5}));
}
TEST(type_prop, proposal_v0_everything_dynamic_class_probs_dynamic_rank_shape_infer) {
op::ProposalAttrs attrs;
attrs.post_nms_topn = 1;
auto class_probs = make_shared<op::Parameter>(element::f32, PartialShape::dynamic(Rank::dynamic()));
auto class_probs = make_shared<op::Parameter>(element::f32, PartialShape::dynamic());
auto class_bbox_deltas = make_shared<op::Parameter>(element::f32, PartialShape::dynamic(4));
auto image_shape = make_shared<op::Parameter>(element::f32, PartialShape::dynamic(1));
auto op = make_shared<op::v0::Proposal>(class_probs, class_bbox_deltas, image_shape, attrs);
ASSERT_EQ(op->get_output_partial_shape(0), (PartialShape{Dimension::dynamic() * attrs.post_nms_topn, 5}));
EXPECT_EQ(op->get_output_partial_shape(0), (PartialShape{-1, 5}));
}
TEST(type_prop, proposal_v0_everything_dynamic_class_probs_bbox_deltas_dynamic_rank_shape_infer) {
@ -205,7 +259,7 @@ TEST(type_prop, proposal_v0_everything_dynamic_class_probs_bbox_deltas_dynamic_r
auto image_shape = make_shared<op::Parameter>(element::f32, PartialShape::dynamic(1));
auto op = make_shared<op::v0::Proposal>(class_probs, class_bbox_deltas, image_shape, attrs);
ASSERT_EQ(op->get_output_partial_shape(0), (PartialShape{Dimension::dynamic() * attrs.post_nms_topn, 5}));
EXPECT_EQ(op->get_output_partial_shape(0), (PartialShape{-1, 5}));
}
TEST(type_prop, proposal_v0_invalid_class_probs_dynamic) {
@ -214,15 +268,9 @@ TEST(type_prop, proposal_v0_invalid_class_probs_dynamic) {
auto class_bbox_deltas = make_shared<op::Parameter>(element::f32, Shape{1, 4, 3, 4});
auto image_shape = make_shared<op::Parameter>(element::f32, Shape{5});
try {
auto proposal = make_shared<op::v0::Proposal>(class_probs, class_bbox_deltas, image_shape, attrs);
// Should have thrown, so fail if it didn't
FAIL() << "Invalid input tensor rank.";
} catch (const NodeValidationFailure& error) {
EXPECT_HAS_SUBSTRING(error.what(), std::string("Proposal layer shape class_probs should be rank 4 compatible"));
} catch (...) {
FAIL() << "Deduced type check failed for unexpected reason";
}
OV_EXPECT_THROW(std::ignore = make_shared<op::v0::Proposal>(class_probs, class_bbox_deltas, image_shape, attrs),
NodeValidationFailure,
HasSubstr("Proposal layer shape class_probs should be rank 4 compatible"));
}
TEST(type_prop, proposal_v0_invalid_bbox_deltas_dynamic) {
@ -231,15 +279,9 @@ TEST(type_prop, proposal_v0_invalid_bbox_deltas_dynamic) {
auto class_bbox_deltas = make_shared<op::Parameter>(element::f32, PartialShape::dynamic(3));
auto image_shape = make_shared<op::Parameter>(element::f32, Shape{5});
try {
auto proposal = make_shared<op::v0::Proposal>(class_probs, class_bbox_deltas, image_shape, attrs);
// Should have thrown, so fail if it didn't
FAIL() << "Invalid input tensor rank.";
} catch (const NodeValidationFailure& error) {
EXPECT_HAS_SUBSTRING(error.what(), std::string("Proposal layer shape bbox_deltas should be rank 4 compatible"));
} catch (...) {
FAIL() << "Deduced type check failed for unexpected reason";
}
OV_EXPECT_THROW(std::ignore = make_shared<op::v0::Proposal>(class_probs, class_bbox_deltas, image_shape, attrs),
NodeValidationFailure,
HasSubstr("Proposal layer shape bbox_deltas should be rank 4 compatible"));
}
TEST(type_prop, proposal_v0_invalid_image_shape_dynamic) {
@ -248,15 +290,9 @@ TEST(type_prop, proposal_v0_invalid_image_shape_dynamic) {
auto class_bbox_deltas = make_shared<op::Parameter>(element::f32, Shape{1, 4, 3, 4});
auto image_shape = make_shared<op::Parameter>(element::f32, PartialShape::dynamic(0));
try {
auto proposal = make_shared<op::v0::Proposal>(class_probs, class_bbox_deltas, image_shape, attrs);
// Should have thrown, so fail if it didn't
FAIL() << "Invalid input tensor rank.";
} catch (const NodeValidationFailure& error) {
EXPECT_HAS_SUBSTRING(error.what(), std::string("Proposal layer shape image_shape should be rank 1 compatible"));
} catch (...) {
FAIL() << "Deduced type check failed for unexpected reason";
}
OV_EXPECT_THROW(std::ignore = make_shared<op::v0::Proposal>(class_probs, class_bbox_deltas, image_shape, attrs),
NodeValidationFailure,
HasSubstr("Image_shape must be 1-D tensor"));
}
TEST(type_prop, proposal_v0_invalid_class_probs_type) {
@ -265,16 +301,9 @@ TEST(type_prop, proposal_v0_invalid_class_probs_type) {
auto class_bbox_deltas = make_shared<op::Parameter>(element::f32, Shape{1, 4, 3, 4});
auto image_shape = make_shared<op::Parameter>(element::f32, Shape{3});
try {
auto proposal = make_shared<op::v0::Proposal>(class_probs, class_bbox_deltas, image_shape, attrs);
// Should have thrown, so fail if it didn't
FAIL() << "Invalid input tensor rank.";
} catch (const NodeValidationFailure& error) {
EXPECT_HAS_SUBSTRING(error.what(),
std::string("Proposal layer input class_probs should have floating point type"));
} catch (...) {
FAIL() << "Deduced type check failed for unexpected reason";
}
OV_EXPECT_THROW(std::ignore = make_shared<op::v0::Proposal>(class_probs, class_bbox_deltas, image_shape, attrs),
NodeValidationFailure,
HasSubstr("Proposal layer input class_probs should have floating point type"));
}
TEST(type_prop, proposal_v0_invalid_bbox_deltas_type) {
@ -283,16 +312,9 @@ TEST(type_prop, proposal_v0_invalid_bbox_deltas_type) {
auto class_bbox_deltas = make_shared<op::Parameter>(element::i32, Shape{1, 4, 3, 4});
auto image_shape = make_shared<op::Parameter>(element::f32, Shape{3});
try {
auto proposal = make_shared<op::v0::Proposal>(class_probs, class_bbox_deltas, image_shape, attrs);
// Should have thrown, so fail if it didn't
FAIL() << "Invalid input tensor rank.";
} catch (const NodeValidationFailure& error) {
EXPECT_HAS_SUBSTRING(error.what(),
std::string("Proposal layer input bbox_deltas should have floating point type"));
} catch (...) {
FAIL() << "Deduced type check failed for unexpected reason";
}
OV_EXPECT_THROW(std::ignore = make_shared<op::v0::Proposal>(class_probs, class_bbox_deltas, image_shape, attrs),
NodeValidationFailure,
HasSubstr("Proposal layer input bbox_deltas should have floating point type"));
}
TEST(type_prop, proposal_v0_invalid_image_shape_type) {
@ -301,17 +323,11 @@ TEST(type_prop, proposal_v0_invalid_image_shape_type) {
auto class_bbox_deltas = make_shared<op::Parameter>(element::f32, Shape{1, 4, 3, 4});
auto image_shape = make_shared<op::Parameter>(element::i32, Shape{3});
try {
auto proposal = make_shared<op::v0::Proposal>(class_probs, class_bbox_deltas, image_shape, attrs);
// Should have thrown, so fail if it didn't
FAIL() << "Invalid input tensor rank.";
} catch (const NodeValidationFailure& error) {
EXPECT_HAS_SUBSTRING(error.what(),
std::string("Proposal layer input image_shape should have floating point type"));
} catch (...) {
FAIL() << "Deduced type check failed for unexpected reason";
}
OV_EXPECT_THROW(std::ignore = make_shared<op::v0::Proposal>(class_probs, class_bbox_deltas, image_shape, attrs),
NodeValidationFailure,
HasSubstr("Proposal layer input image_shape should have floating point type"));
}
// ------------------------------ V4 ------------------------------
TEST(type_prop, proposal_v4_invalid_class_probs_rank) {
@ -320,15 +336,9 @@ TEST(type_prop, proposal_v4_invalid_class_probs_rank) {
auto class_bbox_deltas = make_shared<op::Parameter>(element::f32, Shape{1, 2, 3, 4});
auto image_shape = make_shared<op::Parameter>(element::f32, Shape{3});
try {
auto proposal = make_shared<op::v4::Proposal>(class_probs, class_bbox_deltas, image_shape, attrs);
// Should have thrown, so fail if it didn't
FAIL() << "Invalid input tensor rank.";
} catch (const NodeValidationFailure& error) {
EXPECT_HAS_SUBSTRING(error.what(), std::string("Proposal layer shape class_probs should be rank 4 compatible"));
} catch (...) {
FAIL() << "Deduced type check failed for unexpected reason";
}
OV_EXPECT_THROW(std::ignore = make_shared<op::v0::Proposal>(class_probs, class_bbox_deltas, image_shape, attrs),
NodeValidationFailure,
HasSubstr("Proposal layer shape class_probs should be rank 4 compatible"));
}
TEST(type_prop, proposal_v4_invalid_class_bbox_deltas_rank) {
@ -337,15 +347,9 @@ TEST(type_prop, proposal_v4_invalid_class_bbox_deltas_rank) {
auto class_bbox_deltas = make_shared<op::Parameter>(element::f32, Shape{1, 2, 3});
auto image_shape = make_shared<op::Parameter>(element::f32, Shape{3});
try {
auto proposal = make_shared<op::v4::Proposal>(class_probs, class_bbox_deltas, image_shape, attrs);
// Should have thrown, so fail if it didn't
FAIL() << "Invalid input tensor rank.";
} catch (const NodeValidationFailure& error) {
EXPECT_HAS_SUBSTRING(error.what(), std::string("Proposal layer shape bbox_deltas should be rank 4 compatible"));
} catch (...) {
FAIL() << "Deduced type check failed for unexpected reason";
}
OV_EXPECT_THROW(std::ignore = make_shared<op::v0::Proposal>(class_probs, class_bbox_deltas, image_shape, attrs),
NodeValidationFailure,
HasSubstr("Proposal layer shape bbox_deltas should be rank 4 compatible"));
}
TEST(type_prop, proposal_v4_invalid_image_shape_rank) {
@ -354,15 +358,9 @@ TEST(type_prop, proposal_v4_invalid_image_shape_rank) {
auto class_bbox_deltas = make_shared<op::Parameter>(element::f32, Shape{1, 4, 3, 4});
auto image_shape = make_shared<op::Parameter>(element::f32, Shape{2, 1});
try {
auto proposal = make_shared<op::v4::Proposal>(class_probs, class_bbox_deltas, image_shape, attrs);
// Should have thrown, so fail if it didn't
FAIL() << "Invalid input tensor rank.";
} catch (const NodeValidationFailure& error) {
EXPECT_HAS_SUBSTRING(error.what(), std::string("Proposal layer shape image_shape should be rank 1 compatible"));
} catch (...) {
FAIL() << "Deduced type check failed for unexpected reason";
}
OV_EXPECT_THROW(std::ignore = make_shared<op::v0::Proposal>(class_probs, class_bbox_deltas, image_shape, attrs),
NodeValidationFailure,
HasSubstr("Image_shape must be 1-D tensor"));
}
TEST(type_prop, proposal_v4_invalid_image_shape_size) {
@ -371,17 +369,33 @@ TEST(type_prop, proposal_v4_invalid_image_shape_size) {
auto class_bbox_deltas = make_shared<op::Parameter>(element::f32, Shape{1, 4, 3, 4});
auto image_shape = make_shared<op::Parameter>(element::f32, Shape{5});
try {
auto proposal = make_shared<op::v4::Proposal>(class_probs, class_bbox_deltas, image_shape, attrs);
// Should have thrown, so fail if it didn't
FAIL() << "Invalid input tensor rank.";
} catch (const NodeValidationFailure& error) {
EXPECT_HAS_SUBSTRING(
error.what(),
std::string("Image_shape 1D tensor must have => 3 and <= 4 elements (image_shape_shape[0]"));
} catch (...) {
FAIL() << "Deduced type check failed for unexpected reason";
}
OV_EXPECT_THROW(std::ignore = make_shared<op::v0::Proposal>(class_probs, class_bbox_deltas, image_shape, attrs),
NodeValidationFailure,
HasSubstr("Image_shape must be 1-D tensor and has got 3 or 4 elements (image_shape_shape[0]"));
}
TEST(type_prop, proposal_v4_default_ctor) {
op::ProposalAttrs attrs;
attrs.base_size = 1;
attrs.pre_nms_topn = 20;
attrs.post_nms_topn = 200;
const size_t batch_size = 7;
auto class_probs = make_shared<op::Parameter>(element::f16, Shape{batch_size, 12, 34, 62});
auto class_bbox_deltas = make_shared<op::Parameter>(element::f16, Shape{batch_size, 24, 34, 62});
auto image_shape = make_shared<op::Parameter>(element::f16, Shape{3});
auto op = make_shared<op::v4::Proposal>();
op->set_arguments(OutputVector{class_probs, class_bbox_deltas, image_shape});
op->set_attrs(attrs);
op->validate_and_infer_types();
EXPECT_EQ(op->get_input_size(), 3);
EXPECT_EQ(op->get_output_size(), 2);
EXPECT_THAT(op->outputs(), Each(Property("Element type", &Output<Node>::get_element_type, element::f16)));
EXPECT_EQ(op->get_output_shape(0), (Shape{batch_size * attrs.post_nms_topn, 5}));
EXPECT_EQ(op->get_output_shape(1), (Shape{batch_size * attrs.post_nms_topn}));
}
TEST(type_prop, proposal_v4_shape_infer) {
@ -395,44 +409,78 @@ TEST(type_prop, proposal_v4_shape_infer) {
auto class_bbox_deltas = make_shared<op::Parameter>(element::f32, Shape{batch_size, 24, 34, 62});
auto image_shape = make_shared<op::Parameter>(element::f32, Shape{3});
auto op = make_shared<op::v4::Proposal>(class_probs, class_bbox_deltas, image_shape, attrs);
ASSERT_EQ(op->get_output_shape(0), (Shape{batch_size * attrs.post_nms_topn, 5}));
ASSERT_EQ(op->get_output_shape(1), (Shape{batch_size * attrs.post_nms_topn}));
EXPECT_THAT(op->outputs(), Each(Property("Element type", &Output<Node>::get_element_type, element::f32)));
EXPECT_EQ(op->get_output_shape(0), (Shape{batch_size * attrs.post_nms_topn, 5}));
EXPECT_EQ(op->get_output_shape(1), (Shape{batch_size * attrs.post_nms_topn}));
}
TEST(type_prop, proposal_v4_dynamic_class_probs_dim1_batch_size_infer) {
op::ProposalAttrs attrs;
attrs.post_nms_topn = 1;
const size_t batch_size = 2;
auto class_probs = make_shared<op::Parameter>(element::f32, PartialShape{Dimension::dynamic(), 2, 3, 4});
auto class_bbox_deltas = make_shared<op::Parameter>(element::f32, Shape{batch_size, 4, 3, 4});
auto image_shape = make_shared<op::Parameter>(element::f32, Shape{3});
const auto batch_size = Dimension(2);
auto class_props_shape = PartialShape{-1, 2, 3, 4};
auto class_bbox_shape = PartialShape{batch_size, 4, {0, 3}, {1, 4}};
set_shape_labels(class_props_shape, 10);
set_shape_labels(class_bbox_shape, 20);
auto class_probs = make_shared<op::Parameter>(element::f64, class_props_shape);
auto class_bbox_deltas = make_shared<op::Parameter>(element::f64, class_bbox_shape);
auto image_shape = make_shared<op::Parameter>(element::f64, Shape{3});
auto op = make_shared<op::v4::Proposal>(class_probs, class_bbox_deltas, image_shape, attrs);
ASSERT_EQ(op->get_output_shape(0), (Shape{batch_size * attrs.post_nms_topn, 5}));
EXPECT_THAT(op->outputs(), Each(Property("Element type", &Output<Node>::get_element_type, element::f64)));
EXPECT_EQ(op->get_output_partial_shape(0), (PartialShape{batch_size * attrs.post_nms_topn, 5}));
EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), ElementsAre(20, ov::no_label));
EXPECT_EQ(op->get_output_partial_shape(1), (PartialShape{batch_size * attrs.post_nms_topn}));
EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(1)), ElementsAre(20));
}
TEST(type_prop, proposal_v4_dynamic_bbox_deltas_dim1_batch_size_infer) {
op::ProposalAttrs attrs;
const size_t batch_size = 2;
attrs.post_nms_topn = 1;
auto class_probs = make_shared<op::Parameter>(element::f32, PartialShape{Dimension::dynamic(), 2, 3, 4});
auto class_bbox_deltas = make_shared<op::Parameter>(element::f32, Shape{batch_size, 4, 3, 4});
auto image_shape = make_shared<op::Parameter>(element::f32, Shape{3});
const auto batch_size = Dimension(2);
auto class_props_shape = PartialShape{batch_size, 2, 3, 4};
auto class_bbox_shape = PartialShape{-1, 4, {0, 3}, {1, 4}};
set_shape_labels(class_props_shape, 10);
auto class_probs = make_shared<op::Parameter>(element::bf16, class_props_shape);
auto class_bbox_deltas = make_shared<op::Parameter>(element::bf16, class_bbox_shape);
auto image_shape = make_shared<op::Parameter>(element::bf16, Shape{3});
auto op = make_shared<op::v4::Proposal>(class_probs, class_bbox_deltas, image_shape, attrs);
ASSERT_EQ(op->get_output_shape(0), (Shape{batch_size * attrs.post_nms_topn, 5}));
EXPECT_THAT(op->outputs(), Each(Property("Element type", &Output<Node>::get_element_type, element::bf16)));
EXPECT_EQ(op->get_output_partial_shape(0), (PartialShape{batch_size * attrs.post_nms_topn, 5}));
EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), ElementsAre(10, ov::no_label));
EXPECT_EQ(op->get_output_partial_shape(1), (PartialShape{batch_size * attrs.post_nms_topn}));
EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(1)), ElementsAre(10));
}
TEST(type_prop, proposal_v4_dynamic_class_probs_bbox_deltas_dim1_batch_size_infer) {
op::ProposalAttrs attrs;
attrs.post_nms_topn = 1;
auto class_probs = make_shared<op::Parameter>(element::f32, PartialShape{Dimension::dynamic(), 2, 3, 4});
auto class_bbox_deltas = make_shared<op::Parameter>(element::f32, PartialShape{Dimension::dynamic(), 4, 3, 4});
auto class_props_shape = PartialShape{-1, 2, 3, 4};
auto class_bbox_shape = PartialShape{-1, 4, 3, 4};
set_shape_labels(class_bbox_shape, 20);
auto class_probs = make_shared<op::Parameter>(element::f32, class_props_shape);
auto class_bbox_deltas = make_shared<op::Parameter>(element::f32, class_bbox_shape);
auto image_shape = make_shared<op::Parameter>(element::f32, Shape{3});
auto op = make_shared<op::v4::Proposal>(class_probs, class_bbox_deltas, image_shape, attrs);
ASSERT_EQ(op->get_output_partial_shape(0), (PartialShape{Dimension::dynamic() * attrs.post_nms_topn, 5}));
ASSERT_EQ(op->get_output_partial_shape(1), (PartialShape{Dimension::dynamic() * attrs.post_nms_topn}));
EXPECT_EQ(op->get_output_partial_shape(0), (PartialShape{-1, 5}));
EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), ElementsAre(20, ov::no_label));
EXPECT_EQ(op->get_output_partial_shape(1), (PartialShape{-1}));
EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(1)), ElementsAre(20));
}
TEST(type_prop, proposal_v4_dynamic_image_shape_shape_infer) {
@ -440,13 +488,24 @@ TEST(type_prop, proposal_v4_dynamic_image_shape_shape_infer) {
attrs.base_size = 1;
attrs.pre_nms_topn = 20;
attrs.post_nms_topn = 200;
const size_t batch_size = 7;
const auto batch_size = Dimension(7);
auto class_probs = make_shared<op::Parameter>(element::f32, Shape{batch_size, 12, 34, 62});
auto class_bbox_deltas = make_shared<op::Parameter>(element::f32, Shape{batch_size, 24, 34, 62});
auto class_props_shape = PartialShape{batch_size, 2, 3, 4};
auto class_bbox_shape = PartialShape{batch_size, 4, {0, 3}, {1, 4}};
set_shape_labels(class_props_shape, 10);
set_shape_labels(class_bbox_shape, 20);
auto class_probs = make_shared<op::Parameter>(element::f32, class_props_shape);
auto class_bbox_deltas = make_shared<op::Parameter>(element::f32, class_bbox_shape);
auto image_shape = make_shared<op::Parameter>(element::f32, PartialShape::dynamic());
auto op = make_shared<op::v4::Proposal>(class_probs, class_bbox_deltas, image_shape, attrs);
ASSERT_EQ(op->get_output_shape(0), (Shape{batch_size * attrs.post_nms_topn, 5}));
EXPECT_EQ(op->get_output_partial_shape(0), (PartialShape{batch_size * attrs.post_nms_topn, 5}));
EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), Each(ov::no_label));
EXPECT_EQ(op->get_output_partial_shape(1), (PartialShape{batch_size * attrs.post_nms_topn}));
EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(1)), ElementsAre(ov::no_label));
}
TEST(type_prop, proposal_v4_everything_dynamic_shape_infer) {
@ -457,8 +516,9 @@ TEST(type_prop, proposal_v4_everything_dynamic_shape_infer) {
auto image_shape = make_shared<op::Parameter>(element::f32, PartialShape::dynamic(1));
auto op = make_shared<op::v4::Proposal>(class_probs, class_bbox_deltas, image_shape, attrs);
ASSERT_EQ(op->get_output_partial_shape(0), (PartialShape{Dimension::dynamic() * attrs.post_nms_topn, 5}));
ASSERT_EQ(op->get_output_partial_shape(1), (PartialShape{Dimension::dynamic() * attrs.post_nms_topn}));
EXPECT_EQ(op->get_output_partial_shape(0), (PartialShape{-1, 5}));
EXPECT_EQ(op->get_output_partial_shape(1), (PartialShape{-1}));
}
TEST(type_prop, proposal_v4_everything_dynamic_class_probs_dynamic_rank_shape_infer) {
@ -469,8 +529,9 @@ TEST(type_prop, proposal_v4_everything_dynamic_class_probs_dynamic_rank_shape_in
auto image_shape = make_shared<op::Parameter>(element::f32, PartialShape::dynamic(1));
auto op = make_shared<op::v4::Proposal>(class_probs, class_bbox_deltas, image_shape, attrs);
ASSERT_EQ(op->get_output_partial_shape(0), (PartialShape{Dimension::dynamic() * attrs.post_nms_topn, 5}));
ASSERT_EQ(op->get_output_partial_shape(1), (PartialShape{Dimension::dynamic() * attrs.post_nms_topn}));
EXPECT_EQ(op->get_output_partial_shape(0), (PartialShape{-1, 5}));
EXPECT_EQ(op->get_output_partial_shape(1), (PartialShape{-1}));
}
TEST(type_prop, proposal_v4_everything_dynamic_class_probs_bbox_deltas_dynamic_rank_shape_infer) {
@ -481,22 +542,61 @@ TEST(type_prop, proposal_v4_everything_dynamic_class_probs_bbox_deltas_dynamic_r
auto image_shape = make_shared<op::Parameter>(element::f32, PartialShape::dynamic(1));
auto op = make_shared<op::v4::Proposal>(class_probs, class_bbox_deltas, image_shape, attrs);
ASSERT_EQ(op->get_output_partial_shape(0), (PartialShape{Dimension::dynamic() * attrs.post_nms_topn, 5}));
ASSERT_EQ(op->get_output_partial_shape(1), (PartialShape{Dimension::dynamic() * attrs.post_nms_topn}));
EXPECT_EQ(op->get_output_partial_shape(0), (PartialShape{-1, 5}));
EXPECT_EQ(op->get_output_partial_shape(1), (PartialShape{-1}));
}
TEST(type_prop, proposal_v4_dynamic_range_class_probs_bbox_deltas_dim1_batch_size_infer) {
op::ProposalAttrs attrs;
attrs.post_nms_topn = 2;
auto class_probs = make_shared<op::Parameter>(element::f32, PartialShape{Dimension(8, 14), 2, 3, 4});
auto class_bbox_deltas = make_shared<op::Parameter>(element::f32, PartialShape{Dimension(10, 15), 4, 3, 4});
auto class_props_shape = PartialShape{{8, 14}, 2, 3, 4};
auto class_bbox_shape = PartialShape{{10, 15}, 4, {0, 3}, {1, 4}};
set_shape_labels(class_props_shape, 10);
set_shape_labels(class_bbox_shape, 20);
auto class_probs = make_shared<op::Parameter>(element::f32, class_props_shape);
auto class_bbox_deltas = make_shared<op::Parameter>(element::f32, class_bbox_shape);
auto image_shape = make_shared<op::Parameter>(element::f32, Shape{3});
auto op = make_shared<op::v4::Proposal>(class_probs, class_bbox_deltas, image_shape, attrs);
ASSERT_EQ(op->get_output_partial_shape(0),
EXPECT_EQ(op->get_output_partial_shape(0),
(PartialShape{Dimension(10 * attrs.post_nms_topn, 14 * attrs.post_nms_topn), 5}));
ASSERT_EQ(op->get_output_partial_shape(1),
EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), Each(ov::no_label));
EXPECT_EQ(op->get_output_partial_shape(1),
(PartialShape{Dimension(10 * attrs.post_nms_topn, 14 * attrs.post_nms_topn)}));
EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(1)), Each(ov::no_label));
}
TEST(type_prop, proposal_v4_class_dynamic_rank_but_batch_shape_defined_in_bbox) {
op::ProposalAttrs attrs;
attrs.post_nms_topn = 1;
const auto batch_size = Dimension(7);
auto class_probs = make_shared<op::Parameter>(element::f32, PartialShape::dynamic());
auto class_bbox_deltas = make_shared<op::Parameter>(element::f32, PartialShape{batch_size, 24, 32, 32});
auto image_shape = make_shared<op::Parameter>(element::f32, PartialShape::dynamic(1));
auto op = make_shared<op::v4::Proposal>(class_probs, class_bbox_deltas, image_shape, attrs);
EXPECT_EQ(op->get_output_partial_shape(0), (PartialShape{batch_size * attrs.post_nms_topn, 5}));
EXPECT_EQ(op->get_output_partial_shape(1), (PartialShape{batch_size * attrs.post_nms_topn}));
}
TEST(type_prop, proposal_v4_bbox_dynamic_rank_but_batch_defined_in_class_probs) {
op::ProposalAttrs attrs;
attrs.post_nms_topn = 1;
const auto batch_size = Dimension(10);
auto class_probs = make_shared<op::Parameter>(element::f32, PartialShape{batch_size, 24, 32, 32});
auto class_bbox_deltas = make_shared<op::Parameter>(element::f32, PartialShape::dynamic());
auto image_shape = make_shared<op::Parameter>(element::f32, PartialShape::dynamic(1));
auto op = make_shared<op::v4::Proposal>(class_probs, class_bbox_deltas, image_shape, attrs);
EXPECT_EQ(op->get_output_partial_shape(0), (PartialShape{batch_size * attrs.post_nms_topn, 5}));
EXPECT_EQ(op->get_output_partial_shape(1), (PartialShape{batch_size * attrs.post_nms_topn}));
}
TEST(type_prop, proposal_v4_invalid_class_probs_dynamic) {
@ -505,15 +605,9 @@ TEST(type_prop, proposal_v4_invalid_class_probs_dynamic) {
auto class_bbox_deltas = make_shared<op::Parameter>(element::f32, Shape{1, 4, 3, 4});
auto image_shape = make_shared<op::Parameter>(element::f32, Shape{5});
try {
auto proposal = make_shared<op::v4::Proposal>(class_probs, class_bbox_deltas, image_shape, attrs);
// Should have thrown, so fail if it didn't
FAIL() << "Invalid input tensor rank.";
} catch (const NodeValidationFailure& error) {
EXPECT_HAS_SUBSTRING(error.what(), std::string("Proposal layer shape class_probs should be rank 4 compatible"));
} catch (...) {
FAIL() << "Deduced type check failed for unexpected reason";
}
OV_EXPECT_THROW(std::ignore = make_shared<op::v4::Proposal>(class_probs, class_bbox_deltas, image_shape, attrs),
NodeValidationFailure,
HasSubstr("Proposal layer shape class_probs should be rank 4 compatible"));
}
TEST(type_prop, proposal_v4_invalid_bbox_deltas_dynamic) {
@ -522,15 +616,9 @@ TEST(type_prop, proposal_v4_invalid_bbox_deltas_dynamic) {
auto class_bbox_deltas = make_shared<op::Parameter>(element::f32, PartialShape::dynamic(3));
auto image_shape = make_shared<op::Parameter>(element::f32, Shape{5});
try {
auto proposal = make_shared<op::v4::Proposal>(class_probs, class_bbox_deltas, image_shape, attrs);
// Should have thrown, so fail if it didn't
FAIL() << "Invalid input tensor rank.";
} catch (const NodeValidationFailure& error) {
EXPECT_HAS_SUBSTRING(error.what(), std::string("Proposal layer shape bbox_deltas should be rank 4 compatible"));
} catch (...) {
FAIL() << "Deduced type check failed for unexpected reason";
}
OV_EXPECT_THROW(std::ignore = make_shared<op::v4::Proposal>(class_probs, class_bbox_deltas, image_shape, attrs),
NodeValidationFailure,
HasSubstr("Proposal layer shape bbox_deltas should be rank 4 compatible"));
}
TEST(type_prop, proposal_v4_invalid_image_shape_dynamic) {
@ -539,15 +627,9 @@ TEST(type_prop, proposal_v4_invalid_image_shape_dynamic) {
auto class_bbox_deltas = make_shared<op::Parameter>(element::f32, Shape{1, 4, 3, 4});
auto image_shape = make_shared<op::Parameter>(element::f32, PartialShape::dynamic(0));
try {
auto proposal = make_shared<op::v4::Proposal>(class_probs, class_bbox_deltas, image_shape, attrs);
// Should have thrown, so fail if it didn't
FAIL() << "Invalid input tensor rank.";
} catch (const NodeValidationFailure& error) {
EXPECT_HAS_SUBSTRING(error.what(), std::string("Proposal layer shape image_shape should be rank 1 compatible"));
} catch (...) {
FAIL() << "Deduced type check failed for unexpected reason";
}
OV_EXPECT_THROW(std::ignore = make_shared<op::v4::Proposal>(class_probs, class_bbox_deltas, image_shape, attrs),
NodeValidationFailure,
HasSubstr("Image_shape must be 1-D tensor"));
}
TEST(type_prop, proposal_v4_invalid_class_probs_type) {
@ -556,16 +638,9 @@ TEST(type_prop, proposal_v4_invalid_class_probs_type) {
auto class_bbox_deltas = make_shared<op::Parameter>(element::f32, Shape{1, 4, 3, 4});
auto image_shape = make_shared<op::Parameter>(element::f32, Shape{3});
try {
auto proposal = make_shared<op::v4::Proposal>(class_probs, class_bbox_deltas, image_shape, attrs);
// Should have thrown, so fail if it didn't
FAIL() << "Invalid input tensor rank.";
} catch (const NodeValidationFailure& error) {
EXPECT_HAS_SUBSTRING(error.what(),
std::string("Proposal layer input class_probs should have floating point type"));
} catch (...) {
FAIL() << "Deduced type check failed for unexpected reason";
}
OV_EXPECT_THROW(std::ignore = make_shared<op::v4::Proposal>(class_probs, class_bbox_deltas, image_shape, attrs),
NodeValidationFailure,
HasSubstr("Proposal layer input class_probs should have floating point type"));
}
TEST(type_prop, proposal_v4_invalid_bbox_deltas_type) {
@ -574,16 +649,9 @@ TEST(type_prop, proposal_v4_invalid_bbox_deltas_type) {
auto class_bbox_deltas = make_shared<op::Parameter>(element::i32, Shape{1, 4, 3, 4});
auto image_shape = make_shared<op::Parameter>(element::f32, Shape{3});
try {
auto proposal = make_shared<op::v4::Proposal>(class_probs, class_bbox_deltas, image_shape, attrs);
// Should have thrown, so fail if it didn't
FAIL() << "Invalid input tensor rank.";
} catch (const NodeValidationFailure& error) {
EXPECT_HAS_SUBSTRING(error.what(),
std::string("Proposal layer input bbox_deltas should have floating point type"));
} catch (...) {
FAIL() << "Deduced type check failed for unexpected reason";
}
OV_EXPECT_THROW(std::ignore = make_shared<op::v4::Proposal>(class_probs, class_bbox_deltas, image_shape, attrs),
NodeValidationFailure,
HasSubstr("Proposal layer input bbox_deltas should have floating point type"));
}
TEST(type_prop, proposal_v4_invalid_image_shape_type) {
@ -592,14 +660,7 @@ TEST(type_prop, proposal_v4_invalid_image_shape_type) {
auto class_bbox_deltas = make_shared<op::Parameter>(element::f32, Shape{1, 4, 3, 4});
auto image_shape = make_shared<op::Parameter>(element::i32, Shape{3});
try {
auto proposal = make_shared<op::v4::Proposal>(class_probs, class_bbox_deltas, image_shape, attrs);
// Should have thrown, so fail if it didn't
FAIL() << "Invalid input tensor rank.";
} catch (const NodeValidationFailure& error) {
EXPECT_HAS_SUBSTRING(error.what(),
std::string("Proposal layer input image_shape should have floating point type"));
} catch (...) {
FAIL() << "Deduced type check failed for unexpected reason";
}
OV_EXPECT_THROW(std::ignore = make_shared<op::v4::Proposal>(class_probs, class_bbox_deltas, image_shape, attrs),
NodeValidationFailure,
HasSubstr("Proposal layer input image_shape should have floating point type"));
}

View File

@ -43,6 +43,19 @@ TEST(type_prop, random_uniform_dynamic_shape) {
EXPECT_TRUE(r->get_output_partial_shape(0).same_scheme(PartialShape::dynamic()));
}
TEST(type_prop, random_uniform_dynamic_shape_1) {
auto shape = make_shared<opset8::Parameter>(element::i32, PartialShape{{0, 10}, 4, {3, 7}, -1});
auto out_shape = make_shared<opset8::ShapeOf>(shape);
auto min_val = make_shared<opset8::Constant>(element::i64, Shape{}, 5);
auto max_val = make_shared<opset8::Constant>(element::i64, Shape{}, 10);
auto r = make_shared<opset8::RandomUniform>(out_shape, min_val, max_val, element::i64, 100, 200);
EXPECT_EQ(r->get_output_element_type(0), element::i64);
EXPECT_EQ(r->get_output_partial_shape(0), PartialShape({{0, 10}, 4, {3, 7}, -1}));
}
TEST(type_prop, random_uniform_dynamic_rank) {
auto out_shape = make_shared<opset8::Parameter>(element::i32, PartialShape::dynamic());
auto min_val = make_shared<opset8::Constant>(element::f64, Shape{}, 5);

View File

@ -21,6 +21,29 @@ TEST(type_prop, reorg_yolo_stride_2) {
EXPECT_EQ(reorg_yolo->get_output_shape(0), expected_shape);
}
TEST(type_prop, reorg_yolo_stride_2_dynamic_shape) {
const auto in_shape = PartialShape{-1, -1, -1, -1};
size_t stride = 2;
auto data_param = make_shared<op::Parameter>(element::f32, in_shape);
auto reorg_yolo = make_shared<op::v0::ReorgYolo>(data_param, stride);
const auto expected_shape = PartialShape{-1, -1, -1, -1};
EXPECT_EQ(reorg_yolo->get_output_partial_shape(0), expected_shape);
}
TEST(type_prop, reorg_yolo_stride_2_dynamic_shape_ranges) {
const auto in_shape = PartialShape{{1, 4}, {3, 9}, {16, 32}, {16, 32}};
size_t stride = 2;
auto data_param = make_shared<op::Parameter>(element::f32, in_shape);
auto reorg_yolo = make_shared<op::v0::ReorgYolo>(data_param, stride);
// in_shape [N,C,H,W] -> out_shape [N, C*stride*stride, H/stride, W/stride]
const auto expected_shape = PartialShape{{1, 4}, {12, 36}, {8, 16}, {8, 16}};
EXPECT_EQ(reorg_yolo->get_output_partial_shape(0), expected_shape);
}
TEST(type_prop, reorg_yolo_stride_2_batch_2) {
const auto in_shape = Shape{2, 64, 26, 26};
size_t stride = 2;

View File

@ -3,6 +3,7 @@
//
#include "openvino/frontend/pytorch/node_context.hpp"
#include "openvino/op/convert.hpp"
#include "openvino/op/reduce_sum.hpp"
#include "utils.hpp"
@ -16,6 +17,9 @@ OutputVector translate_sum(const NodeContext& context) {
bool keep_dims = false;
ov::Output<ov::Node> axes;
auto data = context.get_input(0);
if (data.get_element_type() == element::boolean) {
data = context.mark_node(std::make_shared<ov::op::v0::Convert>(data, element::i64));
}
if (context.input_is_none(1)) {
axes = get_axes_range(context, 0);
} else {

View File

@ -0,0 +1,46 @@
// Copyright (C) 2018-2023 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#include "openvino/frontend/pytorch/node_context.hpp"
#include "openvino/op/add.hpp"
#include "openvino/op/concat.hpp"
#include "openvino/op/constant.hpp"
#include "openvino/op/convert.hpp"
#include "openvino/op/reshape.hpp"
#include "openvino/op/shape_of.hpp"
#include "openvino/op/slice.hpp"
#include "utils.hpp"
namespace ov {
namespace frontend {
namespace pytorch {
namespace op {
using namespace ov::op;
OutputVector translate_unflatten(const NodeContext& context) {
// aten::unflatten.int(Tensor(a) self, int dim, int[] sizes) -> Tensor(a)
num_inputs_check(context, 3, 3);
auto input = context.get_input(0);
auto dim = context.get_input(1);
auto sizes = context.get_input(2);
auto input_shape = context.mark_node(std::make_shared<v3::ShapeOf>(input, element::i32));
auto zero_1d = context.mark_node(v0::Constant::create(element::i32, Shape{1}, {0}));
auto one_1d = context.mark_node(v0::Constant::create(element::i32, Shape{1}, {1}));
dim = context.mark_node(std::make_shared<v0::Convert>(dim, element::i32));
dim = normalize_axis(context, dim, input);
sizes = context.mark_node(std::make_shared<v0::Convert>(sizes, element::i32));
auto max_int = context.mark_node(v0::Constant::create(element::i32, Shape{1}, {std::numeric_limits<int>::max()}));
auto dim_plus_one = context.mark_node(std::make_shared<v1::Add>(dim, one_1d));
auto head_part_rank = context.mark_node(std::make_shared<v8::Slice>(input_shape, zero_1d, dim, one_1d));
auto tail_part_rank = context.mark_node(std::make_shared<v8::Slice>(input_shape, dim_plus_one, max_int, one_1d));
auto new_shape =
context.mark_node(std::make_shared<v0::Concat>(OutputVector{head_part_rank, sizes, tail_part_rank}, 0));
return {context.mark_node(std::make_shared<v1::Reshape>(input, new_shape, false))};
};
} // namespace op
} // namespace pytorch
} // namespace frontend
} // namespace ov

View File

@ -126,6 +126,7 @@ OP_CONVERTER(translate_topk);
OP_CONVERTER(translate_transpose);
OP_CONVERTER(translate_tril);
OP_CONVERTER(translate_triu);
OP_CONVERTER(translate_unflatten);
OP_CONVERTER(translate_unfold);
OP_CONVERTER(translate_upsample_bicubic2d);
OP_CONVERTER(translate_upsample_bilinear2d);
@ -249,6 +250,7 @@ const std::map<std::string, CreatorFunction> get_supported_ops() {
{"aten::Int", op::translate_int},
{"aten::IntImplicit", op::translate_int},
{"aten::is_grad_enabled", op::return_false_scalar},
{"aten::item", op::translate_1to1_match_1_inputs<opset10::Squeeze>},
{"aten::layer_norm", op::translate_layer_norm},
{"aten::le", op::translate_1to1_match_2_inputs_align_types<opset10::LessEqual>},
{"aten::leaky_relu", op::translate_1to1_match_2_inputs<opset10::PRelu>},
@ -338,6 +340,7 @@ const std::map<std::string, CreatorFunction> get_supported_ops() {
{"aten::triu", op::translate_triu},
{"aten::type_as",
op::translate_1to1_match_2_inputs<opset10::ConvertLike>}, // TODO: overflow semantics is different
{"aten::unflatten", op::translate_unflatten},
{"aten::unfold", op::translate_unfold},
{"aten::unsqueeze", op::translate_1to1_match_2_inputs<opset10::Unsqueeze>},
{"aten::unsqueeze_", op::inplace_op<op::translate_1to1_match_2_inputs<opset10::Unsqueeze>>},

View File

@ -116,6 +116,17 @@ std::shared_ptr<Node> get_axes_range(const NodeContext& context, int input_id) {
return context.mark_node(std::make_shared<opset10::Range>(start, reduced_rank, step, element::i32));
};
std::shared_ptr<Node> normalize_axis(const NodeContext& context,
const Output<Node>& axis,
const Output<Node>& input_node) {
Output<Node> rank;
std::tie(std::ignore, rank) = get_shape_rank(context, input_node);
auto axis_rank = context.mark_node(std::make_shared<opset10::Add>(axis, rank));
auto is_less = context.mark_node(std::make_shared<opset10::Less>(axis_rank, rank));
auto new_axis = context.mark_node(std::make_shared<opset10::Select>(is_less, axis_rank, axis));
return new_axis;
}
std::shared_ptr<Node> numel(const NodeContext& context, const Output<Node>& x) {
auto input_shape = context.mark_node(std::make_shared<opset10::ShapeOf>(x, element::i32));
auto axes = context.mark_node(opset10::Constant::create(element::i32, Shape({1}), {0}));

View File

@ -38,6 +38,10 @@ Output<Node> reshape_kernel_for_group(const NodeContext& context, const Output<N
std::shared_ptr<Node> get_axes_range(const NodeContext& context, int input_id);
std::shared_ptr<Node> normalize_axis(const NodeContext& context,
const Output<Node>& axis,
const Output<Node>& input_node);
std::shared_ptr<Node> numel(const NodeContext& context, const Output<Node>& x);
element::Type convert_dtype(int64_t dtype_value);

View File

@ -11,6 +11,24 @@
namespace ov {
namespace details {
namespace {
bool model_has_suitable_do(const std::shared_ptr<const ov::Model>& model) {
bool bDetectionOutput = false;
for (auto& result_node : model->get_results()) {
auto do_node = result_node->input_value(0).get_node_shared_ptr();
std::shared_ptr<ov::Node> convert_node;
if (ov::is_type<ov::opset1::Convert>(do_node)) { // cases with do->convert->result
convert_node = do_node;
do_node = convert_node->get_input_node_shared_ptr(0);
}
auto detectionOutputBase = std::dynamic_pointer_cast<ov::op::util::DetectionOutputBase>(do_node);
if (detectionOutputBase) {
bDetectionOutput = true;
}
}
return bDetectionOutput;
}
} // namespace
NetworkBatchAbility is_model_batchable(const std::shared_ptr<const ov::Model>& model,
const std::string& deviceNameWithoutBatch,
@ -48,11 +66,16 @@ NetworkBatchAbility is_model_batchable(const std::shared_ptr<const ov::Model>& m
if (!any_batched_inputs)
return NetworkBatchAbility::NO;
return model_has_suitable_do(model) ? NetworkBatchAbility::WITH_HETERO : NetworkBatchAbility::AS_IS;
}
std::shared_ptr<const ov::Model> apply_batch_affinity(const std::shared_ptr<const ov::Model>& model_,
const std::string& deviceNameWithoutBatch) {
auto model = model_->clone();
for (auto&& node : model->get_ops())
node->get_rt_info()["affinity"] = "BATCH"; // default affinity (ignored if HETERO is not triggered)
// have to execute the DetectionOutput separately (without batching)
// as this layer does mix-in the values from the different inputs (batch id)
bool bDetectionOutput = false;
for (auto& result_node : model->get_results()) {
auto do_node = result_node->input_value(0).get_node_shared_ptr();
std::shared_ptr<ov::Node> convert_node;
@ -68,10 +91,9 @@ NetworkBatchAbility is_model_batchable(const std::shared_ptr<const ov::Model>& m
do_node->get_rt_info()["affinity"] = deviceNameWithoutBatch;
if (convert_node)
convert_node->get_rt_info()["affinity"] = deviceNameWithoutBatch;
bDetectionOutput = true;
}
}
return bDetectionOutput ? NetworkBatchAbility::WITH_HETERO : NetworkBatchAbility::AS_IS;
return model;
}
} // namespace details

View File

@ -10,14 +10,22 @@
namespace ov {
namespace details {
/**
* @brief Checks if the input network is batch-able (e.g. no dynamic inputs, inputs has the batch dimension, etc)
* @param function A ngraph function to check for automatic-batching applicability
* @return An enum value indicating whether the network can be safely batched (with HETERO or as is) or not
* @brief Checks if the input model is batch-able (e.g. no dynamic inputs, inputs has the batch dimension, etc)
* @param model A model to check for automatic-batching applicability
* @return An enum value indicating whether the model can be safely batched (with HETERO or as is) or not
*/
enum class NetworkBatchAbility : uint32_t { NO = 0, AS_IS, WITH_HETERO };
NetworkBatchAbility is_model_batchable(const std::shared_ptr<const ov::Model>& model,
const std::string& deviceNoBatch,
bool strictly_track_dims);
/**
* @brief Sets BATCH affinity for all the nodes except DetectionOutput
* @param model_ A model to set affinity to
* @param deviceNameWithoutBatch Device name to set for DetectionOutput node if any
* @return A copy of the model with set affinity
*/
std::shared_ptr<const ov::Model> apply_batch_affinity(const std::shared_ptr<const ov::Model>& model_,
const std::string& deviceNameWithoutBatch);
} // namespace details
} // namespace ov

View File

@ -536,14 +536,14 @@ ov::Plugin ov::CoreImpl::get_plugin(const std::string& pluginName) const {
}
}
ov::SoPtr<ov::ICompiledModel> ov::CoreImpl::compile_model(const std::shared_ptr<const ov::Model>& model,
ov::SoPtr<ov::ICompiledModel> ov::CoreImpl::compile_model(const std::shared_ptr<const ov::Model>& model_,
const std::string& device_name,
const ov::AnyMap& config) const {
OV_ITT_SCOPE(FIRST_INFERENCE, ie::itt::domains::IE_LT, "Core::compile_model::model");
std::string deviceName = device_name;
ov::AnyMap config_with_batch = config;
// if auto-batching is applicable, the below function will patch the device name and config accordingly:
apply_auto_batching(model, deviceName, config_with_batch);
auto model = apply_auto_batching(model_, deviceName, config_with_batch);
auto parsed = parseDeviceNameIntoConfig(deviceName, config_with_batch);
auto plugin = get_plugin(parsed._deviceName);
@ -562,7 +562,7 @@ ov::SoPtr<ov::ICompiledModel> ov::CoreImpl::compile_model(const std::shared_ptr<
return res;
}
ov::SoPtr<ov::ICompiledModel> ov::CoreImpl::compile_model(const std::shared_ptr<const ov::Model>& model,
ov::SoPtr<ov::ICompiledModel> ov::CoreImpl::compile_model(const std::shared_ptr<const ov::Model>& model_,
const ov::RemoteContext& context,
const ov::AnyMap& config) const {
OV_ITT_SCOPE(FIRST_INFERENCE, ie::itt::domains::IE_LT, "Core::compile_model::RemoteContext");
@ -572,7 +572,7 @@ ov::SoPtr<ov::ICompiledModel> ov::CoreImpl::compile_model(const std::shared_ptr<
std::string deviceName = context.get_device_name();
ov::AnyMap config_with_batch = config;
// if auto-batching is applicable, the below function will patch the device name and config accordingly:
apply_auto_batching(model, deviceName, config_with_batch);
auto model = apply_auto_batching(model_, deviceName, config_with_batch);
auto parsed = parseDeviceNameIntoConfig(deviceName, config_with_batch);
auto plugin = get_plugin(parsed._deviceName);
@ -734,13 +734,13 @@ ov::AnyMap ov::CoreImpl::get_supported_property(const std::string& full_device_n
// Considerations:
// 1. in case of virtual devices all the magic will happen on the level when
// virtual device calls ICore::get_supported_property for real HW devices
// so, for now we can returns user properties almost as is without any
// so, for now we can return user properties almost as is without any
// filtering / flattening
// 2. The only exception here: while common properties like ov::num::streams or
// ov::hint::performance_mode are shared across all the devices, the
// ov::device::priority cannot be shared, because it's specific for current virtual
// plugin. So, we need to remove ov::device::priorities from the list, because it's
// supposed to be set for current virtual plugin and cannot be propogated down
// supposed to be set for current virtual plugin and cannot be propagated down
ov::AnyMap return_properties = user_properties;
auto device_priorities_it = return_properties.find(ov::device::priorities.name());
if (device_priorities_it != return_properties.end()) {
@ -806,9 +806,9 @@ ov::RemoteContext ov::CoreImpl::get_default_context(const std::string& device_na
return get_plugin(parsed._deviceName).get_default_context(parsed._config);
}
void ov::CoreImpl::apply_auto_batching(const std::shared_ptr<const ov::Model>& model,
std::string& deviceName,
ov::AnyMap& config) const {
std::shared_ptr<const ov::Model> ov::CoreImpl::apply_auto_batching(const std::shared_ptr<const ov::Model>& model,
std::string& deviceName,
ov::AnyMap& config) const {
std::string deviceNameWithBatchSize, deviceNameWithoutBatch;
// fully strict dims tracking by default (Auto-Batching is enabled implicitly)
bool strictly_check_dims = true;
@ -816,7 +816,7 @@ void ov::CoreImpl::apply_auto_batching(const std::shared_ptr<const ov::Model>& m
// explicitly enabled Auto-Batching
auto pos = deviceName.find_first_of(":");
if (pos == std::string::npos)
return; // BATCH device is already configured via the config
return model; // BATCH device is already configured via the config
deviceNameWithBatchSize = deviceName.substr(pos + 1);
deviceNameWithoutBatch = ov::DeviceIDParser::get_batch_device(deviceNameWithBatchSize);
// when user sets the BATCH device explicitly, we may check the dims less strictly
@ -827,7 +827,7 @@ void ov::CoreImpl::apply_auto_batching(const std::shared_ptr<const ov::Model>& m
try {
get_plugin("BATCH");
} catch (const std::runtime_error&) {
return;
return model;
}
// check whether the Auto-Batching is disabled explicitly
@ -835,12 +835,12 @@ void ov::CoreImpl::apply_auto_batching(const std::shared_ptr<const ov::Model>& m
if (batch_mode != config.end()) {
const auto disabled = batch_mode->second.as<std::string>() == CONFIG_VALUE(NO);
// virtual plugins like AUTO/MULTI will need the config
// e.g to deduce the #requests correctly
// e.g. to deduce the #requests correctly
// otherwise, no need for this config key in the rest of loading
if (!is_virtual_device(deviceName))
config.erase(batch_mode);
if (disabled)
return;
return model;
}
// check whether if the Auto-Batching is applicable to the device
@ -851,7 +851,7 @@ void ov::CoreImpl::apply_auto_batching(const std::shared_ptr<const ov::Model>& m
.as<std::vector<std::string>>();
auto it = std::find(metrics.begin(), metrics.end(), METRIC_KEY(OPTIMAL_BATCH_SIZE));
if (metrics.end() == it)
return;
return model;
// if applicable, the Auto-Batching is implicitly enabled via the performance hints
bool bTputInPlg =
@ -861,13 +861,13 @@ void ov::CoreImpl::apply_auto_batching(const std::shared_ptr<const ov::Model>& m
const auto& excl = config.find(CONFIG_KEY(EXCLUSIVE_ASYNC_REQUESTS));
bool bExclReqsEnabled = (excl != config.end() && excl->second.as<std::string>() == CONFIG_VALUE(YES));
if (bExclReqsEnabled || (!bTputInPlg && !bTputInLoadCfg))
return;
return model;
}
auto batchConfig = deviceNameWithBatchSize.empty() ? deviceNameWithoutBatch : deviceNameWithBatchSize;
auto res = ov::details::is_model_batchable(model, deviceNameWithoutBatch, strictly_check_dims);
switch (res) {
case ov::details::NetworkBatchAbility::NO:
return;
return model;
case ov::details::NetworkBatchAbility::AS_IS:
deviceName = "BATCH:" + batchConfig;
break;
@ -876,6 +876,7 @@ void ov::CoreImpl::apply_auto_batching(const std::shared_ptr<const ov::Model>& m
config[CONFIG_KEY(AUTO_BATCH_DEVICE_CONFIG)] = batchConfig;
break;
}
return ov::details::apply_batch_affinity(model, deviceNameWithoutBatch);
}
void ov::CoreImpl::set_property(const std::string& device_name, const AnyMap& properties) {

View File

@ -218,7 +218,7 @@ public:
*/
void register_plugins_in_registry(const std::string& xml_config_file, const bool& by_abs_path = false);
void apply_auto_batching(const std::shared_ptr<const ov::Model>& model,
std::shared_ptr<const ov::Model> apply_auto_batching(const std::shared_ptr<const ov::Model>& model,
std::string& deviceName,
ov::AnyMap& config) const;

View File

@ -7,11 +7,13 @@
#include <gtest/gtest.h>
#include <fstream>
#include <thread>
#include "common_test_utils/file_utils.hpp"
#include "common_test_utils/test_assertions.hpp"
#include "dev/core_impl.hpp"
#include "file_utils.h"
#include "openvino/op/relu.hpp"
#include "openvino/util/file_util.hpp"
using namespace testing;
@ -381,3 +383,39 @@ TEST(CoreTests_parse_device_config, get_device_config) {
ov::AnyMap{ov::device::priorities("MULTI,DEVICE"),
ov::device::properties(ov::AnyMap{{"MULTI", ov::AnyMap{ov::device::priorities("DEVICE")}}})});
}
class ApplyAutoBatchThreading : public testing::Test {
public:
static void runParallel(std::function<void(void)> func,
const unsigned int iterations = 50,
const unsigned int threadsNum = 24) {
std::vector<std::thread> threads(threadsNum);
for (auto& thread : threads) {
thread = std::thread([&]() {
for (unsigned int i = 0; i < iterations; ++i) {
func();
}
});
}
for (auto& thread : threads) {
if (thread.joinable())
thread.join();
}
}
};
// Tested function: apply_auto_batch
TEST_F(ApplyAutoBatchThreading, ApplyAutoBatch) {
ov::CoreImpl core(true);
auto input = std::make_shared<ov::op::v0::Parameter>(ov::element::f32, ov::PartialShape{1, 2, 3, 4});
ov::Output<ov::Node> intermediate = input->output(0);
for (size_t i = 0; i < 100; ++i)
intermediate = std::make_shared<ov::op::v0::Relu>(input)->output(0);
auto output = std::make_shared<ov::op::v0::Result>(intermediate);
auto model = std::make_shared<ov::Model>(ov::ResultVector{output}, ov::ParameterVector{input});
std::string device = "GPU";
ov::AnyMap config;
runParallel([&]() {
core.apply_auto_batching(model, device, config);
});
}

View File

@ -21,8 +21,6 @@ addIeTargetTest(
${SHARED_HEADERS_DIR}
LINK_LIBRARIES
unitTestUtils
openvino::runtime
openvino::runtime::dev
ngraphFunctions
DEPENDENCIES
mock_engine

View File

@ -305,11 +305,7 @@ protected:
/**
* @brief Base shape inference object implementing the IStaticShapeInfer without padding support
*
* @tparam TOp Type of operator.
* @tparam mask Bit Mask of data dependent ports.
*/
template <class TOp, uint32_t mask>
class ShapeInferBase : public IStaticShapeInfer {
public:
using iface_type = IStaticShapeInfer;
@ -330,10 +326,8 @@ public:
return infer(input_shapes, make_tensor_accessor(constant_data));
}
IShapeInferCommon::Result infer(const std::vector<StaticShape>& input_shapes,
const ov::ITensorAccessor& tensor_accessor) override {
auto result = shape_infer(static_cast<TOp*>(m_node.get()), input_shapes, tensor_accessor);
return {std::move(result), ShapeInferStatus::success};
IShapeInferCommon::Result infer(const std::vector<StaticShape>& input_shapes, const ov::ITensorAccessor&) override {
OPENVINO_THROW("Not implemented by base class");
}
const ov::CoordinateDiff& get_pads_begin() override {
@ -349,7 +343,7 @@ public:
}
port_mask_t get_port_mask() const override {
return mask;
return 0;
}
protected:
@ -357,6 +351,44 @@ protected:
std::shared_ptr<ov::Node> m_node;
};
/**
* @brief Shape inference using tensor accessor to get constant data.
*
* @tparam TOp Type of operator.
* @tparam MASK The bit mask where each bit corresponds to an input port number.
*/
template <class TOp, uint32_t MASK>
class ShapeInferTA : public ShapeInferBase {
public:
using ShapeInferBase::ShapeInferBase;
IShapeInferCommon::Result infer(const std::vector<StaticShape>& input_shapes,
const ov::ITensorAccessor& tensor_accessor) override {
return {shape_infer(static_cast<TOp*>(m_node.get()), input_shapes, tensor_accessor), ShapeInferStatus::success};
}
port_mask_t get_port_mask() const override {
return MASK;
}
};
/**
* @brief Shape inference not using tensor accessor
*
* The MASK is 0 there is no dependant inputs with data for shape inference.
*
* @tparam TOp Type of operator.
*/
template <class TOp>
class ShapeInferTA<TOp, 0> : public ShapeInferBase {
public:
using ShapeInferBase::ShapeInferBase;
IShapeInferCommon::Result infer(const std::vector<StaticShape>& input_shapes, const ov::ITensorAccessor&) override {
return {shape_infer(static_cast<TOp*>(m_node.get()), input_shapes), ShapeInferStatus::success};
}
};
/**
* \brief Shape infer factory
*
@ -510,7 +542,6 @@ const IShapeInferCommonFactory::TRegistry IShapeInferCommonFactory::registry{
_OV_OP_SHAPE_INFER_REG(Pad, entryIOC),
_OV_OP_SHAPE_INFER_REG(PriorBox, entryIOC),
_OV_OP_SHAPE_INFER_REG(PriorBoxClustered, entryIOC),
_OV_OP_SHAPE_INFER_REG(Proposal, entryIO),
_OV_OP_SHAPE_INFER_REG(PSROIPooling, entryIO),
_OV_OP_SHAPE_INFER_REG(Range, entryIOC),
_OV_OP_SHAPE_INFER_REG(RDFT, entryIOC),
@ -566,7 +597,6 @@ const IShapeInferCommonFactory::TRegistry IShapeInferCommonFactory::registry{
_OV_OP_SHAPE_INFER_REG(opset1::Interpolate, entryIOC),
_OV_OP_SHAPE_INFER_REG(opset1::LSTMCell, entryIO),
_OV_OP_SHAPE_INFER_REG(opset1::MaxPool, ShapeInferWithPadding),
_OV_OP_SHAPE_INFER_REG(opset1::Proposal, entryIO),
_OV_OP_SHAPE_INFER_REG(opset1::Range, entryIOC),
_OV_OP_SHAPE_INFER_REG(opset1::ShapeOf, entryIO),
_OV_OP_SHAPE_INFER_REG(opset1::TopK, entryIOC),
@ -583,11 +613,13 @@ using IStaticShapeInferFactory =
template <>
const IStaticShapeInferFactory::TRegistry IStaticShapeInferFactory::registry{
// Default opset
_OV_OP_SHAPE_INFER_MASK_REG(Tile, ShapeInferBase, util::bit::mask(1)),
_OV_OP_SHAPE_INFER_MASK_REG(ExperimentalDetectronROIFeatureExtractor, ShapeInferBase, util::bit::mask()),
_OV_OP_SHAPE_INFER_MASK_REG(ExperimentalDetectronROIFeatureExtractor, ShapeInferTA, util::bit::mask()),
_OV_OP_SHAPE_INFER_MASK_REG(Proposal, ShapeInferTA, util::bit::mask()),
_OV_OP_SHAPE_INFER_MASK_REG(Tile, ShapeInferTA, util::bit::mask(1)),
// Operators shape inferences for specific opset version should be specified below
// opset1
_OV_OP_SHAPE_INFER_MASK_REG(opset1::Reverse, ShapeInferBase, util::bit::mask(1)),
_OV_OP_SHAPE_INFER_MASK_REG(opset1::Proposal, ShapeInferTA, util::bit::mask()),
_OV_OP_SHAPE_INFER_MASK_REG(opset1::Reverse, ShapeInferTA, util::bit::mask(1)),
};
#undef _OV_OP_NON_TEMPLATE_SHAPE_INFER_REG

View File

@ -1,51 +0,0 @@
// Copyright (C) 2018-2023 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#include <gtest/gtest.h>
#include "utils.hpp"
using namespace ov;
using namespace ov::intel_cpu;
TEST(StaticShapeInferenceTest, ProposalV0Test) {
op::v0::Proposal::Attributes attrs;
attrs.base_size = 1;
attrs.pre_nms_topn = 20;
attrs.post_nms_topn = 200;
const size_t batch_size = 7;
auto class_probs = std::make_shared<op::v0::Parameter>(element::f32, PartialShape{-1, -1, -1, -1});
auto class_bbox_deltas = std::make_shared<op::v0::Parameter>(element::f32, PartialShape{-1, -1, -1, -1});
auto image_shape = std::make_shared<op::v0::Parameter>(element::f32, PartialShape{-1});
auto op = std::make_shared<op::v0::Proposal>(class_probs, class_bbox_deltas, image_shape, attrs);
const std::vector<StaticShape> input_shapes = {StaticShape{batch_size, 12, 34, 62},
StaticShape{batch_size, 24, 34, 62},
StaticShape{3}};
std::vector<StaticShape> output_shapes = {StaticShape{}};
shape_inference(op.get(), input_shapes, output_shapes);
ASSERT_EQ(output_shapes[0], (StaticShape{batch_size * attrs.post_nms_topn, 5}));
}
TEST(StaticShapeInferenceTest, ProposalV4Test) {
op::v0::Proposal::Attributes attrs;
attrs.base_size = 1;
attrs.pre_nms_topn = 20;
attrs.post_nms_topn = 200;
const size_t batch_size = 7;
auto class_probs = std::make_shared<op::v0::Parameter>(element::f32, PartialShape{-1, -1, -1, -1});
auto class_bbox_deltas = std::make_shared<op::v0::Parameter>(element::f32, PartialShape{-1, -1, -1, -1});
auto image_shape = std::make_shared<op::v0::Parameter>(element::f32, PartialShape{-1});
auto op = std::make_shared<op::v4::Proposal>(class_probs, class_bbox_deltas, image_shape, attrs);
const std::vector<StaticShape> input_shapes = {StaticShape{batch_size, 12, 34, 62},
StaticShape{batch_size, 24, 34, 62},
StaticShape{3}};
std::vector<StaticShape> output_shapes = {StaticShape{}, StaticShape{}};
shape_inference(op.get(), input_shapes, output_shapes);
ASSERT_EQ(output_shapes[0], (StaticShape{batch_size * attrs.post_nms_topn, 5}));
ASSERT_EQ(output_shapes[1], (StaticShape{batch_size * attrs.post_nms_topn}));
}

View File

@ -0,0 +1,111 @@
// Copyright (C) 2018-2023 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#include <gmock/gmock.h>
#include "common_test_utils/test_assertions.hpp"
#include "utils.hpp"
using namespace ov;
using namespace ov::intel_cpu;
using namespace testing;
template <class TOp>
class ProposalTest : public OpStaticShapeInferenceTest<TOp> {
protected:
using Attrs = typename TOp::Attributes;
static Attrs make_attrs(size_t post_nms_count) {
Attrs attrs;
attrs.post_nms_topn = post_nms_count;
return attrs;
}
static size_t exp_out_size() {
if (std::is_same<op::v0::Proposal, TOp>::value) {
return 1;
} else if (std::is_same<op::v4::Proposal, TOp>::value) {
return 2;
} else {
return 0;
}
}
};
TYPED_TEST_SUITE_P(ProposalTest);
TYPED_TEST_P(ProposalTest, default_ctor) {
this->op = this->make_op();
this->op->set_attrs(this->make_attrs(10));
this->input_shapes = ShapeVector{{2, 3, 10, 10}, {2, 6, 10, 10}, {3}};
shape_inference(this->op.get(), this->input_shapes, this->output_shapes);
EXPECT_EQ(this->output_shapes.size(), this->exp_out_size());
EXPECT_EQ(this->output_shapes.front(), StaticShape({20, 5}));
}
TYPED_TEST_P(ProposalTest, all_inputs_dynamic_rank) {
const auto class_probs = std::make_shared<op::v0::Parameter>(element::f32, PartialShape::dynamic());
const auto class_bbox_deltas = std::make_shared<op::v0::Parameter>(element::f32, PartialShape::dynamic());
const auto image_shape = std::make_shared<op::v0::Parameter>(element::f32, PartialShape::dynamic());
this->op = this->make_op(class_probs, class_bbox_deltas, image_shape, this->make_attrs(4));
this->input_shapes = ShapeVector{{2, 3, 10, 10}, {2, 6, 10, 10}, {3}};
shape_inference(this->op.get(), this->input_shapes, this->output_shapes);
EXPECT_EQ(this->output_shapes.size(), this->exp_out_size());
EXPECT_EQ(this->output_shapes[0], StaticShape({8, 5}));
}
TYPED_TEST_P(ProposalTest, all_inputs_static_rank) {
const auto class_probs = std::make_shared<op::v0::Parameter>(element::f32, PartialShape::dynamic(4));
const auto class_bbox_deltas = std::make_shared<op::v0::Parameter>(element::f32, PartialShape::dynamic(4));
const auto image_shape = std::make_shared<op::v0::Parameter>(element::f32, PartialShape::dynamic(1));
this->op = this->make_op(class_probs, class_bbox_deltas, image_shape, this->make_attrs(5));
this->input_shapes = ShapeVector{{3, 4, 10, 10}, {3, 8, 10, 10}, {4}};
shape_inference(this->op.get(), this->input_shapes, this->output_shapes);
EXPECT_EQ(this->output_shapes.size(), this->exp_out_size());
EXPECT_EQ(this->output_shapes[0], StaticShape({15, 5}));
}
TYPED_TEST_P(ProposalTest, batch_size_not_compatible) {
const auto class_probs = std::make_shared<op::v0::Parameter>(element::f32, PartialShape::dynamic(4));
const auto class_bbox_deltas = std::make_shared<op::v0::Parameter>(element::f32, PartialShape::dynamic());
const auto image_shape = std::make_shared<op::v0::Parameter>(element::f32, PartialShape::dynamic(1));
this->op = this->make_op(class_probs, class_bbox_deltas, image_shape, this->make_attrs(5));
this->input_shapes = ShapeVector{{3, 4, 10, 10}, {4, 8, 10, 10}, {3}};
OV_EXPECT_THROW(shape_inference(this->op.get(), this->input_shapes, this->output_shapes),
NodeValidationFailure,
HasSubstr("Batch size inconsistent between class_probs"));
}
TYPED_TEST_P(ProposalTest, image_shape_input_not_compatible_shape) {
const auto class_probs = std::make_shared<op::v0::Parameter>(element::f32, PartialShape::dynamic());
const auto class_bbox_deltas = std::make_shared<op::v0::Parameter>(element::f32, PartialShape::dynamic(4));
const auto image_shape = std::make_shared<op::v0::Parameter>(element::f32, PartialShape::dynamic());
this->op = this->make_op(class_probs, class_bbox_deltas, image_shape, this->make_attrs(5));
this->input_shapes = ShapeVector{{3, 4, 10, 10}, {3, 8, 10, 10}, {5}};
OV_EXPECT_THROW(shape_inference(this->op.get(), this->input_shapes, this->output_shapes),
NodeValidationFailure,
HasSubstr("Image_shape must be 1-D tensor and has got 3 or 4 elements"));
}
REGISTER_TYPED_TEST_SUITE_P(ProposalTest,
default_ctor,
all_inputs_dynamic_rank,
all_inputs_static_rank,
batch_size_not_compatible,
image_shape_input_not_compatible_shape);
using ProposalVersions = Types<op::v0::Proposal, op::v4::Proposal>;
INSTANTIATE_TYPED_TEST_SUITE_P(shape_inference, ProposalTest, ProposalVersions);

View File

@ -1,424 +0,0 @@
// Copyright (C) 2018-2023 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#include <vector>
#include <numeric>
#include <gtest/gtest.h>
#include <legacy/layer_transform.hpp>
#include "gna_matcher.hpp"
using namespace InferenceEngine;
using namespace GNATestIRs;
class FP32NonQuantizedTest : public GNATest<>{
protected:
void SetUp() override {
}
};
class FP32TestParams {
public:
int nChannels = 1;
enum tagEltwise : uint8_t {
eSumm,
eMul
} eltwise_type;
FP32TestParams(int nChannels, uint8_t eltwise) : nChannels(nChannels), eltwise_type((tagEltwise)eltwise) {}
};
/**
* parameter defines one of key dims size - number of channels in input tensor
* due to gna-plugin implementation esential it is required to check 64 bits aligned tensors and non aligned
*/
class GNAFP32ParametricTest : public GNATest<::testing::TestWithParam<FP32TestParams>> {
};
static std::string getTestName(testing::TestParamInfo<FP32TestParams> obj) {
return "channels_" + std::to_string(obj.param.nChannels) + "_" + (obj.param.eltwise_type == FP32TestParams::eSumm ? "summ" : "mull");
}
FP32TestParams gna_fp32_test_params[] = {
{7, FP32TestParams::eMul},
{7, FP32TestParams::eSumm},
{10, FP32TestParams::eMul},
{10, FP32TestParams::eSumm},
{32, FP32TestParams::eMul},
{32, FP32TestParams::eSumm}
};
INSTANTIATE_TEST_SUITE_P(GNAFP32Tests, GNAFP32ParametricTest,
::testing::ValuesIn(gna_fp32_test_params), getTestName);
TEST_F(FP32NonQuantizedTest, SplitFollowedByFCAndEltwiseOnCPU) {
std::vector<float> input_data = {1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0};
std::vector<float> expected_result = {12.0, 12.0, 12.0, 12.0, 12.0,
12.0, 12.0, 12.0, 12.0, 12.0};
assert_that().onInferModel(FCWithPaddingAfterSplitModel())
.inNotCompactMode().gna().propagate_forward().onCPU()
.called_with_input_and_expected_output(input_data, expected_result);
}
TEST_F(FP32NonQuantizedTest, SliceFollowedByFCAndEltwiseOnCPU) {
std::vector<float> input_data = {1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0};
std::vector<float> expected_result = {14.0, 14.0, 14.0, 14.0, 14.0, 14.0, 14.0, 14.0};
assert_that().onInferModel(FCWithPaddingAfterSliceModel())
.inNotCompactMode().gna().propagate_forward().onCPU()
.called_with_input_and_expected_output(input_data, expected_result);
}
TEST_F(FP32NonQuantizedTest, SliceFollowedByAlignedFCAndEltwiseOnCPU) {
std::vector<float> input_data = {1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0};
std::vector<float> expected_result = {18.0, 18.0, 18.0, 18.0};
assert_that().onInferModel(SliceModelWithAlignedOutputs())
.inNotCompactMode().gna().propagate_forward().onCPU()
.called_with_input_and_expected_output(input_data, expected_result);
}
TEST_F(FP32NonQuantizedTest, SliceFollowedBy2FCsAnd2EltwisesOnCPU) {
std::vector<float> input_data = {1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0};
std::vector<float> expected_result = {27.0, 27.0, 27.0, 27.0, 27.0, 27.0, 27.0, 27.0};
assert_that().onInferModel(twoFCWithPaddingAfterSliceModel())
.inNotCompactMode().gna().propagate_forward().onCPU()
.called_with_input_and_expected_output(input_data, expected_result);
}
TEST_F(FP32NonQuantizedTest, multiple_inputs_correct_results) {
std::vector<float> input_data = {1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0};
std::vector<float> input2_data = {2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0};
std::vector<float> result = {30.0, 30.0, 30.0, 30.0, 30.0, 30.0, 30.0, 30.0, 30.0, 30.0};
assert_that().onInferModel(two_inputs_to_affine())
.inNotCompactMode().gna().propagate_forward().onCPU()
.called_with().input("input_1", input_data).And().input("input_2", input2_data).result().equals_to(result);
}
TEST_F(FP32NonQuantizedTest, CropWithoutOffsetPropagateForwardWithSuccessOnCPU) {
std::vector<float> input_data = {1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
std::vector<float> expected_result = {11.0, 11.0, 11.0, 11.0, 11.0,
11.0, 11.0, 11.0, 11.0, 11.0};
assert_that().onInferModel(cropWithoutOffsetModel())
.inNotCompactMode().gna().propagate_forward().onCPU()
.called_with_input_and_expected_output(input_data, expected_result);
}
TEST_F(FP32NonQuantizedTest, CropWithAlignedOffsetPropagateForwardWithSuccessOnCPU) {
std::vector<float> input_data = {1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
std::vector<float> expected_result = {3.0, 3.0, 3.0, 3.0, 3.0,
3.0, 3.0, 3.0, 3.0, 3.0};
assert_that().onInferModel(cropWithAlignedOffsetModel())
.inNotCompactMode().gna().propagate_forward().onCPU()
.called_with_input_and_expected_output(input_data, expected_result);
}
TEST_F(FP32NonQuantizedTest, CropWithOffsetPropagateForwardWithSuccessOnCPU) {
std::vector<float> input_data = {1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0};
std::vector<float> expected_result = {7.0, 7.0, 7.0, 7.0, 7.0,
7.0, 7.0, 7.0, 7.0, 7.0};
assert_that().onInferModel(cropWithOffsetModel())
.inNotCompactMode().gna().propagate_forward().onCPU()
.called_with_input_and_expected_output(input_data, expected_result);
}
TEST_F(FP32NonQuantizedTest, CropWithOffsetAndSecondDimPropagateForwardWithSuccessOnCPU) {
std::vector<float> input_data = {1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0};
std::vector<float> expected_result = {7.0, 7.0, 7.0, 7.0, 7.0,
7.0, 7.0, 7.0, 7.0, 7.0};
assert_that().onInferModel(cropWithOffsetAndSecondDimModel())
.inNotCompactMode().gna().propagate_forward().onCPU()
.called_with_input_and_expected_output(input_data, expected_result);
}
TEST_F(FP32NonQuantizedTest, CropWithMaxOffsetPropagateForwardWithSuccessOnCPU) {
std::vector<float> input_data = {1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
std::vector<float> expected_result = {1.0, 1.0, 1.0, 1.0, 1.0,
1.0, 1.0, 1.0, 1.0, 1.0};
assert_that().onInferModel(cropWithMaxOffsetModel())
.inNotCompactMode().gna().propagate_forward().onCPU()
.called_with_input_and_expected_output(input_data, expected_result);
}
TEST_F(FP32NonQuantizedTest, CropWithOffsetAfterFCPropagateForwardWithSuccessOnCPU) {
std::vector<float> input_data = {1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
std::vector<float> expected_result = {111.0, 111.0, 111.0, 111.0, 111.0,
111.0, 111.0, 111.0, 111.0, 111.0};
assert_that().onInferModel(cropWithOffsetExtendedModel())
.inNotCompactMode().gna().propagate_forward().onCPU()
.called_with_input_and_expected_output(input_data, expected_result);
}
TEST_F(FP32NonQuantizedTest, TwoCropsWithDistanceInBetween) {
std::vector<float> input_data ={1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0,
17.0, 18.0, 19.0, 20.0, 21.0, 22.0, 23.0, 24.0, 25.0, 26.0, 27.0, 28.0, 29.0, 30.0, 31.0, 32.0,
33.0, 34.0, 35.0, 36.0, 37.0, 38.0, 39.0, 40.0, 41.0, 42.0, 43.0, 44.0, 45.0, 46.0, 47.0, 48.0};
std::vector<float> expected_result = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0,
33.0, 34.0, 35.0, 36.0, 37.0, 38.0, 39.0, 40.0, 41.0, 42.0, 43.0, 44.0, 45.0, 46.0, 47.0, 48.0};
assert_that().onInferModel(twoCropsModel())
.inNotCompactMode().gna().propagate_forward().onCPU()
.called_with_input_and_expected_output(input_data, expected_result);
}
TEST_F(FP32NonQuantizedTest, ThreeCropsWithDistanceInBetween) {
std::vector<float> input_data ={1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0,
9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0,
17.0, 18.0, 19.0, 20.0, 21.0, 22.0, 23.0, 24.0,
25.0, 26.0, 27.0, 28.0, 29.0, 30.0, 31.0, 32.0,
33.0, 34.0, 35.0, 36.0, 37.0, 38.0, 39.0, 40.0};
std::vector<float> expected_result = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0,
17.0, 18.0, 19.0, 20.0, 21.0, 22.0, 23.0, 24.0,
33.0, 34.0, 35.0, 36.0, 37.0, 38.0, 39.0, 40.0};
assert_that().onInferModel(threeCropsModel())
.inNotCompactMode().gna().propagate_forward().onCPU()
.called_with_input_and_expected_output(input_data, expected_result);
}
TEST_F(FP32NonQuantizedTest, ThreeCropsWithReshapeWithDistanceInBetween) {
std::vector<float> input_data ={1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0,
9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0,
17.0, 18.0, 19.0, 20.0, 21.0, 22.0, 23.0, 24.0,
25.0, 26.0, 27.0, 28.0, 29.0, 30.0, 31.0, 32.0,
33.0, 34.0, 35.0, 36.0, 37.0, 38.0, 39.0, 40.0};
std::vector<float> expected_result = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0,
17.0, 18.0, 19.0, 20.0, 21.0, 22.0, 23.0, 24.0,
33.0, 34.0, 35.0, 36.0, 37.0, 38.0, 39.0, 40.0};
assert_that().onInferModel(threeCropsWithReshapeModel())
.inNotCompactMode().gna().propagate_forward().onCPU()
.called_with_input_and_expected_output(input_data, expected_result);
}
TEST_F(FP32NonQuantizedTest, CopySimpleCasePropagateForwardWithSuccessOnCPU) {
std::vector<float> input_data = {1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
std::vector<float> expected_result = {12.0, 12.0, 12.0, 12.0, 12.0,
12.0, 12.0, 12.0, 12.0, 12.0,
11.0, 11.0, 11.0, 11.0, 11.0,
11.0, 11.0, 11.0, 11.0, 11.0,};
assert_that().onInferModel(copyModel())
.inNotCompactMode().gna().propagate_forward().onCPU()
.called_with_input_and_expected_output(input_data, expected_result);
}
TEST_F(FP32NonQuantizedTest, ScaleShiftWithBroadcastSupported) {
std::vector<float> input_data (40, 1.0);
std::vector<float> expected_result = {2.0, 4.0, 6.0, 8.0, 10.0, 12.0, 14.0, 16.0,
2.0, 4.0, 6.0, 8.0, 10.0, 12.0, 14.0, 16.0,
2.0, 4.0, 6.0, 8.0, 10.0, 12.0, 14.0, 16.0,
2.0, 4.0, 6.0, 8.0, 10.0, 12.0, 14.0, 16.0,
2.0, 4.0, 6.0, 8.0, 10.0, 12.0, 14.0, 16.0};
assert_that().onInferModel(ScaleShift3DModel()).withWeigthsPattern({1.0f,2.0f,3.0f,4.0f,5.0f,6.0f,7.0f,8.0f})
.inNotCompactMode().gna().propagate_forward().onCPU()
.called_with_input_and_expected_output(input_data, expected_result);
}
TEST_F(FP32NonQuantizedTest, InputSplitConcatPropagateForward) {
std::vector<float> input_data(64, 1.0f);
std::vector<float> expected_result(10, 64.f);
assert_that().onInferModel(InputSplitConcatModel())
.inNotCompactMode().gna().propagate_forward().onCPU()
.called_with_input(input_data).equals_to(expected_result);
}
TEST_F(FP32NonQuantizedTest, InputSplitConcatUnalignedPropagateForward) {
std::vector<float> input_data(20, 1.0f);
std::vector<float> expected_result(10, 20.f);
assert_that().onInferModel(InputSplitConcatModelUnaligned())
.inNotCompactMode().gna().propagate_forward().onCPU()
.called_with_input(input_data).equals_to(expected_result);
}
TEST_F(FP32NonQuantizedTest, InputSplitConcatReshapeUnalignedPropagateForward) {
std::vector<float> input_data(20, 1.0f);
std::vector<float> expected_result(10, 20.f);
assert_that().onInferModel(InputSplitConcatReshapeModelUnaligned())
.inNotCompactMode().gna().propagate_forward().onCPU()
.called_with_input(input_data).equals_to(expected_result);
}
TEST_F(FP32NonQuantizedTest, LSTMCellPropagateForward) {
std::vector<float> input_data(96, 0.10f);
std::vector<float> expected_result(32, 0.14366889f);
assert_that().onInferModel(LSTMCellOnlyModel()).withWeigthsPattern({0.1f})
.inNotCompactMode().gna().propagate_forward().onCPU()
.called_with_input(input_data).equals_to(expected_result);
}
TEST_F(FP32NonQuantizedTest, LSTMCellUnalignedPropagateForward) {
std::vector<float> input_data(30, 0.10f);
std::vector<float> expected_result(10, 0.10488615);
assert_that().onInferModel(LSTMCellOnlyModelUnaligned()).withWeigthsPattern({0.1f})
.inNotCompactMode().gna().propagate_forward().onCPU()
.called_with_input(input_data).equals_to(expected_result);
}
TEST_F(FP32NonQuantizedTest, TI1PropagateForward) {
std::vector<float> input_data(10, 0.10f);
std::vector<float> expected_result1(10, 0.22478661f);
std::vector<float> expected_result2(12, 0.22699516);
assert_that().onInferModel(TIModelWithLSTMCell1()).withWeigthsPattern("ScaleShift_1", {1.0f}).withWeigthsPattern({0.1f})
.inNotCompactMode().gna().propagate_forward().onCPU()
.called_with_input(input_data).equals_to(expected_result1).equals_to(expected_result2);
}
TEST_F(FP32NonQuantizedTest, TI1PropagateForwardWithoutScaleShift) {
std::vector<float> input_data(10, 0.10f);
std::vector<float> expected_result1(10, 0.22478661f);
std::vector<float> expected_result2(12, 0.22699516f);
assert_that().onInferModel(TIModelWithLSTMCell1WithoutScaleShift()).withWeigthsPattern({0.1f})
.inNotCompactMode().gna().propagate_forward().onCPU()
.called_with_input(input_data).equals_to(expected_result1).equals_to(expected_result2);
}
// DISABLED DUE TO (31901)
TEST_F(FP32NonQuantizedTest, DISABLED_TI1AlignedPropagateForward) {
std::vector<float> input_data(32, 0.1f);
std::vector<float> expected_result1(32, 0.25883245);
std::vector<float> expected_result2(12, 0.59515548f);
assert_that().onInferModel(TIModelWithLSTMCell1Aligned()).withWeigthsPattern({0.1f})
.inNotCompactMode().gna().propagate_forward().onCPU()
.called_with_input(input_data).equals_to(expected_result1).And().equals_to(expected_result2);
}
// DISABLED DUE TO (31901)
TEST_F(FP32NonQuantizedTest, DISABLED_TI3AlignedPropagateForward) {
std::vector<float> input_data(96, 0.1f);
std::vector<float> expected_result1(32, 0.42592844f);
std::vector<float> expected_result2(12, 0.97069889f);
assert_that().onInferModel(TIModelWithLSTMCell3Aligned()).withWeigthsPattern({0.1f})
.inNotCompactMode().gna().propagate_forward().onCPU()
.called_with_input(input_data).equals_to(expected_result1).And().equals_to(expected_result2);
}
TEST_F(FP32NonQuantizedTest, TI2PropagateForward) {
std::vector<float> input_data(20, 0.1f);
std::vector<float> expected_result1(10, 0.22478661f);
std::vector<float> expected_result2(12, 0.22699516f);
assert_that().onInferModel(TIModelWithLSTMCell2()).withWeigthsPattern({0.1f})
.inNotCompactMode().gna().propagate_forward().onCPU()
.called_with_input(input_data).equals_to(expected_result1).equals_to(expected_result2);
}
TEST_F(FP32NonQuantizedTest, PowerWithScaleFactorPropagateForward) {
std::vector<float> input_data(10, 2.f);
std::vector<float> expected_result(12, 21.f);
assert_that().onInferModel(PowerWithScaleFactor1())
.inNotCompactMode().withWeigthsPattern({1}).gna().propagate_forward().onCPU()
.called_with_input(input_data).equals_to(expected_result);
}
TEST_F(FP32NonQuantizedTest, SplitToConcatThroughScaleShiftPropagateForward) {
std::vector<float> input_data(30, 1.f);
std::vector<float> expected_result(20, 41.f);
expected_result.insert(expected_result.end(), 20, 2.f);
assert_that().onInferModel(SplitToConcatThroughScaleShift())
.inNotCompactMode().withWeigthsPattern({1}).gna().propagate_forward().onCPU()
.called_with_input(input_data).equals_to(expected_result);
}
TEST_F(FP32NonQuantizedTest, TwoOutputsPropagateForward) {
std::vector<float> input_data(10, 1);
std::vector<float> result1(20, 11.f);
std::vector<float> result2(10, 11.f);
assert_that().onInferModel(TwoOutputs())
.inNotCompactMode().gna().propagate_forward().onCPU()
.called_with().input("input_1", input_data).result().equals_to(result1).And().equals_to(result2);
}
TEST_F(FP32NonQuantizedTest, TwoOutputsDiffPrecisionPropagateForward) {
std::vector<float> input_data(10, 1);
std::vector<float> result1(10, 11.f);
std::vector<float> result2(20, 11.f);
assert_that().onInferModel(TwoOutputsDiffPrecision())
.inNotCompactMode().gna().propagate_forward().onCPU()
.called_with().input("input_1", input_data).result().equals_to(result1).And().equals_to(result2);
}
TEST_F(FP32NonQuantizedTest, DISABLED_SplitToConcatWith2InputsAlignedNoFC) {
std::vector<float> input_data(64);
std::iota(input_data.begin(), input_data.end(), 1.0f);
assert_that().onInferModel(SplitToConcatWith2InputsAlignedNoFC())
.inNotCompactMode().gna().propagate_forward().onCPU()
.called_with_input(input_data).equals_to(input_data);
}
TEST_F(FP32NonQuantizedTest, DISABLED_SplitToConcatWith2By64InputsAlignedNoFC) {
std::vector<float> input_data(128);
std::iota(input_data.begin(), input_data.end(), 1.0f);
assert_that().onInferModel(SplitToConcatWith2By64InputsAlignedNoFC())
.inNotCompactMode().gna().propagate_forward().onCPU()
.called_with_input(input_data).equals_to(input_data);
}
TEST_F(FP32NonQuantizedTest, DISABLED_SplitToConcatWith3InputsAlignedNoFC) {
std::vector<float> input_data(96);
std::iota(input_data.begin(), input_data.end(), 1.0f);
assert_that().onInferModel(SplitToConcatWith3InputsAlignedNoFC())
.inNotCompactMode().gna().propagate_forward().onCPU()
.called_with_input(input_data).equals_to(input_data);
}
TEST_F(FP32NonQuantizedTest, DISABLED_SplitToConcatWith10InputsAlignedNoFC) {
std::vector<float> input_data(320);
std::iota(input_data.begin(), input_data.end(), 1.0f);
assert_that().onInferModel(SplitToConcatWith10InputsAlignedNoFC())
.inNotCompactMode().gna().propagate_forward().onCPU()
.called_with_input(input_data).equals_to(input_data);
}
TEST_F(FP32NonQuantizedTest, ReshapeConvolutionLessThan48Filters) {
std::vector<float> input_data(800, 1.f);
std::vector<float> expected_result(1600, 8.f);
assert_that().onInferModel(ReshapeConvolutionLessThan48Filters())
.inNotCompactMode()
.withWeigthsPattern({1})
.gna()
.propagate_forward()
.onCPU()
.called_with_input(input_data)
.equals_to(expected_result);
}

View File

@ -98,5 +98,7 @@ std::vector<std::string> disabledTestPatterns() {
R"(.*smoke_Multi_BehaviorTests.*)",
// unsupported metrics
R"(.*smoke_MultiHeteroOVGetMetricPropsTest.*OVGetMetricPropsTest.*(AVAILABLE_DEVICES|OPTIMIZATION_CAPABILITIES|RANGE_FOR_ASYNC_INFER_REQUESTS|RANGE_FOR_STREAMS).*)",
// TODO: Issue: 111556
R"(.*SplitConvTest.CompareWithRefImpl.*IS=\(1.(128|256)\).*IC=4.*OC=4.*configItem=GNA_DEVICE_MODE_GNA_SW_FP32)",
};
}

View File

@ -17,7 +17,8 @@ std::vector<size_t> concat_const_sizes = {7, 16, 35, 64};
const std::vector<InferenceEngine::Precision> netPrecisions = {InferenceEngine::Precision::FP32,
InferenceEngine::Precision::FP16};
std::map<std::string, std::string> additional_config = {};
const std::vector<std::map<std::string, std::string>> configs = {{{"GNA_DEVICE_MODE", "GNA_SW_FP32"}},
{{"GNA_DEVICE_MODE", "GNA_SW_EXACT"}}};
INSTANTIATE_TEST_SUITE_P(smoke_CompareRefs,
ActivationConcatsEltwise,
@ -25,7 +26,7 @@ INSTANTIATE_TEST_SUITE_P(smoke_CompareRefs,
::testing::ValuesIn(concat_const_sizes),
::testing::ValuesIn(netPrecisions),
::testing::Values(CommonTestUtils::DEVICE_GNA),
::testing::Values(additional_config)),
::testing::ValuesIn(configs)),
ActivationConcatsEltwise::getTestCaseName);
} // namespace

View File

@ -15,11 +15,9 @@ const std::vector<InferenceEngine::Precision> netPrecisions = {
InferenceEngine::Precision::FP16,
};
const std::vector<std::map<std::string, std::string>> configs = {{
{"GNA_DEVICE_MODE", "GNA_SW_EXACT"},
{"GNA_COMPACT_MODE", "NO"},
{"GNA_SCALE_FACTOR_0", "2048"},
}};
const std::vector<std::map<std::string, std::string>> configs = {
{{"GNA_DEVICE_MODE", "GNA_SW_EXACT"}, {"GNA_COMPACT_MODE", "NO"}, {"GNA_SCALE_FACTOR_0", "2048"}},
{{"GNA_DEVICE_MODE", "GNA_SW_FP32"}}};
const std::vector<std::vector<std::vector<size_t>>> input_shapes{
{{1, 8224}, {1, 257, 32}},

View File

@ -14,7 +14,8 @@ namespace {
const std::vector<InferenceEngine::Precision> netPrecisions = {InferenceEngine::Precision::FP32,
InferenceEngine::Precision::FP16};
const std::vector<std::map<std::string, std::string>> configs = {{{"GNA_DEVICE_MODE", "GNA_SW_EXACT"}}};
const std::vector<std::map<std::string, std::string>> configs = {{{"GNA_DEVICE_MODE", "GNA_SW_EXACT"}},
{{"GNA_DEVICE_MODE", "GNA_SW_FP32"}}};
std::vector<convParams> params = {std::make_tuple(std::vector<size_t>{1, 32}, // InputShape
std::vector<size_t>{1, 3}, // KernelShape

View File

@ -26,19 +26,20 @@ const std::vector<InferenceEngine::Precision> netPrecisions = {
InferenceEngine::Precision::FP16,
};
std::map<std::string, std::string> additional_config = {
{"GNA_DEVICE_MODE", "GNA_SW_EXACT"},
{"GNA_COMPACT_MODE", "NO"},
{"GNA_SCALE_FACTOR_0", "2048"},
{"GNA_PRECISION", "I16"},
};
std::vector<std::map<std::string, std::string>> configs = {{
{"GNA_DEVICE_MODE", "GNA_SW_EXACT"},
{"GNA_COMPACT_MODE", "NO"},
{"GNA_SCALE_FACTOR_0", "2048"},
{"GNA_PRECISION", "I16"},
},
{{"GNA_DEVICE_MODE", "GNA_SW_FP32"}}};
INSTANTIATE_TEST_SUITE_P(smoke_concat_multi_input,
ConcatMultiInput,
::testing::Combine(::testing::ValuesIn(inShapes),
::testing::ValuesIn(netPrecisions),
::testing::Values(CommonTestUtils::DEVICE_GNA),
::testing::Values(additional_config)),
::testing::ValuesIn(configs)),
ConcatMultiInput::getTestCaseName);
} // namespace

View File

@ -12,12 +12,13 @@ std::vector<size_t> input_sizes = {80, 32, 64, 100};
std::vector<midOutputType> midLayerTypes{midOutputType::Mul, midOutputType::Sub, midOutputType::Sum};
std::map<std::string, std::string> additional_config = {
{"GNA_COMPACT_MODE", "NO"},
{"GNA_DEVICE_MODE", "GNA_SW_EXACT"},
{"GNA_SCALE_FACTOR_0", "1638.4"},
{"GNA_SCALE_FACTOR_1", "1638.4"},
};
std::vector<std::map<std::string, std::string>> configs = {{
{"GNA_COMPACT_MODE", "NO"},
{"GNA_DEVICE_MODE", "GNA_SW_EXACT"},
{"GNA_SCALE_FACTOR_0", "1638.4"},
{"GNA_SCALE_FACTOR_1", "1638.4"},
},
{{"GNA_DEVICE_MODE", "GNA_SW_FP32"}}};
} // namespace
INSTANTIATE_TEST_SUITE_P(OutputBeforeActivation,
@ -26,6 +27,6 @@ INSTANTIATE_TEST_SUITE_P(OutputBeforeActivation,
::testing::Values(InferenceEngine::Precision::FP32),
::testing::ValuesIn(input_sizes),
::testing::ValuesIn(midLayerTypes),
::testing::Values(additional_config)),
::testing::ValuesIn(configs)),
OutputBeforeActivation::getTestCaseName);
} // namespace SubgraphTestsDefinitions

View File

@ -15,7 +15,8 @@ const std::vector<InferenceEngine::Precision> netPrecisions = {InferenceEngine::
InferenceEngine::Precision::FP16};
const std::vector<std::map<std::string, std::string>> configs = {
{{"GNA_DEVICE_MODE", "GNA_SW_EXACT"}, {"GNA_SCALE_FACTOR_0", "81.9175"}}};
{{"GNA_DEVICE_MODE", "GNA_SW_EXACT"}, {"GNA_SCALE_FACTOR_0", "81.9175"}},
{{"GNA_DEVICE_MODE", "GNA_SW_FP32"}}};
std::vector<std::vector<size_t>> input_shapes = {{1, 8}, {1, 42}, {1, 100}, {1, 128}, {1, 512}};

View File

@ -19,7 +19,8 @@ std::vector<InferenceEngine::Precision> netPrecisions = {
InferenceEngine::Precision::FP16,
};
std::map<std::string, std::string> additional_config = {{{"GNA_DEVICE_MODE", "GNA_SW_EXACT"}}};
std::vector<std::map<std::string, std::string>> configs = {{{"GNA_DEVICE_MODE", "GNA_SW_EXACT"}},
{{"GNA_DEVICE_MODE", "GNA_SW_FP32"}}};
std::vector<std::tuple<std::vector<int64_t>,
std::vector<int64_t>,
@ -52,7 +53,7 @@ INSTANTIATE_TEST_SUITE_P(smoke_memory_fq_concat_prelu,
::testing::Combine(::testing::ValuesIn(inputs),
::testing::ValuesIn(netPrecisions),
::testing::Values(CommonTestUtils::DEVICE_GNA),
::testing::Values(additional_config),
::testing::ValuesIn(configs),
::testing::ValuesIn(strided_slice_params),
::testing::ValuesIn(fake_quantize_params)),
MemoryFqConcatPrelu::getTestCaseName);

View File

@ -12,7 +12,8 @@ std::vector<size_t> input = {32, 15, 17, 10};
std::vector<std::map<std::string, std::string>> additional_config = {
{{"GNA_DEVICE_MODE", "GNA_SW_EXACT"}, {"GNA_SCALE_FACTOR_0", "2"}, {"GNA_SCALE_FACTOR_1", "2"}},
{{"GNA_DEVICE_MODE", "GNA_SW_EXACT"}, {"GNA_SCALE_FACTOR_0", "2"}, {"GNA_SCALE_FACTOR_1", "1638.4"}}};
{{"GNA_DEVICE_MODE", "GNA_SW_EXACT"}, {"GNA_SCALE_FACTOR_0", "2"}, {"GNA_SCALE_FACTOR_1", "1638.4"}},
{{"GNA_DEVICE_MODE", "GNA_SW_FP32"}}};
} // namespace
INSTANTIATE_TEST_SUITE_P(smoke_multiple_input_scale,

View File

@ -23,9 +23,8 @@ std::vector<std::vector<std::vector<size_t>>> inputs{{{1, 16}},
{{8, 512}},
{{8, 1024}}};
std::map<std::string, std::string> additional_config = {
{"GNA_COMPACT_MODE", "NO"},
};
std::vector<std::map<std::string, std::string>> configs = {{{"GNA_COMPACT_MODE", "NO"}},
{{"GNA_DEVICE_MODE", "GNA_SW_FP32"}}};
std::vector<InferenceEngine::Precision> netPrecisions = {
InferenceEngine::Precision::FP32,
@ -37,6 +36,6 @@ INSTANTIATE_TEST_SUITE_P(smoke_multioutput_eltwise_identity,
::testing::Combine(::testing::ValuesIn(inputs),
::testing::ValuesIn(netPrecisions),
::testing::Values(CommonTestUtils::DEVICE_GNA),
::testing::Values(additional_config)),
::testing::ValuesIn(configs)),
MultioutputEltwiseReshapeEltwise::getTestCaseName);
} // namespace

View File

@ -12,9 +12,8 @@ std::vector<size_t> input = {
64,
};
std::map<std::string, std::string> additional_config = {
{"GNA_DEVICE_MODE", "GNA_SW_EXACT"},
};
std::vector<std::map<std::string, std::string>> configs = {{{"GNA_DEVICE_MODE", "GNA_SW_EXACT"}},
{{"GNA_DEVICE_MODE", "GNA_SW_FP32"}}};
} // namespace
INSTANTIATE_TEST_SUITE_P(smoke_multiple_input,
@ -22,6 +21,6 @@ INSTANTIATE_TEST_SUITE_P(smoke_multiple_input,
::testing::Combine(::testing::Values(CommonTestUtils::DEVICE_GNA),
::testing::Values(InferenceEngine::Precision::FP32),
::testing::ValuesIn(input),
::testing::Values(additional_config)),
::testing::ValuesIn(configs)),
MultipleInputTest::getTestCaseName);
} // namespace SubgraphTestsDefinitions

View File

@ -28,9 +28,8 @@ std::vector<InferenceEngine::Precision> netPrecisions = {
InferenceEngine::Precision::FP16,
};
std::map<std::string, std::string> additional_config = {
{"GNA_DEVICE_MODE", "GNA_SW_EXACT"},
};
std::vector<std::map<std::string, std::string>> configs = {{{"GNA_DEVICE_MODE", "GNA_SW_EXACT"}},
{{"GNA_DEVICE_MODE", "GNA_SW_FP32"}}};
} // namespace
namespace SubgraphTestsDefinitions {
@ -41,6 +40,6 @@ INSTANTIATE_TEST_SUITE_P(smoke_basic,
::testing::ValuesIn(input_shapes),
::testing::ValuesIn(kernel_shapes),
::testing::ValuesIn(output_channels),
::testing::Values(additional_config)),
::testing::ValuesIn(configs)),
PermConvPermConcat::getTestCaseName);
} // namespace SubgraphTestsDefinitions

View File

@ -31,8 +31,9 @@ std::vector<InferenceEngine::Precision> netPrecisions = {
InferenceEngine::Precision::FP16,
};
std::map<std::string, std::string> additional_config = {{"GNA_DEVICE_MODE", "GNA_SW_EXACT"},
{"GNA_SCALE_FACTOR_0", "2340"}};
std::vector<std::map<std::string, std::string>> configs = {
{{"GNA_DEVICE_MODE", "GNA_SW_EXACT"}, {"GNA_SCALE_FACTOR_0", "2340"}},
{{"GNA_DEVICE_MODE", "GNA_SW_FP32"}}};
namespace SubgraphTestsDefinitions {
INSTANTIATE_TEST_SUITE_P(smoke_basic,
@ -42,6 +43,6 @@ INSTANTIATE_TEST_SUITE_P(smoke_basic,
::testing::ValuesIn(input_shapes),
::testing::ValuesIn(kernel_shapes),
::testing::ValuesIn(output_channels),
::testing::Values(additional_config)),
::testing::ValuesIn(configs)),
ConvReshapeAct::getTestCaseName);
} // namespace SubgraphTestsDefinitions

View File

@ -15,7 +15,8 @@ const std::vector<InferenceEngine::Precision> netPrecisions = {InferenceEngine::
InferenceEngine::Precision::FP16};
const std::vector<std::map<std::string, std::string>> configs = {
{{"GNA_DEVICE_MODE", "GNA_SW_EXACT"}, {"GNA_SCALE_FACTOR_0", "3276.7"}, {"GNA_COMPACT_MODE", "NO"}}};
{{"GNA_DEVICE_MODE", "GNA_SW_EXACT"}, {"GNA_SCALE_FACTOR_0", "3276.7"}, {"GNA_COMPACT_MODE", "NO"}},
{{"GNA_DEVICE_MODE", "GNA_SW_FP32"}}};
std::vector<std::vector<size_t>> input_shapes =
{{1, 8}, {1, 42}, {1, 100}, {1, 128}, {1, 1, 64}, {1, 1, 1, 64}, {1, 1, 1, 100}};

View File

@ -14,7 +14,8 @@ namespace {
const std::vector<InferenceEngine::Precision> netPrecisions = {InferenceEngine::Precision::FP32,
InferenceEngine::Precision::FP16};
const std::vector<std::map<std::string, std::string>> configs = {{{"GNA_DEVICE_MODE", "GNA_SW_EXACT"}}};
const std::vector<std::map<std::string, std::string>> configs = {{{"GNA_DEVICE_MODE", "GNA_SW_EXACT"}},
{{"GNA_DEVICE_MODE", "GNA_SW_FP32"}}};
std::vector<convParams> params = {std::make_tuple(std::vector<size_t>{1, 128}, // InputShape
std::vector<size_t>{1, 3}, // KernelShape

View File

@ -39,7 +39,8 @@ const std::vector<InferenceEngine::Precision> netPrecisions = {
};
const std::vector<std::map<std::string, std::string>> configs = {
{{"GNA_DEVICE_MODE", "GNA_SW_EXACT"}, {"GNA_COMPACT_MODE", "NO"}}};
{{"GNA_DEVICE_MODE", "GNA_SW_EXACT"}, {"GNA_COMPACT_MODE", "NO"}},
{{"GNA_DEVICE_MODE", "GNA_SW_FP32"}}};
INSTANTIATE_TEST_SUITE_P(smoke_stridedslice_gna,
StridedSliceTest,

View File

@ -14,9 +14,8 @@ namespace {
const std::vector<InferenceEngine::Precision> netPrecisions = {InferenceEngine::Precision::FP32,
InferenceEngine::Precision::FP16};
const std::vector<std::map<std::string, std::string>> configs = {{
{"GNA_DEVICE_MODE", "GNA_SW_EXACT"},
}};
const std::vector<std::map<std::string, std::string>> configs = {{{"GNA_DEVICE_MODE", "GNA_SW_EXACT"}},
{{"GNA_DEVICE_MODE", "GNA_SW_FP32"}}};
const std::vector<StridedSliceParams> sliceParams = {
{{8, 16}, {1, 16}, {2, 16}, {1, 1}, {0, 1}, {0, 1}},

View File

@ -14,7 +14,8 @@ namespace {
const std::vector<InferenceEngine::Precision> netPrecisions = {InferenceEngine::Precision::FP32,
InferenceEngine::Precision::FP16};
const std::vector<std::map<std::string, std::string>> configs = {{{"GNA_DEVICE_MODE", "GNA_SW_EXACT"}}};
const std::vector<std::map<std::string, std::string>> configs = {{{"GNA_DEVICE_MODE", "GNA_SW_EXACT"}},
{{"GNA_DEVICE_MODE", "GNA_SW_FP32"}}};
std::vector<convParams> params = {std::make_tuple(std::vector<size_t>{1, 1, 1, 256}, // InputShape
std::vector<size_t>{1, 3}, // KernelShape

View File

@ -120,8 +120,12 @@ void ReadIRTest::query_model() {
try {
SubgraphBaseTest::query_model();
s.updateOPsStats(functionRefs, ov::test::utils::PassRate::Statuses::PASSED, rel_influence_coef);
} catch (std::exception& err) {
s.updateOPsStats(functionRefs, ov::test::utils::PassRate::Statuses::FAILED, rel_influence_coef);
GTEST_FAIL() << err.what();
} catch (...) {
s.updateOPsStats(functionRefs, ov::test::utils::PassRate::Statuses::FAILED, rel_influence_coef);
GTEST_FAIL() << "Something is wrong in Query model! Please check";
}
} else if (jmpRes == CommonTestUtils::JMP_STATUS::alarmErr) {
s.updateOPsStats(functionRefs, ov::test::utils::PassRate::Statuses::HANGED, rel_influence_coef);

View File

@ -23,6 +23,9 @@ std::string ActivationConcatsEltwise::getTestCaseName(const testing::TestParamIn
result << "CS=" << concatSize << "_";
result << "PRC=" << netPrecision.name() << "_";
result << "dev=" << targetDevice;
for (auto const& configItem : configuration) {
result << "_configItem=" << configItem.first << "_" << configItem.second;
}
return result.str();
}

View File

@ -17,6 +17,9 @@ std::string ConcatMultiInput::getTestCaseName(const testing::TestParamInfo<conca
result << "IS=" << CommonTestUtils::vec2str(inputShapes) << "_";
result << "netPRC=" << netPrecision.name() << "_";
result << "targetDevice=" << targetDevice;
for (auto const& configItem : additional_config) {
result << "_configItem=" << configItem.first << "_" << configItem.second;
}
return result.str();
}

View File

@ -32,6 +32,9 @@ std::string OutputBeforeActivation::getTestCaseName(const testing::TestParamInfo
result << "IS=" << inputSize << "_";
result << "OutputType=" << outputType << "_";
result << "targetDevice=" << targetDevice;
for (auto const& configItem : config) {
result << "_configItem=" << configItem.first << "_" << configItem.second;
}
return result.str();
}

View File

@ -16,6 +16,9 @@ namespace SubgraphTestsDefinitions {
results << "IS=" << CommonTestUtils::vec2str(input[0]) << "_";
results << "netPRC=" << netPrecision.name() << "_";
results << "targetDevice=" << targetName << "_";
for (auto const& configItem : additional_config) {
results << "_configItem=" << configItem.first << "_" << configItem.second;
}
return results.str();
}

View File

@ -17,6 +17,9 @@ std::string MultipleInputTest::getTestCaseName(const testing::TestParamInfo<mult
result << "netPrecision=" << netPrecision.name() << "_";
result << "IS=" << inputSize << "_";
result << "targetDevice=" << targetDevice;
for (auto const& configItem : config) {
result << "_configItem=" << configItem.first << "_" << configItem.second;
}
return result.str();
}

View File

@ -22,6 +22,9 @@ std::string PermConvPermConcat::getTestCaseName(const testing::TestParamInfo<Per
results << "OC=" << output_channels << "_";
results << "netPRC=" << netPrecision.name() << "_";
results << "targetDevice=" << targetName;
for (auto const& configItem : configuration) {
results << "_configItem=" << configItem.first << "_" << configItem.second;
}
return results.str();
}

View File

@ -22,6 +22,9 @@ namespace SubgraphTestsDefinitions {
results << "OC=" << output_channels << "_";
results << "netPRC=" << netPrecision.name() << "_";
results << "targetDevice=" << targetName;
for (auto const& configItem : configuration) {
results << "_configItem=" << configItem.first << "_" << configItem.second;
}
return results.str();
}

View File

@ -32,6 +32,9 @@ std::string StridedSliceTest::getTestCaseName(const testing::TestParamInfo<Strid
result << "shrink_m=" << (params.shrinkAxisMask.empty() ? "def" : CommonTestUtils::vec2str(params.shrinkAxisMask)) << "_";
result << "ellipsis_m=" << (params.ellipsisAxisMask.empty() ? "def" : CommonTestUtils::vec2str(params.ellipsisAxisMask)) << "_";
result << "trgDev=" << targetName;
for (auto const& configItem : additionalConfig) {
result << "_configItem=" << configItem.first << "_" << configItem.second;
}
return result.str();
}

View File

@ -8,7 +8,8 @@ from argparse import ArgumentParser
from subprocess import Popen, STDOUT, TimeoutExpired, run, call
from hashlib import sha256
from pathlib import Path
from shutil import rmtree
from shutil import rmtree, copyfile
from tarfile import open as tar_open
if not constants.IS_WIN:
from signal import SIGKILL
@ -205,6 +206,7 @@ class TestParallelRunner:
def __init__(self, exec_file_path: os.path, test_command_line: list, worker_num: int, working_dir: os.path, cache_path: os.path, is_parallel_devices=False):
self._exec_file_path = exec_file_path
self._working_dir = working_dir
self._conformance_ir_filelists = list()
self._command = self.__init_basic_command_line_for_exec_file(test_command_line)
self._worker_num = worker_num
if not os.path.exists(self._working_dir):
@ -239,6 +241,7 @@ class TestParallelRunner:
if os.path.isfile(input_path) and file_utils.is_archieve(input_path):
input_path = file_utils.unzip_archieve(input_path, self._working_dir)
buf = file_utils.prepare_filelist(input_path, ["*.xml"])
self._conformance_ir_filelists.append(buf)
buf += ","
argument = buf
else:
@ -610,6 +613,8 @@ class TestParallelRunner:
logger.error(f"Number of tests in {log}: {test_cnt_real}. Expected is {test_cnt_expected} tests")
else:
os.remove(log_filename)
if len(list(Path(os.path.join(self._working_dir, "temp")).rglob("log_*.log"))) == 0:
rmtree(os.path.join(self._working_dir, "temp"))
for test_name in interapted_tests:
# update test_cache with tests. If tests is crashed use -1 as unknown time
time = -1
@ -642,9 +647,42 @@ class TestParallelRunner:
fix_priority.sort(reverse=True)
csv_writer = csv.writer(csv_file, dialect='excel')
csv_writer.writerow(["Test Name", "Fix Priority"])
ir_hashes = list()
for priority, name in fix_priority:
csv_writer.writerow([name, priority])
if "IR=" in name:
ir_hashes.append(name[name.find('IR=')+3:name.find('_Device=')])
logger.info(f"Fix priorities list is saved to: {fix_priority_path}")
# Find all irs for failed tests
failed_ir_dir = os.path.join(self._working_dir, f'{self._device}_failed_ir')
for conformance_ir_filelist in self._conformance_ir_filelists:
with open(conformance_ir_filelist, 'r') as file:
for conformance_ir in file.readlines():
correct_ir = conformance_ir.replace('\n', '')
_, tail = os.path.split(correct_ir)
ir_hash, _ = os.path.splitext(tail)
if ir_hash in ir_hashes:
head, _ = os.path.split(conformance_ir_filelist)
prefix, _ = os.path.splitext(correct_ir)
xml_file = correct_ir
bin_file = prefix + constants.BIN_EXTENSION
meta_file = prefix + constants.META_EXTENSION
failed_ir_xml = xml_file.replace(head, failed_ir_dir)
failed_ir_bin = bin_file.replace(head, failed_ir_dir)
failed_ir_meta = meta_file.replace(head, failed_ir_dir)
dir, _ = os.path.split(failed_ir_xml)
if not os.path.isdir(dir):
os.makedirs(dir)
copyfile(xml_file, failed_ir_xml)
copyfile(bin_file, failed_ir_bin)
copyfile(meta_file, failed_ir_meta)
output_file_name = failed_ir_dir + '.tar'
with tar_open(output_file_name, "w:gz") as tar:
tar.add(failed_ir_dir, arcname=os.path.basename(failed_ir_dir))
logger.info(f"All Conformance IRs for failed tests are saved to: {output_file_name}")
rmtree(failed_ir_dir)
disabled_tests_path = os.path.join(logs_dir, "disabled_tests.log")
with open(disabled_tests_path, "w") as disabled_tests_file:

View File

@ -46,3 +46,7 @@ NOT_EXIST_DEVICE = "NOT_EXIST_DEVICE"
MEM_USAGE = "MEM_USAGE="
CONVERT_OP_NAME = "Convert-1"
META_EXTENSION = ".meta"
XML_EXTENSION = ".xml"
BIN_EXTENSION = ".bin"

View File

@ -0,0 +1,32 @@
# Copyright (C) 2018-2023 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import pytest
import numpy as np
import torch
from pytorch_layer_test_class import PytorchLayerTest
@pytest.mark.parametrize("dtype", [np.int32, np.float32])
@pytest.mark.parametrize("shape", [[], [1], [1, 1, 1]])
class TestItem(PytorchLayerTest):
def _prepare_input(self):
return [np.random.randn(1).astype(self.dtype).reshape(self.shape)]
def create_model(self):
class aten_item(torch.nn.Module):
def forward(self, x: torch.Tensor):
return x.item()
ref_net = None
return aten_item(), ref_net, "aten::item"
@pytest.mark.nightly
@pytest.mark.precommit
def test_item(self, ie_device, precision, ir_version, dtype, shape):
self.dtype = dtype
self.shape = shape
# Dynamic shapes are not supported by Squeeze implementation
self._test(*self.create_model(), ie_device, precision, ir_version, dynamic_shapes=False)

View File

@ -40,3 +40,39 @@ class TestSum(PytorchLayerTest):
def test_sum(self, axes, keep_dim, ie_device, precision, ir_version):
self._test(*self.create_model(axes, keep_dim),
ie_device, precision, ir_version)
class TestSumBool(PytorchLayerTest):
def _prepare_input(self):
import numpy as np
return (np.random.randint(0, 2, (1, 3, 20, 24)).astype(bool),)
def create_model(self, axes, keep_dims):
import torch
class aten_sum(torch.nn.Module):
def __init__(self, axes=None, keep_dims=None):
super(aten_sum, self).__init__()
self.axes = axes
self.keep_dims = keep_dims
def forward(self, x):
x = x.to(torch.bool)
if self.axes is None and self.keep_dims is None:
return torch.sum(x)
if self.axes is not None and self.keep_dims is None:
return torch.sum(x, self.axes)
return torch.sum(x, self.axes, self.keep_dims)
ref_net = None
return aten_sum(axes, keep_dims), ref_net, "aten::sum"
@pytest.mark.parametrize("axes,keep_dim",
[(None, None), (None, False), (-1, None), (1, None), ((2, 3), False), ((3, 2), True)])
@pytest.mark.nightly
@pytest.mark.precommit
def test_sum(self, axes, keep_dim, ie_device, precision, ir_version):
self._test(*self.create_model(axes, keep_dim),
ie_device, precision, ir_version)

View File

@ -0,0 +1,35 @@
# Copyright (C) 2018-2023 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import numpy as np
import pytest
from pytorch_layer_test_class import PytorchLayerTest
class TestUnflatten(PytorchLayerTest):
def _prepare_input(self, dtype):
return (np.random.uniform(0, 50, (6, 3, 4)).astype(dtype),)
def create_model(self, dim, shape):
import torch
class aten_unflatten(torch.nn.Module):
def __init__(self, dim, shape):
super(aten_unflatten, self).__init__()
self.dim = dim
self.shape = shape
def forward(self, x):
return x.unflatten(self.dim, self.shape)
ref_net = None
return aten_unflatten(dim, shape), ref_net, "aten::unflatten"
@pytest.mark.parametrize(("dim", "shape"), [(0, [2, 1, 3]), (1, [1, 3]), (2, (2, -1)), (-1, (2, 2)), (-2, (-1, 1))])
@pytest.mark.parametrize("dtype", ["float32", "int32"])
@pytest.mark.nightly
@pytest.mark.precommit
def test_unflatten(self, dim, shape, dtype, ie_device, precision, ir_version):
self._test(*self.create_model(dim, shape), ie_device, precision, ir_version, kwargs_to_prepare_input={"dtype": dtype})

View File

@ -2,11 +2,20 @@
# SPDX-License-Identifier: Apache-2.0
#
set(_old_CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
set(_old_CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE ${CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE})
# Android toolchain does not provide pkg-config file. So, cmake mistakenly uses
# build system pkg-config executable, which finds packages on build system. Such
# libraries cannot be linked into Android binaries.
if(NOT ANDROID)
find_package(PkgConfig QUIET)
# see https://cmake.org/cmake/help/latest/command/add_library.html#alias-libraries
# cmake older than 3.18 cannot create an alias for imported non-GLOBAL targets
# so, we have to use 'IMPORTED_GLOBAL' property
if(CMAKE_VERSION VERSION_LESS 3.18)
set(OV_PkgConfig_VISILITY GLOBAL)
endif()
endif()
if(SUGGEST_OVERRIDE_SUPPORTED)
@ -21,31 +30,20 @@ if(ENABLE_PROFILING_ITT)
find_package(ittapi QUIET)
if(ittapi_FOUND)
# conan defines 'ittapi::ittapi' target
# create more common alias 'ittapi::ittnotify'
set_target_properties(ittapi::ittapi PROPERTIES
IMPORTED_GLOBAL ON
INTERFACE_COMPILE_DEFINITIONS ENABLE_PROFILING_ITT)
add_library(ittapi::ittnotify ALIAS ittapi::ittapi)
# set ittapi_FOUND to parent scope to properly generate OpenVINOConfig.cmake for static build
set(ittapi_FOUND ${ittapi_FOUND} PARENT_SCOPE)
else()
add_subdirectory(ittapi)
add_subdirectory(thirdparty/ittapi)
endif()
add_subdirectory(itt_collector EXCLUDE_FROM_ALL)
endif()
if(ENABLE_SAMPLES OR ENABLE_TESTS)
add_subdirectory(cnpy EXCLUDE_FROM_ALL)
add_subdirectory(thirdparty/itt_collector EXCLUDE_FROM_ALL)
endif()
if(X86_64 OR UNIVERSAL2)
find_package(xbyak QUIET)
if(xbyak_FOUND)
# conan creates alias xbyak::xbyak, we only need to make it GLOBAL
set_target_properties(xbyak::xbyak PROPERTIES IMPORTED_GLOBAL ON)
# conan creates alias xbyak::xbyak, no extra steps are required
else()
add_subdirectory(xbyak EXCLUDE_FROM_ALL)
add_subdirectory(thirdparty/xbyak EXCLUDE_FROM_ALL)
# export and install xbyak
openvino_developer_export_targets(COMPONENT openvino_common TARGETS xbyak::xbyak)
ov_install_static_lib(xbyak ${OV_CPACK_COMP_CORE})
@ -71,7 +69,6 @@ if(ENABLE_INTEL_GPU)
if(NOT OpenCLHeaders_FOUND)
message(WARNING "OpenCLHeaders not found, but OpenCLICDLoader is installed. Please, install OpenCL headers")
else()
set_target_properties(OpenCL::Headers PROPERTIES IMPORTED_GLOBAL ON)
set_property(TARGET OpenCL::OpenCL APPEND PROPERTY INTERFACE_LINK_LIBRARIES OpenCL::Headers)
endif()
@ -82,25 +79,20 @@ if(ENABLE_INTEL_GPU)
if(NOT OpenCLHeadersCpp_FOUND)
message(WARNING "OpenCLHeadersCpp not found, but OpenCLICDLoader is installed. Please, install OpenCL C++ headers")
else()
set_target_properties(OpenCL::HeadersCpp PROPERTIES IMPORTED_GLOBAL ON)
get_target_property(opencl_cpp_include_dirs OpenCL::HeadersCpp INTERFACE_INCLUDE_DIRECTORIES)
set_property(TARGET OpenCL::OpenCL APPEND PROPERTY INTERFACE_LINK_LIBRARIES OpenCL::HeadersCpp)
endif()
# set OpenCLICDLoader_FOUND to parent scope to generate proper OpenVINOConfig.cmake for static libraries case
set(OpenCLICDLoader_FOUND ON PARENT_SCOPE)
else()
# try to find system OpenCL:
# - 'apt-get install opencl-headers ocl-icd-opencl-dev'
# - 'yum install ocl-icd-devel opencl-headers'
# - 'conda install khronos-opencl-icd-loader -c conda-forge'
# - 'vcpkg install opencl:<triplet>'
find_package(OpenCL QUIET)
endif()
endif()
if(TARGET OpenCL::OpenCL)
set_target_properties(OpenCL::OpenCL PROPERTIES IMPORTED_GLOBAL ON)
# try to find CL/opencl.hpp
find_file(OpenCL_HPP
NAMES CL/opencl.hpp OpenCL/opencl.hpp
@ -123,8 +115,8 @@ if(ENABLE_INTEL_GPU)
# set variables for onednn_gpu
if(OpenCLHeaders_FOUND)
set(OpenCL_INCLUDE_DIR "$<TARGET_PROPERTY:OpenCL::Headers,INTERFACE_INCLUDE_DIRECTORIES>" PARENT_SCOPE)
set(OpenCL_LIBRARY "$<TARGET_PROPERTY:OpenCL::OpenCL,IMPORTED_LOCATION_RELEASE>" PARENT_SCOPE)
set(OpenCL_INCLUDE_DIR "$<TARGET_PROPERTY:OpenCL::Headers,INTERFACE_INCLUDE_DIRECTORIES>")
set(OpenCL_LIBRARY "$<TARGET_PROPERTY:OpenCL::OpenCL,IMPORTED_LOCATION_RELEASE>")
elseif(OpenCL_FOUND)
# find_package(OpenCL) already defines OpenCL_INCLUDE_DIR and OpenCL_LIBRARY
# see https://cmake.org/cmake/help/latest/module/FindOpenCL.html
@ -133,14 +125,7 @@ if(ENABLE_INTEL_GPU)
message(FATAL_ERROR "Internal error: cannot find OpenCL headers")
endif()
else()
add_subdirectory(ocl)
set(OpenCL_INCLUDE_DIR "${OpenCL_INCLUDE_DIR}" PARENT_SCOPE)
set(OpenCL_LIBRARY "${OpenCL_LIBRARY}" PARENT_SCOPE)
set(opencl_root_hints "${opencl_root_hints}" PARENT_SCOPE)
# system OpenCL is not found: set it explictly for consistent OpenVINOConfig.cmake generation
set(ENABLE_SYSTEM_OPENCL OFF PARENT_SCOPE)
add_subdirectory(thirdparty/ocl)
endif()
# cmake cannot set properties for imported targets
@ -157,7 +142,8 @@ if(ENABLE_INTEL_GPU)
# used in tests
add_library(opencl_new_headers INTERFACE)
add_library(OpenCL::NewHeaders ALIAS opencl_new_headers)
foreach(opencl_dir "${CMAKE_CURRENT_SOURCE_DIR}/ocl/clhpp_headers/include" "${CMAKE_CURRENT_SOURCE_DIR}/ocl/cl_headers")
foreach(opencl_dir "${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/ocl/clhpp_headers/include"
"${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/ocl/cl_headers")
if(EXISTS "${opencl_dir}")
set_property(TARGET opencl_new_headers APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES
$<BUILD_INTERFACE:${opencl_dir}>)
@ -172,35 +158,44 @@ endif()
#
if(ENABLE_SAMPLES OR ENABLE_TESTS)
find_package(ZLIB QUIET CONFIG)
find_package(ZLIB QUIET)
if(ZLIB_FOUND)
# need to make it global to use outside of the current sub-directory
set_target_properties(ZLIB::ZLIB PROPERTIES IMPORTED_GLOBAL ON)
# FindZLIB module defines ZLIB::ZLIB, no extra steps are required
endif()
# cmake has failed to find zlib, let's try pkg-config
if(NOT ZLIB_FOUND AND PkgConfig_FOUND)
pkg_search_module(zlib QUIET
IMPORTED_TARGET GLOBAL
IMPORTED_TARGET
zlib)
if(zlib_FOUND)
add_library(ZLIB::ZLIB ALIAS PkgConfig::zlib)
add_library(ZLIB::ZLIB INTERFACE IMPORTED)
set_target_properties(ZLIB::ZLIB PROPERTIES INTERFACE_LINK_LIBRARIES PkgConfig::zlib)
message(STATUS "${PKG_CONFIG_EXECUTABLE}: zlib (${zlib_VERSION}) is found at ${zlib_PREFIX}")
endif()
endif()
if(NOT (zlib_FOUND OR ZLIB_FOUND))
add_subdirectory(zlib EXCLUDE_FROM_ALL)
add_subdirectory(thirdparty/zlib EXCLUDE_FROM_ALL)
endif()
endif()
#
# cnpy
#
if(ENABLE_SAMPLES OR ENABLE_TESTS)
add_subdirectory(thirdparty/cnpy EXCLUDE_FROM_ALL)
endif()
#
# Pugixml
#
if(ENABLE_SYSTEM_PUGIXML)
# try system pugixml first
find_package(PugiXML QUIET)
# Note: we also specify 'pugixml' in NAMES because vcpkg
find_package(PugiXML QUIET NAMES PugiXML pugixml)
if(PugiXML_FOUND)
# TODO: use static pugixml library in case of BUILD_SHARED_LIBS=OFF
if(TARGET pugixml::shared)
@ -216,7 +211,7 @@ if(ENABLE_SYSTEM_PUGIXML)
# - 'apt-get install libpugixml-dev'
set(pugixml_target pugixml)
elseif(TARGET pugixml::static)
# sometimes pugixml::static target already exists, just need to make it global
# sometimes pugixml::static target already exists, just need to create an alias
# - 'conda install pugixml -c conda-forge'
set(pugixml_target pugixml::static)
else()
@ -225,10 +220,10 @@ if(ENABLE_SYSTEM_PUGIXML)
# to property generate OpenVINO Developer packages files
set(PugiXML_FOUND ${PugiXML_FOUND} CACHE BOOL "" FORCE)
elseif(PkgConfig_FOUND)
# U18 case when cmake interface is not available
# Ubuntu 18.04 case when cmake interface is not available
pkg_search_module(pugixml QUIET
IMPORTED_TARGET
GLOBAL
${OV_PkgConfig_VISILITY}
pugixml)
if(pugixml_FOUND)
set(pugixml_target PkgConfig::pugixml)
@ -246,10 +241,13 @@ if(ENABLE_SYSTEM_PUGIXML)
if(NOT TARGET ${pugixml_target})
find_library(PUGIXML_LIBRARY NAMES pugixml DOC "Path to pugixml library")
if(PUGIXML_LIBRARY)
add_library(pugixml INTERFACE IMPORTED GLOBAL)
add_library(pugixml INTERFACE IMPORTED)
set_target_properties(pugixml PROPERTIES INTERFACE_LINK_LIBRARIES "${PUGIXML_LIBRARY}")
set(pugixml_target pugixml)
set(PugiXML_FOUND ON)
# because we don't need to have a dependency on specific cmake targets in this case
# in file OpenVINOConfig.cmake static build case
set(ENABLE_SYSTEM_PUGIXML OFF)
endif()
endif()
@ -279,13 +277,16 @@ if(ENABLE_SYSTEM_PUGIXML)
message(FATAL_ERROR "Debian | RPM package build requires shared Pugixml library")
endif()
set_target_properties(${pugixml_target} PROPERTIES IMPORTED_GLOBAL ON)
if(OV_PkgConfig_VISILITY)
# need to set GLOBAL visibility in order to create ALIAS for this target
set_target_properties(${pugixml_target} PROPERTIES IMPORTED_GLOBAL ON)
endif()
# create an alias for real target which can be shared or static
add_library(openvino::pugixml ALIAS ${pugixml_target})
else()
# reset to prevent improper code generation in OpenVINODeveloperPackage.cmake,
# and OpenVINOConfig.cmake for static case
set(ENABLE_SYSTEM_PUGIXML OFF PARENT_SCOPE)
set(ENABLE_SYSTEM_PUGIXML OFF)
endif()
endif()
@ -294,7 +295,7 @@ if(NOT TARGET openvino::pugixml)
function(ov_build_pugixml)
function(ov_build_pugixml_static)
set(BUILD_SHARED_LIBS OFF)
add_subdirectory(pugixml EXCLUDE_FROM_ALL)
add_subdirectory(thirdparty/pugixml EXCLUDE_FROM_ALL)
endfunction()
ov_build_pugixml_static()
set_property(TARGET pugixml-static PROPERTY EXPORT_NAME pugixml)
@ -312,17 +313,17 @@ endif()
if(ENABLE_GAPI_PREPROCESSING)
add_library(ocv_hal INTERFACE)
target_include_directories(ocv_hal INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/ocv")
target_include_directories(ocv_hal INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/ocv")
# ade
find_package(ade 0.1.2 QUIET)
find_package(ade 0.1.0 QUIET)
if(ade_FOUND)
# conan creates 'ade' target
# set ade_FOUND to parent scope to properly generate OpenVINOConfig.cmake for static build
set(ade_FOUND ${ade_FOUND} PARENT_SCOPE)
# conan and vcpkg create 'ade' target
# we just need to remove non-numerical symbols from version,
# because conan defines it as 0.1.2a, which is invalid in cmake
string(REGEX REPLACE "[a-z]" "" ade_VERSION "${ade_VERSION}")
else()
add_subdirectory(ade EXCLUDE_FROM_ALL)
add_subdirectory(thirdparty/ade EXCLUDE_FROM_ALL)
set_target_properties(ade PROPERTIES FOLDER thirdparty)
openvino_developer_export_targets(COMPONENT openvino_common TARGETS ade)
@ -331,7 +332,7 @@ if(ENABLE_GAPI_PREPROCESSING)
endif()
# fluid
add_subdirectory(fluid/modules/gapi EXCLUDE_FROM_ALL)
add_subdirectory(thirdparty/fluid/modules/gapi EXCLUDE_FROM_ALL)
if(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 11)
target_compile_options(fluid PRIVATE "-Wno-maybe-uninitialized")
@ -351,42 +352,50 @@ endif()
#
if(ENABLE_SAMPLES OR ENABLE_COMPILE_TOOL OR ENABLE_TESTS)
# on Windows and macOS we don't use gflags, because will be dynamically linked
if(CMAKE_HOST_LINUX AND LINUX)
if(CMAKE_TOOLCHAIN_FILE MATCHES "vcpkg " OR DEFINED VCPKG_VERBOSE OR
CMAKE_TOOLCHAIN_FILE MATCHES "conan_toolchain" OR DEFINED CONAN_EXPORTED)
# vcpkg contains only libs compiled with threads
# conan case
find_package(gflags QUIET)
elseif(APPLE OR WIN32)
# on Windows and macOS we don't use gflags, because will be dynamically linked
elseif(CMAKE_HOST_LINUX AND LINUX)
if(OV_OS_RHEL)
set(gflag_component nothreads_shared)
elseif(OV_OS_DEBIAN)
set(gflag_component nothreads_static)
endif()
find_package(gflags QUIET OPTIONAL_COMPONENTS ${gflag_component})
else()
# conan case
find_package(gflags QUIET)
endif()
if(gflags_FOUND)
if(TARGET gflags)
set_target_properties(gflags PROPERTIES IMPORTED_GLOBAL ON)
# no extra steps
elseif(TARGET gflags_nothreads-static)
# Debian 9: gflag_component is ignored
set_target_properties(gflags_nothreads-static PROPERTIES IMPORTED_GLOBAL ON)
add_library(gflags ALIAS gflags_nothreads-static)
set(gflags_target gflags_nothreads-static)
elseif(TARGET gflags_nothreads-shared)
# CentOS / RHEL / Fedora case
set_target_properties(gflags_nothreads-shared PROPERTIES IMPORTED_GLOBAL ON)
add_library(gflags ALIAS gflags_nothreads-shared)
set(gflags_target gflags_nothreads-shared)
elseif(TARGET ${GFLAGS_TARGET})
set_target_properties(${GFLAGS_TARGET} PROPERTIES IMPORTED_GLOBAL ON)
add_library(gflags ALIAS ${GFLAGS_TARGET})
set(gflags_target ${GFLAGS_TARGET})
else()
message(FATAL_ERROR "Internal error: failed to find imported target 'gflags' using '${gflag_component}' component")
endif()
if(gflags_target)
if(OV_PkgConfig_VISILITY)
# need to set GLOBAL visibility in order to create ALIAS for this target
set_target_properties(${gflags_target} PROPERTIES IMPORTED_GLOBAL ON)
endif()
add_library(gflags ALIAS ${gflags_target})
endif()
message(STATUS "gflags (${gflags_VERSION}) is found at ${gflags_DIR} using '${gflag_component}' component")
endif()
if(NOT TARGET gflags)
add_subdirectory(gflags EXCLUDE_FROM_ALL)
add_subdirectory(thirdparty/gflags EXCLUDE_FROM_ALL)
openvino_developer_export_targets(COMPONENT openvino_common TARGETS gflags)
endif()
endif()
@ -401,11 +410,14 @@ if(ENABLE_TESTS)
if(GTest_FOUND)
foreach(gtest_target gtest gtest_main gmock gmock_main)
set_target_properties(GTest::${gtest_target} PROPERTIES IMPORTED_GLOBAL ON)
if(OV_PkgConfig_VISILITY)
# need to set GLOBAL visibility in order to create ALIAS for this target
set_target_properties(GTest::${gtest_target} PROPERTIES IMPORTED_GLOBAL ON)
endif()
add_library(${gtest_target} ALIAS GTest::${gtest_target})
endforeach()
else()
add_subdirectory(gtest EXCLUDE_FROM_ALL)
add_subdirectory(thirdparty/gtest EXCLUDE_FROM_ALL)
openvino_developer_export_targets(COMPONENT tests
TARGETS gmock gmock_main gtest gtest_main)
endif()
@ -423,25 +435,15 @@ if(ENABLE_OV_PADDLE_FRONTEND OR ENABLE_OV_ONNX_FRONTEND OR ENABLE_OV_TF_FRONTEND
if(CMAKE_VERBOSE_MAKEFILE)
set(Protobuf_DEBUG ON)
endif()
find_package(Protobuf 3.20.3 REQUIRED)
# Note: we also specify 'protobuf' in NAMES because vcpkg
find_package(Protobuf 3.20.3 REQUIRED NAMES Protobuf protobuf)
set(PROTOC_EXECUTABLE protobuf::protoc)
# in case of system protobuf, we have to add version to OpenVINOConfig.cmake for static build
# to ensure no mismatch between versions of protoc and libprotobuf, we need to use exactly
# the same versions
set(Protobuf_VERSION ${Protobuf_VERSION} PARENT_SCOPE)
foreach(target ${PROTOC_EXECUTABLE} protobuf::libprotobuf protobuf::libprotobuf-lite)
set_target_properties(${target} PROPERTIES IMPORTED_GLOBAL ON)
endforeach()
else()
add_subdirectory(protobuf EXCLUDE_FROM_ALL)
add_subdirectory(thirdparty/protobuf EXCLUDE_FROM_ALL)
endif()
# forward variables used in the other places
set(PROTOC_DEPENDENCY ${PROTOC_DEPENDENCY} PARENT_SCOPE)
set(PROTOC_EXECUTABLE ${PROTOC_EXECUTABLE} PARENT_SCOPE)
set(Protobuf_IN_FRONTEND ON PARENT_SCOPE)
# forward additional variables used in the other places
set(Protobuf_IN_FRONTEND ON)
# set public / interface compile options
foreach(target_name protobuf::libprotobuf protobuf::libprotobuf-lite)
@ -477,7 +479,9 @@ if(ENABLE_OV_TF_LITE_FRONTEND)
endif()
endif()
find_host_package(Flatbuffers QUIET NO_CMAKE_FIND_ROOT_PATH)
# on new Ubuntu versions like 23.04 we have config called FlatBuffersConfig.cmake
# so, we need to provide alternative names
find_host_package(Flatbuffers QUIET NAMES Flatbuffers FlatBuffers NO_CMAKE_FIND_ROOT_PATH)
if(DEFINED _old_flat_CMAKE_LIBRARY_ARCHITECTURE)
set(CMAKE_LIBRARY_ARCHITECTURE ${_old_flat_CMAKE_LIBRARY_ARCHITECTURE})
@ -489,17 +493,12 @@ if(ENABLE_OV_TF_LITE_FRONTEND)
# we don't actually use library files (.so | .dylib | .a) itself, only headers
set(flatbuffers_LIBRARY flatbuffers::flatbuffers)
set(flatbuffers_COMPILER flatbuffers::flatc)
foreach(target IN LISTS flatbuffers_LIBRARY flatbuffers_COMPILER)
set_property(TARGET ${target} PROPERTY IMPORTED_GLOBAL ON)
endforeach()
else()
add_subdirectory(flatbuffers EXCLUDE_FROM_ALL)
add_subdirectory(thirdparty/flatbuffers EXCLUDE_FROM_ALL)
endif()
set(flatbuffers_INCLUDE_DIRECTORIES $<TARGET_PROPERTY:${flatbuffers_LIBRARY},INTERFACE_INCLUDE_DIRECTORIES> PARENT_SCOPE)
set(flatbuffers_COMPILER ${flatbuffers_COMPILER} PARENT_SCOPE)
set(flatbuffers_DEPENDENCY ${flatbuffers_DEPENDENCY} PARENT_SCOPE)
# set additional variables, used in other places of our cmake scripts
set(flatbuffers_INCLUDE_DIRECTORIES $<TARGET_PROPERTY:${flatbuffers_LIBRARY},INTERFACE_INCLUDE_DIRECTORIES>)
endif()
#
@ -517,13 +516,12 @@ if(ENABLE_SNAPPY_COMPRESSION)
set(ov_snappy_lib Snappy::snappy-static)
endif()
set_target_properties(${ov_snappy_lib} PROPERTIES IMPORTED_GLOBAL ON)
add_library(openvino::snappy ALIAS ${ov_snappy_lib})
if(OV_PkgConfig_VISILITY)
# need to set GLOBAL visibility in order to create ALIAS for this target
set_target_properties(${ov_snappy_lib} PROPERTIES IMPORTED_GLOBAL ON)
endif()
# set Snappy_VERSION to parent scope for consistent OpenVINOConfig.cmake generation
# in case of static build with system dependencies
set(Snappy_VERSION ${Snappy_VERSION} PARENT_SCOPE)
set(ov_snappy_lib ${ov_snappy_lib} PARENT_SCOPE)
add_library(openvino::snappy ALIAS ${ov_snappy_lib})
endif()
if(NOT TARGET openvino::snappy)
@ -551,7 +549,7 @@ if(ENABLE_SNAPPY_COMPRESSION)
ie_add_compiler_flags(-Wno-sign-compare)
endif()
add_subdirectory(snappy EXCLUDE_FROM_ALL)
add_subdirectory(thirdparty/snappy EXCLUDE_FROM_ALL)
# need to create alias openvino::snappy
add_library(openvino::snappy ALIAS snappy)
@ -574,15 +572,9 @@ if(ENABLE_OV_ONNX_FRONTEND)
find_package(ONNX 1.13.1 EXACT QUIET COMPONENTS onnx onnx_proto NO_MODULE)
if(ONNX_FOUND)
# conan creates imported targets 'onnx' and 'onnx_proto'
set_target_properties(onnx onnx_proto PROPERTIES IMPORTED_GLOBAL ON)
# set ONNX_VERSION to parent scope for correct OpenVINOConfig.cmake generation
# in case of static libraries
set(ONNX_VERSION ${ONNX_VERSION} PARENT_SCOPE)
set(ENABLE_SYSTEM_ONNX ON PARENT_SCOPE)
# conan and vcpkg create imported targets 'onnx' and 'onnx_proto'
else()
add_subdirectory(onnx)
add_subdirectory(thirdparty/onnx)
endif()
endif()
@ -594,19 +586,16 @@ if(ENABLE_SAMPLES)
# Note: VPUX requires 3.9.0 version, because it contains 'nlohmann::ordered_json'
find_package(nlohmann_json 3.9.0 QUIET)
if(nlohmann_json_FOUND)
# conan creates imported target nlohmann_json::nlohmann_json
# no needs to make the target global, because samples call find_package(nlohmann_json) as well
# but we need to set nlohmann_json_FOUND to parent scope to properly generate InferenceEngineDeveloperPackageConfig.cmake
set(nlohmann_json_FOUND ${nlohmann_json_FOUND} PARENT_SCOPE)
# conan and vcpkg create imported target nlohmann_json::nlohmann_json
else()
add_subdirectory(json)
add_subdirectory(thirdparty/json)
# this is required only because of VPUX plugin reused this
openvino_developer_export_targets(COMPONENT openvino_common TARGETS nlohmann_json)
# for nlohmann library versions older than v3.0.0
if(NOT TARGET nlohmann_json::nlohmann_json)
add_library(nlohmann_json::nlohmann_json INTERFACE IMPORTED GLOBAL)
add_library(nlohmann_json::nlohmann_json INTERFACE IMPORTED)
set_target_properties(nlohmann_json::nlohmann_json PROPERTIES
INTERFACE_LINK_LIBRARIES nlohmann_json
INTERFACE_COMPILE_DEFINITIONS JSON_HEADER)
@ -633,7 +622,7 @@ if(CPACK_GENERATOR MATCHES "^(DEB|RPM|CONDA-FORGE|BREW|CONAN)$")
message(FATAL_ERROR "Pugixml must be used as a ${CPACK_GENERATOR} package. Install libpugixml-dev / pugixml-devel")
endif()
elseif(APPLE OR WIN32)
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/gflags
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/gflags
DESTINATION ${OV_CPACK_SAMPLESDIR}/cpp/thirdparty
COMPONENT ${OV_CPACK_COMP_CPP_SAMPLES}
PATTERN bazel EXCLUDE
@ -652,16 +641,16 @@ elseif(APPLE OR WIN32)
PATTERN .travis.yml EXCLUDE
PATTERN WORKSPACE EXCLUDE)
file(GLOB zlib_sources ${CMAKE_CURRENT_SOURCE_DIR}/zlib/zlib/*.c
${CMAKE_CURRENT_SOURCE_DIR}/zlib/zlib/*.h)
file(GLOB zlib_sources ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/zlib/zlib/*.c
${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/zlib/zlib/*.h)
install(FILES ${zlib_sources}
DESTINATION ${OV_CPACK_SAMPLESDIR}/cpp/thirdparty/zlib/zlib
COMPONENT ${OV_CPACK_COMP_CPP_SAMPLES})
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/zlib/CMakeLists.txt
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/zlib/CMakeLists.txt
DESTINATION ${OV_CPACK_SAMPLESDIR}/cpp/thirdparty/zlib
COMPONENT ${OV_CPACK_COMP_CPP_SAMPLES})
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/json/nlohmann_json
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/json/nlohmann_json
DESTINATION ${OV_CPACK_SAMPLESDIR}/cpp/thirdparty
COMPONENT ${OV_CPACK_COMP_CPP_SAMPLES}
PATTERN ChangeLog.md EXCLUDE
@ -682,6 +671,11 @@ elseif(APPLE OR WIN32)
PATTERN wsjcpp.yml EXCLUDE)
endif()
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/cnpy
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/cnpy
DESTINATION ${OV_CPACK_SAMPLESDIR}/cpp/thirdparty
COMPONENT ${OV_CPACK_COMP_CPP_SAMPLES})
# restore state
set(CMAKE_CXX_FLAGS "${_old_CMAKE_CXX_FLAGS}")
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE ${_old_CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE})

View File

@ -27,7 +27,7 @@ add_library(${TARGET_NAME} SHARED ${SOURCES})
target_include_directories(${TARGET_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
set_target_properties(${TARGET_NAME} PROPERTIES OUTPUT_NAME IntelSEAPI)
target_link_libraries(${TARGET_NAME} PRIVATE ittapi::ittnotify)
target_link_libraries(${TARGET_NAME} PRIVATE ittapi::ittapi)
if(UNIX)
target_link_libraries(${TARGET_NAME} PRIVATE ${CMAKE_DL_LIBS})

View File

@ -22,9 +22,9 @@ else()
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/ittapi/src/ittnotify>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/ittapi/include>)
# create alias ittapi::ittnotify
add_library(ittapi::ittnotify ALIAS ittnotify)
# create alias ittapi::ittapi
add_library(ittapi::ittapi ALIAS ittnotify)
openvino_developer_export_targets(COMPONENT openvino_common TARGETS ittapi::ittnotify)
ov_install_static_lib(ittapi::ittnotify ${OV_CPACK_COMP_CORE})
openvino_developer_export_targets(COMPONENT openvino_common TARGETS ittapi::ittapi)
ov_install_static_lib(ittapi::ittapi ${OV_CPACK_COMP_CORE})
endif()

View File

@ -59,9 +59,6 @@ class Benchmark:
def set_cache_dir(self, cache_dir: str):
self.core.set_property({'CACHE_DIR': cache_dir})
def set_allow_auto_batching(self, flag: bool):
self.core.set_property({'ALLOW_AUTO_BATCHING': flag})
def read_model(self, path_to_model: str):
model_filename = os.path.abspath(path_to_model)
head, ext = os.path.splitext(model_filename)

View File

@ -324,7 +324,7 @@ def main():
## If set batch size, disable the auto batching
if args.batch_size:
logger.warning("Batch size is set. Auto batching will be disabled")
benchmark.set_allow_auto_batching(False)
device_config["ALLOW_AUTO_BATCHING"] = False
topology_name = ""
load_from_file_enabled = is_flag_set_in_command_line('load_from_file') or is_flag_set_in_command_line('lfile')