How to Convert a Model with Custom Layers in the OpenVINO™ toolkit

Documentation

Product Information & Documentation

000057426

10/12/2021

You cannot directly convert models with unsupported layers to Intermediate Representation (IR). If you used the Query Network function to determine that your model has unsupported, or custom, layers, expand the appropriate topic below to find information on how to convert your model to an IR.

Caffe* Models with Custom Layers

There are two options for Caffe* models with custom layers:

  1. Register the custom layers as extensions to the Model Optimizer. For instructions, see Extending the Model Optimizer with New Primitives. This is the preferred method.
  2. Register the custom layers as Custom and use the system Caffe to calculate the output shape of each Custom Layer.
TensorFlow* Models with Custom Layers

There are three options for TensorFlow* models with custom layers:

  1. Register the custom layers as extensions to the Model Optimizer. For instructions, see Extending the Model Optimizer with New Primitives.
  2. If you have sub-graphs that should not be expressed with the analogous sub-graph in the Intermediate Representation, but another sub-graph should appear in the model, the Model Optimizer provides such an option. To read more, see Sub-graph Replacement in the Model Optimizer.
  3. Alternatively, you can offload the computation of the sub-graph back to Tensorflow during inference.
MXNet* Models with Custom Layers

There are two options for MXNet* models with custom layers:

  1. Register the custom layers as extensions to the Model Optimizer. For instructions, see Extending MXNet Model Optimizer with New Primitives. When your custom layers are registered as extensions, the Model Optimizer generates a valid and optimized Intermediate Representation. You can create Model Optimizer extensions for both MXNet layers with op Custom and layers that are not standard MXNet layers.
  2. If you have sub-graphs that should not be expressed with the analogous sub-graph in the Intermediate Representation, but another sub-graph should appear in the model, the Model Optimizer provides such an option. In MXNet, the function that is actively used for SSD models provides you with an opportunity when it is necessary to replace sub-graph sequences. To read more, see Sub-graph Replacement in the Model Optimizer.
Related topics
Supported Layers
Custom Layers