Skip to content

Commit

Permalink
[relay] Small refactor for context (#4091)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhiics authored and tqchen committed Oct 9, 2019
1 parent 3a32729 commit c12275e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
7 changes: 3 additions & 4 deletions src/relay/backend/build_module.cc
Original file line number Diff line number Diff line change
Expand Up @@ -328,10 +328,9 @@ class RelayBuildModule : public runtime::ModuleNode {
// Create a sequential pass and perform optimizations.
transform::Pass seq = transform::Sequential(pass_seqs);
if (targets.size() == 1) {
for (const auto& kv : targets) {
With<Target> tctx(kv.second);
relay_module = seq(relay_module);
}
const auto& it = targets.begin();
With<Target> tctx((*it).second);
relay_module = seq(relay_module);
} else {
relay_module = seq(relay_module);
}
Expand Down
7 changes: 3 additions & 4 deletions src/relay/backend/vm/compiler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -897,10 +897,9 @@ Module VMCompiler::OptimizeModule(const Module& mod, const TargetsMap& targets)
// TODO(wweic): Support heterogenous execution
tvm::With<relay::transform::PassContext> ctx(pass_ctx);
if (targets.size() == 1) {
for (const auto& kv : targets) {
With<Target> tctx(kv.second);
return seq(mod);
}
const auto& it = targets.begin();
With<Target> tctx((*it).second);
return seq(mod);
}
return seq(mod);
}
Expand Down

0 comments on commit c12275e

Please sign in to comment.