[locomotiv] Introduce Session class API (#3326)
author박천교/On-Device Lab(SR)/Engineer/삼성전자 <ch.bahk@samsung.com>
Mon, 22 Apr 2019 05:37:00 +0000 (14:37 +0900)
committer박세희/On-Device Lab(SR)/Principal Engineer/삼성전자 <saehie.park@samsung.com>
Mon, 22 Apr 2019 05:37:00 +0000 (14:37 +0900)
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 <ch.bahk@samsung.com>
contrib/locomotiv/CMakeLists.txt
contrib/locomotiv/include/locomotiv/NodeData.h [new file with mode: 0644]
contrib/locomotiv/include/locomotiv/Session.h [new file with mode: 0644]
contrib/locomotiv/requires.cmake [new file with mode: 0644]
contrib/locomotiv/src/Session.cpp [new file with mode: 0644]

index e69de29..b508ce9 100644 (file)
@@ -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 (file)
index 0000000..bba4579
--- /dev/null
@@ -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 (file)
index 0000000..4a29324
--- /dev/null
@@ -0,0 +1,38 @@
+#ifndef _LOCOMOTIV_SESSION_H_
+#define _LOCOMOTIV_SESSION_H_
+
+#include "locomotiv/NodeData.h"
+
+#include <loco.h>
+#include <nncc/core/ADT/tensor/Buffer.h>
+
+namespace locomotiv
+{
+
+/**
+ * @brief Session for loco graph inference
+ */
+class Session
+{
+public:
+  template <typename DT> using Buffer = nncc::core::ADT::tensor::Buffer<DT>;
+
+  Session() = delete;
+  Session(loco::Graph *g) : _graph(g)
+  {
+    // DO NOTHING
+  }
+
+  template <typename DT> void set_input(uint32_t index, Buffer<DT> &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 (file)
index 0000000..654db88
--- /dev/null
@@ -0,0 +1 @@
+require("angkor")
diff --git a/contrib/locomotiv/src/Session.cpp b/contrib/locomotiv/src/Session.cpp
new file mode 100644 (file)
index 0000000..cefda18
--- /dev/null
@@ -0,0 +1 @@
+#include "locomotiv/Session.h"