資源簡(jiǎn)介
FPGA的CNN網(wǎng)絡(luò)加速代碼,重磅資源,親側(cè)可用的,講述了使用HLS寫(xiě)入深度學(xué)習(xí)CNN的推斷部分加速代碼,網(wǎng)絡(luò)通用性高。
代碼片段和文件信息
function?[legend_hobject_hplot_htext_strings]?=?columnlegend(numcolumns?str?varargin)
%
%???columnlegend?creates?a?legend?with?a?specified?number?of?columns.
%???
%???columnlegend(numcolumns?str?varargin)
%???????numcolumns?-?number?of?columns?in?the?legend
%???????str?-?cell?array?of?strings?for?the?legend
%???????
%???columnlegend(...?‘Location‘?loc)
%???????loc?-?location?variable?for?legend?default?is?‘NorthEast‘
%??????????????????possible?values:?‘NorthWest‘?‘NorthEast‘?‘SouthEast‘?‘SouthWest‘?
%
%???columnlegend(...?‘boxon‘)
%???columnlegend(...?‘boxoff‘)
%????????set?legend?bounding?box?on/off
%
%???example:
%??????legend_str?=?[];?
%??????for?i=1:10?
%???????????x?=?1:i:(10*i);?
%???????????plot(x);?hold?on;?
%???????????legend_str?=?[legend_str;?{num2str(i)}];
%??????end
%??????columnlegend(3?legend_str?‘Location‘?‘NorthWest‘);
%
%
%???Author:?Simon?Henin?
%???
%???4/09/2013?-?Fixed?bug?with?3?entries?/?3?columns
%???4/09/2013?-?Added?bounding?box?option?as?per?@Durga?Lal?Shrestha?(fileexchage)
%
%???22/7/2016?-?Edited?by?davidgs?for?FontName?Handling
location?=?‘NorthEast‘;
boxon?=?false;
fontsize=[];
fontname=‘‘;
for?i=1:length(varargin)
????switch?lower(varargin{i})
????????case?‘location‘
????????????location?=?varargin{i+1};
????????case?‘boxon‘
????????????boxon?=?true;
????????case?‘boxoff‘
????????????boxon?=?false;
????????case?‘fontsize‘
????????????fontsize=varargin{i+1};
????????case?‘fontname‘
????????????fontname=varargin{i+1};
????end
end
%create?the?legend
%[legend_hobject_hplot_htext_strings]?=?legend(str);
%create?the?legend
[legend_hobject_hplot_htext_strings]?=?legend(str);
legendT=findobj(object_h‘Type‘‘Text‘);
if?~isempty(fontsize)?&?isnumeric(fontsize)
????set(legendT‘FontSize‘fontsize);
end
if?~isempty(fontname)
????set(legendT‘FontName‘fontname);
end
%some?variables
numlines?=?length(str);
numpercolumn?=?ceil(numlines/numcolumns);
%get?old?width?new?width?and?scale?factor
pos?=?get(legend_h?‘position‘);
width?=?numcolumns*pos(3);
rescale?=?pos(3)/width;
%get?some?old?values?so?we?can?scale?everything?later
xdata?=?get(object_h(numlines+1)?‘xdata‘);?
ydata1?=?get(object_h(numlines+1)?‘ydata‘);
ydata2?=?get(object_h(numlines+3)?‘ydata‘);
%we‘ll?use?these?later?to?align?things?appropriately
sheight?=?ydata1(1)-ydata2(1);??????????????????%?height?between?data?lines
height?=?ydata1(1);?????????????????????????????%?height?of?the?box.?Used?to?top?margin?offset
line_width?=?(xdata(2)-xdata(1))*rescale;???%?rescaled?linewidth?to?match?original
spacer?=?xdata(1)*rescale;????????????????????%?rescaled?spacer?used?for?margins
%put?the?legend?on?the?upper?left?corner?to?make?initial?adjustments?easier
loci?=?get(gca?‘position‘);
set(legend_h?‘position‘?[loci(1)?pos(2)?width?pos(4)]);
col?=?-1;
for?i=1:numlines
????if?(mod(inumpercolumn)==1?||?(numpercolumn?==?1))
????????col?=?col+1;
????end
????
????if?i==1
????????linenum?=?i+numlines;
????else
??
評(píng)論
共有 條評(píng)論