* Preprocessing API - base classes
Includes API definition for trivial mean/scale operations (which don't require layout)
Mean/scale with 'layout' support will be done under separate task together
with Layout
Current test code coverage: 100%
* Python bindings for base preprocessing API
* remove pre_post_process directory from ngraph/core
* remove files from ngraph/python dir
* move pyngraph pre_post_process files from ngraph/python to runtime
* remove pre_post_process test from CMakeList
* move include to the header
* update include path for pre_post_process
* style fix
* bind InputTensorInfo::set_layout
* cleaned test_preprocess
* fix test expected output
* remove duplicate test
* update description of set_element_type
* fix style
* move preprocess from pyngraph to pyopenvino/graph
* update test_preprocess imports and remove unnecessary test
* remove duplicate import
* update custom method
* update test
* update test
* create decorator that changes Node into Output<Node>
* create function that cast Node to Output<Node>
* update test_preprocess to use decorator for custom function
* change _cast_to_output -> _from_node
* style fix
* add tests fro scale and mean with vector input
* style fix
* add docstring for custom_preprocess_function
* bind InputInfo network method
* style fix
* bind OutputInfo
* fix description of preprocess submodule
* fix style
* update copyright year
* bind OutputTensorInfo
* bind OutputNetworkInfo and InputNetworkInfo
* Bind exec core ov (#50)
* Output const node python tests (#52)
* add python bindings tests for Output<const ov::None>
* add proper tests
* add new line
* rename ie_version to version
* Pszmel/bind infer request (#51)
* remove set_batch, get_blob and set_blob
* update InferRequest class
* change InferenceEngine::InferRequest to ov::runtime::InferRequest
* update set_callback body
* update bindings to reflect ov::runtime::InferRequest
* bind set_input_tensor and get_input_tensor
* style fix
* clen ie_infer_queue.cpp
* Bind exec core ov (#50)
* bind core, exec_net classes
* rm unused function
* add new line
* rename ie_infer_request -> infer_request
* update imports
* update __init__.py
* update ie_api.py
* Replace old containers with the new one
* create impl for create_infer_request
* comment out infer_queue to avoid errors with old infer_request
* update infer_request bind to reflect new infer_request api
* comment out inpuit_info from ie_network to avoid errors with old containers
* Register new containers and comment out InferQueue
* update infer request tests
* style fix
* remove unused imports
* remove unused imports and 2 methods
* add tests to cover all new methods from infer_request
* style fix
* add test
* remove registration of InferResults
* update name of exception_ptr parameter
* update the loops that iterate through inputs and outputs
* clean setCustomCallbacks
* style fix
* add Tensor import
* style fix
* update infer and normalize_inputs
* style fix
* rename startTime and endTime
* Create test for mixed keys as infer arguments
* update infer function
* update return type of infer
Co-authored-by: Bartek Szmelczynski <bartosz.szmelczynski@intel.com>
* fix get_version
* fix opaque issue
* some cosmetic changes
* fix codestyle in tests
* make tests green
* Extend python InferRequest
* Extend python Function
* Change return value of infer call
* Fix missing precisions conversions in CPU plugin
* Rework of runtime for new tests
* Fixed onnx reading in python tests
* Edit compatibility tests
* Edit tests
* Add FLOAT_LIKE xfails
* bind ColorFormat and ResizeAlgorithm
* clean imports
* fix typo
* [Python API] bind ProfilingInfo (#55)
* bind ProfilingInfo
* Add tests
* Fix code style
* Add property
* fix codestyle
* Infer new request method (#56)
* fix conflicts, add infer_new_request function
* remove redundant functions, fix style
* revert the unwanted changes
* revert removal of the Blob
* revert removal of isTblob
* add add_extension from path
* codestyle
* add PostProcessSteps to init
* bind PreProcessSteps
* create additional tests
* fix win build
* add inputs-outputs to function
* update infer queue
* fix code style
* Hot-fix CPU plugin with precision
* fix start_async
* add performance hint to time infer (#8480)
* Updated common migration pipeline (#8176)
* Updated common migration pipeline
* Fixed merge issue
* Added new model and extended example
* Fixed typo
* Added v10-v11 comparison
* Avoid redundant graph nodes scans (#8415)
* Refactor work with env variables (#8208)
* del MO_ROOT
* del MO_ROOT from common_utils.py
* add MO_PATH to common_utils.py
* change mo_path
* [IE Sample Scripts] Use cmake to build samples (#8442)
* Use cmake to build samples
* Add the option to set custom build output folder
* Remove opset8 from compatibility ngraph python API (#8452)
* [GPU] OneDNN gpu submodule update to version 2.5 (#8449)
* [GPU] OneDNN gpu submodule update to version 2.5
* [GPU] Updated onednn submodule and added layout optimizer fix
* Install rules for static libraries case (#8384)
* Proper cmake install for static libraries case
* Added an ability to skip template plugin
* Added install rules for VPU / GPU
* Install more libraries
* Fixed absolute TBB include paths
* Disable GNA
* Fixed issue with linker
* Some fixes
* Fixed linkage issues in tests
* Disabled some tests
* Updated CI pipelines
* Fixed Windows linkage
* Fixed custom_opset test for static casr
* Fixed CVS-70313
* Continue on error
* Fixed clanf-format
* Try to fix Windows linker
* Fixed compilation
* Disable samples
* Fixed samples build with THREADING=SEQ
* Fixed link error on Windows
* Fixed ieFuncTests
* Added static Azure CI
* Revert "Fixed link error on Windows"
This reverts commit 78cca36fd2.
* Merge static and dynamic linux pipelines
* Fixed Azure
* fix codestyle
* rename all methods in this class to snake_case
* some updates
* code style
* fix code style in tests
* update statistics reporting
* update filling inputs
* change ngraph.Type to ov.Type
* fix typo
* save work
* save work
* save work
* compute latency in callback
* save work
* Fix get_idle_request
* save work
* fix latency
* Fix code style
* update AppInputInfo
* add iteration to PatrialShape
* fix rebasing
* bind result::get_layout()
* correct mistakes
* fix setup
* use parameters/results instead inputs/outputs
* move _from_node to node_output.hpp
* add read_model from buffer
* update imports
* revert package struct
* add new line
* remove bad quotes
* update imports
* style fix
* add new line
* Fix preprocessing
* rename functin args
* set NCHW layout to image as default
* Fix input fillings
* remove Type import
* update tests
* style fix
* test clean
* remove blank line
* Add tensor_shape
* fix comments
* update PrePostProcessor init and build methods
* create test with model update tests with new PrePostProcessor init and build
* Change filling inputs
* fix preprocessing
* basic support dynamic shapes
* fix legacy mode
* rename ie to core
* fix cpp code style
* fix input files parsing
* fix binary filling
* support dynamic batch size
* process images with original shapes if no tensor shapes were given
* fix fps and number of iterations
* Add new metrics
* support pass path to folder into input mapping
* add pcseq flag
* fix resolving conflicts
* dump statistic per group
* check for compatibility with partial shape
* revert statistic report names
* code refactoring
* update parameters
* enable legacy_mode if data size less than nireq
* add serialize to offline_transformations
* Fix preprocessing import
* change log output due to ci parsing
* fix layout
* allow to pass batch size with undefined layout
* add serializer
* fix comments from jiwaszki
* Fix latency parsing for ci
* code style
* rename tensor_shape to data_shape
* add message if image is processed with original shape
* fix syntax warning
* remove default legacy_mode if requests cover all data
* rewrite all file parsing
* fix preprocessing
* Fix preprocessing #2
* Use layout instead str
* Fix file extensions
* Fix image sizes filling
* sort input files
* [Python API] quick fix of packaging
* update tests
* fix setup.py
* small fix
* small fixes according to comments
* skip mo frontend tests
* full mode is default for dynamic models only
* backward compatibility
* Fix package
* set layout in runtime
* static mode for dynamic models with all equal data shapes
* use get_tensor instead set_tensor in legacy mode
* benchmarking dynamic model available in full mode only
* fix layout detection
* use batch_size * iteration instead processed_frames in legacy mode
* fix tensor naming
* represent --inference_only
* refactoring main loop
* Fix number of iterations for full mode
Co-authored-by: Michael Nosov <mikhail.nosov@intel.com>
Co-authored-by: pszmel <piotr.szmelczynski@intel.com>
Co-authored-by: Bartek Szmelczynski <bartosz.szmelczynski@intel.com>
Co-authored-by: Anastasia Kuporosova <anastasia.kuporosova@intel.com>
Co-authored-by: jiwaszki <jan.iwaszkiewicz@intel.com>
Co-authored-by: Victor Kuznetsov <victor.kuznetsov@intel.com>
Co-authored-by: Ilya Churaev <ilya.churaev@intel.com>
Co-authored-by: Tomasz Jankowski <tomasz1.jankowski@intel.com>
Co-authored-by: Dmitry Pigasin <dmitry.pigasin@intel.com>
Co-authored-by: Artur Kulikowski <artur.kulikowski@intel.com>
Co-authored-by: Ilya Znamenskiy <ilya.znamenskiy@intel.com>
Co-authored-by: Ilya Lavrenov <ilya.lavrenov@intel.com>
Benchmark Python* Tool
This topic demonstrates how to run the Benchmark Python* Tool, which performs inference using convolutional networks. Performance can be measured for two inference modes: latency- and throughput-oriented.
NOTE: This topic describes usage of Python implementation of the Benchmark Tool. For the C++ implementation, refer to Benchmark C++ Tool.
Tip
: You can quick start with the Benchmark Tool inside the OpenVINO™ [Deep Learning Workbench](@ref openvino_docs_get_started_get_started_dl_workbench) (DL Workbench). [DL Workbench](@ref workbench_docs_Workbench_DG_Introduction) is the OpenVINO™ toolkit UI you to import a model, analyze its performance and accuracy, visualize the outputs, optimize and prepare the model for deployment on various Intel® platforms.
How It Works
Upon start-up, the application reads command-line parameters and loads a network and inputs (images/binary files) to the specified device. Device-specific execution parameters (number of streams, threads, and so on) can be either explicitly specified through the command line or left default. In the latter case, the sample logic will select the values for the optimal throughput. While further experimenting with individual parameters (like number of streams and requests, batch size, etc) allows to find the performance sweet spot, usually, the resulting values are not very performance-portable, so the values from one machine or device are not necessarily optimal for another. From this perspective, the most portable way is experimenting only the performance hints. To learn more, refer to the section below.
Note
: By default, Inference Engine samples, tools and demos expect input with BGR channels order. If you trained your model to work with RGB order, you need to manually rearrange the default channels order in the sample or demo application or reconvert your model using the Model Optimizer tool with
--reverse_input_channelsargument specified. For more information about the argument, refer to When to Reverse Input Channels section of Converting a Model Using General Conversion Parameters.
Latency and Throughput-focused Inference Modes
In many cases the primary performance metric is the time (in milliseconds) for an individual inference request.
For conventional devices the best latency is usually achieved when the application operates single inference request.
Similarly, while for some devices the synchronous API (Infer method) was slightly better for the latency.
However, advanced devices like multi-socket CPUs, modern GPUs and so on, are capable to run multiple inference requests,
while delivering the same latency (as with the single request). Also, the asynchronous API is more general/flexible
(with respect to handling multiple inference requests).
Overall, the legacy way of measuring latency (triggered by '-api sync') with a single request and synchronous API is discouraged
in favor of the dedicated '-hint latency' that lets the device to apply the right settings to minimize the time to request.
Throughput-oriented scenarios, in contrast, are focused on fully saturating the machine with enough data to crunch, as opposite to the time of the individual request. So, the primary performance metric is rather FPS (frames per second). Yet, just like with the latency case, the optimal execution parameters may differ between machines and devices. So, again, as explained in the previous section, the most portable way is to use the dedicated performance hint, rather than playing individual parameters. The hints allow the device to configure actual settings for the specified mode. The sample then queries/executes the optimal number of inference requests.
During the execution, the application collects/reports two types of metrics:
- Wall-clock time (latency) of each infer request and resulting latency
- Duration of all inference executions and resulting throughput By default, the reported latency value is always calculated as the median (i.e. 50th percentile) value of all collected latencies from individual requests. Notice that you can change the desired percentile with the command-line flag. The throughput value is derived from the overall inference execution time and number of completed requests (respecting the batch size).
Defining the Number of Inference Executions
A number of executions is defined by one of the two values:
- Explicitly, with the
-nitercommand-line argument - As time duration specified with the
-tcommand-line argument - Both of them (execution will continue until both conditions are met)
- Predefined duration if neither
-niternor-tare not specified. Predefined duration value depends on the device.
Run the Tool
Before running the Benchmark tool, install the requirements:
pip install -r requirements.txt
Notice that the benchmark_app usually produces optimal performance for any device out of the box.
So in most cases you don't need to play the app options explicitly and the plain device name is enough, for example, for CPU:
python3 benchmark_app.py -m <model> -i <input> -d CPU
But it is still may be sub-optimal for some cases, especially for very small networks. More details can read in Introduction to Performance Topics.
Running the application with the -h or --help' option yields the following usage message:
usage: benchmark_app.py [-h] [-i PATH_TO_INPUT] -m PATH_TO_MODEL
[-d TARGET_DEVICE]
[-l PATH_TO_EXTENSION] [-c PATH_TO_CLDNN_CONFIG]
[-hint {throughput, latency}]
[-api {sync,async}] [-niter NUMBER_ITERATIONS]
[-b BATCH_SIZE]
[-stream_output [STREAM_OUTPUT]] [-t TIME]
[-progress [PROGRESS]] [-nstreams NUMBER_STREAMS]
[-nthreads NUMBER_THREADS] [-pin {YES,NO,NUMA,HYBRID_AWARE}]
[--exec_graph_path EXEC_GRAPH_PATH]
[-pc [PERF_COUNTS]]
Options:
-h, --help Show this help message and exit.
-i PATH_TO_INPUT, --path_to_input PATH_TO_INPUT
Optional. Path to a folder with images and/or binaries
or to specific image or binary file.
-m PATH_TO_MODEL, --path_to_model PATH_TO_MODEL
Required. Path to an .xml/.onnx/.prototxt file with a
trained model or to a .blob file with a trained
compiled model.
-d TARGET_DEVICE, --target_device TARGET_DEVICE
Optional. Specify a target device to infer on: CPU,
GPU, HDDL or MYRIAD.
Use "-d HETERO:<comma separated devices list>" format to specify HETERO plugin.
Use "-d MULTI:<comma separated devices list>" format to specify MULTI plugin.
The application looks for a suitable plugin for the specified device.
-l PATH_TO_EXTENSION, --path_to_extension PATH_TO_EXTENSION
Optional. Required for CPU custom layers. Absolute
path to a shared library with the kernels
implementations.
-c PATH_TO_CLDNN_CONFIG, --path_to_cldnn_config PATH_TO_CLDNN_CONFIG
Optional. Required for GPU custom kernels. Absolute
path to an .xml file with the kernels description.
-hint {throughput, latency}, --perf_hint {throughput, latency}
Optional. Performance hint (optimize for latency or throughput).
The hint allows the OpenVINO device to select the right network-specific settings,
as opposite to defining specific values like \nstreams\ from the command line.
So you can specify just the hint without adding explicit device-specific options.
-api {sync,async}, --api_type {sync,async}
Optional. Enable using sync/async API. Default value
is async.
-niter NUMBER_ITERATIONS, --number_iterations NUMBER_ITERATIONS
Optional. Number of iterations. If not specified, the
number of iterations is calculated depending on a
device.
-b BATCH_SIZE, --batch_size BATCH_SIZE
Optional. Batch size value. If not specified, the
batch size value is determined from IR
-stream_output [STREAM_OUTPUT]
Optional. Print progress as a plain text. When
specified, an interactive progress bar is replaced
with a multiline output.
-t TIME, --time TIME Optional. Time in seconds to execute topology.
-progress [PROGRESS] Optional. Show progress bar (can affect performance
measurement). Default values is "False".
-shape SHAPE Optional. Set shape for input. For example,
"input1[1,3,224,224],input2[1,4]" or "[1,3,224,224]"
in case of one input size.
-layout LAYOUT Optional. Prompts how network layouts should be
treated by application. For example,
"input1[NCHW],input2[NC]" or "[NCHW]" in case of one
input size.
-nstreams NUMBER_STREAMS, --number_streams NUMBER_STREAMS
Optional. Number of streams to use for inference on the CPU/GPU/MYX in throughput mode
(for HETERO and MULTI device cases use format <device1>:<nstreams1>,<device2>:<nstreams2> or just <nstreams>).
Default value is determined automatically for a device.
Please note that although the automatic selection usually provides a reasonable performance,
it still may be non-optimal for some cases, especially for very small networks.
-nthreads NUMBER_THREADS, --number_threads NUMBER_THREADS
Number of threads to use for inference on the CPU
(including HETERO and MULTI cases).
-pin {YES,NO,NUMA,HYBRID_AWARE}, --infer_threads_pinning {YES,NO,NUMA,HYBRID_AWARE}
Optional. Enable threads->cores ('YES' which is OpenVINO runtime's default for conventional CPUs),
threads->(NUMA)nodes ('NUMA'),
threads->appropriate core types ('HYBRID_AWARE', which is OpenVINO runtime's default for Hybrid CPUs)
or completely disable ('NO')
CPU threads pinning for CPU-involved inference.
--exec_graph_path EXEC_GRAPH_PATH
Optional. Path to a file where to store executable
graph information serialized.
-pc [PERF_COUNTS], --perf_counts [PERF_COUNTS]
Optional. Report performance counters.
-ip "U8"/"FP16"/"FP32" Optional. Specifies precision for all input layers of the network.
-op "U8"/"FP16"/"FP32" Optional. Specifies precision for all output layers of the network.
-iop Optional. Specifies precision for input and output layers by name. Example: -iop "input:FP16, output:FP16". Notice that quotes are required. Overwrites precision from ip and op options for specified layers.
Running the application with the empty list of options yields the usage message given above and an error message.
Application supports topologies with one or more inputs. If a topology is not data sensitive, you can skip the input parameter. In this case, inputs are filled with random values. If a model has only image input(s), please a provide folder with images or a path to an image as input. If a model has some specific input(s) (not images), please prepare a binary file(s), which is filled with data of appropriate precision and provide a path to them as input. If a model has mixed input types, input folder should contain all required files. Image inputs are filled with image files one by one. Binary inputs are filled with binary inputs one by one.
To run the tool, you can use [public](@ref omz_models_group_public) or [Intel's](@ref omz_models_group_intel) pre-trained models from the Open Model Zoo. The models can be downloaded using the [Model Downloader](@ref omz_tools_downloader).
Note
: Before running the tool with a trained model, make sure the model is converted to the Inference Engine format (*.xml + *.bin) using the Model Optimizer tool.
Examples of Running the Tool
This section provides step-by-step instructions on how to run the Benchmark Tool with the googlenet-v1 public model on CPU or GPU devices. As an input, the car.png file from the <INSTALL_DIR>/samples/scripts/ directory is used.
NOTE: The Internet access is required to execute the following steps successfully. If you have access to the Internet through the proxy server only, please make sure that it is configured in your OS environment.
-
Download the model. Go to the the Model Downloader directory and run the
downloader.pyscript with specifying the model name and directory to download the model to:cd <INSTALL_DIR>/extras/open_model_zoo/tools/downloaderpython3 downloader.py --name googlenet-v1 -o <models_dir> -
Convert the model to the Inference Engine IR format. Go to the Model Optimizer directory and run the
mo.pyscript with specifying the path to the model, model format (which must be FP32 for CPU and FPG) and output directory to generate the IR files:cd <INSTALL_DIR>/tools/model_optimizerpython3 mo.py --input_model <models_dir>/public/googlenet-v1/googlenet-v1.caffemodel --data_type FP32 --output_dir <ir_dir> -
Run the tool with specifying the
<INSTALL_DIR>/samples/scripts/car.pngfile as an input image, the IR of thegooglenet-v1model and a device to perform inference on. The following commands demonstrate running the Benchmark Tool in the asynchronous mode on CPU and GPU devices:- On CPU:
python3 benchmark_app.py -m <ir_dir>/googlenet-v1.xml -d CPU -api async -i <INSTALL_DIR>/samples/scripts/car.png --progress true -b 1- On GPU:
python3 benchmark_app.py -m <ir_dir>/googlenet-v1.xml -d GPU -api async -i <INSTALL_DIR>/samples/scripts/car.png --progress true -b 1
The application outputs number of executed iterations, total duration of execution, latency and throughput.
Additionally, if you set the -pc parameter, the application outputs performance counters.
If you set -exec_graph_path, the application reports executable graph information serialized.
Below are fragments of sample output for CPU and GPU devices:
- For CPU:
[Step 8/9] Measuring performance (Start inference asynchronously, 60000 ms duration, 4 inference requests in parallel using 4 streams) Progress: |................................| 100.00% [Step 9/9] Dumping statistics report Progress: |................................| 100.00% Count: 4408 iterations Duration: 60153.52 ms Latency: 51.8244 ms Throughput: 73.28 FPS - For GPU:
[Step 10/11] Measuring performance (Start inference asynchronously, 5 inference requests using 1 streams for CPU, limits: 120000 ms duration) Progress: |................................| 100% [Step 11/11] Dumping statistics report Count: 98075 iterations Duration: 120011.03 ms Latency: 5.65 ms Throughput: 817.22 FPS
See Also
- Using Inference Engine Samples
- Model Optimizer
- [Model Downloader](@ref omz_tools_downloader)