* 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.7 KiB
Model Representation in OpenVINO™ Runtime
In OpenVINO™ Runtime a model is represented by the ov::Model class.
The ov::Model object stores shared pointers to ov::op::v0::Parameter, ov::op::v0::Result and ov::op::Sink operations that are inputs, outputs and sinks of the graph.
Sinks of the graph have no consumers and are not included in the results vector. All other operations hold each other via shared pointers: child operation holds its parent (hard link). If an operation has no consumers and it's not the Result or Sink operation
(shared pointer counter is zero), then it will be destructed and won't be accessible anymore.
Each operation in ov::Model has the std::shared_ptr<ov::Node> type.
For details on how to build a model in OpenVINO™ Runtime, see the [Build a Model in OpenVINO™ Runtime](@ref ov_ug_build_model) section.
OpenVINO™ Runtime allows to use different approaches to work with model inputs/outputs:
ov::Model::inputs()/ov::Model::outputs()methods allow to get vector of all input/output ports.- For a model which has only one input or output you can use methods
ov::Model::input()orov::Model::output()without arguments to get input or output port respectively. - Methods
ov::Model::input()andov::Model::output()can be used with index of input or output from the framework model to get specific port by index. - You can use tensor name of input or output from the original framework model together with methods
ov::Model::input()orov::Model::output()to get specific port. It means that you don't need to have any additional mapping of names from framework to OpenVINO, as it was before, OpenVINO™ Runtime allows using of native framework tensor names.
@sphinxtabset
@sphinxtab{C++}
@snippet docs/snippets/ov_model_snippets.cpp all_inputs_ouputs
@endsphinxtab
@sphinxtab{Python}
@snippet docs/snippets/ov_model_snippets.py all_inputs_ouputs
@endsphinxtab
@endsphinxtabset
OpenVINO™ Runtime model representation uses special classes to work with model data types and shapes. For data types the ov::element::Type is used.
Shapes Representation
OpenVINO™ Runtime provides two types for shape representation:
-
ov::Shape- Represents static (fully defined) shapes. -
ov::PartialShape- Represents dynamic shapes. That means that the rank or some of dimensions are dynamic (dimension defines an interval or undefined).ov::PartialShapecan be converted toov::Shapeusing theget_shape()method if all dimensions are static; otherwise the conversion raises an exception.
@sphinxtabset
@sphinxtab{C++}
@snippet docs/snippets/ov_model_snippets.cpp ov:partial_shape
@endsphinxtab
@sphinxtab{Python}
@snippet docs/snippets/ov_model_snippets.py ov:partial_shape
@endsphinxtab
@endsphinxtabset
But in most cases before getting static shape using get_shape() method, you need to check that shape is static.
Operations
The ov::Op class represents any abstract operation in the model representation. Use this class to create custom operations.
Operation Sets
Operation set (opset) is a collection of operations that can be used to construct a model. The ov::OpSet class provides a functionality to work with operation sets.
For each operation set, OpenVINO™ Runtime provides a separate namespace, for example opset8.
Each OpenVINO™ Release introduces new operations and add these operations to a new operation set. New operation sets help to introduce a new version of operations that change behavior of previous operations. Using operation sets allows you to avoid changes in your application if new operations have been introduced.
For a complete list of operation sets supported in OpenVINO™ toolkit, see Available Operations Sets.
To add support of custom operations, see the Add Custom OpenVINO Operations document.
Build a Model in OpenVINO™ Runtime
You can create a model from source. This section illustrates how to construct a model composed of operations from an available operation set.
Operation set opsetX integrates a list of pre-compiled operations that work for this purpose. In other words, opsetX defines a set of operations for building a graph.
To build an ov::Model instance from opset8 operations, include the following files:
@sphinxtabset
@sphinxtab{C++}
@snippet docs/snippets/ov_model_snippets.cpp ov:include
@endsphinxtab
@sphinxtab{Python}
@snippet docs/snippets/ov_model_snippets.py import
@endsphinxtab
@endsphinxtabset
The following code demonstrates how to create a simple model:
@sphinxtabset
@sphinxtab{C++}
@snippet docs/snippets/ov_model_snippets.cpp ov:create_simple_model
@endsphinxtab
@sphinxtab{Python}
@snippet docs/snippets/ov_model_snippets.py ov:create_simple_model
@endsphinxtab
@endsphinxtabset
The following code creates a model with several outputs:
@sphinxtabset
@sphinxtab{C++}
@snippet docs/snippets/ov_model_snippets.cpp ov:create_advanced_model
@endsphinxtab
@sphinxtab{Python}
@snippet docs/snippets/ov_model_snippets.py ov:create_advanced_model
@endsphinxtab
@endsphinxtabset
Model debug capabilities
OpenVINO™ provides several debug capabilities:
- To receive additional messages about applied model modifications, rebuild the OpenVINO™ Runtime library with the
-DENABLE_OPENVINO_DEBUG=ONoption. - Model can be visualized to image from the xDot format:
@sphinxtabset
@sphinxtab{C++}
@snippet docs/snippets/ov_model_snippets.cpp ov:visualize
@endsphinxtab
@sphinxtab{Python}
@snippet docs/snippets/ov_model_snippets.py ov:visualize
@endsphinxtab
@endsphinxtabset
`ov::pass::VisualizeTree` can be parametrized via environment variables:
OV_VISUALIZE_TREE_OUTPUT_SHAPES=1 - visualize shapes
OV_VISUALIZE_TREE_OUTPUT_TYPES=1 - visualize types
OV_VISUALIZE_TREE_MIN_MAX_DENORMAL=1 - pretty denormal values
OV_VISUALIZE_TREE_RUNTIME_INFO=1 - print runtime information
OV_VISUALIZE_TREE_IO=1 - print I/O ports
OV_VISUALIZE_TREE_MEMBERS_NAME=1 - print member names
-
Also model can be serialized to IR:
@sphinxtabset
@sphinxtab{C++}
@snippet docs/snippets/ov_model_snippets.cpp ov:serialize
@endsphinxtab
@sphinxtab{Python}
@snippet docs/snippets/ov_model_snippets.py ov:serialize
@endsphinxtab