Main Content

coder.MklDNNConfig

Parameters to configure deep learning code generation with the Intel Math Kernel Library for Deep Neural Networks

Description

The coder.MklDNNConfig object contains the Intel® MKL-DNN specific parameters that codegen uses for generating C++ code for deep neural networks.

To use a coder.MklDNNConfig object for code generation, assign it to the DeepLearningConfig property of a code generation configuration object that you pass to codegen.

Creation

Description

example

deepLearningCfg = coder.DeepLearningConfig('mkldnn') creates a coder.MklDNNConfig object for deep learning code generation by using the MKL-DNN library.

Properties

expand all

Name of target library, specified as a character vector.

Examples

collapse all

Create an entry-point function resnet_predict that uses the coder.loadDeepLearningNetwork function to load the resnet50 (Deep Learning Toolbox) SeriesNetwork object.

function out = resnet_predict(in)

persistent mynet;
if isempty(mynet)
    mynet = coder.loadDeepLearningNetwork('resnet50', 'myresnet');
end

out = predict(mynet,in);

Create a coder.config configuration object for MEX code generation.

cfg = coder.config('mex');

Set the target language to C++.

cfg.TargetLang = 'C++';

Create a coder.MklDNNConfig deep learning configuration object. Assign it to the DeepLearningConfig property of the cfg configuration object.

cfg.DeepLearningConfig = coder.DeepLearningConfig('mkldnn');

Use the -config option of the codegen function to pass 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(224,224,3,'single')} -config cfg resnet_predict

The codegen command places all the generated files in the codegen folder. The folder contains the C++ code for the entry-point function resnet_predict.cpp, header, and source files containing the C++ class definitions for the convolutional neural network (CNN), weight, and bias files.

Introduced in R2018b