How do I upload my deeplearning network to previous version of Simulink?

조회 수: 4 (최근 30일)
I'm trying to upload my deep learning model which is trained at R2021a, to Simulink R2018b.
I've been trying this for over a month, but I didn't succeed.
If you know any Idea, It will be huge gift for me.
I have tried these things:
- at R2018b Simulink, Use matlab function block
-> It causes error(coder dot indexing problem)
- at R2018b, generate C++ code for my model
-> It doesn't work(dot indexing problem)
- at R2021a, generate C++ code for my model, and upload to R2018b Simulink via S-function
-> Code generation was successful, but I have no idea what to do next.

채택된 답변

Hariprasad Ravishankar
Hariprasad Ravishankar 2022년 11월 4일
Hello,
I believe step 2 of this MATLAB Answers post will help you take your generated code to a previous release of MATLAB via S-function.
Please let us know if you found this helpful.
Hari
  댓글 수: 1
재원
재원 2022년 11월 7일
You are my savior. Thank you so much.
Instead of using cuDNN, I used MKL_DNN as my target library. and It works well, too.
To use MKL_DNN, I should build mkldnn library first. The link below will help.
this is the code I used.
% Function to DLL
setenv('INTEL_MKLDNN', 'C:\Program Files\mkl-dnn')
setenv('PATH', [getenv('INTEL_MKLDNN') filesep 'lib' pathsep getenv('PATH')])
cfg = coder.config('dll');
cfg.TargetLang = 'C++';
cfg.GenerateReport = true;
cfg.DeepLearningConfig = coder.DeepLearningConfig('mkldnn');
codegen -args {ones(1,200,1,8,'uint16')} -config cfg CNN_as_Func
copyfile(fullfile(pwd, 'codegen','dll', 'CNN_as_Func','CNN_as_Func.dll'), pwd);
% DLL to S-Function
srcPath = fullfile(pwd, 'codegen', 'dll', 'CNN_as_Func');
mkldnnPath = getenv('INTEL_MKLDNN');
mkldnnLibPath = fullfile(mkldnnPath,'lib');
mkldnnIncludePath = fullfile(mkldnnPath,'include');
libs = {'CNN_as_Func.lib','dnnl.lib'};
headerPath = {srcPath;mkldnnIncludePath};
libPath = {srcPath;mkldnnLibPath};
def = legacy_code('initialize');
def.SFunctionName = 'High_Classification_S_Func';
def.OutputFcnSpec = 'void CNN_as_Func(uint16 u1[1600],single y1[16])';
def.IncPaths = headerPath;
def.HeaderFiles = {'CNN_as_Func.h'};
def.LibPaths = libPath;
def.HostLibFiles = libs;
def.Options.useTlcWithAccel = false;
def.Options.language = 'C++';
legacy_code('sfcn_cmex_generate', def);
status = evalc("legacy_code('compile', def)");
Thanks again, Hariprasad Ravishankar.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Deep Learning Code Generation Fundamentals에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by