kumasento commented on a change in pull request #4847: Return empty 
CSourceModule when no lowered_funcs exists in Relay mod
URL: https://github.com/apache/incubator-tvm/pull/4847#discussion_r379544814
 
 

 ##########
 File path: src/relay/backend/build_module.cc
 ##########
 @@ -437,28 +441,50 @@ class RelayBuildModule : public runtime::ModuleNode {
     ret_.params = graph_codegen_->GetParams();
 
     auto lowered_funcs = graph_codegen_->GetLoweredFunc();
+
+    // When there is no lowered_funcs due to reasons such as optimization,
+    // we first try to generate a dummy one if the target host is "llvm".
+    if (lowered_funcs.size() == 0) {
+      // Decide first the target host 
+      Target target_host_val = target_host_;
+      if (!target_host_.defined()) {
+        for (const auto &it: targets_) {
+          if (it.second->device_type == kDLCPU) {
+            target_host_val = it.second;
+            break;
+          }
+        }
+      }
+
+      // If no target_host has been set, we choose a default one, which is
+      // llvm if "codegen.build_llvm" is accessible.
+      const runtime::PackedFunc* pf = 
runtime::Registry::Get("codegen.build_llvm");
+      if (!target_host_val.defined())
+        target_host_val = (pf != nullptr) ? target::llvm() : target::stackvm();
+
+      if (target_host_val.defined() && target_host_val->str() == "llvm")
 
 Review comment:
   Thanks @FrozenGene, this is indeed problematic. I changed the condition to 
`target_host_val->target_name == "llvm"`. Hope that's OK.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to