Supported Layers
Deep Learning HDL Toolbox™ supports the layers listed in these tables.
Input Layers
Layer | Layer Type Hardware (HW) or Software(SW) | Description and Limitations | INT8 Compatible |
SW | An image input layer inputs 2-D images to a network and applies data
normalization. The normalization options | Yes. Runs as single datatype in SW. | |
SW | A feature input layer inputs feature data to a network and applies data normalization. | Yes | |
SW | A sequence input layer inputs sequence data to a network. | Yes | |
wordEmbeddingLayer (Text Analytics Toolbox) | SW | A word embedding layer maps word indices to vectors. | No |
Convolution and Fully Connected Layers
Layer | Layer Type Hardware (HW) or Software(SW) | Layer Output Format | Description and Limitations | INT8 Compatible |
HW | Convolution (Conv) | A 2-D convolutional layer applies sliding convolutional filters to the input. When generating code for a network using this layer, these limitations apply:
| Yes | |
HW | Convolution (Conv) | A 2-D grouped convolutional layer separates the input channels into groups and applies sliding convolutional filters. Use grouped convolutional layers for channel-wise separable (also known as depth-wise separable) convolution. Code generation is now supported for a 2-D grouped convolution layer
that has the When generating code for a network using this layer, these limitations apply:
| Yes | |
HW | Inherit from input | A 1-D convolutional layer applies sliding convolutional filters to 1-D input. The layer convolves the input by moving the filters along the input and computing the dot product of the weights and the input, then adding a bias term. When generating code for a network using this layer, these limitations apply:
| Yes | |
HW | Convolution (Conv) | A transposed 2-D convolution layer upsamples feature maps. When generating code for a network using this layer, these limitations apply:
| Yes | |
HW | Fully Connected (FC) | A fully connected layer multiplies the input by a weight matrix, and then adds a bias vector. When generating code for a network using this layer, these limitations apply:
| Yes |
Activation Layers
Layer | Layer Type Hardware (HW) or Software(SW) | Layer Output Format | Description and Limitations | INT8 Compatible |
HW | Layer is fused. | A ReLU layer performs a threshold operation to each element of the input where any value less than zero is set to zero. A ReLU layer is supported only when it is preceded by any of these layers:
| Yes | |
HW | Layer is fused. | A leaky ReLU layer performs a threshold operation where any input value less than zero is multiplied by a fixed scalar. A leaky ReLU layer is supported only when it is preceded by any of these layers:
| Yes | |
HW | Layer is fused. | A clipped ReLU layer performs a threshold operation where any input value less than zero is set to zero and any value above the clipping ceiling is set to that clipping ceiling value. A clipped ReLU layer is supported only when it is preceded by any of these layers:
| Yes | |
HW | Inherit from input | A hyperbolic tangent (tanh) activation layer applies the tanh function on the layer inputs. | Yes. Runs as single datatype in HW. | |
swishLayer | HW | Inherit from input | A swish layer applies the swish activation function on layer inputs. | No |
dlhdl.layer.mishLayer | HW | Inherit from input | A mish layer applies the mish activation function on layer inputs. | No |
geluLayer | HW | Inherit from input | A Gaussian error linear unit (GELU) layer weighs the inputs by its probability under a Gaussian distribution. A GELU layer is supported only when it is preceded by any of these layers:
When generating code for a network using this layer, these limitations apply:
| No |
Normalization, Dropout, and Cropping Layers
Layer | Layer Type Hardware (HW) or Software(SW) | Layer Output Format | Description and Limitations | INT8 Compatible |
HW | Layer is fused. | A batch normalization layer normalizes each input channel across a mini-batch. A batch normalization layer is supported when preceded by an image input layer, convolution layer, or as a standalone layer. | Yes | |
HW | Convolution (Conv) | A channel-wise local response (cross-channel) normalization layer carries out channel-wise normalization. The
| Yes. Runs as single datatype in HW. | |
NoOP on inference | NoOP on inference | A dropout layer randomly sets input elements to zero within a given probability. | Yes | |
| HW | Inherit from input | A 2-D resize layer resizes 2-D input by a scale factor, to a specified height and width, or to the size of a reference input feature map. When generating code for a network using this layer, these limitations apply:
The | Yes |
crop2dLayer | HW | Inherit from input | A 2-D crop layer applies 2-D cropping to the input. When generating code for a network using this layer, these limitations apply:
| Yes |
dlhdl.layer.reshapeLayer | HW | Inherit from input | A reshape layer changes the shape of the layer activation data. | Yes |
dlhdl.layer.sliceLayer | HW | Inherit from input | A slice layer divides the input to the layer into an equal number of groups along the channel dimension of the image. When generating code for a network using this layer, these limitations apply:
| Yes |
upsample2DLayer | HW | Inherit from input | During compiler optimization Deep Learning HDL Toolbox replaces this layer with a resize2-D layer. | Yes |
layerNormalizationLayer | HW | Inherit from input | A layer normalization layer normalizes a mini-batch of data across all channels for each observation independently. During compiler optimization Deep Learning HDL Toolbox replaces this layer with a fully connected layer, and maps the scale to fully connected layer weights and offset to the fully connected layer bias. When generating code for a network using this layer, these limitations apply:
| No |
Pooling and Unpooling Layers
Layer | Layer Type Hardware (HW) or Software(SW) | Layer Output Format | Description and Limitations | INT8 Compatible |
HW | Convolution (Conv) | A max pooling layer performs downsampling by dividing the layer input into rectangular pooling regions and computing the maximum of each region. When generating code for a network using this layer, these limitations apply:
| Yes No, when | |
HW | Convolution (Conv) | A max unpooling layer unpools the output of a max pooling layer. | No | |
HW | Convolution (Conv) | An average pooling layer performs downsampling by dividing the layer input into rectangular pooling regions and computing the average values of each region. When generating code for a network using this layer, these limitations apply:
| Yes | |
HW | Convolution (Conv) | A global average pooling layer performs downsampling by computing the mean of the height and width dimensions of the input. When generating code for a network using this layer, these limitations apply:
| Yes |
Combination Layers
Layer | Layer Type Hardware (HW) or Software(SW) | Layer Output Format | Description and Limitations | INT8 Compatible |
HW | Inherit from input. | An addition layer adds inputs from multiple neural network layers element-wise. You can now generated code for this layer with
When generating code for a network using this layer, these limitations apply:
| Yes | |
HW | Inherit from input. | A depth concatenation layer takes inputs that have the same height and width and concatenates them along the third dimension (the channel dimension). When generating code for a network using this layer, these limitations apply:
| Yes | |
HW | Inherit from input | A multiplication layer multiplies inputs from multiple neural network layers element-wise. | Yes | |
HW | Inherit from input | A split layer divides a layer output into equal parts along the channel dimension of the image. | Yes |
Sequence Layers
Layer | Layer Type Hardware (HW) or Software(SW) | Description and Limitations | INT8 Compatible |
---|---|---|---|
HW | An LSTM layer learns long-term dependencies between time steps in time series and sequence data. The layer performs additive interactions, which can help improve gradient flow over long sequences during training. When generating code for a network using this layer, these limitations apply:
| No | |
HW | A GRU layer is an RNN layer that learns dependencies between time steps in time series and sequence data. When generating code for a network using this layer, these limitations apply:
| No | |
lstmProjectedLayer | HW | A projected LSTM layer is a type of deep learning layer that enables compression by reducing the number of stored learnable parameters. When generating code for a network using this layer, these limitations apply:
| No |
gruProjectedLayer | HW | A projected GRU layer is a type of deep learning layer that enables compression by reducing the number of stored learnable parameters. When generating code for a network using this layer, these limitations apply:
| No |
Output Layer
Layer | Layer Type Hardware (HW) or Software(SW) | Description and Limitations | INT8 Compatible |
SW and HW | A softmax layer applies a softmax function to the input. If the softmax layer is implemented in hardware:
| Yes. Runs as single datatype in SW. | |
SW | A classification layer computes the cross-entropy loss for multiclass classification issues that have mutually exclusive classes. | Yes | |
SW | A regression layer computes the half mean squared error loss for regression problems. | Yes | |
HW | A sigmoid layer applies a sigmoid function to the input. The sigmoid layer is implemented in the custom module of the deep learning processor configuration and runs as single datatype in HW. | Yes. Runs as single datatype in HW. |
Keras and ONNX Layers
Layer | Layer Type Hardware (HW) or Software(SW) | Layer Output Format | Description and Limitations | INT8 Compatible |
nnet.keras.layer.FlattenCStyleLayer | HW | Layer will be fused | Flatten activations into 1-D layers assuming C-style (row-major) order. A | Yes |
nnet.keras.layer.ZeroPadding2dLayer | HW | Layer will be fused. | Zero padding layer for 2-D input. A
| Yes |
nnet.onnx.layer.FlattenInto2dLayer | HW | Layer will be fused | Flattens a MATLAB® 2D image batch in the way ONNX does, producing a 2D output array
with A
| Yes |
nnet.onnx.layer.FlattenLayer | HW | Layer will be fused | Flatten layer for ONNX™ network. A
If the layer
following the
| Yes |
flattenLayer | HW/SW | Layer will be fused | A flatten layer collapses the spatial dimensions of the input into the channel dimension. A flatten layer should be followed by a fully connected layer. Starting in R2024b, you can use a flatten layer as the last layer in a network when you implement it as a SW layer. | Yes |
Custom Layers
Layer | Layer Type Hardware (HW) or Software(SW) | Layer Output Format | Description and Limitations | INT8 Compatible |
---|---|---|---|---|
Custom Layers | HW | Inherit from input | Custom layers, with or without learnable parameters, that you define for your problem. To learn how to define your custom deep learning layers, see Create Deep Learning Processor Configuration for Custom Layers. | No |
Image Input Layer Normalization Hardware Implementation
To enable hardware implementation of the normalization functions for the image input
layer, set the HardwareNormalization
argument of the
compile
method to auto
or on
. When
HardwareNormalization
is set to auto
, the compile
method looks for the presence of addition and multiplication layers to implement the
normalization function on hardware. The normalization is implemented on hardware by:
Creating a new constant layer, This layer holds the value which is to be subtracted.
Using existing addition and multiplication layers. The layers to be used depends on the normalization function being implemented.
Constant Layer Buffer Content
This table describes the value stored in the constant layer buffer.
Normalization Function | Number of Constants | Constant Layer Buffer Value |
---|---|---|
zerocenter | 1 | - Mean |
zscore | 2 | The first constant value is -Mean . The second constant
value is 1/StandardDeviation |