From: 이한종/On-Device Lab(SR)/Engineer/삼성전자 Date: Wed, 6 Mar 2019 01:06:23 +0000 (+0900) Subject: [neurun] Extract Backend as a separate file (#4587) X-Git-Tag: submit/tizen/20190325.013700~153 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1c19fb46d4448a3548a6d7fead1c2db84f47640c;p=platform%2Fcore%2Fml%2Fnnfw.git [neurun] Extract Backend as a separate file (#4587) Extract `backend::Backend` as a separate file. Signed-off-by: Hanjoung Lee --- diff --git a/runtimes/neurun/src/backend/Backend.cc b/runtimes/neurun/src/backend/Backend.cc new file mode 100644 index 0000000..52f3314 --- /dev/null +++ b/runtimes/neurun/src/backend/Backend.cc @@ -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 &backend_config, + const std::shared_ptr &stage_gen) + : _config(backend_config), _stage_gen(stage_gen) +{ + backend_config->initialize(); +} + +const std::shared_ptr Backend::config() const { return _config; } + +const std::shared_ptr Backend::stage_gen() const +{ + return _stage_gen; +} + +const std::shared_ptr 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 index 0000000..d47fc21 --- /dev/null +++ b/runtimes/neurun/src/backend/Backend.h @@ -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 + +namespace neurun +{ +namespace backend +{ + +struct IConfig; +struct IStageGenerator; +struct ITensorBuilder; + +class Backend +{ +public: + Backend(const std::shared_ptr &backend_config, + const std::shared_ptr &stage_gen); + + Backend(void) : _config(nullptr), _stage_gen(nullptr) + { + // DO NOTHING + } + +public: + const std::shared_ptr config() const; + const std::shared_ptr stage_gen() const; + const std::shared_ptr tensor_builder() const; + +private: + std::shared_ptr _config; + std::shared_ptr _stage_gen; +}; + +} // namespace backend +} // namespace neurun + +#endif // __NEURUN_BACKEND_BACKEND_H__ diff --git a/runtimes/neurun/src/backend/BackendManager.cc b/runtimes/neurun/src/backend/BackendManager.cc index eb8772c..e2d6343 100644 --- a/runtimes/neurun/src/backend/BackendManager.cc +++ b/runtimes/neurun/src/backend/BackendManager.cc @@ -28,25 +28,6 @@ namespace neurun namespace backend { -Backend::Backend(const std::shared_ptr &backend_config, - const std::shared_ptr &stage_gen) - : _config(backend_config), _stage_gen(stage_gen) -{ - backend_config->initialize(); -} - -const std::shared_ptr Backend::config() const { return _config; } - -const std::shared_ptr Backend::stage_gen() const -{ - return _stage_gen; -} - -const std::shared_ptr Backend::tensor_builder() const -{ - return _stage_gen->tensor_builder(); -} - template void BackendManager::loadObjectFromPlugin(std::shared_ptr &object_of_plugin_class, const std::string obj_creator_func_name, void *handle, diff --git a/runtimes/neurun/src/backend/BackendManager.h b/runtimes/neurun/src/backend/BackendManager.h index 428542b..66cf6be 100644 --- a/runtimes/neurun/src/backend/BackendManager.h +++ b/runtimes/neurun/src/backend/BackendManager.h @@ -21,37 +21,13 @@ #include #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 &backend_config, - const std::shared_ptr &stage_gen); - - Backend(void) : _config(nullptr), _stage_gen(nullptr) - { - // DO NOTHING - } - -public: - const std::shared_ptr config() const; - const std::shared_ptr stage_gen() const; - const std::shared_ptr tensor_builder() const; - -private: - std::shared_ptr _config; - std::shared_ptr _stage_gen; -}; - class BackendManager { public: