* Added info on DockerHub CI Framework * Feature/azaytsev/change layout (#3295) * Changes according to feedback comments * Replaced @ref's with html links * Fixed links, added a title page for installing from repos and images, fixed formatting issues * Added links * minor fix * Added DL Streamer to the list of components installed by default * Link fixes * Link fixes * ovms doc fix (#2988) * added OpenVINO Model Server * ovms doc fixes Co-authored-by: Trawinski, Dariusz <dariusz.trawinski@intel.com> * Updated openvino_docs.xml * Updated the link to software license agreements * Revert "Updated the link to software license agreements" This reverts commit706dac500e. * Updated legal info (#6409) # Conflicts: # thirdparty/ade * Cherry-pick4833c8db72[DOCS]Changed DL WB related docs and tips (#6318) * changed DL WB related docs and tips * added two tips to benchmark and changed layout * changed layout * changed links * page title added * changed tips * ie layout fixed * updated diagram and hints * changed tooltip and ref link * changet tooltip link * changed DL WB description * typo fix # Conflicts: # docs/doxygen/ie_docs.xml # thirdparty/ade * Cherry-pick 6405 Feature/azaytsev/mo devguide changes (#6405) * MO devguide edits * MO devguide edits * MO devguide edits * MO devguide edits * MO devguide edits * Experimenting with videos * Experimenting with videos * Experimenting with videos * Experimenting with videos * Experimenting with videos * Experimenting with videos * Experimenting with videos * Experimenting with videos * Experimenting with videos * Additional edits * Additional edits * Updated the workflow diagram * Minor fix * Experimenting with videos * Updated the workflow diagram * Removed Prepare_Trained_Model, changed the title for Config_Model_Optimizer * Rolled back * Revert "Rolled back" This reverts commit6a4a3e1765. * Revert "Removed Prepare_Trained_Model, changed the title for Config_Model_Optimizer" This reverts commit0810bd534f. * Fixed ie_docs.xml, Removed Prepare_Trained_Model, changed the title for Config_Model_Optimizer * Fixed ie_docs.xml * Minor fix * <details> tag issue * <details> tag issue * Fix <details> tag issue * Fix <details> tag issue * Fix <details> tag issue # Conflicts: # thirdparty/ade * Cherry-pick #6419 * [Runtime] INT8 inference documentation update * [Runtime] INT8 inference documentation: typo was fixed * Update docs/IE_DG/Int8Inference.md Co-authored-by: Anastasiya Ageeva <anastasiya.ageeva@intel.com> * Update docs/IE_DG/Int8Inference.md Co-authored-by: Anastasiya Ageeva <anastasiya.ageeva@intel.com> * Update docs/IE_DG/Int8Inference.md Co-authored-by: Anastasiya Ageeva <anastasiya.ageeva@intel.com> * Update docs/IE_DG/Int8Inference.md Co-authored-by: Anastasiya Ageeva <anastasiya.ageeva@intel.com> * Update docs/IE_DG/Int8Inference.md Co-authored-by: Anastasiya Ageeva <anastasiya.ageeva@intel.com> * Table of Contents was removed Co-authored-by: Anastasiya Ageeva <anastasiya.ageeva@intel.com> # Conflicts: # docs/IE_DG/Int8Inference.md # thirdparty/ade * Cherry pick (#6437) * Q2 changes * Changed Convert_RNNT.md Co-authored-by: baychub <cbay@yahoo.com> # Conflicts: # docs/IE_DG/Int8Inference.md # docs/install_guides/installing-openvino-conda.md # docs/install_guides/pypi-openvino-dev.md # thirdparty/ade * Cherry-pick (#6447) * Added benchmark page changes * Make the picture smaller * Added Intel® Iris® Xe MAX Graphics * Changed the TIP about DL WB * Added Note on the driver for Intel® Iris® Xe MAX Graphics * Fixed formatting * Added the link to Intel® software for general purpose GPU capabilities * OVSA ovsa_get_started updates * Fixed link # Conflicts: # thirdparty/ade * Cherry-pick #6450 * fix layout * 4 # Conflicts: # thirdparty/ade * Cherry-pick #6466 * Cherry-pick #6548 * install docs fixes * changed video width * CMake reference added * fixed table * added backtics and table formating * new table changes * GPU table changes * added more backtics and changed table format * gpu table changes * Update get_started_dl_workbench.md Co-authored-by: Andrey Zaytsev <andrey.zaytsev@intel.com> # Conflicts: # thirdparty/ade * [Runtime] INT8 inference documentation update (#6419) * [Runtime] INT8 inference documentation update * [Runtime] INT8 inference documentation: typo was fixed * Update docs/IE_DG/Int8Inference.md Co-authored-by: Anastasiya Ageeva <anastasiya.ageeva@intel.com> * Update docs/IE_DG/Int8Inference.md Co-authored-by: Anastasiya Ageeva <anastasiya.ageeva@intel.com> * Update docs/IE_DG/Int8Inference.md Co-authored-by: Anastasiya Ageeva <anastasiya.ageeva@intel.com> * Update docs/IE_DG/Int8Inference.md Co-authored-by: Anastasiya Ageeva <anastasiya.ageeva@intel.com> * Update docs/IE_DG/Int8Inference.md Co-authored-by: Anastasiya Ageeva <anastasiya.ageeva@intel.com> * Table of Contents was removed Co-authored-by: Anastasiya Ageeva <anastasiya.ageeva@intel.com> # Conflicts: # docs/IE_DG/Int8Inference.md # thirdparty/ade * Cherry-pick #6651 * Edits to MO Per findings spreadsheet * macOS changes per issue spreadsheet * Fixes from review spreadsheet Mostly IE_DG fixes * Consistency changes * Make doc fixes from last round of review * Add GSG build-all details * Fix links to samples and demos pages * Make MO_DG v2 changes * Add image view step to classify demo * Put MO dependency with others * Edit docs per issues spreadsheet * Add file to pytorch_specific * More fixes per spreadsheet * Prototype sample page * Add build section * Update README.md * Batch download/convert by default * Add detail to How It Works * Minor change * Temporary restored topics * corrected layout * Resized * Added white background into the picture * fixed link to omz_tools_downloader * fixed title in the layout Co-authored-by: baychub <cbay@yahoo.com> Co-authored-by: baychub <31420038+baychub@users.noreply.github.com> # Conflicts: # docs/doxygen/ie_docs.xml * Cherry-pick (#6789) [59449][DOCS] GPU table layout change * changed argument display * added br tag to more arguments * changed argument display in GPU table * changed more arguments * changed Quantized_ models display # Conflicts: # thirdparty/ade * Sync doxygen-ignore * Removed ref to FPGA.md * Fixed link to ONNX format doc Co-authored-by: Trawinski, Dariusz <dariusz.trawinski@intel.com> Co-authored-by: Tatiana Savina <tatiana.savina@intel.com> Co-authored-by: Edward Shogulin <edward.shogulin@intel.com> Co-authored-by: Nikolay Tyukaev <nikolay.tyukaev@intel.com>
7.7 KiB
Using Shape Inference
OpenVINO™ provides the following methods for runtime model reshaping:
- Set a new input shape with the
InferenceEngine::CNNNetwork::reshapemethod.
TheInferenceEngine::CNNNetwork::reshapemethod updates input shapes and propagates them down to the outputs of the model through all intermediate layers.
NOTES:
- Starting with the 2021.1 release, the Model Optimizer converts topologies keeping shape-calculating sub-graphs by default, which enables correct shape propagation during reshaping in most cases.
- Older versions of IRs are not guaranteed to reshape successfully. Please regenerate them with the Model Optimizer of the latest version of OpenVINO™.
- If an ONNX model does not have a fully defined input shape and the model was imported with the ONNX importer, reshape the model before loading it to the plugin.
-
Set a new batch dimension value with the
InferenceEngine::CNNNetwork::setBatchSizemethod.
The meaning of a model batch may vary depending on the model design. This method does not deduce batch placement for inputs from the model architecture. It assumes that the batch is placed at the zero index in the shape for all inputs and uses theInferenceEngine::CNNNetwork::reshapemethod to propagate updated shapes through the model.The method transforms the model before a new shape propagation to relax a hard-coded batch dimension in the model, if any.
Use
InferenceEngine::CNNNetwork::reshapeinstead ofInferenceEngine::CNNNetwork::setBatchSizeto set new input shapes for the model in case the model has:- Multiple inputs with different zero-index dimension meanings
- Input without a batch dimension
- 0D, 1D, or 3D shape
The
InferenceEngine::CNNNetwork::setBatchSizemethod is a high-level API method that wraps theInferenceEngine::CNNNetwork::reshapemethod call and works for trivial models from the batch placement standpoint. UseInferenceEngine::CNNNetwork::reshapefor other models.Using the
InferenceEngine::CNNNetwork::setBatchSizemethod for models with a non-zero index batch placement or for models with inputs that do not have a batch dimension may lead to undefined behaviour.
You can change input shapes multiple times using the InferenceEngine::CNNNetwork::reshape and InferenceEngine::CNNNetwork::setBatchSize methods in any order.
If a model has a hard-coded batch dimension, use InferenceEngine::CNNNetwork::setBatchSize first to change the batch, then call InferenceEngine::CNNNetwork::reshape to update other dimensions, if needed.
Inference Engine takes three kinds of a model description as an input, which are converted into an InferenceEngine::CNNNetwork object:
- Intermediate Representation (IR) through
InferenceEngine::Core::ReadNetwork - ONNX model through
InferenceEngine::Core::ReadNetwork - nGraph function through the constructor of
InferenceEngine::CNNNetwork
InferenceEngine::CNNNetwork keeps an ngraph::Function object with the model description internally.
The object should have fully defined input shapes to be successfully loaded to the Inference Engine plugins.
To resolve undefined input dimensions of a model, call the CNNNetwork::reshape method providing new input shapes before loading to the Inference Engine plugin.
Run the following code right after InferenceEngine::CNNNetwork creation to explicitly check for model input names and shapes:
CNNNetwork network = ... // read IR / ONNX model or create from nGraph::Function explicitly
const auto parameters = network.getFunction()->get_parameters();
for (const auto & parameter : parameters) {
std::cout << "name: " << parameter->get_friendly_name() << " shape: " << parameter->get_partial_shape() << std::endl;
if (parameter->get_partial_shape().is_dynamic())
std::cout << "ATTENTION: Input shape is not fully defined. Use the CNNNetwork::reshape method to resolve it." << std::endl;
}
To feed input data of a shape that is different from the model input shape, reshape the model first.
Once the input shape of InferenceEngine::CNNNetwork is set, call the InferenceEngine::Core::LoadNetwork method to get an InferenceEngine::ExecutableNetwork object for inference with updated shapes.
There are other approaches to reshape the model during the stage of IR generation or nGraph::Function creation.
Practically, some models are not ready to be reshaped. In this case, a new input shape cannot be set with the Model Optimizer or the InferenceEngine::CNNNetwork::reshape method.
Troubleshooting Reshape Errors
Operation semantics may impose restrictions on input shapes of the operation. Shape collision during shape propagation may be a sign that a new shape does not satisfy the restrictions. Changing the model input shape may result in intermediate operations shape collision.
Examples of such operations:
- Reshape operation with a hard-coded output shape value
- MatMul operation with the
Constsecond input cannot be resized by spatial dimensions due to operation semantics
Model structure and logic should not change significantly after model reshaping.
-
The Global Pooling operation is commonly used to reduce output feature map of classification models output. Having the input of the shape [N, C, H, W], Global Pooling returns the output of the shape [N, C, 1, 1]. Model architects usually express Global Pooling with the help of the
Poolingoperation with the fixed kernel size [H, W]. During spatial reshape, having the input of the shape [N, C, H1, W1], Pooling with the fixed kernel size [H, W] returns the output of the shape [N, C, H2, W2], where H2 and W2 are commonly not equal to1. It breaks the classification model structure. For example, publicly available Inception family models from TensorFlow* have this issue. -
Changing the model input shape may significantly affect its accuracy. For example, Object Detection models from TensorFlow have resizing restrictions by design. To keep the model valid after the reshape, choose a new input shape that satisfies conditions listed in the
pipeline.configfile. For details, refer to the Tensorflow Object Detection API models resizing techniques.
Usage of Reshape Method
The primary method of the feature is InferenceEngine::CNNNetwork::reshape.
It gets new input shapes and propagates it from input to output for all intermediates layers of the given network.
The method takes InferenceEngine::ICNNNetwork::InputShapes - a map of pairs: name of input data and its dimension.
The algorithm for resizing network is the following:
-
Collect the map of input names and shapes from Intermediate Representation (IR) using helper method
InferenceEngine::CNNNetwork::getInputShapes -
Set new input shapes
-
Call reshape
Here is a code example:
@snippet snippets/ShapeInference.cpp part0
Shape Inference feature is used in [Smart Classroom Demo](@ref omz_demos_smart_classroom_demo_cpp).
Extensibility
Inference Engine provides a special mechanism that allows to add the support of shape inference for custom operations. This mechanism is described in the Extensibility documentation