Skip to content

Commit

Permalink
Use dummy func when no lowered_funcs exists in Relay mod
Browse files Browse the repository at this point in the history
  • Loading branch information
kumasento committed Feb 8, 2020
1 parent e33de24 commit 3bcb8aa
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions src/relay/backend/build_module.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <tvm/relay/expr.h>
#include <tvm/relay/transform.h>
#include <tvm/relay/qnn/transform.h>
#include <tvm/tir/ir_pass.h>
#include <memory>

#include "utils.h"
Expand All @@ -37,6 +38,9 @@ namespace relay {
namespace backend {

using tir::LoweredFunc;
using tir::Stmt;
using tir::MakeAPI;
using tir::EvaluateNode;

using TargetsMap = Map<tvm::Integer, tvm::Target>;
using namespace tvm::relay::transform;
Expand Down Expand Up @@ -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<ObjectRef> api_args;

auto dummy_func = MakeAPI(body, "__dummy__", api_args, 0, false);
lowered_funcs.Set("llvm", Array<LoweredFunc>({dummy_func}));
}

ret_.mod = tvm::build(
lowered_funcs,
target_host_,
BuildConfig::Current());

Array<tvm::runtime::Module> ext_mods = graph_codegen_->GetExternalModules();
if (!ext_mods.empty()) {
CHECK(lowered_funcs.size() > 0 || ext_mods.size() == 1)
Expand Down

0 comments on commit 3bcb8aa

Please sign in to comment.