Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return empty CSourceModule when no lowered_funcs exists in Relay mod #4847

Merged
merged 13 commits into from
Mar 16, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 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>
kumasento marked this conversation as resolved.
Show resolved Hide resolved
#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,19 @@ 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, "
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to retain this warning? With external codegen, having no lowered funcs can be a perfectly normal mode of operation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @mbarrett97 , I've removed that log.

<< "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}));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is defaulting the LLVM the correct behaviour here (eg. will this fall over if we build without LLVM support)?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think should set target_host_. Even we have LLVM support, it is not correct too, imagine our target host is ARM.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you guys for your kind comments. We don't need to set target in the latest commit.

}

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