[enco] frontend/caffe: Introduce GraphBuilderRegistry (#2535)
author박세희/동작제어Lab(SR)/Principal Engineer/삼성전자 <saehie.park@samsung.com>
Thu, 6 Dec 2018 07:42:11 +0000 (16:42 +0900)
committerGitHub Enterprise <noreply-CODE@samsung.com>
Thu, 6 Dec 2018 07:42:11 +0000 (16:42 +0900)
This will introduce GraphBuilderRegistry class to register GraphBuilder by layer type

Signed-off-by: SaeHie Park <saehie.park@samsung.com>
contrib/enco/frontend/caffe/src/GraphBuilderRegistry.cpp [new file with mode: 0644]
contrib/enco/frontend/caffe/src/GraphBuilderRegistry.h [new file with mode: 0644]

diff --git a/contrib/enco/frontend/caffe/src/GraphBuilderRegistry.cpp b/contrib/enco/frontend/caffe/src/GraphBuilderRegistry.cpp
new file mode 100644 (file)
index 0000000..094896d
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "GraphBuilderRegistry.h"
+
+namespace caffeimport
+{
+
+GraphBuilderRegistry::GraphBuilderRegistry()
+{
+  // TODO add GraphBuilder for each caffe layer.
+}
+
+} // namespace caffeimport
diff --git a/contrib/enco/frontend/caffe/src/GraphBuilderRegistry.h b/contrib/enco/frontend/caffe/src/GraphBuilderRegistry.h
new file mode 100644 (file)
index 0000000..c32a4a6
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __GRAPH_BUILDER_REGISTRY_H__
+#define __GRAPH_BUILDER_REGISTRY_H__
+
+#include "GraphBuilder.h"
+
+#include <map>
+#include <string>
+
+namespace caffeimport
+{
+
+class GraphBuilderRegistry
+{
+public:
+  const GraphBuilder *lookup(std::string op) const
+  {
+    if (_builder_map.find(op) == _builder_map.end())
+      return nullptr;
+
+    return _builder_map.at(op).get();
+  }
+
+  static GraphBuilderRegistry &get()
+  {
+    static GraphBuilderRegistry me;
+    return me;
+  }
+
+private:
+  GraphBuilderRegistry();
+
+private:
+  std::map<std::string, std::unique_ptr<GraphBuilder>> _builder_map;
+};
+
+} // namespace caffeimport
+
+#endif // __GRAPH_BUILDER_REGISTRY_H__