From b86a8251b9511016298322b47d60af55f42a4ec5 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: Fri, 14 Dec 2018 16:09:43 +0900 Subject: [PATCH] [neurun] Replace EnvVar with ConfigManager (#4045) Replace EnvVar with ConfigManager. Some default values are revised to work in the same way as before. Signed-off-by: Hanjoung Lee --- runtimes/neurun/src/compiler/BackendResolver.h | 8 ++++---- runtimes/neurun/src/compiler/Compiler.cc | 4 ++-- runtimes/neurun/src/util/config/Config.lst | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/runtimes/neurun/src/compiler/BackendResolver.h b/runtimes/neurun/src/compiler/BackendResolver.h index b3cd5a7..9d1b46c 100644 --- a/runtimes/neurun/src/compiler/BackendResolver.h +++ b/runtimes/neurun/src/compiler/BackendResolver.h @@ -22,7 +22,7 @@ #include #include "logging.h" -#include "misc/EnvVar.h" +#include "util/config/ConfigManager.h" #include "backend/BackendManager.h" #include "backend/interface/IStageGenerator.h" @@ -38,8 +38,8 @@ public: { _backend_manager = std::make_shared(operands); - const auto &backend_all_str = - ::nnfw::misc::EnvVar{std::string("OP_BACKEND_ALLOPS")}.asString("none"); + const auto backend_all_str = + config::ConfigManager::instance().get("OP_BACKEND_ALLOPS"); if (backend_all_str.compare("none") != 0) { VERBOSE(BackendResolver) << "Use backend for all ops: " << backend_all_str << std::endl; @@ -58,7 +58,7 @@ public: if (IsNnApi) \ { \ const auto &backend_str = \ - ::nnfw::misc::EnvVar{std::string("OP_BACKEND_") + #NnApiName}.asString("acl_cl"); \ + config::ConfigManager::instance().get("OP_BACKEND_" #NnApiName); \ auto backend = _backend_manager->get(backend_str); \ VERBOSE(BackendResolver) << "backend for " << #NnApiName << ": " << backend_str << std::endl; \ _gen_map[typeid(graph::operation::InternalName)] = backend; \ diff --git a/runtimes/neurun/src/compiler/Compiler.cc b/runtimes/neurun/src/compiler/Compiler.cc index 0688766..cf5a048 100644 --- a/runtimes/neurun/src/compiler/Compiler.cc +++ b/runtimes/neurun/src/compiler/Compiler.cc @@ -26,7 +26,7 @@ #include "dumper/dot/DotDumper.h" #include "linear/Linear.h" -#include "misc/EnvVar.h" +#include "util/config/ConfigManager.h" namespace neurun { @@ -50,7 +50,7 @@ void Compiler::compile(void) // dump graph to .dot // TODO : These can be moved to another place. - const auto &dotdump_env = ::nnfw::misc::EnvVar{"GRAPH_DOT_DUMP"}.asInt(0); + const auto dotdump_env = config::ConfigManager::instance().get("GRAPH_DOT_DUMP"); if (dotdump_env) { neurun::dumper::dot::DotDumper dot_dumper(graph); diff --git a/runtimes/neurun/src/util/config/Config.lst b/runtimes/neurun/src/util/config/Config.lst index d1a46af..95cee51 100644 --- a/runtimes/neurun/src/util/config/Config.lst +++ b/runtimes/neurun/src/util/config/Config.lst @@ -20,14 +20,14 @@ // Name | Type | Default CONFIG(GRAPH_DOT_DUMP , int , "0") -CONFIG(BACKENDS , std::string , "cpu") -CONFIG(OP_BACKEND_ALLOPS , std::string , "cpu") +CONFIG(BACKENDS , std::string , "cpu;acl_cl") +CONFIG(OP_BACKEND_ALLOPS , std::string , "none") // Auto-generate all operations #define OP(InternalName, IsNnApi, NnApiName) \ - CONFIG(OP_BACKEND_ ## NnApiName, std::string, std::string{"cpu"}) + CONFIG(OP_BACKEND_ ## NnApiName, std::string, "acl_cl") #include "graph/operation/Op.lst" #undef OP -- 2.7.4