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
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: [153×1 nnet.cnn.layer.Layer] Connections: [162×2 table] Learnables: [210×3 table] State: [104×3 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: [0×0 table] LayerDiagnostics: [150×3 table] IncompatibleLayerTypes: [6×1 string]
Display the layer types not supported for CMSIS-NN code generation.
S(7).IncompatibleLayerTypes
ans = 6×1 string
"AdditionLayer"
"BatchNormalizationLayer"
"ClippedReLULayer"
"Convolution2DLayer"
"GlobalAveragePooling2DLayer"
"GroupedConvolution2DLayer"
Input Arguments
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"]);
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. |
Scalar boolean
value to suppress report display. By default,
the function displays the analysis in verbose mode.
Output Arguments
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) |coder.loadDeepLearningNetwork
|codegen
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- 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)