diff --git a/src/relay/backend/build_module.cc b/src/relay/backend/build_module.cc index ff64d4a3acbb3..461a453f3f49f 100644 --- a/src/relay/backend/build_module.cc +++ b/src/relay/backend/build_module.cc @@ -28,6 +28,7 @@ #include #include #include +#include #include #include "utils.h" @@ -37,6 +38,9 @@ namespace relay { namespace backend { using tir::LoweredFunc; +using tir::Stmt; +using tir::MakeAPI; +using tir::EvaluateNode; using TargetsMap = Map; using namespace tvm::relay::transform; @@ -438,13 +442,21 @@ class RelayBuildModule : public runtime::ModuleNode { auto lowered_funcs = graph_codegen_->GetLoweredFunc(); if (lowered_funcs.size() == 0) { - LOG(WARNING) << "no lowered funcs exist in the compiled module"; - } else { - ret_.mod = tvm::build( - lowered_funcs, - target_host_, - BuildConfig::Current()); + LOG(WARNING) << "No lowered funcs exist in the compiled module, " + << "a dummy function \"__dummy__\" will be created."; + + Stmt body = EvaluateNode::make(0); + Array api_args; + + auto dummy_func = MakeAPI(body, "__dummy__", api_args, 0, false); + lowered_funcs.Set("llvm", Array({dummy_func})); } + + ret_.mod = tvm::build( + lowered_funcs, + target_host_, + BuildConfig::Current()); + Array ext_mods = graph_codegen_->GetExternalModules(); if (!ext_mods.empty()) { CHECK(lowered_funcs.size() > 0 || ext_mods.size() == 1)