[Compiler] Declare interface
authorJihoon Lee <jhoon.it.lee@samsung.com>
Thu, 1 Apr 2021 10:32:20 +0000 (19:32 +0900)
committerJijoong Moon <jijoong.moon@samsung.com>
Wed, 7 Apr 2021 01:34:17 +0000 (10:34 +0900)
This patch declares interface of compiler / interpreter

**Self evaluation:**
1. Build test: [X]Passed [ ]Failed [ ]Skipped
2. Run test: [X]Passed [ ]Failed [ ]Skipped

Signed-off-by: Jihoon Lee <jhoon.it.lee@samsung.com>
nntrainer/compiler/compiler.h

index 73b6f90..6a16849 100644 (file)
  * @bug No known bugs except for NYI items
  */
 
+#include <iostream>
+#include <memory>
+
 namespace nntrainer {
 
 class ExecutableGraph;
 
 class GraphRepresentation;
 
-class GraphCompiler;
+/**
+ * @brief Pure virtual class for the Graph Compiler
+ *
+ */
+class GraphCompiler {
+public:
+  virtual ~GraphCompiler() {}
+  /**
+   * @brief serialize graph to a file stream
+   *
+   * @param representation graph representation
+   * @param file ifstream to serialize graph
+   */
+  virtual std::shared_ptr<ExecutableGraph>
+  compile(const GraphRepresentation &representation) = 0;
+
+  /**
+   * @brief deserialize graph from a file stream
+   *
+   * @param executable executable graph
+   * @return GraphRepresentation graph representation
+   */
+  virtual GraphRepresentation
+  decompile(std::shared_ptr<ExecutableGraph> executable) = 0;
+};
+
+/**
+ * @brief Pure virtual class for the Graph Interpreter
+ *
+ */
+class GraphInterpreter {
+public:
+  virtual ~GraphInterpreter() {}
+  /**
+   * @brief serialize graph to a stream
+   *
+   * @param representation graph representation
+   * @param out outstream to serialize graph
+   */
+  virtual void serialize(const GraphRepresentation &representation,
+                         std::ostream &out) = 0;
+
+  /**
+   * @brief deserialize graph from a stream
+   *
+   * @param in in stream to deserialize
+   * @return GraphRepresentation graph representation
+   */
+  virtual GraphRepresentation deserialize(std::istream &in) = 0;
+};
 
 class GraphInterpreter;