NOTE: It is a preview version of the Inference Engine Neural Network Builder API for evaluation purpose only. Module structure and API itself may be changed in future releases.
This API extends the Inference Engine functionality that allows to create and modify topologies in the source code.
InferenceEngine::Builder::Network allows to create and modify graphs. This class does not modify the original graph if it is used for graph modification. Instead, it creates a copy of the original graph and works with a copied object. Also the use of this class allows to avoid invalid graphs because it checks:
If a graph contains custom layers and shape inference is required, you should add Functions for shape inference to the Network builder from custom Context.
Network builder contains the following methods for graph modification:
addLayer(...) allows to add new layer builders to the network builder. This method creates a copy of the original layer builder, puts the copy to the network builder, and returns the ID of the layer builder which was added to the network builder.removeLayer(...) allows to remove layer builder from the network builder by ID.connect(...) allows to connect two layer builders using layer builder IDs and port indexes.disconnect(...) allows to remove connection from the network builder.getLayer(...) allows to get the layer builder from the network builder by ID.getLayerConnections(...) allows to get all connections for a layer builder by ID.getLayers() allows to get all layer builders.build() allows to generate Inference Engine Network. This method validates each layer builder and graph structure and creates INetwork.The function convertToICNNNetwork(...) converts INetwork to CNNNetwork.
InferenceEngine::Builder::Layer class creates and modifies layers. This class allows you to modify all layer parameters, add new constant data, change type and name of the layer, and create a valid layer object.
Each default Inference Engine layer has a special builder added in order to simplify the process of layer creation. These builders hide all unnecessary methods for the specific layer and add new methods.
Below you can see the list of builders for default layers:
InferenceEngine::Builder::ArgMaxInferenceEngine::Builder::BatchNormalizationInferenceEngine::Builder::ClampInferenceEngine::Builder::ConcatInferenceEngine::Builder::ConstInferenceEngine::Builder::ConvolutionInferenceEngine::Builder::CropInferenceEngine::Builder::CTCGreedyDecoderInferenceEngine::Builder::DeconvolutionInferenceEngine::Builder::DetectionOutputInferenceEngine::Builder::EltwiseInferenceEngine::Builder::ELUInferenceEngine::Builder::FullyConnectedInferenceEngine::Builder::GRNInferenceEngine::Builder::GRNSequenceInferenceEngine::Builder::InputInferenceEngine::Builder::LRNInferenceEngine::Builder::LSTMSequenceInferenceEngine::Builder::MemoryInferenceEngine::Builder::MVNInferenceEngine::Builder::NormInferenceEngine::Builder::NormalizeInferenceEngine::Builder::OutputInferenceEngine::Builder::PermuteInferenceEngine::Builder::PoolingInferenceEngine::Builder::PowerInferenceEngine::Builder::PReLUInferenceEngine::Builder::PriorBoxClusteredInferenceEngine::Builder::PriorBoxInferenceEngine::Builder::ProposalInferenceEngine::Builder::PSROIPoolingInferenceEngine::Builder::RegionYoloInferenceEngine::Builder::ReLU6InferenceEngine::Builder::ReLUInferenceEngine::Builder::ReorgYoloInferenceEngine::Builder::ResampleInferenceEngine::Builder::ReshapeInferenceEngine::Builder::RNNSequenceInferenceEngine::Builder::ROIPoolingInferenceEngine::Builder::ScaleShiftInferenceEngine::Builder::SigmoidInferenceEngine::Builder::SimplerNMSInferenceEngine::Builder::SoftMaxInferenceEngine::Builder::SplitInferenceEngine::Builder::TanHInferenceEngine::Builder::TileThe Inference Engine Neural Network Builder API does not support the TensorIterator layer.
To use the NN Builder API, include ie_builders.hpp header which includes all Inference Engine builders.
After that, all builders will be available to use.
The NN Builder can be created in different ways:
You can modify a graph with the NN Builder: