coder.ARMNEONConfig - Parameters to configure deep learning code generation with the ARM Compute Library - MATLAB (original) (raw)
Main Content
Parameters to configure deep learning code generation with the ARM Compute Library
Description
The coder.ARMNEONConfig
object contains ARM® Compute Library and target specific parameters that codegen uses for generating C++ code for deep neural networks.
To use a coder.ARMNEONConfig
object for code generation, assign it to the DeepLearningConfig
property of a code generation configuration object that you pass to codegen
.
Creation
Create an ARM NEON configuration object by using the coder.DeepLearningConfig function with target library set as'arm-compute'
.
Properties
ArmComputeVersion
— Version of ARM Compute Library
'20.02.1' (default) | '19.05'
Version of ARM Compute Library used on the target hardware, specified as a character vector or string scalar.
ArmArchitecture
— ARM architecture supported in the target hardware
'armv8' | 'armv7'
ARM architecture supported in the target hardware, specified as a character vector or string scalar. The specified architecture must be the same as the architecture for the ARM Compute Library on the target hardware.
ARMArchitecture
must be specified for these cases:
- You do not use a hardware support package (the
Hardware
property of the code generation configuration object is empty). - You use a hardware support package, but generate code only.
DataType
— Inference computation precision
'fp32'
(default) | 'int8'
Specify the precision of the inference computations in supported layers. When performing inference in 32-bit floats, use 'fp32'
. For 8-bit integer, use 'int8'
. Default value is 'fp32'
.
CalibrationResultFile
— Location of calibration MAT-file
''
(default) | character vector | string scalar
Location of the MAT-file containing the calibration data. Default value is''
. This option is applicable only whenDataType
is set to 'int8'
.
When performing quantization, the calibrate (Deep Learning Toolbox) function exercises the network and collects the dynamic ranges of the weights and biases in the convolution and fully connected layers of the network and the dynamic ranges of the activations in all layers of the network. To generate code for the optimized network, save the results from the calibrate
function to a MAT-file and specify the location of this MAT-file to the code generator using this property. For more information, see Generate int8 Code for Deep Learning Networks.
TargetLibrary
— Target library name
'arm-compute'
Name of target library, specified as a character vector.
Examples
Generate Code for the ResNet-50 Network Using ARM Compute Library
Create an entry-point function resnet_predict
that uses thecoder.loadDeepLearningNetwork
function to load thedlnetwork
object that contains the SqueezeNet
network. For more information, see Code Generation for dlarray.
function out = resnet_predict(in)
dlIn = dlarray(in, 'SSCB'); persistent dlnet; if isempty(dlnet) dlnet = imagePretrainedNetwork('resnet50'); end
dlOut = predict(dlnet, dlIn); out = extractdata(dlOut);
Create a coder.config
configuration object for generation of a static library.
cfg = coder.config('lib');
Set the target language to C++. Specify that you want to generate only source code.
cfg.TargetLang = 'C++'; cfg.GenCodeOnly=true;
Create a coder.ARMNEONConfig
deep learning configuration object. Assign it to the DeepLearningConfig
property of thecfg
configuration object.
dlcfg = coder.DeepLearningConfig('arm-compute'); dlcfg.ArmArchitecture = 'armv8'; dlcfg.ArmComputeVersion = '20.02.1'; cfg.DeepLearningConfig = dlcfg;
Use the -config
option of the codegen function to specify the cfg
configuration object. The codegen function must determine the size, class, and complexity of MATLAB® function inputs. Use the -args
option to specify the size of the input to the entry-point function.
codegen -args {ones(227,227,3,'single')} -config cfg squeezenet_predict
The codegen
command places all the generated files in thecodegen
folder. The folder contains the C++ code for the entry-point function squeezenet_predict.cpp
, header, and source files containing the C++ class definitions for the neural network, weight, and bias files.
Version History
Introduced in R2019a