\hypertarget{classnntrainer_1_1IterationQueue}{}\doxysection{nntrainer\+::Iteration\+Queue Class Reference}
\label{classnntrainer_1_1IterationQueue}\index{nntrainer::IterationQueue@{nntrainer::IterationQueue}}


\mbox{\hyperlink{classnntrainer_1_1Iteration}{Iteration}} queue that owns the buffer for input / labels.  




{\ttfamily \#include $<$iteration\+\_\+queue.\+h$>$}

\doxysubsection*{Public Member Functions}
\begin{DoxyCompactItemize}
\item 
\mbox{\hyperlink{classnntrainer_1_1IterationQueue_adf862a526a619bf73ff6784667d44ba4}{Iteration\+Queue}} (unsigned int num\+\_\+slots, const std\+::vector$<$ ml\+::train\+::\+Tensor\+Dim $>$ \&input\+\_\+dims, const std\+::vector$<$ ml\+::train\+::\+Tensor\+Dim $>$ \&label\+\_\+dims)
\begin{DoxyCompactList}\small\item\em Construct a new \mbox{\hyperlink{classnntrainer_1_1Iteration}{Iteration}} Queue object. \end{DoxyCompactList}\item 
\mbox{\hyperlink{classnntrainer_1_1IterationQueue_a2c83807c6a10973b2dd8bb2b27766323}{$\sim$\+Iteration\+Queue}} ()
\begin{DoxyCompactList}\small\item\em Destroy the \mbox{\hyperlink{classnntrainer_1_1Iteration}{Iteration}} Queue object. \end{DoxyCompactList}\item 
\mbox{\hyperlink{classnntrainer_1_1ScopedView}{Scoped\+View}}$<$ \mbox{\hyperlink{classnntrainer_1_1Sample}{Sample}} $>$ \mbox{\hyperlink{classnntrainer_1_1IterationQueue_a90ae5200e1fa9338d09c4ca0eea965a3}{request\+Empty\+Slot}} ()
\begin{DoxyCompactList}\small\item\em request empty sample from the queue. \end{DoxyCompactList}\item 
\mbox{\hyperlink{classnntrainer_1_1ScopedView}{Scoped\+View}}$<$ \mbox{\hyperlink{classnntrainer_1_1Iteration}{Iteration}} $>$ \mbox{\hyperlink{classnntrainer_1_1IterationQueue_a40e56c8d26e7a7f22b01d2ee211f8d22}{request\+Filled\+Slot}} ()
\begin{DoxyCompactList}\small\item\em request filled iteration from the queue. \end{DoxyCompactList}\item 
unsigned int \mbox{\hyperlink{classnntrainer_1_1IterationQueue_a6d494e75a203146ccf30780afbd4114f}{slots}} ()
\begin{DoxyCompactList}\small\item\em get slot size, slot size is number of batches inside the queue \end{DoxyCompactList}\item 
unsigned int \mbox{\hyperlink{classnntrainer_1_1IterationQueue_a1d44c25118e68ebf45023c775602b805}{batch}} ()
\begin{DoxyCompactList}\small\item\em get size of batch for one iteration \end{DoxyCompactList}\item 
void \mbox{\hyperlink{classnntrainer_1_1IterationQueue_aa52e3027551ac85bd981ed41239147be}{notify\+End\+Of\+Request\+Empty}} ()
\begin{DoxyCompactList}\small\item\em notify\+End\+Of\+Request, when the producing by request\+Empty\+Slot has finished. \end{DoxyCompactList}\end{DoxyCompactItemize}


\doxysubsection{Detailed Description}
\mbox{\hyperlink{classnntrainer_1_1Iteration}{Iteration}} queue that owns the buffer for input / labels. 


\begin{DoxyItemize}
\item \mbox{\hyperlink{classnntrainer_1_1IterationQueue_a90ae5200e1fa9338d09c4ca0eea965a3}{request\+Empty\+Slot()}} will give a Scoped\+View$<$sample$>$ Destructing the returned object will notify the iteration that is done filling the sample. Once iteration is done filling, it will internally call Iteration\+Queue\+::mark\+Filled();
\item \mbox{\hyperlink{classnntrainer_1_1IterationQueue_a40e56c8d26e7a7f22b01d2ee211f8d22}{request\+Filled\+Slot()}} will give a Scoped\+View$<$\+Iteration$>$ Destructing this will notify the queue that is done used (internally calls Iteration\+Queue\+::mark\+Empty())
\end{DoxyItemize}

For an iteration there can be four state.
\begin{DoxyEnumerate}
\item The buffer is empty, waiting to be filled (will be in empty\+\_\+q)
\item The buffer is being filled sample by sample, waiting to be marked as filled.
\item The buffer is filled, waiting to be served (will be in filled\+\_\+q)
\item The buffer is being served, waiting to be marked as emptied. \begin{DoxyRefDesc}{Todo}
\item[\mbox{\hyperlink{todo__todo000029}{Todo}}]apply this to the databuffer 

handle error case\+: 1. when Scoped\+View$<$\+Sample$>$ has met throw
\begin{DoxyEnumerate}
\item when Scoped\+View$<$\+Iteration$>$ has met throw 
\end{DoxyEnumerate}\end{DoxyRefDesc}

\end{DoxyEnumerate}

Definition at line 199 of file iteration\+\_\+queue.\+h.



\doxysubsection{Constructor \& Destructor Documentation}
\mbox{\Hypertarget{classnntrainer_1_1IterationQueue_adf862a526a619bf73ff6784667d44ba4}\label{classnntrainer_1_1IterationQueue_adf862a526a619bf73ff6784667d44ba4}} 
\index{nntrainer::IterationQueue@{nntrainer::IterationQueue}!IterationQueue@{IterationQueue}}
\index{IterationQueue@{IterationQueue}!nntrainer::IterationQueue@{nntrainer::IterationQueue}}
\doxysubsubsection{\texorpdfstring{IterationQueue()}{IterationQueue()}}
{\footnotesize\ttfamily nntrainer\+::\+Iteration\+Queue\+::\+Iteration\+Queue (\begin{DoxyParamCaption}\item[{unsigned int}]{num\+\_\+slots,  }\item[{const std\+::vector$<$ ml\+::train\+::\+Tensor\+Dim $>$ \&}]{input\+\_\+dims,  }\item[{const std\+::vector$<$ ml\+::train\+::\+Tensor\+Dim $>$ \&}]{label\+\_\+dims }\end{DoxyParamCaption})}



Construct a new \mbox{\hyperlink{classnntrainer_1_1Iteration}{Iteration}} Queue object. 

\begin{DoxyNote}{Note}
input\+\_\+dimension and label\+\_\+dimension should include the batch, if \mbox{\hyperlink{classnntrainer_1_1IterationQueue_a1d44c25118e68ebf45023c775602b805}{Iteration\+Queue\+::batch()}} is zero, it means it\textquotesingle{}s invalid 
\end{DoxyNote}

\begin{DoxyParams}{Parameters}
{\em num\+\_\+slots} & number of slots this iteration queue will allocate, it should be buffersize/batchsize \\
\hline
{\em input\+\_\+dims} & input dimensions \\
\hline
{\em label\+\_\+dims} & label dimensions \\
\hline
\end{DoxyParams}


Definition at line 24 of file iteration\+\_\+queue.\+cpp.

\mbox{\Hypertarget{classnntrainer_1_1IterationQueue_a2c83807c6a10973b2dd8bb2b27766323}\label{classnntrainer_1_1IterationQueue_a2c83807c6a10973b2dd8bb2b27766323}} 
\index{nntrainer::IterationQueue@{nntrainer::IterationQueue}!````~IterationQueue@{$\sim$IterationQueue}}
\index{````~IterationQueue@{$\sim$IterationQueue}!nntrainer::IterationQueue@{nntrainer::IterationQueue}}
\doxysubsubsection{\texorpdfstring{$\sim$IterationQueue()}{~IterationQueue()}}
{\footnotesize\ttfamily nntrainer\+::\+Iteration\+Queue\+::$\sim$\+Iteration\+Queue (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption})}



Destroy the \mbox{\hyperlink{classnntrainer_1_1Iteration}{Iteration}} Queue object. 

if an iteration is not included in either empty\+\_\+q or filled\+\_\+q, that means it\textquotesingle{}s either being filled or being served. Which means it will be dangerous to destroy {\itshape this}, we might want to wait on the destructor if we can assure this can stay no except

Definition at line 41 of file iteration\+\_\+queue.\+cpp.

Here is the call graph for this function\+:
\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=350pt]{classnntrainer_1_1IterationQueue_a2c83807c6a10973b2dd8bb2b27766323_cgraph}
\end{center}
\end{figure}


\doxysubsection{Member Function Documentation}
\mbox{\Hypertarget{classnntrainer_1_1IterationQueue_a1d44c25118e68ebf45023c775602b805}\label{classnntrainer_1_1IterationQueue_a1d44c25118e68ebf45023c775602b805}} 
\index{nntrainer::IterationQueue@{nntrainer::IterationQueue}!batch@{batch}}
\index{batch@{batch}!nntrainer::IterationQueue@{nntrainer::IterationQueue}}
\doxysubsubsection{\texorpdfstring{batch()}{batch()}}
{\footnotesize\ttfamily unsigned int nntrainer\+::\+Iteration\+Queue\+::batch (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}}



get size of batch for one iteration 

\begin{DoxyReturn}{Returns}
unsigned int size of batch 
\end{DoxyReturn}


Definition at line 253 of file iteration\+\_\+queue.\+h.

\mbox{\Hypertarget{classnntrainer_1_1IterationQueue_aa52e3027551ac85bd981ed41239147be}\label{classnntrainer_1_1IterationQueue_aa52e3027551ac85bd981ed41239147be}} 
\index{nntrainer::IterationQueue@{nntrainer::IterationQueue}!notifyEndOfRequestEmpty@{notifyEndOfRequestEmpty}}
\index{notifyEndOfRequestEmpty@{notifyEndOfRequestEmpty}!nntrainer::IterationQueue@{nntrainer::IterationQueue}}
\doxysubsubsection{\texorpdfstring{notifyEndOfRequestEmpty()}{notifyEndOfRequestEmpty()}}
{\footnotesize\ttfamily void nntrainer\+::\+Iteration\+Queue\+::notify\+End\+Of\+Request\+Empty (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption})}



notify\+End\+Of\+Request, when the producing by request\+Empty\+Slot has finished. 

\begin{DoxyNote}{Note}
It is important that the owner of this class must ensure that there will be no more request\+Empty\+Slot call after this. This means that, in case of multiple workers, the manager of the worker(producer) must know every producer has finished. and call this function other than each worker call this function. 
\end{DoxyNote}
we have to defined ordering of having stop\+\_\+requested -\/$>$ push nullptr to filled\+\_\+q -\/$>$ stopped so when the case of changing to stopped it has to push nullptr to empty\+\_\+q, and filled\+\_\+q to wake them up and stop. this has potential cases that weren\textquotesingle{}t considered. let\textquotesingle{}s change this to a simpler mechanisms to wait on conditional variable.

below is useful information when debugging iteration queue, but there will be too much log if we turn the log on. so leaving it as a comment for now.

Definition at line 129 of file iteration\+\_\+queue.\+cpp.

\mbox{\Hypertarget{classnntrainer_1_1IterationQueue_a90ae5200e1fa9338d09c4ca0eea965a3}\label{classnntrainer_1_1IterationQueue_a90ae5200e1fa9338d09c4ca0eea965a3}} 
\index{nntrainer::IterationQueue@{nntrainer::IterationQueue}!requestEmptySlot@{requestEmptySlot}}
\index{requestEmptySlot@{requestEmptySlot}!nntrainer::IterationQueue@{nntrainer::IterationQueue}}
\doxysubsubsection{\texorpdfstring{requestEmptySlot()}{requestEmptySlot()}}
{\footnotesize\ttfamily \mbox{\hyperlink{classnntrainer_1_1ScopedView}{Scoped\+View}}$<$ \mbox{\hyperlink{classnntrainer_1_1Sample}{Sample}} $>$ nntrainer\+::\+Iteration\+Queue\+::request\+Empty\+Slot (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption})}



request empty sample from the queue. 

\begin{DoxyNote}{Note}
User must check if \mbox{\hyperlink{classnntrainer_1_1ScopedView}{Scoped\+View}} actually has a value by calling \mbox{\hyperlink{classnntrainer_1_1ScopedView_a5711bee3adb59e4a6c2360dcfa23996f}{Scoped\+View\+::is\+Empty()}} 
\end{DoxyNote}
\begin{DoxyReturn}{Returns}
Scoped\+View$<$\+Sample$>$ sample view. \mbox{\hyperlink{classnntrainer_1_1ScopedView_a5711bee3adb59e4a6c2360dcfa23996f}{Scoped\+View\+::is\+Empty()}} == true if there is no more data coming. Destroying the returned object will signal the queue that the sample is filled. 
\end{DoxyReturn}
below is useful information when debugging iteration queue, but there will be too much log if we turn the log on. so leaving it as a comment for now.

Definition at line 54 of file iteration\+\_\+queue.\+cpp.

\mbox{\Hypertarget{classnntrainer_1_1IterationQueue_a40e56c8d26e7a7f22b01d2ee211f8d22}\label{classnntrainer_1_1IterationQueue_a40e56c8d26e7a7f22b01d2ee211f8d22}} 
\index{nntrainer::IterationQueue@{nntrainer::IterationQueue}!requestFilledSlot@{requestFilledSlot}}
\index{requestFilledSlot@{requestFilledSlot}!nntrainer::IterationQueue@{nntrainer::IterationQueue}}
\doxysubsubsection{\texorpdfstring{requestFilledSlot()}{requestFilledSlot()}}
{\footnotesize\ttfamily \mbox{\hyperlink{classnntrainer_1_1ScopedView}{Scoped\+View}}$<$ \mbox{\hyperlink{classnntrainer_1_1Iteration}{Iteration}} $>$ nntrainer\+::\+Iteration\+Queue\+::request\+Filled\+Slot (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption})}



request filled iteration from the queue. 

\begin{DoxyNote}{Note}
User must check if \mbox{\hyperlink{classnntrainer_1_1ScopedView}{Scoped\+View}} actually has a value by calling \mbox{\hyperlink{classnntrainer_1_1ScopedView_a5711bee3adb59e4a6c2360dcfa23996f}{Scoped\+View\+::is\+Empty()}} 
\end{DoxyNote}
\begin{DoxyReturn}{Returns}
Scoped\+View$<$\+Iteration$>$ Ieration view. \mbox{\hyperlink{classnntrainer_1_1ScopedView_a5711bee3adb59e4a6c2360dcfa23996f}{Scoped\+View\+::is\+Empty()}} == true if there is no more data coming. Destroying the returned object will signal the queue that the sample is done using. 
\end{DoxyReturn}
below is useful information when debugging iteration queue, but there will be too much log if we turn the log on. so leaving it as a comment for now.

Definition at line 93 of file iteration\+\_\+queue.\+cpp.

Here is the call graph for this function\+:
\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=350pt]{classnntrainer_1_1IterationQueue_a40e56c8d26e7a7f22b01d2ee211f8d22_cgraph}
\end{center}
\end{figure}
\mbox{\Hypertarget{classnntrainer_1_1IterationQueue_a6d494e75a203146ccf30780afbd4114f}\label{classnntrainer_1_1IterationQueue_a6d494e75a203146ccf30780afbd4114f}} 
\index{nntrainer::IterationQueue@{nntrainer::IterationQueue}!slots@{slots}}
\index{slots@{slots}!nntrainer::IterationQueue@{nntrainer::IterationQueue}}
\doxysubsubsection{\texorpdfstring{slots()}{slots()}}
{\footnotesize\ttfamily unsigned int nntrainer\+::\+Iteration\+Queue\+::slots (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}}



get slot size, slot size is number of batches inside the queue 

\begin{DoxyReturn}{Returns}
unsigned int num slot 
\end{DoxyReturn}


Definition at line 246 of file iteration\+\_\+queue.\+h.



The documentation for this class was generated from the following files\+:\begin{DoxyCompactItemize}
\item 
dataset/\mbox{\hyperlink{iteration__queue_8h}{iteration\+\_\+queue.\+h}}\item 
dataset/\mbox{\hyperlink{iteration__queue_8cpp}{iteration\+\_\+queue.\+cpp}}\end{DoxyCompactItemize}
