Skip to content

Commit

Permalink
Remove ext params stored in metadata from params to avoid duplication
Browse files Browse the repository at this point in the history
  • Loading branch information
Trevor Morris committed May 5, 2021
1 parent f85cab2 commit 8c7c205
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/relay/backend/build_module.cc
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,19 @@ class RelayBuildModule : public runtime::ModuleNode {
auto ext_mods = executor_codegen_->GetExternalModules();
ret_.mod = tvm::codegen::CreateMetadataModule(ret_.params, ret_.mod, ext_mods, GetTargetHost(),
executor_codegen_->GetMetadata());
// Remove external params which were stored in metadata module.
for (tvm::runtime::Module mod : ext_mods) {
auto pf_var = mod.GetFunction("get_const_vars");
if (pf_var != nullptr) {
Array<String> variables = pf_var();
for (size_t i = 0; i < variables.size(); i++) {
auto it = ret_.params.find(variables[i].operator std::string());
if (it != ret_.params.end()) {
ret_.params.erase(it);
}
}
}
}
}

private:
Expand Down

0 comments on commit 8c7c205

Please sign in to comment.