Main Content

Networks and Layers Supported for Code Generation

MATLAB® Coder™ supports code generation for dlnetwork (Deep Learning Toolbox), series, and directed acyclic graph (DAG) networks. You can generate code for any trained neural network that uses supported deep learning networks, layers and classes.

Supported Pretrained Networks

These pretrained networks, available in Deep Learning Toolbox™, are supported for code generation. You can use imagePretrainedNetwork (Deep Learning Toolbox) function to load these pretrained neural networks as dlnetwork (Deep Learning Toolbox) objects for code generation. Note that code generation does not support setting the name-value argument Weights of imagePretrainedNetwork function to "none". For example, use this code to load a pretrained GoogLeNet neural network.

net = imagePretrainedNetwork("googlenet")

You can use analyzeNetworkForCodegen to see if a network is compatible for code generation for a specific deep learning library. For example:

result = analyzeNetworkForCodegen(imagePretrainedNetwork("googlenet"),TargetLibrary='none')

imagePretrainedNetwork Model Name ArgumentGeneric C/C++

Intel® MKL-DNN and

ARM® Compute Libraries

"alexnet"

"darknet19"

"darknet53"

"densenet201"

"efficientnetb0"

"googlenet"

"inceptionresnetv2"

"inceptionv3"

"mobilenetv2"

"nasnetlarge"

 

"nasnetmobile"

 

"resnet18"

"resnet50"

"resnet101"

"shufflenet"

 

Note

The ARM Compute library is not supported for shufflenet.

"squeezenet"

"vgg16"

"vgg19"

"xception"

Supported Layers

These layers are supported for code generation for the target deep learning libraries specified in the table.

Note

In the following tables, the information icon indicates that the network, layer, or class has limited code generation capabilities. You might see errors and unexpected behavior. For more information, see the Extended Capabilities section on the page for that network, layer, or class.

Input Layers

LayerGeneric C/C++

Intel MKL-DNN and

ARM Compute Libraries

imageInputLayer (Deep Learning Toolbox)

sequenceInputLayer (Deep Learning Toolbox)

featureInputLayer (Deep Learning Toolbox)

Convolution and Fully Connected Layers

LayerGeneric C/C++

Intel MKL-DNN and

ARM Compute Libraries

convolution1dLayer (Deep Learning Toolbox)

 

convolution2dLayer (Deep Learning Toolbox)

fullyConnectedLayer (Deep Learning Toolbox)

groupedConvolution2dLayer (Deep Learning Toolbox)

Note

You can generate generic C/C++ code for channel-wise convolution when the number of groups is equal to the number of filter channels.

transposedConv2dLayer (Deep Learning Toolbox)

 

Sequence Layers

LayerGeneric C/C++

Intel MKL-DNN and

ARM Compute Libraries

bilstmLayer (Deep Learning Toolbox)

flattenLayer (Deep Learning Toolbox)

gruProjectedLayer (Deep Learning Toolbox)

 

gruLayer (Deep Learning Toolbox)

lstmLayer (Deep Learning Toolbox)

lstmProjectedLayer (Deep Learning Toolbox)

 

sequenceInputLayer (Deep Learning Toolbox)

wordEmbeddingLayer (Text Analytics Toolbox)

Activation Layers

LayerGeneric C/C++

Intel MKL-DNN and

ARM Compute Libraries

clippedReluLayer (Deep Learning Toolbox)

eluLayer (Deep Learning Toolbox)

gelu (Deep Learning Toolbox)

geluLayer (Deep Learning Toolbox)

leakyReluLayer (Deep Learning Toolbox)

preluLayer (Deep Learning Toolbox)

reluLayer (Deep Learning Toolbox)

sigmoidLayer (Deep Learning Toolbox)

softmaxLayer (Deep Learning Toolbox)

softplusLayer (Reinforcement Learning Toolbox)

swishLayer (Deep Learning Toolbox)

tanhLayer (Deep Learning Toolbox)

Normalization Layers

LayerGeneric C/C++

Intel MKL-DNN and

ARM Compute Libraries

batchNormalizationLayer (Deep Learning Toolbox)

crossChannelNormalizationLayer (Deep Learning Toolbox)

 

instanceNormalizationLayer (Deep Learning Toolbox)

layerNormalizationLayer (Deep Learning Toolbox)

groupNormalizationLayer (Deep Learning Toolbox)

Utility Layers

LayerGeneric C/C++

Intel MKL-DNN and

ARM Compute Libraries

crop2dLayer (Deep Learning Toolbox)

 

dropoutLayer (Deep Learning Toolbox)

scalingLayer (Reinforcement Learning Toolbox)

spatialDropoutLayer (Deep Learning Toolbox)

Resizing Layers

LayerGeneric C/C++

Intel MKL-DNN and

ARM Compute Libraries

resize2dLayer (Image Processing Toolbox)

Pooling and Unpooling Layers

LayerGeneric C/C++

Intel MKL-DNN and

ARM Compute Libraries

adaptiveAveragePooling2dLayer (Deep Learning Toolbox)

averagePooling1dLayer (Deep Learning Toolbox)

 

averagePooling2dLayer (Deep Learning Toolbox)

globalAveragePooling1dLayer (Deep Learning Toolbox)

 

globalAveragePooling2dLayer (Deep Learning Toolbox)

globalMaxPooling1dLayer (Deep Learning Toolbox)

 

globalMaxPooling2dLayer (Deep Learning Toolbox)

maxPooling1dLayer (Deep Learning Toolbox)

 

maxPooling2dLayer (Deep Learning Toolbox)

maxUnpooling2dLayer (Deep Learning Toolbox)

 

Note

The ARM Compute library is not supported for maxUnpooling2dLayer.

Combination Layers

LayerGeneric C/C++

Intel MKL-DNN and

ARM Compute Libraries

additionLayer (Deep Learning Toolbox)

concatenationLayer (Deep Learning Toolbox)

depthConcatenationLayer (Deep Learning Toolbox)

multiplicationLayer (Deep Learning Toolbox)

Transformer Layers

LayerGeneric C/C++

Intel MKL-DNN and

ARM Compute Libraries

AttentionLayer (Deep Learning Toolbox)

 

embeddingConcatenationLayer (Deep Learning Toolbox)

 

indexing1dLayer (Deep Learning Toolbox)

 

patchEmbeddingLayer (Computer Vision Toolbox)

 

PositionEmbeddingLayer (Deep Learning Toolbox)

 

selfAttentionLayer (Deep Learning Toolbox)

 

Compute Vision and Image Processing Layers

LayerGeneric C/C++

Intel MKL-DNN and

ARM Compute Libraries

depthToSpace2dLayer (Image Processing Toolbox)

patchEmbeddingLayer (Computer Vision Toolbox)

 

spaceToDepthLayer (Image Processing Toolbox)

ssdMergeLayer (Computer Vision Toolbox)

resize2dLayer (Image Processing Toolbox)

yolov2TransformLayer (Computer Vision Toolbox)

Custom Layers

LayerGeneric C/C++

Intel MKL-DNN and

ARM Compute Libraries

Custom layers

 More information

 Code generation limitations

Custom Output Layer (Deep Learning Toolbox)

 More information

Custom Keras Layers

LayerGeneric C/C++

Intel MKL-DNN and

ARM Compute Libraries

nnet.keras.layer.ClipLayer (Deep Learning Toolbox)

nnet.keras.layer.FlattenCStyleLayer (Deep Learning Toolbox)

nnet.keras.layer.GlobalAveragePooling2dLayer (Deep Learning Toolbox)

nnet.keras.layer.PreluLayer (Deep Learning Toolbox)

nnet.keras.layer.SigmoidLayer (Deep Learning Toolbox)

nnet.keras.layer.TanhLayer (Deep Learning Toolbox)

nnet.keras.layer.TimeDistributedFlattenCStyleLayer (Deep Learning Toolbox)

nnet.keras.layer.ZeroPadding2dLayer (Deep Learning Toolbox)

Custom ONNX Layers

LayerGeneric C/C++

Intel MKL-DNN and

ARM Compute Libraries

nnet.onnx.layer.ClipLayer (Deep Learning Toolbox)

nnet.onnx.layer.ElementwiseAffineLayer (Deep Learning Toolbox)

nnet.onnx.layer.FlattenInto2dLayer (Deep Learning Toolbox)

nnet.onnx.layer.FlattenLayer (Deep Learning Toolbox)

nnet.onnx.layer.GlobalAveragePooling2dLayer (Deep Learning Toolbox)

nnet.onnx.layer.IdentityLayer (Deep Learning Toolbox)

nnet.onnx.layer.PreluLayer (Deep Learning Toolbox)

nnet.onnx.layer.SigmoidLayer (Deep Learning Toolbox)

nnet.onnx.layer.TanhLayer (Deep Learning Toolbox)

nnet.onnx.layer.VerifyBatchSizeLayer (Deep Learning Toolbox)

Supported Classes

Class

Generic C/C++

Intel MKL-DNN and

ARM Compute Libraries

dlnetwork (Deep Learning Toolbox)

DAGNetwork (Deep Learning Toolbox)

pointPillarsObjectDetector (Lidar Toolbox)

SeriesNetwork (Deep Learning Toolbox)

ssdObjectDetector (Computer Vision Toolbox)

yolov2ObjectDetector (Computer Vision Toolbox)

 

yolov3ObjectDetector (Computer Vision Toolbox)

yolov4ObjectDetector (Computer Vision Toolbox)

yoloxObjectDetector (Computer Vision Toolbox)

See Also

(Deep Learning Toolbox) |

Related Topics