File Exchange

image thumbnail

MATLAB Coder Interface for Deep Learning Libraries

Interface for Deep Learning Libraries from MATLAB Coder

54 Downloads

Updated 14 Oct 2020

MATLAB Coder™ generates C and C++ code from MATLAB® code for a variety of hardware platforms, from desktop systems to embedded hardware. It supports most of the MATLAB language and a wide range of toolboxes. You can integrate the generated code into your projects as source code, static libraries, or dynamic libraries. The generated code is readable and portable.

You can deploy a variety of trained deep learning networks such as YOLOv2, ResNet-50, SqueezeNet, and MobileNet from Deep Learning Toolbox™. You can generate optimized code for preprocessing and postprocessing along with your trained deep learning networks to deploy complete algorithms.

Supported networks: https://www.mathworks.com/help/coder/ug/networks-and-layers-supported-for-c-code-generation.html

MATLAB Coder Interface for Deep Learning Libraries provides the ability for the generated code to call target-specific optimized libraries. The support package integrates with the following deep learning accelerator libraries for the corresponding CPU architectures:

• Intel Math Kernel Library for Deep Neural Networks (MKL-DNN) for Intel CPUs that support AVX2
• ARM Compute library for ARM Cortex-A processors that support NEON instructions

This support package is functional for R2018b and beyond.

If you have download or installation problems, please contact Technical Support - https://www.mathworks.com/support/contact_us.html

[Updates in R2019b]
1) Add VC++ 2019 compiler support for cnncodegen for MKL-DNN target
2) Add support for ONNX identity layer for all targets (ARM Neon, MKL-DNN)
3) Add support for Crop2dLayer for ARM Neon. This enables support for Fully Convolution Networks for Semantic Segmentation

Comments and Ratings (10)

Praveen Kumar Gajula

Hari Krishna Nalla

Nikolay Vedman

When use mkl-dnn ver 1.x

Configuration:
cfg = coder.config('mex');
cfg.TargetLang = 'C++';
cfg.DeepLearningConfig = coder.DeepLearningConfig('mkldnn');

Call codegen:
codegen -config cfg classifyImage -args {ones(28,28,1,'static')} -report

Errors:
MWCNNLayerImpl.hpp:143:21: error: 'primitive_desc' is not a member of 'mkldnn::memory'
MWMkldnnUtils.cpp:10:28: error: 'mkldnn::memory::format' has not been declared
MWMkldnnUtils.cpp:17:1: error: 'primitive_desc' is not a member of 'mkldnn::memory'
... and others

When I try use mkldnn library version 0.x - it not working because MATLAB mkldnn api don't work with old version

cui

nice!

R2018b users can fix the linker error "can not open “C:\Program Files\mkl-dnn\lib\mwmklnnet.lib” by following the steps in the bug report below:
https://www.mathworks.com/support/bugreports/details/1858299

Steps to install Intel MKL-DNN v0.14 can be found at the MATLAB Answers post below:
https://www.mathworks.com/matlabcentral/answers/447387-matlab-coder-how-do-i-build-the-intel-mkl-dnn-library-for-deep-learning-c-code-generation-and-dep

TripleSSSS

I also experience this problem:

can not open “C:\Program Files\mkl-dnn\lib\mwmklnnet.lib”

where should I get "mwmklnnet.lib"

Ram

Bill Chou

peng hook

I have installed MKLDNN. and then

cfg = coder.config('mex');
cfg.TargetLang = 'C++';
cfg.DeepLearningConfig = coder.DeepLearningConfig('mkldnn');
codegen -args {ones(227,227,3,'single')} -config cfg alexnet_predict

but I got a problem about link error.
can not open “C:\Program Files\mkl-dnn\lib\mwmklnnet.lib”

where should I get "mwmklnnet.lib"

peng hook

why my platform is not supported

MATLAB Release Compatibility
Created with R2018b
Compatible with R2018b to R2020b
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!