From: 박천교/On-Device Lab(SR)/Engineer/삼성전자 Date: Mon, 22 Apr 2019 05:37:00 +0000 (+0900) Subject: [locomotiv] Introduce Session class API (#3326) X-Git-Tag: nncc_backup~687 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=535d00c8dc6cac365047da82a1456d4da853bd5c;p=platform%2Fcore%2Fml%2Fnnfw.git [locomotiv] Introduce Session class API (#3326) This commit defines basic interpreter API using Session class. Session class is responsible to loco graph inference. NodeData class is to store node information that would be passed as output. Signed-off-by: Cheongyo Bahk --- diff --git a/contrib/locomotiv/CMakeLists.txt b/contrib/locomotiv/CMakeLists.txt index e69de29..b508ce9 100644 --- a/contrib/locomotiv/CMakeLists.txt +++ b/contrib/locomotiv/CMakeLists.txt @@ -0,0 +1,11 @@ +file(GLOB_RECURSE SOURCES "src/*.cpp") + +add_library(locomotiv SHARED ${SOURCES}) +target_include_directories(locomotiv PUBLIC include) +target_link_libraries(locomotiv PUBLIC loco) +target_link_libraries(locomotiv PUBLIC angkor) +# Let's apply nncc common compile options +# +# NOTE This will enable strict compilation (warnings as error). +# Please refer to the top-level CMakeLists.txt for details +target_link_libraries(locomotiv PRIVATE nncc_common) diff --git a/contrib/locomotiv/include/locomotiv/NodeData.h b/contrib/locomotiv/include/locomotiv/NodeData.h new file mode 100644 index 0000000..bba4579 --- /dev/null +++ b/contrib/locomotiv/include/locomotiv/NodeData.h @@ -0,0 +1,14 @@ +#ifndef _LOCOMOTIV_NODEDATA_H_ +#define _LOCOMOTIV_NODEDATA_H_ + +namespace locomotiv +{ + +/** + * @brief Node annotation for data type and value + */ +class NodeData; + +} // namespace locomotiv + +#endif // _LOCOMOTIV_NODEDATA_H_ diff --git a/contrib/locomotiv/include/locomotiv/Session.h b/contrib/locomotiv/include/locomotiv/Session.h new file mode 100644 index 0000000..4a29324 --- /dev/null +++ b/contrib/locomotiv/include/locomotiv/Session.h @@ -0,0 +1,38 @@ +#ifndef _LOCOMOTIV_SESSION_H_ +#define _LOCOMOTIV_SESSION_H_ + +#include "locomotiv/NodeData.h" + +#include +#include + +namespace locomotiv +{ + +/** + * @brief Session for loco graph inference + */ +class Session +{ +public: + template using Buffer = nncc::core::ADT::tensor::Buffer
; + + Session() = delete; + Session(loco::Graph *g) : _graph(g) + { + // DO NOTHING + } + + template void set_input(uint32_t index, Buffer
&buf); + + bool infer(); + + const NodeData *get_output(uint32_t index); + +private: + loco::Graph *_graph; +}; + +} // namespace locomotiv + +#endif // _LOCOMOTIV_SESSION_H_ diff --git a/contrib/locomotiv/requires.cmake b/contrib/locomotiv/requires.cmake new file mode 100644 index 0000000..654db88 --- /dev/null +++ b/contrib/locomotiv/requires.cmake @@ -0,0 +1 @@ +require("angkor") diff --git a/contrib/locomotiv/src/Session.cpp b/contrib/locomotiv/src/Session.cpp new file mode 100644 index 0000000..cefda18 --- /dev/null +++ b/contrib/locomotiv/src/Session.cpp @@ -0,0 +1 @@ +#include "locomotiv/Session.h"