From 3956a71fd20874660f9dc2fa25aa1e44fd8cfcb1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EC=98=A4=ED=98=95=EC=84=9D/=EB=8F=99=EC=9E=91=EC=A0=9C?= =?utf8?q?=EC=96=B4Lab=28SR=29/Staff=20Engineer/=EC=82=BC=EC=84=B1?= =?utf8?q?=EC=A0=84=EC=9E=90?= Date: Thu, 2 Aug 2018 13:08:24 +0900 Subject: [PATCH] Environment variable to set all configurable operators' backend (#2141) Introduce new environment variable to set all configurable operators' backend: OP_BACKEND_ALLOPS none: use each operator's backend configuration (default) acl_cl: use acl for all configurable operators' backend cpu: use cpu for all configurable operators' backend Signed-off-by: Hyeongseok Oh --- runtimes/neurun/src/compilation.cc | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/runtimes/neurun/src/compilation.cc b/runtimes/neurun/src/compilation.cc index a584af5..b401d38 100644 --- a/runtimes/neurun/src/compilation.cc +++ b/runtimes/neurun/src/compilation.cc @@ -79,16 +79,33 @@ class BackendResolver public: BackendResolver(::internal::BackendManager &backend_manager) : _backend_manager(backend_manager) { -#define OP(InternalName, NnApiName) \ - { \ - const auto &backend_str = \ - ::nnfw::util::EnvVar{std::string("OP_BACKEND_") + #NnApiName}.asString("acl_cl"); \ - auto backend = _backend_manager.get(backend_str); \ - _gen_map[typeid(::internal::tflite::op::InternalName::Node)] = backend; \ + const auto &backend_all_str = + ::nnfw::util::EnvVar{std::string("OP_BACKEND_ALLOPS")}.asString("none"); + if (backend_all_str.compare("none") != 0) + { + VERBOSE(BackendResolver) << "Use backend for all ops: " << backend_all_str << std::endl; +#define OP(InternalName, NnApiName) \ + { \ + auto backend = _backend_manager.get(backend_all_str); \ + _gen_map[typeid(::internal::tflite::op::InternalName::Node)] = backend; \ + } +#include "internal/op/Op.lst" +#undef OP + } + else + { +#define OP(InternalName, NnApiName) \ + { \ + const auto &backend_str = \ + ::nnfw::util::EnvVar{std::string("OP_BACKEND_") + #NnApiName}.asString("acl_cl"); \ + auto backend = _backend_manager.get(backend_str); \ + VERBOSE(BackendResolver) << "backend for " << #NnApiName << ": " << backend_str << std::endl; \ + _gen_map[typeid(::internal::tflite::op::InternalName::Node)] = backend; \ } #include "internal/op/Op.lst" #undef OP + } // TODO : It's just workaround. It's logic should be changed. _gen_map[typeid(::internal::tflite::op::TensorConvert::CpuFromCommon::Node)] = -- 2.7.4