[moco-tf] Using composed GraphBuilderRegistry for custom op (#6093)
author윤현식/On-Device Lab(SR)/Principal Engineer/삼성전자 <hyunsik.yoon@samsung.com>
Thu, 1 Aug 2019 07:08:30 +0000 (16:08 +0900)
committer박종현/On-Device Lab(SR)/Staff Engineer/삼성전자 <jh1302.park@samsung.com>
Thu, 1 Aug 2019 07:08:30 +0000 (16:08 +0900)
* [moco-tf] Using composed GraphBuilderRegistry for custom op

This is to use a composed GraphBuilderRegistry, instead of singleton GraphBuilderRegistry, to add GraphBuilder for custom op later.

Signed-off-by: Hyun Sik Yoon <hyunsik.yoon@samsung.com>
* enhance comment. rename function

compiler/moco-tf/src/Frontend.cpp

index f91863e..487360e 100644 (file)
@@ -99,6 +99,19 @@ void load_tf(std::istream *stream, moco::tf::Frontend::FileType type,
   }
 }
 
+/**
+ * @brief Returns GraphBuilderRegistry that looks up default registry and additions
+ *        such as custom op
+ */
+moco::tf::GraphBuilderRegistry make_graph_builder_registry(const moco::tf::ModelSignature &sig)
+{
+  moco::tf::GraphBuilderRegistry registry{&moco::tf::GraphBuilderRegistry::get()};
+
+  // TODO add GraphBuilder for Custom op into registry
+
+  return registry;
+}
+
 } // namespace
 
 // TODO Find a proper place for this function
@@ -209,7 +222,10 @@ void cleanup(loco::Graph *graph)
 std::unique_ptr<loco::Graph> Frontend::import(const ModelSignature &signature,
                                               tensorflow::GraphDef &tf_graph_def) const
 {
-  Importer importer;
+  // Let's use GraphBuilderRegistry with COpCallGraphBuilder
+  GraphBuilderRegistry registry = make_graph_builder_registry(signature);
+
+  Importer importer{&registry};
 
   auto graph = importer.import(signature, tf_graph_def);