From 10e15a01e1e2baf50c7b82ab3f0cfd312b6d1713 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EC=9D=B4=ED=95=9C=EC=A2=85/=EB=8F=99=EC=9E=91=EC=A0=9C?= =?utf8?q?=EC=96=B4Lab=28SR=29/Engineer/=EC=82=BC=EC=84=B1=EC=A0=84?= =?utf8?q?=EC=9E=90?= Date: Thu, 8 Nov 2018 10:11:02 +0900 Subject: [PATCH] [neurun] Remove InitializerGenerator dependency (#3508) Remove all InitializerGenerator dependent code since we now have ConstantInitializer for this purpose. Signed-off-by: Hanjoung Lee --- runtimes/neurun/src/backend/BackendManager.cc | 16 ++--------- runtimes/neurun/src/backend/BackendManager.h | 6 +--- runtimes/neurun/src/codegen/BackendResolver.h | 1 - runtimes/neurun/src/codegen/Planner.cc | 40 --------------------------- 4 files changed, 4 insertions(+), 59 deletions(-) diff --git a/runtimes/neurun/src/backend/BackendManager.cc b/runtimes/neurun/src/backend/BackendManager.cc index 8fef674..0dbb14c 100644 --- a/runtimes/neurun/src/backend/BackendManager.cc +++ b/runtimes/neurun/src/backend/BackendManager.cc @@ -18,11 +18,9 @@ #include "backend/acl_cl/Config.h" #include "backend/acl_cl/TensorBuilder.h" -#include "backend/acl_cl/InitializerGenerator.h" #include "backend/acl_cl/StageGenerator.h" #include "backend/cpu/Config.h" #include "backend/cpu/TensorBuilder.h" -#include "backend/cpu/InitializerGenerator.h" #include "backend/cpu/StageGenerator.h" namespace neurun @@ -31,20 +29,14 @@ namespace backend { Backend::Backend(const std::shared_ptr &backend_config, - const std::shared_ptr &initializer_gen, const std::shared_ptr &stage_gen) - : _config(backend_config), _initializer_gen(initializer_gen), _stage_gen(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::initializer_gen() const -{ - return _initializer_gen; -} - const std::shared_ptr Backend::stage_gen() const { return _stage_gen; @@ -62,10 +54,9 @@ BackendManager::BackendManager(const neurun::graph::operand::Set &operands) using namespace ::neurun::backend::acl_cl; auto config = std::make_shared(); auto tensor_builder = std::make_shared(); - auto initializer_gen = std::make_shared(operands); auto stage_gen = std::make_shared(operands, tensor_builder); - _gen_map[config->id()] = {config, initializer_gen, stage_gen}; + _gen_map[config->id()] = {config, stage_gen}; } // Add CPU backend @@ -73,10 +64,9 @@ BackendManager::BackendManager(const neurun::graph::operand::Set &operands) using namespace ::neurun::backend::cpu; auto config = std::make_shared(); auto tensor_builder = std::make_shared(); - auto initializer_gen = std::make_shared(operands); auto stage_gen = std::make_shared(operands, tensor_builder); - _gen_map[config->id()] = {config, initializer_gen, stage_gen}; + _gen_map[config->id()] = {config, stage_gen}; } } diff --git a/runtimes/neurun/src/backend/BackendManager.h b/runtimes/neurun/src/backend/BackendManager.h index 50cece9..aeb4153 100644 --- a/runtimes/neurun/src/backend/BackendManager.h +++ b/runtimes/neurun/src/backend/BackendManager.h @@ -28,7 +28,6 @@ namespace backend { struct IConfig; -struct IInitializerGenerator; struct IStageGenerator; struct ITensorBuilder; @@ -36,23 +35,20 @@ class Backend { public: Backend(const std::shared_ptr &backend_config, - const std::shared_ptr &initializer_gen, const std::shared_ptr &stage_gen); - Backend(void) : _config(nullptr), _initializer_gen(nullptr), _stage_gen(nullptr) + Backend(void) : _config(nullptr), _stage_gen(nullptr) { // DO NOTHING } public: const std::shared_ptr config() const; - const std::shared_ptr initializer_gen() const; const std::shared_ptr stage_gen() const; const std::shared_ptr tensor_builder() const; private: std::shared_ptr _config; - std::shared_ptr _initializer_gen; std::shared_ptr _stage_gen; }; diff --git a/runtimes/neurun/src/codegen/BackendResolver.h b/runtimes/neurun/src/codegen/BackendResolver.h index e788836..4ec7c52 100644 --- a/runtimes/neurun/src/codegen/BackendResolver.h +++ b/runtimes/neurun/src/codegen/BackendResolver.h @@ -24,7 +24,6 @@ #include "logging.h" #include "util/EnvVar.h" #include "backend/BackendManager.h" -#include "backend/interface/IInitializerGenerator.h" #include "backend/interface/IStageGenerator.h" namespace neurun diff --git a/runtimes/neurun/src/codegen/Planner.cc b/runtimes/neurun/src/codegen/Planner.cc index 9393156..addab58 100644 --- a/runtimes/neurun/src/codegen/Planner.cc +++ b/runtimes/neurun/src/codegen/Planner.cc @@ -35,10 +35,6 @@ void Planner::visit(const graph::operation::Conv2DNode &node) // backend auto backend = node.lower_info()->backend(); - // Generate Initializers - auto init_gen = backend->initializer_gen(); - _builder.addInitializer(init_gen->generate(node)); - // Generate Stage auto stage_gen = backend->stage_gen(); _builder.addStage(stage_gen->generate(node)); @@ -49,10 +45,6 @@ void Planner::visit(const graph::operation::MaxPool2DNode &node) // backend auto backend = node.lower_info()->backend(); - // Generate Initializers - auto init_gen = backend->initializer_gen(); - _builder.addInitializer(init_gen->generate(node)); - // Generate Stage auto stage_gen = backend->stage_gen(); _builder.addStage(stage_gen->generate(node)); @@ -63,10 +55,6 @@ void Planner::visit(const graph::operation::AvgPool2DNode &node) // backend auto backend = node.lower_info()->backend(); - // Generate Initializers - auto init_gen = backend->initializer_gen(); - _builder.addInitializer(init_gen->generate(node)); - // Generate Stage auto stage_gen = backend->stage_gen(); _builder.addStage(stage_gen->generate(node)); @@ -82,10 +70,6 @@ void Planner::visit(const graph::operation::ConcatNode &node) // backend auto backend = node.lower_info()->backend(); - // Generate Initializers - auto init_gen = backend->initializer_gen(); - _builder.addInitializer(init_gen->generate(node)); - // Generate Stage auto stage_gen = backend->stage_gen(); _builder.addStage(stage_gen->generate(node)); @@ -98,10 +82,6 @@ void Planner::visit(const graph::operation::FullyConnectedNode &node) // backend auto backend = node.lower_info()->backend(); - // Generate Initializers - auto init_gen = backend->initializer_gen(); - _builder.addInitializer(init_gen->generate(node)); - // Generate Stage auto stage_gen = backend->stage_gen(); _builder.addStage(stage_gen->generate(node)); @@ -131,10 +111,6 @@ void Planner::visit(const graph::operation::ReshapeNode &node) // backend auto backend = node.lower_info()->backend(); - // Generate Initializers - auto init_gen = backend->initializer_gen(); - _builder.addInitializer(init_gen->generate(node)); - // Generate Stage auto stage_gen = backend->stage_gen(); _builder.addStage(stage_gen->generate(node)); @@ -158,10 +134,6 @@ void Planner::visit(const graph::operation::SoftmaxNode &node) // backend auto backend = node.lower_info()->backend(); - // Generate Initializers - auto init_gen = backend->initializer_gen(); - _builder.addInitializer(init_gen->generate(node)); - // Generate Stage auto stage_gen = backend->stage_gen(); _builder.addStage(stage_gen->generate(node)); @@ -172,10 +144,6 @@ void Planner::visit(const graph::operation::NOPNode &node) // backend auto backend = node.lower_info()->backend(); - // Generate Initializers - auto init_gen = backend->initializer_gen(); - _builder.addInitializer(init_gen->generate(node)); - // Generate Stage auto stage_gen = backend->stage_gen(); _builder.addStage(stage_gen->generate(node)); @@ -193,10 +161,6 @@ void Planner::visit(const graph::operation::PermuteNode &node) // backend auto backend = node.lower_info()->backend(); - // Generate Initializers - auto init_gen = backend->initializer_gen(); - _builder.addInitializer(init_gen->generate(node)); - // Generate Stage auto stage_gen = backend->stage_gen(); _builder.addStage(stage_gen->generate(node)); @@ -209,10 +173,6 @@ void Planner::visit(const graph::operation::AddNode &node) // backend auto backend = node.lower_info()->backend(); - // Generate Initializers - auto init_gen = backend->initializer_gen(); - _builder.addInitializer(init_gen->generate(node)); - // Generate Stage auto stage_gen = backend->stage_gen(); _builder.addStage(stage_gen->generate(node)); -- 2.7.4