\hypertarget{app__context_8cpp}{}\doxysection{app\+\_\+context.\+cpp File Reference}
\label{app__context_8cpp}\index{app\_context.cpp@{app\_context.cpp}}


This file contains app context related functions and classes that manages the global configuration of the current environment.  


{\ttfamily \#include $<$dirent.\+h$>$}\newline
{\ttfamily \#include $<$dlfcn.\+h$>$}\newline
{\ttfamily \#include $<$iostream$>$}\newline
{\ttfamily \#include $<$sstream$>$}\newline
{\ttfamily \#include $<$string$>$}\newline
{\ttfamily \#include $<$vector$>$}\newline
{\ttfamily \#include $<$iniparser.\+h$>$}\newline
{\ttfamily \#include $<$app\+\_\+context.\+h$>$}\newline
{\ttfamily \#include $<$layer.\+h$>$}\newline
{\ttfamily \#include $<$nntrainer\+\_\+error.\+h$>$}\newline
{\ttfamily \#include $<$nntrainer\+\_\+log.\+h$>$}\newline
{\ttfamily \#include $<$optimizer.\+h$>$}\newline
{\ttfamily \#include $<$util\+\_\+func.\+h$>$}\newline
{\ttfamily \#include $<$adam.\+h$>$}\newline
{\ttfamily \#include $<$sgd.\+h$>$}\newline
{\ttfamily \#include $<$activation\+\_\+layer.\+h$>$}\newline
{\ttfamily \#include $<$addition\+\_\+layer.\+h$>$}\newline
{\ttfamily \#include $<$attention\+\_\+layer.\+h$>$}\newline
{\ttfamily \#include $<$bn\+\_\+layer.\+h$>$}\newline
{\ttfamily \#include $<$centroid\+\_\+knn.\+h$>$}\newline
{\ttfamily \#include $<$concat\+\_\+layer.\+h$>$}\newline
{\ttfamily \#include $<$constant\+\_\+derivative\+\_\+loss\+\_\+layer.\+h$>$}\newline
{\ttfamily \#include $<$conv1d\+\_\+layer.\+h$>$}\newline
{\ttfamily \#include $<$conv2d\+\_\+layer.\+h$>$}\newline
{\ttfamily \#include $<$cross\+\_\+entropy\+\_\+sigmoid\+\_\+loss\+\_\+layer.\+h$>$}\newline
{\ttfamily \#include $<$cross\+\_\+entropy\+\_\+softmax\+\_\+loss\+\_\+layer.\+h$>$}\newline
{\ttfamily \#include $<$dropout.\+h$>$}\newline
{\ttfamily \#include $<$embedding.\+h$>$}\newline
{\ttfamily \#include $<$fc\+\_\+layer.\+h$>$}\newline
{\ttfamily \#include $<$flatten\+\_\+layer.\+h$>$}\newline
{\ttfamily \#include $<$gru.\+h$>$}\newline
{\ttfamily \#include $<$grucell.\+h$>$}\newline
{\ttfamily \#include $<$identity\+\_\+layer.\+h$>$}\newline
{\ttfamily \#include $<$input\+\_\+layer.\+h$>$}\newline
{\ttfamily \#include $<$layer\+\_\+normalization\+\_\+layer.\+h$>$}\newline
{\ttfamily \#include $<$lr\+\_\+scheduler\+\_\+constant.\+h$>$}\newline
{\ttfamily \#include $<$lr\+\_\+scheduler\+\_\+exponential.\+h$>$}\newline
{\ttfamily \#include $<$lr\+\_\+scheduler\+\_\+step.\+h$>$}\newline
{\ttfamily \#include $<$lstm.\+h$>$}\newline
{\ttfamily \#include $<$lstmcell.\+h$>$}\newline
{\ttfamily \#include $<$mol\+\_\+attention\+\_\+layer.\+h$>$}\newline
{\ttfamily \#include $<$mse\+\_\+loss\+\_\+layer.\+h$>$}\newline
{\ttfamily \#include $<$multi\+\_\+head\+\_\+attention\+\_\+layer.\+h$>$}\newline
{\ttfamily \#include $<$multiout\+\_\+layer.\+h$>$}\newline
{\ttfamily \#include $<$permute\+\_\+layer.\+h$>$}\newline
{\ttfamily \#include $<$plugged\+\_\+layer.\+h$>$}\newline
{\ttfamily \#include $<$plugged\+\_\+optimizer.\+h$>$}\newline
{\ttfamily \#include $<$pooling2d\+\_\+layer.\+h$>$}\newline
{\ttfamily \#include $<$positional\+\_\+encoding\+\_\+layer.\+h$>$}\newline
{\ttfamily \#include $<$preprocess\+\_\+flip\+\_\+layer.\+h$>$}\newline
{\ttfamily \#include $<$preprocess\+\_\+l2norm\+\_\+layer.\+h$>$}\newline
{\ttfamily \#include $<$preprocess\+\_\+translate\+\_\+layer.\+h$>$}\newline
{\ttfamily \#include $<$reduce\+\_\+mean\+\_\+layer.\+h$>$}\newline
{\ttfamily \#include $<$rnn.\+h$>$}\newline
{\ttfamily \#include $<$rnncell.\+h$>$}\newline
{\ttfamily \#include $<$split\+\_\+layer.\+h$>$}\newline
{\ttfamily \#include $<$time\+\_\+dist.\+h$>$}\newline
{\ttfamily \#include $<$zoneout\+\_\+lstmcell.\+h$>$}\newline
\doxysubsection*{Namespaces}
\begin{DoxyCompactItemize}
\item 
 \mbox{\hyperlink{namespacenntrainer}{nntrainer}}
\end{DoxyCompactItemize}
\doxysubsection*{Functions}
\begin{DoxyCompactItemize}
\item 
\mbox{\Hypertarget{app__context_8cpp_aee3cdd9d26ee672f950360d35ed97cdf}\label{app__context_8cpp_aee3cdd9d26ee672f950360d35ed97cdf}} 
constexpr const char $\ast$ {\bfseries get\+Conf\+Path} ()
\item 
static void \mbox{\hyperlink{namespacenntrainer_a145a6299e379ef59c6470344684a6a94}{nntrainer\+::fini\+\_\+global\+\_\+context\+\_\+nntrainer}} (void) \+\_\+\+\_\+attribute\+\_\+\+\_\+((destructor))
\begin{DoxyCompactList}\small\item\em finialize global context \end{DoxyCompactList}\item 
static void \mbox{\hyperlink{namespacenntrainer_afc6e105048ea4ceca0fb54eba1f60115}{nntrainer\+::add\+\_\+default\+\_\+object}} (App\+Context \&ac)
\item 
\mbox{\Hypertarget{namespacenntrainer_a8f4ffd9ee0289266229b9dea5b03c3eb}\label{namespacenntrainer_a8f4ffd9ee0289266229b9dea5b03c3eb}} 
static void {\bfseries nntrainer\+::add\+\_\+extension\+\_\+object} (App\+Context \&ac)
\item 
\mbox{\Hypertarget{namespacenntrainer_ad7046419e29f532fc74e1a39296d5c6e}\label{namespacenntrainer_ad7046419e29f532fc74e1a39296d5c6e}} 
static void {\bfseries nntrainer\+::registerer} (App\+Context \&ac) noexcept
\item 
{\footnotesize template$<$size\+\_\+t I = 0, typename V , typename... Ts$>$ }\\std\+::enable\+\_\+if$<$ I==sizeof...(Ts), void $>$\+::type \mbox{\hyperlink{namespacenntrainer_adee2dd1c2fcdb8d0dd152a14600c9cba}{nntrainer\+::parse\+\_\+properties}} (V \&props, std\+::tuple$<$ Ts... $>$ \&tup)
\begin{DoxyCompactList}\small\item\em base case of iterate\+\_\+prop, iterate\+\_\+prop iterates the given tuple \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsection*{Variables}
\begin{DoxyCompactItemize}
\item 
\mbox{\Hypertarget{app__context_8cpp_a19deed47bf112acc1e2461ff69cffb84}\label{app__context_8cpp_a19deed47bf112acc1e2461ff69cffb84}} 
static std\+::string \mbox{\hyperlink{app__context_8cpp_a19deed47bf112acc1e2461ff69cffb84}{solib\+\_\+suffix}} = \char`\"{}.so\char`\"{}
\begin{DoxyCompactList}\small\item\em add \#ifdef across platform \end{DoxyCompactList}\item 
\mbox{\Hypertarget{app__context_8cpp_ac6c7ff54ec7ef42704511fc156c13711}\label{app__context_8cpp_ac6c7ff54ec7ef42704511fc156c13711}} 
static std\+::string {\bfseries layerlib\+\_\+suffix} = \char`\"{}layer.\+so\char`\"{}
\item 
\mbox{\Hypertarget{app__context_8cpp_aa18476c38542298d559b75923c33f4f6}\label{app__context_8cpp_aa18476c38542298d559b75923c33f4f6}} 
static std\+::string {\bfseries optimizerlib\+\_\+suffix} = \char`\"{}optimizer.\+so\char`\"{}
\item 
\mbox{\Hypertarget{app__context_8cpp_a46f5f1f5f7751bd63ba8cdc418d257b6}\label{app__context_8cpp_a46f5f1f5f7751bd63ba8cdc418d257b6}} 
static const std\+::string {\bfseries func\+\_\+tag} = \char`\"{}\mbox{[}App\+Context\mbox{]} \char`\"{}
\item 
\mbox{\Hypertarget{app__context_8cpp_a8fce9c46145ebdd341f4269fe9afcd1c}\label{app__context_8cpp_a8fce9c46145ebdd341f4269fe9afcd1c}} 
constexpr const char $\ast$ {\bfseries D\+E\+F\+A\+U\+L\+T\+\_\+\+C\+O\+N\+F\+\_\+\+P\+A\+TH} = \char`\"{}/etc/nntrainer.\+ini\char`\"{}
\item 
\mbox{\Hypertarget{namespacenntrainer_ac56e68f68ea95acd43ce84ef222e3913}\label{namespacenntrainer_ac56e68f68ea95acd43ce84ef222e3913}} 
std\+::mutex {\bfseries nntrainer\+::factory\+\_\+mutex}
\item 
\mbox{\Hypertarget{namespacenntrainer_a1709e60231ada08fc703cfff079c2bc4}\label{namespacenntrainer_a1709e60231ada08fc703cfff079c2bc4}} 
std\+::once\+\_\+flag {\bfseries nntrainer\+::global\+\_\+app\+\_\+context\+\_\+init\+\_\+flag}
\item 
{\footnotesize template$<$size\+\_\+t I = 0, typename V , typename... Ts$>$ }\\std\+::enable\+\_\+if$<$ I$<$ sizeof...(Ts), void $>$\+::type inline parse\+\_\+properties(V \&props, std\+::tuple$<$ Ts... $>$ \&tup) \{ std\+::string name=std\+::get$<$ I $>$tup);std\+::string prop=get\+Config(name);if(!prop.\+empty()) props.\+push\+\_\+back(name+\char`\"{}=\char`\"{}+prop);parse\+\_\+properties$<$ I+1 $>$props, tup);\}const std\+::vector$<$ std\+::string $>$ App\+Context\+::get\+Properties(void) \{ std\+::vector$<$ std\+::string $>$ properties;auto props=std\+::tuple(\char`\"{}memory\+\_\+swap\char`\"{}, \char`\"{}memory\+\_\+swap\+\_\+path\char`\"{});parse\+\_\+properties(properties, props);return properties;\}int App\+Context\+::register\+Layer(const std\+::string \&library\+\_\+path, const std\+::string \&base\+\_\+path) \{ const std\+::string full\+\_\+path=get\+Full\+Path(library\+\_\+path, base\+\_\+path);void $\ast$handle=dlopen(full\+\_\+path.\+c\+\_\+str(), R\+T\+L\+D\+\_\+\+L\+A\+ZY$\vert$R\+T\+L\+D\+\_\+\+L\+O\+C\+AL);const char $\ast$error\+\_\+msg=dlerror();$<$$<$ func\+\_\+tag$<$$<$ \char`\"{}open plugin failed, reason\+: \char`\"{}$<$$<$ error\+\_\+msg;nntrainer\+::\+Layer\+Pluggable $\ast$pluggable=reinterpret\+\_\+cast$<$ nntrainer\+::\+Layer\+Pluggable $\ast$ $>$ dlsym(handle, \char`\"{}ml\+\_\+train\+\_\+layer\+\_\+pluggable\char`\"{}));error\+\_\+msg=dlerror();auto close\+\_\+dl=\mbox{[}handle\mbox{]} \{ dlclose(handle);\};N\+N\+T\+R\+\_\+\+T\+H\+R\+O\+W\+\_\+\+I\+F\+\_\+\+C\+L\+E\+A\+N\+UP(error\+\_\+msg !=nullptr$\vert$$\vert$pluggable==nullptr, std\+::invalid\+\_\+argument, close\+\_\+dl)$<$$<$ func\+\_\+tag$<$$<$ \char`\"{}loading symbol failed, reason\+: \char`\"{}$<$$<$ error\+\_\+msg;auto layer=pluggable-\/$>$ \mbox{\hyperlink{namespacenntrainer_a771d7e0358e19bd9d648fbe1efc9fadf}{nntrainer\+::createfunc}} ()
\begin{DoxyCompactList}\small\item\em base case of iterate\+\_\+prop, iterate\+\_\+prop iterates the given tuple \end{DoxyCompactList}\end{DoxyCompactItemize}


\doxysubsection{Detailed Description}
This file contains app context related functions and classes that manages the global configuration of the current environment. 

Copyright (C) 2020 Jihoon Lee \href{mailto:jhoon.it.lee@samsung.com}{\texttt{ jhoon.\+it.\+lee@samsung.\+com}}

\begin{DoxyDate}{Date}
10 November 2020 
\end{DoxyDate}
\begin{DoxySeeAlso}{See also}
\href{https://github.com/nnstreamer/nntrainer}{\texttt{ https\+://github.\+com/nnstreamer/nntrainer}} 
\end{DoxySeeAlso}
\begin{DoxyAuthor}{Author}
Jihoon Lee \href{mailto:jhoon.it.lee@samsung.com}{\texttt{ jhoon.\+it.\+lee@samsung.\+com}} 
\end{DoxyAuthor}
\begin{DoxyRefDesc}{Bug}
\item[\mbox{\hyperlink{bug__bug000001}{Bug}}]No known bugs except for N\+YI items\end{DoxyRefDesc}
