FrozenGene 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_r379218842
########## 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: Please add one test "llvm -device=arm_cpu -mattr=+neon -target=aarch64-linux-gnu" to make sure we get correct llvm target. I doubt your `target_host_val->str() == "llvm"` is not correct logic. ---------------------------------------------------------------- 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