[neurun] Extract Backend as a separate file (#4587)
author이한종/On-Device Lab(SR)/Engineer/삼성전자 <hanjoung.lee@samsung.com>
Wed, 6 Mar 2019 01:06:23 +0000 (10:06 +0900)
committer박세희/On-Device Lab(SR)/Principal Engineer/삼성전자 <saehie.park@samsung.com>
Wed, 6 Mar 2019 01:06:23 +0000 (10:06 +0900)
Extract `backend::Backend` as a separate file.

Signed-off-by: Hanjoung Lee <hanjoung.lee@samsung.com>
runtimes/neurun/src/backend/Backend.cc [new file with mode: 0644]
runtimes/neurun/src/backend/Backend.h [new file with mode: 0644]
runtimes/neurun/src/backend/BackendManager.cc
runtimes/neurun/src/backend/BackendManager.h

diff --git a/runtimes/neurun/src/backend/Backend.cc b/runtimes/neurun/src/backend/Backend.cc
new file mode 100644 (file)
index 0000000..52f3314
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2019 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 "Backend.h"
+
+#include "backend/interface/IConfig.h"
+#include "backend/interface/ITensorBuilder.h"
+#include "backend/interface/IStageGenerator.h"
+
+namespace neurun
+{
+namespace backend
+{
+
+Backend::Backend(const std::shared_ptr<neurun::backend::IConfig> &backend_config,
+                 const std::shared_ptr<neurun::backend::IStageGenerator> &stage_gen)
+    : _config(backend_config), _stage_gen(stage_gen)
+{
+  backend_config->initialize();
+}
+
+const std::shared_ptr<neurun::backend::IConfig> Backend::config() const { return _config; }
+
+const std::shared_ptr<neurun::backend::IStageGenerator> Backend::stage_gen() const
+{
+  return _stage_gen;
+}
+
+const std::shared_ptr<neurun::backend::ITensorBuilder> Backend::tensor_builder() const
+{
+  return _stage_gen->tensor_builder();
+}
+
+} // namespace backend
+} // namespace neurun
diff --git a/runtimes/neurun/src/backend/Backend.h b/runtimes/neurun/src/backend/Backend.h
new file mode 100644 (file)
index 0000000..d47fc21
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2019 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 __NEURUN_BACKEND_BACKEND_H__
+#define __NEURUN_BACKEND_BACKEND_H__
+
+#include <memory>
+
+namespace neurun
+{
+namespace backend
+{
+
+struct IConfig;
+struct IStageGenerator;
+struct ITensorBuilder;
+
+class Backend
+{
+public:
+  Backend(const std::shared_ptr<neurun::backend::IConfig> &backend_config,
+          const std::shared_ptr<neurun::backend::IStageGenerator> &stage_gen);
+
+  Backend(void) : _config(nullptr), _stage_gen(nullptr)
+  {
+    // DO NOTHING
+  }
+
+public:
+  const std::shared_ptr<neurun::backend::IConfig> config() const;
+  const std::shared_ptr<neurun::backend::IStageGenerator> stage_gen() const;
+  const std::shared_ptr<neurun::backend::ITensorBuilder> tensor_builder() const;
+
+private:
+  std::shared_ptr<neurun::backend::IConfig> _config;
+  std::shared_ptr<neurun::backend::IStageGenerator> _stage_gen;
+};
+
+} // namespace backend
+} // namespace neurun
+
+#endif // __NEURUN_BACKEND_BACKEND_H__
index eb8772c..e2d6343 100644 (file)
@@ -28,25 +28,6 @@ namespace neurun
 namespace backend
 {
 
-Backend::Backend(const std::shared_ptr<neurun::backend::IConfig> &backend_config,
-                 const std::shared_ptr<neurun::backend::IStageGenerator> &stage_gen)
-    : _config(backend_config), _stage_gen(stage_gen)
-{
-  backend_config->initialize();
-}
-
-const std::shared_ptr<neurun::backend::IConfig> Backend::config() const { return _config; }
-
-const std::shared_ptr<neurun::backend::IStageGenerator> Backend::stage_gen() const
-{
-  return _stage_gen;
-}
-
-const std::shared_ptr<neurun::backend::ITensorBuilder> Backend::tensor_builder() const
-{
-  return _stage_gen->tensor_builder();
-}
-
 template <typename T, class... Types>
 void BackendManager::loadObjectFromPlugin(std::shared_ptr<T> &object_of_plugin_class,
                                           const std::string obj_creator_func_name, void *handle,
index 428542b..66cf6be 100644 (file)
 #include <map>
 
 #include "model/operand/Set.h"
+#include "Backend.h"
 
 namespace neurun
 {
 namespace backend
 {
 
-struct IConfig;
-struct IStageGenerator;
-struct ITensorBuilder;
-
-class Backend
-{
-public:
-  Backend(const std::shared_ptr<neurun::backend::IConfig> &backend_config,
-          const std::shared_ptr<neurun::backend::IStageGenerator> &stage_gen);
-
-  Backend(void) : _config(nullptr), _stage_gen(nullptr)
-  {
-    // DO NOTHING
-  }
-
-public:
-  const std::shared_ptr<neurun::backend::IConfig> config() const;
-  const std::shared_ptr<neurun::backend::IStageGenerator> stage_gen() const;
-  const std::shared_ptr<neurun::backend::ITensorBuilder> tensor_builder() const;
-
-private:
-  std::shared_ptr<neurun::backend::IConfig> _config;
-  std::shared_ptr<neurun::backend::IStageGenerator> _stage_gen;
-};
-
 class BackendManager
 {
 public: