analyzeNetworkForCodegen
Description
analyzes the deep learning network result
= analyzeNetworkForCodegen(net
) net
for code generation and reports
network and layer compatibility issues. Network must be a dlnetwork
,
SeriesNetwork
, or DAGNetwork
object. By default, the
function validates against a set of default CPU and GPU deep learning library
targets.
___ = analyzeNetworkForCodegen(___,
analyzes the deep learning network Name,Value
)net
for code generation by using the
options specified by one or more Name,Value
pair arguments.
Examples
Check Network for Code Generation Compatibility
This example uses:
- Deep Learning ToolboxDeep Learning Toolbox
- Deep Learning Toolbox Model for MobileNet-v2 NetworkDeep Learning Toolbox Model for MobileNet-v2 Network
- GPU Coder Interface for Deep LearningGPU Coder Interface for Deep Learning
- MATLAB Coder Interface for Deep LearningMATLAB Coder Interface for Deep Learning
This example shows how to check code generation compatibility of the MobileNet-v2 network by using the analyzeNetworkForCodegen
function.
You can use the analyzeNetworkForCodegen
function to determine network and layer compatibility issues when targeting a variety of CPU and GPU deep learning library targets.
Download MobileNet-v2 Support Package
This example uses the pretrained version of the MobileNet-v2 available through the Deep Learning Toolbox™ Model for MobileNet-v2 Network support package.
MobileNet-v2 is a convolutional neural network that is 53 layers deep. The pretrained version of the network is trained on more than a million images from the ImageNet database. The pretrained network has an image input size of 224-by-224 and can classify images into 1000 object categories, such as keyboard, mouse, pencil, and many animals.
mobilenetv2 = imagePretrainedNetwork('mobilenetv2')
mobilenetv2 = dlnetwork with properties: Layers: [153x1 nnet.cnn.layer.Layer] Connections: [162x2 table] Learnables: [210x3 table] State: [104x3 table] InputNames: {'input_1'} OutputNames: {'Logits_softmax'} Initialized: 1 View summary with summary.
If the Deep Learning Toolbox Model for MobileNet-v2 Network support package is not installed, then the function provides a link to the required support package in the Add-On Explorer. To install the support package, click the link, and then click Install.
Analyze Network for Code Generation
Run the analyzeNetworkForCodegen
function for mobilenetv2
, specifying the target libraries to analyze. The analyzeNetworkForCodegen
function requires the MATLAB® Coder™ Interface for Deep Learning and the GPU Coder™ Interface for Deep Learning support packages. To install the required support packages, use the Add-On Explorer.
targetLibraries = ["none","cudnn","tensorrt","mkldnn","arm-compute",... "arm-compute-mali","cmsis-nn"]; S = analyzeNetworkForCodegen(mobilenetv2,TargetLibrary = targetLibraries);
Supported LayerDiagnostics _________ _______________________________________________________________________________________________________________________________________________________________________________ none "Yes" "" cudnn "Yes" "" tensorrt "Yes" "" mkldnn "Yes" "" arm-compute "Yes" "" arm-compute-mali "Yes" "" cmsis-nn "No" "Found 6 unsupported layer types. View incompatible layer types."
To access the analysis results for the CMSIS-NN target, use the following command.
disp(S(7))
TargetLibrary: 'cmsis-nn' Supported: 0 NetworkDiagnostics: [0x0 table] LayerDiagnostics: [150x3 table] IncompatibleLayerTypes: [6x1 string]
Display the layer types not supported for CMSIS-NN code generation.
S(7).IncompatibleLayerTypes
ans = 6x1 string
"AdditionLayer"
"BatchNormalizationLayer"
"ClippedReLULayer"
"Convolution2DLayer"
"GlobalAveragePooling2DLayer"
"GroupedConvolution2DLayer"
Input Arguments
net
— Deep learning network to analyze
SeriesNetwork
object | DAGNetwork
object | dlnetwork
object
Network to analyze for code generation. Network can be a
dlnetwork
, SeriesNetwork
, or
DAGNetwork
object for custom training loops or custom pruning
loops.
Name-Value Arguments
Specify optional pairs of arguments as
Name1=Value1,...,NameN=ValueN
, where Name
is
the argument name and Value
is the corresponding value.
Name-value arguments must appear after other arguments, but the order of the
pairs does not matter.
Example: resultStruct =
analyzeNetworkForCodegen(imagePretrainedNetwork("mobilenetv2"), TargetLibrary = ["none",
"mkldnn"]);
TargetLibrary
— Code generation target library
character vector | string scalar
Target library for deep learning code generation, specified as one of the values in this table.
Value | Description |
---|---|
"none" | For generating code that does not use any third-party library. |
"arm-compute" | For generating code that uses the ARM® Compute Library. |
"mkldnn" | For generating code that uses the Intel® Math Kernel Library for Deep Neural Networks (Intel MKL-DNN). |
"cmsis-nn" | Common Microcontroller Software Interface Standard - Neural Network (CMSIS-NN) library. Requires the MATLAB® Coder™ Interface for Deep Learning. |
"cudnn" | For generating code that uses the CUDA® Deep Neural Network library (cuDNN). This option requires GPU Coder™. |
"tensorrt" | For generating code that takes advantage of the NVIDIA® TensorRT – high performance deep learning inference optimizer and run-time library. This option requires GPU Coder. |
Quiet
— Suppress report display
false
(default) | true
Scalar boolean
value to suppress report display. By default,
the function displays the analysis in verbose mode.
Output Arguments
result
— Analysis output
structure array
Results of checking the deep learning network for code generation compatibility,
returned as a 1
-by-N
structure, where
N
is the number of target libraries to check for.
Version History
Introduced in R2022b
See Also
Functions
imagePretrainedNetwork
(Deep Learning Toolbox) |codegen
|coder.loadDeepLearningNetwork
Comando de MATLAB
Ha hecho clic en un enlace que corresponde a este comando de MATLAB:
Ejecute el comando introduciéndolo en la ventana de comandos de MATLAB. Los navegadores web no admiten comandos de MATLAB.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)