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

Relay C++ Build Module #3082

Merged
merged 2 commits into from
May 8, 2019
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
Next Next commit
[Relay] C++ Build module
Bing Xu committed Apr 24, 2019
commit 6ea243ac777201302a4952a461a28c519331e784
6 changes: 5 additions & 1 deletion include/tvm/build_module.h
Original file line number Diff line number Diff line change
@@ -351,12 +351,16 @@ TVM_DLL Array<LoweredFunc> lower(Schedule sch,
* \param target The target device to build for.
* \param target_host The target for building host code. To use the default, pass Target()
* \param config The build configuration.
* \param (optional) returned host functions
* \param (optional) returned dev mods
* \return The built module.
*/
TVM_DLL runtime::Module build(const Array<LoweredFunc>& funcs,
const Target& target,
const Target& target_host,
const BuildConfig& config);
const BuildConfig& config,
Array<LoweredFunc>* fhost_ret = nullptr,
std::vector<runtime::Module>* devmod_ret = nullptr);
antinucleon marked this conversation as resolved.
Show resolved Hide resolved

class GenericFuncNode;

13 changes: 12 additions & 1 deletion src/codegen/build_module.cc
Original file line number Diff line number Diff line change
@@ -425,7 +425,9 @@ Array<LoweredFunc> lower(Schedule sch,
runtime::Module build(const Array<LoweredFunc>& funcs,
const Target& target,
const Target& target_host,
const BuildConfig& config) {
const BuildConfig& config,
Array<LoweredFunc>* fhost_ret,
std::vector<runtime::Module>* devmod_ret) {
std::unordered_set<std::string> all_names;
for (const auto &x : funcs) {
CHECK(all_names.count(x->name) == 0) << "Duplicate function name " << x->name;
@@ -464,6 +466,12 @@ runtime::Module build(const Array<LoweredFunc>& funcs,
}
}

if (fhost_ret != nullptr) {
for (auto f : fhost) {
fhost_ret->push_back(f);
}
}

auto keys = target->keys();
bool target_is_gpu =
std::find(keys.begin(), keys.end(), "gpu") != keys.end();
@@ -497,6 +505,9 @@ runtime::Module build(const Array<LoweredFunc>& funcs,

if (fdevice.size() > 0) {
auto mdev = codegen::Build(fdevice, target->str());
if (devmod_ret != nullptr) {
devmod_ret->push_back(mdev);
}
mhost.Import(mdev);
}

Loading