From 535d00c8dc6cac365047da82a1456d4da853bd5c Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EB=B0=95=EC=B2=9C=EA=B5=90/On-Device=20Lab=28SR=29/Enginee?= =?utf8?q?r/=EC=82=BC=EC=84=B1=EC=A0=84=EC=9E=90?= Date: Mon, 22 Apr 2019 14:37:00 +0900 Subject: [PATCH] [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 --- contrib/locomotiv/CMakeLists.txt | 11 ++++++++ contrib/locomotiv/include/locomotiv/NodeData.h | 14 ++++++++++ contrib/locomotiv/include/locomotiv/Session.h | 38 ++++++++++++++++++++++++++ contrib/locomotiv/requires.cmake | 1 + contrib/locomotiv/src/Session.cpp | 1 + 5 files changed, 65 insertions(+) create mode 100644 contrib/locomotiv/include/locomotiv/NodeData.h create mode 100644 contrib/locomotiv/include/locomotiv/Session.h create mode 100644 contrib/locomotiv/requires.cmake create mode 100644 contrib/locomotiv/src/Session.cpp 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" -- 2.7.4