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

2 ビュー (過去 30 日間)
재원
재원 2022 年 11 月 4 日
編集済み: 재원 2022 年 11 月 7 日
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 Center および File ExchangeDeep 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