From: 오형석/On-Device Lab(SR)/Staff Engineer/삼성전자 Date: Tue, 26 Feb 2019 09:07:52 +0000 (+0900) Subject: Introduce method to check compilable (#4500) X-Git-Tag: submit/tizen/20190325.013700~202 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=277d69741b8206fffb84228c7fe63baf48625147;p=platform%2Fcore%2Fml%2Fnnfw.git Introduce method to check compilable (#4500) Introduce method to check compilable to handle case cannot compile (environment variable setting, unspecified operand shape, etc) Signed-off-by: Hyeongseok Oh --- diff --git a/runtimes/neurun/src/compiler/Compiler.cc b/runtimes/neurun/src/compiler/Compiler.cc index 3d04634..e837329 100644 --- a/runtimes/neurun/src/compiler/Compiler.cc +++ b/runtimes/neurun/src/compiler/Compiler.cc @@ -42,10 +42,7 @@ void Compiler::compile(void) const auto &operands = _model->operands(); - // Disable compile phase - // When ready to use interpreter backend, remove this config and use backend setting - const auto env_disable_compile = config::ConfigManager::instance().get("DISABLE_COMPILE"); - if (env_disable_compile) + if (!checkCompilable()) { _executor = std::make_shared(_model->shareModel()); return; @@ -126,6 +123,21 @@ void Compiler::compile(void) _state = State::COMPILED; } +bool Compiler::checkCompilable() +{ + // Disable compile phase + // When ready to use interpreter backend, remove this config and use backend setting + const auto env_disable_compile = config::ConfigManager::instance().get("DISABLE_COMPILE"); + if (env_disable_compile) + { + return false; + } + + // TODO check unspecified operand shape + + return true; +} + } // namespace compiler } // namespace neurun diff --git a/runtimes/neurun/src/compiler/Compiler.h b/runtimes/neurun/src/compiler/Compiler.h index aced294..79e10a8 100644 --- a/runtimes/neurun/src/compiler/Compiler.h +++ b/runtimes/neurun/src/compiler/Compiler.h @@ -72,6 +72,15 @@ public: State state(void) const { return _state; } private: + /** + * @brief Check if model can compile + * @return @c true if model can compile, otherwise @c false + * @note This method don't check model correctness,\n + * so model verification should be done before calling this method + */ + bool checkCompilable(); + +private: std::shared_ptr _model; std::shared_ptr _executor; State _state;