Introduce method to check compilable (#4500)
author오형석/On-Device Lab(SR)/Staff Engineer/삼성전자 <hseok82.oh@samsung.com>
Tue, 26 Feb 2019 09:07:52 +0000 (18:07 +0900)
committerGitHub Enterprise <noreply-CODE@samsung.com>
Tue, 26 Feb 2019 09:07:52 +0000 (18:07 +0900)
Introduce method to check compilable to handle case cannot compile (environment variable setting,  unspecified operand shape, etc)

Signed-off-by: Hyeongseok Oh <hseok82.oh@samsung.com>
runtimes/neurun/src/compiler/Compiler.cc
runtimes/neurun/src/compiler/Compiler.h

index 3d04634..e837329 100644 (file)
@@ -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<bool>("DISABLE_COMPILE");
-  if (env_disable_compile)
+  if (!checkCompilable())
   {
     _executor = std::make_shared<exec::interp::Interpreter>(_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<bool>("DISABLE_COMPILE");
+  if (env_disable_compile)
+  {
+    return false;
+  }
+
+  // TODO check unspecified operand shape
+
+  return true;
+}
+
 } // namespace compiler
 
 } // namespace neurun
index aced294..79e10a8 100644 (file)
@@ -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<graph::Graph> _model;
   std::shared_ptr<exec::IExecutor> _executor;
   State _state;