diff --git a/src/relay/backend/build_module.cc b/src/relay/backend/build_module.cc index 20e760f9956b..4cf13a3d21a2 100644 --- a/src/relay/backend/build_module.cc +++ b/src/relay/backend/build_module.cc @@ -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 tctx(kv.second); - relay_module = seq(relay_module); - } + const auto& it = targets.begin(); + With tctx((*it).second); + relay_module = seq(relay_module); } else { relay_module = seq(relay_module); } diff --git a/src/relay/backend/vm/compiler.cc b/src/relay/backend/vm/compiler.cc index 49079fbc107e..013d8b02dfa2 100644 --- a/src/relay/backend/vm/compiler.cc +++ b/src/relay/backend/vm/compiler.cc @@ -897,10 +897,9 @@ Module VMCompiler::OptimizeModule(const Module& mod, const TargetsMap& targets) // TODO(wweic): Support heterogenous execution tvm::With ctx(pass_ctx); if (targets.size() == 1) { - for (const auto& kv : targets) { - With tctx(kv.second); - return seq(mod); - } + const auto& it = targets.begin(); + With tctx((*it).second); + return seq(mod); } return seq(mod); }