\hypertarget{classnntrainer_1_1OptimizedV2Planner}{}\doxysection{nntrainer\+::Optimized\+V2\+Planner Class Reference}
\label{classnntrainer_1_1OptimizedV2Planner}\index{nntrainer::OptimizedV2Planner@{nntrainer::OptimizedV2Planner}}


Optimized V2 Memory Planner provides the optimized plan for memory layout.  




{\ttfamily \#include $<$optimized\+\_\+v2\+\_\+planner.\+h$>$}



Inheritance diagram for nntrainer\+::Optimized\+V2\+Planner\+:
\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=247pt]{classnntrainer_1_1OptimizedV2Planner__inherit__graph}
\end{center}
\end{figure}


Collaboration diagram for nntrainer\+::Optimized\+V2\+Planner\+:
\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=247pt]{classnntrainer_1_1OptimizedV2Planner__coll__graph}
\end{center}
\end{figure}
\doxysubsection*{Public Member Functions}
\begin{DoxyCompactItemize}
\item 
\mbox{\hyperlink{classnntrainer_1_1OptimizedV2Planner_a4e3e42cef4cd0405eab91db85586af07}{Optimized\+V2\+Planner}} ()=default
\begin{DoxyCompactList}\small\item\em \mbox{\hyperlink{classnntrainer_1_1OptimizedV1Planner}{Optimized\+V1\+Planner}} destructor. \end{DoxyCompactList}\item 
size\+\_\+t \mbox{\hyperlink{classnntrainer_1_1OptimizedV2Planner_a89ddd97e1405978989c85c50d53e27c6}{plan\+Layout}} (const std\+::vector$<$ size\+\_\+t $>$ \&memory\+\_\+size, const std\+::vector$<$ std\+::pair$<$ unsigned int, unsigned int $>$$>$ \&memory\+\_\+validity, std\+::vector$<$ size\+\_\+t $>$ \&memory\+\_\+offset, std\+::vector$<$ bool $>$ \&memory\+\_\+is\+\_\+wgrad, size\+\_\+t n\+\_\+wgrad=0) const
\item 
const std\+::string \& \mbox{\hyperlink{classnntrainer_1_1OptimizedV2Planner_a357772f85388d8b9bcf6c345e2eae8ec}{get\+Type}} () const
\begin{DoxyCompactList}\small\item\em Get type of the planner. \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsection*{Static Public Attributes}
\begin{DoxyCompactItemize}
\item 
\mbox{\Hypertarget{classnntrainer_1_1OptimizedV2Planner_a73fecb2f1169903b0f1293a14edb6402}\label{classnntrainer_1_1OptimizedV2Planner_a73fecb2f1169903b0f1293a14edb6402}} 
static const std\+::string {\bfseries type} = \char`\"{}optimized\+\_\+v2\+\_\+planner\char`\"{}
\end{DoxyCompactItemize}


\doxysubsection{Detailed Description}
Optimized V2 Memory Planner provides the optimized plan for memory layout. 

optimized planner performs sharing of overlapping memory sharing upto certain extent 

Definition at line 45 of file optimized\+\_\+v2\+\_\+planner.\+h.



\doxysubsection{Constructor \& Destructor Documentation}
\mbox{\Hypertarget{classnntrainer_1_1OptimizedV2Planner_a4e3e42cef4cd0405eab91db85586af07}\label{classnntrainer_1_1OptimizedV2Planner_a4e3e42cef4cd0405eab91db85586af07}} 
\index{nntrainer::OptimizedV2Planner@{nntrainer::OptimizedV2Planner}!OptimizedV2Planner@{OptimizedV2Planner}}
\index{OptimizedV2Planner@{OptimizedV2Planner}!nntrainer::OptimizedV2Planner@{nntrainer::OptimizedV2Planner}}
\doxysubsubsection{\texorpdfstring{OptimizedV2Planner()}{OptimizedV2Planner()}}
{\footnotesize\ttfamily nntrainer\+::\+Optimized\+V2\+Planner\+::\+Optimized\+V2\+Planner (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [default]}}



\mbox{\hyperlink{classnntrainer_1_1OptimizedV1Planner}{Optimized\+V1\+Planner}} destructor. 



\doxysubsection{Member Function Documentation}
\mbox{\Hypertarget{classnntrainer_1_1OptimizedV2Planner_a357772f85388d8b9bcf6c345e2eae8ec}\label{classnntrainer_1_1OptimizedV2Planner_a357772f85388d8b9bcf6c345e2eae8ec}} 
\index{nntrainer::OptimizedV2Planner@{nntrainer::OptimizedV2Planner}!getType@{getType}}
\index{getType@{getType}!nntrainer::OptimizedV2Planner@{nntrainer::OptimizedV2Planner}}
\doxysubsubsection{\texorpdfstring{getType()}{getType()}}
{\footnotesize\ttfamily const std\+::string\& nntrainer\+::\+Optimized\+V2\+Planner\+::get\+Type (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption}) const\hspace{0.3cm}{\ttfamily [inline]}, {\ttfamily [virtual]}}



Get type of the planner. 

\begin{DoxyReturn}{Returns}
The type of the planner 
\end{DoxyReturn}


Implements \mbox{\hyperlink{classnntrainer_1_1MemoryPlanner_a7b35b512d91d9d3afb5f2cc8c2bdbecd}{nntrainer\+::\+Memory\+Planner}}.



Definition at line 71 of file optimized\+\_\+v2\+\_\+planner.\+h.

\mbox{\Hypertarget{classnntrainer_1_1OptimizedV2Planner_a89ddd97e1405978989c85c50d53e27c6}\label{classnntrainer_1_1OptimizedV2Planner_a89ddd97e1405978989c85c50d53e27c6}} 
\index{nntrainer::OptimizedV2Planner@{nntrainer::OptimizedV2Planner}!planLayout@{planLayout}}
\index{planLayout@{planLayout}!nntrainer::OptimizedV2Planner@{nntrainer::OptimizedV2Planner}}
\doxysubsubsection{\texorpdfstring{planLayout()}{planLayout()}}
{\footnotesize\ttfamily size\+\_\+t nntrainer\+::\+Optimized\+V2\+Planner\+::plan\+Layout (\begin{DoxyParamCaption}\item[{const std\+::vector$<$ size\+\_\+t $>$ \&}]{memory\+\_\+size,  }\item[{const std\+::vector$<$ std\+::pair$<$ unsigned int, unsigned int $>$$>$ \&}]{memory\+\_\+validity,  }\item[{std\+::vector$<$ size\+\_\+t $>$ \&}]{memory\+\_\+offset,  }\item[{std\+::vector$<$ bool $>$ \&}]{memory\+\_\+is\+\_\+wgrad,  }\item[{size\+\_\+t}]{n\+\_\+wgrad = {\ttfamily 0} }\end{DoxyParamCaption}) const\hspace{0.3cm}{\ttfamily [virtual]}}





The optimized v1 memory planner assigns memory to the requests whose validity starts first. The requested memories are sorted based on the ascending order of the start timestamps, and descending order using the end timestamps. The sorted memories are given increasing offset based on the memory size. At the end of each timestamp, invalid memories are freed, and offset updated for reuse. This planner allocates overlapping memory for all the required memories. create memory requests structure array for easier management

sort the memory requests with ascending order of start time first, and then end time

T\+O\+DO\+: try this

all the memories in use sorted by their assigned offset and size

iterate over the sorted requests and start allocation of the requests

remove expired memories and update offset

if there exists an expired memory with same size (not at the edge), reuse it

T\+O\+DO\+: reuse if memory size not exactly match

assign offset to the new request and push to queue

T\+O\+DO\+: We donot need to start from memeory\+\_\+req. We might find proper offset considering execution order

Implements \mbox{\hyperlink{classnntrainer_1_1MemoryPlanner_a9bc7139a759929d7d1323243bbdeefaa}{nntrainer\+::\+Memory\+Planner}}.



Definition at line 141 of file optimized\+\_\+v2\+\_\+planner.\+cpp.



The documentation for this class was generated from the following files\+:\begin{DoxyCompactItemize}
\item 
tensor/optimized\+\_\+v2\+\_\+planner.\+h\item 
tensor/\mbox{\hyperlink{optimized__v2__planner_8cpp}{optimized\+\_\+v2\+\_\+planner.\+cpp}}\end{DoxyCompactItemize}
