* Extensibility guide with FE extensions and remove OV_FRAMEWORK_MAP from docs * Rework of Extensibility Intro, adopted examples to missing OPENVINO_FRAMEWORK_MAP * Removed OPENVINO_FRAMEWORK_MAP reference * Frontend extension detailed documentation * Fixed distributed snippets * Fixed snippet inclusion in FE extension document and chapter headers * Fixed wrong name in a snippet reference * Fixed test for template extension due to changed number of loaded extensions * Update docs/Extensibility_UG/frontend_extensions.md Co-authored-by: Ivan Tikhonov <ivan.tikhonov@intel.com> * Minor fixes in extension snippets * Small grammar fix Co-authored-by: Ivan Tikhonov <ivan.tikhonov@intel.com> Co-authored-by: Ivan Tikhonov <ivan.tikhonov@intel.com> * DOCS: transition banner (#10973) * transition banner * minor fix * update transition banner * updates * update custom.js * updates * updates * Documentation fixes (#11044) * Benchmark app usage * Fixed link to the devices * More fixes * Update docs/OV_Runtime_UG/multi_device.md Co-authored-by: Sergey Lyubimtsev <sergey.lyubimtsev@intel.com> * Removed several hardcoded links Co-authored-by: Sergey Lyubimtsev <sergey.lyubimtsev@intel.com> * Updated documentation for compile_tool (#11049) * Added deployment guide (#11060) * Added deployment guide * Added local distribution * Updates * Fixed more indentations * Removed obsolete code snippets (#11061) * Removed obsolete code snippets * NCC style * Fixed NCC for BA * Add a troubleshooting issue for PRC installation (#11074) * updates * adding gna to linux * add missing reference * update * Update docs/install_guides/installing-model-dev-tools.md Co-authored-by: Sergey Lyubimtsev <sergey.lyubimtsev@intel.com> * Update docs/install_guides/installing-model-dev-tools.md Co-authored-by: Sergey Lyubimtsev <sergey.lyubimtsev@intel.com> * Update docs/install_guides/installing-model-dev-tools.md Co-authored-by: Sergey Lyubimtsev <sergey.lyubimtsev@intel.com> * Update docs/install_guides/installing-model-dev-tools.md Co-authored-by: Sergey Lyubimtsev <sergey.lyubimtsev@intel.com> * Update docs/install_guides/installing-model-dev-tools.md Co-authored-by: Sergey Lyubimtsev <sergey.lyubimtsev@intel.com> * update * minor updates * add gna item to yum and apt * add gna to get started page * update reference formatting * merge commit * add a troubleshooting issue * update * update * fix CVS-71846 Co-authored-by: Sergey Lyubimtsev <sergey.lyubimtsev@intel.com> * DOCS: fixed hardcoded links (#11100) * Fixes * Use links * applying reviewers comments to the Opt Guide (#11093) * applying reviewrs comments * fixed refs, more structuring (bold, bullets, etc) * refactoring tput/latency sections * next iteration (mostly latency), also brushed the auto-batching and other sections * updates sync/async images * common opts brushed * WIP tput redesigned * minor brushing of common and auto-batching * Tput fully refactored * fixed doc name in the link * moved int8 perf counters to the right section * fixed links * fixed broken quotes * fixed more links * add ref to the internals to the TOC * Added a note on the batch size Co-authored-by: Andrey Zaytsev <andrey.zaytsev@intel.com> * [80085] New images for docs (#11114) * change doc structure * fix manager tools * fix manager tools 3 step * fix manager tools 3 step * new img * new img for OV Runtime * fix steps * steps * fix intendents * change list * fix space * fix space * code snippets fix * change display * Benchmarks 2022 1 (#11130) * Minor fixes * Updates for 2022.1 * Edits according to the review * Edits according to review comments * Edits according to review comments * Edits according to review comments * Fixed table * Edits according to review comments * Removed config for Intel® Core™ i7-11850HE * Removed forward-tacotron-duration-prediction-241 graph * Added resnet-18-pytorch * Add info about Docker images in Deployment guide (#11136) * Renamed user guides (#11137) * fix screenshot (#11140) * More conservative recommendations on dynamic shapes usage in docs (#11161) * More conservative recommendations about using dynamic shapes * Duplicated statement from C++ part to Python part of reshape doc (no semantical changes) * Update ShapeInference.md (#11168) * Benchmarks 2022 1 updates (#11180) * Updated graphs * Quick fix for TODO in Dynamic Shapes article * Anchor link fixes * Fixed DM config (#11199) * DOCS: doxy sphinxtabs (#11027) * initial implementation of doxy sphinxtabs * fixes * fixes * fixes * fixes * fixes * WA for ignored visibility attribute * Fixes Co-authored-by: Sergey Lyalin <sergey.lyalin@intel.com> Co-authored-by: Ivan Tikhonov <ivan.tikhonov@intel.com> Co-authored-by: Nikolay Tyukaev <nikolay.tyukaev@intel.com> Co-authored-by: Sergey Lyubimtsev <sergey.lyubimtsev@intel.com> Co-authored-by: Yuan Xu <yuan1.xu@intel.com> Co-authored-by: Maxim Shevtsov <maxim.y.shevtsov@intel.com> Co-authored-by: Andrey Zaytsev <andrey.zaytsev@intel.com> Co-authored-by: Tatiana Savina <tatiana.savina@intel.com> Co-authored-by: Ilya Naumov <ilya.naumov@intel.com> Co-authored-by: Evgenya Stepyreva <evgenya.stepyreva@intel.com>
6.9 KiB
Integrate OpenVINO™ with Your Application
@sphinxdirective
.. toctree:: :maxdepth: 1 :hidden:
openvino_docs_OV_Runtime_UG_Model_Representation openvino_docs_OV_Runtime_UG_Infer_request openvino_docs_OV_Runtime_UG_Python_API_exclusives
@endsphinxdirective
Note
: Before start using OpenVINO™ Runtime, make sure you set all environment variables during the installation. If you did not, follow the instructions from the Set the Environment Variables section in the installation guides:
- For Windows* 10
- For Linux*
- For macOS*
- To build an open source version, use the OpenVINO™ Runtime Build Instructions.
Use OpenVINO™ Runtime API to Implement Inference Pipeline
This section provides step-by-step instructions to implement a typical inference pipeline with the OpenVINO™ Runtime C++ API:
Step 1. Create OpenVINO™ Runtime Core
Include next files to work with OpenVINO™ Runtime:
@sphinxtabset
@sphinxtab{C++}
@snippet docs/snippets/src/main.cpp include
@endsphinxtab
@sphinxtab{Python}
@snippet docs/snippets/src/main.py import
@endsphinxtab
@endsphinxtabset
Use the following code to create OpenVINO™ Core to manage available devices and read model objects:
@sphinxtabset
@sphinxtab{C++}
@snippet docs/snippets/src/main.cpp part1
@endsphinxtab
@sphinxtab{Python}
@snippet docs/snippets/src/main.py part1
@endsphinxtab
@endsphinxtabset
Step 2. Compile the Model
ov::CompiledModel class represents a device specific compiled model. ov::CompiledModel allows you to get information inputs or output ports by a tensor name or index, this approach is aligned with the majority of frameworks.
Compile the model for a specific device using ov::Core::compile_model():
@sphinxtabset
@sphinxtab{C++}
@sphinxtabset
@sphinxtab{IR}
@snippet docs/snippets/src/main.cpp part2_1
@endsphinxtab
@sphinxtab{ONNX}
@snippet docs/snippets/src/main.cpp part2_2
@endsphinxtab
@sphinxtab{PaddlePaddle}
@snippet docs/snippets/src/main.cpp part2_3
@endsphinxtab
@sphinxtab{ov::Model}
@snippet docs/snippets/src/main.cpp part2_4
@endsphinxtab
@endsphinxtabset
@endsphinxtab
@sphinxtab{Python}
@sphinxtabset
@sphinxtab{IR}
@snippet docs/snippets/src/main.py part2_1
@endsphinxtab
@sphinxtab{ONNX}
@snippet docs/snippets/src/main.py part2_2
@endsphinxtab
@sphinxtab{PaddlePaddle}
@snippet docs/snippets/src/main.py part2_3
@endsphinxtab
@sphinxtab{ov::Model}
@snippet docs/snippets/src/main.py part2_4
@endsphinxtab
@endsphinxtabset
@endsphinxtab
@endsphinxtabset
The ov::Model object represents any models inside the OpenVINO™ Runtime.
For more details please read article about OpenVINO™ Model representation.
The code above creates a compiled model associated with a single hardware device from the model object. It is possible to create as many compiled models as needed and use them simultaneously (up to the limitation of the hardware resources). To learn how to change the device configuration, read the Query device properties article.
Step 3. Create an Inference Request
ov::InferRequest class provides methods for model inference in OpenVINO™ Runtime. Create an infer request using the following code (see InferRequest detailed documentation for more details):
@sphinxtabset
@sphinxtab{C++}
@snippet docs/snippets/src/main.cpp part3
@endsphinxtab
@sphinxtab{Python}
@snippet docs/snippets/src/main.py part3
@endsphinxtab
@endsphinxtabset
Step 4. Set Inputs
You can use external memory to create ov::Tensor and use the ov::InferRequest::set_input_tensor method to put this tensor on the device:
@sphinxtabset
@sphinxtab{C++}
@snippet docs/snippets/src/main.cpp part4
@endsphinxtab
@sphinxtab{Python}
@snippet docs/snippets/src/main.py part4
@endsphinxtab
@endsphinxtabset
Step 5. Start Inference
OpenVINO™ Runtime supports inference in either synchronous or asynchronous mode. Using the Async API can improve application's overall frame-rate, because rather than wait for inference to complete, the app can keep working on the host, while the accelerator is busy. You can use ov::InferRequest::start_async to start model inference in the asynchronous mode and call ov::InferRequest::wait to wait for the inference results:
@sphinxtabset
@sphinxtab{C++}
@snippet docs/snippets/src/main.cpp part5
@endsphinxtab
@sphinxtab{Python}
@snippet docs/snippets/src/main.py part5
@endsphinxtab
@endsphinxtabset
This section demonstrates a simple pipeline, to get more information about other ways to perform inference, read the dedicated "Run inference" section.
Step 6. Process the Inference Results
Go over the output tensors and process the inference results.
@sphinxtabset
@sphinxtab{C++}
@snippet docs/snippets/src/main.cpp part6
@endsphinxtab
@sphinxtab{Python}
@snippet docs/snippets/src/main.py part6
@endsphinxtab
@endsphinxtabset
Link and Build Your C++ Application with OpenVINO™ Runtime
The example uses CMake for project configuration.
-
Create a structure for the project:
project/ ├── CMakeLists.txt - CMake file to build ├── ... - Additional folders like includes/ └── src/ - source folder └── main.cpp build/ - build directory ... -
Include OpenVINO™ Runtime libraries in
project/CMakeLists.txt@snippet snippets/CMakeLists.txt cmake:integration_example
To build your project using CMake with the default build tools currently available on your machine, execute the following commands:
Note
: Make sure you set environment variables first by running
<INSTALL_DIR>/setupvars.sh(orsetupvars.batfor Windows). Otherwise theOpenVINO_DIRvariable won't be configured properly to passfind_packagecalls.
cd build/
cmake ../project
cmake --build .
It's allowed to specify additional build options (e.g. to build CMake project on Windows with a specific build tools). Please refer to the CMake page for details.
Run Your Application
Congratulations, you have made your first application with OpenVINO™ toolkit, now you may run it.