mirror of
https://github.com/harvard-edge/cs249r_book.git
synced 2026-03-09 07:15:51 -05:00
chore(frameworks): update TikZ figures from PR 1219
This commit is contained in:
@@ -352,59 +352,175 @@ Real machine learning models require much more complex graph structures. @fig-ml
|
||||
|
||||
```{.tikz}
|
||||
\begin{tikzpicture}[font=\usefont{T1}{phv}{m}{n}\small]
|
||||
%
|
||||
\tikzset{Line/.style={line width=1.0pt,black!50
|
||||
},
|
||||
Box/.style={align=flush center,
|
||||
inner xsep=2pt,
|
||||
node distance=1.1,
|
||||
draw=BlueLine,
|
||||
line width=0.75pt,
|
||||
fill=BlueL,
|
||||
text width=26mm,
|
||||
minimum width=26mm, minimum height=10mm
|
||||
},
|
||||
Text/.style={%
|
||||
inner sep=3pt,
|
||||
|
||||
\tikzset{
|
||||
Box/.style={ inner xsep=2pt,
|
||||
node distance=1.4,
|
||||
draw=none,
|
||||
line width=0.75pt,
|
||||
fill=TextColor!80,
|
||||
text=black,
|
||||
font=\usefont{T1}{phv}{m}{n}\footnotesize,
|
||||
align=flush center,
|
||||
minimum width=7mm, minimum height=5mm
|
||||
line width=0.5pt,,
|
||||
fill=none,
|
||||
minimum width=27mm, minimum height=15mm
|
||||
},
|
||||
LineA/.style={violet!40,line width=5pt,{-{Triangle[width=1.0*11pt,length=1.0*8pt]}},shorten <=1pt,shorten >=1pt},
|
||||
graphpanel/.style={
|
||||
draw=olive!60!black,
|
||||
fill=olive!02,
|
||||
line width=0.9pt,
|
||||
rounded corners=4pt,
|
||||
inner sep=14pt,yshift=9pt
|
||||
},
|
||||
syspanel/.style={
|
||||
draw=orange!70!black,
|
||||
fill=orange!03,
|
||||
line width=0.9pt,
|
||||
rounded corners=4pt,
|
||||
inner sep=10pt
|
||||
},
|
||||
opnode/.style={
|
||||
circle,node distance=7mm,
|
||||
draw=BlueLine,,
|
||||
fill=cyan!15,
|
||||
minimum size=7mm,
|
||||
line width=0.9pt
|
||||
},
|
||||
compbox/.style={
|
||||
draw=orange!80!black,
|
||||
fill=orange!12,
|
||||
rounded corners=2pt,
|
||||
minimum width=2.7cm,
|
||||
minimum height=0.9cm,
|
||||
align=center,
|
||||
line width=0.8pt
|
||||
},
|
||||
flow/.style={
|
||||
-{Latex[length=2.2mm]},
|
||||
draw=BrownLine!75,
|
||||
line width=0.9pt
|
||||
},
|
||||
}
|
||||
%CPU style
|
||||
\tikzset{
|
||||
pics/cpu/.style = {
|
||||
code = {
|
||||
\pgfkeys{/channel/.cd, #1}
|
||||
\begin{scope}[local bounding box = CPU,shift={($(0,0)+(0,0)$)},scale=\scalefac,every node/.append style={transform shape}]
|
||||
\node[fill=\filllcolor,minimum width=66, minimum height=66,
|
||||
rounded corners=2,outer sep=2pt] (C1) {};
|
||||
\node[fill=white,minimum width=54, minimum height=54] (C2) {};
|
||||
\node[fill=\filllcolor!50,minimum width=44, minimum height=44] (C3) {\Large\bfseries GPU};
|
||||
|
||||
\foreach \x/\y in {0.11/1,0.26/2,0.41/3,0.56/4,0.71/5,0.85/6}{
|
||||
\node[fill=\filllcolor,minimum width=4, minimum height=15,
|
||||
inner sep=0pt,anchor=south](GO\y)at($(C1.north west)!\x!(C1.north east)$){};
|
||||
}
|
||||
\foreach \x/\y in {0.11/1,0.26/2,0.41/3,0.56/4,0.71/5,0.85/6}{
|
||||
\node[fill=\filllcolor,minimum width=4, minimum height=15,
|
||||
inner sep=0pt,anchor=north](DO\y)at($(C1.south west)!\x!(C1.south east)$){};
|
||||
}
|
||||
\foreach \x/\y in {0.11/1,0.26/2,0.41/3,0.56/4,0.71/5,0.85/6}{
|
||||
\node[fill=\filllcolor,minimum width=15, minimum height=4,
|
||||
inner sep=0pt,anchor=east](LE\y)at($(C1.north west)!\x!(C1.south west)$){};
|
||||
}
|
||||
\foreach \x/\y in {0.11/1,0.26/2,0.41/3,0.56/4,0.71/5,0.85/6}{
|
||||
\node[fill=\filllcolor,minimum width=15, minimum height=4,
|
||||
inner sep=0pt,anchor=west](DE\y)at($(C1.north east)!\x!(C1.south east)$){};
|
||||
}
|
||||
\end{scope}
|
||||
}
|
||||
}
|
||||
}
|
||||
\begin{scope}[local bounding box=scope1]
|
||||
\node[Box,fill=BlueL,draw=BlueLine](B1){Operation Node 1};
|
||||
\node[Box,fill=BlueL,draw=BlueLine,below=of B1](B2){Operation Node 2};
|
||||
\node[Box,fill=BlueL,draw=BlueLine,below left=0.75 and 0.1 of B2](B3){Operation Node 3};
|
||||
\node[Box,fill=BlueL,draw=BlueLine,below right=0.75 and 0.1 of B2](B4){Operation Node 4};
|
||||
\node[Box,fill=BlueL,draw=BlueLine,below=of B3](B5){Operation Node 5};
|
||||
\node[Box,fill=BlueL,draw=BlueLine,below=of B4](B6){Operation Node 6};
|
||||
\tikzset{
|
||||
pics/dram/.style = {
|
||||
code = {
|
||||
\pgfkeys{/channel/.cd, #1}
|
||||
\begin{scope}[shift={($(0,0)+(0,0)$)},scale=\scalefac,every node/.append style={transform shape}]
|
||||
\node[draw=\drawcolor,fill=\filllcolor!70,line width=1.5*\Linewidth,inner sep=0pt,outer sep=0pt,
|
||||
minimum width=56mm,minimum height=14mm](DRAM\picname)at(0,0){};
|
||||
\node[draw=\drawcolor,fill=\filllcolor!30,line width=1.5*\Linewidth,inner sep=0pt,outer sep=0pt,anchor=north,
|
||||
minimum width=52mm,minimum height=6mm](MDRAM\picname)at(DRAM\picname.south){};
|
||||
%
|
||||
\scoped[on background layer]
|
||||
\node[draw=BackLine,inner xsep=4mm,inner ysep=6mm,yshift=2mm,
|
||||
fill=BackColor!80,fit=(B1)(B3)(B6),line width=0.75pt](BB1){};
|
||||
\node[below=2pt of BB1.north east,anchor=north east]{Computational Graph};
|
||||
\pgfmathsetmacro{\spacing}{56/(6+1)}
|
||||
\foreach \i in {1,...,6} {
|
||||
\pgfmathsetmacro{\x}{\i * \spacing}
|
||||
\node[draw=\drawcolor,fill=\filllcolor!20,line width=\Linewidth, inner sep=0pt, outer sep=0pt,
|
||||
minimum width=6mm, minimum height=8mm]
|
||||
at ([xshift=\x mm]DRAM\picname.west) {};
|
||||
}
|
||||
%
|
||||
\foreach \i in {1,...,19} {
|
||||
\pgfmathsetmacro{\x}{\i*(52/20)}
|
||||
\draw[draw=\drawcolor, line width=3*\Linewidth]
|
||||
([xshift=\x mm,yshift=1pt]MDRAM\picname.south west) -- ++(0,2mm);
|
||||
}
|
||||
\end{scope}
|
||||
}
|
||||
}
|
||||
}
|
||||
\pgfkeys{
|
||||
/channel/.cd,
|
||||
Depth/.store in=\Depth,
|
||||
Height/.store in=\Height,
|
||||
Width/.store in=\Width,
|
||||
filllcirclecolor/.store in=\filllcirclecolor,
|
||||
filllcolor/.store in=\filllcolor,
|
||||
drawcolor/.store in=\drawcolor,
|
||||
drawcircle/.store in=\drawcircle,
|
||||
scalefac/.store in=\scalefac,
|
||||
Linewidth/.store in=\Linewidth,
|
||||
picname/.store in=\picname,
|
||||
filllcolor=BrownLine,
|
||||
filllcirclecolor=cyan!40,
|
||||
drawcolor=black,
|
||||
drawcircle=violet,
|
||||
scalefac=1,
|
||||
Linewidth=0.5pt,
|
||||
Depth=1.3,
|
||||
Height=0.8,
|
||||
Width=1.1,
|
||||
picname=C
|
||||
}
|
||||
|
||||
% graph nodes
|
||||
\node[opnode] (a) {};
|
||||
\node[opnode,below left=of a] (b) {};
|
||||
\node[opnode,below right =of a] (c) {};
|
||||
\node[opnode,below=of b] (d) {};
|
||||
\node[opnode,below =of c] (e) {};
|
||||
\node[opnode,below right=of d] (f) {};
|
||||
% edges
|
||||
\draw[flow] (a) -- (b);
|
||||
\draw[flow] (a) -- (c);
|
||||
\draw[flow] (b) -- (d);
|
||||
\draw[flow] (c) -- (e);
|
||||
\draw[flow] (d) -- (f);
|
||||
\draw[flow] (e) -- (f);
|
||||
% optional cross-edge
|
||||
\draw[flow] (b) -- (e);
|
||||
|
||||
\node[opnode,minimum size=3mm,below left= 0.33 and 1.65of f] (l) {};
|
||||
\node[right=0pt of l,font=\usefont{T1}{phv}{m}{n}\footnotesize](O){Operations};
|
||||
\draw[flow]($(O.east)+(1mm,0)$)--++(0:7mm)coordinate(A);
|
||||
\node[right=0pt of A,font=\usefont{T1}{phv}{m}{n}\footnotesize](AA){Data flow};
|
||||
\scoped[on background layer]
|
||||
\node[graphpanel,fit=(a)(l)(O)(AA),inner xsep=6pt](FF){};
|
||||
\node[below=1pt of FF.north,font=\usefont{T1}{phv}{b}{n}\footnotesize]{Computational Graph};
|
||||
%
|
||||
\begin{scope}[local bounding box=scope2, shift={($(scope1.east)+(45mm,10mm)$)}]
|
||||
\node[Box,fill=OrangeL,draw=OrangeLine](2B1){Memory Management};
|
||||
\node[Box,fill=OrangeL,draw=OrangeLine,below=of 2B1](2B2){Device Placement};
|
||||
%
|
||||
\scoped[on background layer]
|
||||
\node[draw=BackLine,inner xsep=4mm,inner ysep=6mm,yshift=2mm,
|
||||
fill=BackColor!50,fit=(2B1)(2B2),line width=0.75pt](2BB1){};
|
||||
\node[below=2pt of 2BB1.north east,anchor=north east]{System Components};
|
||||
\end{scope}
|
||||
\draw[-latex,Line](B1)--node[Text,pos=0.45]{Data Flow}(B2);
|
||||
\draw[-latex,Line](B3)--node[Text,pos=0.45]{Data Flow}(B5);
|
||||
\draw[-latex,Line](B4)--node[Text,pos=0.45]{Data Flow}(B6);
|
||||
\draw[-latex,Line](B2)-|node[Text,pos=0.45]{Data Flow}(B3);
|
||||
\draw[-latex,Line](B2)-|node[Text,pos=0.45]{Data Flow}(B4);
|
||||
\draw[latex-,Line](2B2) --node[Text,pos=0.55]{Interacts with} (scope1.east|-2B2);
|
||||
\draw[latex-,Line](2B1) --node[Text,pos=0.55]{Interacts with} (scope1.east|-2B1);
|
||||
\node[right=29mm of FF.27,Box](MM){};
|
||||
\node[below=-6pt of MM](T1){Memory Management};
|
||||
\pic[shift={(0,0.1)}] at (MM){dram={scalefac=0.43,picname=1,
|
||||
drawcolor=black,filllcolor=OrangeLine!50!,Linewidth=0.5pt}};
|
||||
\node[right=29mm of FF.338,Box](DP){};
|
||||
\node[below=1pt of DP](T2){Device Placement};
|
||||
\pic[shift={(0,0)}] at (DP) {cpu={scalefac=0.45,picname=1,
|
||||
drawcolor=RedLine,filllcolor=BlueLine!80!,Linewidth=0.5pt}};
|
||||
|
||||
\scoped[on background layer]
|
||||
\node[fit=(MM)(T1)(T2),syspanel,yshift=1mm,inner xsep=6pt](DD){};
|
||||
\node[below=1pt of DD.north,font=\usefont{T1}{phv}{b}{n}\footnotesize]{System Components};
|
||||
|
||||
\draw[LineA](FF)--
|
||||
node[above,pos=0.45,text=black!70,font=\usefont{T1}{phv}{m}{n}\footnotesize]{Interacts with}
|
||||
(DD);
|
||||
\end{tikzpicture}
|
||||
```
|
||||
|
||||
@@ -514,54 +630,217 @@ Follow this "define-by-run" execution model step by step in @fig-mlfm-dynamic-gr
|
||||
::: {#fig-mlfm-dynamic-graph-flow fig-env="figure" fig-pos="htb" fig-cap="**Dynamic Graph Execution Flow**: In eager execution, each operation is defined and immediately executed before the next operation begins. This define-by-run model enables natural debugging and data-dependent control flow at the cost of optimization opportunities." fig-alt="Flow diagram showing Start to Operation 1 to Operation 1 Executed to Operation 2 to Operation 2 Executed to End. Above arrows show Define Operation, Execute Operation, Define Next Operation, Execute Operation, Repeat Until Done."}
|
||||
|
||||
```{.tikz}
|
||||
\begin{tikzpicture}[font=\usefont{T1}{phv}{m}{n}\small]
|
||||
\tikzset{Line/.style={line width=1.0pt,black!50
|
||||
},
|
||||
\begin{tikzpicture}[line join=round,font=\usefont{T1}{phv}{m}{n}\small]
|
||||
\tikzset{%
|
||||
Line/.style={line width=0.75pt,black!50,text=black},
|
||||
Box/.style={align=flush center,
|
||||
inner xsep=2pt,
|
||||
node distance=1.0,
|
||||
node distance=0.75,
|
||||
draw=BlueLine,
|
||||
line width=0.75pt,
|
||||
fill=BlueL,
|
||||
text width=18mm,
|
||||
minimum width=18mm,
|
||||
minimum height=10mm
|
||||
},
|
||||
Text/.style={%
|
||||
inner sep=4pt,
|
||||
draw=none,
|
||||
line width=0.75pt,
|
||||
fill=TextColor!80,
|
||||
text=black,
|
||||
font=\usefont{T1}{phv}{m}{n}\footnotesize,
|
||||
align=flush center,
|
||||
minimum width=7mm, minimum height=5mm
|
||||
fill=BlueL!30,
|
||||
%text width=35mm,
|
||||
minimum width=35mm, minimum height=11mm
|
||||
},
|
||||
decision/.style = {Box,diamond,text width=35mm,aspect=1.95, inner xsep=7pt,inner ysep=-2ex, fill=VioletL2!70,
|
||||
draw=VioletLine},
|
||||
startstop/.style = {Box,minimum width=25mm, rounded corners=10pt, fill=red!10, draw=RedLine},
|
||||
LineA/.style={black!50,line width=1.5pt,{-{Triangle[width=1.0*5pt,length=1.0*5pt]}},shorten <=0pt,shorten >=0pt},
|
||||
}
|
||||
\node[Box,text width=12mm,minimum width=14mm,
|
||||
fill=OliveL!70,draw=OliveLine](B1){Start};
|
||||
\node[Box,fill=VioletL,draw=VioletLine,right=of B1](B2){Operation 1};
|
||||
\node[Box,fill=GreenL,draw=GreenLine,right=of B2,
|
||||
minimum height=14mm](B3){Operation 1 Executed};
|
||||
\node[Box,node distance=2.1,fill=VioletL,draw=VioletLine,right=of B3](B4){Operation 2};
|
||||
\node[Box,fill=GreenL,draw=GreenLine,right=of B4,
|
||||
minimum height=14mm](B5){Operation 2 Executed};
|
||||
\node[Box,right=of B5,text width=12mm,minimum width=14mm,
|
||||
fill=OliveL!70,draw=OliveLine](B6){End};
|
||||
%%
|
||||
\foreach \x/\y in{1/2,2/3,3/4,4/5,5/6}
|
||||
\draw[-latex,Line](B\x)--(B\y);
|
||||
\def\vi{15mm}
|
||||
\draw[thick]($(B1.east)!0.5!(B2.west)$)--++(90:\vi)
|
||||
node[Text]{Define\\ Operation};
|
||||
\draw[thick]($(B2.east)!0.5!(B3.west)$)--++(90:\vi)
|
||||
node[Text]{Execute\\ Operation};
|
||||
\draw[thick]($(B3.east)!0.5!(B4.west)$)--++(90:\vi)
|
||||
node[Text]{Define Next\\ Operation};
|
||||
\draw[thick]($(B4.east)!0.5!(B5.west)$)--++(90:\vi)
|
||||
node[Text]{Execute\\ Operation};
|
||||
\draw[thick]($(B5.east)!0.5!(B6.west)$)--++(90:\vi)
|
||||
node[Text](BB6){Repeat\\ Until Done};
|
||||
|
||||
\tikzset{
|
||||
pics/repeat/.style = {
|
||||
code = {
|
||||
\pgfkeys{/channel/.cd, #1}
|
||||
\begin{scope}[shift={($(0,0)+(0,0)$)},scale=\scalefac,every node/.append style={transform shape}]
|
||||
\def\w{4cm}
|
||||
\def\h{15mm}
|
||||
\def\r{6mm} % radius
|
||||
\def\gap{4mm} % break lengths
|
||||
\draw[\filllcirclecolor, -{Latex[length=10pt,width=15pt]},line width=\Linewidth]
|
||||
(\w,\h-\r) -- (\w,\r)
|
||||
arc[start angle=0, end angle=-90, radius=\r]
|
||||
-- (\gap,0);
|
||||
%
|
||||
\draw[\filllcolor, -{Latex[length=10pt,width=15pt]},line width=\Linewidth]
|
||||
(0,\r) -- (0,\h-\r)
|
||||
arc[start angle=180, end angle=90, radius=\r]
|
||||
-- ({\w-\gap},\h);
|
||||
\end{scope}
|
||||
}
|
||||
}
|
||||
}
|
||||
\tikzset{
|
||||
pics/interpreter/.style = {
|
||||
code = {
|
||||
\pgfkeys{/channel/.cd, #1}
|
||||
\def\ra{}
|
||||
\begin{scope}[shift={($(0,0)+(0,0)$)},scale=\scalefac,every node/.append style={transform shape}]
|
||||
\node[red,font=\Large\bfseries]at(-0.75,0.6){\textless\,/\,\textgreater};
|
||||
\draw[line cap=round,line join=round,yellow,line width=\Linewidth](-1.15,-0.1)--(-0.95,-0.1);
|
||||
\draw[line cap=round,line join=round,red,line width=\Linewidth](-0.7,-0.1)--(0.1,-0.1);
|
||||
|
||||
\draw[line cap=round,line join=round,yellow,line width=\Linewidth](-1.15,-0.5)--(0,-0.5);
|
||||
|
||||
\draw[line cap=round,line join=round,yellow,line width=\Linewidth](-1.15,-0.9)--(-0.75,-0.9);
|
||||
\draw[line cap=round,line join=round,red,line width=\Linewidth](-0.45,-0.9)--(0.45,-0.9);
|
||||
\draw[line cap=round,line join=round,cyan,line width=\Linewidth](0.75,-0.9)--(1.1,-0.9);
|
||||
|
||||
\draw[line cap=round,line join=round,yellow,line width=\Linewidth](-1.15,-1.3)--(-1,-1.3);
|
||||
\draw[line cap=round,line join=round,red,line width=\Linewidth](-0.65,-1.3)--(-0.10,-1.3);
|
||||
\draw[line cap=round,line join=round,cyan,line width=\Linewidth](0.2,-1.3)--(1.1,-1.3);
|
||||
\end{scope}
|
||||
}
|
||||
}
|
||||
}
|
||||
%CPU
|
||||
\tikzset{%
|
||||
pics/cpu/.style = {
|
||||
code = {
|
||||
\pgfkeys{/channel/.cd, #1}
|
||||
\begin{scope}[local bounding box=FUNNEL,scale=\scalefac, every node/.append style={transform shape}]
|
||||
\node[fill=\filllcolor,minimum width=66, minimum height=66,
|
||||
rounded corners=2,outer sep=2pt] (C1) {};
|
||||
\node[fill=white,minimum width=54, minimum height=54] (C2) {};
|
||||
\node[fill=\filllcolor!40,minimum width=44, minimum height=44] (C3) {\Large\bfseries GPU};
|
||||
|
||||
\foreach \x/\y in {0.11/1,0.26/2,0.41/3,0.56/4,0.71/5,0.85/6}{
|
||||
\node[fill=\filllcolor,minimum width=3, minimum height=15,
|
||||
inner sep=0pt,anchor=south](GO\y)at($(C1.north west)!\x!(C1.north east)$){};
|
||||
}
|
||||
\foreach \x/\y in {0.11/1,0.26/2,0.41/3,0.56/4,0.71/5,0.85/6}{
|
||||
\node[fill=\filllcolor,minimum width=3, minimum height=15,
|
||||
inner sep=0pt,anchor=north](DO\y)at($(C1.south west)!\x!(C1.south east)$){};
|
||||
}
|
||||
\foreach \x/\y in {0.11/1,0.26/2,0.41/3,0.56/4,0.71/5,0.85/6}{
|
||||
\node[fill=\filllcolor,minimum width=15, minimum height=3,
|
||||
inner sep=0pt,anchor=east](LE\y)at($(C1.north west)!\x!(C1.south west)$){};
|
||||
}
|
||||
\foreach \x/\y in {0.11/1,0.26/2,0.41/3,0.56/4,0.71/5,0.85/6}{
|
||||
\node[fill=\filllcolor,minimum width=15, minimum height=3,
|
||||
inner sep=0pt,anchor=west](DE\y)at($(C1.north east)!\x!(C1.south east)$){};
|
||||
}
|
||||
\end{scope}
|
||||
}
|
||||
}
|
||||
}
|
||||
%start
|
||||
\tikzset{%
|
||||
pics/start/.style = {
|
||||
code = {
|
||||
\pgfkeys{/channel/.cd, #1}
|
||||
\begin{scope}[local bounding box=START,scale=\scalefac, every node/.append style={transform shape}]
|
||||
\node[fill=\filllcolor,minimum width=6mm, minimum height=6mm,
|
||||
outer sep=2pt] (C1) {};
|
||||
\node[isosceles triangle,isosceles triangle apex angle=45,xshift=-2.5pt,
|
||||
inner sep=1pt, fill=white,minimum size =3.5mm] (T1)at (C1){};
|
||||
\end{scope}
|
||||
}
|
||||
}
|
||||
}
|
||||
%check
|
||||
\tikzset{pics/.cd,
|
||||
checkmark/.style={code={
|
||||
\pgfkeys{/channel/.cd, #1}
|
||||
\pgfgettransformentries{\tmpxx}{\tmp}{\tmp}{\tmp}{\tmp}{\tmp}
|
||||
\draw[line width=\tmpxx*1pt,draw=none,fill=\filllcirclecolor,line join=bevel] (0,.35) -- (.25,0) to[bend left=5] (0.8,.6) to[bend
|
||||
right=5] (.25,.18) -- cycle;}}}
|
||||
\tikzset{%
|
||||
pics/checkI/.style = {
|
||||
code = {
|
||||
\pgfkeys{/channel/.cd, #1}
|
||||
\begin{scope}[local bounding box=CHECK,scale=\scalefac, every node/.append style={transform shape}]
|
||||
\node[fill=\filllcolor,minimum width=6mm, minimum height=6mm,
|
||||
outer sep=2pt] (C1) {};
|
||||
\pic[shift={(-0.27,-0.19)},scale=0.7]{checkmark};
|
||||
\end{scope}
|
||||
}
|
||||
}
|
||||
}
|
||||
\pgfkeys{
|
||||
/channel/.cd,
|
||||
Depth/.store in=\Depth,
|
||||
Height/.store in=\Height,
|
||||
Width/.store in=\Width,
|
||||
filllcirclecolor/.store in=\filllcirclecolor,
|
||||
filllcolor/.store in=\filllcolor,
|
||||
drawcolor/.store in=\drawcolor,
|
||||
drawcircle/.store in=\drawcircle,
|
||||
scalefac/.store in=\scalefac,
|
||||
Linewidth/.store in=\Linewidth,
|
||||
picname/.store in=\picname,
|
||||
filllcolor=BrownLine,
|
||||
filllcirclecolor=violet!20,
|
||||
drawcolor=red,
|
||||
drawcircle=violet,
|
||||
scalefac=1,
|
||||
Linewidth=0.5pt,
|
||||
Depth=1.3,
|
||||
Height=0.8,
|
||||
Width=1.1,
|
||||
picname=C
|
||||
}
|
||||
|
||||
\node[startstop](B1){};
|
||||
\coordinate(GO1)at($(B1.north west)!0.33!(B1.north east)$);
|
||||
\coordinate(T1)at($(GO1)!0.5!(B1.south east)$);
|
||||
\node[align=center]at(T1){Start};
|
||||
\begin{scope}
|
||||
\coordinate(I1)at($(GO1)!0.5!(B1.south west)$);
|
||||
\clip (B1.south west) rectangle (GO1);
|
||||
%\fill[RedLine!30,rounded corners=10pt] (B1.south west) rectangle (B1.north east);
|
||||
\end{scope}
|
||||
\draw[dashed,RedLine, line width=0.75pt,](GO1)--(GO1|-B1.south west);
|
||||
\node[startstop,fill=none]{};
|
||||
\pic[shift={(0,0)}] at (I1){start={scalefac=1,picname=1,filllcolor=GreenLine, Linewidth=0.7pt}};
|
||||
%Define
|
||||
\node[Box,right=of B1](B2){};
|
||||
\node[above=1pt of B2,text=black!70]{Python Dispatch};
|
||||
\coordinate(GO2)at($(B2.north west)!0.3!(B2.north east)$);
|
||||
%\fill[fill=BlueL!90](B2.south west)rectangle(GO2);
|
||||
\coordinate(T2)at($(GO2)!0.5!(B2.south east)$);
|
||||
\coordinate(I2)at($(GO2)!0.5!(B2.south west)$);
|
||||
\node[align=center]at(T2){Define\\Operation};
|
||||
\draw[dashed,BlueLine, line width=0.75pt,](GO2)--(GO2|-B2.south west);
|
||||
\node[Box,right=of B1,fill=none]{};
|
||||
\pic[shift={(0.05,0.11)}] at (I2){interpreter={scalefac=0.35,picname=1,
|
||||
filllcolor=cyan!30!, Linewidth=1.5pt,filllcirclecolor=orange}};
|
||||
%Execute
|
||||
\node[Box,right=of B2](B3){};
|
||||
\node[above=1pt of B3,text=black!70]{GPU Kernel};
|
||||
\coordinate(GO3)at($(B3.north west)!0.3!(B3.north east)$);
|
||||
%\fill[fill=BlueL!90](B3.south west)rectangle(GO3);
|
||||
\coordinate(T3)at($(GO3)!0.5!(B3.south east)$);
|
||||
\coordinate(I3)at($(GO3)!0.5!(B3.south west)$);
|
||||
\node[align=center]at(T3){Execute\\Operation};
|
||||
\draw[dashed,BlueLine, line width=0.75pt,](GO3)--(GO3|-B3.south west);
|
||||
\node[Box,right=of B2,fill=none](B3){};
|
||||
\pic[shift={(0,0)}] at (I3){cpu={scalefac=0.23,picname=1,filllcolor=BrownLine, Linewidth=0.7pt}};
|
||||
%More operations
|
||||
\node[decision,right=of B3](B4){More\\operations?};
|
||||
\path[red](B4.west)|-coordinate(SR4)(B4.south);
|
||||
\pic[shift={(-0.30,-0.14)}] at (SR4){repeat={scalefac=0.3,picname=1,filllcolor=RedLine,
|
||||
Linewidth=4pt,filllcirclecolor=GreenLine}};
|
||||
%End
|
||||
\node[startstop,right=of B4](B5){};
|
||||
\coordinate(GO5)at($(B5.north west)!0.33!(B5.north east)$);
|
||||
\coordinate(T5)at($(GO5)!0.5!(B5.south east)$);
|
||||
\coordinate(I5)at($(GO5)!0.5!(B5.south west)$);
|
||||
\node[align=center]at(T5){End};
|
||||
\begin{scope}
|
||||
\clip (B5.south west) rectangle (GO5);
|
||||
%\fill[RedLine!30,rounded corners=10pt] (B5.south west) rectangle (B5.north east);
|
||||
\end{scope}
|
||||
\draw[dashed,RedLine, line width=0.75pt,](GO5)--(GO5|-B5.south west);
|
||||
\node[startstop,right=of B4,fill=none](B5){};
|
||||
\pic[shift={(0,0)}] at (I5){checkI={scalefac=1,picname=1,filllcolor=GreenLine, filllcirclecolor=white,Linewidth=0.7pt}};
|
||||
%arrows
|
||||
\foreach \i in {1,2,3,4}{
|
||||
\pgfmathtruncatemacro{\x}{\i + 1}
|
||||
\draw[LineA](B\i)--coordinate[pos=0.3](SR\i)(B\x);
|
||||
}
|
||||
\node[above=0pt of SR4]{No};
|
||||
\draw[LineA](B4.south)--node[right,pos=0.5]{Yes}++(270:0.55)-|(B2);
|
||||
\end{tikzpicture}
|
||||
```
|
||||
|
||||
@@ -676,41 +955,287 @@ Compare this with the dynamic model by examining @fig-mlfm-static-graph. Notice
|
||||
::: {#fig-mlfm-static-graph fig-env="figure" fig-pos="htb" fig-cap="**Static Graph: Define then Execute.** The two phases of static graph execution. The definition phase (left) declares operations and builds the graph. The execution phase (right) loads data, runs the optimized graph, and produces results." fig-alt="Flow diagram showing two phases. Definition Phase: Define Operations, Declare Variables, Build Graph. Execution Phase: Load Data, Run Graph, Get Results. Arrows connect boxes left to right."}
|
||||
|
||||
```{.tikz}
|
||||
\begin{tikzpicture}[font=\usefont{T1}{phv}{m}{n}\small]
|
||||
%
|
||||
\tikzset{Line/.style={line width=1.0pt,black!50,rounded corners
|
||||
},
|
||||
\begin{tikzpicture}[line join=round,font=\usefont{T1}{phv}{m}{n}\small]
|
||||
\tikzset{%
|
||||
Box/.style={align=flush center,
|
||||
inner xsep=2pt,
|
||||
node distance=0.7,
|
||||
node distance=0.65,
|
||||
draw=BlueLine,
|
||||
line width=0.75pt,
|
||||
fill=BlueL,
|
||||
text width=18mm,
|
||||
minimum width=18mm, minimum height=10mm
|
||||
fill=BlueL!30,
|
||||
%text width=35mm,
|
||||
minimum width=30mm, minimum height=14mm
|
||||
},
|
||||
Box2/.style={Box, draw=BrownLine, fill=BrownL!30,
|
||||
},
|
||||
LineA/.style={black!40,line width=6.5pt,{-{Triangle[width=1.0*12pt,length=1.0*5pt]}},shorten <=0pt,shorten >=0pt},
|
||||
}
|
||||
\node[Box,fill=VioletL,draw=VioletLine](B1){Define Operations};
|
||||
\node[Box,fill=VioletL,draw=VioletLine,right=of B1](B2){Declare Variables};
|
||||
\node[Box,fill=VioletL,draw=VioletLine,right=of B2](B3){Build Graph};
|
||||
|
||||
\tikzset{
|
||||
pics/interpreter/.style = {
|
||||
code = {
|
||||
\pgfkeys{/channel/.cd, #1}
|
||||
\def\ra{}
|
||||
\begin{scope}[shift={($(0,0)+(0,0)$)},scale=\scalefac,every node/.append style={transform shape}]
|
||||
\node[red,font=\Large\bfseries]at(-0.75,0.6){\textless\,/\,\textgreater};
|
||||
\draw[line cap=round,line join=round,violet,line width=\Linewidth](-1.15,-0.1)--(-0.95,-0.1);
|
||||
\draw[line cap=round,line join=round,red,line width=\Linewidth](-0.7,-0.1)--(0.1,-0.1);
|
||||
|
||||
\draw[line cap=round,line join=round,violet,line width=\Linewidth](-1.15,-0.5)--(0,-0.5);
|
||||
|
||||
\draw[line cap=round,line join=round,violet,line width=\Linewidth](-1.15,-0.9)--(-0.75,-0.9);
|
||||
\draw[line cap=round,line join=round,red,line width=\Linewidth](-0.45,-0.9)--(0.45,-0.9);
|
||||
\draw[line cap=round,line join=round,cyan,line width=\Linewidth](0.75,-0.9)--(1.1,-0.9);
|
||||
|
||||
\draw[line cap=round,line join=round,violet,line width=\Linewidth](-1.15,-1.3)--(-1,-1.3);
|
||||
\draw[line cap=round,line join=round,red,line width=\Linewidth](-0.65,-1.3)--(-0.10,-1.3);
|
||||
\draw[line cap=round,line join=round,cyan,line width=\Linewidth](0.2,-1.3)--(1.1,-1.3);
|
||||
\end{scope}
|
||||
}
|
||||
}
|
||||
}
|
||||
%CPU
|
||||
\tikzset{%
|
||||
pics/cpu/.style = {
|
||||
code = {
|
||||
\pgfkeys{/channel/.cd, #1}
|
||||
\begin{scope}[local bounding box=FUNNEL,scale=\scalefac, every node/.append style={transform shape}]
|
||||
\node[fill=\filllcolor,minimum width=66, minimum height=66,
|
||||
rounded corners=2,outer sep=2pt] (C1) {};
|
||||
\node[fill=white,minimum width=54, minimum height=54] (C2) {};
|
||||
\node[fill=\filllcolor!40,minimum width=44, minimum height=44] (C3) {\Large\bfseries GPU};
|
||||
|
||||
\foreach \x/\y in {0.11/1,0.26/2,0.41/3,0.56/4,0.71/5,0.85/6}{
|
||||
\node[fill=\filllcolor,minimum width=3, minimum height=15,
|
||||
inner sep=0pt,anchor=south](GO\y)at($(C1.north west)!\x!(C1.north east)$){};
|
||||
}
|
||||
\foreach \x/\y in {0.11/1,0.26/2,0.41/3,0.56/4,0.71/5,0.85/6}{
|
||||
\node[fill=\filllcolor,minimum width=3, minimum height=15,
|
||||
inner sep=0pt,anchor=north](DO\y)at($(C1.south west)!\x!(C1.south east)$){};
|
||||
}
|
||||
\foreach \x/\y in {0.11/1,0.26/2,0.41/3,0.56/4,0.71/5,0.85/6}{
|
||||
\node[fill=\filllcolor,minimum width=15, minimum height=3,
|
||||
inner sep=0pt,anchor=east](LE\y)at($(C1.north west)!\x!(C1.south west)$){};
|
||||
}
|
||||
\foreach \x/\y in {0.11/1,0.26/2,0.41/3,0.56/4,0.71/5,0.85/6}{
|
||||
\node[fill=\filllcolor,minimum width=15, minimum height=3,
|
||||
inner sep=0pt,anchor=west](DE\y)at($(C1.north east)!\x!(C1.south east)$){};
|
||||
}
|
||||
\end{scope}
|
||||
}
|
||||
}
|
||||
}
|
||||
%graph style
|
||||
\tikzset{
|
||||
pics/graph3D/.style = {
|
||||
code = {
|
||||
\pgfkeys{/channel/.cd, #1}
|
||||
\begin{scope}[local bounding box=GRAPH,scale=1, every node/.append style={transform shape}]
|
||||
\def\dx{\Width}
|
||||
\def\dy{\Height}
|
||||
\def\dz{\Depth}
|
||||
% koordinata donjeg levog ugla (početak bara)
|
||||
\def\x{0}
|
||||
\def\y{0.15}
|
||||
\def\z{0}
|
||||
% boje
|
||||
\draw[draw=\filllcirclecolor,line width=1pt](-0.2,0)--(1.3,0);
|
||||
\draw[draw=\filllcirclecolor,line width=1pt](-0.2,0)--(-0.2,1.2);
|
||||
\filldraw[fill=\filllcolor!10, draw=\drawcolor] (\x,\y+\dy,\z) -- (\x,\y+\dy,\z+\dz) -- (\x+\dx,\y+\dy,\z+\dz) -- (\x+\dx,\y+\dy,\z) -- cycle; % gornja strana
|
||||
\filldraw[fill=\filllcolor!50, draw=\drawcolor] (\x+\dx,\y,\z) -- (\x+\dx,\y,\z+\dz) -- (\x+\dx,\y+\dy,\z+\dz) -- (\x+\dx,\y+\dy,\z) -- cycle; % desna strana
|
||||
\filldraw[fill=\filllcolor!60, draw=\drawcolor] (\x,\y,\z+\dz) -- (\x+\dx,\y,\z+\dz) -- (\x+\dx,\y+\dy,\z+\dz) -- (\x,\y+\dy,\z+\dz) -- cycle; % prednja strana
|
||||
\end{scope}
|
||||
}
|
||||
}
|
||||
}
|
||||
\tikzset{mycylinder/.style={cylinder, shape border rotate=90, aspect=1.3, draw, fill=white,
|
||||
minimum width=25mm,minimum height=11mm,line width=\Linewidth,node distance=-0.15},
|
||||
pics/data/.style = {
|
||||
code = {
|
||||
\pgfkeys{/channel/.cd, #1}
|
||||
\begin{scope}[local bounding box=STREAMING,scale=\scalefac, every node/.append style={transform shape}]
|
||||
\node[mycylinder,fill=\filllcolor!50] (A) {};
|
||||
\node[mycylinder, above=of A,fill=\filllcolor!30] (B) {};
|
||||
\node[mycylinder, above=of B,fill=\filllcolor!10] (C) {};
|
||||
\fill[\filllcolor!50!black]($(C.west)!0.12!(C.east)$)circle(3pt);
|
||||
\fill[\filllcolor!50!black]($(B.west)!0.12!(B.east)$)circle(3pt);
|
||||
\fill[\filllcolor!50!black]($(A.west)!0.12!(A.east)$)circle(3pt);
|
||||
\end{scope}
|
||||
}
|
||||
}
|
||||
}
|
||||
\tikzset{pics/brain/.style = {
|
||||
code = {
|
||||
\pgfkeys{/channel/.cd, #1}
|
||||
\begin{scope}[local bounding box=BRAIN,scale=\scalefac, every node/.append style={transform shape}]
|
||||
\fill[fill=\filllcolor!50](0.1,-0.5)to[out=0,in=180](0.33,-0.5)
|
||||
to[out=0,in=270](0.45,-0.38)to(0.45,-0.18)
|
||||
to[out=40,in=240](0.57,-0.13)to[out=110,in=310](0.52,-0.05)
|
||||
to[out=130,in=290](0.44,0.15)to[out=90,in=340,distance=8](0.08,0.69)
|
||||
to[out=160,in=80](-0.42,-0.15)to (-0.48,-0.7)to(0.07,-0.7)to(0.1,-0.5)
|
||||
(-0.10,-0.42)to[out=310,in=180](0.1,-0.5);
|
||||
\draw[draw=\drawcolor,line width=\Linewidth](0.1,-0.5)to[out=0,in=180](0.33,-0.5)
|
||||
to[out=0,in=270](0.45,-0.38)to(0.45,-0.18)
|
||||
to[out=40,in=240](0.57,-0.13)to[out=110,in=310](0.52,-0.05)
|
||||
to[out=130,in=290](0.44,0.15)to[out=90,in=340,distance=8](0.08,0.69)
|
||||
(-0.42,-0.15)to (-0.48,-0.7)
|
||||
(0.07,-0.7)to(0.1,-0.5)
|
||||
(-0.10,-0.42)to[out=310,in=180](0.1,-0.5);
|
||||
\draw[fill=\filllcolor,line width=\Linewidth](-0.3,-0.10)to(0.08,0.60)
|
||||
to[out=60,in=50,distance=3](-0.1,0.69)to[out=160,in=80](-0.26,0.59)to[out=170,in=90](-0.46,0.42)
|
||||
to[out=170,in=110](-0.54,0.25)to[out=210,in=150](-0.54,0.04)
|
||||
to[out=240,in=130](-0.52,-0.1)to[out=300,in=240]cycle;
|
||||
\draw[fill=\filllcolor,line width=\Linewidth]
|
||||
(-0.04,0.64)to[out=120,in=0](-0.1,0.69)(-0.19,0.52)to[out=120,in=330](-0.26,0.59)
|
||||
(-0.4,0.33)to[out=150,in=280](-0.46,0.42)
|
||||
%
|
||||
\scoped[on background layer]
|
||||
\node[draw=BackLine,inner xsep=4mm,inner ysep=6mm,yshift=2mm,
|
||||
fill=BackColor!80,fit=(B1)(B2)(B3),line width=0.75pt](BB1){};
|
||||
\node[below=2pt of BB1.north,anchor=north]{Definition Phase};
|
||||
(-0.44,-0.03)to[bend left=30](-0.34,-0.04)
|
||||
(-0.33,0.08)to[bend left=40](-0.37,0.2) (-0.37,0.12)to[bend left=40](-0.45,0.14)
|
||||
(-0.26,0.2)to[bend left=30](-0.24,0.13)
|
||||
(-0.16,0.32)to[bend right=30](-0.27,0.3)to[bend right=30](-0.29,0.38)
|
||||
(-0.13,0.49)to[bend left=30](-0.04,0.51);
|
||||
|
||||
\draw[rounded corners=0.8pt,\drawcircle,-{Circle[fill=\filllcirclecolor,length=2.5pt]}](-0.23,0.03)--(-0.15,-0.03)--(-0.19,-0.18)--(-0.04,-0.28);
|
||||
\draw[rounded corners=0.8pt,\drawcircle,-{Circle[fill=\filllcirclecolor,length=2.5pt]}](-0.17,0.13)--(-0.04,0.05)--(-0.06,-0.06)--(0.14,-0.11);
|
||||
\draw[rounded corners=0.8pt,\drawcircle,-{Circle[fill=\filllcirclecolor,length=2.5pt]}](-0.12,0.23)--(0.31,0.0);
|
||||
\draw[rounded corners=0.8pt,\drawcircle,-{Circle[fill=\filllcirclecolor,length=2.5pt]}](-0.07,0.32)--(0.06,0.26)--(0.16,0.33)--(0.34,0.2);
|
||||
\draw[rounded corners=0.8pt,\drawcircle,-{Circle[fill=\filllcirclecolor,length=2.5pt]}](-0.01,0.43)--(0.06,0.39)--(0.18,0.51)--(0.31,0.4);
|
||||
\end{scope}
|
||||
}
|
||||
}
|
||||
}
|
||||
\tikzset{pics/brainMEM/.style = {
|
||||
code = {
|
||||
\pgfkeys{/channel/.cd, #1}
|
||||
\begin{scope}[local bounding box=BRAIN,scale=\scalefac, every node/.append style={transform shape}]
|
||||
\fill[fill=\filllcolor!50](0.1,-0.5)to[out=0,in=180](0.33,-0.5)%
|
||||
to[out=0,in=270](0.45,-0.38)to(0.45,-0.18)
|
||||
to[out=40,in=240](0.57,-0.13)to[out=110,in=310](0.52,-0.05)
|
||||
to[out=130,in=290](0.44,0.15)to[out=90,in=340,distance=8](0.08,0.69)
|
||||
to[out=160,in=80](-0.42,-0.15)to (-0.48,-0.7)to(0.07,-0.7)to(0.1,-0.5)
|
||||
(-0.10,-0.42)to[out=310,in=180](0.1,-0.5);
|
||||
\draw[draw=\drawcolor,line width=\Linewidth](0.1,-0.5)to[out=0,in=180](0.33,-0.5)
|
||||
to[out=0,in=270](0.45,-0.38)to(0.45,-0.18)
|
||||
to[out=40,in=240](0.57,-0.13)to[out=110,in=310](0.52,-0.05)
|
||||
to[out=130,in=290](0.44,0.15)to[out=90,in=340,distance=8](0.08,0.69)
|
||||
(-0.42,-0.15)to (-0.48,-0.7)
|
||||
(0.07,-0.7)to(0.1,-0.5)
|
||||
(-0.10,-0.42)to[out=310,in=180](0.1,-0.5);
|
||||
%
|
||||
\node[Box,node distance=1.5,fill=BrownL,draw=BrownLine,right=of B3](B4){Load Data};
|
||||
\node[Box,fill=BrownL,draw=BrownLine,right=of B4](B5){Run Graph};
|
||||
\node[Box,fill=BrownL,draw=BrownLine,right=of B5](B6){Get Results};
|
||||
%
|
||||
\scoped[on background layer]
|
||||
\node[draw=GreenLine,inner xsep=4mm,inner ysep=6mm,yshift=2mm,
|
||||
fill=GreenL!20,fit=(B4)(B5)(B6),line width=0.75pt](BB2){};
|
||||
\node[below=2pt of BB2.north,anchor=north]{Execution Phase};
|
||||
%
|
||||
\foreach \x/\y in{1/2,2/3,3/4,4/5,5/6}
|
||||
\draw[-latex,Line](B\x)--(B\y);
|
||||
\node[draw=\drawcolor,fill=\filllcirclecolor,line width=\Linewidth,rounded corners=3pt,minimum size=8mm](MR)at(-0.350,0.31){};
|
||||
\node[draw=\drawcolor,fill=white,line width=1.5*\Linewidth,circle,inner sep=1pt,minimum size=2mm]
|
||||
at($(MR.south)+(0,0.25)$){};
|
||||
\node[fill=\filllcolor!50!blue!50,draw=\drawcolor,line width=\Linewidth,rectangle,anchor=north,
|
||||
minimum width=5mm](MMR)at(MR.north){};
|
||||
\draw[draw=\drawcolor,line width=\Linewidth](MMR.120)--(MMR.240);
|
||||
\node[fill=black,minimum size=0.9mm,inner sep=1pt]at($(MMR.west)!0.75!(MMR.east)$){};
|
||||
\end{scope}
|
||||
}
|
||||
}
|
||||
}
|
||||
\pgfkeys{
|
||||
/channel/.cd,
|
||||
Depth/.store in=\Depth,
|
||||
Height/.store in=\Height,
|
||||
Width/.store in=\Width,
|
||||
filllcirclecolor/.store in=\filllcirclecolor,
|
||||
filllcolor/.store in=\filllcolor,
|
||||
drawcolor/.store in=\drawcolor,
|
||||
drawcircle/.store in=\drawcircle,
|
||||
scalefac/.store in=\scalefac,
|
||||
Linewidth/.store in=\Linewidth,
|
||||
picname/.store in=\picname,
|
||||
filllcolor=BrownLine,
|
||||
filllcirclecolor=violet!20,
|
||||
drawcolor=red,
|
||||
drawcircle=violet,
|
||||
scalefac=1,
|
||||
Linewidth=0.5pt,
|
||||
Depth=0.2,
|
||||
Height=0.5,
|
||||
Width=0.25,
|
||||
picname=C
|
||||
}
|
||||
|
||||
\node[Box](B1){};
|
||||
\coordinate(GO1)at($(B1.north west)!0.38!(B1.north east)$);
|
||||
\coordinate(T1)at($(GO1)!0.5!(B1.south east)$);
|
||||
\coordinate(I1)at($(B1.west)!0.21!(B1.east)$);
|
||||
\node[align=center]at(T1){Define\\ Operations};
|
||||
%\draw[dashed,RedLine, line width=0.75pt,](GO1)--(GO1|-B1.south west);
|
||||
\node[Box,fill=none]{};
|
||||
\pic[shift={(0.05,0.11)}] at (I1){interpreter={scalefac=0.38,picname=1,
|
||||
filllcolor=cyan!30!, Linewidth=1.5pt,filllcirclecolor=orange}};
|
||||
%Declare Variables
|
||||
\node[Box,right=of B1](B2){};
|
||||
\coordinate(GO2)at($(B2.north west)!0.4!(B2.north east)$);
|
||||
%\fill[fill=BlueL!90](B2.south west)rectangle(GO2);
|
||||
\coordinate(T2)at($(GO2)!0.5!(B2.south east)$);
|
||||
\coordinate(I2)at($(B2.west)!0.24!(B2.east)$);
|
||||
\node[align=center]at(T2){Declare\\ Variables};
|
||||
%\draw[dashed,BlueLine, line width=0.75pt,](GO2)--(GO2|-B2.south west);
|
||||
\node[Box,right=of B1,fill=none]{};
|
||||
\pic[shift={(0,0)}] at (I2){brainMEM={scalefac=0.68,drawcolor=black,
|
||||
filllcirclecolor=green!70!black!30,picname=1,filllcolor=orange!30!, Linewidth=0.75pt}};
|
||||
%Build Graph
|
||||
\node[Box,right=of B2](B3){};
|
||||
\coordinate(GO3)at($(B3.north west)!0.4!(B3.north east)$);
|
||||
%\fill[fill=BlueL!90](B3.south west)rectangle(GO3);
|
||||
\coordinate(T3)at($(GO3)!0.5!(B3.south east)$);
|
||||
\coordinate(I3)at($(B3.west)!0.22!(B3.east)$);
|
||||
\node[align=center]at(T3){Build\\ Graph};
|
||||
%\draw[dashed,BlueLine, line width=0.75pt,](GO3)--(GO3|-B3.south west);
|
||||
\node[Box,right=of B2,fill=none](B3){};
|
||||
\pic[shift={(0,0)}] at (I3){brain={scalefac=0.65,picname=1,drawcolor=black,filllcolor=orange!30!, Linewidth=0.65pt}};
|
||||
%Load Data
|
||||
\node[Box2,right=1.5 of B3](B4){};
|
||||
\coordinate(GO4)at($(B4.north west)!0.34!(B4.north east)$);
|
||||
%\fill[fill=BlueL!90](B3.south west)rectangle(GO3);
|
||||
\coordinate(T4)at($(GO4)!0.5!(B4.south east)$);
|
||||
\coordinate(I4)at($(B4.west)!0.22!(B4.east)$);
|
||||
\node[align=center]at(T4){Load\\ Data};
|
||||
%\draw[dashed,BlueLine, line width=0.75pt,](GO4)--(GO4|-B4.south west);
|
||||
\node[Box2,right=1.5 of B3,fill=none](B4){};
|
||||
\pic[shift={(0,-0.33)}] at (I4){data={scalefac=0.3,picname=1,filllcolor=red, Linewidth=0.6pt}};
|
||||
%Run Graph
|
||||
\node[Box2,right=of B4](B5){};
|
||||
\coordinate(GO5)at($(B5.north west)!0.34!(B5.north east)$);
|
||||
\coordinate(T5)at($(GO5)!0.5!(B5.south east)$);
|
||||
\coordinate(I5)at($(B5.west)!0.24!(B5.east)$);
|
||||
\node[align=center]at(T5){Run\\ Graph};
|
||||
%\draw[dashed,RedLine, line width=0.75pt,](GO5)--(GO5|-B5.south west);
|
||||
\node[Box2,right=of B4,fill=none](B5){};
|
||||
\pic[shift={(0,0)}] at (I5){cpu={scalefac=0.3,picname=1,filllcolor=VioletLine, Linewidth=0.7pt}};
|
||||
%Get Results
|
||||
\node[Box2,right=of B5](B6){};
|
||||
\coordinate(GO6)at($(B6.north west)!0.4!(B6.north east)$);
|
||||
\coordinate(T6)at($(GO6)!0.5!(B6.south east)$);
|
||||
\coordinate(I6)at($(B6.west)!0.22!(B6.east)$);
|
||||
\node[align=center]at(T6){Get\\ Results};
|
||||
%\draw[dashed,RedLine, line width=0.75pt,](GO6)--(GO6|-B6.south west);
|
||||
\node[Box2,right=of B5,fill=none](B6){};
|
||||
\begin{scope}[shift={($(I6)+(-0.25,-0.4)$)},scale=0.7, every node/.append style={transform shape}]
|
||||
\pic[shift={(0,0)}] at (0,0){graph3D={filllcirclecolor=black!60,scalefac=0.5,picname=1,drawcolor=black,filllcolor=red,Height=0.5,Linewidth=1.25pt}};
|
||||
\pic[shift={(0.33,0)}] at (0,0){graph3D={filllcirclecolor=none,scalefac=0.5,picname=2,drawcolor=black,filllcolor=blue,Height=1,Linewidth=1.25pt}};
|
||||
\pic[shift={(0.66,0)}] at (0,0){graph3D={filllcirclecolor=none,scalefac=0.5,picname=3,drawcolor=black,filllcolor=green,Height=0.25,Linewidth=1.25pt}};
|
||||
\pic[shift={(0.99,0)}] at (0,0){graph3D={filllcirclecolor=none,scalefac=0.5,picname=4,drawcolor=black,filllcolor=orange,Height=0.75,Linewidth=1.25pt}};
|
||||
\end{scope}
|
||||
|
||||
%arrows
|
||||
\foreach \i in {1,2,3,4,5}{
|
||||
\pgfmathtruncatemacro{\x}{\i + 1}
|
||||
\draw[LineA](B\i)--coordinate[pos=0.3](SR\i)(B\x);
|
||||
}
|
||||
\begin{scope}[on background layer]
|
||||
\node[draw=orange,fit=(B1)(B3),inner xsep=4mm,inner ysep=7mm,yshift=3mm,
|
||||
fill=orange!05](F1){};
|
||||
\node[font=\usefont{T1}{phv}{b}{n}\small,below=1pt of F1.north]{Definition Phase};
|
||||
\node[draw=GreenLine,fit=(B4)(B6),inner xsep=4mm,inner ysep=7mm,yshift=3mm,
|
||||
fill=green!03](F2){};
|
||||
\node[font=\usefont{T1}{phv}{b}{n}\small,below=1pt of F2.north]{Execution Phase};
|
||||
\end{scope}
|
||||
\end{tikzpicture}
|
||||
|
||||
```
|
||||
|
||||
:::
|
||||
|
||||
@@ -30,14 +30,14 @@ class ModelSpec:
|
||||
model_size: Optional[Q_] = None # For models defined by size (DLRM)
|
||||
|
||||
def __post_init__(self):
|
||||
\"\"\"Validate model specs: correct dimension type first, then positive value.\"\"\"
|
||||
"""Validate model specs: correct dimension type first, then positive value."""
|
||||
from .constants import ureg
|
||||
if self.parameters is not None:
|
||||
if not self.parameters.is_compatible_with(ureg.count):
|
||||
raise pint.DimensionalityError(self.parameters.units, ureg.count,
|
||||
extra_msg=f" — {self.name}.parameters must be in param/count units")
|
||||
if self.parameters.magnitude <= 0:
|
||||
raise ValueError(f\"{self.name}: parameters must be positive.\")
|
||||
raise ValueError(f"{self.name}: parameters must be positive.")
|
||||
if self.inference_flops is not None and not self.inference_flops.is_compatible_with(ureg.flop):
|
||||
raise pint.DimensionalityError(self.inference_flops.units, ureg.flop,
|
||||
extra_msg=f" — {self.name}.inference_flops must be in flop units")
|
||||
@@ -49,7 +49,7 @@ class ModelSpec:
|
||||
extra_msg=f" — {self.name}.model_size must be in byte units")
|
||||
|
||||
def size_in_bytes(self, precision: Q_ = BYTES_FP16) -> Q_:
|
||||
\"\"\"Calculates the weight storage size for a given precision.\"\"\"
|
||||
"""Calculates the weight storage size for a given precision."""
|
||||
from .constants import ureg
|
||||
if self.model_size:
|
||||
return self.model_size
|
||||
@@ -58,41 +58,41 @@ class ModelSpec:
|
||||
return (param_count * bpp * ureg.byte).to(ureg.byte)
|
||||
|
||||
def __repr__(self):
|
||||
return f\"Model({self.name}, {self.architecture})\"
|
||||
return f"Model({self.name}, {self.architecture})"
|
||||
|
||||
class GPT(Registry):
|
||||
\"\"\"GPT Model Family.\"\"\"
|
||||
GPT2 = ModelSpec(\"GPT-2 (1.5B)\", GPT2_PARAMS, \"Transformer\", layers=48)
|
||||
GPT3 = ModelSpec(\"GPT-3 (175B)\", GPT3_PARAMS, \"Transformer\", layers=96, training_ops=GPT3_TRAINING_OPS)
|
||||
GPT4 = ModelSpec(\"GPT-4\", GPT4_EST_PARAMS, \"Transformer\", layers=120, training_gpu_days=GPT4_TRAINING_GPU_DAYS)
|
||||
"""GPT Model Family."""
|
||||
GPT2 = ModelSpec("GPT-2 (1.5B)", GPT2_PARAMS, "Transformer", layers=48)
|
||||
GPT3 = ModelSpec("GPT-3 (175B)", GPT3_PARAMS, "Transformer", layers=96, training_ops=GPT3_TRAINING_OPS)
|
||||
GPT4 = ModelSpec("GPT-4", GPT4_EST_PARAMS, "Transformer", layers=120, training_gpu_days=GPT4_TRAINING_GPU_DAYS)
|
||||
|
||||
class Language(Registry):
|
||||
\"\"\"Large Language Models.\"\"\"
|
||||
"""Large Language Models."""
|
||||
# GPT is a nested registry here, but for list() we want to treat it specially or flatten it
|
||||
BERT_Base = ModelSpec(\"BERT-Base\", BERT_BASE_PARAMS, \"Transformer\", layers=12, inference_flops=22e9 * ureg.flop)
|
||||
BERT_Large = ModelSpec(\"BERT-Large\", BERT_LARGE_PARAMS, \"Transformer\", layers=24)
|
||||
Llama2_70B = ModelSpec(\"Llama-2-70B\", 70e9 * ureg.param, \"Transformer\", layers=80)
|
||||
Llama3_8B = ModelSpec(\"Llama-3.1-8B\", LLAMA3_8B_PARAMS, \"Transformer\", layers=32)
|
||||
Llama3_70B = ModelSpec(\"Llama-3.1-70B\", LLAMA3_70B_PARAMS, \"Transformer\", layers=80)
|
||||
Llama3_405B = ModelSpec(\"Llama-3.1-405B\", LLAMA3_405B_PARAMS, \"Transformer\", layers=126)
|
||||
BERT_Base = ModelSpec("BERT-Base", BERT_BASE_PARAMS, "Transformer", layers=12, inference_flops=22e9 * ureg.flop)
|
||||
BERT_Large = ModelSpec("BERT-Large", BERT_LARGE_PARAMS, "Transformer", layers=24)
|
||||
Llama2_70B = ModelSpec("Llama-2-70B", 70e9 * ureg.param, "Transformer", layers=80)
|
||||
Llama3_8B = ModelSpec("Llama-3.1-8B", LLAMA3_8B_PARAMS, "Transformer", layers=32)
|
||||
Llama3_70B = ModelSpec("Llama-3.1-70B", LLAMA3_70B_PARAMS, "Transformer", layers=80)
|
||||
Llama3_405B = ModelSpec("Llama-3.1-405B", LLAMA3_405B_PARAMS, "Transformer", layers=126)
|
||||
|
||||
class Recommendation(Registry):
|
||||
\"\"\"Recommendation Models.\"\"\"
|
||||
DLRM = ModelSpec(\"DLRM\", 25e9 * ureg.param, \"DLRM\", model_size=DLRM_MODEL_SIZE_FP32)
|
||||
"""Recommendation Models."""
|
||||
DLRM = ModelSpec("DLRM", 25e9 * ureg.param, "DLRM", model_size=DLRM_MODEL_SIZE_FP32)
|
||||
|
||||
class Vision(Registry):
|
||||
\"\"\"Image Classification and Detection.\"\"\"
|
||||
ALEXNET = ModelSpec(\"AlexNet\", ALEXNET_PARAMS, \"CNN\", layers=8)
|
||||
ResNet50 = ModelSpec(\"ResNet-50\", RESNET50_PARAMS, \"CNN\", layers=50, inference_flops=RESNET50_FLOPs)
|
||||
MobileNetV1 = ModelSpec(\"MobileNetV1\", 4.2e6 * ureg.param, \"CNN\", layers=28)
|
||||
MobileNetV2 = ModelSpec(\"MobileNetV2\", MOBILENETV2_PARAMS, \"CNN\", layers=54, inference_flops=MOBILENETV2_FLOPs)
|
||||
YOLOv8_Nano = ModelSpec(\"YOLOv8-Nano\", 3.2e6 * ureg.param, \"CNN\", layers=225, training_ops=8.7e9 * ureg.flop)
|
||||
"""Image Classification and Detection."""
|
||||
ALEXNET = ModelSpec("AlexNet", ALEXNET_PARAMS, "CNN", layers=8)
|
||||
ResNet50 = ModelSpec("ResNet-50", RESNET50_PARAMS, "CNN", layers=50, inference_flops=RESNET50_FLOPs)
|
||||
MobileNetV1 = ModelSpec("MobileNetV1", 4.2e6 * ureg.param, "CNN", layers=28)
|
||||
MobileNetV2 = ModelSpec("MobileNetV2", MOBILENETV2_PARAMS, "CNN", layers=54, inference_flops=MOBILENETV2_FLOPs)
|
||||
YOLOv8_Nano = ModelSpec("YOLOv8-Nano", 3.2e6 * ureg.param, "CNN", layers=225, training_ops=8.7e9 * ureg.flop)
|
||||
|
||||
class Tiny(Registry):
|
||||
\"\"\"Always-on and Embedded models.\"\"\"
|
||||
DS_CNN = ModelSpec(\"DS-CNN (KWS)\", KWS_DSCNN_PARAMS, \"CNN\", inference_flops=KWS_DSCNN_FLOPs)
|
||||
AnomalyDetector = ModelSpec(\"Anomaly Detector\", ANOMALY_MODEL_PARAMS, \"MLP\")
|
||||
WakeVision = ModelSpec(\"Wake Vision (Doorbell)\", 0.25e6 * ureg.param, \"CNN\", inference_flops=25e6 * ureg.flop)
|
||||
"""Always-on and Embedded models."""
|
||||
DS_CNN = ModelSpec("DS-CNN (KWS)", KWS_DSCNN_PARAMS, "CNN", inference_flops=KWS_DSCNN_FLOPs)
|
||||
AnomalyDetector = ModelSpec("Anomaly Detector", ANOMALY_MODEL_PARAMS, "MLP")
|
||||
WakeVision = ModelSpec("Wake Vision (Doorbell)", 0.25e6 * ureg.param, "CNN", inference_flops=25e6 * ureg.flop)
|
||||
|
||||
class Models(Registry):
|
||||
Language = Language
|
||||
@@ -113,7 +113,7 @@ class Models(Registry):
|
||||
|
||||
@classmethod
|
||||
def list(cls, sort_by: str = 'parameters', reverse: bool = False) -> List[ModelSpec]:
|
||||
\"\"\"Consolidated list of all models from all domains.\"\"\"
|
||||
"""Consolidated list of all models from all domains."""
|
||||
all_items = []
|
||||
# Flatten the categories
|
||||
all_items.extend(cls.GPT.list())
|
||||
|
||||
Reference in New Issue
Block a user